Skip to contentSkip to conversation

Patches for Freescale MXC SoCs and direct ULPI communication [v3]

PATCH New Daniel Mack 4 participants 10 messages Sep 2, 2009 – Oct 7, 2009

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Sorry for the long delay on this issue.

Here comes another round of four patches to support the EHCI ports on Freescale's MX2/MX3 SoCs.

The difference to the last version I've sent is that the ISP1504 specific drivers has become a generic ULPI driver now with all the defines renamed.

Also the driver does not set DRV_VBUS and DRV_VBUS_EXT blindly anymore but uses a flags field in the otg_transceiver struct which can be specified when creating the device. This allows the adaption of the code to a wider variety of applications.

As a reference, I've added a patch to add board specific support code for the lilly1131 module.

Let me know if that still works for other boards and if that version looks better to you.

Again, #1, #2 and #4 are supposed to go thru the USB folks' channel, while the rest might be picked by Sascha Hauer eventually.

Thanks,
Daniel

[PATCH 1/5] USB OTG: add support for ulpi connected external transceivers [PATCH 2/5] USB OTG: Add generic driver for ULPI OTG transceiver [PATCH 3/5] MXC: Add support for ULPI Viewports
[PATCH 4/5] USB: Add EHCI support for MX27 and MX31 based boards [PATCH 5/5] MX3: add USB support for lilly1131

#1 lore raw

PATCH 1/5 USB OTG: add support for ulpi connected external transceivers

This adds support for OTG transceivers directly connected to the ULPI interface. In particular, the following details are added

- a struct for low level io functions (read/write)
- a priv field to be used as 'viewport' by low level access functions
- an (*init) and (*shutdown) callbacks, along with static inline helpers
- a (*set_vbus) callback to switch the port power on and off
- a flags field for per-transceiver settings
- some defines for the flags bitmask to configure platform specific details

Cc Greg Kroah-Hartman <[email protected]>
Cc David Brownell <[email protected]>
Cc linux-usb at vger.kernel.org
---
 include/linux/usb/otg.h |   68 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 67 insertions(+), 1 deletions(-)
include/linux/usb/otg.h +67 -1
index 2443c0e..52bb917 100644
@@ -33,6 +33,23 @@ enum usb_otg_state {
 	OTG_STATE_A_VBUS_ERR,
 };
 
+#define USB_OTG_PULLUP_ID		(1 << 0)
+#define USB_OTG_PULLDOWN_DP		(1 << 1)
+#define USB_OTG_PULLDOWN_DM		(1 << 2)
+#define USB_OTG_EXT_VBUS_INDICATOR	(1 << 3)
+#define USB_OTG_DRV_VBUS		(1 << 4)
+#define USB_OTG_DRV_VBUS_EXT		(1 << 5)
+
+struct otg_transceiver;
+
+/* for transceivers connected thru an ULPI interface, the user must
+ * provide access ops
+ */
+struct otg_io_access_ops {
+	int (*read)(struct otg_transceiver *otg, u32 reg);
+	int (*write)(struct otg_transceiver *otg, u32 val, u32 reg);
+};
+
 /*
  * the otg driver needs to interact with both device side and host side
  * usb controllers.  it decides which controller is active@a given
@@ -42,6 +59,7 @@ enum usb_otg_state {
 struct otg_transceiver {
 	struct device		*dev;
 	const char		*label;
+	unsigned int		 flags;
 
 	u8			default_a;
 	enum usb_otg_state	state;
@@ -49,10 +67,17 @@ struct otg_transceiver {
 	struct usb_bus		*host;
 	struct usb_gadget	*gadget;
 
+	struct otg_io_access_ops	*io_ops;
+	void __iomem			*io_priv;
+
 	/* to pass extra port status to the root hub */
 	u16			port_status;
 	u16			port_change;
 
+	/* initialize/shutdown the OTG controller */
+	int	(*init)(struct otg_transceiver *otg);
+	void	(*shutdown)(struct otg_transceiver *otg);
+
 	/* bind/unbind the host controller */
 	int	(*set_host)(struct otg_transceiver *otg,
 				struct usb_bus *host);
