Skip to contentSkip to conversation

usb: gadget: Introduce Cadence USB2 UDC Driver

RFC PATCH In review Neil Armstrong 5 participants 9 messages Oct 16, 2015 – May 24, 2016

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

RFC PATCH 1/1 usb: gadget: Introduce Cadence USB2 UDC Driver

Introduces UDC support for the Device-Mode only version of the Cadence USB2 Controller IP Core.

Host mode and OTG mode are not implemented by lack of hardware. Support for Isochronous endpoints is not implemented by lack of time.

Internal DMA is supported and can be activated by DT property.

---
 .../devicetree/bindings/usb/cadence-hsudc.txt      |   55 +
 drivers/usb/gadget/udc/Kconfig                     |   15 +
 drivers/usb/gadget/udc/Makefile                    |    1 +
 drivers/usb/gadget/udc/cadence_hsudc.c             | 2136 ++++++++++++++++++++
 drivers/usb/gadget/udc/cadence_hsudc_regs.h        |  283 +++
 5 files changed, 2490 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/cadence-hsudc.txt
 create mode 100644 drivers/usb/gadget/udc/cadence_hsudc.c
 create mode 100644 drivers/usb/gadget/udc/cadence_hsudc_regs.h
Documentation/devicetree/bindings/usb/cadence-hsudc.txt new file +55 -0
new file mode 100644
index 0000000..4a9fa7f
@@ -0,0 +1,55 @@
+Cadence USB2.0 Device Controller
+
+The Cadence USB2.0 Device Controller as verilog IP core library.
+
+Required properties:
+- compatible	: Should be "cdns,usbhs-udc"
+- reg		: Physical base address and size of the USB2
+			device registers map.
+- interrupts	: Should contain single irq line of USB2 device
+			controller
+- cdns,ep-in	: Should be an array of u32 containing 1 for each available
+			IN endpoint, endpoint 0 is mandatory,
+			0 means not available, 16 entries max
+- cdns,ep-out	: Should be an array of u32 containing 1 for each available
+			OUT endpoint, endpoint 0 is mandatory
+			0 means not available, 16 entries max
+- cdns,ep-in-size	: Should be an array of u32 containing the max buffer
+				size available for each IN endpoint,
+				i.e. 64 for EP0, 512 for BULK, 1024 for ISO
+- cdns,ep-in-buffers	: Should be an array of u32 containing the buffer
+				count available for each IN endpoint,
+				i.e. 1 for EP0 or BULK, 2 to 4 for ISO
+- cdns,ep-in-buffstart	: Should be an array of u32 containing the buffer
+				start offset for each IN endpoint
+- cdns,ep-out-size	: Should be an array of u32 containing the max buffer
+				size available for each OUT endpoint,
+				i.e. 64 for EP0, 512 for BULK, 1024 for ISO
+- cdns,ep-out-buffers	: Should be an array of u32 containing the buffer
+				count available for each OUT endpoint,
+				i.e. 1 for EP0 or BULK, 2 to 4 for ISO
+- cdns,ep-out-buffstart	: Should be an array of u32 containing the buffer
+				start offset for each OUT endpoint
+
+Optional Properties :
+- cdns,dma-enable	: Present of dma is present and must be enabled
+- cdns,dma-channels	: If cdns,dma-enable is present, should be an u32
+				containing the count of DMA channels
+- clocks		: Should contain a phandle to the bus clock to enable
+
+Example :
+	usbd@80402000 {
+		compatible = "cdns,usbhs-udc";
+		interrupts = <25>;
+		reg = <0x80402000 0x1000>;
+		cdns,ep-in = <1 1 1>;
+		cdns,ep-out = <1 1 1>;
+		cdns,ep-in-size = <64 512 512>;
+		cdns,ep-out-size = <64 512 512>;
+		cdns,ep-in-buffers = <1 1 1>;
+		cdns,ep-out-buffers = <1 1 1>;
+		cdns,ep-in-buffstart = <0 64 576>;
+		cdns,ep-out-buffstart = <0 64 576>;
+		cdns,dma-enable;
+		cdns,dma-channels = <4>;
+	};
drivers/usb/gadget/udc/Kconfig +15 -0
index 9a3a6b0..2d24f85 100644
@@ -373,6 +373,21 @@ config USB_GADGET_XILINX
 	  dynamically linked module called "udc-xilinx" and force all
 	  gadget drivers to also be dynamically linked.
 
