public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/4] USB: Add support for designware UDC
@ 2012-02-16 12:03 Amit Virdi
  2012-02-16 12:03 ` [U-Boot] [PATCH 1/4] USB:gadget:designware USB device controller (UDC) implementation Amit Virdi
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Amit Virdi @ 2012-02-16 12:03 UTC (permalink / raw)
  To: u-boot

Support for designware USB device controller (UDC) exists in the u-boot for
SPEAr platform. This patchset makes the driver more generic so that it can be
used across multiple platforms.

Shiraz Hashim (1):
  USB:gadget:designware Fix memory nonalignment issue

Vipin KUMAR (3):
  USB:gadget:designware USB device controller (UDC) implementation
  USB:gadget:designware Device controller bugfixes
  USB:gadget:designware Support high speed

 drivers/serial/usbtty.h                            |    4 +-
 drivers/usb/gadget/Makefile                        |    2 +-
 drivers/usb/gadget/{spr_udc.c => designware_udc.c} |  138 ++++++++++++--------
 include/configs/spear-common.h                     |    4 +-
 include/usb/{spr_udc.h => designware_udc.h}        |    9 +-
 5 files changed, 98 insertions(+), 59 deletions(-)
 rename drivers/usb/gadget/{spr_udc.c => designware_udc.c} (89%)
 rename include/usb/{spr_udc.h => designware_udc.h} (97%)

-- 
1.7.2.2

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 1/4] USB:gadget:designware USB device controller (UDC) implementation
  2012-02-16 12:03 [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
@ 2012-02-16 12:03 ` Amit Virdi
  2012-03-05 18:12   ` Marek Vasut
  2012-02-16 12:03 ` [U-Boot] [PATCH 2/4] USB:gadget:designware Device controller bugfixes Amit Virdi
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: Amit Virdi @ 2012-02-16 12:03 UTC (permalink / raw)
  To: u-boot

From: Vipin KUMAR <vipin.kumar@st.com>

The earlier usb device controller driver was specific to spear platforms. This
patch implements the usb device controller driver as a generic controller which
can be reused by other platforms using this peripheral.

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
---
 drivers/serial/usbtty.h                            |    4 +-
 drivers/usb/gadget/Makefile                        |    2 +-
 drivers/usb/gadget/{spr_udc.c => designware_udc.c} |   57 ++++++++++----------
 include/configs/spear-common.h                     |    4 +-
 include/usb/{spr_udc.h => designware_udc.h}        |    6 +-
 5 files changed, 37 insertions(+), 36 deletions(-)
 rename drivers/usb/gadget/{spr_udc.c => designware_udc.c} (94%)
 rename include/usb/{spr_udc.h => designware_udc.h} (98%)

diff --git a/drivers/serial/usbtty.h b/drivers/serial/usbtty.h
index e449cd7..60347d7 100644
--- a/drivers/serial/usbtty.h
+++ b/drivers/serial/usbtty.h
@@ -33,8 +33,8 @@
 #include <usb/musb_udc.h>
 #elif defined(CONFIG_CPU_PXA27X)
 #include <usb/pxa27x_udc.h>
-#elif defined(CONFIG_SPEAR3XX) || defined(CONFIG_SPEAR600)
-#include <usb/spr_udc.h>
+#elif defined(CONFIG_DW_UDC)
+#include <usb/designware_udc.h>
 #endif
 
 #include <version.h>
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 64b091f..87d1918 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -39,11 +39,11 @@ else
 ifdef CONFIG_USB_DEVICE
 COBJS-y += core.o
 COBJS-y += ep0.o
+COBJS-$(CONFIG_DW_UDC) += designware_udc.o
 COBJS-$(CONFIG_OMAP1510) += omap1510_udc.o
 COBJS-$(CONFIG_OMAP1610) += omap1510_udc.o
 COBJS-$(CONFIG_MPC885_FAMILY) += mpc8xx_udc.o
 COBJS-$(CONFIG_CPU_PXA27X) += pxa27x_udc.o
-COBJS-$(CONFIG_SPEARUDC) += spr_udc.o
 endif
 endif
 
diff --git a/drivers/usb/gadget/spr_udc.c b/drivers/usb/gadget/designware_udc.c
similarity index 94%
rename from drivers/usb/gadget/spr_udc.c
rename to drivers/usb/gadget/designware_udc.c
index f2b06d6..aee44aa 100644
--- a/drivers/usb/gadget/spr_udc.c
+++ b/drivers/usb/gadget/designware_udc.c
@@ -29,14 +29,13 @@
 
 #include <usbdevice.h>
 #include "ep0.h"
-#include <usb/spr_udc.h>
+#include <usb/designware_udc.h>
 #include <asm/arch/hardware.h>
-#include <asm/arch/spr_misc.h>
 
 #define UDC_INIT_MDELAY		80	/* Device settle delay */
 
 /* Some kind of debugging output... */
-#ifndef DEBUG_SPRUSBTTY
+#ifndef DEBUG_DWUSBTTY
 #define UDCDBG(str)
 #define UDCDBGA(fmt, args...)
 #else
@@ -251,7 +250,7 @@ static void usbputpcktofifo(int epNum, u8 *bufp, u32 len)
 }
 
 /*
- * spear_write_noniso_tx_fifo - Write the next packet to TxFIFO.
+ * dw_write_noniso_tx_fifo - Write the next packet to TxFIFO.
  * @endpoint:		Endpoint pointer.
  *
  * If the endpoint has an active tx_urb, then the next packet of data from the
@@ -263,7 +262,7 @@ static void usbputpcktofifo(int epNum, u8 *bufp, u32 len)
  * transmitted in this packet.
  *
  */
