AM35x: Add musb support
Subsystems (6)
PATCH v3 1/3 AM35x: Add musb support
AM35x has musb interface (version 1.8) and uses CPPI41 DMA engine. It supports upto 500mA of power in host mode.
---
Patch created against linus'tree + all musb patches in Greg's queue and patches available in linux-omap/for-next branch.
arch/arm/mach-omap2/board-am3517evm.c | 43 +++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/usb-musb.c | 4 +++ arch/arm/plat-omap/include/plat/usb.h | 21 ++++++++++++++++ 3 files changed, 68 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-am3517evm.c +43 -0
@@ -35,6 +35,7 @@#include <plat/control.h> #include <plat/usb.h> #include <plat/display.h> +#include <plat/control.h> #include "mux.h"
@@ -375,6 +376,43 @@ static void __init am3517_evm_init_irq(void)omap_gpio_init (); } +static struct omap_musb_board_data musb_board_data = { + .interface_type =MUSB_INTERFACE_ULPI , + .mode =MUSB_OTG , + .power =500 , +}; + +static __init void am3517_evm_musb_init (void ) +{ +u32 devconf2; + +/* +* Set up USB clock/mode in the DEVCONF2 register. +*/ + devconf2 =omap_ctrl_readl (AM35XX_CONTROL_DEVCONF2 ); + +/* USB2.0 PHY reference clock is 13 MHz */ + devconf2 &= ~CONF2_REFFREQ ; + devconf2 |=CONF2_REFFREQ_13MHZ ; + +/* +* We have to override VBUS/ID signals when MUSB is configured into the +* host-only mode -- ID pin will float if no cable is connected, so the +* controller won't be able to drive VBUS thinking that it's a B-device. +* Otherwise, we want to use the OTG mode and enable VBUS comparators. +*/ + devconf2 &= ~CONF2_OTGMODE ; +#ifdef CONFIG_USB_MUSB_HOST + devconf2 |=CONF2_FORCE_HOST ; +#else + devconf2 |=CONF2_SESENDEN |CONF2_VBDTCTEN ; +#endif + +omap_ctrl_writel (devconf2,AM35XX_CONTROL_DEVCONF2 ); + +usb_musb_init (&musb_board_data); +} +static const struct ehci_hcd_omap_platform_data ehci_pdata__initconst = { .port_mode[0 ] =EHCI_HCD_OMAP_MODE_PHY , #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
@@ -393,6 +431,8 @@ static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {#ifdef CONFIG_OMAP_MUX static struct omap_board_mux board_mux[]__initdata = { +/* USB OTG DRVVBUS offset = 0x212 */ +OMAP3_MUX (SAD2D_MCAD23 ,OMAP_MUX_MODE0 |OMAP_PIN_INPUT_PULLDOWN ), { .reg_offset =OMAP_MUX_TERMINATOR }, };#else
@@ -459,6 +499,9 @@ static void __init am3517_evm_init(void) ARRAY_SIZE(am3517evm_i2c1_boardinfo));/*Ethernet*/ am3517_evm_ethernet_init (&am3517_evm_emac_pdata); + +/* MUSB */ +am3517_evm_musb_init (); }static void __init am3517_evm_map_io (void )
arch/arm/mach-omap2/usb-musb.c +4 -0
@@ -21,6 +21,7 @@#include <linux/usb/musb.h> #include <mach/irqs.h> +#include <mach/am35xx.h> #include <plat/usb.h> #ifdef CONFIG_USB_MUSB_SOC
@@ -69,6 +70,9 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data) {if (cpu_is_omap243x ()) { musb_resources[0 ].start =OMAP243X_HS_BASE ; + }else if (cpu_is_omap3517 ()) { + musb_resources[0 ].start =AM35XX_IPSS_USBOTGSS_BASE ; + musb_resources[1 ].start =INT_35XX_USBOTG_IRQ ; }else if (cpu_is_omap34xx ()) { musb_resources[0 ].start =OMAP34XX_HSUSB_OTG_BASE ; }else if (cpu_is_omap44xx ()) {
arch/arm/plat-omap/include/plat/usb.h +21 -0
@@ -168,5 +168,26 @@ void omap_usb_init(struct omap_usb_config *pdata);# define USBT2TLL5PI (1 << 17)# define USB0PUENACTLOI (1 << 16)# define USBSTANDBYCTRL (1 << 15) +/* AM3517 */ +/* USB 2.0 PHY Control */ +#define CONF2_PHY_GPIOMODE (1 << 23) +#define CONF2_OTGMODE (3 << 14) +#define CONF2_NO_OVERRIDE (0 << 14) +#define CONF2_FORCE_HOST (1 << 14) +#define CONF2_FORCE_DEVICE (2 << 14) +#define CONF2_FORCE_HOST_VBUS_LOW (3 << 14) +#define CONF2_SESENDEN (1 << 13) +#define CONF2_VBDTCTEN (1 << 12) +#define CONF2_REFFREQ_24MHZ (2 << 8) +#define CONF2_REFFREQ_26MHZ (7 << 8) +#define CONF2_REFFREQ_13MHZ (6 << 8) +#define CONF2_REFFREQ (0xf << 8) +#define CONF2_PHYCLKGD (1 << 7) +#define CONF2_VBUSSENSE (1 << 6) +#define CONF2_PHY_PLLON (1 << 5) +#define CONF2_RESET (1 << 4) +#define CONF2_PHYPWRDN (1 << 3) +#define CONF2_OTGPWRDN (1 << 2) +#define CONF2_DATPOL (1 << 1)#endif /* __ASM_ARCH_OMAP_USB_H */
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
A message that is not in the archive (sent off-list or not yet received): 1274093235-7616-1-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org
PATCH v3 2/3 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.
---
Patch created against linus'tree + all musb patches in Greg's queue Changes from v2:
- fixed multipline comment style
- Removed unneeded 'coremask' variable
- Added 'break' instead of 'return'
- Updated musb_platform_init signature
I had to use MACH_OMAP3517EVM as there is no ARCH_xxx config specific to AM3517 platforms other than ARCH_OMAP3.
drivers/usb/musb/Kconfig | 4 +- drivers/usb/musb/Makefile | 4 + drivers/usb/musb/am3517.c | 517 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 523 insertions(+), 2 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, ...)'
@@ -144,7 +144,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_ARCH_OMAP4),y)
drivers/usb/musb/am3517.c new file +517 -0
517 lines not on this page · raw message
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
PATCH 3/3 musb: AM35x: Workaround for fifo read issue
AM35x supports only 32bit read operations so we need to have workaround for 8bit and 16bit read operations.
---
Patch created against linus'tree + all musb patches in Greg's queue Changes from v2:
- fixed multipline comment style
drivers/usb/musb/am3517.c | 31 +++++++++++++++++++++++++++++++ drivers/usb/musb/musb_core.c | 2 ++ 2 files changed, 33 insertions(+), 0 deletions(-)
drivers/usb/musb/am3517.c +31 -0
@@ -515,3 +515,34 @@ 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
@@ -262,6 +262,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 */
@@ -299,6 +300,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)readsb (fifo, dst, len); } } +#endif #endif /* normal PIO */
Signature · 1 line
1.6.2.4
Re: [PATCH 3/3] musb: AM35x: Workaround for fifo read issue
Hello.
Quoted 20 lines · Ajay Kumar Gupta
AM35x supports only 32bit read operations so we need to have workaround for 8bit and 16bit read operations.
Signed-off-by Ajay Kumar Gupta <[email protected]>---
Patch created against linus'tree + all musb patches in Greg's queue Changes from v2:
- fixed multipline comment styledrivers/usb/musb/am3517.c | 31 +++++++++++++++++++++++++++++++ drivers/usb/musb/musb_core.c | 2 ++ 2 files changed, 33 insertions(+), 0 deletions(-)drivers/usb/musb/am3517.c +0
-0@@ -515,3 +515,34 @@ void musb_platform_restore_context(struct musb_context_registers phy_on(); }#endif
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 527
Quoted 10 lines
drivers/usb/musb/am3517.c +10
-0+ +/* 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 ) {
You don't need to put likely() in parens.
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 529
Quoted 2 lines
drivers/usb/musb/am3517.c +2
-0+readsl (fifo, dst, len >>2 ); + dst += (len & ~0x03 );
You don't need parens here as well.
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 539
Quoted 10 lines
drivers/usb/musb/am3517.c +10
-0+ 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 );
Can't you do away with memcpy() here?
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 548
Quoted 9 lines
drivers/usb/musb/am3517.c +9
-0+ dst +=4 ; + } + len %=4 ; + } +if (len >0 ) { + val =musb_readl (fifo,0 ); +memcpy (dst, &val, len); + } +}
WBR, Sergei
A message that is not in the archive (sent off-list or not yet received): [email protected]
RE: [PATCH 3/3] musb: AM35x: Workaround for fifo read issue
Hi,
Quoted 20 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct
Quoted 17 lines · Ajay Kumar Gupta
AM35x supports only 32bit read operations so we need to have workaround for 8bit and 16bit read operations.
Signed-off-by Ajay Kumar Gupta <[email protected]>---
Patch created against linus'tree + all musb patches in Greg's queue Changes from v2:
- fixed multipline comment styledrivers/usb/musb/am3517.c | 31 +++++++++++++++++++++++++++++++ drivers/usb/musb/musb_core.c | 2 ++ 2 files changed, 33 insertions(+), 0 deletions(-)drivers/usb/musb/am3517.c +0
-0@@ -515,3 +515,34 @@ void musb_platform_restore_context(struct
musb_context_registers
Quoted 15 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 527
Quoted 13 lines
drivers/usb/musb/am3517.c +10
-0phy_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 ) {You don't need to put
likely()in parens.
Ok.
Quoted 5 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 529
Quoted 3 lines
drivers/usb/musb/am3517.c +2
-0+readsl (fifo, dst, len >>2 ); + dst += (len & ~0x03 );You don't need parens here as well.
Ok.
Quoted 13 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 539
Quoted 11 lines
drivers/usb/musb/am3517.c +10
-0+ 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 );Can't you do away with
memcpy()here?
Are you asking for change below?
*(u32 *)dst = musb_readl(fifo, 0);
-Ajay
Quoted 12 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 548
Quoted 10 lines
drivers/usb/musb/am3517.c +9
-0+ dst +=4 ; + } + len %=4 ; + } +if (len >0 ) { + val =musb_readl (fifo,0 ); +memcpy (dst, &val, len); + } +}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
RE: [PATCH 3/3] musb: AM35x: Workaround for fifo read issue
Hi,
Quoted 59 lines
Quoted 20 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct
Quoted 17 lines · Ajay Kumar Gupta
AM35x supports only 32bit read operations so we need to have workaround for 8bit and 16bit read operations.
Signed-off-by Ajay Kumar Gupta <[email protected]>---
Patch created against linus'tree + all musb patches in Greg's queue Changes from v2:
- fixed multipline comment styledrivers/usb/musb/am3517.c | 31 +++++++++++++++++++++++++++++++ drivers/usb/musb/musb_core.c | 2 ++ 2 files changed, 33 insertions(+), 0 deletions(-)drivers/usb/musb/am3517.c +0
-0@@ -515,3 +515,34 @@ void musb_platform_restore_context(struct
musb_context_registersQuoted 15 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 527
Quoted 13 lines
drivers/usb/musb/am3517.c +10
-0phy_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 ) {You don't need to put
likely()in parens.Ok.
Quoted 5 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 529
Quoted 3 lines
drivers/usb/musb/am3517.c +2
-0+readsl (fifo, dst, len >>2 ); + dst += (len & ~0x03 );You don't need parens here as well.
Ok.
Quoted 13 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 539
Quoted 11 lines
drivers/usb/musb/am3517.c +10
-0+ 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 );Can't you do away with
memcpy()here?
Quoted 2 lines
Are you asking for change below?
*(u32 *)dst =musb_readl(fifo, 0);
This one is safe and works but the other memcpy (below one) would not be safe to replace as the length would be 1 to 3 bytes.
-Ajay
Quoted 15 lines
Quoted 11 lines
drivers/usb/musb/am3517.c void musb_platform_restore_context(struct musb_context_registers · line 548
Quoted 9 lines
drivers/usb/musb/am3517.c +9
-0+ dst +=4 ; + } + len %=4 ; + } +if (len >0 ) { + val =musb_readl (fifo,0 ); +memcpy (dst, &val, len); + } +}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