Skip to contentSkip to conversation

usb: gadget: Add UDC driver for Aeroflex Gaisler GRUSBDC

PATCH Superseded Andreas Larsson 2 participants 2 messages Dec 23, 2013

Subsystems (2)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 usb: gadget: Add UDC driver for Aeroflex Gaisler GRUSBDC

This adds an UDC driver for GRUSBDC USB Device Controller cores available in the GRLIB VHDL IP core library. The driver only supports DMA mode.

---

Differences since v1:
- Use hexprint for debug printoutes instead of homemade equivalent
- Use the dev_* printk variants over the board
- Get rid of unnecessary casts and includes
- Use USB_STATE_NOTATTACHED instead of USB_STATE_ATTACHED for clarity
- Get rid of commented out VERBOSE_DEBUG definition
- Do not devm-allocate any requests
- Get rid of unnecessary resqueduling of the workqueue handler
- Make sure that gadget setup function is called with interrupts disabled Differences since v2:
- Fixed an error printout
- Got rid of the work queue in favor of threaded interrupts Differences since v3:
- Disable interrupts when locking spinlocks instead of using local_irq_save deeper within critical section
Differences since v4
- Set quirk_ep_out_aligned_size
- Use usb_ep_set_maxpacket_limit
- Add devicetree documentation

 Documentation/devicetree/bindings/usb/gr-udc.txt |   28 +
 drivers/usb/gadget/Kconfig                       |    7 +
 drivers/usb/gadget/Makefile                      |    1 +
 drivers/usb/gadget/gr_udc.c                      | 2238 ++++++++++++++++++++++
 drivers/usb/gadget/gr_udc.h                      |  220 +++
 5 files changed, 2494 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/gr-udc.txt
 create mode 100644 drivers/usb/gadget/gr_udc.c
 create mode 100644 drivers/usb/gadget/gr_udc.h
Documentation/devicetree/bindings/usb/gr-udc.txt new file +28 -0
new file mode 100644
index 0000000..0c5118f
@@ -0,0 +1,28 @@
+USB Peripheral Controller driver for Aeroflex Gaisler GRUSBDC.
+
+The GRUSBDC USB Device Controller core is available in the GRLIB VHDL
+IP core library.
+
+Note: In the ordinary environment for the core, a Leon SPARC system,
+these properties are built from information in the AMBA plug&play.
+
+Required properties:
+
+- name : Should be "GAISLER_USBDC" or "01_021"
+
+- reg : Address and length of the register set for the device
+
+- interrupts : Interrupt numbers for this device
+
+Optional properties:
+
+- epobufsizes : An array of buffer sizes for OUT endpoints. If the property is
+	not present, or for endpoints outside of the array, 1024 is assumed by
+	the driver.
+
+- epibufsizes : An array of buffer sizes for IN endpoints. If the property is
+	not present, or for endpoints outside of the array, 1024 is assumed by
+	the driver.
+
+For further information look in the documentation for the GLIB IP core library:
+http://www.gaisler.com/products/grlib/grip.pdf
drivers/usb/gadget/Kconfig +7 -0
index ef5075e..ee220f3 100644
@@ -216,6 +216,13 @@ config USB_FOTG210_UDC
 	   Say "y" to link the driver statically, or "m" to build a
 	   dynamically linked module called "fotg210_udc".
 
+config USB_GR_UDC
+       tristate "Aeroflex Gaisler GRUSBDC USB Peripheral Controller Driver"
+       depends on OF && HAS_DMA
+       help
+          Select this to support Aeroflex Gaisler GRUSBDC cores from the GRLIB
+	  VHDL IP core library.
+
 config USB_OMAP
 	tristate "OMAP USB Device Controller"
 	depends on ARCH_OMAP1
drivers/usb/gadget/Makefile +1 -0
index 6cccdfe..5f150bc 100644
@@ -35,6 +35,7 @@ mv_udc-y			:= mv_udc_core.o
 obj-$(CONFIG_USB_FUSB300)	+= fusb300_udc.o
 obj-$(CONFIG_USB_FOTG210_UDC)	+= fotg210-udc.o
 obj-$(CONFIG_USB_MV_U3D)	+= mv_u3d_core.o
+obj-$(CONFIG_USB_GR_UDC)	+= gr_udc.o
 
 # USB Functions
 usb_f_acm-y			:= f_acm.o
drivers/usb/gadget/gr_udc.c new file +2238 -0

2,238 lines not on this page · raw message

drivers/usb/gadget/gr_udc.h new file +220 -0

220 lines not on this page · raw message

Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

Hi,

Quoted 4 lines · Andreas Larsson

This adds an UDC driver for GRUSBDC USB Device Controller cores available in the GRLIB VHDL IP core library. The driver only supports DMA mode.

You have a few Sparse Warnings:

drivers/usb/gadget/gr_udc.c:1255:13: warning: incorrect type in argument 1 (different address spaces)
drivers/usb/gadget/gr_udc.c:1255:13: expected void [noderef] <asn:2>*<noident>
drivers/usb/gadget/gr_udc.c:1255:13: got unsigned int *<noident>
drivers/usb/gadget/gr_udc.c:1284:16: warning: incorrect type in argument 1 (different address spaces)
drivers/usb/gadget/gr_udc.c:1284:16: expected void [noderef] <asn:2>*<noident>
drivers/usb/gadget/gr_udc.c:1284:16: got unsigned int *<noident>
drivers/usb/gadget/gr_udc.c:1136:28: warning: context imbalance in 'gr_ep0_setup' - unexpected unlock drivers/usb/gadget/gr_udc.c:1052:1: warning: "/*" within comment [-Wcomment]
/* Must be called with dev->lock held and irqs disabled

Two of them I fixed below:

drivers/usb/gadget/Kconfig +1 -1
index ee220f3..5eb36af 100644
@@ -218,7 +218,7 @@ config USB_FOTG210_UDC
 
 config USB_GR_UDC
        tristate "Aeroflex Gaisler GRUSBDC USB Peripheral Controller Driver"
-       depends on OF && HAS_DMA
+       depends on HAS_DMA
        help
           Select this to support Aeroflex Gaisler GRUSBDC cores from the GRLIB
 	  VHDL IP core library.
drivers/usb/gadget/gr_udc.c +3 -1
index 4f99a61..9ac378a 100644
@@ -1049,9 +1049,11 @@ static void gr_ep0out_requeue(struct gr_udc *dev)
 /*
  * The main function dealing with setup requests on ep0.
  *
-/* Must be called with dev->lock held and irqs disabled
+ * Must be called with dev->lock held and irqs disabled
  */
 static void gr_ep0_setup(struct gr_udc *dev, struct gr_request *req)
+	__releases(&dev->lock)
+	__acquires(&dev->lock)
 {
 	union {
 		struct usb_ctrlrequest ctrl;

The other two are seem like they would require a much larger code change. Why are you passing integers as arguments to IO access functions ? You should be passing void __iomem *.

Dropping for now.

Signature · 1 line
balbi