Skip to contentSkip to conversation

AM35x: Add musb support

PATCH Superseded Ajay Kumar Gupta 3 participants 6 messages May 17, 2010 – May 18, 2010 2 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 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
index af383a8..313559c 100644
@@ -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
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/include/plat/usb.h +21 -0
index 60c734f..c7a019c 100644
@@ -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

#2 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 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
index 7fab721..68efecf 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 || 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
index 9705f71..ce57675 100644
@@ -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
#3 lore raw

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
index b74e664..c68c784 100644
@@ -515,3 +515,34 @@ 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++) {
+			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
index 4093f6d..9c59a8e 100644
@@ -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
#4 lore raw

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.

---
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 +0 -0
index b74e664..c68c784 100644
@@ -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]

#6 lore raw

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.

---
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 +0 -0
index b74e664..c68c784 100644
@@ -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 -0
 	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) {

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

#7 lore raw

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.

---
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 +0 -0
index b74e664..c68c784 100644
@@ -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 -0
 	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) {

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