@@ -65,6 +90,10 @@ struct otg_transceiver {
 	int	(*set_power)(struct otg_transceiver *otg,
 				unsigned mA);
 
+	/* effective for A-peripheral, ignored for B devices */
+	int	(*set_vbus)(struct otg_transceiver *otg,
+				bool enabled);
+
 	/* for non-OTG B devices: set transceiver into suspend mode */
 	int	(*set_suspend)(struct otg_transceiver *otg,
 				int suspend);
@@ -85,6 +114,38 @@ extern int otg_set_transceiver(struct otg_transceiver *);
 extern void usb_nop_xceiv_register(void);
 extern void usb_nop_xceiv_unregister(void);
 
+/* helpers for direct access thru low-level io interface */
+static inline int otg_io_read(struct otg_transceiver *otg, u32 reg)
+{
+	if (otg->io_ops && otg->io_ops->read)
+		return otg->io_ops->read(otg, reg);
+
+	return -EINVAL;
+}
+
+static inline int otg_io_write(struct otg_transceiver *otg, u32 reg, u32 val)
+{
+	if (otg->io_ops && otg->io_ops->write)
+		return otg->io_ops->write(otg, reg, val);
+
+	return -EINVAL;
+}
+
+static inline int
+otg_init(struct otg_transceiver *otg)
+{
+	if (otg->init)
+		return otg->init(otg);
+
+	return 0;
+}
+
+static inline void
+otg_shutdown(struct otg_transceiver *otg)
+{
+	if (otg->shutdown)
+		otg->shutdown(otg);
+}
 
 /* for usb host and peripheral controller drivers */
 extern struct otg_transceiver *otg_get_transceiver(void);
@@ -97,6 +158,12 @@ otg_start_hnp(struct otg_transceiver *otg)
 	return otg->start_hnp(otg);
 }
 
+/* Context: can sleep */
+static inline int
+otg_set_vbus(struct otg_transceiver *otg, bool enabled)
+{
+	return otg->set_vbus(otg, enabled);
+}
 
 /* for HCDs */
 static inline int
@@ -105,7 +172,6 @@ otg_set_host(struct otg_transceiver *otg, struct usb_bus *host)
 	return otg->set_host(otg, host);
 }
 
-
 /* for usb peripheral controller drivers */
 
 /* Context: can sleep */
Signature · 1 line
1.6.3.3
#2 lore raw

PATCH 2/5 USB OTG: Add generic driver for ULPI OTG transceiver

This adds a minimal generic driver for ULPI connected transceivers, using the OTG framework functions recently introduced.

The driver got a table to match the ULPI chips, which currently only has one entry for NXP's ISP 1504 transceiver.

Cc Greg Kroah-Hartman <[email protected]>
Cc David Brownell <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc linux-usb at vger.kernel.org
---
 drivers/usb/Makefile     |    2 +
 drivers/usb/otg/Kconfig  |    9 +++
 drivers/usb/otg/Makefile |    1 +
 drivers/usb/otg/ulpi.c   |  136 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/usb/ulpi.h |    7 +++
 5 files changed, 155 insertions(+), 0 deletions(-)
 create mode 100644 drivers/usb/otg/ulpi.c
 create mode 100644 include/linux/usb/ulpi.h
drivers/usb/Makefile +2 -0
index 19cb7d5..37797e3 100644
@@ -42,3 +42,5 @@ obj-$(CONFIG_USB)		+= misc/
 
 obj-$(CONFIG_USB_ATM)		+= atm/
 obj-$(CONFIG_USB_SPEEDTOUCH)	+= atm/
+
+obj-$(CONFIG_USB_ULPI)		+= otg/
drivers/usb/otg/Kconfig +9 -0
index aa884d0..de56b3d 100644
@@ -41,6 +41,15 @@ config ISP1301_OMAP
 	  This driver can also be built as a module.  If so, the module
 	  will be called isp1301_omap.
 
+config USB_ULPI
+	bool "Generic ULPI Transceiver Driver"
+	depends on ARM
+	help
+	  Enable this to support ULPI connected USB OTG transceivers which
+	  are likely found on embedded boards.
+
+	  The only chip currently supported is NXP's ISP1504
+
 config TWL4030_USB
 	tristate "TWL4030 USB Transceiver Driver"
 	depends on TWL4030_CORE && REGULATOR_TWL4030
drivers/usb/otg/Makefile +1 -0
index 2081678..aeb49a8 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_USB_GPIO_VBUS)	+= gpio_vbus.o
 obj-$(CONFIG_ISP1301_OMAP)	+= isp1301_omap.o
 obj-$(CONFIG_TWL4030_USB)	+= twl4030-usb.o
 obj-$(CONFIG_NOP_USB_XCEIV)	+= nop-usb-xceiv.o
