summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorVipin KUMAR <vipin.kumar@st.com>2012-03-06 23:39:37 +0000
committerMarek Vasut <marek.vasut@gmail.com>2012-03-19 00:08:16 +0100
commit2721551a11e64ac639547211dae027eea476af4c (patch)
treea61ab51a59f5d045eb801558f6e1152d410f5e14 /drivers
parent5b84dd67cfd8c07c4adff935310224a03d0c4d01 (diff)
downloadu-boot-imx-2721551a11e64ac639547211dae027eea476af4c.zip
u-boot-imx-2721551a11e64ac639547211dae027eea476af4c.tar.gz
u-boot-imx-2721551a11e64ac639547211dae027eea476af4c.tar.bz2
USB:gadget:designware USB device controller (UDC) implementation
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> Acked-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/serial/usbtty.h4
-rw-r--r--drivers/usb/gadget/Makefile2
-rw-r--r--drivers/usb/gadget/designware_udc.c (renamed from drivers/usb/gadget/spr_udc.c)57
3 files changed, 31 insertions, 32 deletions
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
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 */