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 <usbdescriptors.h>
41 #include <linux/usb/gadget.h>
43 #include <asm/byteorder.h>
44 #include <asm/unaligned.h>
47 #include <asm/mach-types.h>
48 #include <asm/arch/gpio.h>
51 #include <usb/lin_gadget_compat.h>
53 /***********************************************************/
55 #define OTG_DMA_MODE 1
60 #define DEBUG_OUT_EP 0
63 #include <usb/s3c_udc.h>
68 static char *state_names[] = {
71 "DATA_STATE_NEED_ZLP",
72 "WAIT_FOR_OUT_STATUS",
75 "WAIT_FOR_OUT_COMPLETE",
76 "WAIT_FOR_IN_COMPLETE",
77 "WAIT_FOR_NULL_COMPLETE",
80 #define DRIVER_DESC "S3C HS USB OTG Device Driver, (c) Samsung Electronics"
81 #define DRIVER_VERSION "15 March 2009"
83 struct s3c_udc *the_controller;
85 static const char driver_name[] = "s3c-udc";
86 static const char driver_desc[] = DRIVER_DESC;
87 static const char ep0name[] = "ep0-control";
90 static unsigned int ep0_fifo_size = 64;
91 static unsigned int ep_fifo_size = 512;
92 static unsigned int ep_fifo_size2 = 1024;
93 static int reset_available = 1;
95 static struct usb_ctrlrequest *usb_ctrl;
96 static dma_addr_t usb_ctrl_dma_addr;
101 static int s3c_ep_enable(struct usb_ep *ep,
102 const struct usb_endpoint_descriptor *);
103 static int s3c_ep_disable(struct usb_ep *ep);
104 static struct usb_request *s3c_alloc_request(struct usb_ep *ep,
106 static void s3c_free_request(struct usb_ep *ep, struct usb_request *);
108 static int s3c_queue(struct usb_ep *ep, struct usb_request *, gfp_t gfp_flags);
109 static int s3c_dequeue(struct usb_ep *ep, struct usb_request *);
110 static int s3c_fifo_status(struct usb_ep *ep);
111 static void s3c_fifo_flush(struct usb_ep *ep);
112 static void s3c_ep0_read(struct s3c_udc *dev);
113 static void s3c_ep0_kick(struct s3c_udc *dev, struct s3c_ep *ep);
114 static void s3c_handle_ep0(struct s3c_udc *dev);
115 static int s3c_ep0_write(struct s3c_udc *dev);
116 static int write_fifo_ep0(struct s3c_ep *ep, struct s3c_request *req);
117 static void done(struct s3c_ep *ep, struct s3c_request *req, int status);
118 static void stop_activity(struct s3c_udc *dev,
119 struct usb_gadget_driver *driver);
120 static int udc_enable(struct s3c_udc *dev);
121 static void udc_set_address(struct s3c_udc *dev, unsigned char address);
122 static void reconfig_usbd(void);
123 static void set_max_pktsize(struct s3c_udc *dev, enum usb_device_speed speed);
124 static void nuke(struct s3c_ep *ep, int status);
125 static int s3c_udc_set_halt(struct usb_ep *_ep, int value);
126 static void s3c_udc_set_nak(struct s3c_ep *ep);
128 void set_udc_gadget_private_data(void *p)
130 debug_cond(DEBUG_SETUP != 0,
131 "%s: the_controller: 0x%p, p: 0x%p\n", __func__,
133 the_controller->gadget.dev.device_data = p;
136 void *get_udc_gadget_private_data(struct usb_gadget *gadget)
138 return gadget->dev.device_data;
141 static struct usb_ep_ops s3c_ep_ops = {
142 .enable = s3c_ep_enable,
143 .disable = s3c_ep_disable,
145 .alloc_request = s3c_alloc_request,
146 .free_request = s3c_free_request,
149 .dequeue = s3c_dequeue,
151 .set_halt = s3c_udc_set_halt,
152 .fifo_status = s3c_fifo_status,
153 .fifo_flush = s3c_fifo_flush,
156 #define create_proc_files() do {} while (0)
157 #define remove_proc_files() do {} while (0)
159 /***********************************************************/
161 void __iomem *regs_otg;
162 struct s3c_usbotg_reg *reg;
163 struct s3c_usbotg_phy *phy;
164 static unsigned int usb_phy_ctrl;
166 void otg_phy_init(struct s3c_udc *dev)
168 dev->pdata->phy_control(1);
171 printf("USB PHY0 Enable\n");
174 writel(readl(usb_phy_ctrl) | USB_PHY_CTRL_EN0, usb_phy_ctrl);
176 if (dev->pdata->usb_flags == PHY0_SLEEP) /* C210 Universal */
177 writel((readl(&phy->phypwr)
178 &~(PHY_0_SLEEP | OTG_DISABLE_0 | ANALOG_PWRDOWN)
179 &~FORCE_SUSPEND_0), &phy->phypwr);
181 writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
182 &~FORCE_SUSPEND_0), &phy->phypwr);
184 writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
185 CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
187 writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
188 | PHY_SW_RST0, &phy->rstcon);
190 writel(readl(&phy->rstcon)
191 &~(PHY_SW_RST0 | LINK_SW_RST | PHYLNK_SW_RST), &phy->rstcon);
195 void otg_phy_off(struct s3c_udc *dev)
197 /* reset controller just in case */
198 writel(PHY_SW_RST0, &phy->rstcon);
200 writel(readl(&phy->phypwr) &~PHY_SW_RST0, &phy->rstcon);
203 writel(readl(&phy->phypwr) | OTG_DISABLE_0 | ANALOG_PWRDOWN
204 | FORCE_SUSPEND_0, &phy->phypwr);
206 writel(readl(usb_phy_ctrl) &~USB_PHY_CTRL_EN0, usb_phy_ctrl);
208 writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)),
213 dev->pdata->phy_control(0);
216 /***********************************************************/
218 #include "s3c_udc_otg_xfer_dma.c"
221 * udc_disable - disable USB device controller
223 static void udc_disable(struct s3c_udc *dev)
225 debug_cond(DEBUG_SETUP != 0, "%s: %p\n", __func__, dev);
227 udc_set_address(dev, 0);
229 dev->ep0state = WAIT_FOR_SETUP;
230 dev->gadget.speed = USB_SPEED_UNKNOWN;
231 dev->usb_address = 0;
237 * udc_reinit - initialize software state
239 static void udc_reinit(struct s3c_udc *dev)
243 debug_cond(DEBUG_SETUP != 0, "%s: %p\n", __func__, dev);
245 /* device/ep0 records init */
246 INIT_LIST_HEAD(&dev->gadget.ep_list);
247 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
248 dev->ep0state = WAIT_FOR_SETUP;
250 /* basic endpoint records init */
251 for (i = 0; i < S3C_MAX_ENDPOINTS; i++) {
252 struct s3c_ep *ep = &dev->ep[i];
255 list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list);
259 INIT_LIST_HEAD(&ep->queue);
263 /* the rest was statically initialized, and is read-only */
266 #define BYTES2MAXP(x) (x / 8)
267 #define MAXP2BYTES(x) (x * 8)
269 /* until it's enabled, this UDC should be completely invisible
272 static int udc_enable(struct s3c_udc *dev)
274 debug_cond(DEBUG_SETUP != 0, "%s: %p\n", __func__, dev);
279 debug_cond(DEBUG_SETUP != 0,
280 "S3C USB 2.0 OTG Controller Core Initialized : 0x%x\n",
281 readl(®->gintmsk));
283 dev->gadget.speed = USB_SPEED_UNKNOWN;
289 Register entry point for the peripheral controller driver.
291 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
293 struct s3c_udc *dev = the_controller;
297 debug_cond(DEBUG_SETUP != 0, "%s: %s\n", __func__, "no name");
300 || (driver->speed != USB_SPEED_FULL
301 && driver->speed != USB_SPEED_HIGH)
302 || !driver->bind || !driver->disconnect || !driver->setup)
309 spin_lock_irqsave(&dev->lock, flags);
310 /* first hook up the driver ... */
311 dev->driver = driver;
312 spin_unlock_irqrestore(&dev->lock, flags);
314 if (retval) { /* TODO */
315 printf("target device_add failed, error %d\n", retval);
319 retval = driver->bind(&dev->gadget);
321 debug_cond(DEBUG_SETUP != 0,
322 "%s: bind to driver --> error %d\n",
323 dev->gadget.name, retval);
330 debug_cond(DEBUG_SETUP != 0,
331 "Registered gadget driver %s\n", dev->gadget.name);
338 * Unregister entry point for the peripheral controller driver.
340 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
342 struct s3c_udc *dev = the_controller;
347 if (!driver || driver != dev->driver)
350 spin_lock_irqsave(&dev->lock, flags);
352 stop_activity(dev, driver);
353 spin_unlock_irqrestore(&dev->lock, flags);
355 driver->unbind(&dev->gadget);
357 disable_irq(IRQ_OTG);
364 * done - retire a request; caller blocked irqs
366 static void done(struct s3c_ep *ep, struct s3c_request *req, int status)
368 unsigned int stopped = ep->stopped;
370 debug("%s: %s %p, req = %p, stopped = %d\n",
371 __func__, ep->ep.name, ep, &req->req, stopped);
373 list_del_init(&req->queue);
375 if (likely(req->req.status == -EINPROGRESS))
376 req->req.status = status;
378 status = req->req.status;
380 if (status && status != -ESHUTDOWN) {
381 debug("complete %s req %p stat %d len %u/%u\n",
382 ep->ep.name, &req->req, status,
383 req->req.actual, req->req.length);
386 /* don't modify queue heads during completion callback */
390 printf("calling complete callback\n");
392 int i, len = req->req.length;
394 printf("pkt[%d] = ", req->req.length);
397 for (i = 0; i < len; i++) {
398 printf("%02x", ((u8 *)req->req.buf)[i]);
405 spin_unlock(&ep->dev->lock);
406 req->req.complete(&ep->ep, &req->req);
407 spin_lock(&ep->dev->lock);
409 debug("callback completed\n");
411 ep->stopped = stopped;
415 * nuke - dequeue ALL requests
417 static void nuke(struct s3c_ep *ep, int status)
419 struct s3c_request *req;
421 debug("%s: %s %p\n", __func__, ep->ep.name, ep);
423 /* called with irqs blocked */
424 while (!list_empty(&ep->queue)) {
425 req = list_entry(ep->queue.next, struct s3c_request, queue);
426 done(ep, req, status);
430 static void stop_activity(struct s3c_udc *dev,
431 struct usb_gadget_driver *driver)
435 /* don't disconnect drivers more than once */
436 if (dev->gadget.speed == USB_SPEED_UNKNOWN)
438 dev->gadget.speed = USB_SPEED_UNKNOWN;
440 /* prevent new request submissions, kill any outstanding requests */
441 for (i = 0; i < S3C_MAX_ENDPOINTS; i++) {
442 struct s3c_ep *ep = &dev->ep[i];
444 nuke(ep, -ESHUTDOWN);
447 /* report disconnect; the driver is already quiesced */
449 spin_unlock(&dev->lock);
450 driver->disconnect(&dev->gadget);
451 spin_lock(&dev->lock);
454 /* re-init driver-visible data structures */
458 static void reconfig_usbd(void)
460 /* 2. Soft-reset OTG Core and then unreset again. */
462 unsigned int uTemp = writel(CORE_SOFT_RESET, ®->grstctl);
464 debug("Reseting OTG controller\n");
466 writel(0<<15 /* PHY Low Power Clock sel*/
467 |1<<14 /* Non-Periodic TxFIFO Rewind Enable*/
468 |0x5<<10 /* Turnaround time*/
469 |0<<9 | 0<<8 /* [0:HNP disable,1:HNP enable][ 0:SRP disable*/
470 /* 1:SRP enable] H1= 1,1*/
471 |0<<7 /* Ulpi DDR sel*/
472 |0<<6 /* 0: high speed utmi+, 1: full speed serial*/
473 |0<<4 /* 0: utmi+, 1:ulpi*/
474 |1<<3 /* phy i/f 0:8bit, 1:16bit*/
475 |0x7<<0, /* HS/FS Timeout**/
478 /* 3. Put the OTG device core in the disconnected state.*/
479 uTemp = readl(®->dctl);
480 uTemp |= SOFT_DISCONNECT;
481 writel(uTemp, ®->dctl);
485 /* 4. Make the OTG device core exit from the disconnected state.*/
486 uTemp = readl(®->dctl);
487 uTemp = uTemp & ~SOFT_DISCONNECT;
488 writel(uTemp, ®->dctl);
490 /* 5. Configure OTG Core to initial settings of device mode.*/
491 /* [][1: full speed(30Mhz) 0:high speed]*/
492 writel(EP_MISS_CNT(1) | DEV_SPEED_HIGH_SPEED_20, ®->dcfg);
496 /* 6. Unmask the core interrupts*/
497 writel(GINTMSK_INIT, ®->gintmsk);
499 /* 7. Set NAK bit of EP0, EP1, EP2*/
500 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->out_endp[EP0_CON].doepctl);
501 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->in_endp[EP0_CON].diepctl);
503 for (i = 1; i < S3C_MAX_ENDPOINTS; i++) {
504 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->out_endp[i].doepctl);
505 writel(DEPCTL_EPDIS|DEPCTL_SNAK, ®->in_endp[i].diepctl);
508 /* 8. Unmask EPO interrupts*/
509 writel(((1 << EP0_CON) << DAINT_OUT_BIT)
510 | (1 << EP0_CON), ®->daintmsk);
512 /* 9. Unmask device OUT EP common interrupts*/
513 writel(DOEPMSK_INIT, ®->doepmsk);
515 /* 10. Unmask device IN EP common interrupts*/
516 writel(DIEPMSK_INIT, ®->diepmsk);
518 /* 11. Set Rx FIFO Size (in 32-bit words) */
519 writel(RX_FIFO_SIZE >> 2, ®->grxfsiz);
521 /* 12. Set Non Periodic Tx FIFO Size */
522 writel((NPTX_FIFO_SIZE >> 2) << 16 | ((RX_FIFO_SIZE >> 2)) << 0,
525 for (i = 1; i < S3C_MAX_HW_ENDPOINTS; i++)
526 writel((PTX_FIFO_SIZE >> 2) << 16 |
527 ((RX_FIFO_SIZE + NPTX_FIFO_SIZE +
528 PTX_FIFO_SIZE*(i-1)) >> 2) << 0,
531 /* Flush the RX FIFO */
532 writel(RX_FIFO_FLUSH, ®->grstctl);
533 while (readl(®->grstctl) & RX_FIFO_FLUSH)
534 debug("%s: waiting for S3C_UDC_OTG_GRSTCTL\n", __func__);
536 /* Flush all the Tx FIFO's */
537 writel(TX_FIFO_FLUSH_ALL, ®->grstctl);
538 writel(TX_FIFO_FLUSH_ALL | TX_FIFO_FLUSH, ®->grstctl);
539 while (readl(®->grstctl) & TX_FIFO_FLUSH)
540 debug("%s: waiting for S3C_UDC_OTG_GRSTCTL\n", __func__);
542 /* 13. Clear NAK bit of EP0, EP1, EP2*/
544 /* EP0: Control OUT */
545 writel(DEPCTL_EPDIS | DEPCTL_CNAK,
546 ®->out_endp[EP0_CON].doepctl);
548 /* 14. Initialize OTG Link Core.*/
549 writel(GAHBCFG_INIT, ®->gahbcfg);
552 static void set_max_pktsize(struct s3c_udc *dev, enum usb_device_speed speed)
554 unsigned int ep_ctrl;
557 if (speed == USB_SPEED_HIGH) {
560 ep_fifo_size2 = 1024;
561 dev->gadget.speed = USB_SPEED_HIGH;
566 dev->gadget.speed = USB_SPEED_FULL;
569 dev->ep[0].ep.maxpacket = ep0_fifo_size;
570 for (i = 1; i < S3C_MAX_ENDPOINTS; i++)
571 dev->ep[i].ep.maxpacket = ep_fifo_size;
573 /* EP0 - Control IN (64 bytes)*/
574 ep_ctrl = readl(®->in_endp[EP0_CON].diepctl);
575 writel(ep_ctrl|(0<<0), ®->in_endp[EP0_CON].diepctl);
577 /* EP0 - Control OUT (64 bytes)*/
578 ep_ctrl = readl(®->out_endp[EP0_CON].doepctl);
579 writel(ep_ctrl|(0<<0), ®->out_endp[EP0_CON].doepctl);
582 static int s3c_ep_enable(struct usb_ep *_ep,
583 const struct usb_endpoint_descriptor *desc)
589 debug("%s: %p\n", __func__, _ep);
591 ep = container_of(_ep, struct s3c_ep, ep);
592 if (!_ep || !desc || ep->desc || _ep->name == ep0name
593 || desc->bDescriptorType != USB_DT_ENDPOINT
594 || ep->bEndpointAddress != desc->bEndpointAddress
595 || ep_maxpacket(ep) <
596 le16_to_cpu(get_unaligned(&desc->wMaxPacketSize))) {
598 debug("%s: bad ep or descriptor\n", __func__);
602 /* xfer types must match, except that interrupt ~= bulk */
603 if (ep->bmAttributes != desc->bmAttributes
604 && ep->bmAttributes != USB_ENDPOINT_XFER_BULK
605 && desc->bmAttributes != USB_ENDPOINT_XFER_INT) {
607 debug("%s: %s type mismatch\n", __func__, _ep->name);
611 /* hardware _could_ do smaller, but driver doesn't */
612 if ((desc->bmAttributes == USB_ENDPOINT_XFER_BULK
613 && le16_to_cpu(get_unaligned(&desc->wMaxPacketSize)) !=
614 ep_maxpacket(ep)) || !get_unaligned(&desc->wMaxPacketSize)) {
616 debug("%s: bad %s maxpacket\n", __func__, _ep->name);
621 if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) {
623 debug("%s: bogus device state\n", __func__);
630 ep->ep.maxpacket = le16_to_cpu(get_unaligned(&desc->wMaxPacketSize));
632 /* Reset halt state */
634 s3c_udc_set_halt(_ep, 0);
636 spin_lock_irqsave(&ep->dev->lock, flags);
637 s3c_udc_ep_activate(ep);
638 spin_unlock_irqrestore(&ep->dev->lock, flags);
640 debug("%s: enabled %s, stopped = %d, maxpacket = %d\n",
641 __func__, _ep->name, ep->stopped, ep->ep.maxpacket);
648 static int s3c_ep_disable(struct usb_ep *_ep)
653 debug("%s: %p\n", __func__, _ep);
655 ep = container_of(_ep, struct s3c_ep, ep);
656 if (!_ep || !ep->desc) {
657 debug("%s: %s not enabled\n", __func__,
658 _ep ? ep->ep.name : NULL);
662 spin_lock_irqsave(&ep->dev->lock, flags);
664 /* Nuke all pending requests */
665 nuke(ep, -ESHUTDOWN);
670 spin_unlock_irqrestore(&ep->dev->lock, flags);
672 debug("%s: disabled %s\n", __func__, _ep->name);
676 static struct usb_request *s3c_alloc_request(struct usb_ep *ep,
679 struct s3c_request *req;
681 debug("%s: %s %p\n", __func__, ep->name, ep);
683 req = memalign(CONFIG_SYS_CACHELINE_SIZE, sizeof(*req));
687 memset(req, 0, sizeof *req);
688 INIT_LIST_HEAD(&req->queue);
693 static void s3c_free_request(struct usb_ep *ep, struct usb_request *_req)
695 struct s3c_request *req;
697 debug("%s: %p\n", __func__, ep);
699 req = container_of(_req, struct s3c_request, req);
700 WARN_ON(!list_empty(&req->queue));
704 /* dequeue JUST ONE request */
705 static int s3c_dequeue(struct usb_ep *_ep, struct usb_request *_req)
708 struct s3c_request *req;
711 debug("%s: %p\n", __func__, _ep);
713 ep = container_of(_ep, struct s3c_ep, ep);
714 if (!_ep || ep->ep.name == ep0name)
717 spin_lock_irqsave(&ep->dev->lock, flags);
719 /* make sure it's actually queued on this endpoint */
720 list_for_each_entry(req, &ep->queue, queue) {
721 if (&req->req == _req)
724 if (&req->req != _req) {
725 spin_unlock_irqrestore(&ep->dev->lock, flags);
729 done(ep, req, -ECONNRESET);
731 spin_unlock_irqrestore(&ep->dev->lock, flags);
736 * Return bytes in EP FIFO
738 static int s3c_fifo_status(struct usb_ep *_ep)
743 ep = container_of(_ep, struct s3c_ep, ep);
745 debug("%s: bad ep\n", __func__);
749 debug("%s: %d\n", __func__, ep_index(ep));
751 /* LPD can't report unclaimed bytes from IN fifos */
761 static void s3c_fifo_flush(struct usb_ep *_ep)
765 ep = container_of(_ep, struct s3c_ep, ep);
766 if (unlikely(!_ep || (!ep->desc && ep->ep.name != ep0name))) {
767 debug("%s: bad ep\n", __func__);
771 debug("%s: %d\n", __func__, ep_index(ep));
774 static const struct usb_gadget_ops s3c_udc_ops = {
775 /* current versions must always be self-powered */
778 static struct s3c_udc memory = {
782 .ep0 = &memory.ep[0].ep,
786 /* control endpoint */
791 .maxpacket = EP0_FIFO_SIZE,
795 .bEndpointAddress = 0,
798 .ep_type = ep_control,
801 /* first group of endpoints */
804 .name = "ep1in-bulk",
806 .maxpacket = EP_FIFO_SIZE,
810 .bEndpointAddress = USB_DIR_IN | 1,
811 .bmAttributes = USB_ENDPOINT_XFER_BULK,
813 .ep_type = ep_bulk_out,
819 .name = "ep2out-bulk",
821 .maxpacket = EP_FIFO_SIZE,
825 .bEndpointAddress = USB_DIR_OUT | 2,
826 .bmAttributes = USB_ENDPOINT_XFER_BULK,
828 .ep_type = ep_bulk_in,
836 .maxpacket = EP_FIFO_SIZE,
840 .bEndpointAddress = USB_DIR_IN | 3,
841 .bmAttributes = USB_ENDPOINT_XFER_INT,
843 .ep_type = ep_interrupt,
849 * probe - binds to the platform device
852 int s3c_udc_probe(struct s3c_plat_otg_data *pdata)
854 struct s3c_udc *dev = &memory;
857 debug("%s: %p\n", __func__, pdata);
861 phy = (struct s3c_usbotg_phy *)pdata->regs_phy;
862 reg = (struct s3c_usbotg_reg *)pdata->regs_otg;
863 usb_phy_ctrl = pdata->usb_phy_ctrl;
865 /* regs_otg = (void *)pdata->regs_otg; */
867 dev->gadget.is_dualspeed = 1; /* Hack only*/
868 dev->gadget.is_otg = 0;
869 dev->gadget.is_a_peripheral = 0;
870 dev->gadget.b_hnp_enable = 0;
871 dev->gadget.a_hnp_support = 0;
872 dev->gadget.a_alt_hnp_support = 0;
874 the_controller = dev;
876 for (i = 0; i < S3C_MAX_ENDPOINTS+1; i++) {
877 dev->dma_buf[i] = memalign(CONFIG_SYS_CACHELINE_SIZE,
879 dev->dma_addr[i] = (dma_addr_t) dev->dma_buf[i];
880 invalidate_dcache_range((unsigned long) dev->dma_buf[i],
881 (unsigned long) (dev->dma_buf[i]
884 usb_ctrl = dev->dma_buf[0];
885 usb_ctrl_dma_addr = dev->dma_addr[0];
892 int usb_gadget_handle_interrupts()
894 u32 intr_status = readl(®->gintsts);
895 u32 gintmsk = readl(®->gintmsk);
897 if (intr_status & gintmsk)
898 return s3c_udc_irq(1, (void *)the_controller);