Skip to contentSkip to conversation

USB: Add support for Xilinx USB host controller

PATCH In review Julie Zhu 3 participants 5 messages Sep 15, 2009 – Sep 21, 2009

Subsystems (3)
lore
Share & tools
lore

Julie Zhu

author
#0 lore raw

PATCH 1/1 USB: Add support for Xilinx USB host controller

Add bus glue driver for Xilinx USB host controller. The controller can be configured as HS only or HS/FS hybrid. The driver uses the device tree file to configure the driver according to the setting in the hardware system.

This driver has been tested with usbtest using the NET2280 PCI card.

---
 drivers/usb/host/Kconfig          |   15 ++-
 drivers/usb/host/ehci-hcd.c       |    5 +
 drivers/usb/host/ehci-xilinx-of.c |  303 +++++++++++++++++++++++++++++++++++++
 3 files changed, 321 insertions(+), 2 deletions(-)
 create mode 100644 drivers/usb/host/ehci-xilinx-of.c
drivers/usb/host/Kconfig +13 -2
index 1a920c7..95e4689 100644
@@ -90,14 +90,25 @@ config USB_EHCI_TT_NEWSCHED
 
 config USB_EHCI_BIG_ENDIAN_MMIO
 	bool
-	depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX)
+	depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX)
 	default y
 
 config USB_EHCI_BIG_ENDIAN_DESC
 	bool
-	depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX)
+	depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX)
 	default y
 
+config XPS_USB_HCD_XILINX
+	bool "Use Xilinx usb host EHCI controller core"
+	depends on USB_EHCI_HCD && (PPC32 || MICROBLAZE)
+	select USB_EHCI_BIG_ENDIAN_DESC
+	select USB_EHCI_BIG_ENDIAN_MMIO
+	---help---
+		Xilinx xps USB host controller core is EHCI compilant and has
+		transaction translator built-in. It can be configured to either
+		support both high speed and full speed devices, or high speed
+		devices only.
+
 config USB_EHCI_FSL
 	bool "Support for Freescale on-chip EHCI USB controller"
 	depends on USB_EHCI_HCD && FSL_SOC
drivers/usb/host/ehci-hcd.c +5 -0
index 11c627c..7672624 100644
@@ -1107,6 +1107,11 @@ MODULE_LICENSE ("GPL");
 #define OF_PLATFORM_DRIVER	ehci_hcd_ppc_of_driver
 #endif
 
+#ifdef CONFIG_XPS_USB_HCD_XILINX
+#include "ehci-xilinx-of.c"
+#define OF_PLATFORM_DRIVER	ehci_hcd_xilinx_of_driver
+#endif
+
 #ifdef CONFIG_PLAT_ORION
 #include "ehci-orion.c"
 #define	PLATFORM_DRIVER		ehci_orion_driver
drivers/usb/host/ehci-xilinx-of.c new file +303 -0

303 lines not on this page · raw message

Signature · 5 lines
1.5.6.6



This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
#1 lore raw
Quoted 7 lines · Julie Zhu

Add bus glue driver for Xilinx USB host controller. The controller can be configured as HS only or HS/FS hybrid. The driver uses the device tree file to configure the driver according to the setting in the hardware system.

This driver has been tested with usbtest using the NET2280 PCI card.

Hi !

First, this is a very clean piece of code, thanks.

Just a few minor nits:

Quoted 12 lines

static int ehci_xilinx_port_handed_over(struct usb_hcd *hcd, int portnum)

drivers/usb/host/ehci-xilinx-of.c new file +11 -0
+{
+	dev_warn(hcd->self.controller, "port %d cannot be enabled\n", portnum);
+	if (hcd->has_tt) {
+		dev_warn(hcd->self.controller,
+			"Maybe you have connected an LS device?\n");
+
+		dev_warn(hcd->self.controller,
+			"We do not support LS devices\n");
+	} else {
+		dev_warn(hcd->self.controller,
+			"Maybe your device is not an HS device?\n");

drivers/usb/host/ehci-xilinx-of.c line 92

Quoted 10 lines
drivers/usb/host/ehci-xilinx-of.c new file +10 -0
+		dev_warn(hcd->self.controller,
+			"The USB host controller does not support FS or "
+			"LS devices\n");
+		dev_warn(hcd->self.controller,
+			"You can reconfigure the host controller to have "
+			"FS support\n");
+	}
+
+	return 0;
+}

I'm not sure the final users would know what "FS", "LS" or "HS" mean here, it might be worth being a -tad- more verbose :-)

.../...

Quoted 9 lines
drivers/usb/host/ehci-xilinx-of.c new file +9 -0
+
+/**
+ * ehci_hcd_xilinx_of_remove - shutdown hcd and release resources
+ * @op:		pointer to of_device structure that is to be removed
+ *
+ * Remove the hcd structure, and release resources that has been requested
+ * during probe.
+ */
+static int ehci_hcd_xilinx_of_remove(struct of_device *op)

drivers/usb/host/ehci-xilinx-of.c line 260