+obj-$(CONFIG_USB_ULPI)		+= ulpi.o
 
 ccflags-$(CONFIG_USB_DEBUG)	+= -DDEBUG
 ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
drivers/usb/otg/ulpi.c new file +136 -0

136 lines not on this page · raw message

include/linux/usb/ulpi.h new file +7 -0
new file mode 100644
index 0000000..20675c6
@@ -0,0 +1,7 @@
+#ifndef __LINUX_USB_ULPI_H
+#define __LINUX_USB_ULPI_H
+
+struct otg_transceiver *otg_ulpi_create(struct otg_io_access_ops *ops,
+					unsigned int flags);
+
+#endif /* __LINUX_USB_ULPI_H */
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 3/5 MXC: Add support for ULPI Viewports

The ARC USB OTG Core has support for accessing ULPI tranceivers through so called ULPI viewports. Export a set of function for use with the USB OTG framework.

Cc Greg Kroah-Hartman <[email protected]>
Cc David Brownell <[email protected]>
Cc linux-usb at vger.kernel.org
---
 arch/arm/plat-mxc/Kconfig             |    3 +
 arch/arm/plat-mxc/Makefile            |    1 +
 arch/arm/plat-mxc/include/mach/ulpi.h |    7 ++
 arch/arm/plat-mxc/ulpi.c              |  111 +++++++++++++++++++++++++++++++++
 4 files changed, 122 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-mxc/include/mach/ulpi.h
 create mode 100644 arch/arm/plat-mxc/ulpi.c
arch/arm/plat-mxc/Kconfig +3 -0
index 0617c19..5254670 100644
@@ -53,6 +53,9 @@ config MXC_PWM
 	help
 	  Enable support for the i.MX PWM controller(s).
 
+config MXC_ULPI
+	bool
+
 config ARCH_HAS_RNGA
 	bool
 	depends on ARCH_MXC
arch/arm/plat-mxc/Makefile +1 -0
index e3212c8..545412f 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_ARCH_MX1) += iomux-mx1-mx2.o dma-mx1-mx2.o
 obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o
 obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
 obj-$(CONFIG_MXC_PWM)  += pwm.o
+obj-$(CONFIG_MXC_ULPI) += ulpi.o
arch/arm/plat-mxc/include/mach/ulpi.h new file +7 -0
new file mode 100644
index 0000000..96b6ab4
@@ -0,0 +1,7 @@
+#ifndef __MACH_ULPI_H
+#define __MACH_ULPI_H
+
+extern struct otg_io_access_ops mxc_ulpi_access_ops;
+
+#endif /* __MACH_ULPI_H */
+
arch/arm/plat-mxc/ulpi.c new file +111 -0

111 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#4 lore raw

PATCH 4/5 USB: Add EHCI support for MX27 and MX31 based boards

The Freescale MX27 and MX31 SoCs have a EHCI controller onboard. The controller is capable of USB on the go. This patch adds a driver to support all three of them.

Users have to pass details about serial interface configuration in the platform data.

The USB OTG core used here is the ARC core, so the driver should be renamed and probably be merged with ehci-fsl.c eventually.

Cc Greg Kroah-Hartman <[email protected]>
Cc David Brownell <[email protected]>
Cc linux-usb at vger.kernel.org
---
 arch/arm/plat-mxc/Makefile                |    2 +
 arch/arm/plat-mxc/ehci.c                  |   90 +++++++++
 arch/arm/plat-mxc/include/mach/mxc_ehci.h |   37 ++++
 drivers/usb/Kconfig                       |    1 +
 drivers/usb/host/Kconfig                  |    7 +
 drivers/usb/host/ehci-hcd.c               |    5 +
 drivers/usb/host/ehci-mxc.c               |  296 +++++++++++++++++++++++++++++
 7 files changed, 438 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-mxc/ehci.c
 create mode 100644 arch/arm/plat-mxc/include/mach/mxc_ehci.h
 create mode 100644 drivers/usb/host/ehci-mxc.c