+config USB_CADENCE_HSUDC
+    tristate "Cadence USB2.0 Device Controller Driver"
+    depends on OF
+    help
+      Cadence sells an USB2.0 IP with Device Only mode.
+      This is a variant of the OTG Core.
+      This driver implements the Device Only mode,
+      OTG nor Host mode are implemented in the driver.
+      The Cadence USB2.0 DMA support is implemented.
+      Support for Isochronous endpoints is not implemented.
+
+      Say "y" to link the driver statically, or "m" to build a
+      dynamically linked module called "cusb2_udc" and force all
+      gadget drivers to also be dynamically linked.
+
 #
 # LAST -- dummy/emulated controller
 #
drivers/usb/gadget/udc/Makefile +1 -0
index fba2049..94cf53c 100644
@@ -31,3 +31,4 @@ obj-$(CONFIG_USB_MV_U3D)	+= mv_u3d_core.o
 obj-$(CONFIG_USB_GR_UDC)	+= gr_udc.o
 obj-$(CONFIG_USB_GADGET_XILINX)	+= udc-xilinx.o
 obj-$(CONFIG_USB_BDC_UDC)	+= bdc/
+obj-$(CONFIG_USB_CADENCE_HSUDC)	+= cadence_hsudc.o
drivers/usb/gadget/udc/cadence_hsudc.c new file +2136 -0

2,136 lines not on this page · raw message

drivers/usb/gadget/udc/cadence_hsudc_regs.h new file +283 -0

283 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

[PATCH] usb: gadget: fix platform_no_drv_owner.cocci warnings

drivers/usb/gadget/udc/cadence_hsudc.c:2127:6-11: No need to set .owner here. The core will do it.

drivers/usb/gadget/udc/cadence_hsudc.c:2127:6-11: No need to set .owner here. The core will do it.

Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

CC Neil Armstrong <[email protected]>

---

 cadence_hsudc.c |    1 -
 1 file changed, 1 deletion(-)
drivers/usb/gadget/udc/cadence_hsudc.c +0 -1
@@ -2124,7 +2124,6 @@ static struct platform_driver cadence_hs
 	.remove = cadence_hsudc_remove,
 	.driver = {
 		   .name = "cadence_hsudc",
-		   .owner = THIS_MODULE,
 		   .of_match_table = of_match_ptr(cadence_hsudc_of_match),
 		   },
 };
#2 lore raw
In reply to Neil Armstrong
reproduce:

Hi Neil,

