Make mv_udc work for i.mx6
Subsystems (14)
v6 cover Make mv_udc work for i.mx6
Hi Marek
This series is based on u-boot-usb/next branch.
After this series, nitrogen6x works with tftpboot to transfer files over usb, and will recognize a usb stick in the OTG port.
This V6 has been rebased to the latest u-boot-usb/next branch and changed to address Marek comments.
The most noticeable change is the addition of patches to use enum usb_init_type.
Tested on a Nitrogen6x board with the following commands when connected to a USB2.0 hub and a USB1.1 hub
setenv ipaddr 10.0.0.2 && setenv netmask 255.255.255.0 && setenv serverip 10.0.0.1 setenv usbnet_devaddr 00:11:22:33:44:55 && setenv usbnet_hostaddr 00:aa:bb:cc:dd:ee setenv ethprime usb_ether && setenv ethact usb_ether && setenv ncip 10.0.0.1 tftpboot 10800000 10.0.0.1:uImage6w
The USB1.1 had a transfer rate of 687.5 KiB/s, the USB2.0 hub had a transfer rate of 5.4 MiB/s.
And by recognizing a usb stick in each port.
Troy Kisky (10):
usb: rename board_usb_init_type to usb_init_type
usb: add enum usb_init_type parameter to usb_lowlevel_init
usb: ehci-hcd: add enum usb_init_type parameter to ehci_hcd_init.
usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT
usb: ehci-mx6: add support for otg port
usb: gadget: mv_udc: fix full speed connections
usb: gadget: mv_udc: optimize bounce
usb: gadget: mv_udc: optimize ep_enable
usb: gadget: mv_udc: split mv_udc.h file
usb: udc: add udc.h include file
arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c | 2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c | 2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c | 2 +- arch/sparc/cpu/leon3/usb_uhci.c | 2 +- board/amcc/canyonlands/canyonlands.c | 4 +- board/balloon3/balloon3.c | 4 +- board/compulab/cm_t35/cm_t35.c | 3 +- board/esd/apc405/apc405.c | 4 +- board/esd/pmc440/pmc440.c | 4 +- board/htkw/mcx/mcx.c | 3 +- board/icpdas/lp8x4x/lp8x4x.c | 4 +- board/mpl/common/usb_uhci.c | 2 +- board/samsung/trats/trats.c | 2 +- board/technexion/twister/twister.c | 3 +- board/teejet/mt_ventoux/mt_ventoux.c | 3 +- board/ti/beagle/beagle.c | 3 +- board/ti/omap5_uevm/evm.c | 3 +- board/ti/panda/panda.c | 3 +- board/toradex/colibri_pxa270/colibri_pxa270.c | 4 +- board/trizepsiv/conxs.c | 4 +- board/vpac270/vpac270.c | 4 +- common/usb.c | 4 +- drivers/serial/usbtty.h | 3 +- drivers/usb/gadget/designware_udc.c | 1 + drivers/usb/gadget/mpc8xx_udc.c | 1 + drivers/usb/gadget/mv_udc.c | 101 +++++++++++-------- drivers/usb/gadget/mv_udc.h | 115 ++++++++++++++++++++++ drivers/usb/gadget/omap1510_udc.c | 1 + drivers/usb/gadget/pxa27x_udc.c | 1 + drivers/usb/host/ehci-armada100.c | 3 +- drivers/usb/host/ehci-atmel.c | 3 +- drivers/usb/host/ehci-exynos.c | 3 +- drivers/usb/host/ehci-faraday.c | 4 +- drivers/usb/host/ehci-fsl.c | 3 +- drivers/usb/host/ehci-hcd.c | 17 ++-- drivers/usb/host/ehci-ixp4xx.c | 3 +- drivers/usb/host/ehci-marvell.c | 3 +- drivers/usb/host/ehci-mpc512x.c | 3 +- drivers/usb/host/ehci-mx5.c | 3 +- drivers/usb/host/ehci-mx6.c | 134 ++++++++++++++++++-------- drivers/usb/host/ehci-mxc.c | 3 +- drivers/usb/host/ehci-mxs.c | 3 +- drivers/usb/host/ehci-pci.c | 4 +- drivers/usb/host/ehci-ppc4xx.c | 3 +- drivers/usb/host/ehci-spear.c | 3 +- drivers/usb/host/ehci-tegra.c | 3 +- drivers/usb/host/ehci-vct.c | 3 +- drivers/usb/host/ehci.h | 3 +- drivers/usb/host/isp116x-hcd.c | 2 +- drivers/usb/host/ohci-hcd.c | 2 +- drivers/usb/host/ohci-s3c24xx.c | 2 +- drivers/usb/host/r8a66597-hcd.c | 2 +- drivers/usb/host/sl811-hcd.c | 2 +- drivers/usb/host/xhci.c | 2 +- drivers/usb/musb-new/musb_uboot.c | 2 +- drivers/usb/musb/musb_hcd.c | 2 +- drivers/usb/musb/musb_udc.c | 3 +- include/configs/mx6qsabreauto.h | 3 +- include/configs/nitrogen6x.h | 3 +- include/usb.h | 28 +++--- include/usb/designware_udc.h | 31 ------ include/usb/mpc8xx_udc.h | 19 +--- include/usb/musb_udc.h | 40 -------- include/usb/mv_udc.h | 118 ----------------------- include/usb/omap1510_udc.h | 31 ++---- include/usb/pxa27x_udc.h | 26 +---- include/usb/udc.h | 53 ++++++++++ 67 files changed, 444 insertions(+), 423 deletions(-) create mode 100644 drivers/usb/gadget/mv_udc.h delete mode 100644 include/usb/musb_udc.h create mode 100644 include/usb/udc.h
Signature · 1 line
1.8.1.2
PATCH v6 1/10 usb: rename board_usb_init_type to usb_init_type
This will be used by usb_lowlevel_init so it will no longer be used by only board specific functions.
Move definition of enum usb_init_type higher in file so that it will be available for usb_low_level_init.
---
v6: new patch
--- board/amcc/canyonlands/canyonlands.c | 4 ++-- board/balloon3/balloon3.c | 4 ++-- board/esd/apc405/apc405.c | 4 ++-- board/esd/pmc440/pmc440.c | 4 ++-- board/icpdas/lp8x4x/lp8x4x.c | 4 ++-- board/samsung/trats/trats.c | 2 +- board/toradex/colibri_pxa270/colibri_pxa270.c | 4 ++-- board/trizepsiv/conxs.c | 4 ++-- board/vpac270/vpac270.c | 4 ++-- common/usb.c | 2 +- include/usb.h | 26 +++++++++++++------------- 11 files changed, 31 insertions(+), 31 deletions(-)
board/amcc/canyonlands/canyonlands.c +2 -2
@@ -189,7 +189,7 @@ int board_early_init_f(void) }#if defined(CONFIG_USB_OHCI_NEW ) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT ) -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) {struct board_bcsr *bcsr_data = (struct board_bcsr *)CONFIG_SYS_BCSR_BASE ;
@@ -230,7 +230,7 @@ int usb_board_stop(void)return 0 ; } -int board_usb_cleanup (int index,enum board_usb_init_type init) +int board_usb_cleanup (int index,enum usb_init_type init) {return usb_board_stop (); }
board/balloon3/balloon3.c +2 -2
@@ -60,7 +60,7 @@ void dram_init_banksize(void) }#ifdef CONFIG_CMD_USB -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) { writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) & ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
@@ -91,7 +91,7 @@ int board_usb_init(int index, enum board_usb_init_type init)return 0 ; } -int board_usb_cleanup (int index,enum board_usb_init_type init) +int board_usb_cleanup (int index,enum usb_init_type init) {return 0 ; }
board/esd/apc405/apc405.c +2 -2
@@ -429,7 +429,7 @@ void reset_phy(void) }#if defined(CONFIG_USB_OHCI_NEW ) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT ) -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) {return 0 ; }
@@ -454,7 +454,7 @@ int usb_board_stop(void)return 0 ; } -int board_usb_cleanup (int index,enum board_usb_init_type init) +int board_usb_cleanup (int index,enum usb_init_type init) {return usb_board_stop (); }
board/esd/pmc440/pmc440.c +2 -2
@@ -822,7 +822,7 @@ int bootstrap_eeprom_read (unsigned dev_addr, unsigned offset, }#if defined(CONFIG_USB_OHCI_NEW ) && defined(CONFIG_SYS_USB_OHCI_BOARD_INIT ) -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) {char *act =getenv ("usbact" );int i;
@@ -846,7 +846,7 @@ int usb_board_stop(void)return 0 ; } -int board_usb_cleanup (int index,enum board_usb_init_type init) +int board_usb_cleanup (int index,enum usb_init_type init) {return usb_board_stop (); }
board/icpdas/lp8x4x/lp8x4x.c +2 -2
@@ -59,7 +59,7 @@ int board_mmc_init(bd_t *bis)#endif #ifdef CONFIG_CMD_USB -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) { writel((UHCHR | UHCHR_PCPL | UHCHR_PSPL) & ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
@@ -90,7 +90,7 @@ int board_usb_init(int index, enum board_usb_init_type init)return 0 ; } -int board_usb_cleanup (int index,enum board_usb_init_type init) +int board_usb_cleanup (int index,enum usb_init_type init) {return 0 ; }
board/samsung/trats/trats.c +1 -1
@@ -496,7 +496,7 @@ struct s3c_plat_otg_data s5pc210_otg_data = { .usb_flags = PHY0_SLEEP, }; -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) {debug ("USB_udc_probe\n" );return s3c_udc_probe (&s5pc210_otg_data);
board/toradex/colibri_pxa270/colibri_pxa270.c +2 -2
@@ -40,7 +40,7 @@ int dram_init(void) }#ifdef CONFIG_CMD_USB -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) { writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) & ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
@@ -71,7 +71,7 @@ int board_usb_init(int index, enum board_usb_init_type init)return 0 ; } -int board_usb_cleanup (int index,enum board_usb_init_type init) +int board_usb_cleanup (int index,enum usb_init_type init) {return 0 ; }
board/trizepsiv/conxs.c +2 -2
@@ -43,7 +43,7 @@ extern struct serial_device serial_stuart_device;* Miscelaneous platform dependent initialisations */ -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) { writel((readl(UHCHR) | UHCHR_PCPL | UHCHR_PSPL) & ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
@@ -70,7 +70,7 @@ int board_usb_init(int index, enum board_usb_init_type init)return 0 ; } -int board_usb_cleanup (int index,enum board_usb_init_type init) +int board_usb_cleanup (int index,enum usb_init_type init) {return 0 ; }
board/vpac270/vpac270.c +2 -2
@@ -67,7 +67,7 @@ int board_mmc_init(bd_t *bis)#endif #ifdef CONFIG_CMD_USB -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) { writel((UHCHR | UHCHR_PCPL | UHCHR_PSPL) & ~(UHCHR_SSEP0 | UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE),
@@ -98,7 +98,7 @@ int board_usb_init(int index, enum board_usb_init_type init)return 0 ; } -int board_usb_cleanup (int index,enum board_usb_init_type init) +int board_usb_cleanup (int index,enum usb_init_type init) {return 0 ; }
common/usb.c +1 -1
@@ -1068,7 +1068,7 @@ int usb_new_device(struct usb_device *dev) }__weak -int board_usb_init (int index,enum board_usb_init_type init) +int board_usb_init (int index,enum usb_init_type init) {return 0 ; }
include/usb.h +13 -13
@@ -129,6 +129,16 @@ struct usb_device {unsigned int slot_id; }; +/* +* You can initialize platform's USB host or device +* ports by passing this enum as an argument to +* board_usb_init(). +*/ +enum usb_init_type { +USB_INIT_HOST , +USB_INIT_DEVICE +}; +/********************************************************************** * this is how the lowlevel part communicate with the outer world */
@@ -170,32 +180,22 @@ extern void udc_disconnect(void);#endif /* -* You can initialize platform's USB host or device -* ports by passing this enum as an argument to -* board_usb_init(). -*/ -enum board_usb_init_type { -USB_INIT_HOST , -USB_INIT_DEVICE -}; - -/* * board-specific hardware initialization, called by * usb drivers and u-boot commands * * @param index USB controller number * @param init initializes controller as USB host or device */ -int board_usb_init (int index,enum board_usb_init_type init); +int board_usb_init (int index,enum usb_init_type init);/* * can be used to clean up after failed USB initialization attempt * vide: board_usb_init() * * @param index USB controller number for selective cleanup -* @param init board_usb_init_type passed to board_usb_init() +* @param init usb_init_type passed to board_usb_init() */ -int board_usb_cleanup (int index,enum board_usb_init_type init); +int board_usb_cleanup (int index,enum usb_init_type init);#ifdef CONFIG_USB_STORAGE
Signature · 1 line
1.8.1.2
PATCH v6 2/10 usb: add enum usb_init_type parameter to usb_lowlevel_init
In reply to Troy KiskyThis parameter will later be used to verify OTG ports.
---
v6: new patch
--- arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c | 2 +- arch/powerpc/cpu/mpc5xxx/usb_ohci.c | 2 +- arch/powerpc/cpu/ppc4xx/usb_ohci.c | 2 +- arch/sparc/cpu/leon3/usb_uhci.c | 2 +- board/mpl/common/usb_uhci.c | 2 +- common/usb.c | 2 +- drivers/usb/gadget/mv_udc.c | 2 +- drivers/usb/host/ehci-hcd.c | 2 +- drivers/usb/host/isp116x-hcd.c | 2 +- drivers/usb/host/ohci-hcd.c | 2 +- drivers/usb/host/ohci-s3c24xx.c | 2 +- drivers/usb/host/r8a66597-hcd.c | 2 +- drivers/usb/host/sl811-hcd.c | 2 +- drivers/usb/host/xhci.c | 2 +- drivers/usb/musb-new/musb_uboot.c | 2 +- drivers/usb/musb/musb_hcd.c | 2 +- include/usb.h | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-)
arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c +1 -1
@@ -1548,7 +1548,7 @@ static void hc_release_ohci (ohci_t *ohci)*/ static char ohci_inited =0 ; -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {u32 pin_func;u32 sys_freqctrl, sys_clksrc;
arch/powerpc/cpu/mpc5xxx/usb_ohci.c +1 -1
@@ -1544,7 +1544,7 @@ static void hc_release_ohci (ohci_t *ohci)*/ static char ohci_inited =0 ; -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {/* Set the USB Clock */
arch/powerpc/cpu/ppc4xx/usb_ohci.c +1 -1
@@ -1549,7 +1549,7 @@ static void hc_release_ohci (ohci_t *ohci)*/ static char ohci_inited =0 ; -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {memset (&gohci,0 ,sizeof (ohci_t));memset (&urb_priv,0 ,sizeof (urb_priv_t));
arch/sparc/cpu/leon3/usb_uhci.c +1 -1
@@ -688,7 +688,7 @@ void handle_usb_interrupt(void)/* init uhci */ -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {unsigned char temp;ambapp_ahbdev ahbdev;
board/mpl/common/usb_uhci.c +1 -1
@@ -584,7 +584,7 @@ void handle_usb_interrupt(void)/* init uhci */ -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {unsigned char temp;int busdevfunc;
common/usb.c +1 -1
@@ -75,7 +75,7 @@ int usb_init(void)for (i =0 ; i <CONFIG_USB_MAX_CONTROLLER_COUNT ; i++) {/* init low_level USB */ printf ("USB%d: " , i); -if (usb_lowlevel_init (i, &ctrl)) { +if (usb_lowlevel_init (i,USB_INIT_HOST , &ctrl)) {puts ("lowlevel init failed\n" );continue ; }
drivers/usb/gadget/mv_udc.c +1 -1
@@ -692,7 +692,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)if (driver->speed !=USB_SPEED_FULL && driver->speed !=USB_SPEED_HIGH )return -EINVAL ; - ret =usb_lowlevel_init (0 , (void **)&controller.ctrl); + ret =usb_lowlevel_init (0 ,USB_INIT_DEVICE , (void **)&controller.ctrl);if (ret)return ret;
drivers/usb/host/ehci-hcd.c +1 -1
@@ -919,7 +919,7 @@ int usb_lowlevel_stop(int index)return ehci_hcd_stop (index); } -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {uint32_t reg;uint32_t cmd;
drivers/usb/host/isp116x-hcd.c +1 -1
@@ -1377,7 +1377,7 @@ int isp116x_check_id(struct isp116x *isp116x)return 0 ; } -int usb_lowlevel_init(int index, void **controller)) +int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)) {struct isp116x *isp116x = &isp116x_dev;
drivers/usb/host/ohci-hcd.c +1 -1
@@ -1847,7 +1847,7 @@ static void hc_release_ohci(ohci_t *ohci)*/ static char ohci_inited =0 ; -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {#ifdef CONFIG_PCI_OHCI pci_dev_t pdev;
drivers/usb/host/ohci-s3c24xx.c +1 -1
@@ -1642,7 +1642,7 @@ static void hc_release_ohci(struct ohci *ohci)*/ static char ohci_inited =0 ; -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {struct s3c24x0_clock_power *clk_power =s3c24x0_get_base_clock_power ();struct s3c24x0_gpio *gpio =s3c24x0_get_base_gpio ();
drivers/usb/host/r8a66597-hcd.c +1 -1
@@ -903,7 +903,7 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,return 0 ; } -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {struct r8a66597 *r8a66597 = &gr8a66597;
drivers/usb/host/sl811-hcd.c +1 -1
@@ -194,7 +194,7 @@ static int sl811_hc_reset(void)return 1 ; } -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) { root_hub_devnum =0 ;sl811_hc_reset ();
drivers/usb/host/xhci.c +1 -1
@@ -936,7 +936,7 @@ submit_control_msg(struct usb_device *udev, unsigned long pipe, void *buffer,* @param index index to the host controller data structure * @return pointer to the intialised controller */ -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {uint32_t val;uint32_t val2;
drivers/usb/musb-new/musb_uboot.c +1 -1
@@ -112,7 +112,7 @@ int submit_int_msg(struct usb_device *dev, unsigned long pipe,return submit_urb (&hcd, urb); } -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {u8 power;void *mbase;
drivers/usb/musb/musb_hcd.c +1 -1
@@ -1080,7 +1080,7 @@ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe,/* * This function initializes the usb controller module. */ -int usb_lowlevel_init (int index,void **controller) +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller) {u8 power;u32 timeout;
include/usb.h +1 -1
@@ -152,7 +152,7 @@ enum usb_init_type {defined (CONFIG_USB_MUSB_DSPS ) ||defined (CONFIG_USB_MUSB_AM35X ) || \ defined(CONFIG_USB_MUSB_OMAP2PLUS) || defined(CONFIG_USB_XHCI) -int usb_lowlevel_init (int index,void **controller); +int usb_lowlevel_init (int index,enum usb_init_type init,void **controller);int usb_lowlevel_stop (int index); int submit_bulk_msg(struct usb_device *dev, unsigned long pipe,
Signature · 1 line
1.8.1.2
PATCH v6 3/10 usb: ehci-hcd: add enum usb_init_type parameter to ehci_hcd_init.
In reply to Troy KiskyThis paramter will later be used to initialize OTG ports in host or device mode.
---
v6: new patch
--- board/compulab/cm_t35/cm_t35.c | 3 ++- board/htkw/mcx/mcx.c | 3 ++- board/technexion/twister/twister.c | 3 ++- board/teejet/mt_ventoux/mt_ventoux.c | 3 ++- board/ti/beagle/beagle.c | 3 ++- board/ti/omap5_uevm/evm.c | 3 ++- board/ti/panda/panda.c | 3 ++- drivers/usb/host/ehci-armada100.c | 3 ++- drivers/usb/host/ehci-atmel.c | 3 ++- drivers/usb/host/ehci-exynos.c | 3 ++- drivers/usb/host/ehci-faraday.c | 4 ++-- drivers/usb/host/ehci-fsl.c | 3 ++- drivers/usb/host/ehci-hcd.c | 15 ++++++++++----- drivers/usb/host/ehci-ixp4xx.c | 3 ++- drivers/usb/host/ehci-marvell.c | 3 ++- drivers/usb/host/ehci-mpc512x.c | 3 ++- drivers/usb/host/ehci-mx5.c | 3 ++- drivers/usb/host/ehci-mx6.c | 3 ++- drivers/usb/host/ehci-mxc.c | 3 ++- drivers/usb/host/ehci-mxs.c | 3 ++- drivers/usb/host/ehci-pci.c | 4 ++-- drivers/usb/host/ehci-ppc4xx.c | 3 ++- drivers/usb/host/ehci-spear.c | 3 ++- drivers/usb/host/ehci-tegra.c | 3 ++- drivers/usb/host/ehci-vct.c | 3 ++- drivers/usb/host/ehci.h | 3 ++- 26 files changed, 60 insertions(+), 32 deletions(-)
board/compulab/cm_t35/cm_t35.c +2 -1
@@ -565,7 +565,8 @@ struct omap_usbhs_board_data usbhs_bdata = { };#define SB_T35_USB_HUB_RESET_GPIO 167 -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {u8 val;int offset;
board/htkw/mcx/mcx.c +2 -1
@@ -40,7 +40,8 @@ static struct omap_usbhs_board_data usbhs_bdata = { .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, }; -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {return omap_ehci_hcd_init (index, &usbhs_bdata, hccr, hcor); }
board/technexion/twister/twister.c +2 -1
@@ -51,7 +51,8 @@ static struct omap_usbhs_board_data usbhs_bdata = { .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, }; -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {return omap_ehci_hcd_init (index, &usbhs_bdata, hccr, hcor); }
board/teejet/mt_ventoux/mt_ventoux.c +2 -1
@@ -102,7 +102,8 @@ static struct omap_usbhs_board_data usbhs_bdata = { .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, }; -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {return omap_ehci_hcd_init (index, &usbhs_bdata, hccr, hcor); }
board/ti/beagle/beagle.c +2 -1
@@ -521,7 +521,8 @@ static struct omap_usbhs_board_data usbhs_bdata = { .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED }; -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {return omap_ehci_hcd_init (index, &usbhs_bdata, hccr, hcor); }
board/ti/omap5_uevm/evm.c +2 -1
@@ -159,7 +159,8 @@ static struct omap_usbhs_board_data usbhs_bdata = { .port_mode[2] = OMAP_EHCI_PORT_MODE_HSIC, }; -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {int ret;int reg;
board/ti/panda/panda.c +2 -1
@@ -253,7 +253,8 @@ static struct omap_usbhs_board_data usbhs_bdata = { .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, }; -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {int ret;unsigned int utmi_clk;
drivers/usb/host/ehci-armada100.c +2 -1
@@ -22,7 +22,8 @@/* * EHCI host controller init */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {if (utmi_init () <0 )return -1 ;
drivers/usb/host/ehci-atmel.c +2 -1
@@ -21,7 +21,8 @@*/ #define EN_UPLL_TIMEOUT 500UL -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC ;ulong start_time, tmp_time;
drivers/usb/host/ehci-exynos.c +2 -1
@@ -141,7 +141,8 @@ static void reset_usb_phy(struct exynos_usb_phy *usb)* Create the appropriate control structures to manage * a new EHCI host controller. */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {struct exynos_ehci *ctx = &exynos;
drivers/usb/host/ehci-faraday.c +2 -2
@@ -33,8 +33,8 @@ static inline int ehci_is_fotg2xx(union ehci_faraday_regs *regs)* Create the appropriate control structures to manage * a new EHCI host controller. */ -int ehci_hcd_init (int index,struct ehci_hccr **ret_hccr, -struct ehci_hcor **ret_hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **ret_hccr,struct ehci_hcor **ret_hcor) {struct ehci_hccr *hccr;struct ehci_hcor *hcor;
drivers/usb/host/ehci-fsl.c +2 -1
@@ -35,7 +35,8 @@ static int usb_phy_clk_valid(struct usb_ehci *ehci)* * Excerpts from linux ehci fsl driver. */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {struct usb_ehci *ehci;const char *phy_type =NULL ;
drivers/usb/host/ehci-hcd.c +10 -5
@@ -926,17 +926,22 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)struct QH *qh_list;struct QH *periodic;int i; +int rc; -if (ehci_hcd_init (index, &ehcic[index].hccr, &ehcic[index].hcor)) -return -1 ; + rc =ehci_hcd_init (index, init, &ehcic[index].hccr, &ehcic[index].hcor); +if (rc) +return rc; +if (init ==USB_INIT_DEVICE ) + goto done;/* EHCI spec section 4.1 */ if (ehci_reset (index))return -1 ;#if defined(CONFIG_EHCI_HCD_INIT_AFTER_RESET ) -if (ehci_hcd_init (index, &ehcic[index].hccr, &ehcic[index].hcor)) -return -1 ; + rc =ehci_hcd_init (index, init, &ehcic[index].hccr, &ehcic[index].hcor); +if (rc) +return rc;#endif /* Set the high address word (aka segment) for 64-bit controller */ if (ehci_readl (&ehcic[index].hccr->cr_hccparams) &1 )
@@ -1037,7 +1042,7 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)printf ("USB EHCI %x.%02x\n" , reg >>8 , reg &0xff ); ehcic[index].rootdev =0 ; - +done: *controller = &ehcic[index];return 0 ; }
drivers/usb/host/ehci-ixp4xx.c +2 -1
@@ -14,7 +14,8 @@* Create the appropriate control structures to manage * a new EHCI host controller. */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) { *hccr = (struct ehci_hccr *)(0xcd000100 ); *hcor = (struct ehci_hcor *)((uint32_t) *hccr
drivers/usb/host/ehci-marvell.c +2 -1
@@ -74,7 +74,8 @@ static void usb_brg_adrdec_setup(void)* Create the appropriate control structures to manage * a new EHCI host controller. */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {usb_brg_adrdec_setup ();
drivers/usb/host/ehci-mpc512x.c +2 -1
@@ -32,7 +32,8 @@ static void usb_platform_dr_init(volatile struct usb_ehci *ehci);* This code is derived from EHCI FSL USB Linux driver for MPC5121 * */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {volatile struct usb_ehci *ehci;
drivers/usb/host/ehci-mx5.c +2 -1
@@ -218,7 +218,8 @@ void __weak board_ehci_hcd_postinit(struct usb_ehci *ehci, int port) { } -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {struct usb_ehci *ehci;
drivers/usb/host/ehci-mx6.c +2 -1
@@ -155,7 +155,8 @@ int __weak board_ehci_hcd_init(int port)return 0 ; } -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {struct usb_ehci *ehci;
drivers/usb/host/ehci-mxc.c +2 -1
@@ -208,7 +208,8 @@ static int mxc_set_usbcontrol(int port, unsigned int flags)return 0 ; } -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {struct usb_ehci *ehci;#ifdef CONFIG_MX31
drivers/usb/host/ehci-mxs.c +2 -1
@@ -77,7 +77,8 @@ static int ehci_mxs_toggle_clock(const struct ehci_mxs_port *port, int enable)return 0 ; } -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {int ret;
drivers/usb/host/ehci-pci.c +2 -2
@@ -69,8 +69,8 @@ static pci_dev_t ehci_find_class(int index)* Create the appropriate control structures to manage * a new EHCI host controller. */ -int ehci_hcd_init (int index,struct ehci_hccr **ret_hccr, -struct ehci_hcor **ret_hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **ret_hccr,struct ehci_hcor **ret_hcor) {pci_dev_t pdev;uint32_t cmd;
drivers/usb/host/ehci-ppc4xx.c +2 -1
@@ -15,7 +15,8 @@* Create the appropriate control structures to manage * a new EHCI host controller. */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) { *hccr = (struct ehci_hccr *)(CONFIG_SYS_PPC4XX_USB_ADDR ); *hcor = (struct ehci_hcor *)((uint32_t) *hccr +
drivers/usb/host/ehci-spear.c +2 -1
@@ -20,7 +20,8 @@* Create the appropriate control structures to manage * a new EHCI host controller. */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) { *hccr = (struct ehci_hccr *)(CONFIG_SYS_UHC0_EHCI_BASE +0x100 ); *hcor = (struct ehci_hcor *)((uint32_t)*hccr
drivers/usb/host/ehci-tegra.c +2 -1
@@ -734,7 +734,8 @@ int usb_process_devicetree(const void *blob)* @param hcor returns start address of EHCI HCOR registers * @return 0 if ok, -1 on error (generally invalid port number) */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {struct fdt_usb *config;struct usb_ctlr *usbctlr;
drivers/usb/host/ehci-vct.c +2 -1
@@ -15,7 +15,8 @@ int vct_ehci_hcd_init(u32 *hccr, u32 *hcor);* Create the appropriate control structures to manage * a new EHCI host controller. */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor) +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor) {int ret;u32 vct_hccr;
drivers/usb/host/ehci.h +2 -1
@@ -250,7 +250,8 @@ struct ehci_ctrl { };/* Low level init functions */ -int ehci_hcd_init (int index,struct ehci_hccr **hccr,struct ehci_hcor **hcor); +int ehci_hcd_init (int index,enum usb_init_type init, +struct ehci_hccr **hccr,struct ehci_hcor **hcor);int ehci_hcd_stop (int index);#endif /* USB_EHCI_H */
Signature · 1 line
1.8.1.2
PATCH v6 3/10 usb: ehci-hcd: add enum usb_init_type parameter to ehci_hcd_init.
Dear Troy Kisky,
Quoted 4 lines
This paramter will later be used to initialize OTG ports in host or device mode.
Signed-off-by Troy Kisky <[email protected]>
Might be worth to start consolidating this blowout of parameters into some larger structure to be passed to those functions.
Best regards,
Marek Vasut
PATCH v6 4/10 usb: gadget: mv_udc: don't check CONFIG_USB_MAX_CONTROLLER_COUNT
In reply to Troy Kiskyi.mx6 has 1 otg controller, and 3 host ports. So, CONFIG_USB_MAX_CONTROLLER_COUNT can be greater than 1 even though only 1 device mode controller is supported.
---
v4: new patch
v5: no change
v6: no change
--- drivers/usb/gadget/mv_udc.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/usb/gadget/mv_udc.c +0 -4
@@ -17,10 +17,6 @@#include <linux/types.h> #include <usb/mv_udc.h> -#if CONFIG_USB_MAX_CONTROLLER_COUNT >1 -#error This driver only supports one single controller. -#endif -/* * Check if the system has too long cachelines. If the cachelines are * longer then 128b, the driver will not be able flush/invalidate data
Signature · 1 line
1.8.1.2
PATCH v6 5/10 usb: ehci-mx6: add support for otg port
In reply to Troy KiskyPreviously, only host1 was supported using an index of 0. Now, otg has index 0, host1 is 1, host2 is 2, host3 is 3. Since OTG requires usbmode to be set after reset, I added CONFIG_EHCI_HCD_INIT_AFTER_RESET to nitrogen6x.h and mx6qsabreauto.h.
I also added a weak function board_ehci_power to handle turning power on/off for otg.
Type is type of device connected (USB stick vs Host.) Init is type of device desired.
Only power up port if type == init == USB_INIT_HOST. Only return error if type != init.
---
V4: new patch, replaces "usb: gadget: mv_udc: fix hardware udc address for i.MX6" and has the bonus of giving OTG host mode support
V5: use CONFIG_EHCI_HCD_INIT_AFTER_RESET instead of a weak function. Return error if otg_id is high.
V6: removed USBPHY_CTRL_OTD_ID_BIT and used a mask MACRO instead. Added unreferenced members to struct usbnc_regs and added comment Added device mode support as well
--- drivers/usb/host/ehci-mx6.c | 131 ++++++++++++++++++++++++++++------------ include/configs/mx6qsabreauto.h | 3 +- include/configs/nitrogen6x.h | 3 +- 3 files changed, 95 insertions(+), 42 deletions(-)
drivers/usb/host/ehci-mx6.c +91 -40
@@ -35,6 +35,7 @@#define USBPHY_CTRL_CLKGATE 0x40000000#define USBPHY_CTRL_ENUTMILEVEL3 0x00008000#define USBPHY_CTRL_ENUTMILEVEL2 0x00004000 +#define USBPHY_CTRL_OTG_ID 0x08000000#define ANADIG_USB2_CHRG_DETECT_EN_B 0x00100000#define ANADIG_USB2_CHRG_DETECT_CHK_CHRG_B 0x00080000
@@ -49,52 +50,84 @@#define UCTRL_OVER_CUR_DIS (1 << 7)/* Disable OTG Overcurrent Detection */ /* USBCMD */ -#define UH1_USBCMD_OFFSET 0x140#define UCMD_RUN_STOP (1 << 0)/* controller run/stop */ #define UCMD_RESET (1 << 1)/* controller reset */ -static void usbh1_internal_phy_clock_gate (int on) +static const unsigned phy_bases[] = { +USB_PHY0_BASE_ADDR , +USB_PHY1_BASE_ADDR , +}; + +static void usb_internal_phy_clock_gate (int index,int on) { -void __iomem *phy_reg = (void __iomem *)USB_PHY1_BASE_ADDR ; +void __iomem *phy_reg; + +if (index >=ARRAY_SIZE (phy_bases)) +return ; + phy_reg = (void __iomem *)phy_bases[index]; phy_reg += on ?USBPHY_CTRL_CLR :USBPHY_CTRL_SET ;__raw_writel (USBPHY_CTRL_CLKGATE , phy_reg); } -static void usbh1_power_config (void ) +static void usb_power_config (int index) {struct anatop_regs __iomem *anatop = (struct anatop_regs __iomem *)ANATOP_BASE_ADDR ; +void __iomem *chrg_detect; +void __iomem *pll_480_ctrl_clr; +void __iomem *pll_480_ctrl_set; + +switch (index) { +case 0 : + chrg_detect = &anatop->usb1_chrg_detect; + pll_480_ctrl_clr = &anatop->usb1_pll_480_ctrl_clr; + pll_480_ctrl_set = &anatop->usb1_pll_480_ctrl_set; +break ; +case 1 : + chrg_detect = &anatop->usb2_chrg_detect; + pll_480_ctrl_clr = &anatop->usb2_pll_480_ctrl_clr; + pll_480_ctrl_set = &anatop->usb2_pll_480_ctrl_set; +break ; +default : +return ; + }/* -* Some phy and power's special controls for host1 +* Some phy and power's special controls * 1. The external charger detector needs to be disabled * or the signal at DP will be poor -* 2. The PLL's power and output to usb for host 1 +* 2. The PLL's power and output to usb * is totally controlled by IC, so the Software only needs * to enable them at initializtion. */ __raw_writel (ANADIG_USB2_CHRG_DETECT_EN_B |ANADIG_USB2_CHRG_DETECT_CHK_CHRG_B , - &anatop->usb2_chrg_detect); + chrg_detect);__raw_writel (ANADIG_USB2_PLL_480_CTRL_BYPASS , - &anatop->usb2_pll_480_ctrl_clr); + pll_480_ctrl_clr);__raw_writel (ANADIG_USB2_PLL_480_CTRL_ENABLE |ANADIG_USB2_PLL_480_CTRL_POWER |ANADIG_USB2_PLL_480_CTRL_EN_USB_CLKS , - &anatop->usb2_pll_480_ctrl_set); + pll_480_ctrl_set); } -static int usbh1_phy_enable (void ) +/* Return 0 : host node, <>0 : device mode */ +static int usb_phy_enable (int index,struct usb_ehci *ehci) { -void __iomem *phy_reg = (void __iomem *)USB_PHY1_BASE_ADDR ; -void __iomem *phy_ctrl = (void __iomem *)(phy_reg +USBPHY_CTRL ); -void __iomem *usb_cmd = (void __iomem *)(USBOH3_USB_BASE_ADDR + -USB_H1REGS_OFFSET + -UH1_USBCMD_OFFSET ); +void __iomem *phy_reg; +void __iomem *phy_ctrl; +void __iomem *usb_cmd;u32 val; +if (index >=ARRAY_SIZE (phy_bases)) +return 0 ; + + phy_reg = (void __iomem *)phy_bases[index]; + phy_ctrl = (void __iomem *)(phy_reg +USBPHY_CTRL ); + usb_cmd = (void __iomem *)&ehci->usbcmd; +/* Stop then Reset */ val =__raw_readl (usb_cmd); val &= ~UCMD_RUN_STOP ;
@@ -123,31 +156,41 @@ static int usbh1_phy_enable(void)/* Power up the PHY */ __raw_writel (0 , phy_reg +USBPHY_PWD );/* enable FS/LS device */ - val =__raw_readl (phy_reg +USBPHY_CTRL ); + val =__raw_readl (phy_ctrl); val |= (USBPHY_CTRL_ENUTMILEVEL2 |USBPHY_CTRL_ENUTMILEVEL3 ); -__raw_writel (val, phy_reg +USBPHY_CTRL ); +__raw_writel (val, phy_ctrl); -return 0 ; +return val &USBPHY_CTRL_OTG_ID ; } -static void usbh1_oc_config (void ) +/* Base address for this IP block is 0x02184800 */ +struct usbnc_regs { +u32 ctrl[4 ];/* otg/host1-3 */ +u32 uh2_hsic_ctrl; +u32 uh3_hsic_ctrl; +u32 otg_phy_ctrl_0; +u32 uh1_phy_ctrl_0; +}; + +static void usb_oc_config (int index) { -void __iomem *usb_base = (void __iomem *)USBOH3_USB_BASE_ADDR ; -void __iomem *usbother_base = usb_base +USB_OTHERREGS_OFFSET ; +struct usbnc_regs *usbnc = (struct usbnc_regs *)(USBOH3_USB_BASE_ADDR + +USB_OTHERREGS_OFFSET ); +void __iomem *ctrl = (void __iomem *)(&usbnc->ctrl[index]);u32 val; - val =__raw_readl (usbother_base +USB_H1_CTRL_OFFSET ); + val =__raw_readl (ctrl);#if CONFIG_MACH_TYPE ==MACH_TYPE_MX6Q_ARM2 /* mx6qarm2 seems to required a different setting*/ val &= ~UCTRL_OVER_CUR_POL ;#else val |=UCTRL_OVER_CUR_POL ;#endif -__raw_writel (val, usbother_base +USB_H1_CTRL_OFFSET ); +__raw_writel (val, ctrl); - val =__raw_readl (usbother_base +USB_H1_CTRL_OFFSET ); + val =__raw_readl (ctrl); val |=UCTRL_OVER_CUR_DIS ; -__raw_writel (val, usbother_base +USB_H1_CTRL_OFFSET ); +__raw_writel (val, ctrl); }int __weak board_ehci_hcd_init (int port)
@@ -155,34 +198,42 @@ int __weak board_ehci_hcd_init(int port)return 0 ; } +int __weak board_ehci_power (int port,int on) +{ +return 0 ; +} +int ehci_hcd_init (int index,enum usb_init_type init,struct ehci_hccr **hccr,struct ehci_hcor **hcor) { -struct usb_ehci *ehci; +enum usb_init_type type; +struct usb_ehci *ehci = (struct usb_ehci *)(USBOH3_USB_BASE_ADDR + + (0x200 * index)); +if (index >3 ) +return -EINVAL ;enable_usboh3_clk (1 );mdelay (1 );/* Do board specific initialization */ -board_ehci_hcd_init (CONFIG_MXC_USB_PORT ); - -#if CONFIG_MXC_USB_PORT ==1 -/* USB Host 1 */ -usbh1_power_config (); -usbh1_oc_config (); -usbh1_internal_phy_clock_gate (1 ); -usbh1_phy_enable (); -#else -#error "MXC USB port not yet supported" -#endif +board_ehci_hcd_init (index); + +usb_power_config (index); +usb_oc_config (index); +usb_internal_phy_clock_gate (index,1 ); + type =usb_phy_enable (index, ehci) ?USB_INIT_DEVICE :USB_INIT_HOST ; - ehci = (struct usb_ehci *)(USBOH3_USB_BASE_ADDR + - (0x200 *CONFIG_MXC_USB_PORT )); *hccr = (struct ehci_hccr *)((uint32_t )&ehci->caplength); *hcor = (struct ehci_hcor *)((uint32_t )*hccr +HC_LENGTH (ehci_readl (&(*hccr)->cr_capbase))); -setbits_le32 (&ehci->usbmode,CM_HOST ); +if ((type == init) || (type ==USB_INIT_DEVICE )) +board_ehci_power (index, (type ==USB_INIT_DEVICE ) ?0 :1 ); +if (type != init) +return -ENODEV ; +if (type ==USB_INIT_DEVICE ) +return 0 ; +setbits_le32 (&ehci->usbmode,CM_HOST );__raw_writel (CONFIG_MXC_USB_PORTSC , &ehci->portsc);setbits_le32 (&ehci->portsc,USB_EN );
include/configs/mx6qsabreauto.h +2 -1
@@ -23,7 +23,8 @@#define CONFIG_USB_STORAGE #define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX -#define CONFIG_MXC_USB_PORT 1 +#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 +#define CONFIG_EHCI_HCD_INIT_AFTER_RESET /* For OTG port */ #define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)#define CONFIG_MXC_USB_FLAGS 0
include/configs/nitrogen6x.h +2 -1
@@ -125,7 +125,8 @@#define CONFIG_USB_HOST_ETHER #define CONFIG_USB_ETHER_ASIX #define CONFIG_USB_ETHER_SMSC95XX -#define CONFIG_MXC_USB_PORT 1 +#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 +#define CONFIG_EHCI_HCD_INIT_AFTER_RESET /* For OTG port */ #define CONFIG_MXC_USB_PORTSC (PORT_PTS_UTMI | PORT_PTS_PTW)#define CONFIG_MXC_USB_FLAGS 0
Signature · 1 line
1.8.1.2
PATCH v6 6/10 usb: gadget: mv_udc: fix full speed connections
In reply to Troy KiskySet maximum packet length in queue header to wMaxPacketSize of endpoint.
---
v4: no change
v5: no change
v6: no change
--- drivers/usb/gadget/mv_udc.c | 48 ++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 14 deletions(-)
drivers/usb/gadget/mv_udc.c +34 -14
@@ -14,6 +14,7 @@#include <net.h> #include <malloc.h> #include <asm/io.h> +#include <asm/unaligned.h> #include <linux/types.h> #include <usb/mv_udc.h>
@@ -207,7 +208,7 @@ static void mv_ep_free_request(struct usb_ep *ep, struct usb_request *_req)return ; } -static void ep_enable (int num,int in) +static void ep_enable (int num,int in,int maxpacket) {struct ept_queue_head *head;struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
@@ -221,7 +222,7 @@ static void ep_enable(int num, int in) n |= (CTRL_RXE |CTRL_RXR |CTRL_RXT_BULK );if (num !=0 ) { - head->config =CONFIG_MAX_PKT (EP_MAX_PACKET_SIZE ) |CONFIG_ZLT ; + head->config =CONFIG_MAX_PKT (maxpacket) |CONFIG_ZLT ;mv_flush_qh (num); }writel (n, &udc->epctrl[num]);
@@ -234,8 +235,21 @@ static int mv_ep_enable(struct usb_ep *ep,int num, in; num = desc->bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ; in = (desc->bEndpointAddress &USB_DIR_IN ) !=0 ; -ep_enable (num, in); mv_ep->desc = desc; + +if (num) { +int max =get_unaligned_le16 (&desc->wMaxPacketSize); + +if ((max >64 ) && (controller.gadget.speed ==USB_SPEED_FULL )) + max =64 ; +if (ep->maxpacket != max) { +DBG ("%s: from %d to %d\n" , __func__, + ep->maxpacket, max); + ep->maxpacket = max; + } + } +ep_enable (num, in, ep->maxpacket); +DBG ("%s: num=%d maxpacket=%d\n" , __func__, num, ep->maxpacket);return 0 ; }
@@ -410,14 +424,16 @@ static void handle_setup(void)if ((r.wValue ==0 ) && (r.wLength ==0 )) { req->length =0 ;for (i =0 ; i <NUM_ENDPOINTS ; i++) { -if (!controller.ep[i].desc) +struct mv_ep *ep = &controller.ep[i]; + +if (!ep->desc)continue ; - num = controller.ep[i].desc->bEndpointAddress + num = ep->desc->bEndpointAddress &USB_ENDPOINT_NUMBER_MASK ; - in = (controller.ep[i].desc->bEndpointAddress + in = (ep->desc->bEndpointAddress &USB_DIR_IN ) !=0 ;if ((num == _num) && (in == _in)) { -ep_enable (num, in); +ep_enable (num, in, ep->ep.maxpacket);usb_ep_queue (controller.gadget.ep0, req,0 );break ;
@@ -501,15 +517,19 @@ void udc_irq(void)DBG ("-- suspend --\n" );if (n &STS_PCI ) { -DBG ("-- portchange --\n" ); +int max =64 ; +int speed =USB_SPEED_FULL ; + bit = (readl (&udc->portsc) >>26 ) &3 ; +DBG ("-- portchange %x %s\n" , bit, (bit ==2 ) ?"High" :"Full" );if (bit ==2 ) { - controller.gadget.speed =USB_SPEED_HIGH ; -for (i =1 ; i <NUM_ENDPOINTS && n; i++) -if (controller.ep[i].desc) - controller.ep[i].ep.maxpacket =512 ; - }else { - controller.gadget.speed =USB_SPEED_FULL ; + speed =USB_SPEED_HIGH ; + max =512 ; + } + controller.gadget.speed = speed; +for (i =1 ; i <NUM_ENDPOINTS ; i++) { +if (controller.ep[i].ep.maxpacket > max) + controller.ep[i].ep.maxpacket = max; } }
Signature · 1 line
1.8.1.2
PATCH v6 7/10 usb: gadget: mv_udc: optimize bounce
In reply to Troy KiskyOnly perform one copy, either in the bounce routine for IN transfers, or the debounce rtn for OUT transfer.
On out transfers, only copy the number of bytes received from the bounce buffer
---
v4: no change
v5: no change
v6: no change
--- drivers/usb/gadget/mv_udc.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
drivers/usb/gadget/mv_udc.c +16 -21
@@ -261,7 +261,7 @@ static int mv_ep_disable(struct usb_ep *ep)return 0 ; } -static int mv_bounce (struct mv_ep *ep) +static int mv_bounce (struct mv_ep *ep,int in) {uint32_t addr = (uint32_t )ep->req.buf;uint32_t ba;
@@ -290,8 +290,8 @@ align:if (!ep->b_buf)return -ENOMEM ; } - -memcpy (ep->b_buf, ep->req.buf, ep->req.length); +if (in) +memcpy (ep->b_buf, ep->req.buf, ep->req.length); flush: ba = (uint32_t )ep->b_buf;
@@ -300,29 +300,25 @@ flush:return 0 ; } -static void mv_debounce (struct mv_ep *ep) +static void mv_debounce (struct mv_ep *ep,int in) {uint32_t addr = (uint32_t )ep->req.buf;uint32_t ba = (uint32_t )ep->b_buf; +if (in) { +if (addr == ba) +return ;/* not a bounce */ + goto free; + }invalidate_dcache_range (ba, ba + ep->b_len); -/* Input buffer address is not aligned. */ -if (addr & (ARCH_DMA_MINALIGN -1 )) - goto copy; - -/* Input buffer length is not aligned. */ -if (ep->req.length & (ARCH_DMA_MINALIGN -1 )) - goto copy; - -/* The buffer is well aligned, only invalidate cache. */ -return ; +if (addr == ba) +return ;/* not a bounce */ -copy:memcpy (ep->req.buf, ep->b_buf, ep->req.length); - +free:/* Large payloads use allocated buffer, free it. */ -if (ep->req.length >64 ) +if (ep->b_buf != ep->b_fast)free (ep->b_buf); }
@@ -340,7 +336,7 @@ static int mv_ep_queue(struct usb_ep *ep, head =mv_get_qh (num, in); len = req->length; - ret =mv_bounce (mv_ep); + ret =mv_bounce (mv_ep, in);if (ret)return ret;
@@ -383,10 +379,9 @@ static void handle_ep_complete(struct mv_ep *ep) num, in ? "in" : "out", item->info, item->page0); len = (item->info >>16 ) &0x7fff ; - -mv_debounce (ep); - ep->req.length -= len; +mv_debounce (ep, in); +DBG ("ept%d %s complete %x\n" , num, in ?"in" :"out" , len); ep->req.complete (&ep->ep, &ep->req);
Signature · 1 line
1.8.1.2
PATCH v6 8/10 usb: gadget: mv_udc: optimize ep_enable
In reply to Troy KiskyOnly get head if not ep0.
---
v4: no change
v5: no change
v6: no change
--- drivers/usb/gadget/mv_udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/mv_udc.c +2 -2
@@ -210,10 +210,8 @@ static void mv_ep_free_request(struct usb_ep *ep, struct usb_request *_req)static void ep_enable (int num,int in,int maxpacket) { -struct ept_queue_head *head;struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;unsigned n; - head =mv_get_qh (num, in); n =readl (&udc->epctrl[num]);if (in)
@@ -222,6 +220,8 @@ static void ep_enable(int num, int in, int maxpacket) n |= (CTRL_RXE |CTRL_RXR |CTRL_RXT_BULK );if (num !=0 ) { +struct ept_queue_head *head =mv_get_qh (num, in); + head->config =CONFIG_MAX_PKT (maxpacket) |CONFIG_ZLT ;mv_flush_qh (num); }
Signature · 1 line
1.8.1.2
PATCH v6 9/10 usb: gadget: mv_udc: split mv_udc.h file
In reply to Troy KiskyMove defines only needed by mv_udc.c to a file
in the same directory.
This allows usbtty to compile for mv_udc,
but it still doesn't link.
---
v4: unchanged
v5: unchanged
v6: unchanged
--- drivers/usb/gadget/mv_udc.c | 6 +++ drivers/usb/gadget/mv_udc.h | 115 ++++++++++++++++++++++++++++++++++++++++++ include/usb/mv_udc.h | 118 -------------------------------------------- 3 files changed, 121 insertions(+), 118 deletions(-) create mode 100644 drivers/usb/gadget/mv_udc.h
drivers/usb/gadget/mv_udc.c +6 -0
@@ -13,10 +13,16 @@#include <config.h> #include <net.h> #include <malloc.h> +#include <asm/byteorder.h> +#include <asm/errno.h> #include <asm/io.h> #include <asm/unaligned.h> #include <linux/types.h> +#include <linux/usb/ch9.h> +#include <linux/usb/gadget.h> #include <usb/mv_udc.h> +#include "../host/ehci.h" +#include "mv_udc.h" /* * Check if the system has too long cachelines. If the cachelines are
drivers/usb/gadget/mv_udc.h new file +115 -0
115 lines not on this page · raw message
include/usb/mv_udc.h +0 -118
124 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH v6 10/10 usb: udc: add udc.h include file
In reply to Troy KiskyMove common definitions to udc.h
This allows musb_udc.h to be removed as well.
---
v4: updated commit message
removed ifdef UDC_BULK_HS_PACKET_SIZE since 512 is the only legal value, it shouldn't be overridden.
v5: use #if !defined(CONFIG_PPC) && !defined(CONFIG_OMAP1510) for UDC_xxx_PACKET_SIZE setting
v6: no change
--- drivers/serial/usbtty.h | 3 +-- drivers/usb/gadget/designware_udc.c | 1 + drivers/usb/gadget/mpc8xx_udc.c | 1 + drivers/usb/gadget/omap1510_udc.c | 1 + drivers/usb/gadget/pxa27x_udc.c | 1 + drivers/usb/musb/musb_udc.c | 3 ++- include/usb/designware_udc.h | 31 ---------------------- include/usb/mpc8xx_udc.h | 19 +------------ include/usb/musb_udc.h | 40 ---------------------------- include/usb/omap1510_udc.h | 31 +++++----------------- include/usb/pxa27x_udc.h | 26 +----------------- include/usb/udc.h | 53 +++++++++++++++++++++++++++++++++++++ 12 files changed, 68 insertions(+), 142 deletions(-) delete mode 100644 include/usb/musb_udc.h create mode 100644 include/usb/udc.h
drivers/serial/usbtty.h +1 -2
@@ -16,8 +16,6 @@#include <usb/mpc8xx_udc.h> #elif defined(CONFIG_OMAP1510 )#include <usb/omap1510_udc.h> -#elif defined(CONFIG_MUSB_UDC ) -#include <usb/musb_udc.h> #elif defined(CONFIG_CPU_PXA27X )#include <usb/pxa27x_udc.h> #elif defined(CONFIG_DW_UDC )
@@ -26,6 +24,7 @@#include <usb/mv_udc.h> #endif +#include <usb/udc.h> #include <version.h> /* If no VendorID/ProductID is defined in config.h, pretend to be Linux
drivers/usb/gadget/designware_udc.c +1 -0
@@ -14,6 +14,7 @@#include <usbdevice.h> #include "ep0.h" #include <usb/designware_udc.h> +#include <usb/udc.h> #include <asm/arch/hardware.h> #define UDC_INIT_MDELAY 80/* Device settle delay */
drivers/usb/gadget/mpc8xx_udc.c +1 -0
@@ -47,6 +47,7 @@#include <commproc.h> #include <usbdevice.h> #include <usb/mpc8xx_udc.h> +#include <usb/udc.h> #include "ep0.h"
drivers/usb/gadget/omap1510_udc.c +1 -0
@@ -20,6 +20,7 @@#endif #include <usbdevice.h> #include <usb/omap1510_udc.h> +#include <usb/udc.h> #include "ep0.h"
drivers/usb/gadget/pxa27x_udc.c +1 -0
@@ -16,6 +16,7 @@#include <asm/arch/hardware.h> #include <asm/io.h> #include <usb/pxa27x_udc.h> +#include <usb/udc.h> #include "ep0.h"
drivers/usb/musb/musb_udc.c +2 -1
@@ -39,7 +39,8 @@*/ #include <common.h> -#include <usb/musb_udc.h> +#include <usbdevice.h> +#include <usb/udc.h> #include "../gadget/ep0.h" #include "musb_core.h" #if defined(CONFIG_USB_OMAP3 )
include/usb/designware_udc.h +0 -31
@@ -174,19 +174,6 @@ struct udcfifo_regs { };/* -* USBTTY definitions -*/ -#define EP0_MAX_PACKET_SIZE 64 -#define UDC_INT_ENDPOINT 1 -#define UDC_INT_PACKET_SIZE 64 -#define UDC_OUT_ENDPOINT 2 -#define UDC_BULK_PACKET_SIZE 64 -#define UDC_BULK_HS_PACKET_SIZE 512 -#define UDC_IN_ENDPOINT 3 -#define UDC_OUT_PACKET_SIZE 64 -#define UDC_IN_PACKET_SIZE 64 - -/* * UDC endpoint definitions */ #define UDC_EP0 0
@@ -194,22 +181,4 @@ struct udcfifo_regs {#define UDC_EP2 2#define UDC_EP3 3 -/* -* Function declarations -*/ - -void udc_irq (void ); - -void udc_set_nak (int epid); -void udc_unset_nak (int epid); -int udc_endpoint_write (struct usb_endpoint_instance *endpoint); -int udc_init (void ); -void udc_enable (struct usb_device_instance *device); -void udc_disable (void ); -void udc_connect (void ); -void udc_disconnect (void ); -void udc_startup_events (struct usb_device_instance *device); -void udc_setup_ep (struct usb_device_instance *device,unsigned int ep, -struct usb_endpoint_instance *endpoint); -#endif /* __DW_UDC_H */
include/usb/mpc8xx_udc.h +1 -18
@@ -111,11 +111,9 @@/* UDC device defines */ #define EP0_MAX_PACKET_SIZE EP_MAX_PKT -#define UDC_OUT_ENDPOINT 0x02 +#define UDC_OUT_PACKET_SIZE EP_MIN_PACKET_SIZE -#define UDC_IN_ENDPOINT 0x03#define UDC_IN_PACKET_SIZE EP_MIN_PACKET_SIZE -#define UDC_INT_ENDPOINT 0x01#define UDC_INT_PACKET_SIZE UDC_IN_PACKET_SIZE#define UDC_BULK_PACKET_SIZE EP_MIN_PACKET_SIZE
@@ -178,18 +176,3 @@ typedef enum mpc8xx_udc_state{ STATE_READY, }mpc8xx_udc_state_t; -/* Declarations */ -int udc_init (void ); -void udc_irq (void ); -int udc_endpoint_write (struct usb_endpoint_instance *endpoint); -void udc_setup_ep (struct usb_device_instance *device,unsigned int ep, -struct usb_endpoint_instance *endpoint); -void udc_connect (void ); -void udc_disconnect (void ); -void udc_enable (struct usb_device_instance *device); -void udc_disable (void ); -void udc_startup_events (struct usb_device_instance *device); - -/* Flow control */ -void udc_set_nak (int epid); -void udc_unset_nak (int epid);
include/usb/musb_udc.h deleted +0 -40
@@ -1,40 +0,0 @@ -/* -* Copyright (c) 2009 Wind River Systems, Inc. -* Tom Rix <[email protected]> -* -* SPDX-License-Identifier: GPL-2.0+ -*/ -#ifndef __MUSB_UDC_H__ -#define __MUSB_UDC_H__ - -#include <usbdevice.h> - -/* UDC level routines */ -void udc_irq (void ); -void udc_set_nak (int ep_num); -void udc_unset_nak (int ep_num); -int udc_endpoint_write (struct usb_endpoint_instance *endpoint); -void udc_setup_ep (struct usb_device_instance *device,unsigned int id, -struct usb_endpoint_instance *endpoint); -void udc_connect (void ); -void udc_disconnect (void ); -void udc_enable (struct usb_device_instance *device); -void udc_disable (void ); -void udc_startup_events (struct usb_device_instance *device); -int udc_init (void ); - -/* usbtty */ -#ifdef CONFIG_USB_TTY - -#define EP0_MAX_PACKET_SIZE 64/* MUSB_EP0_FIFOSIZE */ -#define UDC_INT_ENDPOINT 1 -#define UDC_INT_PACKET_SIZE 64 -#define UDC_OUT_ENDPOINT 2 -#define UDC_OUT_PACKET_SIZE 64 -#define UDC_IN_ENDPOINT 3 -#define UDC_IN_PACKET_SIZE 64 -#define UDC_BULK_PACKET_SIZE 64 - -#endif /* CONFIG_USB_TTY */ - -#endif /* __MUSB_UDC_H__ */
include/usb/omap1510_udc.h +6 -25
@@ -162,32 +162,13 @@#define UDC_VBUS_MODE (1 << 18)/* OMAP Endpoint parameters */ -#define EP0_MAX_PACKET_SIZE 64 -#define UDC_OUT_ENDPOINT 2 -#define UDC_OUT_PACKET_SIZE 64 -#define UDC_IN_ENDPOINT 1 -#define UDC_IN_PACKET_SIZE 64 -#define UDC_INT_ENDPOINT 5 +#define UDC_OUT_PACKET_SIZE 64 +#define UDC_IN_PACKET_SIZE 64#define UDC_INT_PACKET_SIZE 16 -#define UDC_BULK_PACKET_SIZE 16 - -void udc_irq (void ); -/* Flow control */ -void udc_set_nak (int epid); -void udc_unset_nak (int epid); - -/* Higher level functions for abstracting away from specific device */ -int udc_endpoint_write (struct usb_endpoint_instance *endpoint); - -int udc_init (void ); +#define UDC_BULK_PACKET_SIZE 16 -void udc_enable (struct usb_device_instance *device); -void udc_disable (void ); - -void udc_connect (void ); -void udc_disconnect (void ); - -void udc_startup_events (struct usb_device_instance *device); -void udc_setup_ep (struct usb_device_instance *device,unsigned int ep,struct usb_endpoint_instance *endpoint); +#define UDC_INT_ENDPOINT 5 +#define UDC_OUT_ENDPOINT 2 +#define UDC_IN_ENDPOINT 1#endif
include/usb/pxa27x_udc.h +1 -25
@@ -22,35 +22,11 @@/* Endpoint parameters */ #define MAX_ENDPOINTS 4 -#define EP_MAX_PACKET_SIZE 64#define EP0_MAX_PACKET_SIZE 16 +#define UDC_OUT_ENDPOINT 0x02 -#define UDC_OUT_PACKET_SIZE EP_MAX_PACKET_SIZE#define UDC_IN_ENDPOINT 0x01 -#define UDC_IN_PACKET_SIZE EP_MAX_PACKET_SIZE#define UDC_INT_ENDPOINT 0x05 -#define UDC_INT_PACKET_SIZE EP_MAX_PACKET_SIZE -#define UDC_BULK_PACKET_SIZE EP_MAX_PACKET_SIZE - -void udc_irq (void ); -/* Flow control */ -void udc_set_nak (int epid); -void udc_unset_nak (int epid); - -/* Higher level functions for abstracting away from specific device */ -int udc_endpoint_write (struct usb_endpoint_instance *endpoint); - -int udc_init (void ); - -void udc_enable (struct usb_device_instance *device); -void udc_disable (void ); - -void udc_connect (void ); -void udc_disconnect (void ); - -void udc_startup_events (struct usb_device_instance *device); -void udc_setup_ep (struct usb_device_instance *device, -unsigned int ep,struct usb_endpoint_instance *endpoint);#endif
include/usb/udc.h new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
1.8.1.2
Marek Vasut
Appliedv6 cover Make mv_udc work for i.mx6
In reply to Troy KiskyDear Troy Kisky,
Quoted 21 lines
Hi Marek
This series is based on u-boot-usb/next branch.
After this series, nitrogen6x works with tftpboot to transfer files over usb, and will recognize a usb stick in the OTG port.This V6 has been rebased to the latest u-boot-usb/next branch and changed to address Marek comments.
The most noticeable change is the addition of patches to use enum
usb_init_type.Tested on a Nitrogen6x board with the following commands when connected to a USB2.0 hub and a USB1.1 hub
setenv ipaddr 10.0.0.2 && setenv netmask 255.255.255.0 && setenv serverip 10.0.0.1 setenv
usbnet_devaddr00:11:22:33:44:55 && setenvusbnet_hostaddr00:aa:bb:cc:dd:ee setenv ethprimeusb_ether&& setenv ethactusb_ether&& setenv ncip 10.0.0.1 tftpboot 10800000 10.0.0.1:uImage6w
Quoted 4 lines
The USB1.1 had a transfer rate of 687.5 KiB/s, the USB2.0 hub had a transfer rate of 5.4 MiB/s.
And by recognizing a usb stick in each port.
Applied all, thanks.
Best regards,
Marek Vasut