Skip to contentSkip to conversation

USB: Add driver for NXP ISP1301 USB transceiver

PATCH Superseded Roland Stigge 4 participants 10 messages Apr 16, 2012

Subsystems (4)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 USB: Add driver for NXP ISP1301 USB transceiver

This very-lowlevel driver registers the NXP ISP1301 chip via the I2C subsystem. The chip is the USB transceiver shared by ohci-nxp, lpc32xx_udc (gadget) and isp1301_omap.

Following patches let the respective USB host and gadget drivers use this driver, instead of duplicating ISP1301 handling.

---

Applies to v3.4-rc3

This driver needs to be probe()d before the respective USB driver using it. For modules, this is handled via the module dependency. When linking statically, it is done via linking order in the Makefile (misc/ before host/ and the gadget/).

Currently, only one ISP1301 chip is supported. To support multiple instances, we would need a mechanism to identify the respective chips via DT (and static resources or platform data) to be referenced by the higher level USB driver at isp1301_get_client(). Any suggestions?

 drivers/usb/Makefile        |    5 ++
 drivers/usb/misc/Kconfig    |   12 ++++++
 drivers/usb/misc/Makefile   |    1 
 drivers/usb/misc/isp1301.c  |   64 ++++++++++++++++++++++++++++++++++
 include/linux/usb/isp1301.h |   82 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 163 insertions(+), 1 deletion(-)
drivers/usb/Makefile +4 -1
@@ -12,6 +12,10 @@ obj-$(CONFIG_USB_DWC3)		+= dwc3/
 
 obj-$(CONFIG_USB_MON)		+= mon/
 
+# misc/ before ohci and gadget for probe order when linking statically:
+# misc/isp1301.c is used by ohci and gadget
+obj-$(CONFIG_USB)		+= misc/
+
 obj-$(CONFIG_PCI)		+= host/
 obj-$(CONFIG_USB_EHCI_HCD)	+= host/
 obj-$(CONFIG_USB_ISP116X_HCD)	+= host/
@@ -45,7 +49,6 @@ obj-$(CONFIG_USB_MICROTEK)	+= image/
 
 obj-$(CONFIG_USB_SERIAL)	+= serial/
 
-obj-$(CONFIG_USB)		+= misc/
 obj-$(CONFIG_EARLY_PRINTK_DBGP)	+= early/
 
 obj-$(CONFIG_USB_ATM)		+= atm/
drivers/usb/misc/Kconfig +12 -0
@@ -231,6 +231,18 @@ config USB_ISIGHTFW
 	  driver beforehand. Tools for doing so are available at
 	  http://bersace03.free.fr
 
+config USB_ISP1301
+	tristate "NXP ISP1301 USB transceiver support"
+	depends on USB
+	depends on I2C
+	help
+	  Say Y here to add support for the NXP ISP1301 USB transceiver driver.
+	  This chip is typically used as USB transceiver for USB host, gadget
+	  and OTG drivers (to be selected separately).
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called isp1301.
+
 config USB_YUREX
 	tristate "USB YUREX driver support"
 	depends on USB
drivers/usb/misc/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_USB_FTDI_ELAN)		+= ftdi-ela
 obj-$(CONFIG_USB_IDMOUSE)		+= idmouse.o
 obj-$(CONFIG_USB_IOWARRIOR)		+= iowarrior.o
 obj-$(CONFIG_USB_ISIGHTFW)		+= isight_firmware.o
+obj-$(CONFIG_USB_ISP1301)		+= isp1301.o
 obj-$(CONFIG_USB_LCD)			+= usblcd.o
 obj-$(CONFIG_USB_LD)			+= ldusb.o
 obj-$(CONFIG_USB_LED)			+= usbled.o
drivers/usb/misc/isp1301.c new file +64 -0

64 lines not on this page · raw message

include/linux/usb/isp1301.h new file +82 -0

82 lines not on this page · raw message

#1 lore raw

PATCH v2 2/3 USB: gadget driver for LPC32xx

This patch adds a USB gadget driver for the LPC32xx ARM SoC.

---

Changes since v1:
* Added DT support
* Removed bad (direct) resource handling
* Use resource_size()
* Implemented set_wedge
* Changed types in descriptors and structs, mostly to u32
* Use bool for boolean types instead of bitfields:1
* Fix redundant ep_*() names in print macros
* Replace static IO_ADDRESS() with ioremap()ed macro versions
* Removed function forward declarations
* Replaced /proc file entry with debugfs file
* Replaced mdelay() with msleep()
* Replaced __raw_readl/__raw_writel with readl/writel
* Commented on schedule_work() for deferred pullup setting
* Add cpu_relax() to busy loop in udc_protocol_cmd_w()
* Use __devexit for lpc32xx_udc_remove() and __devexit_p() in lpc32xx_udc_driver
* Separated out the isp1301 I2C driver for setting up the external USB transceiver, to be re-used by the omap and ohci-nxp drivers which currently duplicate this (see patch 1/3)