[auto build test ERROR on balbi-usb/next -- if it's inappropriate base, please suggest rules for selecting the more suitable base]

url:    https://github.com/0day-ci/linux/commits/Neil-Armstrong/usb-gadget-Introduce-Cadence-USB2-UDC-Driver/20151016-225656
config: i386-allmodconfig (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

>> drivers/usb/gadget/udc/cadence_hsudc.c:151:24: error: unknown type name 'dmashortirq'
          unsigned dmairq, dmashortirq)
                           ^
   drivers/usb/gadget/udc/cadence_hsudc.c: In function 'cadence_hsudc_irq':
>> drivers/usb/gadget/udc/cadence_hsudc.c:224:5: error: implicit declaration of function 'cadence_hsudc_dma_irq' [-Werror=implicit-function-declaration]
        cadence_hsudc_dma_irq(hsudc_dev, i,
        ^
   drivers/usb/gadget/udc/cadence_hsudc.c: In function 'hsudc_copy_to_fifo':
>> drivers/usb/gadget/udc/cadence_hsudc.c:854:36: warning: dereferencing 'void *' pointer
       hsudc_write32(*(uint32_t *)(&buf[i]), reg);
                                       ^
   drivers/usb/gadget/udc/cadence_hsudc.c:143:11: note: in definition of macro 'hsudc_write32'
      writel((value), hsudc_dev->io_base + (reg))
              ^
>> drivers/usb/gadget/udc/cadence_hsudc.c:854:32: warning: taking address of expression of type 'void'
       hsudc_write32(*(uint32_t *)(&buf[i]), reg);
                                   ^
   drivers/usb/gadget/udc/cadence_hsudc.c:143:11: note: in definition of macro 'hsudc_write32'
      writel((value), hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c:858:36: warning: dereferencing 'void *' pointer
       hsudc_write16(*(uint16_t *)(&buf[i]), reg);
                                       ^
   drivers/usb/gadget/udc/cadence_hsudc.c:141:11: note: in definition of macro 'hsudc_write16'
      writew((value)&0xFFFF, hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c:858:32: warning: taking address of expression of type 'void'
       hsudc_write16(*(uint16_t *)(&buf[i]), reg);
                                   ^
   drivers/usb/gadget/udc/cadence_hsudc.c:141:11: note: in definition of macro 'hsudc_write16'
      writew((value)&0xFFFF, hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c:861:34: warning: dereferencing 'void *' pointer
       hsudc_write8(*(uint8_t *)(&buf[i]), reg);
                                     ^
   drivers/usb/gadget/udc/cadence_hsudc.c:139:11: note: in definition of macro 'hsudc_write8'
      writeb((value)&0xFF, hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c:861:30: warning: taking address of expression of type 'void'
       hsudc_write8(*(uint8_t *)(&buf[i]), reg);
                                 ^
   drivers/usb/gadget/udc/cadence_hsudc.c:139:11: note: in definition of macro 'hsudc_write8'
      writeb((value)&0xFF, hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c: In function 'hsudc_copy_from_fifo':
   drivers/usb/gadget/udc/cadence_hsudc.c:877:23: warning: dereferencing 'void *' pointer
       *((uint32_t *) &buf[i]) = hsudc_read32(reg);
                          ^
   drivers/usb/gadget/udc/cadence_hsudc.c:877:19: warning: taking address of expression of type 'void'
       *((uint32_t *) &buf[i]) = hsudc_read32(reg);
                      ^
   drivers/usb/gadget/udc/cadence_hsudc.c:880:23: warning: dereferencing 'void *' pointer
       *((uint16_t *) &buf[i]) = hsudc_read16(reg);
                          ^
   drivers/usb/gadget/udc/cadence_hsudc.c:880:19: warning: taking address of expression of type 'void'
       *((uint16_t *) &buf[i]) = hsudc_read16(reg);
                      ^
   drivers/usb/gadget/udc/cadence_hsudc.c:883:7: warning: dereferencing 'void *' pointer
       buf[i] = hsudc_read8(reg);
          ^
>> drivers/usb/gadget/udc/cadence_hsudc.c:883:4: error: invalid use of void expression
       buf[i] = hsudc_read8(reg);
       ^
   drivers/usb/gadget/udc/cadence_hsudc.c: In function 'hsudc_ep_completion':
>> drivers/usb/gadget/udc/cadence_hsudc.c:928:13: warning: unused variable 'i' [-Wunused-variable]
       unsigned i;
                ^

cc1: some warnings being treated as errors

coccinelle warnings: (new ones prefixed by >>)

>> drivers/usb/gadget/udc/cadence_hsudc.c:1303:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.
   Please make sure the condition has no side effects (see conditional BUG_ON definition in include/asm-generic/bug.h)
--
>> drivers/usb/gadget/udc/cadence_hsudc.c:2127:6-11: No need to set .owner here. The core will do it.

Please review and possibly fold the followup patch.

vim +/dmashortirq +151 drivers/usb/gadget/udc/cadence_hsudc.c

145 #define hsudc_read8(reg) readb(hsudc_dev->io_base + (reg))
146 #define hsudc_read16(reg) readw(hsudc_dev->io_base + (reg))
147 #define hsudc_read32(reg) readl(hsudc_dev->io_base + (reg))
148
149 static inline void cadence_hsudc_dma_irq(struct cadence_hsudc *hsudc_dev,
150 unsigned dma_channel,

 > 151						 unsigned dmairq, dmashortirq)
   152	{
   153		struct hsudc_dma_channel *channel =
   154			&hsudc_dev->dma_channels[dma_channel];
   155	
   156		if ((dmairq & (1 << i))) {
   157			/* Clear and disable DMAIRQ */
   158			hsudc_write32(1 << i, HSUDC_DMA_IRQ_REG32);
   159			hsudc_write32(hsudc_read32(HSUDC_DMA_IEN_REG32) &
   160					~(1 << dma_channel),
   161					HSUDC_DMA_IEN_REG32);
   162		}
   163		if ((dmashortirq & (1 << dma_channel))) {
   164			/* Clear and disable DMASHORTIRQ */
   165			hsudc_write32(1 << dma_channel, HSUDC_DMA_SHORTIRQ_REG32);
   166			hsudc_write32(hsudc_read32(HSUDC_DMA_SHORTIEN_REG32) &
   167					~(1 << dma_channel),
   168					HSUDC_DMA_SHORTIEN_REG32);
   169		}
   170		if (channel->is_available &
   171				channel->in_use &&
   172				channel->cur_ep->cur) {
   173			struct cadence_hsudc_request *hsudc_req =
   174				channel->cur_ep->cur;
   175			unsigned remain =
   176				hsudc_read32(HSUDC_DMA_CNT_REG32(dma_channel));
   177	
   178			hsudc_req->req.actual = hsudc_req->req.length - remain;
   179	
   180			queue_work(hsudc_dev->wq_ep,
   181					&channel->cur_ep->comp);
   182	
   183			channel->cur_ep->dma_channel = NULL;
   184			channel->cur_ep = NULL;
   185			channel->in_use = 0;
   186	
   187			/* Free DMA channel */
   188			up(&hsudc_dev->dma_sem);
   189		}
   190	}
   191	
   192	static irqreturn_t cadence_hsudc_irq(int irq, void *data)
   193	{
   194		struct cadence_hsudc *hsudc_dev = data;
   195	
   196		unsigned in_packet_irq;
   197		unsigned out_packet_irq;
   198		unsigned usbirq;
   199		unsigned dmairq, dmashortirq;
   200	
   201		(void)irq;
   202	
   203		in_packet_irq = hsudc_read16(HSUDC_INIRQ_REG16) &
   204				hsudc_read16(HSUDC_INIEN_REG16);
   205		out_packet_irq = hsudc_read16(HSUDC_OUTIRQ_REG16) &
   206				 hsudc_read16(HSUDC_OUTIEN_REG16);
   207		usbirq = hsudc_read8(HSUDC_USBIRQ_REG8) &
   208			 hsudc_read8(HSUDC_USBIEN_REG8);
   209	
   210		dmairq = hsudc_read32(HSUDC_DMA_IRQ_REG32) &
   211			 hsudc_read32(HSUDC_DMA_IEN_REG32);
   212		dmashortirq = hsudc_read32(HSUDC_DMA_SHORTIRQ_REG32) &
   213			      hsudc_read32(HSUDC_DMA_SHORTIEN_REG32);
   214	
   215		dev_vdbg(&hsudc_dev->pdev->dev, "irq: in %04X out %04X usb %04X dma %x/%x\n",
   216				in_packet_irq, out_packet_irq,
   217				usbirq, dmairq, dmashortirq);
   218	
   219		if (dmairq || dmashortirq) {
   220			unsigned i;
   221	
   222			for (i = 0; i < hsudc_dev->hw_config->dma_channels; ++i)
   223				if ((dmairq & (1 << i)) || (dmashortirq & (1 << i)))
 > 224					cadence_hsudc_dma_irq(hsudc_dev, i,

225 dmairq, dmashortirq);
226 }
227

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

[PATCH] usb: gadget: fix bugon.cocci warnings

In reply to Neil Armstrong
drivers/usb/gadget/udc/cadence_hsudc.c:1303:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG. Please make sure the condition has no side effects (see conditional BUG_ON definition in…

drivers/usb/gadget/udc/cadence_hsudc.c:1303:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG. Please make sure the condition has no side effects (see conditional BUG_ON definition in include/asm-generic/bug.h)

Use BUG_ON instead of a if condition followed by BUG.

Semantic patch information:
This makes an effort to find cases where BUG() follows an if condition on an expression and replaces the if condition and BUG() with a BUG_ON having the conditional expression of the if statement as argument.

Generated by: scripts/coccinelle/misc/bugon.cocci

CC Neil Armstrong <[email protected]>

---

Please take the patch only if it's a positive warning. Thanks!

 cadence_hsudc.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/usb/gadget/udc/cadence_hsudc.c +1 -2
@@ -1299,8 +1299,7 @@ static void hsudc_ep_work(struct work_st
 
 	hsudc_ep->cur = hsudc_req;
 
-	if (!hsudc_req)
-		BUG();
+	BUG_ON(!hsudc_req);
 
 	spin_unlock(&hsudc_ep->s);
 
#4 lore raw
In reply to Neil Armstrong
url: https://github.com/0day-ci/linux/commits/Neil-Armstrong/usb-gadget-Introduce-Cadence-USB2-UDC-Driver/20151016-225656 reproduce:

Hi Neil,

[auto build test WARNING on balbi-usb/next -- if it's inappropriate base, please suggest rules for selecting the more suitable base]

url: https://github.com/0day-ci/linux/commits/Neil-Armstrong/usb-gadget-Introduce-Cadence-USB2-UDC-Driver/20151016-225656
reproduce:

        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

>> drivers/usb/gadget/udc/cadence_hsudc.c:225:63: sparse: incorrect type in argument 4 (invalid types)
   drivers/usb/gadget/udc/cadence_hsudc.c:225:63:    expected incomplete type dmashortirq
   drivers/usb/gadget/udc/cadence_hsudc.c:225:63:    got unsigned int [unsigned] [assigned] dmashortirq
   drivers/usb/gadget/udc/cadence_hsudc.c:156:29: sparse: undefined identifier 'i'
   drivers/usb/gadget/udc/cadence_hsudc.c:158:17: sparse: undefined identifier 'i'
>> drivers/usb/gadget/udc/cadence_hsudc.c:163:26: sparse: incompatible types for operation (&)
   drivers/usb/gadget/udc/cadence_hsudc.c:163:26:    left side has type incomplete type dmashortirq
   drivers/usb/gadget/udc/cadence_hsudc.c:163:26:    right side has type int
   drivers/usb/gadget/udc/cadence_hsudc.c:151:24: error: unknown type name 'dmashortirq'
          unsigned dmairq, dmashortirq)
                           ^
   drivers/usb/gadget/udc/cadence_hsudc.c: In function 'cadence_hsudc_irq':
   drivers/usb/gadget/udc/cadence_hsudc.c:224:5: error: implicit declaration of function 'cadence_hsudc_dma_irq' [-Werror=implicit-function-declaration]
        cadence_hsudc_dma_irq(hsudc_dev, i,
        ^
   drivers/usb/gadget/udc/cadence_hsudc.c: In function 'hsudc_copy_to_fifo':
   drivers/usb/gadget/udc/cadence_hsudc.c:854:36: warning: dereferencing 'void *' pointer
       hsudc_write32(*(uint32_t *)(&buf[i]), reg);
                                       ^
   drivers/usb/gadget/udc/cadence_hsudc.c:143:11: note: in definition of macro 'hsudc_write32'
      writel((value), hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c:854:32: warning: taking address of expression of type 'void'
       hsudc_write32(*(uint32_t *)(&buf[i]), reg);
                                   ^
   drivers/usb/gadget/udc/cadence_hsudc.c:143:11: note: in definition of macro 'hsudc_write32'
      writel((value), hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c:858:36: warning: dereferencing 'void *' pointer
       hsudc_write16(*(uint16_t *)(&buf[i]), reg);
                                       ^
   drivers/usb/gadget/udc/cadence_hsudc.c:141:11: note: in definition of macro 'hsudc_write16'
      writew((value)&0xFFFF, hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c:858:32: warning: taking address of expression of type 'void'
       hsudc_write16(*(uint16_t *)(&buf[i]), reg);
                                   ^
   drivers/usb/gadget/udc/cadence_hsudc.c:141:11: note: in definition of macro 'hsudc_write16'
      writew((value)&0xFFFF, hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c:861:34: warning: dereferencing 'void *' pointer
       hsudc_write8(*(uint8_t *)(&buf[i]), reg);
                                     ^
   drivers/usb/gadget/udc/cadence_hsudc.c:139:11: note: in definition of macro 'hsudc_write8'
      writeb((value)&0xFF, hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c:861:30: warning: taking address of expression of type 'void'
       hsudc_write8(*(uint8_t *)(&buf[i]), reg);
                                 ^
   drivers/usb/gadget/udc/cadence_hsudc.c:139:11: note: in definition of macro 'hsudc_write8'
      writeb((value)&0xFF, hsudc_dev->io_base + (reg))
              ^
   drivers/usb/gadget/udc/cadence_hsudc.c: In function 'hsudc_copy_from_fifo':
   drivers/usb/gadget/udc/cadence_hsudc.c:877:23: warning: dereferencing 'void *' pointer
       *((uint32_t *) &buf[i]) = hsudc_read32(reg);
                          ^
   drivers/usb/gadget/udc/cadence_hsudc.c:877:19: warning: taking address of expression of type 'void'
       *((uint32_t *) &buf[i]) = hsudc_read32(reg);
                      ^
   drivers/usb/gadget/udc/cadence_hsudc.c:880:23: warning: dereferencing 'void *' pointer
       *((uint16_t *) &buf[i]) = hsudc_read16(reg);
                          ^
   drivers/usb/gadget/udc/cadence_hsudc.c:880:19: warning: taking address of expression of type 'void'
       *((uint16_t *) &buf[i]) = hsudc_read16(reg);
                      ^
   drivers/usb/gadget/udc/cadence_hsudc.c:883:7: warning: dereferencing 'void *' pointer
       buf[i] = hsudc_read8(reg);
          ^
   drivers/usb/gadget/udc/cadence_hsudc.c:883:4: error: invalid use of void expression
       buf[i] = hsudc_read8(reg);
       ^
   drivers/usb/gadget/udc/cadence_hsudc.c: In function 'hsudc_ep_completion':
   drivers/usb/gadget/udc/cadence_hsudc.c:928:13: warning: unused variable 'i' [-Wunused-variable]
       unsigned i;
                ^

cc1: some warnings being treated as errors

vim +225 drivers/usb/gadget/udc/cadence_hsudc.c

157 /* Clear and disable DMAIRQ */
158 hsudc_write32(1 << i, HSUDC_DMA_IRQ_REG32);
159 hsudc_write32(hsudc_read32(HSUDC_DMA_IEN_REG32) &
160 ~(1 << dma_channel),
161 HSUDC_DMA_IEN_REG32);
162 }

 > 163		if ((dmashortirq & (1 << dma_channel))) {
   164			/* Clear and disable DMASHORTIRQ */
   165			hsudc_write32(1 << dma_channel, HSUDC_DMA_SHORTIRQ_REG32);
   166			hsudc_write32(hsudc_read32(HSUDC_DMA_SHORTIEN_REG32) &
   167					~(1 << dma_channel),
   168					HSUDC_DMA_SHORTIEN_REG32);
   169		}
   170		if (channel->is_available &
   171				channel->in_use &&
   172				channel->cur_ep->cur) {
   173			struct cadence_hsudc_request *hsudc_req =
   174				channel->cur_ep->cur;
   175			unsigned remain =
   176				hsudc_read32(HSUDC_DMA_CNT_REG32(dma_channel));
   177	
   178			hsudc_req->req.actual = hsudc_req->req.length - remain;
   179	
   180			queue_work(hsudc_dev->wq_ep,
   181					&channel->cur_ep->comp);
   182	
   183			channel->cur_ep->dma_channel = NULL;
   184			channel->cur_ep = NULL;
   185			channel->in_use = 0;
   186	
   187			/* Free DMA channel */
   188			up(&hsudc_dev->dma_sem);
   189		}
   190	}
   191	
   192	static irqreturn_t cadence_hsudc_irq(int irq, void *data)
   193	{
   194		struct cadence_hsudc *hsudc_dev = data;
   195	
   196		unsigned in_packet_irq;
   197		unsigned out_packet_irq;
   198		unsigned usbirq;
   199		unsigned dmairq, dmashortirq;
   200	
   201		(void)irq;
   202	
   203		in_packet_irq = hsudc_read16(HSUDC_INIRQ_REG16) &
   204				hsudc_read16(HSUDC_INIEN_REG16);
   205		out_packet_irq = hsudc_read16(HSUDC_OUTIRQ_REG16) &
   206				 hsudc_read16(HSUDC_OUTIEN_REG16);
   207		usbirq = hsudc_read8(HSUDC_USBIRQ_REG8) &
   208			 hsudc_read8(HSUDC_USBIEN_REG8);
   209	
   210		dmairq = hsudc_read32(HSUDC_DMA_IRQ_REG32) &
   211			 hsudc_read32(HSUDC_DMA_IEN_REG32);
   212		dmashortirq = hsudc_read32(HSUDC_DMA_SHORTIRQ_REG32) &
   213			      hsudc_read32(HSUDC_DMA_SHORTIEN_REG32);
   214	
   215		dev_vdbg(&hsudc_dev->pdev->dev, "irq: in %04X out %04X usb %04X dma %x/%x\n",
   216				in_packet_irq, out_packet_irq,
   217				usbirq, dmairq, dmashortirq);
   218	
   219		if (dmairq || dmashortirq) {
   220			unsigned i;
   221	
   222			for (i = 0; i < hsudc_dev->hw_config->dma_channels; ++i)
   223				if ((dmairq & (1 << i)) || (dmashortirq & (1 << i)))
   224					cadence_hsudc_dma_irq(hsudc_dev, i,
 > 225							      dmairq, dmashortirq);

226 }
227
228 if (in_packet_irq || out_packet_irq) {

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#5 lore raw
In reply to Neil Armstrong

Hi,

Quoted 9 lines · Neil Armstrong

Introduces UDC support for the Device-Mode only version of the Cadence USB2 Controller IP Core.

Host mode and OTG mode are not implemented by lack of hardware. Support for Isochronous endpoints is not implemented by lack of time.

Internal DMA is supported and can be activated by DT property.

looks like there are a few checkpatch warnings to be fixed:

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #89:
new file mode 100644

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #233: FILE: drivers/usb/gadget/udc/cadence_hsudc.c:44:
+ * - EP Bulk and Interrupt tranfer

WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #968: FILE: drivers/usb/gadget/udc/cadence_hsudc.c:779:
+ BUG();

WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #1492: FILE: drivers/usb/gadget/udc/cadence_hsudc.c:1303:
+ BUG();

WARNING: DT compatible string "cdns,usbhs-udc" appears un-documented -- check workspace/linux/Documentation/devicetree/bindings/ #1882: FILE: drivers/usb/gadget/udc/cadence_hsudc.c:1693:
+ { .compatible = "cdns,usbhs-udc" },

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #2603: FILE: drivers/usb/gadget/udc/cadence_hsudc_regs.h:272:
+#define HSUDC_DMA_BUSCTRL_HSIZE_8BIT (0 << 1) /* 8-bit data tranfer */

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #2604: FILE: drivers/usb/gadget/udc/cadence_hsudc_regs.h:273:
+#define HSUDC_DMA_BUSCTRL_HSIZE_16BIT (1 << 1) /* 16-bit data tranfer */

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #2605: FILE: drivers/usb/gadget/udc/cadence_hsudc_regs.h:274:
+#define HSUDC_DMA_BUSCTRL_HSIZE_32BIT (2 << 1) /* 32-bit data tranfer */

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #2607: FILE: drivers/usb/gadget/udc/cadence_hsudc_regs.h:276:
+#define HSUDC_DMA_BUSCTRL_BURST_SINGLE (0 << 4) /* Single tranfer */

total: 0 errors, 9 warnings, 2499 lines checked

Your patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

Signature · 1 line
balbi
#6 lore raw

Hi Felipe, Laurent,

I submitted this driver for a Cadence IP library from a now abandoned project.

The driver was working on a SoC platform ported on a FPGA, but I do not have access to this HW anymore.

But I have a fixed version...

Now, I am looking for SoCs, vendors and even Cadence people (or even Evatronix employees who worked on this IP before being in Cadence portfolio) to push this driver upstream by testing it on a real HW or even FPGA.

I hope this message in a bottle will get read !

Regards,
Neil

Quoted 59 lines · Felipe Balbi

Hi,

Quoted 9 lines · Neil Armstrong

Introduces UDC support for the Device-Mode only version of the Cadence USB2 Controller IP Core.

Host mode and OTG mode are not implemented by lack of hardware. Support for Isochronous endpoints is not implemented by lack of time.

Internal DMA is supported and can be activated by DT property.

looks like there are a few checkpatch warnings to be fixed:

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #89:
new file mode 100644

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #233: FILE: drivers/usb/gadget/udc/cadence_hsudc.c:44:
+ * - EP Bulk and Interrupt tranfer

WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #968: FILE: drivers/usb/gadget/udc/cadence_hsudc.c:779:

(quoted diff) +1 -0
+	BUG();

WARNING: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #1492: FILE: drivers/usb/gadget/udc/cadence_hsudc.c:1303:

(quoted diff) +1 -0
+		BUG();

WARNING: DT compatible string "cdns,usbhs-udc" appears un-documented -- check workspace/linux/Documentation/devicetree/bindings/ #1882: FILE: drivers/usb/gadget/udc/cadence_hsudc.c:1693:

drivers/usb/gadget/udc/cadence_hsudc.c new file +1 -0
+	{ .compatible = "cdns,usbhs-udc" },

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #2603: FILE: drivers/usb/gadget/udc/cadence_hsudc_regs.h:272:
+#define HSUDC_DMA_BUSCTRL_HSIZE_8BIT (0 << 1) /* 8-bit data tranfer */

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #2604: FILE: drivers/usb/gadget/udc/cadence_hsudc_regs.h:273:
+#define HSUDC_DMA_BUSCTRL_HSIZE_16BIT (1 << 1) /* 16-bit data tranfer */

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #2605: FILE: drivers/usb/gadget/udc/cadence_hsudc_regs.h:274:
+#define HSUDC_DMA_BUSCTRL_HSIZE_32BIT (2 << 1) /* 32-bit data tranfer */

WARNING: 'tranfer' may be misspelled - perhaps 'transfer'? #2607: FILE: drivers/usb/gadget/udc/cadence_hsudc_regs.h:276:
+#define HSUDC_DMA_BUSCTRL_BURST_SINGLE (0 << 4) /* Single tranfer */

total: 0 errors, 9 warnings, 2499 lines checked

Your patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

#7 lore raw

Hi,

(please break lines at 80-columns and don't top-post ;)

Quoted 9 lines · Neil Armstrong

[ Unknown signature status ]
Hi Felipe, Laurent,

I submitted this driver for a Cadence IP library from a now abandoned project.

The driver was working on a SoC platform ported on a FPGA, but I do not have access to this HW anymore.

Quoted 8 lines

But I have a fixed version...

Now, I am looking for SoCs, vendors and even Cadence people (or even Evatronix employees who worked on this IP before being in Cadence portfolio) to push this driver upstream by testing it on a real HW or even FPGA.

I hope this message in a bottle will get read !

if you manage to get it tested, send it to linux-usb ;)

Signature · 1 line
balbi
#8 lore raw
In reply to Neil Armstrong

Hi Neil,

Quoted 8 lines · On Tuesday 24 May 2016 16:16:16 Neil Armstrong wrote:

Hi Felipe, Laurent,

I submitted this driver for a Cadence IP library from a now abandoned project.

The driver was working on a SoC platform ported on a FPGA, but I do not have access to this HW anymore.

Quoted 8 lines

But I have a fixed version...

Now, I am looking for SoCs, vendors and even Cadence people (or even Evatronix employees who worked on this IP before being in Cadence portfolio) to push this driver upstream by testing it on a real HW or even FPGA.

I hope this message in a bottle will get read !

I've read it, but what do you expect from me ? :-)

Signature · 3 lines
Regards,

Laurent Pinchart