-static void spear_write_noniso_tx_fifo(struct usb_endpoint_instance
+static void dw_write_noniso_tx_fifo(struct usb_endpoint_instance
 				       *endpoint)
 {
 	struct urb *urb = endpoint->tx_urb;
@@ -307,7 +306,7 @@ static void spear_write_noniso_tx_fifo(struct usb_endpoint_instance
  * Handle SETUP USB interrupt.
  * This function implements TRM Figure 14-14.
  */
-static void spear_udc_setup(struct usb_endpoint_instance *endpoint)
+static void dw_udc_setup(struct usb_endpoint_instance *endpoint)
 {
 	u8 *datap = (u8 *)&ep0_urb->device_request;
 	int ep_addr = endpoint->endpoint_address;
@@ -344,11 +343,11 @@ static void spear_udc_setup(struct usb_endpoint_instance *endpoint)
 		endpoint->tx_urb = ep0_urb;
 		endpoint->sent = 0;
 		/*
-		 * Write packet data to the FIFO.  spear_write_noniso_tx_fifo
+		 * Write packet data to the FIFO.  dw_write_noniso_tx_fifo
 		 * will update endpoint->last with the number of bytes written
 		 * to the FIFO.
 		 */
-		spear_write_noniso_tx_fifo(endpoint);
+		dw_write_noniso_tx_fifo(endpoint);
 
 		writel(0x0, &inep_regs_p[ep_addr].write_done);
 	}
@@ -361,7 +360,7 @@ static void spear_udc_setup(struct usb_endpoint_instance *endpoint)
 /*
  * Handle endpoint 0 RX interrupt
  */
-static void spear_udc_ep0_rx(struct usb_endpoint_instance *endpoint)
+static void dw_udc_ep0_rx(struct usb_endpoint_instance *endpoint)
 {
 	u8 dummy[64];
 
@@ -395,7 +394,7 @@ static void spear_udc_ep0_rx(struct usb_endpoint_instance *endpoint)
 /*
  * Handle endpoint 0 TX interrupt
  */
-static void spear_udc_ep0_tx(struct usb_endpoint_instance *endpoint)
+static void dw_udc_ep0_tx(struct usb_endpoint_instance *endpoint)
 {
 	struct usb_device_request *request = &ep0_urb->device_request;
 	int ep_addr;
@@ -444,7 +443,7 @@ static void spear_udc_ep0_tx(struct usb_endpoint_instance *endpoint)
 			 * need a zero-length terminating packet.
 			 */
 			UDCDBG("ACK control read data stage packet");
-			spear_write_noniso_tx_fifo(endpoint);
+			dw_write_noniso_tx_fifo(endpoint);
 
 			ep_addr = endpoint->endpoint_address;
 			writel(0x0, &inep_regs_p[ep_addr].write_done);
@@ -452,7 +451,7 @@ static void spear_udc_ep0_tx(struct usb_endpoint_instance *endpoint)
 	}
 }
 
-static struct usb_endpoint_instance *spear_find_ep(int ep)
+static struct usb_endpoint_instance *dw_find_ep(int ep)
 {
 	int i;
 
@@ -469,11 +468,11 @@ static struct usb_endpoint_instance *spear_find_ep(int ep)
  * The ep argument is a physical endpoint number for a non-ISO IN endpoint
  * in the range 1 to 15.
  */
-static void spear_udc_epn_rx(int ep)
+static void dw_udc_epn_rx(int ep)
 {
 	int nbytes = 0;
 	struct urb *urb;
-	struct usb_endpoint_instance *endpoint = spear_find_ep(ep);
+	struct usb_endpoint_instance *endpoint = dw_find_ep(ep);
 
 	if (endpoint) {
 		urb = endpoint->rcv_urb;
@@ -494,9 +493,9 @@ static void spear_udc_epn_rx(int ep)
  * The ep argument is a physical endpoint number for a non-ISO IN endpoint
  * in the range 16 to 30.
  */
-static void spear_udc_epn_tx(int ep)
+static void dw_udc_epn_tx(int ep)
 {
-	struct usb_endpoint_instance *endpoint = spear_find_ep(ep);
+	struct usb_endpoint_instance *endpoint = dw_find_ep(ep);
 
 	/*
 	 * We need to transmit a terminating zero-length packet now if
@@ -516,7 +515,7 @@ static void spear_udc_epn_tx(int ep)
 		 */
 		if (endpoint->tx_urb && endpoint->tx_urb->actual_length) {
 			/* write data to FIFO */
-			spear_write_noniso_tx_fifo(endpoint);
+			dw_write_noniso_tx_fifo(endpoint);
 			writel(0x0, &inep_regs_p[ep].write_done);
 
 		} else if (endpoint->tx_urb
@@ -765,7 +764,7 @@ void udc_startup_events(struct usb_device_instance *device)
 	 * DEVICE_HUB_CONFIGURED and DEVICE_RESET events here.
 	 * DEVICE_HUB_CONFIGURED causes a transition to the state STATE_POWERED,
 	 * and DEVICE_RESET causes a transition to the state STATE_DEFAULT.
-	 * The SPEAr USB client controller has the capability to detect when the
+	 * The DW USB client controller has the capability to detect when the
 	 * USB cable is connected to a powered USB bus, so we will defer the
 	 * DEVICE_HUB_CONFIGURED and DEVICE_RESET events until later.
 	 */
@@ -776,7 +775,7 @@ void udc_startup_events(struct usb_device_instance *device)
 /*
  * Plug detection interrupt handling
  */
-void spear_udc_plug_irq(void)
+void dw_udc_plug_irq(void)
 {
 	if (readl(&plug_regs_p->plug_state) & PLUG_STATUS_ATTACHED) {
 		/*
@@ -805,7 +804,7 @@ void spear_udc_plug_irq(void)
 /*
  * Device interrupt handling
  */
-void spear_udc_dev_irq(void)
+void dw_udc_dev_irq(void)
 {
 	if (readl(&udc_regs_p->dev_int) & DEV_INT_USBRESET) {
 		writel(~0x0, &udc_regs_p->endp_int_mask);
@@ -870,7 +869,7 @@ void spear_udc_dev_irq(void)
 /*
  * Endpoint interrupt handling
  */
-void spear_udc_endpoint_irq(void)
+void dw_udc_endpoint_irq(void)
 {
 	while (readl(&udc_regs_p->endp_int) & ENDP0_INT_CTRLOUT) {
 
@@ -878,13 +877,13 @@ void spear_udc_endpoint_irq(void)
 
 		if ((readl(&outep_regs_p[0].endp_status) & ENDP_STATUS_OUTMSK)
 		    == ENDP_STATUS_OUT_SETUP) {
-			spear_udc_setup(udc_device->bus->endpoint_array + 0);
+			dw_udc_setup(udc_device->bus->endpoint_array + 0);
 			writel(ENDP_STATUS_OUT_SETUP,
 			       &outep_regs_p[0].endp_status);
 
 		} else if ((readl(&outep_regs_p[0].endp_status) &
 			    ENDP_STATUS_OUTMSK) == ENDP_STATUS_OUT_DATA) {
-			spear_udc_ep0_rx(udc_device->bus->endpoint_array + 0);
+			dw_udc_ep0_rx(udc_device->bus->endpoint_array + 0);
 			writel(ENDP_STATUS_OUT_DATA,
 			       &outep_regs_p[0].endp_status);
 
@@ -897,7 +896,7 @@ void spear_udc_endpoint_irq(void)
 	}
 
 	if (readl(&udc_regs_p->endp_int) & ENDP0_INT_CTRLIN) {
-		spear_udc_ep0_tx(udc_device->bus->endpoint_array + 0);
+		dw_udc_ep0_tx(udc_device->bus->endpoint_array + 0);
 
 		writel(ENDP_STATUS_IN, &inep_regs_p[0].endp_status);
 		writel(ENDP0_INT_CTRLIN, &udc_regs_p->endp_int);
@@ -919,7 +918,7 @@ void spear_udc_endpoint_irq(void)
 		if ((readl(&outep_regs_p[epnum].endp_status) &
 		     ENDP_STATUS_OUTMSK) == ENDP_STATUS_OUT_DATA) {
 
-			spear_udc_epn_rx(epnum);
+			dw_udc_epn_rx(epnum);
 			writel(ENDP_STATUS_OUT_DATA,
 			       &outep_regs_p[epnum].endp_status);
 		} else if ((readl(&outep_regs_p[epnum].endp_status) &
@@ -941,7 +940,7 @@ void spear_udc_endpoint_irq(void)
 		if (readl(&inep_regs_p[epnum].endp_status) & ENDP_STATUS_IN) {
 			writel(ENDP_STATUS_IN,
 			       &outep_regs_p[epnum].endp_status);
-			spear_udc_epn_tx(epnum);
+			dw_udc_epn_tx(epnum);
 
 			writel(ENDP_STATUS_IN,
 			       &outep_regs_p[epnum].endp_status);
@@ -963,13 +962,13 @@ void udc_irq(void)
 	 * host requests.
 	 */
 	while (readl(&plug_regs_p->plug_pending))
-		spear_udc_plug_irq();
+		dw_udc_plug_irq();
 
 	while (readl(&udc_regs_p->dev_int))
-		spear_udc_dev_irq();
+		dw_udc_dev_irq();
 
 	if (readl(&udc_regs_p->endp_int))
-		spear_udc_endpoint_irq();
+		dw_udc_endpoint_irq();
 }
 
 /* Flow control */
diff --git a/include/configs/spear-common.h b/include/configs/spear-common.h
index 258574f..3dd6b57 100644
--- a/include/configs/spear-common.h
+++ b/include/configs/spear-common.h
@@ -28,14 +28,16 @@
  */
 
 /* USBD driver configuration */
-#define CONFIG_SPEARUDC
+#define CONFIG_DW_UDC
 #define CONFIG_USB_DEVICE
 #define CONFIG_USB_TTY
 
 #define CONFIG_USBD_PRODUCT_NAME		"SPEAr SoC"
 #define CONFIG_USBD_MANUFACTURER		"ST Microelectronics"
 
+#if defined(CONFIG_USB_TTY)
 #define CONFIG_EXTRA_ENV_USBTTY			"usbtty=cdc_acm\0"
+#endif
 
 /* I2C driver configuration */
 #define CONFIG_HARD_I2C
diff --git a/include/usb/spr_udc.h b/include/usb/designware_udc.h
similarity index 98%
rename from include/usb/spr_udc.h
rename to include/usb/designware_udc.h
index 2c332d5..ae98e8c 100644
--- a/include/usb/spr_udc.h
+++ b/include/usb/designware_udc.h
@@ -21,8 +21,8 @@
  * MA 02111-1307 USA
  */
 
-#ifndef __SPR_UDC_H
-#define __SPR_UDC_H
+#ifndef __DW_UDC_H
+#define __DW_UDC_H
 
 /*
  * Defines for  USBD
@@ -227,4 +227,4 @@ void udc_startup_events(struct usb_device_instance *device);
 void udc_setup_ep(struct usb_device_instance *device, unsigned int ep,
 		  struct usb_endpoint_instance *endpoint);
 
-#endif /* __SPR_UDC_H */
+#endif /* __DW_UDC_H */
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 2/4] USB:gadget:designware Device controller bugfixes
  2012-02-16 12:03 [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
  2012-02-16 12:03 ` [U-Boot] [PATCH 1/4] USB:gadget:designware USB device controller (UDC) implementation Amit Virdi
@ 2012-02-16 12:03 ` Amit Virdi
  2012-03-05 18:13   ` Marek Vasut
  2012-02-16 12:03 ` [U-Boot] [PATCH 3/4] USB:gadget:designware Support high speed Amit Virdi
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 20+ messages in thread
From: Amit Virdi @ 2012-02-16 12:03 UTC (permalink / raw)
  To: u-boot

From: Vipin KUMAR <vipin.kumar@st.com>

This patch fixes a few bugs in USB device controller driver.
The fixes are as follows
1. Adding error condition checks eg. NULL return
2. Endpoint other than endpoint 0 (control endpoint) are initialized
only if usb state machine reaches STATE_ADDRESSED or above
3. Zero length packet handling corrected
4. Dead code removed
5. Bulk out endpoint returns after servicing 1 interrupt and returns
back to service if more interrupts are pending

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
---
 drivers/usb/gadget/designware_udc.c |   59 ++++++++++++++++++++++------------
 1 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/designware_udc.c b/drivers/usb/gadget/designware_udc.c
index aee44aa..3c20f3d 100644
--- a/drivers/usb/gadget/designware_udc.c
+++ b/drivers/usb/gadget/designware_udc.c
@@ -497,16 +497,24 @@ static void dw_udc_epn_tx(int ep)
 {
 	struct usb_endpoint_instance *endpoint = dw_find_ep(ep);
 
+	if (!endpoint)
+		return;
+
 	/*
 	 * We need to transmit a terminating zero-length packet now if
 	 * we have sent all of the data in this URB and the transfer
 	 * size was an exact multiple of the packet size.
 	 */
-	if (endpoint && endpoint->tx_urb && endpoint->tx_urb->actual_length) {
-		if (endpoint->last == endpoint->tx_packetSize) {
-			/* handle zero length packet here */
-			writel(0x0, &inep_regs_p[ep].write_done);
-		}
+	if (endpoint->tx_urb &&
+	    (endpoint->last == endpoint->tx_packetSize) &&
+	    (endpoint->tx_urb->actual_length - endpoint->sent -
+	     endpoint->last == 0)) {
+		/* handle zero length packet here */
+		writel(0x0, &inep_regs_p[ep].write_done);
+
+	}
+
+	if (endpoint->tx_urb && endpoint->tx_urb->actual_length) {
 		/* retire the data that was just sent */
 		usbd_tx_complete(endpoint);
 		/*
@@ -548,8 +556,6 @@ int udc_init(void)
 
 	readl(&plug_regs_p->plug_pending);
 
-	udc_disconnect();
-
 	for (i = 0; i < UDC_INIT_MDELAY; i++)
 		udelay(1000);
 
@@ -561,10 +567,9 @@ int udc_init(void)
 	writel(~0x0, &udc_regs_p->endp_int_mask);
 
 	writel(DEV_CONF_FS_SPEED | DEV_CONF_REMWAKEUP | DEV_CONF_SELFPOW |
-	       /* Dev_Conf_SYNCFRAME | */
 	       DEV_CONF_PHYINT_16, &udc_regs_p->dev_conf);
 
-	writel(0x0, &udc_regs_p->dev_cntl);
+	writel(DEV_CNTL_SOFTDISCONNECT, &udc_regs_p->dev_cntl);
 
 	/* Clear all interrupts pending */
 	writel(DEV_INT_MSK, &udc_regs_p->dev_int);
@@ -588,6 +593,9 @@ void udc_setup_ep(struct usb_device_instance *device,
 	char *tt;
 	u32 endp_intmask;
 
+	if ((ep != 0) && (udc_device->device_state < STATE_ADDRESSED))
+		return;
+
 	tt = getenv("usbtty");
 	if (!tt)
 		tt = "generic";
@@ -647,9 +655,6 @@ void udc_setup_ep(struct usb_device_instance *device,
 		writel(packet_size | ((buffer_size / sizeof(int)) << 16),
 		       &out_p->endp_maxpacksize);
 
-		writel((packet_size << 19) | ENDP_EPTYPE_CNTL,
-		       &udc_regs_p->udc_endp_reg[ep_num]);
-
 	} else if ((ep_addr & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) {
 		/* Setup the IN endpoint */
 		writel(0x0, &in_p->endp_status);
@@ -708,7 +713,17 @@ void udc_setup_ep(struct usb_device_instance *device,
 /* Turn on the USB connection by enabling the pullup resistor */
 void udc_connect(void)
 {
-	u32 plug_st;
+	u32 plug_st, dev_cntl;
+
+	dev_cntl = readl(&udc_regs_p->dev_cntl);
+	dev_cntl |= DEV_CNTL_SOFTDISCONNECT;
+	writel(dev_cntl, &udc_regs_p->dev_cntl);
+
+	udelay(1000);
+
+	dev_cntl = readl(&udc_regs_p->dev_cntl);
+	dev_cntl &= ~DEV_CNTL_SOFTDISCONNECT;
+	writel(dev_cntl, &udc_regs_p->dev_cntl);
 
 	plug_st = readl(&plug_regs_p->plug_state);
 	plug_st &= ~(PLUG_STATUS_PHY_RESET | PLUG_STATUS_PHY_MODE);
@@ -720,6 +735,8 @@ void udc_disconnect(void)
 {
 	u32 plug_st;
 
+	writel(DEV_CNTL_SOFTDISCONNECT, &udc_regs_p->dev_cntl);
+
 	plug_st = readl(&plug_regs_p->plug_state);
 	plug_st |= (PLUG_STATUS_PHY_RESET | PLUG_STATUS_PHY_MODE);
 	writel(plug_st, &plug_regs_p->plug_state);
@@ -789,11 +806,6 @@ void dw_udc_plug_irq(void)
 		UDCDBG("device attached and powered");
 		udc_state_transition(udc_device->device_state, STATE_POWERED);
 	} else {
-		/*
-		 * USB cable detached
-		 * Reset the PHY and switch the mode.
-		 */
-		udc_disconnect();
 		writel(~0x0, &udc_regs_p->dev_int_mask);
 
 		UDCDBG("device detached or unpowered");
@@ -809,13 +821,18 @@ void dw_udc_dev_irq(void)
 	if (readl(&udc_regs_p->dev_int) & DEV_INT_USBRESET) {
 		writel(~0x0, &udc_regs_p->endp_int_mask);
 
-		udc_connect();
-
 		writel(readl(&inep_regs_p[0].endp_cntl) | ENDP_CNTL_FLUSH,
 		       &inep_regs_p[0].endp_cntl);
 
 		writel(DEV_INT_USBRESET, &udc_regs_p->dev_int);
 
+		/*
+		 * This endpoint0 specific register can be programmed only
+		 * after the phy clock is initialized
+		 */
+		writel((EP0_MAX_PACKET_SIZE << 19) | ENDP_EPTYPE_CNTL,
+				&udc_regs_p->udc_endp_reg[0]);
+
 		UDCDBG("device reset in progess");
 		udc_state_transition(udc_device->device_state, STATE_DEFAULT);
 	}
@@ -902,7 +919,7 @@ void dw_udc_endpoint_irq(void)
 		writel(ENDP0_INT_CTRLIN, &udc_regs_p->endp_int);
 	}
 
-	while (readl(&udc_regs_p->endp_int) & ENDP_INT_NONISOOUT_MSK) {
+	if (readl(&udc_regs_p->endp_int) & ENDP_INT_NONISOOUT_MSK) {
 		u32 epnum = 0;
 		u32 ep_int = readl(&udc_regs_p->endp_int) &
 		    ENDP_INT_NONISOOUT_MSK;
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 3/4] USB:gadget:designware Support high speed
  2012-02-16 12:03 [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
  2012-02-16 12:03 ` [U-Boot] [PATCH 1/4] USB:gadget:designware USB device controller (UDC) implementation Amit Virdi
  2012-02-16 12:03 ` [U-Boot] [PATCH 2/4] USB:gadget:designware Device controller bugfixes Amit Virdi
@ 2012-02-16 12:03 ` Amit Virdi
  2012-03-05 18:15   ` Marek Vasut
  2012-02-16 12:03 ` [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue Amit Virdi
  2012-02-24 11:56 ` [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
  4 siblings, 1 reply; 20+ messages in thread
From: Amit Virdi @ 2012-02-16 12:03 UTC (permalink / raw)
  To: u-boot

From: Vipin KUMAR <vipin.kumar@st.com>

This patch adds the support for usb device high speed for designware peripheral.

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
---
 drivers/usb/gadget/designware_udc.c |   13 +++++++++----
 include/usb/designware_udc.h        |    3 +++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/designware_udc.c b/drivers/usb/gadget/designware_udc.c
index 3c20f3d..d4b53a2 100644
--- a/drivers/usb/gadget/designware_udc.c
+++ b/drivers/usb/gadget/designware_udc.c
@@ -566,7 +566,7 @@ int udc_init(void)
 	writel(~0x0, &udc_regs_p->dev_int_mask);
 	writel(~0x0, &udc_regs_p->endp_int_mask);
 
-	writel(DEV_CONF_FS_SPEED | DEV_CONF_REMWAKEUP | DEV_CONF_SELFPOW |
+	writel(DEV_CONF_HS_SPEED | DEV_CONF_REMWAKEUP | DEV_CONF_SELFPOW |
 	       DEV_CONF_PHYINT_16, &udc_regs_p->dev_conf);
 
 	writel(DEV_CNTL_SOFTDISCONNECT, &udc_regs_p->dev_cntl);
@@ -577,6 +577,11 @@ int udc_init(void)
 	return 0;
 }
 
+int is_usbd_high_speed(void)
+{
+	return (readl(&udc_regs_p->dev_stat) & DEV_STAT_ENUM) ? 0 : 1;
+}
+
 /*
  * udc_setup_ep - setup endpoint
  * Associate a physical endpoint with endpoint_instance
@@ -792,7 +797,7 @@ void udc_startup_events(struct usb_device_instance *device)
 /*
  * Plug detection interrupt handling
  */
-void dw_udc_plug_irq(void)
+static void dw_udc_plug_irq(void)
 {
 	if (readl(&plug_regs_p->plug_state) & PLUG_STATUS_ATTACHED) {
 		/*
@@ -816,7 +821,7 @@ void dw_udc_plug_irq(void)
 /*
  * Device interrupt handling
  */
-void dw_udc_dev_irq(void)
+static void dw_udc_dev_irq(void)
 {
 	if (readl(&udc_regs_p->dev_int) & DEV_INT_USBRESET) {
 		writel(~0x0, &udc_regs_p->endp_int_mask);
@@ -886,7 +891,7 @@ void dw_udc_dev_irq(void)
 /*
  * Endpoint interrupt handling
  */
-void dw_udc_endpoint_irq(void)
+static void dw_udc_endpoint_irq(void)
 {
 	while (readl(&udc_regs_p->endp_int) & ENDP0_INT_CTRLOUT) {
 
diff --git a/include/usb/designware_udc.h b/include/usb/designware_udc.h
index ae98e8c..8d48ae9 100644
--- a/include/usb/designware_udc.h
+++ b/include/usb/designware_udc.h
@@ -197,6 +197,9 @@ struct udcfifo_regs {
 #define  UDC_INT_PACKET_SIZE		64
 #define  UDC_OUT_ENDPOINT		2
 #define  UDC_BULK_PACKET_SIZE		64
+#if defined(CONFIG_USBD_HS)
+#define  UDC_BULK_HS_PACKET_SIZE	512
+#endif
 #define  UDC_IN_ENDPOINT		3
 #define  UDC_OUT_PACKET_SIZE		64
 #define  UDC_IN_PACKET_SIZE		64
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue
  2012-02-16 12:03 [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
                   ` (2 preceding siblings ...)
  2012-02-16 12:03 ` [U-Boot] [PATCH 3/4] USB:gadget:designware Support high speed Amit Virdi
@ 2012-02-16 12:03 ` Amit Virdi
  2012-03-05 18:21   ` Marek Vasut
  2012-03-06 16:09   ` Mike Frysinger
  2012-02-24 11:56 ` [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
  4 siblings, 2 replies; 20+ messages in thread
From: Amit Virdi @ 2012-02-16 12:03 UTC (permalink / raw)
  To: u-boot

From: Shiraz Hashim <shiraz.hashim@st.com>

While receiving packets from FIFO sometimes the buffer provided was
nonaligned. Fix this by taking a temporary aligned buffer and then
copying the content to nonaligned buffer.

Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
---
 drivers/usb/gadget/designware_udc.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/designware_udc.c b/drivers/usb/gadget/designware_udc.c
index d4b53a2..878123c 100644
--- a/drivers/usb/gadget/designware_udc.c
+++ b/drivers/usb/gadget/designware_udc.c
@@ -202,6 +202,7 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len)
 	u32 i, nw, nb;
 	u32 *wrdp;
 	u8 *bytp;
+	u32 tmp[128];
 
 	if (readl(&udc_regs_p->dev_stat) & DEV_STAT_RXFIFO_EMPTY)
 		return -1;
@@ -209,7 +210,12 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len)
 	nw = len / sizeof(u32);
 	nb = len % sizeof(u32);
 
-	wrdp = (u32 *)bufp;
+	/* use tmp buf if bufp is not word aligned */
+	if ((int)bufp & 0x3)
+		wrdp = (u32 *)&tmp[0];
+	else
+		wrdp = (u32 *)bufp;
+
 	for (i = 0; i < nw; i++) {
 		writel(readl(fifo_ptr), wrdp);
 		wrdp++;
@@ -223,6 +229,13 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32 len)
 	}
 	readl(&outep_regs_p[epNum].write_done);
 
+	/* copy back tmp buffer to bufp if bufp is not word aligned */
+	if ((int)bufp & 0x3) {
+		bytp = (u8 *)&tmp[0];
+		for (i = 0; i < len; i++)
+			bufp[i] = bytp[i];
+	}
+
 	return 0;
 }
 
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 0/4] USB: Add support for designware UDC
  2012-02-16 12:03 [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
                   ` (3 preceding siblings ...)
  2012-02-16 12:03 ` [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue Amit Virdi
@ 2012-02-24 11:56 ` Amit Virdi
  2012-03-05 18:06   ` Marek Vasut
  4 siblings, 1 reply; 20+ messages in thread
From: Amit Virdi @ 2012-02-24 11:56 UTC (permalink / raw)
  To: u-boot

Hello Remy,

On Thu, Feb 16, 2012 at 5:33 PM, Amit Virdi <amit.virdi@st.com> wrote:
> Support for designware USB device controller (UDC) exists in the u-boot for
> SPEAr platform. This patchset makes the driver more generic so that it can be
> used across multiple platforms.
>
> Shiraz Hashim (1):
> ?USB:gadget:designware Fix memory nonalignment issue
>
> Vipin KUMAR (3):
> ?USB:gadget:designware USB device controller (UDC) implementation
> ?USB:gadget:designware Device controller bugfixes
> ?USB:gadget:designware Support high speed
>
> ?drivers/serial/usbtty.h ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? ?4 +-
> ?drivers/usb/gadget/Makefile ? ? ? ? ? ? ? ? ? ? ? ?| ? ?2 +-
> ?drivers/usb/gadget/{spr_udc.c => designware_udc.c} | ?138 ++++++++++++--------
> ?include/configs/spear-common.h ? ? ? ? ? ? ? ? ? ? | ? ?4 +-
> ?include/usb/{spr_udc.h => designware_udc.h} ? ? ? ?| ? ?9 +-
> ?5 files changed, 98 insertions(+), 59 deletions(-)
> ?rename drivers/usb/gadget/{spr_udc.c => designware_udc.c} (89%)
> ?rename include/usb/{spr_udc.h => designware_udc.h} (97%)
>
> --
> 1.7.2.2
>

Any comment on this patchset?

Thanks
Amit Virdi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 0/4] USB: Add support for designware UDC
  2012-02-24 11:56 ` [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
@ 2012-03-05 18:06   ` Marek Vasut
  0 siblings, 0 replies; 20+ messages in thread
From: Marek Vasut @ 2012-03-05 18:06 UTC (permalink / raw)
  To: u-boot

Dear Amit Virdi,

> Hello Remy,
> 
> On Thu, Feb 16, 2012 at 5:33 PM, Amit Virdi <amit.virdi@st.com> wrote:
> > Support for designware USB device controller (UDC) exists in the u-boot
> > for SPEAr platform. This patchset makes the driver more generic so that
> > it can be used across multiple platforms.
> > 
> > Shiraz Hashim (1):
> >  USB:gadget:designware Fix memory nonalignment issue
> > 
> > Vipin KUMAR (3):
> >  USB:gadget:designware USB device controller (UDC) implementation
> >  USB:gadget:designware Device controller bugfixes
> >  USB:gadget:designware Support high speed
> > 
> >  drivers/serial/usbtty.h                            |    4 +-
> >  drivers/usb/gadget/Makefile                        |    2 +-
> >  drivers/usb/gadget/{spr_udc.c => designware_udc.c} |  138
> > ++++++++++++-------- include/configs/spear-common.h                    
> > |    4 +-
> >  include/usb/{spr_udc.h => designware_udc.h}        |    9 +-
> >  5 files changed, 98 insertions(+), 59 deletions(-)
> >  rename drivers/usb/gadget/{spr_udc.c => designware_udc.c} (89%)
> >  rename include/usb/{spr_udc.h => designware_udc.h} (97%)
> > 
> > --
> > 1.7.2.2
> 
> Any comment on this patchset?
> 
> Thanks
> Amit Virdi

I took over after Remy, let's sort this out.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 1/4] USB:gadget:designware USB device controller (UDC) implementation
  2012-02-16 12:03 ` [U-Boot] [PATCH 1/4] USB:gadget:designware USB device controller (UDC) implementation Amit Virdi
@ 2012-03-05 18:12   ` Marek Vasut
  2012-03-06  4:32     ` Amit Virdi
  0 siblings, 1 reply; 20+ messages in thread
From: Marek Vasut @ 2012-03-05 18:12 UTC (permalink / raw)
  To: u-boot

Dear Amit Virdi,

> From: Vipin KUMAR <vipin.kumar@st.com>
> 
> The earlier usb device controller driver was specific to spear platforms.
> This patch implements the usb device controller driver as a generic
> controller which can be reused by other platforms using this peripheral.
> 
> Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
> Signed-off-by: Amit Virdi <amit.virdi@st.com>
> ---
>  drivers/serial/usbtty.h                            |    4 +-
>  drivers/usb/gadget/Makefile                        |    2 +-
>  drivers/usb/gadget/{spr_udc.c => designware_udc.c} |   57
> ++++++++++---------- include/configs/spear-common.h                     | 
>   4 +-
>  include/usb/{spr_udc.h => designware_udc.h}        |    6 +-
>  5 files changed, 37 insertions(+), 36 deletions(-)
>  rename drivers/usb/gadget/{spr_udc.c => designware_udc.c} (94%)
>  rename include/usb/{spr_udc.h => designware_udc.h} (98%)
> 

This patch is just a rename, right?

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 2/4] USB:gadget:designware Device controller bugfixes
  2012-02-16 12:03 ` [U-Boot] [PATCH 2/4] USB:gadget:designware Device controller bugfixes Amit Virdi
@ 2012-03-05 18:13   ` Marek Vasut
  2012-03-06  4:34     ` Amit Virdi
  0 siblings, 1 reply; 20+ messages in thread
From: Marek Vasut @ 2012-03-05 18:13 UTC (permalink / raw)
  To: u-boot

Dear Amit Virdi,

> From: Vipin KUMAR <vipin.kumar@st.com>
> 
> This patch fixes a few bugs in USB device controller driver.
> The fixes are as follows
> 1. Adding error condition checks eg. NULL return
> 2. Endpoint other than endpoint 0 (control endpoint) are initialized
> only if usb state machine reaches STATE_ADDRESSED or above
> 3. Zero length packet handling corrected
> 4. Dead code removed
> 5. Bulk out endpoint returns after servicing 1 interrupt and returns
> back to service if more interrupts are pending
> 
> Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
> Signed-off-by: Amit Virdi <amit.virdi@st.com>

Ok, I take it you know what you're doing here:

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 3/4] USB:gadget:designware Support high speed
  2012-02-16 12:03 ` [U-Boot] [PATCH 3/4] USB:gadget:designware Support high speed Amit Virdi
@ 2012-03-05 18:15   ` Marek Vasut
  2012-03-06  5:44     ` Amit Virdi
  0 siblings, 1 reply; 20+ messages in thread
From: Marek Vasut @ 2012-03-05 18:15 UTC (permalink / raw)
  To: u-boot

Dear Amit Virdi,

> From: Vipin KUMAR <vipin.kumar@st.com>
> 
> This patch adds the support for usb device high speed for designware
> peripheral.
> 
> Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
> Signed-off-by: Amit Virdi <amit.virdi@st.com>
> ---
>  drivers/usb/gadget/designware_udc.c |   13 +++++++++----
>  include/usb/designware_udc.h        |    3 +++
>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/designware_udc.c
> b/drivers/usb/gadget/designware_udc.c index 3c20f3d..d4b53a2 100644
> --- a/drivers/usb/gadget/designware_udc.c
> +++ b/drivers/usb/gadget/designware_udc.c
> @@ -566,7 +566,7 @@ int udc_init(void)
>  	writel(~0x0, &udc_regs_p->dev_int_mask);
>  	writel(~0x0, &udc_regs_p->endp_int_mask);
> 
> -	writel(DEV_CONF_FS_SPEED | DEV_CONF_REMWAKEUP | DEV_CONF_SELFPOW |
> +	writel(DEV_CONF_HS_SPEED | DEV_CONF_REMWAKEUP | DEV_CONF_SELFPOW |
>  	       DEV_CONF_PHYINT_16, &udc_regs_p->dev_conf);

Won't this break anything?
> 
>  	writel(DEV_CNTL_SOFTDISCONNECT, &udc_regs_p->dev_cntl);
> @@ -577,6 +577,11 @@ int udc_init(void)
>  	return 0;
>  }
> 
> +int is_usbd_high_speed(void)
> +{
> +	return (readl(&udc_regs_p->dev_stat) & DEV_STAT_ENUM) ? 0 : 1;
> +}
> +
>  /*
>   * udc_setup_ep - setup endpoint
>   * Associate a physical endpoint with endpoint_instance
> @@ -792,7 +797,7 @@ void udc_startup_events(struct usb_device_instance
> *device) /*
>   * Plug detection interrupt handling
>   */
> -void dw_udc_plug_irq(void)
> +static void dw_udc_plug_irq(void)

This staticisation stuff should go in a separate patch please.

>  {
>  	if (readl(&plug_regs_p->plug_state) & PLUG_STATUS_ATTACHED) {
>  		/*
> @@ -816,7 +821,7 @@ void dw_udc_plug_irq(void)
>  /*
>   * Device interrupt handling
>   */
> -void dw_udc_dev_irq(void)
> +static void dw_udc_dev_irq(void)
>  {
>  	if (readl(&udc_regs_p->dev_int) & DEV_INT_USBRESET) {
>  		writel(~0x0, &udc_regs_p->endp_int_mask);
> @@ -886,7 +891,7 @@ void dw_udc_dev_irq(void)
>  /*
>   * Endpoint interrupt handling
>   */
> -void dw_udc_endpoint_irq(void)
> +static void dw_udc_endpoint_irq(void)
>  {
>  	while (readl(&udc_regs_p->endp_int) & ENDP0_INT_CTRLOUT) {
> 
> diff --git a/include/usb/designware_udc.h b/include/usb/designware_udc.h
> index ae98e8c..8d48ae9 100644
> --- a/include/usb/designware_udc.h
> +++ b/include/usb/designware_udc.h
> @@ -197,6 +197,9 @@ struct udcfifo_regs {
>  #define  UDC_INT_PACKET_SIZE		64
>  #define  UDC_OUT_ENDPOINT		2
>  #define  UDC_BULK_PACKET_SIZE		64
> +#if defined(CONFIG_USBD_HS)
> +#define  UDC_BULK_HS_PACKET_SIZE	512
> +#endif

You can define this without the ifdef

>  #define  UDC_IN_ENDPOINT		3
>  #define  UDC_OUT_PACKET_SIZE		64
>  #define  UDC_IN_PACKET_SIZE		64

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue
  2012-02-16 12:03 ` [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue Amit Virdi
@ 2012-03-05 18:21   ` Marek Vasut
  2012-03-06  9:36     ` Amit Virdi
  2012-03-06 16:09   ` Mike Frysinger
  1 sibling, 1 reply; 20+ messages in thread
From: Marek Vasut @ 2012-03-05 18:21 UTC (permalink / raw)
  To: u-boot

Dear Amit Virdi,

> From: Shiraz Hashim <shiraz.hashim@st.com>
> 
> While receiving packets from FIFO sometimes the buffer provided was
> nonaligned. Fix this by taking a temporary aligned buffer and then
> copying the content to nonaligned buffer.
> 
> Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
> Signed-off-by: Amit Virdi <amit.virdi@st.com>
> ---
>  drivers/usb/gadget/designware_udc.c |   15 ++++++++++++++-
>  1 files changed, 14 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/gadget/designware_udc.c
> b/drivers/usb/gadget/designware_udc.c index d4b53a2..878123c 100644
> --- a/drivers/usb/gadget/designware_udc.c
> +++ b/drivers/usb/gadget/designware_udc.c
> @@ -202,6 +202,7 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32
> len) u32 i, nw, nb;
>  	u32 *wrdp;
>  	u8 *bytp;
> +	u32 tmp[128];
> 
>  	if (readl(&udc_regs_p->dev_stat) & DEV_STAT_RXFIFO_EMPTY)
>  		return -1;
> @@ -209,7 +210,12 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32
> len) nw = len / sizeof(u32);
>  	nb = len % sizeof(u32);
> 
> -	wrdp = (u32 *)bufp;
> +	/* use tmp buf if bufp is not word aligned */
> +	if ((int)bufp & 0x3)
> +		wrdp = (u32 *)&tmp[0];
> +	else
> +		wrdp = (u32 *)bufp;
> +
>  	for (i = 0; i < nw; i++) {
>  		writel(readl(fifo_ptr), wrdp);
>  		wrdp++;
> @@ -223,6 +229,13 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32
> len) }
>  	readl(&outep_regs_p[epNum].write_done);
> 
> +	/* copy back tmp buffer to bufp if bufp is not word aligned */
> +	if ((int)bufp & 0x3) {
> +		bytp = (u8 *)&tmp[0];
> +		for (i = 0; i < len; i++)
> +			bufp[i] = bytp[i];
> +	}
> +
>  	return 0;
>  }

This addresses EHCI cache problem, that's why you need bounce buffer, right? 

This is the patch from Puneet, can you give it a go and tell me if EHCI works 
for you without 4/4 patch from your series or do you still see issues?

http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/126447

Thanks in advance!

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 1/4] USB:gadget:designware USB device controller (UDC) implementation
  2012-03-05 18:12   ` Marek Vasut
@ 2012-03-06  4:32     ` Amit Virdi
  0 siblings, 0 replies; 20+ messages in thread
From: Amit Virdi @ 2012-03-06  4:32 UTC (permalink / raw)
  To: u-boot

Hello Marek,

On 3/5/2012 11:42 PM, Marek Vasut wrote:
> Dear Amit Virdi,
>
>> From: Vipin KUMAR<vipin.kumar@st.com>
>>
>> The earlier usb device controller driver was specific to spear platforms.
>> This patch implements the usb device controller driver as a generic
>> controller which can be reused by other platforms using this peripheral.
>>
>> Signed-off-by: Vipin Kumar<vipin.kumar@st.com>
>> Signed-off-by: Amit Virdi<amit.virdi@st.com>
>> ---
>>   drivers/serial/usbtty.h                            |    4 +-
>>   drivers/usb/gadget/Makefile                        |    2 +-
>>   drivers/usb/gadget/{spr_udc.c =>  designware_udc.c} |   57
>> ++++++++++---------- include/configs/spear-common.h                     |
>>    4 +-
>>   include/usb/{spr_udc.h =>  designware_udc.h}        |    6 +-
>>   5 files changed, 37 insertions(+), 36 deletions(-)
>>   rename drivers/usb/gadget/{spr_udc.c =>  designware_udc.c} (94%)
>>   rename include/usb/{spr_udc.h =>  designware_udc.h} (98%)
>>
>
> This patch is just a rename, right?
>

Yes.

> Acked-by: Marek Vasut<marex@denx.de>
>

Thanks n Regards
Amit Virdi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 2/4] USB:gadget:designware Device controller bugfixes
  2012-03-05 18:13   ` Marek Vasut
@ 2012-03-06  4:34     ` Amit Virdi
  0 siblings, 0 replies; 20+ messages in thread
From: Amit Virdi @ 2012-03-06  4:34 UTC (permalink / raw)
  To: u-boot

Dear Marek,

On 3/5/2012 11:43 PM, Marek Vasut wrote:
> Dear Amit Virdi,
>
>> From: Vipin KUMAR<vipin.kumar@st.com>
>>
>> This patch fixes a few bugs in USB device controller driver.
>> The fixes are as follows
>> 1. Adding error condition checks eg. NULL return
>> 2. Endpoint other than endpoint 0 (control endpoint) are initialized
>> only if usb state machine reaches STATE_ADDRESSED or above
>> 3. Zero length packet handling corrected
>> 4. Dead code removed
>> 5. Bulk out endpoint returns after servicing 1 interrupt and returns
>> back to service if more interrupts are pending
>>
>> Signed-off-by: Vipin Kumar<vipin.kumar@st.com>
>> Signed-off-by: Amit Virdi<amit.virdi@st.com>
>
> Ok, I take it you know what you're doing here:
>
> Acked-by: Marek Vasut<marex@denx.de>
>

Thanks.

Best Regards
Amit Virdi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 3/4] USB:gadget:designware Support high speed
  2012-03-05 18:15   ` Marek Vasut
@ 2012-03-06  5:44     ` Amit Virdi
  0 siblings, 0 replies; 20+ messages in thread
From: Amit Virdi @ 2012-03-06  5:44 UTC (permalink / raw)
  To: u-boot

Dear Marek,

On 3/5/2012 11:45 PM, Marek Vasut wrote:
> Dear Amit Virdi,
>
>> From: Vipin KUMAR<vipin.kumar@st.com>
>>
>> This patch adds the support for usb device high speed for designware
>> peripheral.
>>
>> Signed-off-by: Vipin Kumar<vipin.kumar@st.com>
>> Signed-off-by: Amit Virdi<amit.virdi@st.com>
>> ---
>>   drivers/usb/gadget/designware_udc.c |   13 +++++++++----
>>   include/usb/designware_udc.h        |    3 +++
>>   2 files changed, 12 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/designware_udc.c
>> b/drivers/usb/gadget/designware_udc.c index 3c20f3d..d4b53a2 100644
>> --- a/drivers/usb/gadget/designware_udc.c
>> +++ b/drivers/usb/gadget/designware_udc.c
>> @@ -566,7 +566,7 @@ int udc_init(void)
>>   	writel(~0x0,&udc_regs_p->dev_int_mask);
>>   	writel(~0x0,&udc_regs_p->endp_int_mask);
>>
>> -	writel(DEV_CONF_FS_SPEED | DEV_CONF_REMWAKEUP | DEV_CONF_SELFPOW |
>> +	writel(DEV_CONF_HS_SPEED | DEV_CONF_REMWAKEUP | DEV_CONF_SELFPOW |
>>   	       DEV_CONF_PHYINT_16,&udc_regs_p->dev_conf);
>
> Won't this break anything?

You're right. Perhaps, it's better to configure FS only if the FS is 
configured. I'll amend this part.

>>
>>   	writel(DEV_CNTL_SOFTDISCONNECT,&udc_regs_p->dev_cntl);
>> @@ -577,6 +577,11 @@ int udc_init(void)
>>   	return 0;
>>   }
>>
>> +int is_usbd_high_speed(void)
>> +{
>> +	return (readl(&udc_regs_p->dev_stat)&  DEV_STAT_ENUM) ? 0 : 1;
>> +}
>> +
>>   /*
>>    * udc_setup_ep - setup endpoint
>>    * Associate a physical endpoint with endpoint_instance
>> @@ -792,7 +797,7 @@ void udc_startup_events(struct usb_device_instance
>> *device) /*
>>    * Plug detection interrupt handling
>>    */
>> -void dw_udc_plug_irq(void)
>> +static void dw_udc_plug_irq(void)
>
> This staticisation stuff should go in a separate patch please.
>

Ok.

>>   {
>>   	if (readl(&plug_regs_p->plug_state)&  PLUG_STATUS_ATTACHED) {
>>   		/*
>> @@ -816,7 +821,7 @@ void dw_udc_plug_irq(void)
>>   /*
>>    * Device interrupt handling
>>    */
>> -void dw_udc_dev_irq(void)
>> +static void dw_udc_dev_irq(void)
>>   {
>>   	if (readl(&udc_regs_p->dev_int)&  DEV_INT_USBRESET) {
>>   		writel(~0x0,&udc_regs_p->endp_int_mask);
>> @@ -886,7 +891,7 @@ void dw_udc_dev_irq(void)
>>   /*
>>    * Endpoint interrupt handling
>>    */
>> -void dw_udc_endpoint_irq(void)
>> +static void dw_udc_endpoint_irq(void)
>>   {
>>   	while (readl(&udc_regs_p->endp_int)&  ENDP0_INT_CTRLOUT) {
>>
>> diff --git a/include/usb/designware_udc.h b/include/usb/designware_udc.h
>> index ae98e8c..8d48ae9 100644
>> --- a/include/usb/designware_udc.h
>> +++ b/include/usb/designware_udc.h
>> @@ -197,6 +197,9 @@ struct udcfifo_regs {
>>   #define  UDC_INT_PACKET_SIZE		64
>>   #define  UDC_OUT_ENDPOINT		2
>>   #define  UDC_BULK_PACKET_SIZE		64
>> +#if defined(CONFIG_USBD_HS)
>> +#define  UDC_BULK_HS_PACKET_SIZE	512
>> +#endif
>
> You can define this without the ifdef
>

Ok.

>>   #define  UDC_IN_ENDPOINT		3
>>   #define  UDC_OUT_PACKET_SIZE		64
>>   #define  UDC_IN_PACKET_SIZE		64
>

Thanks for reviewing.

Best Regards
Amit Virdi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue
  2012-03-05 18:21   ` Marek Vasut
@ 2012-03-06  9:36     ` Amit Virdi
  2012-03-06  9:51       ` Marek Vasut
  0 siblings, 1 reply; 20+ messages in thread
From: Amit Virdi @ 2012-03-06  9:36 UTC (permalink / raw)
  To: u-boot

Dear Marek,

On 3/5/2012 11:51 PM, Marek Vasut wrote:
> Dear Amit Virdi,
>
>> From: Shiraz Hashim<shiraz.hashim@st.com>
>>
>> While receiving packets from FIFO sometimes the buffer provided was
>> nonaligned. Fix this by taking a temporary aligned buffer and then
>> copying the content to nonaligned buffer.
>>
>> Signed-off-by: Shiraz Hashim<shiraz.hashim@st.com>
>> Signed-off-by: Amit Virdi<amit.virdi@st.com>
>> ---
>>   drivers/usb/gadget/designware_udc.c |   15 ++++++++++++++-
>>   1 files changed, 14 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/designware_udc.c
>> b/drivers/usb/gadget/designware_udc.c index d4b53a2..878123c 100644
>> --- a/drivers/usb/gadget/designware_udc.c
>> +++ b/drivers/usb/gadget/designware_udc.c
>> @@ -202,6 +202,7 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32
>> len) u32 i, nw, nb;
>>   	u32 *wrdp;
>>   	u8 *bytp;
>> +	u32 tmp[128];
>>
>>   	if (readl(&udc_regs_p->dev_stat)&  DEV_STAT_RXFIFO_EMPTY)
>>   		return -1;
>> @@ -209,7 +210,12 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32
>> len) nw = len / sizeof(u32);
>>   	nb = len % sizeof(u32);
>>
>> -	wrdp = (u32 *)bufp;
>> +	/* use tmp buf if bufp is not word aligned */
>> +	if ((int)bufp&  0x3)
>> +		wrdp = (u32 *)&tmp[0];
>> +	else
>> +		wrdp = (u32 *)bufp;
>> +
>>   	for (i = 0; i<  nw; i++) {
>>   		writel(readl(fifo_ptr), wrdp);
>>   		wrdp++;
>> @@ -223,6 +229,13 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp, u32
>> len) }
>>   	readl(&outep_regs_p[epNum].write_done);
>>
>> +	/* copy back tmp buffer to bufp if bufp is not word aligned */
>> +	if ((int)bufp&  0x3) {
>> +		bytp = (u8 *)&tmp[0];
>> +		for (i = 0; i<  len; i++)
>> +			bufp[i] = bytp[i];
>> +	}
>> +
>>   	return 0;
>>   }
>
> This addresses EHCI cache problem, that's why you need bounce buffer, right?
>

No. The problem was we were copying data word-by-word to a non-word 
aligned memory in the USB gadget. So, this is different from the USB 
host controller issue.


Thanks n Regards
Amit Virdi

> This is the patch from Puneet, can you give it a go and tell me if EHCI works
> for you without 4/4 patch from your series or do you still see issues?
>
> http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/126447
>
> Thanks in advance!
>
> Best regards,
> Marek Vasut
> .
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue
  2012-03-06  9:36     ` Amit Virdi
@ 2012-03-06  9:51       ` Marek Vasut
  2012-03-06 16:08         ` Mike Frysinger
  0 siblings, 1 reply; 20+ messages in thread
From: Marek Vasut @ 2012-03-06  9:51 UTC (permalink / raw)
  To: u-boot

Dear Amit Virdi,

> Dear Marek,
> 
> On 3/5/2012 11:51 PM, Marek Vasut wrote:
> > Dear Amit Virdi,
> > 
> >> From: Shiraz Hashim<shiraz.hashim@st.com>
> >> 
> >> While receiving packets from FIFO sometimes the buffer provided was
> >> nonaligned. Fix this by taking a temporary aligned buffer and then
> >> copying the content to nonaligned buffer.
> >> 
> >> Signed-off-by: Shiraz Hashim<shiraz.hashim@st.com>
> >> Signed-off-by: Amit Virdi<amit.virdi@st.com>
> >> ---
> >> 
> >>   drivers/usb/gadget/designware_udc.c |   15 ++++++++++++++-
> >>   1 files changed, 14 insertions(+), 1 deletions(-)
> >> 
> >> diff --git a/drivers/usb/gadget/designware_udc.c
> >> b/drivers/usb/gadget/designware_udc.c index d4b53a2..878123c 100644
> >> --- a/drivers/usb/gadget/designware_udc.c
> >> +++ b/drivers/usb/gadget/designware_udc.c
> >> @@ -202,6 +202,7 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp,
> >> u32 len) u32 i, nw, nb;
> >> 
> >>   	u32 *wrdp;
> >>   	u8 *bytp;
> >> 
> >> +	u32 tmp[128];
> >> 
> >>   	if (readl(&udc_regs_p->dev_stat)&  DEV_STAT_RXFIFO_EMPTY)
> >>   	
> >>   		return -1;
> >> 
> >> @@ -209,7 +210,12 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp,
> >> u32 len) nw = len / sizeof(u32);
> >> 
> >>   	nb = len % sizeof(u32);
> >> 
> >> -	wrdp = (u32 *)bufp;
> >> +	/* use tmp buf if bufp is not word aligned */
> >> +	if ((int)bufp&  0x3)
> >> +		wrdp = (u32 *)&tmp[0];
> >> +	else
> >> +		wrdp = (u32 *)bufp;
> >> +
> >> 
> >>   	for (i = 0; i<  nw; i++) {
> >>   	
> >>   		writel(readl(fifo_ptr), wrdp);
> >>   		wrdp++;
> >> 
> >> @@ -223,6 +229,13 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp,
> >> u32 len) }
> >> 
> >>   	readl(&outep_regs_p[epNum].write_done);
> >> 
> >> +	/* copy back tmp buffer to bufp if bufp is not word aligned */
> >> +	if ((int)bufp&  0x3) {
> >> +		bytp = (u8 *)&tmp[0];
> >> +		for (i = 0; i<  len; i++)
> >> +			bufp[i] = bytp[i];
> >> +	}
> >> +
> >> 
> >>   	return 0;
> >>   
> >>   }
> > 
> > This addresses EHCI cache problem, that's why you need bounce buffer,
> > right?
> 
> No. The problem was we were copying data word-by-word to a non-word
> aligned memory in the USB gadget. So, this is different from the USB
> host controller issue.
> 

I see ... why isn't buffer aligned by the usb stack then?

Thanks!

> 
> Thanks n Regards
> Amit Virdi
> 
> > This is the patch from Puneet, can you give it a go and tell me if EHCI
> > works for you without 4/4 patch from your series or do you still see
> > issues?
> > 
> > http://permalink.gmane.org/gmane.comp.boot-loaders.u-boot/126447
> > 
> > Thanks in advance!
> > 
> > Best regards,
> > Marek Vasut
> > .

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue
  2012-03-06  9:51       ` Marek Vasut
@ 2012-03-06 16:08         ` Mike Frysinger
  2012-03-07  7:14           ` Amit Virdi
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Frysinger @ 2012-03-06 16:08 UTC (permalink / raw)
  To: u-boot

On Tuesday 06 March 2012 04:51:57 Marek Vasut wrote:
> > On 3/5/2012 11:51 PM, Marek Vasut wrote:
> > > Amit Virdi wrote:
> > >> While receiving packets from FIFO sometimes the buffer provided was
> > >> nonaligned. Fix this by taking a temporary aligned buffer and then
> > >> copying the content to nonaligned buffer.
> > >> 
> > >> --- a/drivers/usb/gadget/designware_udc.c
> > >> +++ b/drivers/usb/gadget/designware_udc.c
> > >> @@ -202,6 +202,7 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp,
> > >> u32 len) u32 i, nw, nb;
> > >> 
> > >>   	u32 *wrdp;
> > >>   	u8 *bytp;
> > >> 
> > >> +	u32 tmp[128];
> > >> 
> > >>   	if (readl(&udc_regs_p->dev_stat)&  DEV_STAT_RXFIFO_EMPTY)
> > >>   	
> > >>   		return -1;
> > >> 
> > >> @@ -209,7 +210,12 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp,
> > >> u32 len) nw = len / sizeof(u32);
> > >> 
> > >>   	nb = len % sizeof(u32);
> > >> 
> > >> -	wrdp = (u32 *)bufp;
> > >> +	/* use tmp buf if bufp is not word aligned */
> > >> +	if ((int)bufp&  0x3)
> > >> +		wrdp = (u32 *)&tmp[0];
> > >> +	else
> > >> +		wrdp = (u32 *)bufp;
> > >> +
> > >> 
> > >>   	for (i = 0; i<  nw; i++) {
> > >>   	
> > >>   		writel(readl(fifo_ptr), wrdp);
> > >>   		wrdp++;
> > >> 
> > >> @@ -223,6 +229,13 @@ static int usbgetpckfromfifo(int epNum, u8 *bufp,
> > >> u32 len) }
> > >> 
> > >>   	readl(&outep_regs_p[epNum].write_done);
> > >> 
> > >> +	/* copy back tmp buffer to bufp if bufp is not word aligned */
> > >> +	if ((int)bufp&  0x3) {
> > >> +		bytp = (u8 *)&tmp[0];
> > >> +		for (i = 0; i<  len; i++)
> > >> +			bufp[i] = bytp[i];
> > >> +	}
> > >> +
> > >> 
> > >>   	return 0;
> > >>   
> > >>   }
> > > 
> > > This addresses EHCI cache problem, that's why you need bounce buffer,
> > > right?
> > 
> > No. The problem was we were copying data word-by-word to a non-word
> > aligned memory in the USB gadget. So, this is different from the USB
> > host controller issue.
> 
> I see ... why isn't buffer aligned by the usb stack then?

because it might not be a requirement higher up.  i.e. it's dealing with a 
data byte stream.  forcing all higher layers to use 32bit alignment because 
this host controller requires 32bit alignment in its FIFOs is incorrect.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120306/3e706ea1/attachment.pgp>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue
  2012-02-16 12:03 ` [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue Amit Virdi
  2012-03-05 18:21   ` Marek Vasut
@ 2012-03-06 16:09   ` Mike Frysinger
  2012-03-07  7:04     ` Amit Virdi
  1 sibling, 1 reply; 20+ messages in thread
From: Mike Frysinger @ 2012-03-06 16:09 UTC (permalink / raw)
  To: u-boot

On Thursday 16 February 2012 07:03:38 Amit Virdi wrote:
> --- a/drivers/usb/gadget/designware_udc.c
> +++ b/drivers/usb/gadget/designware_udc.c
> 
> +	/* copy back tmp buffer to bufp if bufp is not word aligned */
> +	if ((int)bufp & 0x3) {
> +		bytp = (u8 *)&tmp[0];
> +		for (i = 0; i < len; i++)
> +			bufp[i] = bytp[i];
> +	}

memcpy(bufp, tmp, len) ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120306/ee72f671/attachment.pgp>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue
  2012-03-06 16:09   ` Mike Frysinger
@ 2012-03-07  7:04     ` Amit Virdi
  0 siblings, 0 replies; 20+ messages in thread
From: Amit Virdi @ 2012-03-07  7:04 UTC (permalink / raw)
  To: u-boot

Hey Mike,

On 3/6/2012 9:39 PM, Mike Frysinger wrote:
> On Thursday 16 February 2012 07:03:38 Amit Virdi wrote:
>> --- a/drivers/usb/gadget/designware_udc.c
>> +++ b/drivers/usb/gadget/designware_udc.c
>>
>> +	/* copy back tmp buffer to bufp if bufp is not word aligned */
>> +	if ((int)bufp&  0x3) {
>> +		bytp = (u8 *)&tmp[0];
>> +		for (i = 0; i<  len; i++)
>> +			bufp[i] = bytp[i];
>> +	}
>
> memcpy(bufp, tmp, len) ?

Yes, memcpy can be used. I'll amend the code.

Thanks
Amit Virdi

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue
  2012-03-06 16:08         ` Mike Frysinger
@ 2012-03-07  7:14           ` Amit Virdi
  0 siblings, 0 replies; 20+ messages in thread
From: Amit Virdi @ 2012-03-07  7:14 UTC (permalink / raw)
  To: u-boot

Dear Marek,

>>>>>    }
>>>>
>>>> This addresses EHCI cache problem, that's why you need bounce buffer,
>>>> right?
>>>
>>> No. The problem was we were copying data word-by-word to a non-word
>>> aligned memory in the USB gadget. So, this is different from the USB
>>> host controller issue.
>>
>> I see ... why isn't buffer aligned by the usb stack then?
>
> because it might not be a requirement higher up.  i.e. it's dealing with a
> data byte stream.  forcing all higher layers to use 32bit alignment because
> this host controller requires 32bit alignment in its FIFOs is incorrect.

The usb gadget is used by the usbtty so we can receive any number of 
bytes and, as Mike explains, we cannot force 32-bit alignment.

Thanks
Amit Virdi

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2012-03-07  7:14 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-16 12:03 [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
2012-02-16 12:03 ` [U-Boot] [PATCH 1/4] USB:gadget:designware USB device controller (UDC) implementation Amit Virdi
2012-03-05 18:12   ` Marek Vasut
2012-03-06  4:32     ` Amit Virdi
2012-02-16 12:03 ` [U-Boot] [PATCH 2/4] USB:gadget:designware Device controller bugfixes Amit Virdi
2012-03-05 18:13   ` Marek Vasut
2012-03-06  4:34     ` Amit Virdi
2012-02-16 12:03 ` [U-Boot] [PATCH 3/4] USB:gadget:designware Support high speed Amit Virdi
2012-03-05 18:15   ` Marek Vasut
2012-03-06  5:44     ` Amit Virdi
2012-02-16 12:03 ` [U-Boot] [PATCH 4/4] USB:gadget:designware Fix memory nonalignment issue Amit Virdi
2012-03-05 18:21   ` Marek Vasut
2012-03-06  9:36     ` Amit Virdi
2012-03-06  9:51       ` Marek Vasut
2012-03-06 16:08         ` Mike Frysinger
2012-03-07  7:14           ` Amit Virdi
2012-03-06 16:09   ` Mike Frysinger
2012-03-07  7:04     ` Amit Virdi
2012-02-24 11:56 ` [U-Boot] [PATCH 0/4] USB: Add support for designware UDC Amit Virdi
2012-03-05 18:06   ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox