]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: omap3: Move to driver model for GPIO and serial
authorSimon Glass <sjg@chromium.org>
Thu, 23 Oct 2014 03:37:15 +0000 (21:37 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 24 Oct 2014 01:29:07 +0000 (19:29 -0600)
Adjust the configuration for the am33xx boards, including beagleboard,
to use driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Tom Rini <trini@ti.com>
arch/arm/cpu/armv7/omap3/board.c
board/isee/igep00x0/igep00x0.c
board/logicpd/zoom1/zoom1.c
board/overo/overo.c
board/ti/beagle/beagle.c
board/ti/beagle/led.c
include/configs/ti_omap3_common.h

index 667e77ff05ba22429fdf101e0884856e5eb54e62..e6996b50f6b91e3bc5561bb7e3b1cab7a57e252e 100644 (file)
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
 #include <spl.h>
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/mem.h>
 #include <asm/cache.h>
 #include <asm/armv7.h>
-#include <asm/arch/gpio.h>
+#include <asm/gpio.h>
 #include <asm/omap_common.h>
 #include <asm/arch/mmc_host_def.h>
 #include <i2c.h>
@@ -38,6 +39,27 @@ static void omap3_setup_aux_cr(void);
 static void omap3_invalidate_l2_cache_secure(void);
 #endif
 
+#ifdef CONFIG_DM_GPIO
+static const struct omap_gpio_platdata omap34xx_gpio[] = {
+       { 0, OMAP34XX_GPIO1_BASE, METHOD_GPIO_24XX },
+       { 1, OMAP34XX_GPIO2_BASE, METHOD_GPIO_24XX },
+       { 2, OMAP34XX_GPIO3_BASE, METHOD_GPIO_24XX },
+       { 3, OMAP34XX_GPIO4_BASE, METHOD_GPIO_24XX },
+       { 4, OMAP34XX_GPIO5_BASE, METHOD_GPIO_24XX },
+       { 5, OMAP34XX_GPIO6_BASE, METHOD_GPIO_24XX },
+};
+
+U_BOOT_DEVICES(am33xx_gpios) = {
+       { "gpio_omap", &omap34xx_gpio[0] },
+       { "gpio_omap", &omap34xx_gpio[1] },
+       { "gpio_omap", &omap34xx_gpio[2] },
+       { "gpio_omap", &omap34xx_gpio[3] },
+       { "gpio_omap", &omap34xx_gpio[4] },
+       { "gpio_omap", &omap34xx_gpio[5] },
+};
+
+#else
+
 static const struct gpio_bank gpio_bank_34xx[6] = {
        { (void *)OMAP34XX_GPIO1_BASE, METHOD_GPIO_24XX },
        { (void *)OMAP34XX_GPIO2_BASE, METHOD_GPIO_24XX },
@@ -49,6 +71,8 @@ static const struct gpio_bank gpio_bank_34xx[6] = {
 
 const struct gpio_bank *const omap_gpio_bank = gpio_bank_34xx;
 
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 /*
 * We use static variables because global data is not ready yet.
index 3b2b1f15b8e9647fe0fc72efee1e8f78fa11b588..7b87cc27c41b4e517753342202f240e7ff5668b4 100644 (file)
@@ -5,6 +5,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
+#include <ns16550.h>
 #include <twl4030.h>
 #include <netdev.h>
 #include <asm/gpio.h>
@@ -30,6 +32,17 @@ static const u32 gpmc_lan_config[] = {
 };
 #endif
 
+static const struct ns16550_platdata igep_serial = {
+       OMAP34XX_UART3,
+       2,
+       V_NS16550_CLK
+};
+
+U_BOOT_DEVICE(igep_uart) = {
+       "serial_omap",
+       &igep_serial
+};
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
index 461a852724eb6d7a76dd79d785599a26300a8fcb..9ef002637a665f7e405e5873bddee8f640da49af 100644 (file)
@@ -15,6 +15,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
+#include <ns16550.h>
 #include <netdev.h>
 #include <twl4030.h>
 #include <asm/io.h>
@@ -41,6 +43,17 @@ static const u32 gpmc_lab_enet[] = {
        /*CONF7- computed as params */
 };
 
+static const struct ns16550_platdata zoom1_serial = {
+       OMAP34XX_UART3,
+       2,
+       V_NS16550_CLK
+};
+
+U_BOOT_DEVICE(zoom1_uart) = {
+       "serial_omap",
+       &zoom1_serial
+};
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
index 13220c56dd0634dc8a1cee9538fda0dafae2302c..7506820e349f4174679a9d58ee293831c4cc6da2 100644 (file)
@@ -13,6 +13,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
+#include <ns16550.h>
 #include <netdev.h>
 #include <twl4030.h>
 #include <linux/mtd/nand.h>
@@ -73,6 +75,17 @@ static const u32 gpmc_lan_config[] = {
     /*CONFIG7- computed as params */
 };
 
+static const struct ns16550_platdata overo_serial = {
+       OMAP34XX_UART3,
+       2,
+       V_NS16550_CLK
+};
+
+U_BOOT_DEVICE(overo_uart) = {
+       "serial_omap",
+       &overo_serial
+};
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
index 94b99bf53762660406c1dd1d87d1b9694d5a5625..4c5e38136fd55c542c52379285d0e42237e2cda2 100644 (file)
@@ -14,6 +14,8 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
+#include <ns16550.h>
 #ifdef CONFIG_STATUS_LED
 #include <status_led.h>
 #endif
@@ -70,6 +72,17 @@ static struct {
        char env_setting[64];
 } expansion_config;
 
+static const struct ns16550_platdata beagle_serial = {
+       OMAP34XX_UART3,
+       2,
+       V_NS16550_CLK
+};
+
+U_BOOT_DEVICE(beagle_uart) = {
+       "serial_omap",
+       &beagle_serial
+};
+
 /*
  * Routine: board_init
  * Description: Early hardware init.
@@ -103,22 +116,22 @@ int board_init(void)
  */
 static int get_board_revision(void)
 {
-       int revision;
-
-       if (!gpio_request(171, "") &&
-           !gpio_request(172, "") &&
-           !gpio_request(173, "")) {
-
-               gpio_direction_input(171);
-               gpio_direction_input(172);
-               gpio_direction_input(173);
-
-               revision = gpio_get_value(173) << 2 |
-                          gpio_get_value(172) << 1 |
-                          gpio_get_value(171);
-       } else {
-               printf("Error: unable to acquire board revision GPIOs\n");
-               revision = -1;
+       static int revision = -1;
+
+       if (revision == -1) {
+               if (!gpio_request(171, "rev0") &&
+                   !gpio_request(172, "rev1") &&
+                   !gpio_request(173, "rev2")) {
+                       gpio_direction_input(171);
+                       gpio_direction_input(172);
+                       gpio_direction_input(173);
+
+                       revision = gpio_get_value(173) << 2 |
+                               gpio_get_value(172) << 1 |
+                               gpio_get_value(171);
+               } else {
+                       printf("Error: unable to acquire board revision GPIOs\n");
+               }
        }
 
        return revision;
@@ -258,7 +271,7 @@ static void beagle_dvi_pup(void)
        case REVISION_AXBX:
        case REVISION_CX:
        case REVISION_C4:
-               gpio_request(170, "");
+               gpio_request(170, "dvi");
                gpio_direction_output(170, 0);
                gpio_set_value(170, 1);
                break;
index 89b8dd3c3c1ee015be657b27372bc5c2176cc634..a913a4c84aa624453138ce0ad6fa8180db61fc1b 100644 (file)
@@ -27,47 +27,46 @@ void green_led_on(void)
 }
 #endif
 
+static int get_led_gpio(led_id_t mask)
+{
+#ifdef STATUS_LED_BIT
+       if (STATUS_LED_BIT & mask)
+               return BEAGLE_LED_USR0;
+#endif
+#ifdef STATUS_LED_BIT1
+       if (STATUS_LED_BIT1 & mask)
+               return BEAGLE_LED_USR1;
+#endif
+
+       return 0;
+}
+
 void __led_init (led_id_t mask, int state)
 {
-       __led_set (mask, state);
+       int toggle_gpio;
+
+       toggle_gpio = get_led_gpio(mask);
+
+       if (toggle_gpio && !gpio_request(toggle_gpio, "led"))
+               __led_set(mask, state);
 }
 
 void __led_toggle (led_id_t mask)
 {
-       int state, toggle_gpio = 0;
-#ifdef STATUS_LED_BIT
-       if (!toggle_gpio && STATUS_LED_BIT & mask)
-               toggle_gpio = BEAGLE_LED_USR0;
-#endif
-#ifdef STATUS_LED_BIT1
-       if (!toggle_gpio && STATUS_LED_BIT1 & mask)
-               toggle_gpio = BEAGLE_LED_USR1;
-#endif
+       int state, toggle_gpio;
+
+       toggle_gpio = get_led_gpio(mask);
        if (toggle_gpio) {
-               if (!gpio_request(toggle_gpio, "")) {
-                       gpio_direction_output(toggle_gpio, 0);
-                       state = gpio_get_value(toggle_gpio);
-                       gpio_set_value(toggle_gpio, !state);
-               }
+               state = gpio_get_value(toggle_gpio);
+               gpio_direction_output(toggle_gpio, !state);
        }
 }
 
 void __led_set (led_id_t mask, int state)
 {
-#ifdef STATUS_LED_BIT
-       if (STATUS_LED_BIT & mask) {
-               if (!gpio_request(BEAGLE_LED_USR0, "")) {
-                       gpio_direction_output(BEAGLE_LED_USR0, 0);
-                       gpio_set_value(BEAGLE_LED_USR0, state);
-               }
-       }
-#endif
-#ifdef STATUS_LED_BIT1
-       if (STATUS_LED_BIT1 & mask) {
-               if (!gpio_request(BEAGLE_LED_USR1, "")) {
-                       gpio_direction_output(BEAGLE_LED_USR1, 0);
-                       gpio_set_value(BEAGLE_LED_USR1, state);
-               }
-       }
-#endif
+       int toggle_gpio;
+
+       toggle_gpio = get_led_gpio(mask);
+       if (toggle_gpio)
+               gpio_direction_output(toggle_gpio, state);
 }
index 3b19d3d6baf4c46f7a930e5c74c7e1afdea1f6a3..3c634ee680d02143b69fa0534143f28705b1a36b 100644 (file)
 #include <asm/arch/cpu.h>
 #include <asm/arch/omap3.h>
 
+#ifndef CONFIG_SPL_BUILD
+# define CONFIG_DM
+# define CONFIG_CMD_DM
+# define CONFIG_DM_GPIO
+# define CONFIG_DM_SERIAL
+# define CONFIG_OMAP_SERIAL
+# define CONFIG_SYS_MALLOC_F_LEN       (1 << 10)
+#endif
+
 /* The chip has SDRC controller */
 #define CONFIG_SDRC
 
 /* NS16550 Configuration */
 #define V_NS16550_CLK                  48000000        /* 48MHz (APLL96/2) */
 #define CONFIG_SYS_NS16550
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE    (-4)
-#define CONFIG_SYS_NS16550_CLK         V_NS16550_CLK
+#ifdef CONFIG_SPL_BUILD
+# define CONFIG_SYS_NS16550_SERIAL
+# define CONFIG_SYS_NS16550_REG_SIZE   (-4)
+# define CONFIG_SYS_NS16550_CLK                V_NS16550_CLK
+#endif
 #define CONFIG_SYS_BAUDRATE_TABLE      {4800, 9600, 19200, 38400, 57600, \
                                        115200}
 
 /* Select serial console configuration */
 #define CONFIG_CONS_INDEX              3
+#ifdef CONFIG_SPL_BUILD
 #define CONFIG_SYS_NS16550_COM3                OMAP34XX_UART3
 #define CONFIG_SERIAL3                 3
+#endif
 
 /* Physical Memory Map */
 #define PHYS_SDRAM_1           OMAP34XX_SDRC_CS0