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 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include <asm/errno.h>
36 #include <linux/list.h>
39 #include <linux/usb/ch9.h>
40 #include <linux/usb/gadget.h>
42 #include <asm/byteorder.h>
45 #include <asm/mach-types.h>
46 #include <asm/arch/gpio.h>
49 #include <usb/s3c_udc.h>
50 #include <usb/lin_gadget_compat.h>
52 /***********************************************************/
54 #define OTG_DMA_MODE 1
56 #undef DEBUG_S3C_UDC_SETUP
57 #undef DEBUG_S3C_UDC_EP0
58 #undef DEBUG_S3C_UDC_ISR
59 #undef DEBUG_S3C_UDC_OUT_EP
60 #undef DEBUG_S3C_UDC_IN_EP
63 /* #define DEBUG_S3C_UDC_SETUP */
64 /* #define DEBUG_S3C_UDC_EP0 */
65 /* #define DEBUG_S3C_UDC_ISR */
66 /* #define DEBUG_S3C_UDC_OUT_EP */
67 /* #define DEBUG_S3C_UDC_IN_EP */
68 /* #define DEBUG_S3C_UDC */
70 #include <usb/s3c_udc.h>
75 #if defined(DEBUG_S3C_UDC_SETUP) || defined(DEBUG_S3C_UDC_ISR) \
76 || defined(DEBUG_S3C_UDC_OUT_EP)
77 static char *state_names[] = {
80 "DATA_STATE_NEED_ZLP",
81 "WAIT_FOR_OUT_STATUS",
84 "WAIT_FOR_OUT_COMPLETE",
85 "WAIT_FOR_IN_COMPLETE",
86 "WAIT_FOR_NULL_COMPLETE",
90 #define DRIVER_DESC "S3C HS USB OTG Device Driver, (c) Samsung Electronics"
91 #define DRIVER_VERSION "15 March 2009"
93 struct s3c_udc *the_controller;
95 static const char driver_name[] = "s3c-udc";
96 static const char driver_desc[] = DRIVER_DESC;
97 static const char ep0name[] = "ep0-control";
100 static unsigned int ep0_fifo_size = 64;
101 static unsigned int ep_fifo_size = 512;
102 static unsigned int ep_fifo_size2 = 1024;
103 static int reset_available = 1;
105 static struct usb_ctrlrequest *usb_ctrl;
106 static dma_addr_t usb_ctrl_dma_addr;
111 static int s3c_ep_enable(struct usb_ep *ep,
112 const struct usb_endpoint_descriptor *);
113 static int s3c_ep_disable(struct usb_ep *ep);
114 static struct usb_request *s3c_alloc_request(struct usb_ep *ep,
116 static void s3c_free_request(struct usb_ep *ep, struct usb_request *);
118 static int s3c_queue(struct usb_ep *ep, struct usb_request *, gfp_t gfp_flags);
119 static int s3c_dequeue(struct usb_ep *ep, struct usb_request *);
120 static int s3c_fifo_status(struct usb_ep *ep);
121 static void s3c_fifo_flush(struct usb_ep *ep);
122 static void s3c_ep0_read(struct s3c_udc *dev);
123 static void s3c_ep0_kick(struct s3c_udc *dev, struct s3c_ep *ep);
124 static void s3c_handle_ep0(struct s3c_udc *dev);
125 static int s3c_ep0_write(struct s3c_udc *dev);
126 static int write_fifo_ep0(struct s3c_ep *ep, struct s3c_request *req);
127 static void done(struct s3c_ep *ep, struct s3c_request *req, int status);
128 static void stop_activity(struct s3c_udc *dev,
129 struct usb_gadget_driver *driver);
130 static int udc_enable(struct s3c_udc *dev);
131 static void udc_set_address(struct s3c_udc *dev, unsigned char address);
132 static void reconfig_usbd(void);
133 static void set_max_pktsize(struct s3c_udc *dev, enum usb_device_speed speed);
134 static void nuke(struct s3c_ep *ep, int status);
135 static int s3c_udc_set_halt(struct usb_ep *_ep, int value);
136 static void s3c_udc_set_nak(struct s3c_ep *ep);
138 static struct usb_ep_ops s3c_ep_ops = {
139 .enable = s3c_ep_enable,
140 .disable = s3c_ep_disable,
142 .alloc_request = s3c_alloc_request,
143 .free_request = s3c_free_request,
146 .dequeue = s3c_dequeue,
148 .set_halt = s3c_udc_set_halt,
149 .fifo_status = s3c_fifo_status,
150 .fifo_flush = s3c_fifo_flush,
153 #define create_proc_files() do {} while (0)
154 #define remove_proc_files() do {} while (0)
156 /***********************************************************/
158 void __iomem *regs_otg;
159 struct s3c_usbotg_reg *reg;
160 struct s3c_usbotg_phy *phy;
161 static unsigned int usb_phy_ctrl;
163 void otg_phy_init(struct s3c_udc *dev)
165 dev->pdata->phy_control(1);
168 printf("USB PHY0 Enable\n");
171 writel(readl(usb_phy_ctrl) | USB_PHY_CTRL_EN0, usb_phy_ctrl);
173 if (dev->pdata->usb_flags == PHY0_SLEEP) /* C210 Universal */
174 writel((readl(&phy->phypwr)
175 &~(PHY_0_SLEEP | OTG_DISABLE_0 | ANALOG_PWRDOWN)
176 &~FORCE_SUSPEND_0), &phy->phypwr);
178 writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
179 &~FORCE_SUSPEND_0), &phy->phypwr);
181 writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
182 CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
184 writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
185 | PHY_SW_RST0, &phy->rstcon);
187 writel(readl(&phy->rstcon)
188 &~(PHY_SW_RST0 | LINK_SW_RST | PHYLNK_SW_RST), &phy->rstcon);
192 void otg_phy_off(struct s3c_udc *dev)
194 /* reset controller just in case */
195 writel(PHY_SW_RST0, &phy->rstcon);
197 writel(readl(&phy->phypwr) &~PHY_SW_RST0, &phy->rstcon);
200 writel(readl(&phy->phypwr) | OTG_DISABLE_0 | ANALOG_PWRDOWN
201 | FORCE_SUSPEND_0, &phy->phypwr);
203 writel(readl(usb_phy_ctrl) &~USB_PHY_CTRL_EN0, usb_phy_ctrl);
205 writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)),
210 dev->pdata->phy_control(0);
213 /***********************************************************/
215 #include "s3c_udc_otg_xfer_dma.c"
218 * udc_disable - disable USB device controller
220 static void udc_disable(struct s3c_udc *dev)
222 DEBUG_SETUP("%s: %p\n", __func__, dev);
224 udc_set_address(dev, 0);
226 dev->ep0state = WAIT_FOR_SETUP;
227 dev->gadget.speed = USB_SPEED_UNKNOWN;
228 dev->usb_address = 0;
234 * udc_reinit - initialize software state
236 static void udc_reinit(struct s3c_udc *dev)
240 DEBUG_SETUP("%s: %p\n", __func__, dev);
242 /* device/ep0 records init */
243 INIT_LIST_HEAD(&dev->gadget.ep_list);
244 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
245 dev->ep0state = WAIT_FOR_SETUP;
247 /* basic endpoint records init */
248 for (i = 0; i < S3C_MAX_ENDPOINTS; i++) {
249 struct s3c_ep *ep = &dev->ep[i];
252 list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list);
256 INIT_LIST_HEAD(&ep->queue);
260 /* the rest was statically initialized, and is read-only */
263 #define BYTES2MAXP(x) (x / 8)
264 #define MAXP2BYTES(x) (x * 8)
266 /* until it's enabled, this UDC should be completely invisible
269 static int udc_enable(struct s3c_udc *dev)
271 DEBUG_SETUP("%s: %p\n", __func__, dev);
276 DEBUG_SETUP("S3C USB 2.0 OTG Controller Core Initialized : 0x%x\n",
277 readl(®->gintmsk));
279 dev->gadget.speed = USB_SPEED_UNKNOWN;
285 Register entry point for the peripheral controller driver.
287 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
289 struct s3c_udc *dev = the_controller;
293 DEBUG_SETUP("%s: %s\n", __func__, "no name");
296 || (driver->speed != USB_SPEED_FULL
297 && driver->speed != USB_SPEED_HIGH)
298 || !driver->bind || !driver->disconnect || !driver->setup)
305 spin_lock_irqsave(&dev->lock, flags);
306 /* first hook up the driver ... */
307 dev->driver = driver;
308 spin_unlock_irqrestore(&dev->lock, flags);
310 if (retval) { /* TODO */
311 printf("target device_add failed, error %d\n", retval);
315 retval = driver->bind(&dev->gadget);
317 DEBUG_SETUP("%s: bind to driver --> error %d\n",
318 dev->gadget.name, retval);
325 DEBUG_SETUP("Registered gadget driver %s\n", dev->gadget.name);
332 * Unregister entry point for the peripheral controller driver.
334 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
336 struct s3c_udc *dev = the_controller;
341 if (!driver || driver != dev->driver)
344 spin_lock_irqsave(&dev->lock, flags);
346 stop_activity(dev, driver);
347 spin_unlock_irqrestore(&dev->lock, flags);
349 driver->unbind(&dev->gadget);
351 disable_irq(IRQ_OTG);
358 * done - retire a request; caller blocked irqs
360 static void done(struct s3c_ep *ep, struct s3c_request *req, int status)
362 unsigned int stopped = ep->stopped;
364 DEBUG("%s: %s %p, req = %p, stopped = %d\n",
365 __func__, ep->ep.name, ep, &req->req, stopped);
367 list_del_init(&req->queue);
369 if (likely(req->req.status == -EINPROGRESS))
370 req->req.status = status;
372 status = req->req.status;
374 if (status && status != -ESHUTDOWN) {
375 DEBUG("complete %s req %p stat %d len %u/%u\n",
376 ep->ep.name, &req->req, status,
377 req->req.actual, req->req.length);
380 /* don't modify queue heads during completion callback */
384 printf("calling complete callback\n");
386 int i, len = req->req.length;
388 printf("pkt[%d] = ", req->req.length);
391 for (i = 0; i < len; i++) {
392 printf("%02x", ((u8 *)req->req.buf)[i]);
399 spin_unlock(&ep->dev->lock);
400 req->req.complete(&ep->ep, &req->req);
401 spin_lock(&ep->dev->lock);
403 DEBUG("callback completed\n");
405 ep->stopped = stopped;
409 * nuke - dequeue ALL requests
411 static void nuke(struct s3c_ep *ep, int status)
413 struct s3c_request *req;
415 DEBUG("%s: %s %p\n", __func__, ep->ep.name, ep);
417 /* called with irqs blocked */
418 while (!list_empty(&ep->queue)) {
419 req = list_entry(ep->queue.next, struct s3c_request, queue);
420 done(ep, req, status);
424 static void stop_activity(struct s3c_udc *dev,
425 struct usb_gadget_driver *driver)
429 /* don't disconnect drivers more than once */
430 if (dev->gadget.speed == USB_SPEED_UNKNOWN)
432 dev->gadget.speed = USB_SPEED_UNKNOWN;
434 /* prevent new request submissions, kill any outstanding requests */
435 for (i = 0; i < S3C_MAX_ENDPOINTS; i++) {
436 struct s3c_ep *ep = &dev->ep[i];
438 nuke(ep, -ESHUTDOWN);
441 /* report disconnect; the driver is already quiesced */
443 spin_unlock(&dev->lock);
444 driver->disconnect(&dev->gadget);
445 spin_lock(&dev->lock);
448 /* re-init driver-visible data structures */
452 static void reconfig_usbd(void)
454 /* 2. Soft-reset OTG Core and then unreset again. */
456 unsigned int uTemp = writel(CORE_SOFT_RESET, ®->grstctl);
458 DEBUG(2, "Reseting OTG controller\n");
460 writel(0<<15 /* PHY Low Power Clock sel*/
461 |1<<14 /* Non-Periodic TxFIFO Rewind Enable*/
462 |0x5<<10 /* Turnaround time*/
463 |0<<9 | 0<<8 /* [0:HNP disable,1:HNP enable][ 0:SRP disable*/
464 /* 1:SRP enable] H1= 1,1*/
465 |0<<7 /* Ulpi DDR sel*/
466 |0<<6 /* 0: high speed utmi+, 1: full speed serial*/
467 |0<<4 /* 0: utmi+, 1:ulpi*/
468 |1<<3 /* phy i/f 0:8bit, 1:16bit*/
469 |0x7<<0, /* HS/FS Timeout**/
472 /* 3. Put the OTG device core in the disconnected state.*/
473 uTemp = readl(®->dctl);
474 uTemp |= SOFT_DISCONNECT;
475 writel(uTemp, ®->dctl);
479 /* 4. Make the OTG device core exit from the disconnected state.*/
480 uTemp = readl(®->dctl);
481 uTemp = uTemp & ~SOFT_DISCONNECT;
482 writel(uTemp, ®->dctl);
484 /* 5. Configure OTG Core to initial settings of device mode.*/
485 /* [][1: full speed(30Mhz) 0:high speed]*/
486 writel(EP_MISS_CNT(1) | DEV_SPEED_HIGH_SPEED_20, ®->dcfg);
490 /* 6. Unmask the core interrupts*/
491 writel(GINTMSK_INIT, ®->gintmsk);
493 /* 7. Set NAK bit of EP0, EP1, EP2*/
494 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->out_endp[EP0_CON].doepctl);
495 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->in_endp[EP0_CON].diepctl);
497 for (i = 1; i < S3C_MAX_ENDPOINTS; i++) {
498 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->out_endp[i].doepctl);
499 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->in_endp[i].diepctl);
502 /* 8. Unmask EPO interrupts*/
503 writel(((1 << EP0_CON) << DAINT_OUT_BIT)
504 | (1 << EP0_CON), ®->daintmsk);
506 /* 9. Unmask device OUT EP common interrupts*/
507 writel(DOEPMSK_INIT, ®->doepmsk);
509 /* 10. Unmask device IN EP common interrupts*/
510 writel(DIEPMSK_INIT, ®->diepmsk);
512 /* 11. Set Rx FIFO Size (in 32-bit words) */
513 writel(RX_FIFO_SIZE >> 2, ®->grxfsiz);
515 /* 12. Set Non Periodic Tx FIFO Size */
516 writel((NPTX_FIFO_SIZE >> 2) << 16 | ((RX_FIFO_SIZE >> 2)) << 0,
519 for (i = 1; i < S3C_MAX_HW_ENDPOINTS; i++)
520 writel((PTX_FIFO_SIZE >> 2) << 16 |
521 ((RX_FIFO_SIZE + NPTX_FIFO_SIZE +
522 PTX_FIFO_SIZE*(i-1)) >> 2) << 0,
525 /* Flush the RX FIFO */
526 writel(RX_FIFO_FLUSH, ®->grstctl);
527 while (readl(®->grstctl) & RX_FIFO_FLUSH)
528 DEBUG("%s: waiting for S3C_UDC_OTG_GRSTCTL\n", __func__);
530 /* Flush all the Tx FIFO's */
531 writel(TX_FIFO_FLUSH_ALL, ®->grstctl);
532 writel(TX_FIFO_FLUSH_ALL | TX_FIFO_FLUSH, ®->grstctl);
533 while (readl(®->grstctl) & TX_FIFO_FLUSH)
534 DEBUG("%s: waiting for S3C_UDC_OTG_GRSTCTL\n", __func__);
536 /* 13. Clear NAK bit of EP0, EP1, EP2*/
538 /* EP0: Control OUT */
539 writel(DEPCTL_EPDIS | DEPCTL_CNAK,
540 ®->out_endp[EP0_CON].doepctl);
542 /* 14. Initialize OTG Link Core.*/
543 writel(GAHBCFG_INIT, ®->gahbcfg);
546 static void set_max_pktsize(struct s3c_udc *dev, enum usb_device_speed speed)
548 unsigned int ep_ctrl;
551 if (speed == USB_SPEED_HIGH) {
554 ep_fifo_size2 = 1024;
555 dev->gadget.speed = USB_SPEED_HIGH;
560 dev->gadget.speed = USB_SPEED_FULL;
563 dev->ep[0].ep.maxpacket = ep0_fifo_size;
564 for (i = 1; i < S3C_MAX_ENDPOINTS; i++)
565 dev->ep[i].ep.maxpacket = ep_fifo_size;
567 /* EP0 - Control IN (64 bytes)*/
568 ep_ctrl = readl(®->in_endp[EP0_CON].diepctl);
569 writel(ep_ctrl|(0<<0), ®->in_endp[EP0_CON].diepctl);
571 /* EP0 - Control OUT (64 bytes)*/
572 ep_ctrl = readl(®->out_endp[EP0_CON].doepctl);
573 writel(ep_ctrl|(0<<0), ®->out_endp[EP0_CON].doepctl);
576 static int s3c_ep_enable(struct usb_ep *_ep,
577 const struct usb_endpoint_descriptor *desc)
583 DEBUG("%s: %p\n", __func__, _ep);
585 ep = container_of(_ep, struct s3c_ep, ep);
586 if (!_ep || !desc || ep->desc || _ep->name == ep0name
587 || desc->bDescriptorType != USB_DT_ENDPOINT
588 || ep->bEndpointAddress != desc->bEndpointAddress
589 || ep_maxpacket(ep) < le16_to_cpu(desc->wMaxPacketSize)) {
591 DEBUG("%s: bad ep or descriptor\n", __func__);
595 /* xfer types must match, except that interrupt ~= bulk */
596 if (ep->bmAttributes != desc->bmAttributes
597 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK
598 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) {
600 DEBUG("%s: %s type mismatch\n", __func__, _ep->name);
604 /* hardware _could_ do smaller, but driver doesn't */
605 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
606 && le16_to_cpu(desc->wMaxPacketSize) != ep_maxpacket(ep))
607 || !desc->wMaxPacketSize) {
609 DEBUG("%s: bad %s maxpacket\n", __func__, _ep->name);
614 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) {
616 DEBUG("%s: bogus device state\n", __func__);
623 ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
625 /* Reset halt state */
627 s3c_udc_set_halt(_ep, 0);
629 spin_lock_irqsave(&ep->dev->lock, flags);
630 s3c_udc_ep_activate(ep);
631 spin_unlock_irqrestore(&ep->dev->lock, flags);
633 DEBUG("%s: enabled %s, stopped = %d, maxpacket = %d\n",
634 __func__, _ep->name, ep->stopped, ep->ep.maxpacket);
641 static int s3c_ep_disable(struct usb_ep *_ep)
646 DEBUG("%s: %p\n", __func__, _ep);
648 ep = container_of(_ep, struct s3c_ep, ep);
649 if (!_ep || !ep->desc) {
650 DEBUG("%s: %s not enabled\n", __func__,
651 _ep ? ep->ep.name : NULL);
655 spin_lock_irqsave(&ep->dev->lock, flags);
657 /* Nuke all pending requests */
658 nuke(ep, -ESHUTDOWN);
663 spin_unlock_irqrestore(&ep->dev->lock, flags);
665 DEBUG("%s: disabled %s\n", __func__, _ep->name);
669 static struct usb_request *s3c_alloc_request(struct usb_ep *ep,
672 struct s3c_request *req;
674 DEBUG("%s: %s %p\n", __func__, ep->name, ep);
676 req = kmalloc(sizeof *req, gfp_flags);
680 memset(req, 0, sizeof *req);
681 INIT_LIST_HEAD(&req->queue);
686 static void s3c_free_request(struct usb_ep *ep, struct usb_request *_req)
688 struct s3c_request *req;
690 DEBUG("%s: %p\n", __func__, ep);
692 req = container_of(_req, struct s3c_request, req);
693 WARN_ON(!list_empty(&req->queue));
697 /* dequeue JUST ONE request */
698 static int s3c_dequeue(struct usb_ep *_ep, struct usb_request *_req)
701 struct s3c_request *req;
704 DEBUG("%s: %p\n", __func__, _ep);
706 ep = container_of(_ep, struct s3c_ep, ep);
707 if (!_ep || ep->ep.name == ep0name)
710 spin_lock_irqsave(&ep->dev->lock, flags);
712 /* make sure it's actually queued on this endpoint */
713 list_for_each_entry(req, &ep->queue, queue) {
714 if (&req->req == _req)
717 if (&req->req != _req) {
718 spin_unlock_irqrestore(&ep->dev->lock, flags);
722 done(ep, req, -ECONNRESET);
724 spin_unlock_irqrestore(&ep->dev->lock, flags);
729 * Return bytes in EP FIFO
731 static int s3c_fifo_status(struct usb_ep *_ep)
736 ep = container_of(_ep, struct s3c_ep, ep);
738 DEBUG("%s: bad ep\n", __func__);
742 DEBUG("%s: %d\n", __func__, ep_index(ep));
744 /* LPD can't report unclaimed bytes from IN fifos */
754 static void s3c_fifo_flush(struct usb_ep *_ep)
758 ep = container_of(_ep, struct s3c_ep, ep);
759 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) {
760 DEBUG("%s: bad ep\n", __func__);
764 DEBUG("%s: %d\n", __func__, ep_index(ep));
767 static const struct usb_gadget_ops s3c_udc_ops = {
768 /* current versions must always be self-powered */
771 static struct s3c_udc memory = {
775 .ep0 = &memory.ep[0].ep,
779 /* control endpoint */
784 .maxpacket = EP0_FIFO_SIZE,
788 .bEndpointAddress = 0,
791 .ep_type = ep_control,
794 /* first group of endpoints */
797 .name = "ep1in-bulk",
799 .maxpacket = EP_FIFO_SIZE,
803 .bEndpointAddress = USB_DIR_IN | 1,
804 .bmAttributes = USB_ENDPOINT_XFER_BULK,
806 .ep_type = ep_bulk_out,
812 .name = "ep2out-bulk",
814 .maxpacket = EP_FIFO_SIZE,
818 .bEndpointAddress = USB_DIR_OUT | 2,
819 .bmAttributes = USB_ENDPOINT_XFER_BULK,
821 .ep_type = ep_bulk_in,
829 .maxpacket = EP_FIFO_SIZE,
833 .bEndpointAddress = USB_DIR_IN | 3,
834 .bmAttributes = USB_ENDPOINT_XFER_INT,
836 .ep_type = ep_interrupt,
842 * probe - binds to the platform device
845 int s3c_udc_probe(struct s3c_plat_otg_data *pdata)
847 struct s3c_udc *dev = &memory;
850 DEBUG("%s: %p\n", __func__, pdata);
854 phy = (struct s3c_usbotg_phy *)pdata->regs_phy;
855 reg = (struct s3c_usbotg_reg *)pdata->regs_otg;
856 usb_phy_ctrl = pdata->usb_phy_ctrl;
858 /* regs_otg = (void *)pdata->regs_otg; */
860 dev->gadget.is_dualspeed = 1; /* Hack only*/
861 dev->gadget.is_otg = 0;
862 dev->gadget.is_a_peripheral = 0;
863 dev->gadget.b_hnp_enable = 0;
864 dev->gadget.a_hnp_support = 0;
865 dev->gadget.a_alt_hnp_support = 0;
867 the_controller = dev;
869 for (i = 0; i < S3C_MAX_ENDPOINTS+1; i++) {
870 dev->dma_buf[i] = kmalloc(DMA_BUFFER_SIZE, GFP_KERNEL);
871 dev->dma_addr[i] = (dma_addr_t) dev->dma_buf[i];
872 invalidate_dcache_range((unsigned long) dev->dma_buf[i],
873 (unsigned long) (dev->dma_buf[i]
876 usb_ctrl = dev->dma_buf[0];
877 usb_ctrl_dma_addr = dev->dma_addr[0];
884 int usb_gadget_handle_interrupts()
886 u32 intr_status = readl(®->gintsts);
887 u32 gintmsk = readl(®->gintmsk);
889 if (intr_status & gintmsk)
890 return s3c_udc_irq(1, (void *)the_controller);