Thanks to Alan Stern and Arnd Bergmann for reviewing!

Applies to v3.4-rc3

 Documentation/devicetree/bindings/usb/lpc32xx-udc.txt |   21 
 drivers/usb/gadget/Kconfig                            |   11 
 drivers/usb/gadget/Makefile                           |    1 
 drivers/usb/gadget/gadget_chips.h                     |    3 
 drivers/usb/gadget/lpc32xx_udc.c                      | 3533 ++++++++++++++++++
 5 files changed, 3569 insertions(+)
Documentation/devicetree/bindings/usb/lpc32xx-udc.txt new file +21 -0
@@ -0,0 +1,21 @@
+* NXP LPC32xx SoC USB Device Controller (UDC)
+
+Required properties:
+- compatible: must be "nxp,lpc32xx-udc"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- interrupts: The USB interrupts:
+              * USB Device Low Priority Interrupt
+              * USB Device High Priority Interrupt
+              * USB Device DMA Interrupt
+              * External USB Transceiver Interrupt (OTG ATX)
+
+Example:
+
+	usbd at 31020000 {
+		compatible = "nxp,lpc32xx-udc";
+		reg = <0x31020000 0x300>;
+		interrupt-parent = <&mic>;
+		interrupts = <0x3d 0>, <0x3e 0>, <0x3c 0>, <0x3a 0>;
+		status = "disable";
+	};
drivers/usb/gadget/Kconfig +11 -0
@@ -147,6 +147,17 @@ config USB_AT91
 	   dynamically linked module called "at91_udc" and force all
 	   gadget drivers to also be dynamically linked.
 
+config USB_LPC32XX
+	tristate "LPC32XX USB Peripheral Controller"
+	depends on ARCH_LPC32XX
+	select USB_ISP1301
+	help
+	   This option selects the USB device controller in the LPC32xx SoC.
+
+	   Say "y" to link the driver statically, or "m" to build a
+	   dynamically linked module called "lpc32xx_udc" and force all
+	   gadget drivers to also be dynamically linked.
+
 config USB_ATMEL_USBA
 	tristate "Atmel USBA"
 	select USB_GADGET_DUALSPEED
drivers/usb/gadget/Makefile +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_USB_CI13XXX_PCI)	+= ci13xxx
 obj-$(CONFIG_USB_S3C_HSOTG)	+= s3c-hsotg.o
 obj-$(CONFIG_USB_S3C_HSUDC)	+= s3c-hsudc.o
 obj-$(CONFIG_USB_LANGWELL)	+= langwell_udc.o
+obj-$(CONFIG_USB_LPC32XX)	+= lpc32xx_udc.o
 obj-$(CONFIG_USB_EG20T)		+= pch_udc.o
 obj-$(CONFIG_USB_MV_UDC)	+= mv_udc.o
 mv_udc-y			:= mv_udc_core.o
drivers/usb/gadget/gadget_chips.h +3 -0
@@ -37,6 +37,7 @@
 #define gadget_is_goku(g)		(!strcmp("goku_udc", (g)->name))
 #define gadget_is_imx(g)		(!strcmp("imx_udc", (g)->name))
 #define gadget_is_langwell(g)		(!strcmp("langwell_udc", (g)->name))
+#define gadget_is_lpc32xx(g)		(!strcmp("lpc32xx_udc", (g)->name))
 #define gadget_is_m66592(g)		(!strcmp("m66592_udc", (g)->name))
 #define gadget_is_musbhdrc(g)		(!strcmp("musb-hdrc", (g)->name))
 #define gadget_is_net2272(g)		(!strcmp("net2272", (g)->name))
@@ -118,6 +119,8 @@ static inline int usb_gadget_controller_
 		return 0x31;
 	else if (gadget_is_dwc3(gadget))
 		return 0x32;
+	else if (gadget_is_lpc32xx(gadget))
+		return 0x33;
 
 	return -ENOENT;
 }
drivers/usb/gadget/lpc32xx_udc.c new file +3533 -0

2,940 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#2 lore raw

PATCH v2 3/3 USB: ohci-nxp: Use isp1301 driver

In reply to Roland Stigge

ohci-nxp duplicates the isp1301 driver. This patch removes this code and makes ohci-nxp use the new separate isp1301 driver.

---

Applies to v3.4-rc3 + LPC32xx DT patches

You can also pull from:

    git://git.antcom.de/linux-2.6 lpc32xx/udc
    http://git.antcom.de/?p=linux-2.6.git;a=shortlog;h=refs/heads/lpc32xx/udc

