From 0131162439508801b9f8a330fa731f04273c9337 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:52:46 +0100 Subject: dm: usb: create a new UCLASS ID for USB gadget devices UCLASS_USB_DEV_GENERIC was meant for USB devices connected to host controllers, not gadget devices. Adding a new UCLASS for gadget devices alone. Also move the generic DM code for USB gadgets in a separate file for clarity. Signed-off-by: Jean-Jacques Hiblot --- board/sunxi/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'board') diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 64ccbc7245..9b36cc76de 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -663,7 +663,7 @@ int g_dnl_board_usb_cable_connected(void) struct phy phy; int ret; - ret = uclass_get_device(UCLASS_USB_DEV_GENERIC, 0, &dev); + ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, 0, &dev); if (ret) { pr_err("%s: Cannot find USB device\n", __func__); return ret; -- cgit v1.2.3 From 24e261b39cc7d1abf3b03f5a554423cc1d27a986 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:57:41 +0100 Subject: board: ti: dra7xx-evm: turn on USB clocks in late init stage For USB ports that use the Driver Model, turn on the clocks during the late init stage. Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini --- board/ti/dra7xx/evm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'board') diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c index bbe54450ae..b46bda2579 100644 --- a/board/ti/dra7xx/evm.c +++ b/board/ti/dra7xx/evm.c @@ -646,6 +646,19 @@ int dram_init_banksize(void) return 0; } +#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL) +static int device_okay(const char *path) +{ + int node; + + node = fdt_path_offset(gd->fdt_blob, path); + if (node < 0) + return 0; + + return fdtdec_get_is_enabled(gd->fdt_blob, node); +} +#endif + int board_late_init(void) { #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG @@ -684,6 +697,12 @@ int board_late_init(void) */ if (board_is_dra71x_evm()) palmas_i2c_write_u8(LP873X_I2C_SLAVE_ADDR, 0x9, 0x7); +#endif +#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL) + if (device_okay("/ocp/omap_dwc3_1@48880000")) + enable_usb_clocks(0); + if (device_okay("/ocp/omap_dwc3_2@488c0000")) + enable_usb_clocks(1); #endif return 0; } -- cgit v1.2.3 From c3cd5fc870ab4c89316c5caeb8f6f09088e44956 Mon Sep 17 00:00:00 2001 From: Vignesh R Date: Thu, 29 Nov 2018 10:57:42 +0100 Subject: board; ti: am57xx: turn on USB clocks Enable USB clocks in late init stage to support ports under DM_USB. Signed-off-by: Vignesh R Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini --- board/ti/am57xx/board.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'board') diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c index 177a3246c3..8c24d17123 100644 --- a/board/ti/am57xx/board.c +++ b/board/ti/am57xx/board.c @@ -675,6 +675,19 @@ out: return; } +#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL) +static int device_okay(const char *path) +{ + int node; + + node = fdt_path_offset(gd->fdt_blob, path); + if (node < 0) + return 0; + + return fdtdec_get_is_enabled(gd->fdt_blob, node); +} +#endif + int board_late_init(void) { setup_board_eeprom_env(); @@ -714,6 +727,12 @@ int board_late_init(void) board_ti_set_ethaddr(2); #endif +#if CONFIG_IS_ENABLED(DM_USB) && CONFIG_IS_ENABLED(OF_CONTROL) + if (device_okay("/ocp/omap_dwc3_1@48880000")) + enable_usb_clocks(0); + if (device_okay("/ocp/omap_dwc3_2@488c0000")) + enable_usb_clocks(1); +#endif return 0; } -- cgit v1.2.3 From b491afa0f3c0df88027b08f18934cc034c40d659 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:57:44 +0100 Subject: configs: enable DM_USB and DM_USB_DEV for all DRA7 platforms Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini --- board/ti/dra7xx/evm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'board') diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c index b46bda2579..0ddca29ae6 100644 --- a/board/ti/dra7xx/evm.c +++ b/board/ti/dra7xx/evm.c @@ -915,7 +915,7 @@ const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr) } #endif -#ifdef CONFIG_USB_DWC3 +#if defined(CONFIG_USB_DWC3) && !CONFIG_IS_ENABLED(DM_USB) static struct dwc3_device usb_otg_ss1 = { .maximum_speed = USB_SPEED_SUPER, .base = DRA7_USB_OTG_SS1_BASE, -- cgit v1.2.3 From aec0081093e74caf5f3661b7e6a302d07c352d67 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:57:45 +0100 Subject: configs: am57xx_evm: Enable DM_USB and DM_USB_DEV Enable DM_USB and DM_USB_DEV for AM57xx based boards. Signed-off-by: Vignesh R Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini --- board/ti/am57xx/board.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'board') diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c index 8c24d17123..bed2eb3c39 100644 --- a/board/ti/am57xx/board.c +++ b/board/ti/am57xx/board.c @@ -883,7 +883,7 @@ int spl_start_uboot(void) } #endif -#ifdef CONFIG_USB_DWC3 +#if defined(CONFIG_USB_DWC3) && !CONFIG_IS_ENABLED(DM_USB) static struct dwc3_device usb_otg_ss2 = { .maximum_speed = USB_SPEED_HIGH, .base = DRA7_USB_OTG_SS2_BASE, @@ -912,9 +912,7 @@ int usb_gadget_handle_interrupts(int index) return 0; } -#endif /* CONFIG_USB_DWC3 */ -#if defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP) int board_usb_init(int index, enum usb_init_type init) { enable_usb_clocks(index); -- cgit v1.2.3 From 6b3b0bf99f0d5e82cb247c28ef4e86da7ddb8990 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:57:46 +0100 Subject: board: ti: dra7-evm: remove USB platform code Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini --- board/ti/dra7xx/evm.c | 104 -------------------------------------------------- 1 file changed, 104 deletions(-) (limited to 'board') diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c index 0ddca29ae6..d69641e3a0 100644 --- a/board/ti/dra7xx/evm.c +++ b/board/ti/dra7xx/evm.c @@ -915,110 +915,6 @@ const struct mmc_platform_fixups *platform_fixups_mmc(uint32_t addr) } #endif -#if defined(CONFIG_USB_DWC3) && !CONFIG_IS_ENABLED(DM_USB) -static struct dwc3_device usb_otg_ss1 = { - .maximum_speed = USB_SPEED_SUPER, - .base = DRA7_USB_OTG_SS1_BASE, - .tx_fifo_resize = false, - .index = 0, -}; - -static struct dwc3_omap_device usb_otg_ss1_glue = { - .base = (void *)DRA7_USB_OTG_SS1_GLUE_BASE, - .utmi_mode = DWC3_OMAP_UTMI_MODE_SW, - .index = 0, -}; - -static struct ti_usb_phy_device usb_phy1_device = { - .pll_ctrl_base = (void *)DRA7_USB3_PHY1_PLL_CTRL, - .usb2_phy_power = (void *)DRA7_USB2_PHY1_POWER, - .usb3_phy_power = (void *)DRA7_USB3_PHY1_POWER, - .index = 0, -}; - -static struct dwc3_device usb_otg_ss2 = { - .maximum_speed = USB_SPEED_SUPER, - .base = DRA7_USB_OTG_SS2_BASE, - .tx_fifo_resize = false, - .index = 1, -}; - -static struct dwc3_omap_device usb_otg_ss2_glue = { - .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE, - .utmi_mode = DWC3_OMAP_UTMI_MODE_SW, - .index = 1, -}; - -static struct ti_usb_phy_device usb_phy2_device = { - .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER, - .index = 1, -}; - -int board_usb_init(int index, enum usb_init_type init) -{ - enable_usb_clocks(index); - switch (index) { - case 0: - if (init == USB_INIT_DEVICE) { - usb_otg_ss1.dr_mode = USB_DR_MODE_PERIPHERAL; - usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID; - } else { - usb_otg_ss1.dr_mode = USB_DR_MODE_HOST; - usb_otg_ss1_glue.vbus_id_status = OMAP_DWC3_ID_GROUND; - } - - ti_usb_phy_uboot_init(&usb_phy1_device); - dwc3_omap_uboot_init(&usb_otg_ss1_glue); - dwc3_uboot_init(&usb_otg_ss1); - break; - case 1: - if (init == USB_INIT_DEVICE) { - usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL; - usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID; - } else { - usb_otg_ss2.dr_mode = USB_DR_MODE_HOST; - usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_ID_GROUND; - } - - ti_usb_phy_uboot_init(&usb_phy2_device); - dwc3_omap_uboot_init(&usb_otg_ss2_glue); - dwc3_uboot_init(&usb_otg_ss2); - break; - default: - printf("Invalid Controller Index\n"); - } - - return 0; -} - -int board_usb_cleanup(int index, enum usb_init_type init) -{ - switch (index) { - case 0: - case 1: - ti_usb_phy_uboot_exit(index); - dwc3_uboot_exit(index); - dwc3_omap_uboot_exit(index); - break; - default: - printf("Invalid Controller Index\n"); - } - disable_usb_clocks(index); - return 0; -} - -int usb_gadget_handle_interrupts(int index) -{ - u32 status; - - status = dwc3_omap_uboot_interrupt_status(index); - if (status) - dwc3_uboot_handle_interrupt(index); - - return 0; -} -#endif - #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_OS_BOOT) int spl_start_uboot(void) { -- cgit v1.2.3 From 532ededd5cbff3d55e8c8e5b6377cec9e90f2152 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 29 Nov 2018 10:57:47 +0100 Subject: board: ti: am57xx: remove USB platform code Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Tom Rini --- board/ti/am57xx/board.c | 85 ------------------------------------------------- 1 file changed, 85 deletions(-) (limited to 'board') diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c index bed2eb3c39..8dfb2eea43 100644 --- a/board/ti/am57xx/board.c +++ b/board/ti/am57xx/board.c @@ -883,91 +883,6 @@ int spl_start_uboot(void) } #endif -#if defined(CONFIG_USB_DWC3) && !CONFIG_IS_ENABLED(DM_USB) -static struct dwc3_device usb_otg_ss2 = { - .maximum_speed = USB_SPEED_HIGH, - .base = DRA7_USB_OTG_SS2_BASE, - .tx_fifo_resize = false, - .index = 1, -}; - -static struct dwc3_omap_device usb_otg_ss2_glue = { - .base = (void *)DRA7_USB_OTG_SS2_GLUE_BASE, - .utmi_mode = DWC3_OMAP_UTMI_MODE_SW, - .index = 1, -}; - -static struct ti_usb_phy_device usb_phy2_device = { - .usb2_phy_power = (void *)DRA7_USB2_PHY2_POWER, - .index = 1, -}; - -int usb_gadget_handle_interrupts(int index) -{ - u32 status; - - status = dwc3_omap_uboot_interrupt_status(index); - if (status) - dwc3_uboot_handle_interrupt(index); - - return 0; -} - -int board_usb_init(int index, enum usb_init_type init) -{ - enable_usb_clocks(index); - switch (index) { - case 0: - if (init == USB_INIT_DEVICE) { - printf("port %d can't be used as device\n", index); - disable_usb_clocks(index); - return -EINVAL; - } - break; - case 1: - if (init == USB_INIT_DEVICE) { -#ifdef CONFIG_USB_DWC3 - usb_otg_ss2.dr_mode = USB_DR_MODE_PERIPHERAL; - usb_otg_ss2_glue.vbus_id_status = OMAP_DWC3_VBUS_VALID; - ti_usb_phy_uboot_init(&usb_phy2_device); - dwc3_omap_uboot_init(&usb_otg_ss2_glue); - dwc3_uboot_init(&usb_otg_ss2); -#endif - } else { - printf("port %d can't be used as host\n", index); - disable_usb_clocks(index); - return -EINVAL; - } - - break; - default: - printf("Invalid Controller Index\n"); - } - - return 0; -} - -int board_usb_cleanup(int index, enum usb_init_type init) -{ -#ifdef CONFIG_USB_DWC3 - switch (index) { - case 0: - case 1: - if (init == USB_INIT_DEVICE) { - ti_usb_phy_uboot_exit(index); - dwc3_uboot_exit(index); - dwc3_omap_uboot_exit(index); - } - break; - default: - printf("Invalid Controller Index\n"); - } -#endif - disable_usb_clocks(index); - return 0; -} -#endif /* defined(CONFIG_USB_DWC3) || defined(CONFIG_USB_XHCI_OMAP) */ - #ifdef CONFIG_DRIVER_TI_CPSW /* Delay value to add to calibrated value */ -- cgit v1.2.3