arch/arm/plat-mxc/Makefile +2 -0
index 545412f..20a9dba 100644
@@ -10,3 +10,5 @@ obj-$(CONFIG_ARCH_MX2) += iomux-mx1-mx2.o dma-mx1-mx2.o
 obj-$(CONFIG_ARCH_MXC_IOMUX_V3) += iomux-v3.o
 obj-$(CONFIG_MXC_PWM)  += pwm.o
 obj-$(CONFIG_MXC_ULPI) += ulpi.o
+obj-$(CONFIG_USB_EHCI_MXC)	+= ehci.o
+
arch/arm/plat-mxc/ehci.c new file +90 -0

90 lines not on this page · raw message

arch/arm/plat-mxc/include/mach/mxc_ehci.h new file +37 -0
new file mode 100644
index 0000000..8f79623
@@ -0,0 +1,37 @@
+#ifndef __INCLUDE_ASM_ARCH_MXC_EHCI_H
+#define __INCLUDE_ASM_ARCH_MXC_EHCI_H
+
+/* values for portsc field */
+#define MXC_EHCI_PHY_LOW_POWER_SUSPEND	(1 << 23)
+#define MXC_EHCI_FORCE_FS		(1 << 24)
+#define MXC_EHCI_UTMI_8BIT		(0 << 28)
+#define MXC_EHCI_UTMI_16BIT		(1 << 28)
+#define MXC_EHCI_SERIAL			(1 << 29)
+#define MXC_EHCI_MODE_UTMI		(0 << 30)
+#define MXC_EHCI_MODE_PHILIPS		(1 << 30)
+#define MXC_EHCI_MODE_ULPI		(2 << 30)
+#define MXC_EHCI_MODE_SERIAL		(3 << 30)
+
+/* values for flags field */
+#define MXC_EHCI_INTERFACE_DIFF_UNI	(0 << 0)
+#define MXC_EHCI_INTERFACE_DIFF_BI	(1 << 0)
+#define MXC_EHCI_INTERFACE_SINGLE_UNI	(2 << 0)
+#define MXC_EHCI_INTERFACE_SINGLE_BI	(3 << 0)
+#define MXC_EHCI_INTERFACE_MASK		(0xf)
+
+#define MXC_EHCI_POWER_PINS_ENABLED	(1 << 5)
+#define MXC_EHCI_TTL_ENABLED		(1 << 6)
+
+struct mxc_usbh_platform_data {
+	int (*init)(struct platform_device *pdev);
+	int (*exit)(struct platform_device *pdev);
+
+	unsigned int		 portsc;
+	unsigned int		 flags;
+	struct otg_transceiver	*otg;
+};
+
+int mxc_set_usbcontrol(int port, unsigned int flags);
+
+#endif /* __INCLUDE_ASM_ARCH_MXC_EHCI_H */
+
drivers/usb/Kconfig +1 -0
index dcd49f1..3ffaed5 100644
@@ -58,6 +58,7 @@ config USB_ARCH_HAS_EHCI
 	default y if PPC_83xx
 	default y if SOC_AU1200
 	default y if ARCH_IXP4XX
+	default y if ARCH_MXC
 	default PCI
 
 # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
drivers/usb/host/Kconfig +7 -0
index 1a920c7..923b8d8 100644
@@ -105,6 +105,13 @@ config USB_EHCI_FSL
 	---help---
 	  Variation of ARC USB block used in some Freescale chips.
 
+config USB_EHCI_MXC
+	bool "Support for Freescale on-chip EHCI USB controller"
+	depends on USB_EHCI_HCD && ARCH_MXC
+	select USB_EHCI_ROOT_HUB_TT
+	---help---
+	  Variation of ARC USB block used in some Freescale chips.
+
 config USB_EHCI_HCD_PPC_OF
 	bool "EHCI support for PPC USB controller on OF platform bus"
 	depends on USB_EHCI_HCD && PPC_OF
drivers/usb/host/ehci-hcd.c +5 -0
index 7d03549..a7dff61 100644
@@ -1091,6 +1091,11 @@ MODULE_LICENSE ("GPL");
 #define	PLATFORM_DRIVER		ehci_fsl_driver
 #endif
 
+#ifdef CONFIG_USB_EHCI_MXC
+#include "ehci-mxc.c"
+#define PLATFORM_DRIVER		ehci_mxc_driver
+#endif
+
 #ifdef CONFIG_SOC_AU1200
 #include "ehci-au1xxx.c"
 #define	PLATFORM_DRIVER		ehci_hcd_au1xxx_driver