Depends on the isp1301 driver, see PATCH 1/3

 drivers/usb/host/Kconfig    |    1 
 drivers/usb/host/ohci-nxp.c |  106 --------------------------------------------
 2 files changed, 3 insertions(+), 104 deletions(-)
drivers/usb/host/Kconfig +1 -0
@@ -291,6 +291,7 @@ config USB_OHCI_HCD
 	depends on USB && USB_ARCH_HAS_OHCI
 	select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
 	select USB_OTG_UTILS if ARCH_OMAP
+	select USB_ISP1301 if ARCH_LPC32XX || ARCH_PNX4008
 	---help---
 	  The Open Host Controller Interface (OHCI) is a standard for accessing
 	  USB 1.1 host controller hardware.  It does more in hardware than Intel's
drivers/usb/host/ohci-nxp.c +2 -104

155 lines not on this page · raw message

Acked-by on v2 1/3
#3 lore raw
In reply to Roland Stigge
Quoted 8 lines · Roland Stigge

This very-lowlevel driver registers the NXP ISP1301 chip via the I2C subsystem. The chip is the USB transceiver shared by ohci-nxp, lpc32xx_udc (gadget) and isp1301_omap.

Following patches let the respective USB host and gadget drivers use this driver, instead of duplicating ISP1301 handling.

All three patches:

Quoted 3 lines

This driver needs to be probe()d before the respective USB driver using it. For modules, this is handled via the module dependency. When linking statically, it is done via linking order in the Makefile (misc/ before host/ and the gadget/).

You can easily avoid the link order restriction now by returning -EPROBE_DEFER from the probe function of the device that needs this one.

Quoted 4 lines

Currently, only one ISP1301 chip is supported. To support multiple instances, we would need a mechanism to identify the respective chips via DT (and static resources or platform data) to be referenced by the higher level USB driver at isp1301_get_client(). Any suggestions?

Put a phandle into the usb device node, like:

       isp1301: usb-transceiver at 23 {
		compatible = "nxp,isp1301";
		reg = <23>;
	};

       usbd at 31020000 {
               compatible = "nxp,lpc32xx-udc";
               reg = <0x31020000 0x300>;
               interrupt-parent = <&mic>;
               interrupts = <0x3d 0>, <0x3e 0>, <0x3c 0>, <0x3a 0>;
	       transceiver = <&isp1301>;
               status = "disable";
       };

Then add a device_node argument to the isp1301_get_client() function and change the function to use bus_find_device() with a match function that compares the driver pointer.

Alternatively (and much more complex), you could add a generic usb-transceiver abstraction that does this and also hides the register accesses behind hardware independent function calls.

Arnd

maintainer
#5 lore raw
In reply to Roland Stigge
Quoted 23 lines · Roland Stigge

This very-lowlevel driver registers the NXP ISP1301 chip via the I2C subsystem. The chip is the USB transceiver shared by ohci-nxp, lpc32xx_udc (gadget) and isp1301_omap.

Following patches let the respective USB host and gadget drivers use this driver, instead of duplicating ISP1301 handling.

---

Applies to v3.4-rc3

This driver needs to be probe()d before the respective USB driver using it. For modules, this is handled via the module dependency. When linking statically, it is done via linking order in the Makefile (misc/ before host/ and the gadget/).

Currently, only one ISP1301 chip is supported. To support multiple instances, we would need a mechanism to identify the respective chips via DT (and static resources or platform data) to be referenced by the higher level USB driver at isp1301_get_client(). Any suggestions?

Quoted 5 lines
 drivers/usb/Makefile        |    5 ++
 drivers/usb/misc/Kconfig    |   12 ++++++
 drivers/usb/misc/Makefile   |    1 
 drivers/usb/misc/isp1301.c  |   64 ++++++++++++++++++++++++++++++++++
 include/linux/usb/isp1301.h |   82 ++++++++++++++++++++++++++++++++++++++++++++

You know, drivers/usb/misc is meant for miscellaneous USB device drivers. Not for host or transceiver drivers.

You should put the new file somewhere else. Maybe in the otg directory, although that may not be completely appropriate either. Maybe something under the host directory.

Alan Stern

#4 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann
Quoted 3 lines

This driver needs to be probe()d before the respective USB driver using it. For modules, this is handled via the module dependency. When linking statically, it is done via linking order in the Makefile (misc/ before host/ and the gadget/).

You can easily avoid the link order restriction now by returning -EPROBE_DEFER from the probe function of the device that needs this one.

That's exactly what I was looking for! :-)

Same for the phandle idea.

Will include the resp. changes in the next update

Thanks,

Roland

