All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vipin KUMAR <vipin.kumar@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 12/28] SPEAr : USB Device Controller driver support added
Date: Wed, 14 Jul 2010 10:39:48 +0530	[thread overview]
Message-ID: <1279084204-3263-13-git-send-email-vipin.kumar@st.com> (raw)
In-Reply-To: <1279084204-3263-12-git-send-email-vipin.kumar@st.com>

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>
---
 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 a23169a..38b407f 100644
--- a/drivers/serial/usbtty.h
+++ b/drivers/serial/usbtty.h
@@ -33,8 +33,8 @@
 #include <usb/musb_udc.h>
 #elif defined(CONFIG_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_autogenerated.h>
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 1d7362d..3820f36 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -28,11 +28,11 @@ LIB	:= $(obj)libusb_gadget.a
 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_PXA27X) += pxa27x_udc.o
-COBJS-$(CONFIG_SPEARUDC) += spr_udc.o
 endif
 
 COBJS	:= $(COBJS-y)
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 4aa0c15..c03520b 100644
--- a/include/configs/spear-common.h
+++ b/include/configs/spear-common.h
@@ -36,14 +36,16 @@
 #define CONFIG_PHY_RESET_DELAY			(10000)		/* in usec */
 
 /* 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.6.0.2

  reply	other threads:[~2010-07-14  5:09 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-14  5:09 [U-Boot] [PATCH 00/28] Support for SPEAr13xx boards added Vipin KUMAR
2010-07-14  5:09 ` [U-Boot] [PATCH 01/28] change_bit routine defined Vipin KUMAR
2010-07-14  5:09   ` [U-Boot] [PATCH 02/28] SPEAr : SMI erase and write timeouts increased Vipin KUMAR
2010-07-14  5:09     ` [U-Boot] [PATCH 03/28] SPEAr : Placing ethaddr write and read within CONFIG_CMD_NET Vipin KUMAR
2010-07-14  5:09       ` [U-Boot] [PATCH 04/28] SPEAr : Reducing the max RAM size to 128MB Vipin KUMAR
2010-07-14  5:09         ` [U-Boot] [PATCH 05/28] SPEAr : Basic arch related support added for SPEAr SoCs Vipin KUMAR
2010-07-14  5:09           ` [U-Boot] [PATCH 06/28] SPEAr : Network support configured for spear SoCs Vipin KUMAR
2010-07-14  5:09             ` [U-Boot] [PATCH 07/28] SPEAr : macb driver support added for spear310 and spear320 Vipin KUMAR
2010-07-14  5:09               ` [U-Boot] [PATCH 08/28] SPEAr : FSMC driver support added Vipin KUMAR
2010-07-14  5:09                 ` [U-Boot] [PATCH 09/28] SPEAr : Configuring FSMC driver for NAND interface Vipin KUMAR
2010-07-14  5:09                   ` [U-Boot] [PATCH 10/28] SPEAr : i2c driver moved completely into drivers/i2c Vipin KUMAR
2010-07-14  5:09                     ` [U-Boot] [PATCH 11/28] SPEAr : smi driver moved completely into drivers/mtd Vipin KUMAR
2010-07-14  5:09                       ` Vipin KUMAR [this message]
2010-07-14  5:09                         ` [U-Boot] [PATCH 13/28] SPEAr : Supporting various configurations for spear3xx and spear6xx boards Vipin KUMAR
2010-07-14  5:09                           ` [U-Boot] [PATCH 14/28] SPEAr : Basic spear1300 architecture support added Vipin KUMAR
2010-07-14  5:09                             ` [U-Boot] [PATCH 15/28] SPEAr : spear1300 SoC " Vipin KUMAR
2010-07-14  5:09                               ` [U-Boot] [PATCH 16/28] SPEAr : Removing extraneous code Vipin KUMAR
2010-07-14  5:09                                 ` [U-Boot] [PATCH 17/28] SPEAr : USB device controller bugfixes Vipin KUMAR
2010-07-14  5:09                                   ` [U-Boot] [PATCH 18/28] SPEAr : Network driver fixes Vipin KUMAR
2010-07-14  5:09                                     ` [U-Boot] [PATCH 19/28] SPEAr : Changing the default environment variable bootargs Vipin KUMAR
2010-07-14  5:09                                       ` [U-Boot] [PATCH 20/28] SPEAr1300: Workaround the UHC problem (issue #101435) Vipin KUMAR
2010-07-14  5:09                                         ` [U-Boot] [PATCH 21/28] Enable high speed support for usb device framework and usbtty Vipin KUMAR
2010-07-14  5:09                                           ` [U-Boot] [PATCH 22/28] SPEAr : High speed support for designware peripheral Vipin KUMAR
2010-07-14  5:09                                             ` [U-Boot] [PATCH 23/28] SPEAr : Enable usb device high speed support Vipin KUMAR
2010-07-14  5:10                                               ` [U-Boot] [PATCH 24/28] SPEAr : Network support configuration Vipin KUMAR
2010-07-14  5:10                                                 ` [U-Boot] [PATCH 25/28] SPEAr : Enabling GPT clock explicitly Vipin KUMAR
2010-07-14  5:10                                                   ` [U-Boot] [PATCH 26/28] SPEAr : smi_init moved to board_init Vipin KUMAR
2010-07-14  5:10                                                     ` [U-Boot] [PATCH 27/28] SPEAr : Ethernet issue workaround is not needed when uboot is acting as flashing Vipin KUMAR
2010-07-14  5:10                                                       ` [U-Boot] [PATCH 28/28] SPEAr1310 : spear1310 support added Vipin KUMAR
2010-07-15 22:14                                                         ` Wolfgang Denk
2010-07-15 22:12                                                       ` [U-Boot] [PATCH 27/28] SPEAr : Ethernet issue workaround is not needed when uboot is acting as flashing Wolfgang Denk
2010-07-15 22:10                                                   ` [U-Boot] [PATCH 25/28] SPEAr : Enabling GPT clock explicitly Wolfgang Denk
2010-07-15 22:09                                                 ` [U-Boot] [PATCH 24/28] SPEAr : Network support configuration Wolfgang Denk
2010-08-01 11:06                                             ` [U-Boot] [PATCH 22/28] SPEAr : High speed support for designware peripheral Remy Bohmer
2010-07-15 22:08                                           ` [U-Boot] [PATCH 21/28] Enable high speed support for usb device framework and usbtty Wolfgang Denk
2010-08-01 11:11                                   ` [U-Boot] [PATCH 17/28] SPEAr : USB device controller bugfixes Remy Bohmer
2010-07-15 22:04                               ` [U-Boot] [PATCH 15/28] SPEAr : spear1300 SoC support added Wolfgang Denk
2010-07-16  4:45                                 ` Vipin KUMAR
2010-07-15 22:01                             ` [U-Boot] [PATCH 14/28] SPEAr : Basic spear1300 architecture " Wolfgang Denk
2010-07-15 21:55                           ` [U-Boot] [PATCH 13/28] SPEAr : Supporting various configurations for spear3xx and spear6xx boards Wolfgang Denk
2010-07-16 11:24                             ` Wolfgang Denk
2010-07-16 11:41                               ` Reinhard Meyer
2010-07-19  3:41                               ` Vipin KUMAR
2010-08-01 11:08                         ` [U-Boot] [PATCH 12/28] SPEAr : USB Device Controller driver support added Remy Bohmer
2010-07-15 21:41                 ` [U-Boot] [PATCH 08/28] SPEAr : FSMC " Wolfgang Denk
2010-07-15 21:38               ` [U-Boot] [PATCH 07/28] SPEAr : macb driver support added for spear310 and spear320 Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1279084204-3263-13-git-send-email-vipin.kumar@st.com \
    --to=vipin.kumar@st.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.