drivers/usb/host/ehci-mxc.c new file +296 -0

296 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#5 lore raw

PATCH 5/5 MX3: add USB support for lilly1131

This adds support for OTG, host1 and host2 ports on lilly1131.

---
 arch/arm/mach-mx3/Kconfig     |    1 +
 arch/arm/mach-mx3/mx31lilly.c |  147 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+), 0 deletions(-)
arch/arm/mach-mx3/Kconfig +1 -0
index 851f245..d69fa73 100644
@@ -68,6 +68,7 @@ config MACH_MX31MOBOARD
 config MACH_MX31LILLY
 	bool "Support MX31 LILLY-1131 platforms (INCO startec)"
 	select ARCH_MX31
+	select MXC_ULPI
 	help
 	  Include support for mx31 based LILLY1131 modules. This includes
 	  specific configurations for the board and its peripherals.
arch/arm/mach-mx3/mx31lilly.c +147 -0

171 lines not on this page · raw message

Signature · 1 line
1.6.3.3
#6 lore raw
In reply to Daniel Mack

Hi Daniel,

Quoted 9 lines · Daniel Mack

Sorry for the long delay on this issue.

Here comes another round of four patches to support the EHCI ports on Freescale's MX2/MX3 SoCs.

The difference to the last version I've sent is that the ISP1504 specific drivers has become a generic ULPI driver now with all the defines renamed.

Quoted 7 lines

Also the driver does not set DRV_VBUS and DRV_VBUS_EXT blindly anymore but uses a flags field in the otg_transceiver struct which can be specified when creating the device. This allows the adaption of the code to a wider variety of applications.

As a reference, I've added a patch to add board specific support code for the lilly1131 module.

I have such a patch for mx31moboard too. Sascha, should I send it to you now or wait ?

Quoted 3 lines

Let me know if that still works for other boards and if that version looks better to you.

I cannnot say much about the code, it seems that you have addressed all the comments on the previous version (especially about the ulpi genericity). I can however confirm that it still works well on mx31moboard.

Quoted 4 lines

Again, #1, #2 and #4 are supposed to go thru the USB folks' channel, while the rest might be picked by Sascha Hauer eventually.

Quoted 8 lines

Thanks,
Daniel

[PATCH 1/5] USB OTG: add support for ulpi connected external transceivers [PATCH 2/5] USB OTG: Add generic driver for ULPI OTG transceiver [PATCH 3/5] MXC: Add support for ULPI Viewports
[PATCH 4/5] USB: Add EHCI support for MX27 and MX31 based boards [PATCH 5/5] MX3: add USB support for lilly1131

Val

Signature · 4 lines
Valentin Longchamp, PhD Student, EPFL-STI-LSRO1
valentin.longchamp at epfl.ch, Phone: +41216937827
http://people.epfl.ch/valentin.longchamp
MEA3485, Station 9, CH-1015 Lausanne
#7 lore raw

Hi,

Back from holiday...

Quoted 17 lines · Valentin Longchamp

Hi Daniel,

Quoted 14 lines · Daniel Mack

Sorry for the long delay on this issue.

Here comes another round of four patches to support the EHCI ports on Freescale's MX2/MX3 SoCs.

The difference to the last version I've sent is that the ISP1504 specific drivers has become a generic ULPI driver now with all the defines renamed.

Also the driver does not set DRV_VBUS and DRV_VBUS_EXT blindly anymore but uses a flags field in the otg_transceiver struct which can be specified when creating the device. This allows the adaption of the code to a wider variety of applications.

Quoted 5 lines
Quoted 2 lines

As a reference, I've added a patch to add board specific support code for the lilly1131 module.

I have such a patch for mx31moboard too. Sascha, should I send it to you now or wait ?

Please wait till it's clear that the patches go in the way they are, otherwise I end up keeping patches that still need fixups.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#8 lore raw

What is the status regarding to mainline about these patches?

Have they been applied somewhere?

Thanks.

Signature · 10 lines
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20091007/d74e2226/attachment.htm>
#9 lore raw
Quoted 3 lines · javier Martin

What is the status regarding to mainline about these patches?

Have they been applied somewhere?

Not yet. There are some API change requests pending which I will do as soon as I can. I'm currently abroad without access to the hardware, so I can't work on this issue. Please be patient.

Thanks,
Daniel