Merge tag 'mips-pull-2019-02-01' of git://git.denx.de/u-boot-mips
[oweals/u-boot.git] / arch / arm / mach-omap2 / am33xx / board.c
index f5f2bd5308b8c12886167b830750572126f5ccbf..62158a9592521a42f7ebc07c6cc7340c62177130 100644 (file)
@@ -19,6 +19,7 @@
 #include <asm/arch/ddr_defs.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/i2c.h>
 #include <asm/arch/mem.h>
 #include <asm/arch/mmc_host_def.h>
 #include <asm/arch/sys_proto.h>
@@ -93,6 +94,20 @@ U_BOOT_DEVICES(am33xx_uarts) = {
 #  endif
 };
 
+#ifdef CONFIG_DM_I2C
+static const struct omap_i2c_platdata am33xx_i2c[] = {
+       { I2C_BASE1, 100000, OMAP_I2C_REV_V2},
+       { I2C_BASE2, 100000, OMAP_I2C_REV_V2},
+       { I2C_BASE3, 100000, OMAP_I2C_REV_V2},
+};
+
+U_BOOT_DEVICES(am33xx_i2c) = {
+       { "i2c_omap", &am33xx_i2c[0] },
+       { "i2c_omap", &am33xx_i2c[1] },
+       { "i2c_omap", &am33xx_i2c[2] },
+};
+#endif
+
 #ifdef CONFIG_DM_GPIO
 static const struct omap_gpio_platdata am33xx_gpio[] = {
        { 0, AM33XX_GPIO0_BASE },
@@ -159,7 +174,55 @@ int cpu_mmc_init(bd_t *bis)
 /* AM33XX has two MUSB controllers which can be host or gadget */
 #if (defined(CONFIG_USB_MUSB_GADGET) || defined(CONFIG_USB_MUSB_HOST)) && \
        (defined(CONFIG_AM335X_USB0) || defined(CONFIG_AM335X_USB1)) && \
-       (!defined(CONFIG_DM_USB))
+       (!CONFIG_IS_ENABLED(DM_USB) || !CONFIG_IS_ENABLED(OF_CONTROL)) && \
+       (!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_MUSB_NEW_SUPPORT))
+
+static struct musb_hdrc_config musb_config = {
+       .multipoint     = 1,
+       .dyn_fifo       = 1,
+       .num_eps        = 16,
+       .ram_bits       = 12,
+};
+
+#if CONFIG_IS_ENABLED(DM_USB) && !CONFIG_IS_ENABLED(OF_CONTROL)
+static struct ti_musb_platdata usb0 = {
+       .base = (void *)USB0_OTG_BASE,
+       .ctrl_mod_base = &((struct ctrl_dev *)CTRL_DEVICE_BASE)->usb_ctrl0,
+       .plat = {
+               .config         = &musb_config,
+               .power          = 50,
+               .platform_ops   = &musb_dsps_ops,
+               },
+};
+
+static struct ti_musb_platdata usb1 = {
+       .base = (void *)USB1_OTG_BASE,
+       .ctrl_mod_base = &((struct ctrl_dev *)CTRL_DEVICE_BASE)->usb_ctrl1,
+       .plat = {
+               .config         = &musb_config,
+               .power          = 50,
+               .platform_ops   = &musb_dsps_ops,
+               },
+};
+
+U_BOOT_DEVICES(am33xx_usbs) = {
+#if CONFIG_AM335X_USB0_MODE == MUSB_PERIPHERAL
+       { "ti-musb-peripheral", &usb0 },
+#elif CONFIG_AM335X_USB0_MODE == MUSB_HOST
+       { "ti-musb-host", &usb0 },
+#endif
+#if CONFIG_AM335X_USB1_MODE == MUSB_PERIPHERAL
+       { "ti-musb-peripheral", &usb1 },
+#elif CONFIG_AM335X_USB1_MODE == MUSB_HOST
+       { "ti-musb-host", &usb1 },
+#endif
+};
+
+int arch_misc_init(void)
+{
+       return 0;
+}
+#else
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
 /* USB 2.0 PHY Control */
@@ -178,13 +241,6 @@ static void am33xx_usb_set_phy_power(u8 on, u32 *reg_addr)
        }
 }
 
-static struct musb_hdrc_config musb_config = {
-       .multipoint     = 1,
-       .dyn_fifo       = 1,
-       .num_eps        = 16,
-       .ram_bits       = 12,
-};
-
 #ifdef CONFIG_AM335X_USB0
 static void am33xx_otg0_set_phy_power(struct udevice *dev, u8 on)
 {
@@ -235,6 +291,7 @@ int arch_misc_init(void)
 #endif
        return 0;
 }
+#endif
 
 #else  /* CONFIG_USB_MUSB_* && CONFIG_AM335X_USB* && !CONFIG_DM_USB */
 
@@ -457,12 +514,15 @@ void early_system_init(void)
 #ifdef CONFIG_DEBUG_UART_OMAP
        debug_uart_init();
 #endif
-#ifdef CONFIG_TI_I2C_BOARD_DETECT
-       do_board_detect();
-#endif
+
 #ifdef CONFIG_SPL_BUILD
        spl_early_init();
 #endif
+
+#ifdef CONFIG_TI_I2C_BOARD_DETECT
+       do_board_detect();
+#endif
+
 #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC)
        /* Enable RTC32K clock */
        rtc32k_enable();