USB: Add driver for NXP ISP1301 USB transceiver
Subsystems (4)
PATCH v5 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
Changes since v4:
* Documentation adjustment of device tree "compatible" string:
"nxp,lpc32xx-udc" -> "nxp,lpc3220-udc"
Documentation/devicetree/bindings/usb/isp1301.txt | 25 ++++++ drivers/usb/Kconfig | 2 drivers/usb/Makefile | 1 drivers/usb/phy/Kconfig | 17 ++++ drivers/usb/phy/Makefile | 7 + drivers/usb/phy/isp1301.c | 79 ++++++++++++++++++++ include/linux/usb/isp1301.h | 84 ++++++++++++++++++++++ 7 files changed, 215 insertions(+)
Documentation/devicetree/bindings/usb/isp1301.txt new file +25 -0
@@ -0,0 +1,25 @@ +* NXP ISP1301 USB transceiver + +Required properties: +- compatible: must be "nxp,isp1301" +- reg: I2C address of the ISP1301 device + +Optional properties of devices using ISP1301: +- transceiver: phandle of isp1301 - this helps the ISP1301 driver to find the + ISP1301 instance associated with the respective USB driver + +Example: + + isp1301: usb-transceiver at 2c { + compatible = "nxp,isp1301"; + reg = <0x2c>; + }; + + usbd at 31020000 { + compatible = "nxp,lpc3220-udc"; + reg = <0x31020000 0x300>; + interrupt-parent = <&mic>; + interrupts = <0x3d 0>, <0x3e 0>, <0x3c 0>, <0x3a 0>; + transceiver = <&isp1301>; + status = "okay"; + };
drivers/usb/Kconfig +2 -0
@@ -177,6 +177,8 @@ source "drivers/usb/serial/Kconfig" source "drivers/usb/misc/Kconfig" +source "drivers/usb/phy/Kconfig" + source "drivers/usb/atm/Kconfig" source "drivers/usb/gadget/Kconfig"
drivers/usb/Makefile +1 -0
@@ -46,6 +46,7 @@ obj-$(CONFIG_USB_MICROTEK) += image/ obj-$(CONFIG_USB_SERIAL) += serial/ obj-$(CONFIG_USB) += misc/ +obj-$(CONFIG_USB) += phy/ obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/ obj-$(CONFIG_USB_ATM) += atm/
drivers/usb/phy/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# +# Physical Layer USB driver configuration +# +comment "USB Physical Layer drivers" + depends on USB + +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.
drivers/usb/phy/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# +# Makefile for physical layer USB drivers +# + +ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG + +obj-$(CONFIG_USB_ISP1301) += isp1301.o
drivers/usb/phy/isp1301.c new file +79 -0
79 lines not on this page · raw message
include/linux/usb/isp1301.h new file +84 -0
84 lines not on this page · raw message
PATCH v5 2/3 USB: gadget driver for LPC32xx
This patch adds a USB gadget driver for the LPC32xx ARM SoC.
---
Changes since v4:
* Changed device tree "compatible" string from "nxp,lpc32xx-udc" to "nxp,lpc3220-udc"
Applies to v3.4-rc3
Documentation/devicetree/bindings/usb/lpc32xx-udc.txt | 28 drivers/usb/gadget/Kconfig | 11 drivers/usb/gadget/Makefile | 1 drivers/usb/gadget/gadget_chips.h | 3 drivers/usb/gadget/lpc32xx_udc.c | 3538 ++++++++++++++++++ 5 files changed, 3581 insertions(+)
Documentation/devicetree/bindings/usb/lpc32xx-udc.txt new file +28 -0
@@ -0,0 +1,28 @@ +* NXP LPC32xx SoC USB Device Controller (UDC) + +Required properties: +- compatible: Must be "nxp,lpc3220-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) +- transceiver: phandle of the associated ISP1301 device - this is necessary for + the UDC controller for connecting to the USB physical layer + +Example: + + isp1301: usb-transceiver at 2c { + compatible = "nxp,isp1301"; + reg = <0x2c>; + }; + + usbd at 31020000 { + compatible = "nxp,lpc3220-udc"; + reg = <0x31020000 0x300>; + interrupt-parent = <&mic>; + interrupts = <0x3d 0>, <0x3e 0>, <0x3c 0>, <0x3a 0>; + transceiver = <&isp1301>; + };
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 +3538 -0
2,933 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.
PATCH v5 3/3 USB: ohci-nxp: Use isp1301 driver
In reply to Roland Stiggeohci-nxp duplicates the isp1301 driver. This patch removes this code and makes ohci-nxp use the new separate isp1301 driver instead.
---
Applies to v3.4-rc3 + LPC32xx DT patches
Depends on the isp1301 driver, see PATCH 1/3
Changes since v4:
* None
Documentation/devicetree/bindings/usb/ohci-nxp.txt | 8 + drivers/usb/host/Kconfig | 1 drivers/usb/host/ohci-nxp.c | 121 ++------------------- 3 files changed, 24 insertions(+), 106 deletions(-)
Documentation/devicetree/bindings/usb/ohci-nxp.txt +8 -0
@@ -5,12 +5,20 @@ Required properties: - reg: physical base address of the controller and length of memory mapped region. - interrupts: The OHCI interrupt +- transceiver: phandle of the associated ISP1301 device - this is necessary for + the UDC controller for connecting to the USB physical layer Example (LPC32xx): + isp1301: usb-transceiver at 2c { + compatible = "nxp,isp1301"; + reg = <0x2c>; + }; + ohci at 31020000 { compatible = "nxp,ohci-nxp"; reg = <0x31020000 0x300>; interrupt-parent = <&mic>; interrupts = <0x3b 0>; + transceiver = <&isp1301>; };
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 +15 -106
172 lines not on this page · raw message
Greg KH
maintainerQuoted 18 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) andisp1301_omap.Following patches let the respective USB host and gadget drivers use this driver, instead of duplicating ISP1301 handling.
Signed-off-by Roland Stigge <[email protected]>Acked-by Arnd Bergmann <[email protected]>---
Applies to v3.4-rc3
Changes since v4:
* Documentation adjustment of device tree "compatible" string:
"nxp,lpc32xx-udc" -> "nxp,lpc3220-udc"
Quoted 6 lines
Documentation/devicetree/bindings/usb/isp1301.txt | 25 ++++++ drivers/usb/Kconfig | 2 drivers/usb/Makefile | 1 drivers/usb/phy/Kconfig | 17 ++++ drivers/usb/phy/Makefile | 7 + drivers/usb/phy/isp1301.c | 79 ++++++++++++++++++++
Nice, but:
Quoted 1 line
include/linux/usb/isp1301.h | 84 ++++++++++++++++++++++
Why this file? You have a lot of register stuff in here that should be in the .c file, right? Only put what other files need in this .h file, which shouldn't be much at all from what I can tell.
Quoted 1 line
+#define
DRV_VERSION"0.1.0"
Is that really needed?
drivers/usb/phy/isp1301.c line 74
Quoted 13 lines
drivers/usb/phy/isp1301.c new file +13
-0+struct i2c_client *isp1301_get_client (struct device_node *node) +{ +if (node) {/* reference of ISP1301 I2C node via DT */ +struct device *dev =bus_find_device (&i2c_bus_type,NULL , + node, match); +if (!dev) +return NULL ; +return to_i2c_client (dev); + }else {/* non-DT: only one ISP1301 chip supported */ +return isp1301_i2c_client; + } +} +EXPORT_SYMBOL (isp1301_get_client);
EXPORT_SYMBOL_GPL()?
Quoted 3 lines
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Are you really willing to keep track of where the FSF keeps it's office for the next 40 years? Just delete this paragraph please, it's not needed at all.
thanks,
greg k-h
Hi Greg,
thanks for reviewing! I integrated all of your suggestions into the patch update, except ...
Quoted 8 lines · Greg KH
Quoted 7 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) andisp1301_omap.Following patches let the respective USB host and gadget drivers use this driver, instead of duplicating ISP1301 handling.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Roland Stigge <[email protected]>Acked-by Arnd Bergmann <[email protected]>include/linux/usb/isp1301.h | 84 ++++++++++++++++++++++Why this file? You have a lot of register stuff in here that should be in the .c file, right? Only put what other files need in this .h file, which shouldn't be much at all from what I can tell.
Right. At first sight, it doesn't look very elegant that the driver exposes the ISP1301 register set to the drivers using it. I discussed this design previously with Arnd on the mailing list and we agreed on the following: ISP1301 is a very low level driver that primarily separates out the I2C client registration of the ISP1301 chip (including instantiation via DT), used by other drivers, but it's still just a kind of helper driver for some OHCI and USB device drivers. Consider the ISP1301 driver as a register set extension of ohci-nxp, lpc32xx-udc and isp1301_omap, which in turn know best what to do with the low level functionality (individual ISP1301 registers and timing, see the different initialization strategies in those drivers). Those drivers previously internally duplicated ISP1301 register definitions which is solved by the new isp1301 driver.
Initially, I actually had register get/set functions defined in isp1301.h but it turned out that those trivial wrappers around standard i2c_smbus_*() better had been removed.
So what do you think?
Thanks in advance,
Roland
Greg KH
maintainerQuoted 37 lines · Roland Stigge
Hi Greg,
thanks for reviewing! I integrated all of your suggestions into the patch update, except ...
Quoted 8 lines · Greg KH
Quoted 7 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) andisp1301_omap.Following patches let the respective USB host and gadget drivers use this driver, instead of duplicating ISP1301 handling.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Roland Stigge <[email protected]>Acked-by Arnd Bergmann <[email protected]>include/linux/usb/isp1301.h | 84 ++++++++++++++++++++++Why this file? You have a lot of register stuff in here that should be in the .c file, right? Only put what other files need in this .h file, which shouldn't be much at all from what I can tell.
Right. At first sight, it doesn't look very elegant that the driver exposes the ISP1301 register set to the drivers using it. I discussed this design previously with Arnd on the mailing list and we agreed on the following: ISP1301 is a very low level driver that primarily separates out the I2C client registration of the ISP1301 chip (including instantiation via DT), used by other drivers, but it's still just a kind of helper driver for some OHCI and USB device drivers. Consider the ISP1301 driver as a register set extension of ohci-nxp, lpc32xx-udc and
isp1301_omap, which in turn know best what to do with the low level functionality (individual ISP1301 registers and timing, see the different initialization strategies in those drivers). Those drivers previously internally duplicated ISP1301 register definitions which is solved by the new isp1301 driver.
Quoted 5 lines
Initially, I actually had register get/set functions defined in
isp1301.hbut it turned out that those trivial wrappers around standard i2c_smbus_*() better had been removed.So what do you think?
Ok, that makes more sense, thanks for explaining it. Perhaps you should put that in the patch changelog entry itself, so others don't also have that same question?
thanks,
greg k-h