Quoted 10 lines
drivers/usb/host/ehci-xilinx-of.c new file +10 -0
+{
+	struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
+	dev_set_drvdata(&op->dev, NULL);
+
+	dev_dbg(&op->dev, "stopping XILINX-OF USB Controller\n");
+
+	usb_remove_hcd(hcd);
+
+	iounmap(hcd->regs);
+	irq_dispose_mapping(hcd->irq);

You don't need to dispose of the irq mapping, and in fact, it could be harmful if the interrupt is shared, as we don't refcount the mapping users. Just remove the line above. The mapping doesn't really use resources (well, it depends on your PIC but even then, it's minor) so it's better, once a HW IRQ number has been associated to a linux IRQ number, to keep that association for the lifetime of the kernel.

Cheers,
Ben.

#2 lore raw
In reply to Julie Zhu
Quoted 2 lines · Julie Zhu

Add bus glue driver for Xilinx USB host controller. The controller can be configured as HS only or HS/FS hybrid. The driver uses the device tree fi=

le

Quoted 5 lines

to configure the driver according to the setting in the hardware system.

This driver has been tested with usbtest using the NET2280 PCI card.

As Ben said, this is nice tight code. Two comments below.

Quoted 2 lines

+/**
+ * ehci_xilinx_port_handed_over - hand the port out if failed to enable =

it

Quoted 1 line

+ * @hcd: =A0 =A0 =A0 Pointer to the usb_hcd device to which the host con=

troller bound

Quoted 3 lines

+ * @portnum:Port number to which the device is attached.
+ *
+ * This function is used as a place to tell the user that the Xilinx USB=

host

Quoted 1 line

+ * controller does support LS devices. And in an HS only configuration, =

it

Quoted 1 line

+ * does not support FS devices neither. It is hoped that this can help a

s/neither/either

[...]

Quoted 4 lines

+static struct of_device_id ehci_hcd_xilinx_of_match[] =3D {
+ =A0 =A0 =A0 {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 .compatible =3D "usb-ehci",
+ =A0 =A0 =A0 },

This looks wrong. Since this driver only works with Xilinx USB controllers= ,
it should be binding against "xlnx,xps-usb-host-1.00.a", and the meaning of that binding needs to be documented in Documentation/powerpc/dts-bindings.

Having this driver bind against the generic "usb-ehci" will cause conflicts with the ehci-ppc-of driver.

Cheers,
g.

--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

author
#3 lore raw

Thanks, Grant and Ben,

Quoted 5 lines
Quoted 1 line

Add bus glue driver for Xilinx USB host controller. The controller can

be

Quoted 1 line

configured as HS only or HS/FS hybrid. The driver uses the device tree

file

Quoted 1 line

to configure the driver according to the setting in the hardware system=

.

Quoted 11 lines
Quoted 4 lines

This driver has been tested with usbtest using the NET2280 PCI card.

=

As Ben said, this is nice tight code. Two comments below. =

Quoted 2 lines

+/**
+ * ehci_xilinx_port_handed_over - hand the port out if failed to enabl=

e

Quoted 8 lines

it

Quoted 1 line

+ * @hcd: =A0 =A0 =A0 Pointer to the usb_hcd device to which the host

controller bound

Quoted 3 lines

+ * @portnum:Port number to which the device is attached.
+ *
+ * This function is used as a place to tell the user that the Xilinx

USB host

Quoted 1 line

+ * controller does support LS devices. And in an HS only configuration=

,

Quoted 14 lines

it

Quoted 1 line

+ * does not support FS devices neither. It is hoped that this can help=

a
=

s/neither/either
=

[...]

Quoted 4 lines

+static struct of_device_id ehci_hcd_xilinx_of_match[] =3D {
+ =A0 =A0 =A0 {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 .compatible =3D "usb-ehci",
+ =A0 =A0 =A0 },

Quoted 7 lines

=

This looks wrong. Since this driver only works with Xilinx USB controllers,
it should be binding against "xlnx,xps-usb-host-1.00.a", and the meaning of
that binding needs to be documented in Documentation/powerpc/dts-bindings=

.

Quoted 1 line

=

I have changed the compatible to "xlnx,xps-usb-host-1.00.a", thanks for cat= ching this.

Where should I put the binding for Xilinx USB host controller? usb-ehci.txt=
or xilinx.txt?

Thanks,
Julie.

Quoted 8 lines

Having this driver bind against the generic "usb-ehci" will cause conflicts
with the ehci-ppc-of driver.
=

Quoted 7 lines

Cheers,
g.
=

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

This email and any attachments are intended for the sole use of the named r= ecipient(s) and contain(s) confidential information that may be proprietary= , privileged or copyrighted under applicable law. If you are not the intend= ed recipient, do not read, copy, or forward this email message or any attac= hments. Delete this email message and any attachments immediately.

#4 lore raw
Quoted 3 lines · Julie Zhu

I have changed the compatible to "xlnx,xps-usb-host-1.00.a", thanks for catching this.

Where should I put the binding for Xilinx USB host controller? usb-ehci.txt or xilinx.txt?

Probably xilinx.txt.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.