* [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC
@ 2012-03-07 9:39 Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 1/5] USB:gadget:designware USB device controller (UDC) implementation Amit Virdi
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Amit Virdi @ 2012-03-07 9:39 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.
V2:
- Configure the gadget in HS only if CONFIG_USBD_HS is defined
- Made local functions static in a separate commit
- In "Fix memory nonalignment issue" used memcpy instead of copying
byte-by-byte
- Define the HS_PACKET_SIZE unconditionally
V1:
- Added support for designware UDC in a more generic way
Amit Virdi (1):
USB:gadget:designware Make locally used functions static
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} | 7 +-
5 files changed, 97 insertions(+), 58 deletions(-)
rename drivers/usb/gadget/{spr_udc.c => designware_udc.c} (89%)
rename include/usb/{spr_udc.h => designware_udc.h} (98%)
--
1.7.2.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH V2 1/5] USB:gadget:designware USB device controller (UDC) implementation
2012-03-07 9:39 [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Amit Virdi
@ 2012-03-07 9:39 ` Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 2/5] USB:gadget:designware Device controller bugfixes Amit Virdi
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Amit Virdi @ 2012-03-07 9:39 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>
Acked-by: Marek Vasut <marex@denx.de>
---
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 55d19b5..5fef8cc 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] 10+ messages in thread
* [U-Boot] [PATCH V2 2/5] USB:gadget:designware Device controller bugfixes
2012-03-07 9:39 [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 1/5] USB:gadget:designware USB device controller (UDC) implementation Amit Virdi
@ 2012-03-07 9:39 ` Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 3/5] USB:gadget:designware Support high speed Amit Virdi
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Amit Virdi @ 2012-03-07 9:39 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>
Acked-by: Marek Vasut <marex@denx.de>
---
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] 10+ messages in thread
* [U-Boot] [PATCH V2 3/5] USB:gadget:designware Support high speed
2012-03-07 9:39 [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 1/5] USB:gadget:designware USB device controller (UDC) implementation Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 2/5] USB:gadget:designware Device controller bugfixes Amit Virdi
@ 2012-03-07 9:39 ` Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 4/5] USB:gadget:designware Make locally used functions static Amit Virdi
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Amit Virdi @ 2012-03-07 9:39 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 | 10 ++++++++++
include/usb/designware_udc.h | 1 +
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/gadget/designware_udc.c b/drivers/usb/gadget/designware_udc.c
index 3c20f3d..205f54a 100644
--- a/drivers/usb/gadget/designware_udc.c
+++ b/drivers/usb/gadget/designware_udc.c
@@ -566,8 +566,13 @@ int udc_init(void)
writel(~0x0, &udc_regs_p->dev_int_mask);
writel(~0x0, &udc_regs_p->endp_int_mask);
+#ifndef CONFIG_USBD_HS
writel(DEV_CONF_FS_SPEED | DEV_CONF_REMWAKEUP | DEV_CONF_SELFPOW |
DEV_CONF_PHYINT_16, &udc_regs_p->dev_conf);
+#else
+ writel(DEV_CONF_HS_SPEED | DEV_CONF_REMWAKEUP | DEV_CONF_SELFPOW |
+ DEV_CONF_PHYINT_16, &udc_regs_p->dev_conf);
+#endif
writel(DEV_CNTL_SOFTDISCONNECT, &udc_regs_p->dev_cntl);
@@ -577,6 +582,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
diff --git a/include/usb/designware_udc.h b/include/usb/designware_udc.h
index ae98e8c..18b7c19 100644
--- a/include/usb/designware_udc.h
+++ b/include/usb/designware_udc.h
@@ -197,6 +197,7 @@ struct udcfifo_regs {
#define UDC_INT_PACKET_SIZE 64
#define UDC_OUT_ENDPOINT 2
#define UDC_BULK_PACKET_SIZE 64
+#define UDC_BULK_HS_PACKET_SIZE 512
#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] 10+ messages in thread
* [U-Boot] [PATCH V2 4/5] USB:gadget:designware Make locally used functions static
2012-03-07 9:39 [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Amit Virdi
` (2 preceding siblings ...)
2012-03-07 9:39 ` [U-Boot] [PATCH V2 3/5] USB:gadget:designware Support high speed Amit Virdi
@ 2012-03-07 9:39 ` Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 5/5] USB:gadget:designware Fix memory nonalignment issue Amit Virdi
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Amit Virdi @ 2012-03-07 9:39 UTC (permalink / raw)
To: u-boot
Signed-off-by: Amit Virdi <amit.virdi@st.com>
---
drivers/usb/gadget/designware_udc.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/designware_udc.c b/drivers/usb/gadget/designware_udc.c
index 205f54a..67cdb29 100644
--- a/drivers/usb/gadget/designware_udc.c
+++ b/drivers/usb/gadget/designware_udc.c
@@ -802,7 +802,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) {
/*
@@ -826,7 +826,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);
@@ -896,7 +896,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) {
--
1.7.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH V2 5/5] USB:gadget:designware Fix memory nonalignment issue
2012-03-07 9:39 [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Amit Virdi
` (3 preceding siblings ...)
2012-03-07 9:39 ` [U-Boot] [PATCH V2 4/5] USB:gadget:designware Make locally used functions static Amit Virdi
@ 2012-03-07 9:39 ` Amit Virdi
2012-03-07 11:19 ` [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Lukasz Majewski
2012-03-07 12:27 ` Marek Vasut
6 siblings, 0 replies; 10+ messages in thread
From: Amit Virdi @ 2012-03-07 9:39 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 | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/drivers/usb/gadget/designware_udc.c b/drivers/usb/gadget/designware_udc.c
index 67cdb29..7e9ccde 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,10 @@ 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)
+ memcpy(bufp, tmp, len);
+
return 0;
}
--
1.7.2.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC
2012-03-07 9:39 [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Amit Virdi
` (4 preceding siblings ...)
2012-03-07 9:39 ` [U-Boot] [PATCH V2 5/5] USB:gadget:designware Fix memory nonalignment issue Amit Virdi
@ 2012-03-07 11:19 ` Lukasz Majewski
2012-03-07 11:30 ` Stefan Roese
2012-03-07 12:27 ` Marek Vasut
6 siblings, 1 reply; 10+ messages in thread
From: Lukasz Majewski @ 2012-03-07 11:19 UTC (permalink / raw)
To: u-boot
On Wed, 07 Mar 2012 15:09:36 +0530
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.
>
> V2:
> - Configure the gadget in HS only if CONFIG_USBD_HS is defined
> - Made local functions static in a separate commit
> - In "Fix memory nonalignment issue" used memcpy instead of copying
> byte-by-byte
> - Define the HS_PACKET_SIZE unconditionally
>
> V1:
> - Added support for designware UDC in a more generic way
>
> Amit Virdi (1):
> USB:gadget:designware Make locally used functions static
>
> 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} | 7 +- 5 files
> changed, 97 insertions(+), 58 deletions(-) rename
> drivers/usb/gadget/{spr_udc.c => designware_udc.c} (89%) rename
> include/usb/{spr_udc.h => designware_udc.h} (98%)
>
Hi Amit,
Is this driver a Synopsis DWC2 or DWC3 UDC controller?
--
Best regards,
Lukasz Majewski
Samsung Poland R&D Center
Platform Group
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC
2012-03-07 11:19 ` [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Lukasz Majewski
@ 2012-03-07 11:30 ` Stefan Roese
0 siblings, 0 replies; 10+ messages in thread
From: Stefan Roese @ 2012-03-07 11:30 UTC (permalink / raw)
To: u-boot
Hi Lukasz,
On Wednesday 07 March 2012 12:19:11 Lukasz Majewski wrote:
> Is this driver a Synopsis DWC2 or DWC3 UDC controller?
DWC2! Is there already such a driver in mainline U-Boot? Are you working on
something here (I know that you are working on the Linux driver
generalization)?
Thanks,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC
2012-03-07 9:39 [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Amit Virdi
` (5 preceding siblings ...)
2012-03-07 11:19 ` [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Lukasz Majewski
@ 2012-03-07 12:27 ` Marek Vasut
2012-03-07 13:56 ` Amit Virdi
6 siblings, 1 reply; 10+ messages in thread
From: Marek Vasut @ 2012-03-07 12:27 UTC (permalink / raw)
To: u-boot
Dear Amit Virdi,
> 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.
>
> V2:
> - Configure the gadget in HS only if CONFIG_USBD_HS is defined
> - Made local functions static in a separate commit
> - In "Fix memory nonalignment issue" used memcpy instead of copying
> byte-by-byte
> - Define the HS_PACKET_SIZE unconditionally
>
> V1:
> - Added support for designware UDC in a more generic way
>
> Amit Virdi (1):
> USB:gadget:designware Make locally used functions static
>
> 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} | 7 +-
> 5 files changed, 97 insertions(+), 58 deletions(-)
> rename drivers/usb/gadget/{spr_udc.c => designware_udc.c} (89%)
> rename include/usb/{spr_udc.h => designware_udc.h} (98%)
Thank you for your efforts, I'll apply these.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 10+ messages in thread
* [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC
2012-03-07 12:27 ` Marek Vasut
@ 2012-03-07 13:56 ` Amit Virdi
0 siblings, 0 replies; 10+ messages in thread
From: Amit Virdi @ 2012-03-07 13:56 UTC (permalink / raw)
To: u-boot
Dear Marek,
On Wed, Mar 7, 2012 at 5:57 PM, Marek Vasut <marex@denx.de> wrote:
> Dear Amit Virdi,
>
>> 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.
>>
>> V2:
>> ?- Configure the gadget in HS only if CONFIG_USBD_HS is defined
>> ?- Made local functions static in a separate commit
>> ?- In "Fix memory nonalignment issue" used memcpy instead of copying
>> ? ?byte-by-byte
>> ?- Define the HS_PACKET_SIZE unconditionally
>>
>> V1:
>> ?- Added support for designware UDC in a more generic way
>>
>> Amit Virdi (1):
>> ? USB:gadget:designware Make locally used functions static
>>
>> 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} ? ? ? ?| ? ?7 +-
>> ?5 files changed, 97 insertions(+), 58 deletions(-)
>> ?rename drivers/usb/gadget/{spr_udc.c => designware_udc.c} (89%)
>> ?rename include/usb/{spr_udc.h => designware_udc.h} (98%)
>
> Thank you for your efforts, I'll apply these.
Thanks.
Regards
Amit Virdi
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-03-07 13:56 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-07 9:39 [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 1/5] USB:gadget:designware USB device controller (UDC) implementation Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 2/5] USB:gadget:designware Device controller bugfixes Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 3/5] USB:gadget:designware Support high speed Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 4/5] USB:gadget:designware Make locally used functions static Amit Virdi
2012-03-07 9:39 ` [U-Boot] [PATCH V2 5/5] USB:gadget:designware Fix memory nonalignment issue Amit Virdi
2012-03-07 11:19 ` [U-Boot] [PATCH V2 0/5] USB: Add support for designware UDC Lukasz Majewski
2012-03-07 11:30 ` Stefan Roese
2012-03-07 12:27 ` Marek Vasut
2012-03-07 13:56 ` Amit Virdi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox