[U-Boot] [PATCH 10/17] usb: mv_udc: Move QH and qTD into mv_drv
Marek Vasut
marex at denx.de
Wed Jul 10 03:16:36 CEST 2013
Both the endpoint queue head and the endpoint item list is a controller
specific thing. Move them both into controller private data.
Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Fabio Estevam <fabio.estevam at freescale.com>
Cc: Lei Wen <leiwen at marvell.com>
Cc: Otavio Salvador <otavio at ossystems.com.br>
Cc: Stefano Babic <sbabic at denx.de>
---
drivers/usb/gadget/mv_udc.c | 26 +++++++++++++-------------
include/usb/mv_udc.h | 2 ++
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/mv_udc.c
index 8fa9781..422d0a9 100644
--- a/drivers/usb/gadget/mv_udc.c
+++ b/drivers/usb/gadget/mv_udc.c
@@ -75,8 +75,6 @@ static struct usb_endpoint_descriptor ep0_in_desc = {
.bmAttributes = USB_ENDPOINT_XFER_CONTROL,
};
-struct ept_queue_head *epts;
-struct ept_queue_item *items[2 * NUM_ENDPOINTS];
static int mv_pullup(struct usb_gadget *gadget, int is_on);
static int mv_ep_enable(struct usb_ep *ep,
const struct usb_endpoint_descriptor *desc);
@@ -137,7 +135,7 @@ static void ep_enable(int num, int in)
struct ept_queue_head *head;
struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
unsigned n;
- head = epts + 2*num + in;
+ head = controller.epts + 2*num + in;
n = readl(&udc->epctrl[num]);
if (in)
@@ -178,8 +176,8 @@ static int mv_ep_queue(struct usb_ep *ep,
int bit, num, len, in;
num = mv_ep->desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
in = (mv_ep->desc->bEndpointAddress & USB_DIR_IN) != 0;
- item = items[2 * num + in];
- head = epts + 2 * num + in;
+ item = controller.items[2 * num + in];
+ head = controller.epts + 2 * num + in;
phys = (unsigned)req->buf;
len = req->length;
@@ -214,7 +212,7 @@ static void handle_ep_complete(struct mv_ep *ep)
in = (ep->desc->bEndpointAddress & USB_DIR_IN) != 0;
if (num == 0)
ep->desc = &ep0_out_desc;
- item = items[2 * num + in];
+ item = controller.items[2 * num + in];
if (item->info & 0xff)
printf("EP%d/%s FAIL nfo=%x pg0=%x\n",
@@ -243,7 +241,7 @@ static void handle_setup(void)
int status = 0;
int num, in, _num, _in, i;
char *buf;
- head = epts;
+ head = controller.epts + 2 * 0 + 0;
flush_cache((unsigned long)head, sizeof(struct ept_queue_head));
memcpy(&r, head->setup_data, sizeof(struct usb_ctrlrequest));
@@ -324,7 +322,7 @@ static void stop_activity(void)
& USB_ENDPOINT_NUMBER_MASK;
in = (controller.ep[i].desc->bEndpointAddress
& USB_DIR_IN) != 0;
- head = epts + (num * 2) + (in);
+ head = controller.epts + (num * 2) + (in);
head->info = INFO_ACTIVE;
}
}
@@ -407,7 +405,7 @@ static int mv_pullup(struct usb_gadget *gadget, int is_on)
writel(USBCMD_ITC(MICRO_8FRAME) | USBCMD_RST, &udc->usbcmd);
udelay(200);
- writel((unsigned) epts, &udc->epinitaddr);
+ writel((unsigned) controller.epts, &udc->epinitaddr);
/* select DEVICE mode */
writel(USBMODE_DEVICE, &udc->usbmode);
@@ -444,14 +442,15 @@ static int mvudc_probe(void)
int i;
const int num = 2 * NUM_ENDPOINTS;
- epts = memalign(PAGE_SIZE, num * sizeof(struct ept_queue_head));
- memset(epts, 0, num * sizeof(struct ept_queue_head));
+ controller.epts = memalign(PAGE_SIZE,
+ num * sizeof(struct ept_queue_head));
+ memset(controller.epts, 0, num * sizeof(struct ept_queue_head));
for (i = 0; i < 2 * NUM_ENDPOINTS; i++) {
/*
* For item0 and item1, they are served as ep0
* out&in seperately
*/
- head = epts + i;
+ head = controller.epts + i;
if (i < 2)
head->config = CONFIG_MAX_PKT(EP0_MAX_PACKET_SIZE)
| CONFIG_ZLT | CONFIG_IOS;
@@ -461,7 +460,8 @@ static int mvudc_probe(void)
head->next = TERMINATE;
head->info = 0;
- items[i] = memalign(PAGE_SIZE, sizeof(struct ept_queue_item));
+ controller.items[i] = memalign(PAGE_SIZE,
+ sizeof(struct ept_queue_item));
}
INIT_LIST_HEAD(&controller.gadget.ep_list);
diff --git a/include/usb/mv_udc.h b/include/usb/mv_udc.h
index 9af9358..78fa81c 100644
--- a/include/usb/mv_udc.h
+++ b/include/usb/mv_udc.h
@@ -88,6 +88,8 @@ struct mv_drv {
struct usb_gadget gadget;
struct usb_gadget_driver *driver;
struct ehci_ctrl *ctrl;
+ struct ept_queue_head *epts;
+ struct ept_queue_item *items[2 * NUM_ENDPOINTS];
struct mv_ep ep[NUM_ENDPOINTS];
};
--
1.7.10.4
More information about the U-Boot
mailing list