musb: add musb support for AM35x
Subsystems (2)
PATCH 1/2 musb: add musb support for AM35x
AM35x has musb interface and uses CPPI4.1 DMA engine. Current patch supports only PIO mode and there are on-going discussions on location of CPPI4.1 DMA.
--- drivers/usb/musb/Kconfig | 4 +- drivers/usb/musb/Makefile | 4 + drivers/usb/musb/am3517.c | 536 ++++++++++++++++++++++++++++++++++++++++++ drivers/usb/musb/musb_core.c | 3 +- 4 files changed, 544 insertions(+), 3 deletions(-) create mode 100644 drivers/usb/musb/am3517.c
drivers/usb/musb/Kconfig +2 -2
@@ -10,7 +10,7 @@ comment "Enable Host or Gadget support to see Inventra options" config USB_MUSB_HDRC depends on (USB || USB_GADGET) depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523)) - select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) + select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN || MACH_OMAP3517EVM) select TWL4030_USB if MACH_OMAP_3430SDP select USB_OTG_UTILS tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
@@ -140,7 +140,7 @@ config USB_MUSB_HDRC_HCD config MUSB_PIO_ONLY bool 'Disable DMA (always use PIO)' depends on USB_MUSB_HDRC - default y if USB_TUSB6010 + default USB_TUSB6010 || MACH_OMAP3517EVM help All data is copied between memory and FIFO by the CPU. DMA controllers are ignored.
drivers/usb/musb/Makefile +4 -0
@@ -19,7 +19,11 @@ ifeq ($(CONFIG_ARCH_OMAP2430),y) endif ifeq ($(CONFIG_ARCH_OMAP3430),y) + ifeq ($(CONFIG_MACH_OMAP3517EVM),y) + musb_hdrc-objs += am3517.o + else musb_hdrc-objs += omap2430.o + endif endif ifeq ($(CONFIG_BF54x),y)
drivers/usb/musb/am3517.c new file +536 -0
536 lines not on this page · raw message
drivers/usb/musb/musb_core.c +2 -1
@@ -982,7 +982,8 @@ static void musb_shutdown(struct platform_device *pdev)* more than selecting one of a bunch of predefined configurations. */ #if defined(CONFIG_USB_TUSB6010 ) || \ - defined(CONFIG_ARCH_OMAP2430 ) || defined(CONFIG_ARCH_OMAP3 ) + defined(CONFIG_ARCH_OMAP2430 ) || defined(CONFIG_ARCH_OMAP3 ) || \ + defined(CONFIG_MACH_OMAP3517EVM )static ushort __initdata fifo_mode =4 ;#else static ushort __initdata fifo_mode =2 ;
Signature · 1 line
1.6.2.4
A message that is not in the archive (sent off-list or not yet received): 1267017527-17591-1-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org
PATCH 2/2 AM35x: musb: Workaround for fifo read issue
AM35x supports only 32bit read operations so we need to have workaround for 8bit and 16bit read operations.
--- drivers/usb/musb/am3517.c | 30 ++++++++++++++++++++++++++++++ drivers/usb/musb/musb_core.c | 2 ++ 2 files changed, 32 insertions(+), 0 deletions(-)
drivers/usb/musb/am3517.c +30 -0
@@ -534,3 +534,33 @@ void musb_platform_restore_context(struct musb_context_registersphy_on (); }#endif + +/* AM35x supports only 32bit read operation */ +void musb_read_fifo (struct musb_hw_ep *hw_ep,u16 len,u8 *dst) +{ +void __iomem *fifo = hw_ep->fifo; +u32 val; +int i; + +/* Read for 32bit-aligned destination address */ +if ((likely ((0x03 & (unsigned long ) dst) ==0 )) && len >=4 ) { +readsl (fifo, dst, len >>2 ); + dst += (len & ~0x03 ); + len &=0x03 ; + } +/* Now read the rest 1 to 3 bytes or complete length if +* unaligned address. +*/ +if (len >4 ) { +for (i =0 ; i < (len >>2 ); i++) { + val =musb_readl (fifo,0 ); +memcpy (dst, &val,4 ); + dst +=4 ; + } + len %=4 ; + } +if (len >0 ) { + val =musb_readl (fifo,0 ); +memcpy (dst, &val, len); + } +}
drivers/usb/musb/musb_core.c +2 -0
@@ -191,6 +191,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) } } +#if !defined(CONFIG_MACH_OMAP3517EVM )/* * Unload an endpoint's FIFO */
@@ -228,6 +229,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)readsb (fifo, dst, len); } } +#endif #endif /* normal PIO */
Signature · 6 lines
1.6.2.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello.
Quoted 40 lines · Ajay Kumar Gupta
AM35x has musb interface and uses CPPI4.1 DMA engine. Current patch supports only PIO mode and there are on-going discussions on location of CPPI4.1 DMA.
Signed-off-by Ajay Kumar Gupta <[email protected]>--- drivers/usb/musb/Kconfig | 4 +- drivers/usb/musb/Makefile | 4 + drivers/usb/musb/am3517.c | 536 ++++++++++++++++++++++++++++++++++++++++++ drivers/usb/musb/musb_core.c | 3 +- 4 files changed, 544 insertions(+), 3 deletions(-) create mode 100644 drivers/usb/musb/am3517.cdrivers/usb/musb/Kconfig +2
-2@@ -10,7 +10,7 @@ comment "Enable Host or Gadget support to see Inventra options" config USB_MUSB_HDRC depends on (USB || USB_GADGET) depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523)) - select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) + select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN || MACH_OMAP3517EVM) select TWL4030_USB if MACH_OMAP_3430SDP select USB_OTG_UTILS tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'@@ -140,7 +140,7 @@ config USB_MUSB_HDRC_HCD config MUSB_PIO_ONLY bool 'Disable DMA (always use PIO)' depends on USB_MUSB_HDRC - default y if USB_TUSB6010 + default USB_TUSB6010 || MACH_OMAP3517EVM help All data is copied between memory and FIFO by the CPU. DMA controllers are ignored.drivers/usb/musb/Makefile +0
-0
drivers/usb/musb/Makefile ifeq ($(CONFIG_ARCH_OMAP2430),y) · line 24
Quoted 6 lines
drivers/usb/musb/Makefile +2
-0@@ -19,7 +19,11 @@ ifeq ($(CONFIG_ARCH_OMAP2430),y) endif ifeq ($(CONFIG_ARCH_OMAP3430),y) + ifeq ($(CONFIG_MACH_OMAP3517EVM),y) + musb_hdrc-objs += am3517.o
Isn't there some ARCH-level option for AM3517 SoC? Depending on the
board type doesn't really scale well...
Quoted 13 lines
drivers/usb/musb/Makefile +2
-0+ else musb_hdrc-objs += omap2430.o + endif endififeq ($(CONFIG_BF54x),y)
drivers/usb/musb/am3517.c new file +0
-0@@ -0,0 +1,536 @@
[...]
drivers/usb/musb/am3517.c line 46
Quoted 9 lines
drivers/usb/musb/am3517.c new file +8
-0+/* +* AM3517 specific definitions +*/ + +/* CPPI 4.1 queue manager registers */ +#define QMGR_PEND0_REG 0x4090 +#define QMGR_PEND1_REG 0x4094 +#define QMGR_PEND2_REG 0x4098
Those are not used (yet)...
drivers/usb/musb/am3517.c line 84
Quoted 12 lines
drivers/usb/musb/am3517.c new file +11
-0+static inline void phy_on (void ) +{ +u32 devconf2; + +/* +* Start the on-chip PHY and its PLL. +*/ + devconf2 =omap_ctrl_readl (AM35XX_CONTROL_DEVCONF2 ); + + devconf2 &= ~(CONF2_RESET |CONF2_PHYPWRDN |CONF2_OTGPWRDN | +CONF2_OTGMODE |CONF2_REFFREQ |CONF2_PHY_GPIOMODE );
Shouldn't you manipulate CONF2_OTGMODE in the board code instead? I
suspect value of 0 doesn't fit the host-only configuration (without cable connected, MUSB will think it's a B-device, and the driver will fail to initialize IIRC).
drivers/usb/musb/am3517.c line 86
Quoted 3 lines
drivers/usb/musb/am3517.c new file +2
-0+ devconf2 |=CONF2_SESENDEN |CONF2_VBDTCTEN |CONF2_PHY_PLLON | +CONF2_REFFREQ_13MHZ |CONF2_DATPOL ;
Reference clock of 13 MHz, not 12? Hmm... Again, shouldn't the board
code select the reference frequency (clock might be external, IIUC)?
Quoted 20 lines
drivers/usb/musb/am3517.c new file +19
-0+static inline void phy_off (void ) +{ +u32 devconf2; + +/* +* Power down the on-chip PHY. +*/ + devconf2 =omap_ctrl_readl (AM35XX_CONTROL_DEVCONF2 ); + + devconf2 &= ~CONF2_PHY_PLLON ; + devconf2 |=CONF2_PHYPWRDN |CONF2_OTGPWRDN ; +omap_ctrl_writel (devconf2,AM35XX_CONTROL_DEVCONF2 ); +} + +/** +* musb_platform_enable - enable interrupts +*/ +void musb_platform_enable (struct musb *musb) +{
drivers/usb/musb/am3517.c line 124
Quoted 10 lines
drivers/usb/musb/am3517.c new file +10
-0+void __iomem *reg_base = musb->ctrl_base; +u32 epmask, coremask; + +/* Workaround: setup IRQs through both register sets. */ + epmask = ((musb->epmask &AM3517_TX_EP_MASK ) <<USB_INTR_TX_SHIFT ) | + ((musb->epmask &AM3517_RX_EP_MASK ) <<USB_INTR_RX_SHIFT ); + coremask = (0x01ff <<USB_INTR_USB_SHIFT ); + +musb_writel (reg_base,EP_INTR_MASK_SET_REG , epmask); +musb_writel (reg_base,CORE_INTR_MASK_SET_REG , coremask);
Hm, and I thought all CPPI 4.1 based controllers have the same
register layout... alas, I was wrong.
Quoted 2 lines
+static int
vbus_state= -1;
[...]
drivers/usb/musb/am3517.c line 163
Quoted 11 lines
drivers/usb/musb/am3517.c new file +10
-0+static void am3517_source_power (struct musb *musb,int is_on,int immediate) +{ +if (is_on) + is_on =1 ; + +if (vbus_state == is_on) +return ; + vbus_state = is_on; +} +
Without the real GPIOs to manipulate, I don't understand the purpose
of this function...
drivers/usb/musb/am3517.c line 182
Quoted 12 lines
drivers/usb/musb/am3517.c new file +11
-0+static struct timer_list otg_workaround; + +static void otg_timer (unsigned long _musb) +{ +struct musb *musb = (void *)_musb; +void __iomem *mregs = musb->mregs; +u8 devctl; +unsigned long flags; + +/* We poll because AM3517's won't expose several OTG-critical +* status change events (from the transceiver) otherwise.
Need one more space before *...
drivers/usb/musb/am3517.c line 208
Quoted 8 lines
drivers/usb/musb/am3517.c new file +7
-0+case OTG_STATE_A_WAIT_VFALL : +/* +* Wait till VBUS falls below SessionEnd (~0.2 V); the 1.3 +* RTL seems to mis-handle session "start" otherwise (or in +* our case "recover"), in routine "VBUS was valid by the time +* VBUSERR got reported during enumeration" cases. +*/
I wonder if all this still true for RTL 1.8 on which DA8xx (and
probably AM3517) MUSB is based...
drivers/usb/musb/am3517.c
Quoted 3 lines
drivers/usb/musb/am3517.c new file +2
-0+void musb_platform_try_idle (struct musb *musb,unsigned long timeout) +{
I wonder how DaVinci gets about without musb_platfrom_try_idle()...
drivers/usb/musb/am3517.c
Quoted 6 lines
drivers/usb/musb/am3517.c new file +4
-0+static irqreturn_t am3517_interrupt (int irq,void *hci) +{ +/* NOTE: this must complete power-on within 100 ms. */ +am3517_source_power (musb, drvvbus,0 );
This call is effectively a NOP.
drivers/usb/musb/am3517.c line 370
Quoted 7 lines
drivers/usb/musb/am3517.c new file +6
-0+if (musb->int_tx || musb->int_rx || musb->int_usb) { +irqreturn_t mret; + + mret =musb_interrupt (musb); +if (mret ==IRQ_HANDLED ) + ret =IRQ_HANDLED ;
Not sure why you didn't like ret |= musb_interrupt(musb)...
drivers/usb/musb/am3517.c line 397
Quoted 9 lines
drivers/usb/musb/am3517.c new file +8
-0+if (ret !=IRQ_HANDLED ) { +if (epintr || usbintr) +/* +* We sometimes get unhandled IRQs in the peripheral +* mode from EP0 and SOF... +*/ +DBG (2 ,"Unhandled USB IRQ %08x-%08x\n" , + epintr, usbintr);
This check shouldn't be needed any more -- EP0 spurious interrupts
have been all chased down...
drivers/usb/musb/am3517.c line 404
Quoted 8 lines
drivers/usb/musb/am3517.c new file +7
-0+else if (printk_ratelimit ()) +/* +* We've seen series of spurious interrupts in the +* peripheral mode after USB reset and then after some +* time a real interrupt storm starting... +*/ +DBG (2 ,"Spurious IRQ\n" );
Those turned out to be interrupts caused by CPPI 4.1 descriptor
starvation (for which the controller didn't even have an interrupt bit). I still haven't dealt with them...
drivers/usb/musb/am3517.c line 412
Quoted 9 lines
drivers/usb/musb/am3517.c new file +8
-0+ } +return ret; +} + +int musb_platform_set_mode (struct musb *musb,u8 musb_mode) +{ +WARNING ("FIXME: %s not implemented\n" , __func__); +return -EIO ;
Could be implemented using CONF2_OTGMODE...
Quoted 9 lines
drivers/usb/musb/am3517.c new file +8
-0+int __init musb_platform_init (struct musb *musb) +{ +void __iomem *reg_base = musb->ctrl_base; +struct clk *otg_fck; +u32 rev, lvl_intr, sw_reset; + +usb_nop_xceiv_register (); +
drivers/usb/musb/am3517.c line 432
Quoted 10 lines
drivers/usb/musb/am3517.c new file +10
-0+ musb->xceiv =otg_get_transceiver (); +if (!musb->xceiv) +return -ENODEV ; + +/* Mentor is at offset of 0x400 in AM3517 */ + musb->mregs +=USB_MENTOR_CORE_OFFSET ; + +/* musb->clock is already set from board/arch files */ +if (IS_ERR (musb->clock)) +return PTR_ERR (musb->clock);
This is checked by musb_core.c now, no need to duplicate...
drivers/usb/musb/am3517.c line 435
Quoted 3 lines
drivers/usb/musb/am3517.c new file +2
-0+if (musb->set_clock) + musb->set_clock (musb->clock,1 );
musb->set_clock() is about to be dropped...
drivers/usb/musb/am3517.c line 439
Quoted 5 lines
drivers/usb/musb/am3517.c new file +4
-0+else +clk_enable (musb->clock); + +DBG (2 ,"usbotg_ck=%lud\n" ,clk_get_rate (musb->clock));
I'd put an empty line after that DBG() rather than before.
drivers/usb/musb/am3517.c line 441
Quoted 3 lines
drivers/usb/musb/am3517.c new file +2
-0+ otg_fck =clk_get (musb->controller,"fck" ); +clk_enable (otg_fck);
Oh, it needs two clocks... Another argument against Felipe droppingplat->clock. :-)
drivers/usb/musb/am3517.c line 443
Quoted 3 lines
drivers/usb/musb/am3517.c new file +2
-0+ +DBG (2 ,"usbotg_phy_ck=%lud\n" ,clk_get_rate (otg_fck));
Same about empty line here...
drivers/usb/musb/am3517.c line 453
Quoted 2 lines
drivers/usb/musb/am3517.c new file +1
-0+am3517_source_power (musb,0 ,1 );
Effective NOP...
drivers/usb/musb/am3517.c line 470
Quoted 5 lines
drivers/usb/musb/am3517.c new file +4
-0+/* Start the on-chip PHY and its PLL. */ +phy_on (); + +msleep (15 );
5 ms is not enough?
drivers/usb/musb/am3517.c line 472
Quoted 2 lines
drivers/usb/musb/am3517.c new file +1
-0+ musb->a_wait_bcon =A_WAIT_BCON_TIMEOUT ;
Hm... that line kept causing a stream of kernel messages for me,
until I removed it. Doesn't it for you?
drivers/usb/musb/musb_core.c static void musb_shutdown(struct platform_device *pdev) · line 987
Quoted 12 lines
drivers/usb/musb/musb_core.c +2
-1@@ -982,7 +982,8 @@ static void musb_shutdown(struct platform_device *pdev)* more than selecting one of a bunch of predefined configurations. */ #if defined(CONFIG_USB_TUSB6010 ) || \ - defined(CONFIG_ARCH_OMAP2430 ) || defined(CONFIG_ARCH_OMAP3 ) + defined(CONFIG_ARCH_OMAP2430 ) || defined(CONFIG_ARCH_OMAP3 ) || \ + defined(CONFIG_MACH_OMAP3517EVM )
Isn't that dependency already covered by CONFIG_ARCH_OMAP3? Or else I
don't see you adding your #ifdef around musb_platfrom_try_idle() declaration...
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
Quoted 22 lines
Quoted 22 lines
AM35x has musb interface and uses CPPI4.1 DMA engine. Current patch supports only PIO mode and there are on-going discussions on location of CPPI4.1 DMA.
Signed-off-by Ajay Kumar Gupta <[email protected]>drivers/usb/musb/Kconfig +1
-1tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'@@ -140,7 +140,7 @@ config USB_MUSB_HDRC_HCD config MUSB_PIO_ONLY bool 'Disable DMA (always use PIO)' depends on USB_MUSB_HDRC - default y if USB_TUSB6010 + default USB_TUSB6010 || MACH_OMAP3517EVM help All data is copied between memory and FIFO by the CPU. DMA controllers are ignored.drivers/usb/musb/Makefile +0
-0@@ -19,7 +19,11 @@ ifeq ($(CONFIG_ARCH_OMAP2430),y) endif
Quoted 7 lines
drivers/usb/musb/Makefile ifeq ($(CONFIG_ARCH_OMAP2430),y) · line 28
Quoted 4 lines
drivers/usb/musb/Makefile +2
-0ifeq ($(CONFIG_ARCH_OMAP3430),y) + ifeq ($(CONFIG_MACH_OMAP3517EVM),y) + musb_hdrc-objs += am3517.oIsn't there some ARCH-level option for AM3517 SoC? Depending on the
board type doesn't really scale well...
AM3517 is actually based on OMAP3 but musb is different. Unfortunately there is no seperate *_ARCH_* defines for AM3517 alone.
Quoted 10 lines
drivers/usb/musb/Makefile ifeq ($(CONFIG_ARCH_OMAP2430),y)
Quoted 8 lines
drivers/usb/musb/Makefile +7
-0+ * AM3517 specific definitions + */ + +/* CPPI 4.1 queue manager registers */ +#define QMGR_PEND0_REG 0x4090 +#define QMGR_PEND1_REG 0x4094 +#define QMGR_PEND2_REG 0x4098Those are not used (yet)...
Yes, but I added them as they are part of register layout.
Quoted 10 lines
Quoted 10 lines
drivers/usb/musb/Makefile +9
-0+static inline void phy_on(void) +{ + u32 devconf2; + + /* + * Start the on-chip PHY and its PLL. + */ + devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); +
Quoted 8 lines
drivers/usb/musb/Makefile
Quoted 3 lines
drivers/usb/musb/Makefile +2
-0+ devconf2 &= ~(CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN | + CONF2_OTGMODE | CONF2_REFFREQ | CONF2_PHY_GPIOMODE);Shouldn't you manipulate
CONF2_OTGMODEin the board code instead? I
suspect value of 0 doesn't fit the host-only configuration (without cable connected, MUSB will think it's a B-device, and the driver will fail to initialize IIRC).
I didn't see any issue in Host/Device only and OTG mode configurations On AM3517? Did you see any issue on DA8xx?
Quoted 7 lines
drivers/usb/musb/Makefile
Quoted 4 lines
drivers/usb/musb/Makefile +2
-0+ devconf2 |= CONF2_SESENDEN | CONF2_VBDTCTEN | CONF2_PHY_PLLON | + CONF2_REFFREQ_13MHZ | CONF2_DATPOL;Reference clock of 13 MHz, not 12? Hmm... Again, shouldn't the board
code select the reference frequency (clock might be external, IIUC)?
Yeah, it's 13Mhz.Clock setting from board would be good to have though Currently there is only one board AM3517EVM.
Quoted 11 lines
Quoted 11 lines
drivers/usb/musb/Makefile +11
-0+/** + * musb_platform_enable - enable interrupts + */ +void musb_platform_enable(struct musb *musb) +{ + void __iomem *reg_base = musb->ctrl_base; + u32 epmask, coremask; + + /* Workaround: setup IRQs through both register sets. */ + epmask = ((musb->epmask & AM3517_TX_EP_MASK) << USB_INTR_TX_SHIFT) | + ((musb->epmask & AM3517_RX_EP_MASK) << USB_INTR_RX_SHIFT);
Quoted 8 lines
drivers/usb/musb/Makefile
Quoted 5 lines
drivers/usb/musb/Makefile +4
-0+ coremask = (0x01ff << USB_INTR_USB_SHIFT); + + musb_writel(reg_base, EP_INTR_MASK_SET_REG, epmask); + musb_writel(reg_base, CORE_INTR_MASK_SET_REG, coremask);Hm, and I thought all CPPI 4.1 based controllers have the same
register layout... alas, I was wrong.
There are changes as AM3517 supports 15Rx/Tx endpoints.
Quoted 6 lines
Quoted 3 lines
+static int
vbus_state= -1;[...]
Quoted 1 line
+static void am3517_source_power(struct musb *musb, int
is_on, intimmediate)
Quoted 13 lines
drivers/usb/musb/Makefile
Quoted 10 lines
drivers/usb/musb/Makefile +9
-0+{ + if (is_on) + is_on = 1; + + if (vbus_state == is_on) + return; + vbus_state = is_on; +} +Without the real GPIOs to manipulate, I don't understand the purpose
of this function...
Correct, this function can be removed.
Quoted 15 lines
drivers/usb/musb/Makefile
Quoted 13 lines
drivers/usb/musb/Makefile +11
-0+static struct timer_list otg_workaround; + +static void otg_timer(unsigned long _musb) +{ + struct musb *musb = (void *)_musb; + void __iomem *mregs = musb->mregs; + u8 devctl; + unsigned long flags; + + /* We poll because AM3517's won't expose several OTG-critical + * status change events (from the transceiver) otherwise.Need one more space before *...
Right.
Quoted 12 lines
drivers/usb/musb/Makefile
Quoted 9 lines
drivers/usb/musb/Makefile +7
-0+ case OTG_STATE_A_WAIT_VFALL: + /* + * Wait till VBUS falls below SessionEnd (~0.2 V); the 1.3 + * RTL seems to mis-handle session "start" otherwise (or in + * our case "recover"), in routine "VBUS was valid by the time + * VBUSERR got reported during enumeration" cases. + */I wonder if all this still true for RTL 1.8 on which DA8xx (and
probably AM3517) MUSB is based...
Need to check on this..though I didn't see any issue in my testing.
Quoted 6 lines
drivers/usb/musb/Makefile
Quoted 4 lines
drivers/usb/musb/Makefile +2
-0+void musb_platform_try_idle(struct musb *musb, unsigned long timeout) +{I wonder how DaVinci gets about without
musb_platfrom_try_idle()...
Hmm..
Quoted 9 lines
drivers/usb/musb/Makefile
Quoted 7 lines
drivers/usb/musb/Makefile +4
-0+static irqreturn_t am3517_interrupt(int irq, void *hci) +{ + /* NOTE: this must complete power-on within 100 ms. */ + am3517_source_power(musb, drvvbus, 0);This call is effectively a NOP.
Yes and so should be removed.
Quoted 10 lines
drivers/usb/musb/Makefile
Quoted 8 lines
drivers/usb/musb/Makefile +6
-0+ if (musb->int_tx || musb->int_rx || musb->int_usb) { + irqreturn_t mret; + + mret = musb_interrupt(musb); + if (mret == IRQ_HANDLED) + ret = IRQ_HANDLED;Not sure why you didn't like ret |=
musb_interrupt(musb)...
Need to verify/clean it. I remember, was getting some issue initially On this path.
Quoted 13 lines
drivers/usb/musb/Makefile
Quoted 10 lines
drivers/usb/musb/Makefile +8
-0+ if (ret != IRQ_HANDLED) { + if (epintr || usbintr) + /* + * We sometimes get unhandled IRQs in the peripheral + * mode from EP0 and SOF... + */ + DBG(2, "Unhandled USB IRQ %08x-%08x\n", + epintr, usbintr);This check shouldn't be needed any more -- EP0 spurious interrupts
have been all chased down...
Ok fine.
Quoted 13 lines
drivers/usb/musb/Makefile
Quoted 9 lines
drivers/usb/musb/Makefile +7
-0+ else if (printk_ratelimit()) + /* + * We've seen series of spurious interrupts in the + * peripheral mode after USB reset and then after some + * time a real interrupt storm starting... + */ + DBG(2, "Spurious IRQ\n");Those turned out to be interrupts caused by CPPI 4.1 descriptor
starvation (for which the controller didn't even have an interrupt bit). I still haven't dealt with them...
and.. AM3517 has got a bit to disable them, anyways this patch currently supports PIO only so this check can be removed also.
Quoted 12 lines
drivers/usb/musb/Makefile
Quoted 10 lines
drivers/usb/musb/Makefile +8
-0+ } + return ret; +} + +int musb_platform_set_mode(struct musb *musb, u8 musb_mode) +{ + WARNING("FIXME: %s not implemented\n", __func__); + return -EIO;Could be implemented using
CONF2_OTGMODE...
Ok fine.
Quoted 14 lines
Quoted 14 lines
drivers/usb/musb/Makefile +13
-0+int __init musb_platform_init(struct musb *musb) +{ + void __iomem *reg_base = musb->ctrl_base; + struct clk *otg_fck; + u32 rev, lvl_intr, sw_reset; + + usb_nop_xceiv_register(); + + musb->xceiv = otg_get_transceiver(); + if (!musb->xceiv) + return -ENODEV; + + /* Mentor is at offset of 0x400 in AM3517 */
Quoted 8 lines
drivers/usb/musb/Makefile
Quoted 6 lines
drivers/usb/musb/Makefile +5
-0+ musb->mregs += USB_MENTOR_CORE_OFFSET; + + /* musb->clock is already set from board/arch files */ + if (IS_ERR(musb->clock)) + return PTR_ERR(musb->clock);This is checked by
musb_core.cnow, no need to duplicate...
Ok fine.
Quoted 6 lines
drivers/usb/musb/Makefile
Quoted 4 lines
drivers/usb/musb/Makefile +2
-0+ if (musb->set_clock) + musb->set_clock(musb->clock, 1);
musb->set_clock()is about to be dropped...
So there is 'else' part.
Quoted 8 lines
drivers/usb/musb/Makefile
Quoted 6 lines
drivers/usb/musb/Makefile +4
-0+ else + clk_enable(musb->clock); + + DBG(2, "usbotg_ck=%lud\n", clk_get_rate(musb->clock));I'd put an empty line after that
DBG()rather than before.
Ok fine.
Quoted 7 lines
drivers/usb/musb/Makefile
Quoted 4 lines
drivers/usb/musb/Makefile +2
-0+ otg_fck = clk_get(musb->controller, "fck"); + clk_enable(otg_fck);Oh, it needs two clocks... Another argument against Felipe dropping
plat->clock. :-)
..
Quoted 11 lines
drivers/usb/musb/Makefile
Quoted 4 lines
drivers/usb/musb/Makefile +2
-0+ + DBG(2, "usbotg_phy_ck=%lud\n", clk_get_rate(otg_fck));Same about empty line here...
drivers/usb/musb/Makefile
Quoted 2 lines
drivers/usb/musb/Makefile +1
-0+ am3517_source_power(musb, 0, 1);Effective NOP...
So need to remove.
Quoted 8 lines
drivers/usb/musb/Makefile
Quoted 6 lines
drivers/usb/musb/Makefile +4
-0+ /* Start the on-chip PHY and its PLL. */ + phy_on(); + + msleep(15);5 ms is not enough?
Need to test and correct.
Quoted 6 lines
drivers/usb/musb/Makefile
Quoted 3 lines
drivers/usb/musb/Makefile +1
-0+ musb->a_wait_bcon = A_WAIT_BCON_TIMEOUT;Hm... that line kept causing a stream of kernel messages for me,
until I removed it. Doesn't it for you?
No I didn't get any error messages.. what messages were you getting ?
Quoted 7 lines
drivers/usb/musb/musb_core.c static void musb_shutdown(struct platform_device
Quoted 6 lines
drivers/usb/musb/musb_core.c +0
-0@@ -982,7 +982,8 @@ static void musb_shutdown(struct platform_device*pdev)
Quoted 11 lines
drivers/usb/musb/musb_core.c static void musb_shutdown(struct platform_device *pdev)
Quoted 7 lines
drivers/usb/musb/musb_core.c +2
-1* more than selecting one of a bunch of predefined configurations. */ #if defined(CONFIG_USB_TUSB6010 ) || \ - defined(CONFIG_ARCH_OMAP2430 ) || defined(CONFIG_ARCH_OMAP3 ) + defined(CONFIG_ARCH_OMAP2430 ) || defined(CONFIG_ARCH_OMAP3 ) || \ + defined(CONFIG_MACH_OMAP3517EVM )Isn't that dependency already covered by
CONFIG_ARCH_OMAP3? Or else I
don't see you adding your #ifdef aroundmusb_platfrom_try_idle()declaration...
Right..this can be removed.
Quoted 2 lines
+int
musb_platform_exit(struct musb *musb){
[...]
Quoted 8 lines
drivers/usb/musb/am3517.c new file +5
-0+phy_off (); + +usb_nop_xceiv_unregister (); + +return 0 ;Quoted 3 lines
You forgot the calls to
clk_disable()for both your clocks...
Ok fine..need to correct.
Thanks,
Ajay
Quoted 2 lines
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 31 lines · Ajay Kumar
Quoted 22 lines
Quoted 22 lines
AM35x has musb interface and uses CPPI4.1 DMA engine. Current patch supports only PIO mode and there are on-going discussions on location of CPPI4.1 DMA.
Signed-off-by Ajay Kumar Gupta <[email protected]>drivers/usb/musb/Kconfig +1
-1tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'@@ -140,7 +140,7 @@ config USB_MUSB_HDRC_HCD config MUSB_PIO_ONLY bool 'Disable DMA (always use PIO)' depends on USB_MUSB_HDRC - default y if USB_TUSB6010 + default USB_TUSB6010 || MACH_OMAP3517EVM help All data is copied between memory and FIFO by the CPU. DMA controllers are ignored.drivers/usb/musb/Makefile +0
-0@@ -19,7 +19,11 @@ ifeq ($(CONFIG_ARCH_OMAP2430),y) endifQuoted 8 lines
drivers/usb/musb/Makefile ifeq ($(CONFIG_ARCH_OMAP2430),y)
Quoted 5 lines
drivers/usb/musb/Makefile +2
-0ifeq ($(CONFIG_ARCH_OMAP3430),y) + ifeq ($(CONFIG_MACH_OMAP3517EVM),y) + musb_hdrc-objs += am3517.oIsn't there some ARCH-level option for AM3517 SoC? Depending on the
board type doesn't really scale well...
Quoted 3 lines
AM3517 is actually based on OMAP3 but musb is different. Unfortunately there is no seperate *_ARCH_* defines for AM3517 alone.
I would really consider adding such... in the current situation the
thing won't scale with addition of some new AM35x boards.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/usb/musb/Makefile +10
-0+static inline void phy_on(void) +{ + u32 devconf2; + + /* + * Start the on-chip PHY and its PLL. + */ + devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); + + devconf2 &= ~(CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN |
Quoted 8 lines
Quoted 8 lines
drivers/usb/musb/Makefile
Quoted 3 lines
drivers/usb/musb/Makefile +1
-0+ CONF2_OTGMODE | CONF2_REFFREQ | CONF2_PHY_GPIOMODE);Shouldn't you manipulate
CONF2_OTGMODEin the board code instead? I
suspect value of 0 doesn't fit the host-only configuration (without cable connected, MUSB will think it's a B-device, and the driver will fail to initialize IIRC).
It will fail to power the port to be precise, so that when you
finally connect a device, it won't get detected. Note that the comments in musb_core.c twice say that the driver expects ID pin to be *forcibly grounded* for the host-only mode while CONF2_OTGMODE's value of 0 will leave it floating.
Quoted 3 lines
I didn't see any issue in Host/Device only and OTG mode configurations On AM3517? Did you see any issue on DA8xx?
Certainly still seeing it with OTGMODE=0 setting in the host mode --
see above.
Quoted 21 lines
Quoted 11 lines
Quoted 11 lines
drivers/usb/musb/Makefile +11
-0+/** + * musb_platform_enable - enable interrupts + */ +void musb_platform_enable(struct musb *musb) +{ + void __iomem *reg_base = musb->ctrl_base; + u32 epmask, coremask; + + /* Workaround: setup IRQs through both register sets. */ + epmask = ((musb->epmask & AM3517_TX_EP_MASK) << USB_INTR_TX_SHIFT) | + ((musb->epmask & AM3517_RX_EP_MASK) << USB_INTR_RX_SHIFT);Quoted 9 lines
drivers/usb/musb/Makefile
Quoted 6 lines
drivers/usb/musb/Makefile +4
-0+ coremask = (0x01ff << USB_INTR_USB_SHIFT); + + musb_writel(reg_base, EP_INTR_MASK_SET_REG, epmask); + musb_writel(reg_base, CORE_INTR_MASK_SET_REG, coremask);Hm, and I thought all CPPI 4.1 based controllers have the same
register layout... alas, I was wrong.
Quoted 2 lines
There are changes as AM3517 supports 15Rx/Tx endpoints.
Yeah, I need to accomodate cppi41_dma.c to the changes by
externalizing the code accessing the acceleration registers...
Quoted 13 lines
Quoted 12 lines
drivers/usb/musb/Makefile
Quoted 9 lines
drivers/usb/musb/Makefile +7
-0+ case OTG_STATE_A_WAIT_VFALL: + /* + * Wait till VBUS falls below SessionEnd (~0.2 V); the 1.3 + * RTL seems to mis-handle session "start" otherwise (or in + * our case "recover"), in routine "VBUS was valid by the time + * VBUSERR got reported during enumeration" cases. + */I wonder if all this still true for RTL 1.8 on which DA8xx (and
probably AM3517) MUSB is based...
Quoted 2 lines
Need to check on this..though I didn't see any issue in my testing.
There should be no issues AFAIU, just the code can be made shorter I
guess...
Quoted 9 lines
Quoted 6 lines
drivers/usb/musb/Makefile
Quoted 4 lines
drivers/usb/musb/Makefile +2
-0+void musb_platform_try_idle(struct musb *musb, unsigned long timeout) +{I wonder how DaVinci gets about without
musb_platfrom_try_idle()...Hmm..
davinci.c should also define musb_platfrom_try_idle() AFAIU... it
should be no different from DA8xx in this respect.
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
drivers/usb/musb/Makefile +4
-0+ if (ret != IRQ_HANDLED) { + if (epintr || usbintr) + /* + * We sometimes get unhandled IRQs in the peripheralQuoted 9 lines
drivers/usb/musb/Makefile
Quoted 6 lines
drivers/usb/musb/Makefile +4
-0+ * mode from EP0 and SOF... + */ + DBG(2, "Unhandled USB IRQ %08x-%08x\n", + epintr, usbintr);This check shouldn't be needed any more -- EP0 spurious interrupts
have been all chased down...
Quoted 2 lines
Ok fine.
However, I seem to have found a new case of unhandled interrupts
today: when I disconnect a device, all I get is this message:
da8xx_interrupt 405: Unhandled USB IRQ 00280000
The driver failed to sense the disconnect, it's only reported when I re-inserted a device... that's something new. Felipe, are you reading this?
Quoted 9 lines
Quoted 6 lines
drivers/usb/musb/Makefile
Quoted 3 lines
drivers/usb/musb/Makefile +1
-0+ musb->a_wait_bcon = A_WAIT_BCON_TIMEOUT;Hm... that line kept causing a stream of kernel messages for me,
until I removed it. Doesn't it for you?No I didn't get any error messages.. what messages were you getting ?
Cannot reproduce them anymore and don't remember which message it was
-- perhaps this:
musb_bus_suspend 2221: trying to suspend as a_wait_vrise is_active=1
Then it probably got fixed by:
Look at the below commit however -- it removed such code from omap2430.c:
Quoted 4 lines
Quoted 2 lines
+int
musb_platform_exit(struct musb *musb){[...]
Quoted 8 lines
Quoted 8 lines
drivers/usb/musb/am3517.c new file +5
-0+phy_off (); + +usb_nop_xceiv_unregister (); + +return 0 ;Quoted 3 lines
You forgot the calls to
clk_disable()for both your clocks...
... and clk_put() call for the functional clock.
Quoted 4 lines
Ok fine..need to correct.
Thanks,
Ajay
WBR, Sergei
Quoted 5 lines · Ajay Kumar Gupta
AM35x has musb interface and uses CPPI4.1 DMA engine. Current patch supports only PIO mode and there are on-going discussions on location of CPPI4.1 DMA.
Signed-off-by Ajay Kumar Gupta <[email protected]>
Overlooked one thing...
[...]
Quoted 3 lines
(quoted diff) +2
-0+int musb_platform_exit(struct musb *musb) +{
[...]
drivers/usb/musb/am3517.c line 521
Quoted 6 lines
drivers/usb/musb/am3517.c new file +5
-0+phy_off (); + +usb_nop_xceiv_unregister (); + +return 0 ;
You forgot the calls to clk_disable() for both your clocks...
Review
Quoted 3 lines
(quoted diff) +2
-0+} +
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html