2 * drivers/usb/gadget/s3c_udc_otg.c
3 * Samsung S3C on-chip full/high speed USB OTG 2.0 device controllers
5 * Copyright (C) 2008 for Samsung Electronics
7 * BSP Support for Samsung's UDC driver
9 * git://git.kernel.org/pub/scm/linux/kernel/git/kki_ap/linux-2.6-samsung.git
11 * State machine bugfixes:
12 * Marek Szyprowski <m.szyprowski@samsung.com>
15 * Marek Szyprowski <m.szyprowski@samsung.com>
16 * Lukasz Majewski <l.majewski@samsumg.com>
18 * SPDX-License-Identifier: GPL-2.0+
22 #include <asm/errno.h>
23 #include <linux/list.h>
26 #include <linux/usb/ch9.h>
27 #include <linux/usb/gadget.h>
29 #include <asm/byteorder.h>
30 #include <asm/unaligned.h>
33 #include <asm/mach-types.h>
34 #include <asm/arch/gpio.h>
37 #include <usb/lin_gadget_compat.h>
39 /***********************************************************/
41 #define OTG_DMA_MODE 1
46 #define DEBUG_OUT_EP 0
49 #include <usb/s3c_udc.h>
54 static char *state_names[] = {
57 "DATA_STATE_NEED_ZLP",
58 "WAIT_FOR_OUT_STATUS",
61 "WAIT_FOR_OUT_COMPLETE",
62 "WAIT_FOR_IN_COMPLETE",
63 "WAIT_FOR_NULL_COMPLETE",
66 #define DRIVER_DESC "S3C HS USB OTG Device Driver, (c) Samsung Electronics"
67 #define DRIVER_VERSION "15 March 2009"
69 struct s3c_udc *the_controller;
71 static const char driver_name[] = "s3c-udc";
72 static const char driver_desc[] = DRIVER_DESC;
73 static const char ep0name[] = "ep0-control";
76 static unsigned int ep0_fifo_size = 64;
77 static unsigned int ep_fifo_size = 512;
78 static unsigned int ep_fifo_size2 = 1024;
79 static int reset_available = 1;
81 static struct usb_ctrlrequest *usb_ctrl;
82 static dma_addr_t usb_ctrl_dma_addr;
87 static int s3c_ep_enable(struct usb_ep *ep,
88 const struct usb_endpoint_descriptor *);
89 static int s3c_ep_disable(struct usb_ep *ep);
90 static struct usb_request *s3c_alloc_request(struct usb_ep *ep,
92 static void s3c_free_request(struct usb_ep *ep, struct usb_request *);
94 static int s3c_queue(struct usb_ep *ep, struct usb_request *, gfp_t gfp_flags);
95 static int s3c_dequeue(struct usb_ep *ep, struct usb_request *);
96 static int s3c_fifo_status(struct usb_ep *ep);
97 static void s3c_fifo_flush(struct usb_ep *ep);
98 static void s3c_ep0_read(struct s3c_udc *dev);
99 static void s3c_ep0_kick(struct s3c_udc *dev, struct s3c_ep *ep);
100 static void s3c_handle_ep0(struct s3c_udc *dev);
101 static int s3c_ep0_write(struct s3c_udc *dev);
102 static int write_fifo_ep0(struct s3c_ep *ep, struct s3c_request *req);
103 static void done(struct s3c_ep *ep, struct s3c_request *req, int status);
104 static void stop_activity(struct s3c_udc *dev,
105 struct usb_gadget_driver *driver);
106 static int udc_enable(struct s3c_udc *dev);
107 static void udc_set_address(struct s3c_udc *dev, unsigned char address);
108 static void reconfig_usbd(void);
109 static void set_max_pktsize(struct s3c_udc *dev, enum usb_device_speed speed);
110 static void nuke(struct s3c_ep *ep, int status);
111 static int s3c_udc_set_halt(struct usb_ep *_ep, int value);
112 static void s3c_udc_set_nak(struct s3c_ep *ep);
114 void set_udc_gadget_private_data(void *p)
116 debug_cond(DEBUG_SETUP != 0,
117 "%s: the_controller: 0x%p, p: 0x%p\n", __func__,
119 the_controller->gadget.dev.device_data = p;
122 void *get_udc_gadget_private_data(struct usb_gadget *gadget)
124 return gadget->dev.device_data;
127 static struct usb_ep_ops s3c_ep_ops = {
128 .enable = s3c_ep_enable,
129 .disable = s3c_ep_disable,
131 .alloc_request = s3c_alloc_request,
132 .free_request = s3c_free_request,
135 .dequeue = s3c_dequeue,
137 .set_halt = s3c_udc_set_halt,
138 .fifo_status = s3c_fifo_status,
139 .fifo_flush = s3c_fifo_flush,
142 #define create_proc_files() do {} while (0)
143 #define remove_proc_files() do {} while (0)
145 /***********************************************************/
147 void __iomem *regs_otg;
148 struct s3c_usbotg_reg *reg;
149 struct s3c_usbotg_phy *phy;
150 static unsigned int usb_phy_ctrl;
152 void otg_phy_init(struct s3c_udc *dev)
154 dev->pdata->phy_control(1);
157 printf("USB PHY0 Enable\n");
160 writel(readl(usb_phy_ctrl) | USB_PHY_CTRL_EN0, usb_phy_ctrl);
162 if (dev->pdata->usb_flags == PHY0_SLEEP) /* C210 Universal */
163 writel((readl(&phy->phypwr)
164 &~(PHY_0_SLEEP | OTG_DISABLE_0 | ANALOG_PWRDOWN)
165 &~FORCE_SUSPEND_0), &phy->phypwr);
167 writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
168 &~FORCE_SUSPEND_0), &phy->phypwr);
170 writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
171 CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
173 writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
174 | PHY_SW_RST0, &phy->rstcon);
176 writel(readl(&phy->rstcon)
177 &~(PHY_SW_RST0 | LINK_SW_RST | PHYLNK_SW_RST), &phy->rstcon);
181 void otg_phy_off(struct s3c_udc *dev)
183 /* reset controller just in case */
184 writel(PHY_SW_RST0, &phy->rstcon);
186 writel(readl(&phy->phypwr) &~PHY_SW_RST0, &phy->rstcon);
189 writel(readl(&phy->phypwr) | OTG_DISABLE_0 | ANALOG_PWRDOWN
190 | FORCE_SUSPEND_0, &phy->phypwr);
192 writel(readl(usb_phy_ctrl) &~USB_PHY_CTRL_EN0, usb_phy_ctrl);
194 writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)),
199 dev->pdata->phy_control(0);
202 /***********************************************************/
204 #include "s3c_udc_otg_xfer_dma.c"
207 * udc_disable - disable USB device controller
209 static void udc_disable(struct s3c_udc *dev)
211 debug_cond(DEBUG_SETUP != 0, "%s: %p\n", __func__, dev);
213 udc_set_address(dev, 0);
215 dev->ep0state = WAIT_FOR_SETUP;
216 dev->gadget.speed = USB_SPEED_UNKNOWN;
217 dev->usb_address = 0;
223 * udc_reinit - initialize software state
225 static void udc_reinit(struct s3c_udc *dev)
229 debug_cond(DEBUG_SETUP != 0, "%s: %p\n", __func__, dev);
231 /* device/ep0 records init */
232 INIT_LIST_HEAD(&dev->gadget.ep_list);
233 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
234 dev->ep0state = WAIT_FOR_SETUP;
236 /* basic endpoint records init */
237 for (i = 0; i < S3C_MAX_ENDPOINTS; i++) {
238 struct s3c_ep *ep = &dev->ep[i];
241 list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list);
245 INIT_LIST_HEAD(&ep->queue);
249 /* the rest was statically initialized, and is read-only */
252 #define BYTES2MAXP(x) (x / 8)
253 #define MAXP2BYTES(x) (x * 8)
255 /* until it's enabled, this UDC should be completely invisible
258 static int udc_enable(struct s3c_udc *dev)
260 debug_cond(DEBUG_SETUP != 0, "%s: %p\n", __func__, dev);
265 debug_cond(DEBUG_SETUP != 0,
266 "S3C USB 2.0 OTG Controller Core Initialized : 0x%x\n",
267 readl(®->gintmsk));
269 dev->gadget.speed = USB_SPEED_UNKNOWN;
275 Register entry point for the peripheral controller driver.
277 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
279 struct s3c_udc *dev = the_controller;
283 debug_cond(DEBUG_SETUP != 0, "%s: %s\n", __func__, "no name");
286 || (driver->speed != USB_SPEED_FULL
287 && driver->speed != USB_SPEED_HIGH)
288 || !driver->bind || !driver->disconnect || !driver->setup)
295 spin_lock_irqsave(&dev->lock, flags);
296 /* first hook up the driver ... */
297 dev->driver = driver;
298 spin_unlock_irqrestore(&dev->lock, flags);
300 if (retval) { /* TODO */
301 printf("target device_add failed, error %d\n", retval);
305 retval = driver->bind(&dev->gadget);
307 debug_cond(DEBUG_SETUP != 0,
308 "%s: bind to driver --> error %d\n",
309 dev->gadget.name, retval);
316 debug_cond(DEBUG_SETUP != 0,
317 "Registered gadget driver %s\n", dev->gadget.name);
324 * Unregister entry point for the peripheral controller driver.
326 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
328 struct s3c_udc *dev = the_controller;
333 if (!driver || driver != dev->driver)
336 spin_lock_irqsave(&dev->lock, flags);
338 stop_activity(dev, driver);
339 spin_unlock_irqrestore(&dev->lock, flags);
341 driver->unbind(&dev->gadget);
343 disable_irq(IRQ_OTG);
350 * done - retire a request; caller blocked irqs
352 static void done(struct s3c_ep *ep, struct s3c_request *req, int status)
354 unsigned int stopped = ep->stopped;
356 debug("%s: %s %p, req = %p, stopped = %d\n",
357 __func__, ep->ep.name, ep, &req->req, stopped);
359 list_del_init(&req->queue);
361 if (likely(req->req.status == -EINPROGRESS))
362 req->req.status = status;
364 status = req->req.status;
366 if (status && status != -ESHUTDOWN) {
367 debug("complete %s req %p stat %d len %u/%u\n",
368 ep->ep.name, &req->req, status,
369 req->req.actual, req->req.length);
372 /* don't modify queue heads during completion callback */
376 printf("calling complete callback\n");
378 int i, len = req->req.length;
380 printf("pkt[%d] = ", req->req.length);
383 for (i = 0; i < len; i++) {
384 printf("%02x", ((u8 *)req->req.buf)[i]);
391 spin_unlock(&ep->dev->lock);
392 req->req.complete(&ep->ep, &req->req);
393 spin_lock(&ep->dev->lock);
395 debug("callback completed\n");
397 ep->stopped = stopped;
401 * nuke - dequeue ALL requests
403 static void nuke(struct s3c_ep *ep, int status)
405 struct s3c_request *req;
407 debug("%s: %s %p\n", __func__, ep->ep.name, ep);
409 /* called with irqs blocked */
410 while (!list_empty(&ep->queue)) {
411 req = list_entry(ep->queue.next, struct s3c_request, queue);
412 done(ep, req, status);
416 static void stop_activity(struct s3c_udc *dev,
417 struct usb_gadget_driver *driver)
421 /* don't disconnect drivers more than once */
422 if (dev->gadget.speed == USB_SPEED_UNKNOWN)
424 dev->gadget.speed = USB_SPEED_UNKNOWN;
426 /* prevent new request submissions, kill any outstanding requests */
427 for (i = 0; i < S3C_MAX_ENDPOINTS; i++) {
428 struct s3c_ep *ep = &dev->ep[i];
430 nuke(ep, -ESHUTDOWN);
433 /* report disconnect; the driver is already quiesced */
435 spin_unlock(&dev->lock);
436 driver->disconnect(&dev->gadget);
437 spin_lock(&dev->lock);
440 /* re-init driver-visible data structures */
444 static void reconfig_usbd(void)
446 /* 2. Soft-reset OTG Core and then unreset again. */
448 unsigned int uTemp = writel(CORE_SOFT_RESET, ®->grstctl);
450 debug("Reseting OTG controller\n");
452 writel(0<<15 /* PHY Low Power Clock sel*/
453 |1<<14 /* Non-Periodic TxFIFO Rewind Enable*/
454 |0x5<<10 /* Turnaround time*/
455 |0<<9 | 0<<8 /* [0:HNP disable,1:HNP enable][ 0:SRP disable*/
456 /* 1:SRP enable] H1= 1,1*/
457 |0<<7 /* Ulpi DDR sel*/
458 |0<<6 /* 0: high speed utmi+, 1: full speed serial*/
459 |0<<4 /* 0: utmi+, 1:ulpi*/
460 |1<<3 /* phy i/f 0:8bit, 1:16bit*/
461 |0x7<<0, /* HS/FS Timeout**/
464 /* 3. Put the OTG device core in the disconnected state.*/
465 uTemp = readl(®->dctl);
466 uTemp |= SOFT_DISCONNECT;
467 writel(uTemp, ®->dctl);
471 /* 4. Make the OTG device core exit from the disconnected state.*/
472 uTemp = readl(®->dctl);
473 uTemp = uTemp & ~SOFT_DISCONNECT;
474 writel(uTemp, ®->dctl);
476 /* 5. Configure OTG Core to initial settings of device mode.*/
477 /* [][1: full speed(30Mhz) 0:high speed]*/
478 writel(EP_MISS_CNT(1) | DEV_SPEED_HIGH_SPEED_20, ®->dcfg);
482 /* 6. Unmask the core interrupts*/
483 writel(GINTMSK_INIT, ®->gintmsk);
485 /* 7. Set NAK bit of EP0, EP1, EP2*/
486 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->out_endp[EP0_CON].doepctl);
487 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->in_endp[EP0_CON].diepctl);
489 for (i = 1; i < S3C_MAX_ENDPOINTS; i++) {
490 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->out_endp[i].doepctl);
491 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->in_endp[i].diepctl);
494 /* 8. Unmask EPO interrupts*/
495 writel(((1 << EP0_CON) << DAINT_OUT_BIT)
496 | (1 << EP0_CON), ®->daintmsk);
498 /* 9. Unmask device OUT EP common interrupts*/
499 writel(DOEPMSK_INIT, ®->doepmsk);
501 /* 10. Unmask device IN EP common interrupts*/
502 writel(DIEPMSK_INIT, ®->diepmsk);
504 /* 11. Set Rx FIFO Size (in 32-bit words) */
505 writel(RX_FIFO_SIZE >> 2, ®->grxfsiz);
507 /* 12. Set Non Periodic Tx FIFO Size */
508 writel((NPTX_FIFO_SIZE >> 2) << 16 | ((RX_FIFO_SIZE >> 2)) << 0,
511 for (i = 1; i < S3C_MAX_HW_ENDPOINTS; i++)
512 writel((PTX_FIFO_SIZE >> 2) << 16 |
513 ((RX_FIFO_SIZE + NPTX_FIFO_SIZE +
514 PTX_FIFO_SIZE*(i-1)) >> 2) << 0,
517 /* Flush the RX FIFO */
518 writel(RX_FIFO_FLUSH, ®->grstctl);
519 while (readl(®->grstctl) & RX_FIFO_FLUSH)
520 debug("%s: waiting for S3C_UDC_OTG_GRSTCTL\n", __func__);
522 /* Flush all the Tx FIFO's */
523 writel(TX_FIFO_FLUSH_ALL, ®->grstctl);
524 writel(TX_FIFO_FLUSH_ALL | TX_FIFO_FLUSH, ®->grstctl);
525 while (readl(®->grstctl) & TX_FIFO_FLUSH)
526 debug("%s: waiting for S3C_UDC_OTG_GRSTCTL\n", __func__);
528 /* 13. Clear NAK bit of EP0, EP1, EP2*/
530 /* EP0: Control OUT */
531 writel(DEPCTL_EPDIS | DEPCTL_CNAK,
532 ®->out_endp[EP0_CON].doepctl);
534 /* 14. Initialize OTG Link Core.*/
535 writel(GAHBCFG_INIT, ®->gahbcfg);
538 static void set_max_pktsize(struct s3c_udc *dev, enum usb_device_speed speed)
540 unsigned int ep_ctrl;
543 if (speed == USB_SPEED_HIGH) {
546 ep_fifo_size2 = 1024;
547 dev->gadget.speed = USB_SPEED_HIGH;
552 dev->gadget.speed = USB_SPEED_FULL;
555 dev->ep[0].ep.maxpacket = ep0_fifo_size;
556 for (i = 1; i < S3C_MAX_ENDPOINTS; i++)
557 dev->ep[i].ep.maxpacket = ep_fifo_size;
559 /* EP0 - Control IN (64 bytes)*/
560 ep_ctrl = readl(®->in_endp[EP0_CON].diepctl);
561 writel(ep_ctrl|(0<<0), ®->in_endp[EP0_CON].diepctl);
563 /* EP0 - Control OUT (64 bytes)*/
564 ep_ctrl = readl(®->out_endp[EP0_CON].doepctl);
565 writel(ep_ctrl|(0<<0), ®->out_endp[EP0_CON].doepctl);
568 static int s3c_ep_enable(struct usb_ep *_ep,
569 const struct usb_endpoint_descriptor *desc)
575 debug("%s: %p\n", __func__, _ep);
577 ep = container_of(_ep, struct s3c_ep, ep);
578 if (!_ep || !desc || ep->desc || _ep->name == ep0name
579 || desc->bDescriptorType != USB_DT_ENDPOINT
580 || ep->bEndpointAddress != desc->bEndpointAddress
581 || ep_maxpacket(ep) <
582 le16_to_cpu(get_unaligned(&desc->wMaxPacketSize))) {
584 debug("%s: bad ep or descriptor\n", __func__);
588 /* xfer types must match, except that interrupt ~= bulk */
589 if (ep->bmAttributes != desc->bmAttributes
590 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK
591 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) {
593 debug("%s: %s type mismatch\n", __func__, _ep->name);
597 /* hardware _could_ do smaller, but driver doesn't */
598 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
599 && le16_to_cpu(get_unaligned(&desc->wMaxPacketSize)) !=
600 ep_maxpacket(ep)) || !get_unaligned(&desc->wMaxPacketSize)) {
602 debug("%s: bad %s maxpacket\n", __func__, _ep->name);
607 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) {
609 debug("%s: bogus device state\n", __func__);
616 ep->ep.maxpacket = le16_to_cpu(get_unaligned(&desc->wMaxPacketSize));
618 /* Reset halt state */
620 s3c_udc_set_halt(_ep, 0);
622 spin_lock_irqsave(&ep->dev->lock, flags);
623 s3c_udc_ep_activate(ep);
624 spin_unlock_irqrestore(&ep->dev->lock, flags);
626 debug("%s: enabled %s, stopped = %d, maxpacket = %d\n",
627 __func__, _ep->name, ep->stopped, ep->ep.maxpacket);
634 static int s3c_ep_disable(struct usb_ep *_ep)
639 debug("%s: %p\n", __func__, _ep);
641 ep = container_of(_ep, struct s3c_ep, ep);
642 if (!_ep || !ep->desc) {
643 debug("%s: %s not enabled\n", __func__,
644 _ep ? ep->ep.name : NULL);
648 spin_lock_irqsave(&ep->dev->lock, flags);
650 /* Nuke all pending requests */
651 nuke(ep, -ESHUTDOWN);
656 spin_unlock_irqrestore(&ep->dev->lock, flags);
658 debug("%s: disabled %s\n", __func__, _ep->name);
662 static struct usb_request *s3c_alloc_request(struct usb_ep *ep,
665 struct s3c_request *req;
667 debug("%s: %s %p\n", __func__, ep->name, ep);
669 req = memalign(CONFIG_SYS_CACHELINE_SIZE, sizeof(*req));
673 memset(req, 0, sizeof *req);
674 INIT_LIST_HEAD(&req->queue);
679 static void s3c_free_request(struct usb_ep *ep, struct usb_request *_req)
681 struct s3c_request *req;
683 debug("%s: %p\n", __func__, ep);
685 req = container_of(_req, struct s3c_request, req);
686 WARN_ON(!list_empty(&req->queue));
690 /* dequeue JUST ONE request */
691 static int s3c_dequeue(struct usb_ep *_ep, struct usb_request *_req)
694 struct s3c_request *req;
697 debug("%s: %p\n", __func__, _ep);
699 ep = container_of(_ep, struct s3c_ep, ep);
700 if (!_ep || ep->ep.name == ep0name)
703 spin_lock_irqsave(&ep->dev->lock, flags);
705 /* make sure it's actually queued on this endpoint */
706 list_for_each_entry(req, &ep->queue, queue) {
707 if (&req->req == _req)
710 if (&req->req != _req) {
711 spin_unlock_irqrestore(&ep->dev->lock, flags);
715 done(ep, req, -ECONNRESET);
717 spin_unlock_irqrestore(&ep->dev->lock, flags);
722 * Return bytes in EP FIFO
724 static int s3c_fifo_status(struct usb_ep *_ep)
729 ep = container_of(_ep, struct s3c_ep, ep);
731 debug("%s: bad ep\n", __func__);
735 debug("%s: %d\n", __func__, ep_index(ep));
737 /* LPD can't report unclaimed bytes from IN fifos */
747 static void s3c_fifo_flush(struct usb_ep *_ep)
751 ep = container_of(_ep, struct s3c_ep, ep);
752 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) {
753 debug("%s: bad ep\n", __func__);
757 debug("%s: %d\n", __func__, ep_index(ep));
760 static const struct usb_gadget_ops s3c_udc_ops = {
761 /* current versions must always be self-powered */
764 static struct s3c_udc memory = {
768 .ep0 = &memory.ep[0].ep,
772 /* control endpoint */
777 .maxpacket = EP0_FIFO_SIZE,
781 .bEndpointAddress = 0,
784 .ep_type = ep_control,
787 /* first group of endpoints */
790 .name = "ep1in-bulk",
792 .maxpacket = EP_FIFO_SIZE,
796 .bEndpointAddress = USB_DIR_IN | 1,
797 .bmAttributes = USB_ENDPOINT_XFER_BULK,
799 .ep_type = ep_bulk_out,
805 .name = "ep2out-bulk",
807 .maxpacket = EP_FIFO_SIZE,
811 .bEndpointAddress = USB_DIR_OUT | 2,
812 .bmAttributes = USB_ENDPOINT_XFER_BULK,
814 .ep_type = ep_bulk_in,
822 .maxpacket = EP_FIFO_SIZE,
826 .bEndpointAddress = USB_DIR_IN | 3,
827 .bmAttributes = USB_ENDPOINT_XFER_INT,
829 .ep_type = ep_interrupt,
835 * probe - binds to the platform device
838 int s3c_udc_probe(struct s3c_plat_otg_data *pdata)
840 struct s3c_udc *dev = &memory;
843 debug("%s: %p\n", __func__, pdata);
847 phy = (struct s3c_usbotg_phy *)pdata->regs_phy;
848 reg = (struct s3c_usbotg_reg *)pdata->regs_otg;
849 usb_phy_ctrl = pdata->usb_phy_ctrl;
851 /* regs_otg = (void *)pdata->regs_otg; */
853 dev->gadget.is_dualspeed = 1; /* Hack only*/
854 dev->gadget.is_otg = 0;
855 dev->gadget.is_a_peripheral = 0;
856 dev->gadget.b_hnp_enable = 0;
857 dev->gadget.a_hnp_support = 0;
858 dev->gadget.a_alt_hnp_support = 0;
860 the_controller = dev;
862 for (i = 0; i < S3C_MAX_ENDPOINTS+1; i++) {
863 dev->dma_buf[i] = memalign(CONFIG_SYS_CACHELINE_SIZE,
865 dev->dma_addr[i] = (dma_addr_t) dev->dma_buf[i];
866 invalidate_dcache_range((unsigned long) dev->dma_buf[i],
867 (unsigned long) (dev->dma_buf[i]
870 usb_ctrl = dev->dma_buf[0];
871 usb_ctrl_dma_addr = dev->dma_addr[0];
878 int usb_gadget_handle_interrupts()
880 u32 intr_status = readl(®->gintsts);
881 u32 gintmsk = readl(®->gintmsk);
883 if (intr_status & gintmsk)
884 return s3c_udc_irq(1, (void *)the_controller);