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>
43 #include <asm/unaligned.h>
46 #include <asm/mach-types.h>
47 #include <asm/arch/gpio.h>
50 #include <usb/s3c_udc.h>
51 #include <usb/lin_gadget_compat.h>
53 /***********************************************************/
55 #define OTG_DMA_MODE 1
57 #undef DEBUG_S3C_UDC_SETUP
58 #undef DEBUG_S3C_UDC_EP0
59 #undef DEBUG_S3C_UDC_ISR
60 #undef DEBUG_S3C_UDC_OUT_EP
61 #undef DEBUG_S3C_UDC_IN_EP
64 /* #define DEBUG_S3C_UDC_SETUP */
65 /* #define DEBUG_S3C_UDC_EP0 */
66 /* #define DEBUG_S3C_UDC_ISR */
67 /* #define DEBUG_S3C_UDC_OUT_EP */
68 /* #define DEBUG_S3C_UDC_IN_EP */
69 /* #define DEBUG_S3C_UDC */
71 #include <usb/s3c_udc.h>
76 #if defined(DEBUG_S3C_UDC_SETUP) || defined(DEBUG_S3C_UDC_ISR) \
77 || defined(DEBUG_S3C_UDC_OUT_EP)
78 static char *state_names[] = {
81 "DATA_STATE_NEED_ZLP",
82 "WAIT_FOR_OUT_STATUS",
85 "WAIT_FOR_OUT_COMPLETE",
86 "WAIT_FOR_IN_COMPLETE",
87 "WAIT_FOR_NULL_COMPLETE",
91 #define DRIVER_DESC "S3C HS USB OTG Device Driver, (c) Samsung Electronics"
92 #define DRIVER_VERSION "15 March 2009"
94 struct s3c_udc *the_controller;
96 static const char driver_name[] = "s3c-udc";
97 static const char driver_desc[] = DRIVER_DESC;
98 static const char ep0name[] = "ep0-control";
101 static unsigned int ep0_fifo_size = 64;
102 static unsigned int ep_fifo_size = 512;
103 static unsigned int ep_fifo_size2 = 1024;
104 static int reset_available = 1;
106 static struct usb_ctrlrequest *usb_ctrl;
107 static dma_addr_t usb_ctrl_dma_addr;
112 static int s3c_ep_enable(struct usb_ep *ep,
113 const struct usb_endpoint_descriptor *);
114 static int s3c_ep_disable(struct usb_ep *ep);
115 static struct usb_request *s3c_alloc_request(struct usb_ep *ep,
117 static void s3c_free_request(struct usb_ep *ep, struct usb_request *);
119 static int s3c_queue(struct usb_ep *ep, struct usb_request *, gfp_t gfp_flags);
120 static int s3c_dequeue(struct usb_ep *ep, struct usb_request *);
121 static int s3c_fifo_status(struct usb_ep *ep);
122 static void s3c_fifo_flush(struct usb_ep *ep);
123 static void s3c_ep0_read(struct s3c_udc *dev);
124 static void s3c_ep0_kick(struct s3c_udc *dev, struct s3c_ep *ep);
125 static void s3c_handle_ep0(struct s3c_udc *dev);
126 static int s3c_ep0_write(struct s3c_udc *dev);
127 static int write_fifo_ep0(struct s3c_ep *ep, struct s3c_request *req);
128 static void done(struct s3c_ep *ep, struct s3c_request *req, int status);
129 static void stop_activity(struct s3c_udc *dev,
130 struct usb_gadget_driver *driver);
131 static int udc_enable(struct s3c_udc *dev);
132 static void udc_set_address(struct s3c_udc *dev, unsigned char address);
133 static void reconfig_usbd(void);
134 static void set_max_pktsize(struct s3c_udc *dev, enum usb_device_speed speed);
135 static void nuke(struct s3c_ep *ep, int status);
136 static int s3c_udc_set_halt(struct usb_ep *_ep, int value);
137 static void s3c_udc_set_nak(struct s3c_ep *ep);
139 static struct usb_ep_ops s3c_ep_ops = {
140 .enable = s3c_ep_enable,
141 .disable = s3c_ep_disable,
143 .alloc_request = s3c_alloc_request,
144 .free_request = s3c_free_request,
147 .dequeue = s3c_dequeue,
149 .set_halt = s3c_udc_set_halt,
150 .fifo_status = s3c_fifo_status,
151 .fifo_flush = s3c_fifo_flush,
154 #define create_proc_files() do {} while (0)
155 #define remove_proc_files() do {} while (0)
157 /***********************************************************/
159 void __iomem *regs_otg;
160 struct s3c_usbotg_reg *reg;
161 struct s3c_usbotg_phy *phy;
162 static unsigned int usb_phy_ctrl;
164 void otg_phy_init(struct s3c_udc *dev)
166 dev->pdata->phy_control(1);
169 printf("USB PHY0 Enable\n");
172 writel(readl(usb_phy_ctrl) | USB_PHY_CTRL_EN0, usb_phy_ctrl);
174 if (dev->pdata->usb_flags == PHY0_SLEEP) /* C210 Universal */
175 writel((readl(&phy->phypwr)
176 &~(PHY_0_SLEEP | OTG_DISABLE_0 | ANALOG_PWRDOWN)
177 &~FORCE_SUSPEND_0), &phy->phypwr);
179 writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
180 &~FORCE_SUSPEND_0), &phy->phypwr);
182 writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
183 CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
185 writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
186 | PHY_SW_RST0, &phy->rstcon);
188 writel(readl(&phy->rstcon)
189 &~(PHY_SW_RST0 | LINK_SW_RST | PHYLNK_SW_RST), &phy->rstcon);
193 void otg_phy_off(struct s3c_udc *dev)
195 /* reset controller just in case */
196 writel(PHY_SW_RST0, &phy->rstcon);
198 writel(readl(&phy->phypwr) &~PHY_SW_RST0, &phy->rstcon);
201 writel(readl(&phy->phypwr) | OTG_DISABLE_0 | ANALOG_PWRDOWN
202 | FORCE_SUSPEND_0, &phy->phypwr);
204 writel(readl(usb_phy_ctrl) &~USB_PHY_CTRL_EN0, usb_phy_ctrl);
206 writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)),
211 dev->pdata->phy_control(0);
214 /***********************************************************/
216 #include "s3c_udc_otg_xfer_dma.c"
219 * udc_disable - disable USB device controller
221 static void udc_disable(struct s3c_udc *dev)
223 DEBUG_SETUP("%s: %p\n", __func__, dev);
225 udc_set_address(dev, 0);
227 dev->ep0state = WAIT_FOR_SETUP;
228 dev->gadget.speed = USB_SPEED_UNKNOWN;
229 dev->usb_address = 0;
235 * udc_reinit - initialize software state
237 static void udc_reinit(struct s3c_udc *dev)
241 DEBUG_SETUP("%s: %p\n", __func__, dev);
243 /* device/ep0 records init */
244 INIT_LIST_HEAD(&dev->gadget.ep_list);
245 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
246 dev->ep0state = WAIT_FOR_SETUP;
248 /* basic endpoint records init */
249 for (i = 0; i < S3C_MAX_ENDPOINTS; i++) {
250 struct s3c_ep *ep = &dev->ep[i];
253 list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list);
257 INIT_LIST_HEAD(&ep->queue);
261 /* the rest was statically initialized, and is read-only */
264 #define BYTES2MAXP(x) (x / 8)
265 #define MAXP2BYTES(x) (x * 8)
267 /* until it's enabled, this UDC should be completely invisible
270 static int udc_enable(struct s3c_udc *dev)
272 DEBUG_SETUP("%s: %p\n", __func__, dev);
277 DEBUG_SETUP("S3C USB 2.0 OTG Controller Core Initialized : 0x%x\n",
278 readl(®->gintmsk));
280 dev->gadget.speed = USB_SPEED_UNKNOWN;
286 Register entry point for the peripheral controller driver.
288 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
290 struct s3c_udc *dev = the_controller;
294 DEBUG_SETUP("%s: %s\n", __func__, "no name");
297 || (driver->speed != USB_SPEED_FULL
298 && driver->speed != USB_SPEED_HIGH)
299 || !driver->bind || !driver->disconnect || !driver->setup)
306 spin_lock_irqsave(&dev->lock, flags);
307 /* first hook up the driver ... */
308 dev->driver = driver;
309 spin_unlock_irqrestore(&dev->lock, flags);
311 if (retval) { /* TODO */
312 printf("target device_add failed, error %d\n", retval);
316 retval = driver->bind(&dev->gadget);
318 DEBUG_SETUP("%s: bind to driver --> error %d\n",
319 dev->gadget.name, retval);
326 DEBUG_SETUP("Registered gadget driver %s\n", dev->gadget.name);
333 * Unregister entry point for the peripheral controller driver.
335 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
337 struct s3c_udc *dev = the_controller;
342 if (!driver || driver != dev->driver)
345 spin_lock_irqsave(&dev->lock, flags);
347 stop_activity(dev, driver);
348 spin_unlock_irqrestore(&dev->lock, flags);
350 driver->unbind(&dev->gadget);
352 disable_irq(IRQ_OTG);
359 * done - retire a request; caller blocked irqs
361 static void done(struct s3c_ep *ep, struct s3c_request *req, int status)
363 unsigned int stopped = ep->stopped;
365 DEBUG("%s: %s %p, req = %p, stopped = %d\n",
366 __func__, ep->ep.name, ep, &req->req, stopped);
368 list_del_init(&req->queue);
370 if (likely(req->req.status == -EINPROGRESS))
371 req->req.status = status;
373 status = req->req.status;
375 if (status && status != -ESHUTDOWN) {
376 DEBUG("complete %s req %p stat %d len %u/%u\n",
377 ep->ep.name, &req->req, status,
378 req->req.actual, req->req.length);
381 /* don't modify queue heads during completion callback */
385 printf("calling complete callback\n");
387 int i, len = req->req.length;
389 printf("pkt[%d] = ", req->req.length);
392 for (i = 0; i < len; i++) {
393 printf("%02x", ((u8 *)req->req.buf)[i]);
400 spin_unlock(&ep->dev->lock);
401 req->req.complete(&ep->ep, &req->req);
402 spin_lock(&ep->dev->lock);
404 DEBUG("callback completed\n");
406 ep->stopped = stopped;
410 * nuke - dequeue ALL requests
412 static void nuke(struct s3c_ep *ep, int status)
414 struct s3c_request *req;
416 DEBUG("%s: %s %p\n", __func__, ep->ep.name, ep);
418 /* called with irqs blocked */
419 while (!list_empty(&ep->queue)) {
420 req = list_entry(ep->queue.next, struct s3c_request, queue);
421 done(ep, req, status);
425 static void stop_activity(struct s3c_udc *dev,
426 struct usb_gadget_driver *driver)
430 /* don't disconnect drivers more than once */
431 if (dev->gadget.speed == USB_SPEED_UNKNOWN)
433 dev->gadget.speed = USB_SPEED_UNKNOWN;
435 /* prevent new request submissions, kill any outstanding requests */
436 for (i = 0; i < S3C_MAX_ENDPOINTS; i++) {
437 struct s3c_ep *ep = &dev->ep[i];
439 nuke(ep, -ESHUTDOWN);
442 /* report disconnect; the driver is already quiesced */
444 spin_unlock(&dev->lock);
445 driver->disconnect(&dev->gadget);
446 spin_lock(&dev->lock);
449 /* re-init driver-visible data structures */
453 static void reconfig_usbd(void)
455 /* 2. Soft-reset OTG Core and then unreset again. */
457 unsigned int uTemp = writel(CORE_SOFT_RESET, ®->grstctl);
459 DEBUG(2, "Reseting OTG controller\n");
461 writel(0<<15 /* PHY Low Power Clock sel*/
462 |1<<14 /* Non-Periodic TxFIFO Rewind Enable*/
463 |0x5<<10 /* Turnaround time*/
464 |0<<9 | 0<<8 /* [0:HNP disable,1:HNP enable][ 0:SRP disable*/
465 /* 1:SRP enable] H1= 1,1*/
466 |0<<7 /* Ulpi DDR sel*/
467 |0<<6 /* 0: high speed utmi+, 1: full speed serial*/
468 |0<<4 /* 0: utmi+, 1:ulpi*/
469 |1<<3 /* phy i/f 0:8bit, 1:16bit*/
470 |0x7<<0, /* HS/FS Timeout**/
473 /* 3. Put the OTG device core in the disconnected state.*/
474 uTemp = readl(®->dctl);
475 uTemp |= SOFT_DISCONNECT;
476 writel(uTemp, ®->dctl);
480 /* 4. Make the OTG device core exit from the disconnected state.*/
481 uTemp = readl(®->dctl);
482 uTemp = uTemp & ~SOFT_DISCONNECT;
483 writel(uTemp, ®->dctl);
485 /* 5. Configure OTG Core to initial settings of device mode.*/
486 /* [][1: full speed(30Mhz) 0:high speed]*/
487 writel(EP_MISS_CNT(1) | DEV_SPEED_HIGH_SPEED_20, ®->dcfg);
491 /* 6. Unmask the core interrupts*/
492 writel(GINTMSK_INIT, ®->gintmsk);
494 /* 7. Set NAK bit of EP0, EP1, EP2*/
495 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->out_endp[EP0_CON].doepctl);
496 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->in_endp[EP0_CON].diepctl);
498 for (i = 1; i < S3C_MAX_ENDPOINTS; i++) {
499 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->out_endp[i].doepctl);
500 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->in_endp[i].diepctl);
503 /* 8. Unmask EPO interrupts*/
504 writel(((1 << EP0_CON) << DAINT_OUT_BIT)
505 | (1 << EP0_CON), ®->daintmsk);
507 /* 9. Unmask device OUT EP common interrupts*/
508 writel(DOEPMSK_INIT, ®->doepmsk);
510 /* 10. Unmask device IN EP common interrupts*/
511 writel(DIEPMSK_INIT, ®->diepmsk);
513 /* 11. Set Rx FIFO Size (in 32-bit words) */
514 writel(RX_FIFO_SIZE >> 2, ®->grxfsiz);
516 /* 12. Set Non Periodic Tx FIFO Size */
517 writel((NPTX_FIFO_SIZE >> 2) << 16 | ((RX_FIFO_SIZE >> 2)) << 0,
520 for (i = 1; i < S3C_MAX_HW_ENDPOINTS; i++)
521 writel((PTX_FIFO_SIZE >> 2) << 16 |
522 ((RX_FIFO_SIZE + NPTX_FIFO_SIZE +
523 PTX_FIFO_SIZE*(i-1)) >> 2) << 0,
526 /* Flush the RX FIFO */
527 writel(RX_FIFO_FLUSH, ®->grstctl);
528 while (readl(®->grstctl) & RX_FIFO_FLUSH)
529 DEBUG("%s: waiting for S3C_UDC_OTG_GRSTCTL\n", __func__);
531 /* Flush all the Tx FIFO's */
532 writel(TX_FIFO_FLUSH_ALL, ®->grstctl);
533 writel(TX_FIFO_FLUSH_ALL | TX_FIFO_FLUSH, ®->grstctl);
534 while (readl(®->grstctl) & TX_FIFO_FLUSH)
535 DEBUG("%s: waiting for S3C_UDC_OTG_GRSTCTL\n", __func__);
537 /* 13. Clear NAK bit of EP0, EP1, EP2*/
539 /* EP0: Control OUT */
540 writel(DEPCTL_EPDIS | DEPCTL_CNAK,
541 ®->out_endp[EP0_CON].doepctl);
543 /* 14. Initialize OTG Link Core.*/
544 writel(GAHBCFG_INIT, ®->gahbcfg);
547 static void set_max_pktsize(struct s3c_udc *dev, enum usb_device_speed speed)
549 unsigned int ep_ctrl;
552 if (speed == USB_SPEED_HIGH) {
555 ep_fifo_size2 = 1024;
556 dev->gadget.speed = USB_SPEED_HIGH;
561 dev->gadget.speed = USB_SPEED_FULL;
564 dev->ep[0].ep.maxpacket = ep0_fifo_size;
565 for (i = 1; i < S3C_MAX_ENDPOINTS; i++)
566 dev->ep[i].ep.maxpacket = ep_fifo_size;
568 /* EP0 - Control IN (64 bytes)*/
569 ep_ctrl = readl(®->in_endp[EP0_CON].diepctl);
570 writel(ep_ctrl|(0<<0), ®->in_endp[EP0_CON].diepctl);
572 /* EP0 - Control OUT (64 bytes)*/
573 ep_ctrl = readl(®->out_endp[EP0_CON].doepctl);
574 writel(ep_ctrl|(0<<0), ®->out_endp[EP0_CON].doepctl);
577 static int s3c_ep_enable(struct usb_ep *_ep,
578 const struct usb_endpoint_descriptor *desc)
584 DEBUG("%s: %p\n", __func__, _ep);
586 ep = container_of(_ep, struct s3c_ep, ep);
587 if (!_ep || !desc || ep->desc || _ep->name == ep0name
588 || desc->bDescriptorType != USB_DT_ENDPOINT
589 || ep->bEndpointAddress != desc->bEndpointAddress
590 || ep_maxpacket(ep) <
591 le16_to_cpu(get_unaligned(&desc->wMaxPacketSize))) {
593 DEBUG("%s: bad ep or descriptor\n", __func__);
597 /* xfer types must match, except that interrupt ~= bulk */
598 if (ep->bmAttributes != desc->bmAttributes
599 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK
600 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) {
602 DEBUG("%s: %s type mismatch\n", __func__, _ep->name);
606 /* hardware _could_ do smaller, but driver doesn't */
607 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
608 && le16_to_cpu(get_unaligned(&desc->wMaxPacketSize)) !=
609 ep_maxpacket(ep)) || !get_unaligned(&desc->wMaxPacketSize)) {
611 DEBUG("%s: bad %s maxpacket\n", __func__, _ep->name);
616 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) {
618 DEBUG("%s: bogus device state\n", __func__);
625 ep->ep.maxpacket = le16_to_cpu(get_unaligned(&desc->wMaxPacketSize));
627 /* Reset halt state */
629 s3c_udc_set_halt(_ep, 0);
631 spin_lock_irqsave(&ep->dev->lock, flags);
632 s3c_udc_ep_activate(ep);
633 spin_unlock_irqrestore(&ep->dev->lock, flags);
635 DEBUG("%s: enabled %s, stopped = %d, maxpacket = %d\n",
636 __func__, _ep->name, ep->stopped, ep->ep.maxpacket);
643 static int s3c_ep_disable(struct usb_ep *_ep)
648 DEBUG("%s: %p\n", __func__, _ep);
650 ep = container_of(_ep, struct s3c_ep, ep);
651 if (!_ep || !ep->desc) {
652 DEBUG("%s: %s not enabled\n", __func__,
653 _ep ? ep->ep.name : NULL);
657 spin_lock_irqsave(&ep->dev->lock, flags);
659 /* Nuke all pending requests */
660 nuke(ep, -ESHUTDOWN);
665 spin_unlock_irqrestore(&ep->dev->lock, flags);
667 DEBUG("%s: disabled %s\n", __func__, _ep->name);
671 static struct usb_request *s3c_alloc_request(struct usb_ep *ep,
674 struct s3c_request *req;
676 DEBUG("%s: %s %p\n", __func__, ep->name, ep);
678 req = kmalloc(sizeof *req, gfp_flags);
682 memset(req, 0, sizeof *req);
683 INIT_LIST_HEAD(&req->queue);
688 static void s3c_free_request(struct usb_ep *ep, struct usb_request *_req)
690 struct s3c_request *req;
692 DEBUG("%s: %p\n", __func__, ep);
694 req = container_of(_req, struct s3c_request, req);
695 WARN_ON(!list_empty(&req->queue));
699 /* dequeue JUST ONE request */
700 static int s3c_dequeue(struct usb_ep *_ep, struct usb_request *_req)
703 struct s3c_request *req;
706 DEBUG("%s: %p\n", __func__, _ep);
708 ep = container_of(_ep, struct s3c_ep, ep);
709 if (!_ep || ep->ep.name == ep0name)
712 spin_lock_irqsave(&ep->dev->lock, flags);
714 /* make sure it's actually queued on this endpoint */
715 list_for_each_entry(req, &ep->queue, queue) {
716 if (&req->req == _req)
719 if (&req->req != _req) {
720 spin_unlock_irqrestore(&ep->dev->lock, flags);
724 done(ep, req, -ECONNRESET);
726 spin_unlock_irqrestore(&ep->dev->lock, flags);
731 * Return bytes in EP FIFO
733 static int s3c_fifo_status(struct usb_ep *_ep)
738 ep = container_of(_ep, struct s3c_ep, ep);
740 DEBUG("%s: bad ep\n", __func__);
744 DEBUG("%s: %d\n", __func__, ep_index(ep));
746 /* LPD can't report unclaimed bytes from IN fifos */
756 static void s3c_fifo_flush(struct usb_ep *_ep)
760 ep = container_of(_ep, struct s3c_ep, ep);
761 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) {
762 DEBUG("%s: bad ep\n", __func__);
766 DEBUG("%s: %d\n", __func__, ep_index(ep));
769 static const struct usb_gadget_ops s3c_udc_ops = {
770 /* current versions must always be self-powered */
773 static struct s3c_udc memory = {
777 .ep0 = &memory.ep[0].ep,
781 /* control endpoint */
786 .maxpacket = EP0_FIFO_SIZE,
790 .bEndpointAddress = 0,
793 .ep_type = ep_control,
796 /* first group of endpoints */
799 .name = "ep1in-bulk",
801 .maxpacket = EP_FIFO_SIZE,
805 .bEndpointAddress = USB_DIR_IN | 1,
806 .bmAttributes = USB_ENDPOINT_XFER_BULK,
808 .ep_type = ep_bulk_out,
814 .name = "ep2out-bulk",
816 .maxpacket = EP_FIFO_SIZE,
820 .bEndpointAddress = USB_DIR_OUT | 2,
821 .bmAttributes = USB_ENDPOINT_XFER_BULK,
823 .ep_type = ep_bulk_in,
831 .maxpacket = EP_FIFO_SIZE,
835 .bEndpointAddress = USB_DIR_IN | 3,
836 .bmAttributes = USB_ENDPOINT_XFER_INT,
838 .ep_type = ep_interrupt,
844 * probe - binds to the platform device
847 int s3c_udc_probe(struct s3c_plat_otg_data *pdata)
849 struct s3c_udc *dev = &memory;
852 DEBUG("%s: %p\n", __func__, pdata);
856 phy = (struct s3c_usbotg_phy *)pdata->regs_phy;
857 reg = (struct s3c_usbotg_reg *)pdata->regs_otg;
858 usb_phy_ctrl = pdata->usb_phy_ctrl;
860 /* regs_otg = (void *)pdata->regs_otg; */
862 dev->gadget.is_dualspeed = 1; /* Hack only*/
863 dev->gadget.is_otg = 0;
864 dev->gadget.is_a_peripheral = 0;
865 dev->gadget.b_hnp_enable = 0;
866 dev->gadget.a_hnp_support = 0;
867 dev->gadget.a_alt_hnp_support = 0;
869 the_controller = dev;
871 for (i = 0; i < S3C_MAX_ENDPOINTS+1; i++) {
872 dev->dma_buf[i] = kmalloc(DMA_BUFFER_SIZE, GFP_KERNEL);
873 dev->dma_addr[i] = (dma_addr_t) dev->dma_buf[i];
874 invalidate_dcache_range((unsigned long) dev->dma_buf[i],
875 (unsigned long) (dev->dma_buf[i]
878 usb_ctrl = dev->dma_buf[0];
879 usb_ctrl_dma_addr = dev->dma_addr[0];
886 int usb_gadget_handle_interrupts()
888 u32 intr_status = readl(®->gintsts);
889 u32 gintmsk = readl(®->gintmsk);
891 if (intr_status & gintmsk)
892 return s3c_udc_irq(1, (void *)the_controller);