#6 lore raw
In reply to Alan Stern
Quoted 6 lines · Alan Stern
Quoted 5 lines
 drivers/usb/Makefile        |    5 ++
 drivers/usb/misc/Kconfig    |   12 ++++++
 drivers/usb/misc/Makefile   |    1 
 drivers/usb/misc/isp1301.c  |   64 ++++++++++++++++++++++++++++++++++
 include/linux/usb/isp1301.h |   82 ++++++++++++++++++++++++++++++++++++++++++++
Quoted 6 lines

You know, drivers/usb/misc is meant for miscellaneous USB device drivers. Not for host or transceiver drivers.

You should put the new file somewhere else. Maybe in the otg directory, although that may not be completely appropriate either. Maybe something under the host directory.

The driver is used by drivers in the following directories:

drivers/usb/host/    (ohci-nxp.c)
drivers/usb/otg/     (isp1301_omap.c)
drivers/usb/gadget/  (lpc32xx_udc.c)

So host/ and otg/ don't look much better.

Maybe one of (new):

drivers/usb/transceiver/
drivers/usb/phy/
drivers/usb/lowlevel/

?

Otherwise, I will put it in drivers/usb/otg/ even of it doesn't look better to me but the chip is advertised as "OTG transceiver". ;-)

Thanks in advance,

Roland

maintainer
#7 lore raw
Quoted 20 lines · Roland Stigge
Quoted 6 lines · Alan Stern
Quoted 5 lines
 drivers/usb/Makefile        |    5 ++
 drivers/usb/misc/Kconfig    |   12 ++++++
 drivers/usb/misc/Makefile   |    1 
 drivers/usb/misc/isp1301.c  |   64 ++++++++++++++++++++++++++++++++++
 include/linux/usb/isp1301.h |   82 ++++++++++++++++++++++++++++++++++++++++++++
Quoted 6 lines

You know, drivers/usb/misc is meant for miscellaneous USB device drivers. Not for host or transceiver drivers.

You should put the new file somewhere else. Maybe in the otg directory, although that may not be completely appropriate either. Maybe something under the host directory.

The driver is used by drivers in the following directories:

drivers/usb/host/    (ohci-nxp.c)
drivers/usb/otg/     (isp1301_omap.c)
drivers/usb/gadget/  (lpc32xx_udc.c)
Quoted 7 lines

So host/ and otg/ don't look much better.

Maybe one of (new):

drivers/usb/transceiver/
drivers/usb/phy/
drivers/usb/lowlevel/

Sure, any of those would be fine with me, but not misc please.

thanks,

greg k-h

maintainer
#8 lore raw
In reply to Roland Stigge
Quoted 24 lines · Roland Stigge
Quoted 6 lines · Alan Stern
Quoted 5 lines
 drivers/usb/Makefile        |    5 ++
 drivers/usb/misc/Kconfig    |   12 ++++++
 drivers/usb/misc/Makefile   |    1 
 drivers/usb/misc/isp1301.c  |   64 ++++++++++++++++++++++++++++++++++
 include/linux/usb/isp1301.h |   82 ++++++++++++++++++++++++++++++++++++++++++++
Quoted 6 lines

You know, drivers/usb/misc is meant for miscellaneous USB device drivers. Not for host or transceiver drivers.

You should put the new file somewhere else. Maybe in the otg directory, although that may not be completely appropriate either. Maybe something under the host directory.

The driver is used by drivers in the following directories:

drivers/usb/host/    (ohci-nxp.c)
drivers/usb/otg/     (isp1301_omap.c)
drivers/usb/gadget/  (lpc32xx_udc.c)

So host/ and otg/ don't look much better.

Maybe one of (new):

Quoted 8 lines

drivers/usb/transceiver/
drivers/usb/phy/
drivers/usb/lowlevel/

?

Otherwise, I will put it in drivers/usb/otg/ even of it doesn't look better to me but the chip is advertised as "OTG transceiver". ;-)

I don't know. Maybe Greg KH or Felipe Balbi will have a recommendation. But any of these alternatives would be better than drivers/usb/misc/.

Alan Stern

#9 lore raw
Quoted 6 lines · Alan Stern
Quoted 6 lines

Maybe one of (new):

drivers/usb/transceiver/
drivers/usb/phy/
drivers/usb/lowlevel/

Quoted 8 lines
Quoted 4 lines

?

Otherwise, I will put it in drivers/usb/otg/ even of it doesn't look better to me but the chip is advertised as "OTG transceiver". ;-)

I don't know. Maybe Greg KH or Felipe Balbi will have a recommendation. But any of these alternatives would be better than drivers/usb/misc/.

Since you and Greg-KH seem to be fine with the above, I'll pick drivers/usb/phy/ for now.

Thanks for your fast responses,

Roland