Skip to contentSkip to conversation

AM35x: Add musb support

PATCH Superseded Ajay Kumar Gupta 4 participants 8 messages May 25, 2010 – Jun 1, 2010 4 messages not in the archive

Subsystems (6)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/3 AM35x: Add musb support

AM35x has musb interface (version 1.8) and uses CPPI41 DMA engine. It has USB phy built inside the IP itself.

Also added ARCH_AM35x which is required to differentiate musb ips between OMAP3x and AM35x. This config would be used to for below purposes,
- Select am3517.c instead of omap2430.c for compilation at drivers/usb/musb directory. Please note there are significant differneces in these two files as musb ip in quite different on AM35x.
- Select workaround codes applicable for AM35x musb issues. one such workaround is for bytewise read issue on AM35x.

---
Changes from v2:
- Added CONFIG_ARCH_AMx

 arch/arm/mach-omap2/Kconfig           |    1 +
 arch/arm/mach-omap2/board-am3517evm.c |   43 +++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/usb-musb.c        |    4 +++
 arch/arm/plat-omap/Kconfig            |    8 ++++++
 arch/arm/plat-omap/include/plat/usb.h |   21 ++++++++++++++++
 5 files changed, 77 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/Kconfig +1 -0
index b31b6f1..52a6752 100644
@@ -84,6 +84,7 @@ config MACH_OMAP3517EVM
 	bool "OMAP3517/ AM3517 EVM board"
 	depends on ARCH_OMAP3
 	select OMAP_PACKAGE_CBB
+	select ARCH_AM35x
 
 config MACH_OMAP3_PANDORA
 	bool "OMAP3 Pandora"
arch/arm/mach-omap2/board-am3517evm.c +43 -0

67 lines not on this page · raw message

arch/arm/mach-omap2/usb-musb.c +4 -0
index 3befddb..883795b 100644
@@ -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/Kconfig +8 -0
index 78b49a6..3f33d75 100644
@@ -5,6 +5,14 @@ menu "TI OMAP Implementations"
 config ARCH_OMAP_OTG
 	bool
 
+config ARCH_AM35x
+	bool
+	help
+	  Select this option if your platform is based on AM35x. As
+	  AM35x has an updated MUSB with CPPI4.1 DMA so this config
+	  is introduced to differentiate musb ip between OMAP3x and
+	  AM35x platforms.
+
 choice
 	prompt "OMAP System Type"
 	default ARCH_OMAP2PLUS
arch/arm/plat-omap/include/plat/usb.h +21 -0
index 98eef53..a32d3af 100644
@@ -191,5 +191,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
#1 lore raw

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. DMA support can be added later once basic CPPI4.1 DMA patch is accepted.

---
Changes from v2:
- Added CONFIG_ARCH_AMx

 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
index 7fab721..f6d4d40 100644
@@ -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 || ARCH_AM35x)
 	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 || ARCH_AM35x
 	help
 	  All data is copied between memory and FIFO by the CPU.
 	  DMA controllers are ignored.
drivers/usb/musb/Makefile +4 -0
index 9705f71..4baa7db 100644
@@ -19,7 +19,11 @@ ifeq ($(CONFIG_ARCH_OMAP2430),y)
 endif
 
 ifeq ($(CONFIG_ARCH_OMAP3430),y)
+   ifeq ($(CONFIG_ARCH_AM35x),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 · 1 line
1.6.2.4

A message that is not in the archive (sent off-list or not yet received): 1274769522-28212-2-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org

#3 lore raw

PATCH v3 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.

---
Changes from v2:
- Added CONFIG_ARCH_AMx

 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
index b74e664..3299c66 100644
@@ -515,3 +515,33 @@ void musb_platform_restore_context(struct musb_context_registers
 	phy_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++) {
+			*(u32 *) dst = musb_readl(fifo, 0);
+			dst += 4;
+		}
+		len %= 4;
+	}
+	if (len > 0) {
+		val = musb_readl(fifo, 0);
+		memcpy(dst, &val, len);
+	}
+}
drivers/usb/musb/musb_core.c +2 -0
index 5f53ac1..e71049c 100644
@@ -262,6 +262,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
 	}
 }
 
