diff options
Diffstat (limited to 'drivers/usb/gadget/imx_udc.c')
-rw-r--r-- | drivers/usb/gadget/imx_udc.c | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c index 9e3fe306301d..3ee5bd8bea70 100644 --- a/drivers/usb/gadget/imx_udc.c +++ b/drivers/usb/gadget/imx_udc.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * driver/usb/gadget/imx_udc.c | 2 | * driver/usb/gadget/imx_udc.c |
3 | * | 3 | * |
4 | * Copyright (C) 2005 Mike Lee(eemike@gmail.com) | 4 | * Copyright (C) 2005 Mike Lee <eemike@gmail.com> |
5 | * Copyright (C) 2008 Darius Augulis <augulis.darius@gmail.com> | 5 | * Copyright (C) 2008 Darius Augulis <augulis.darius@gmail.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -51,7 +51,8 @@ void ep0_chg_stat(const char *label, struct imx_udc_struct *imx_usb, | |||
51 | void imx_udc_enable(struct imx_udc_struct *imx_usb) | 51 | void imx_udc_enable(struct imx_udc_struct *imx_usb) |
52 | { | 52 | { |
53 | int temp = __raw_readl(imx_usb->base + USB_CTRL); | 53 | int temp = __raw_readl(imx_usb->base + USB_CTRL); |
54 | __raw_writel(temp | CTRL_FE_ENA | CTRL_AFE_ENA, imx_usb->base + USB_CTRL); | 54 | __raw_writel(temp | CTRL_FE_ENA | CTRL_AFE_ENA, |
55 | imx_usb->base + USB_CTRL); | ||
55 | imx_usb->gadget.speed = USB_SPEED_FULL; | 56 | imx_usb->gadget.speed = USB_SPEED_FULL; |
56 | } | 57 | } |
57 | 58 | ||
@@ -126,7 +127,8 @@ void imx_udc_config(struct imx_udc_struct *imx_usb) | |||
126 | for (j = 0; j < 5; j++) { | 127 | for (j = 0; j < 5; j++) { |
127 | __raw_writeb(ep_conf[j], | 128 | __raw_writeb(ep_conf[j], |
128 | imx_usb->base + USB_DDAT); | 129 | imx_usb->base + USB_DDAT); |
129 | do {} while (__raw_readl(imx_usb->base + USB_DADR) | 130 | do {} while (__raw_readl(imx_usb->base |
131 | + USB_DADR) | ||
130 | & DADR_BSY); | 132 | & DADR_BSY); |
131 | } | 133 | } |
132 | } | 134 | } |
@@ -183,7 +185,8 @@ void imx_udc_init_ep(struct imx_udc_struct *imx_usb) | |||
183 | temp = (EP_DIR(imx_ep) << 7) | (max << 5) | 185 | temp = (EP_DIR(imx_ep) << 7) | (max << 5) |
184 | | (imx_ep->bmAttributes << 3); | 186 | | (imx_ep->bmAttributes << 3); |
185 | __raw_writel(temp, imx_usb->base + USB_EP_STAT(i)); | 187 | __raw_writel(temp, imx_usb->base + USB_EP_STAT(i)); |
186 | __raw_writel(temp | EPSTAT_FLUSH, imx_usb->base + USB_EP_STAT(i)); | 188 | __raw_writel(temp | EPSTAT_FLUSH, |
189 | imx_usb->base + USB_EP_STAT(i)); | ||
187 | D_INI(imx_usb->dev, "<%s> ep%d_stat %08x\n", __func__, i, | 190 | D_INI(imx_usb->dev, "<%s> ep%d_stat %08x\n", __func__, i, |
188 | __raw_readl(imx_usb->base + USB_EP_STAT(i))); | 191 | __raw_readl(imx_usb->base + USB_EP_STAT(i))); |
189 | } | 192 | } |
@@ -278,15 +281,18 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep) | |||
278 | struct imx_udc_struct *imx_usb = imx_ep->imx_usb; | 281 | struct imx_udc_struct *imx_usb = imx_ep->imx_usb; |
279 | int temp, i; | 282 | int temp, i; |
280 | 283 | ||
281 | D_ERR(imx_usb->dev, "<%s> Forced stall on %s\n", __func__, imx_ep->ep.name); | 284 | D_ERR(imx_usb->dev, |
285 | "<%s> Forced stall on %s\n", __func__, imx_ep->ep.name); | ||
282 | 286 | ||
283 | imx_flush(imx_ep); | 287 | imx_flush(imx_ep); |
284 | 288 | ||
285 | /* Special care for ep0 */ | 289 | /* Special care for ep0 */ |
286 | if (!EP_NO(imx_ep)) { | 290 | if (!EP_NO(imx_ep)) { |
287 | temp = __raw_readl(imx_usb->base + USB_CTRL); | 291 | temp = __raw_readl(imx_usb->base + USB_CTRL); |
288 | __raw_writel(temp | CTRL_CMDOVER | CTRL_CMDERROR, imx_usb->base + USB_CTRL); | 292 | __raw_writel(temp | CTRL_CMDOVER | CTRL_CMDERROR, |
289 | do { } while (__raw_readl(imx_usb->base + USB_CTRL) & CTRL_CMDOVER); | 293 | imx_usb->base + USB_CTRL); |
294 | do { } while (__raw_readl(imx_usb->base + USB_CTRL) | ||
295 | & CTRL_CMDOVER); | ||
290 | temp = __raw_readl(imx_usb->base + USB_CTRL); | 296 | temp = __raw_readl(imx_usb->base + USB_CTRL); |
291 | __raw_writel(temp & ~CTRL_CMDERROR, imx_usb->base + USB_CTRL); | 297 | __raw_writel(temp & ~CTRL_CMDERROR, imx_usb->base + USB_CTRL); |
292 | } | 298 | } |
@@ -296,7 +302,8 @@ void imx_ep_stall(struct imx_ep_struct *imx_ep) | |||
296 | imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); | 302 | imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); |
297 | 303 | ||
298 | for (i = 0; i < 100; i ++) { | 304 | for (i = 0; i < 100; i ++) { |
299 | temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep))); | 305 | temp = __raw_readl(imx_usb->base |
306 | + USB_EP_STAT(EP_NO(imx_ep))); | ||
300 | if (!(temp & EPSTAT_STALL)) | 307 | if (!(temp & EPSTAT_STALL)) |
301 | break; | 308 | break; |
302 | udelay(20); | 309 | udelay(20); |
@@ -325,7 +332,8 @@ static int imx_udc_wakeup(struct usb_gadget *_gadget) | |||
325 | ******************************************************************************* | 332 | ******************************************************************************* |
326 | */ | 333 | */ |
327 | 334 | ||
328 | static void ep_add_request(struct imx_ep_struct *imx_ep, struct imx_request *req) | 335 | static void ep_add_request(struct imx_ep_struct *imx_ep, |
336 | struct imx_request *req) | ||
329 | { | 337 | { |
330 | if (unlikely(!req)) | 338 | if (unlikely(!req)) |
331 | return; | 339 | return; |
@@ -334,7 +342,8 @@ static void ep_add_request(struct imx_ep_struct *imx_ep, struct imx_request *req | |||
334 | list_add_tail(&req->queue, &imx_ep->queue); | 342 | list_add_tail(&req->queue, &imx_ep->queue); |
335 | } | 343 | } |
336 | 344 | ||
337 | static void ep_del_request(struct imx_ep_struct *imx_ep, struct imx_request *req) | 345 | static void ep_del_request(struct imx_ep_struct *imx_ep, |
346 | struct imx_request *req) | ||
338 | { | 347 | { |
339 | if (unlikely(!req)) | 348 | if (unlikely(!req)) |
340 | return; | 349 | return; |
@@ -343,7 +352,8 @@ static void ep_del_request(struct imx_ep_struct *imx_ep, struct imx_request *req | |||
343 | req->in_use = 0; | 352 | req->in_use = 0; |
344 | } | 353 | } |
345 | 354 | ||
346 | static void done(struct imx_ep_struct *imx_ep, struct imx_request *req, int status) | 355 | static void done(struct imx_ep_struct *imx_ep, |
356 | struct imx_request *req, int status) | ||
347 | { | 357 | { |
348 | ep_del_request(imx_ep, req); | 358 | ep_del_request(imx_ep, req); |
349 | 359 | ||
@@ -494,7 +504,8 @@ static int write_fifo(struct imx_ep_struct *imx_ep, struct imx_request *req) | |||
494 | __func__, imx_ep->ep.name, req, | 504 | __func__, imx_ep->ep.name, req, |
495 | completed ? "completed" : "not completed"); | 505 | completed ? "completed" : "not completed"); |
496 | if (!EP_NO(imx_ep)) | 506 | if (!EP_NO(imx_ep)) |
497 | ep0_chg_stat(__func__, imx_ep->imx_usb, EP0_IDLE); | 507 | ep0_chg_stat(__func__, |
508 | imx_ep->imx_usb, EP0_IDLE); | ||
498 | } | 509 | } |
499 | } | 510 | } |
500 | 511 | ||
@@ -586,7 +597,8 @@ static void handle_ep0_devreq(struct imx_udc_struct *imx_usb) | |||
586 | "<%s> no setup packet received\n", __func__); | 597 | "<%s> no setup packet received\n", __func__); |
587 | goto stall; | 598 | goto stall; |
588 | } | 599 | } |
589 | u.word[i] = __raw_readl(imx_usb->base + USB_EP_FDAT(EP_NO(imx_ep))); | 600 | u.word[i] = __raw_readl(imx_usb->base |
601 | + USB_EP_FDAT(EP_NO(imx_ep))); | ||
590 | } | 602 | } |
591 | 603 | ||
592 | temp = imx_ep_empty(imx_ep); | 604 | temp = imx_ep_empty(imx_ep); |
@@ -785,8 +797,10 @@ static int imx_ep_queue | |||
785 | /* Debug */ | 797 | /* Debug */ |
786 | D_REQ(imx_usb->dev, "<%s> ep%d %s request for [%d] bytes\n", | 798 | D_REQ(imx_usb->dev, "<%s> ep%d %s request for [%d] bytes\n", |
787 | __func__, EP_NO(imx_ep), | 799 | __func__, EP_NO(imx_ep), |
788 | ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state == EP0_IN_DATA_PHASE) | 800 | ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state |
789 | || (EP_NO(imx_ep) && EP_DIR(imx_ep))) ? "IN" : "OUT", usb_req->length); | 801 | == EP0_IN_DATA_PHASE) |
802 | || (EP_NO(imx_ep) && EP_DIR(imx_ep))) | ||
803 | ? "IN" : "OUT", usb_req->length); | ||
790 | dump_req(__func__, imx_ep, usb_req); | 804 | dump_req(__func__, imx_ep, usb_req); |
791 | 805 | ||
792 | if (imx_ep->stopped) { | 806 | if (imx_ep->stopped) { |
@@ -1061,7 +1075,8 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) | |||
1061 | 1075 | ||
1062 | /* Config setup */ | 1076 | /* Config setup */ |
1063 | if (imx_usb->cfg != cfg) { | 1077 | if (imx_usb->cfg != cfg) { |
1064 | D_REQ(imx_usb->dev, "<%s> Change config start\n",__func__); | 1078 | D_REQ(imx_usb->dev, |
1079 | "<%s> Change config start\n", __func__); | ||
1065 | u.bRequest = USB_REQ_SET_CONFIGURATION; | 1080 | u.bRequest = USB_REQ_SET_CONFIGURATION; |
1066 | u.bRequestType = USB_DIR_OUT | | 1081 | u.bRequestType = USB_DIR_OUT | |
1067 | USB_TYPE_STANDARD | | 1082 | USB_TYPE_STANDARD | |
@@ -1073,11 +1088,13 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) | |||
1073 | imx_usb->set_config = 1; | 1088 | imx_usb->set_config = 1; |
1074 | imx_usb->driver->setup(&imx_usb->gadget, &u); | 1089 | imx_usb->driver->setup(&imx_usb->gadget, &u); |
1075 | imx_usb->set_config = 0; | 1090 | imx_usb->set_config = 0; |
1076 | D_REQ(imx_usb->dev, "<%s> Change config done\n",__func__); | 1091 | D_REQ(imx_usb->dev, |
1092 | "<%s> Change config done\n", __func__); | ||
1077 | 1093 | ||
1078 | } | 1094 | } |
1079 | if (imx_usb->intf != intf || imx_usb->alt != alt) { | 1095 | if (imx_usb->intf != intf || imx_usb->alt != alt) { |
1080 | D_REQ(imx_usb->dev, "<%s> Change interface start\n",__func__); | 1096 | D_REQ(imx_usb->dev, |
1097 | "<%s> Change interface start\n", __func__); | ||
1081 | u.bRequest = USB_REQ_SET_INTERFACE; | 1098 | u.bRequest = USB_REQ_SET_INTERFACE; |
1082 | u.bRequestType = USB_DIR_OUT | | 1099 | u.bRequestType = USB_DIR_OUT | |
1083 | USB_TYPE_STANDARD | | 1100 | USB_TYPE_STANDARD | |
@@ -1090,7 +1107,8 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) | |||
1090 | imx_usb->set_config = 1; | 1107 | imx_usb->set_config = 1; |
1091 | imx_usb->driver->setup(&imx_usb->gadget, &u); | 1108 | imx_usb->driver->setup(&imx_usb->gadget, &u); |
1092 | imx_usb->set_config = 0; | 1109 | imx_usb->set_config = 0; |
1093 | D_REQ(imx_usb->dev, "<%s> Change interface done\n",__func__); | 1110 | D_REQ(imx_usb->dev, |
1111 | "<%s> Change interface done\n", __func__); | ||
1094 | } | 1112 | } |
1095 | } | 1113 | } |
1096 | 1114 | ||
@@ -1102,7 +1120,8 @@ static irqreturn_t imx_udc_irq(int irq, void *dev) | |||
1102 | */ | 1120 | */ |
1103 | if (imx_usb->ep0state == EP0_IDLE) { | 1121 | if (imx_usb->ep0state == EP0_IDLE) { |
1104 | temp = __raw_readl(imx_usb->base + USB_CTRL); | 1122 | temp = __raw_readl(imx_usb->base + USB_CTRL); |
1105 | __raw_writel(temp | CTRL_CMDOVER, imx_usb->base + USB_CTRL); | 1123 | __raw_writel(temp | CTRL_CMDOVER, |
1124 | imx_usb->base + USB_CTRL); | ||
1106 | } | 1125 | } |
1107 | } | 1126 | } |
1108 | 1127 | ||