diff options
Diffstat (limited to 'drivers/usb/gadget/fusb300_udc.c')
-rw-r--r-- | drivers/usb/gadget/fusb300_udc.c | 111 |
1 files changed, 19 insertions, 92 deletions
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c index 763d462454b..24a924330c8 100644 --- a/drivers/usb/gadget/fusb300_udc.c +++ b/drivers/usb/gadget/fusb300_udc.c @@ -767,56 +767,6 @@ static void fusb300_rdfifo(struct fusb300_ep *ep, } while (!reg); } -/* write data to fifo */ -static void fusb300_wrfifo(struct fusb300_ep *ep, - struct fusb300_request *req) -{ - int i = 0; - u8 *tmp; - u32 data, reg; - struct fusb300 *fusb300 = ep->fusb300; - - tmp = req->req.buf; - req->req.actual = req->req.length; - - for (i = (req->req.length >> 2); i > 0; i--) { - data = *tmp | *(tmp + 1) << 8 | - *(tmp + 2) << 16 | *(tmp + 3) << 24; - - iowrite32(data, fusb300->reg + - FUSB300_OFFSET_EPPORT(ep->epnum)); - tmp += 4; - } - - switch (req->req.length % 4) { - case 1: - data = *tmp; - iowrite32(data, fusb300->reg + - FUSB300_OFFSET_EPPORT(ep->epnum)); - break; - case 2: - data = *tmp | *(tmp + 1) << 8; - iowrite32(data, fusb300->reg + - FUSB300_OFFSET_EPPORT(ep->epnum)); - break; - case 3: - data = *tmp | *(tmp + 1) << 8 | *(tmp + 2) << 16; - iowrite32(data, fusb300->reg + - FUSB300_OFFSET_EPPORT(ep->epnum)); - break; - default: - break; - } - - do { - reg = ioread32(fusb300->reg + FUSB300_OFFSET_IGR1); - reg &= FUSB300_IGR1_SYNF0_EMPTY_INT; - if (i) - printk(KERN_INFO"sync fifo is not empty!\n"); - i++; - } while (!reg); -} - static u8 fusb300_get_epnstall(struct fusb300 *fusb300, u8 ep) { u8 value; @@ -980,11 +930,6 @@ static void set_address(struct fusb300 *fusb300, struct usb_ctrlrequest *ctrl) } \ } while (0) -static void fusb300_ep0_complete(struct usb_ep *ep, - struct usb_request *req) -{ -} - static int setup_packet(struct fusb300 *fusb300, struct usb_ctrlrequest *ctrl) { u8 *p = (u8 *)ctrl; @@ -1029,17 +974,6 @@ static int setup_packet(struct fusb300 *fusb300, struct usb_ctrlrequest *ctrl) return ret; } -static void fusb300_set_ep_bycnt(struct fusb300_ep *ep, u32 bycnt) -{ - struct fusb300 *fusb300 = ep->fusb300; - u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPFFR(ep->epnum)); - - reg &= ~FUSB300_FFR_BYCNT; - reg |= bycnt & FUSB300_FFR_BYCNT; - - iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPFFR(ep->epnum)); -} - static void done(struct fusb300_ep *ep, struct fusb300_request *req, int status) { @@ -1063,8 +997,8 @@ static void done(struct fusb300_ep *ep, struct fusb300_request *req, fusb300_set_cxdone(ep->fusb300); } -void fusb300_fill_idma_prdtbl(struct fusb300_ep *ep, - struct fusb300_request *req) +static void fusb300_fill_idma_prdtbl(struct fusb300_ep *ep, dma_addr_t d, + u32 len) { u32 value; u32 reg; @@ -1076,10 +1010,9 @@ void fusb300_fill_idma_prdtbl(struct fusb300_ep *ep, reg &= FUSB300_EPPRD0_H; } while (reg); - iowrite32((u32) req->req.buf, ep->fusb300->reg + - FUSB300_OFFSET_EPPRD_W1(ep->epnum)); + iowrite32(d, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W1(ep->epnum)); - value = FUSB300_EPPRD0_BTC(req->req.length) | FUSB300_EPPRD0_H | + value = FUSB300_EPPRD0_BTC(len) | FUSB300_EPPRD0_H | FUSB300_EPPRD0_F | FUSB300_EPPRD0_L | FUSB300_EPPRD0_I; iowrite32(value, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W0(ep->epnum)); @@ -1116,13 +1049,12 @@ static void fusb300_set_idma(struct fusb300_ep *ep, struct fusb300_request *req) { dma_addr_t d; - u8 *tmp = NULL; d = dma_map_single(NULL, req->req.buf, req->req.length, DMA_TO_DEVICE); if (dma_mapping_error(NULL, d)) { - kfree(req->req.buf); printk(KERN_DEBUG "dma_mapping_error\n"); + return; } dma_sync_single_for_device(NULL, d, req->req.length, DMA_TO_DEVICE); @@ -1130,17 +1062,11 @@ static void fusb300_set_idma(struct fusb300_ep *ep, fusb300_enable_bit(ep->fusb300, FUSB300_OFFSET_IGER0, FUSB300_IGER0_EEPn_PRD_INT(ep->epnum)); - tmp = req->req.buf; - req->req.buf = (u8 *)d; - - fusb300_fill_idma_prdtbl(ep, req); + fusb300_fill_idma_prdtbl(ep, d, req->req.length); /* check idma is done */ fusb300_wait_idma_finished(ep); - req->req.buf = tmp; - - if (d) - dma_unmap_single(NULL, d, req->req.length, DMA_TO_DEVICE); + dma_unmap_single(NULL, d, req->req.length, DMA_TO_DEVICE); } static void in_ep_fifo_handler(struct fusb300_ep *ep) @@ -1148,14 +1074,8 @@ static void in_ep_fifo_handler(struct fusb300_ep *ep) struct fusb300_request *req = list_entry(ep->queue.next, struct fusb300_request, queue); - if (req->req.length) { -#if 0 - fusb300_set_ep_bycnt(ep, req->req.length); - fusb300_wrfifo(ep, req); -#else + if (req->req.length) fusb300_set_idma(ep, req); -#endif - } done(ep, req, 0); } @@ -1500,7 +1420,7 @@ static void init_controller(struct fusb300 *fusb300) /*------------------------------------------------------------------------*/ static struct fusb300 *the_controller; -int usb_gadget_probe_driver(struct usb_gadget_driver *driver, +static int fusb300_udc_start(struct usb_gadget_driver *driver, int (*bind)(struct usb_gadget *)) { struct fusb300 *fusb300 = the_controller; @@ -1544,9 +1464,8 @@ error: return retval; } -EXPORT_SYMBOL(usb_gadget_probe_driver); -int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) +static int fusb300_udc_stop(struct usb_gadget_driver *driver) { struct fusb300 *fusb300 = the_controller; @@ -1562,7 +1481,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) return 0; } -EXPORT_SYMBOL(usb_gadget_unregister_driver); /*--------------------------------------------------------------------------*/ static int fusb300_udc_pullup(struct usb_gadget *_gadget, int is_active) @@ -1572,12 +1490,15 @@ static int fusb300_udc_pullup(struct usb_gadget *_gadget, int is_active) static struct usb_gadget_ops fusb300_gadget_ops = { .pullup = fusb300_udc_pullup, + .start = fusb300_udc_start, + .stop = fusb300_udc_stop, }; static int __exit fusb300_remove(struct platform_device *pdev) { struct fusb300 *fusb300 = dev_get_drvdata(&pdev->dev); + usb_del_gadget_udc(&fusb300->gadget); iounmap(fusb300->reg); free_irq(platform_get_irq(pdev, 0), fusb300); @@ -1702,9 +1623,15 @@ static int __init fusb300_probe(struct platform_device *pdev) goto clean_up3; init_controller(fusb300); + ret = usb_add_gadget_udc(&pdev->dev, &fusb300->gadget); + if (ret) + goto err_add_udc; + dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION); return 0; +err_add_udc: + fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req); clean_up3: free_irq(ires->start, fusb300); |