+#if !defined(CONFIG_ARCH_AM35x)
 /*
  * 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 · 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): 1274769522-28212-1-git-send-email-ajay.gupta-l0cyMroinI0@public.gmane.org

#5 lore raw

Hello.

Quoted 14 lines · Ajay Kumar Gupta

AM35x has musb interface (version 1.8) and uses CPPI41 DMA engine. It has USB phy built inside the IP itself.

Also added ARCH_AM35x which is required to differentiate musb ips between OMAP3x and AM35x. This config would be used to for below purposes,
- Select am3517.c instead of omap2430.c for compilation at drivers/usb/musb directory. Please note there are significant differneces in these two files as musb ip in quite different on AM35x.
- Select workaround codes applicable for AM35x musb issues. one such workaround is for bytewise read issue on AM35x.

[...]

Quoted 22 lines
arch/arm/mach-omap2/board-am3517evm.c +18 -0
@@ -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;

arch/arm/mach-omap2/board-am3517evm.c static void __init am3517_evm_init_irq(void) · line 406

Quoted 10 lines
arch/arm/mach-omap2/board-am3517evm.c +10 -0
+
+	/*
+	 * 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;

Well, this is only necessary if the board doesn't have pulldown on
the USB ID signal. On DA830 EVM, rev. of the board A had it, and it got removed on the later revisions (presumably it conflicted with OTG function?), so this override became necessary. So, make sure this is indeed necessary on your board as using the overrides isn't generally desirable (they all also override VBUS sensing in addition to ID pin).

arch/arm/mach-omap2/board-am3517evm.c static void __init am3517_evm_init_irq(void) · line 418

Quoted 12 lines
arch/arm/mach-omap2/board-am3517evm.c +9 -0
+#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) || \

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]

#7 lore raw
Quoted 6 lines · Sergei Shtylyov
Quoted 1 line · Ajay Kumar Gupta

AM35x has musb interface (version 1.8) and uses CPPI41

DMA engine.

Quoted 1 line

It has USB phy built inside the IP itself.

So it's more like DaVinci (earlier CPPI as well as integrated PHY) than OMAP3...

Quoted 3 lines
Quoted 1 line

Also added ARCH_AM35x which is required to

differentiate musb ips

Quoted 1 line

between OMAP3x and AM35x.

--
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

#8 lore raw
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

AM35x has musb interface (version 1.8) and uses CPPI41

DMA engine.

Quoted 1 line

It has USB phy built inside the IP itself.

So it's more like DaVinci (earlier CPPI as well as integrated PHY) than OMAP3...

Yes. Actually they removed original musb controller from OMAP3 and replaced it with DaVinci family musb ip.

-Ajay

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Also added ARCH_AM35x which is required to

differentiate musb ips

Quoted 1 line

between OMAP3x and AM35x.

A message that is not in the archive (sent off-list or not yet received): 19F8576C6E063C45BE387C64729E7394044E6D2537-/tLxBxkBPtCIQmiDNMet8wC/[email protected]

#10 lore raw

Hello.

Quoted 9 lines · Ajay Kumar
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

AM35x has musb interface (version 1.8) and uses CPPI41

DMA engine.

Quoted 1 line

It has USB phy built inside the IP itself.

So it's more like DaVinci (earlier CPPI as well as integrated PHY) than OMAP3...

Yes. Actually they removed original musb controller from OMAP3 and replaced it with DaVinci family musb ip.

DA8xx/OMAP-L1x family actually. DaVinci has MUSB RTL 1.3 and CPPI 3.0,
while DA8xx has RTL 1.8 and CPPI 4.1 like AM35x.

Quoted 1 line

-Ajay

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

#11 lore raw
In reply to Sergei Shtylyov

Hi,
[..]

Quoted 8 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * We have to override VBUS/ID signals when MUSB is configured into

the

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * host-only mode -- ID pin will float if no cable is connected, so

the

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * controller won't be able to drive VBUS thinking that it's a B-

device.

Review

Quoted 1 line
(quoted diff) +1 -0
+	 * Otherwise, we want to use the OTG mode and enable VBUS

comparators.

Quoted 11 lines

arch/arm/mach-omap2/board-am3517evm.c static void __init am3517_evm_init_irq(void) · line 406

Quoted 4 lines
arch/arm/mach-omap2/board-am3517evm.c +4 -0
+	 */
+	devconf2 &= ~CONF2_OTGMODE;
+#ifdef	CONFIG_USB_MUSB_HOST
+	devconf2 |=  CONF2_FORCE_HOST;

Well, this is only necessary if the board doesn't have pulldown on
the USB ID signal. On DA830 EVM, rev. of the board A had it, and it got removed on the later revisions (presumably it conflicted with OTG function?), so this override became necessary. So, make sure this is indeed necessary on your board as using the overrides isn't generally desirable (they all also override VBUS sensing in addition to ID pin).

Yes, it's not needed for AM3517EVM

-Ajay

Quoted 16 lines

arch/arm/mach-omap2/board-am3517evm.c static void __init am3517_evm_init_irq(void)

Quoted 11 lines
arch/arm/mach-omap2/board-am3517evm.c +9 -0
+#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

= {

Quoted 2 lines

.port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
#if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \

WBR, Sergei