2 * M66592 UDC (USB gadget)
4 * Copyright (C) 2006-2007 Renesas Solutions Corp.
6 * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <linux/module.h>
24 #include <linux/kernel.h>
25 #include <linux/sched.h>
26 #include <linux/smp_lock.h>
27 #include <linux/errno.h>
28 #include <linux/init.h>
29 #include <linux/timer.h>
30 #include <linux/delay.h>
31 #include <linux/list.h>
32 #include <linux/interrupt.h>
33 #include <linux/platform_device.h>
34 #include <linux/usb/ch9.h>
35 #include <linux/usb_gadget.h>
39 #include <asm/system.h>
41 #include "m66592-udc.h"
43 MODULE_DESCRIPTION("M66592 USB gadget driiver");
44 MODULE_LICENSE("GPL");
45 MODULE_AUTHOR("Yoshihiro Shimoda");
47 #define DRIVER_VERSION "29 May 2007"
49 /* module parameters */
50 static unsigned short clock = M66592_XTAL24;
51 module_param(clock, ushort, 0644);
52 MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0(default=16384)");
53 static unsigned short vif = M66592_LDRV;
54 module_param(vif, ushort, 0644);
55 MODULE_PARM_DESC(vif, "input VIF: 3.3V=32768, 1.5V=0(default=32768)");
56 static unsigned short endian = 0;
57 module_param(endian, ushort, 0644);
58 MODULE_PARM_DESC(endian, "data endian: big=256, little=0(default=0)");
59 static unsigned short irq_sense = M66592_INTL;
60 module_param(irq_sense, ushort, 0644);
61 MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=2, falling edge=0(default=2)");
63 static const char udc_name[] = "m66592_udc";
64 static const char *m66592_ep_name[] = {
65 "ep0", "ep1", "ep2", "ep3", "ep4", "ep5", "ep6", "ep7"
68 static void disable_controller(struct m66592 *m66592);
69 static void irq_ep0_write(struct m66592_ep *ep, struct m66592_request *req);
70 static void irq_packet_write(struct m66592_ep *ep, struct m66592_request *req);
71 static int m66592_queue(struct usb_ep *_ep, struct usb_request *_req,
74 static void transfer_complete(struct m66592_ep *ep,
75 struct m66592_request *req,
77 /*-------------------------------------------------------------------------*/
78 static inline u16 get_usb_speed(struct m66592 *m66592)
80 return (m66592_read(m66592, M66592_DVSTCTR) & M66592_RHST);
83 static void enable_pipe_irq(struct m66592 *m66592, u16 pipenum,
88 tmp = m66592_read(m66592, M66592_INTENB0);
89 m66592_bclr(m66592, M66592_BEMPE | M66592_NRDYE | M66592_BRDYE,
91 m66592_bset(m66592, (1 << pipenum), reg);
92 m66592_write(m66592, tmp, M66592_INTENB0);
95 static void disable_pipe_irq(struct m66592 *m66592, u16 pipenum,
100 tmp = m66592_read(m66592, M66592_INTENB0);
101 m66592_bclr(m66592, M66592_BEMPE | M66592_NRDYE | M66592_BRDYE,
103 m66592_bclr(m66592, (1 << pipenum), reg);
104 m66592_write(m66592, tmp, M66592_INTENB0);
107 static void m66592_usb_connect(struct m66592 *m66592)
109 m66592_bset(m66592, M66592_CTRE, M66592_INTENB0);
110 m66592_bset(m66592, M66592_WDST | M66592_RDST | M66592_CMPL,
112 m66592_bset(m66592, M66592_BEMPE | M66592_BRDYE, M66592_INTENB0);
114 m66592_bset(m66592, M66592_DPRPU, M66592_SYSCFG);
117 static void m66592_usb_disconnect(struct m66592 *m66592)
119 m66592_bclr(m66592, M66592_CTRE, M66592_INTENB0);
120 m66592_bclr(m66592, M66592_WDST | M66592_RDST | M66592_CMPL,
122 m66592_bclr(m66592, M66592_BEMPE | M66592_BRDYE, M66592_INTENB0);
123 m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG);
125 m66592->gadget.speed = USB_SPEED_UNKNOWN;
126 spin_unlock(&m66592->lock);
127 m66592->driver->disconnect(&m66592->gadget);
128 spin_lock(&m66592->lock);
130 disable_controller(m66592);
131 INIT_LIST_HEAD(&m66592->ep[0].queue);
134 static inline u16 control_reg_get_pid(struct m66592 *m66592, u16 pipenum)
137 unsigned long offset;
140 pid = m66592_read(m66592, M66592_DCPCTR) & M66592_PID;
141 else if (pipenum < M66592_MAX_NUM_PIPE) {
142 offset = get_pipectr_addr(pipenum);
143 pid = m66592_read(m66592, offset) & M66592_PID;
145 printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum);
150 static inline void control_reg_set_pid(struct m66592 *m66592, u16 pipenum,
153 unsigned long offset;
156 m66592_mdfy(m66592, pid, M66592_PID, M66592_DCPCTR);
157 else if (pipenum < M66592_MAX_NUM_PIPE) {
158 offset = get_pipectr_addr(pipenum);
159 m66592_mdfy(m66592, pid, M66592_PID, offset);
161 printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum);
164 static inline void pipe_start(struct m66592 *m66592, u16 pipenum)
166 control_reg_set_pid(m66592, pipenum, M66592_PID_BUF);
169 static inline void pipe_stop(struct m66592 *m66592, u16 pipenum)
171 control_reg_set_pid(m66592, pipenum, M66592_PID_NAK);
174 static inline void pipe_stall(struct m66592 *m66592, u16 pipenum)
176 control_reg_set_pid(m66592, pipenum, M66592_PID_STALL);
179 static inline u16 control_reg_get(struct m66592 *m66592, u16 pipenum)
182 unsigned long offset;
185 ret = m66592_read(m66592, M66592_DCPCTR);
186 else if (pipenum < M66592_MAX_NUM_PIPE) {
187 offset = get_pipectr_addr(pipenum);
188 ret = m66592_read(m66592, offset);
190 printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum);
195 static inline void control_reg_sqclr(struct m66592 *m66592, u16 pipenum)
197 unsigned long offset;
199 pipe_stop(m66592, pipenum);
202 m66592_bset(m66592, M66592_SQCLR, M66592_DCPCTR);
203 else if (pipenum < M66592_MAX_NUM_PIPE) {
204 offset = get_pipectr_addr(pipenum);
205 m66592_bset(m66592, M66592_SQCLR, offset);
207 printk(KERN_ERR "unexpect pipe num(%d)\n", pipenum);
210 static inline int get_buffer_size(struct m66592 *m66592, u16 pipenum)
216 tmp = m66592_read(m66592, M66592_DCPCFG);
217 if ((tmp & M66592_CNTMD) != 0)
220 tmp = m66592_read(m66592, M66592_DCPMAXP);
221 size = tmp & M66592_MAXP;
224 m66592_write(m66592, pipenum, M66592_PIPESEL);
225 tmp = m66592_read(m66592, M66592_PIPECFG);
226 if ((tmp & M66592_CNTMD) != 0) {
227 tmp = m66592_read(m66592, M66592_PIPEBUF);
228 size = ((tmp >> 10) + 1) * 64;
230 tmp = m66592_read(m66592, M66592_PIPEMAXP);
231 size = tmp & M66592_MXPS;
238 static inline void pipe_change(struct m66592 *m66592, u16 pipenum)
240 struct m66592_ep *ep = m66592->pipenum2ep[pipenum];
245 m66592_mdfy(m66592, pipenum, M66592_CURPIPE, ep->fifosel);
249 m66592_bset(m66592, M66592_MBW, ep->fifosel);
252 static int pipe_buffer_setting(struct m66592 *m66592,
253 struct m66592_pipe_info *info)
255 u16 bufnum = 0, buf_bsize = 0;
261 m66592_write(m66592, info->pipe, M66592_PIPESEL);
264 pipecfg |= M66592_DIR;
265 pipecfg |= info->type;
266 pipecfg |= info->epnum;
267 switch (info->type) {
269 bufnum = 4 + (info->pipe - M66592_BASE_PIPENUM_INT);
273 bufnum = m66592->bi_bufnum +
274 (info->pipe - M66592_BASE_PIPENUM_BULK) * 16;
275 m66592->bi_bufnum += 16;
277 pipecfg |= M66592_DBLB;
279 pipecfg |= M66592_SHTNAK;
282 bufnum = m66592->bi_bufnum +
283 (info->pipe - M66592_BASE_PIPENUM_ISOC) * 16;
284 m66592->bi_bufnum += 16;
288 if (m66592->bi_bufnum > M66592_MAX_BUFNUM) {
289 printk(KERN_ERR "m66592 pipe memory is insufficient(%d)\n",
294 m66592_write(m66592, pipecfg, M66592_PIPECFG);
295 m66592_write(m66592, (buf_bsize << 10) | (bufnum), M66592_PIPEBUF);
296 m66592_write(m66592, info->maxpacket, M66592_PIPEMAXP);
299 m66592_write(m66592, info->interval, M66592_PIPEPERI);
304 static void pipe_buffer_release(struct m66592 *m66592,
305 struct m66592_pipe_info *info)
310 switch (info->type) {
312 if (is_bulk_pipe(info->pipe))
313 m66592->bi_bufnum -= 16;
316 if (is_isoc_pipe(info->pipe))
317 m66592->bi_bufnum -= 16;
321 if (is_bulk_pipe(info->pipe)) {
323 } else if (is_interrupt_pipe(info->pipe))
325 else if (is_isoc_pipe(info->pipe)) {
326 m66592->isochronous--;
327 if (info->type == M66592_BULK)
330 printk(KERN_ERR "ep_release: unexpect pipenum (%d)\n",
334 static void pipe_initialize(struct m66592_ep *ep)
336 struct m66592 *m66592 = ep->m66592;
338 m66592_mdfy(m66592, 0, M66592_CURPIPE, ep->fifosel);
340 m66592_write(m66592, M66592_ACLRM, ep->pipectr);
341 m66592_write(m66592, 0, ep->pipectr);
342 m66592_write(m66592, M66592_SQCLR, ep->pipectr);
344 m66592_mdfy(m66592, ep->pipenum, M66592_CURPIPE, ep->fifosel);
348 m66592_bset(m66592, M66592_MBW, ep->fifosel);
352 static void m66592_ep_setting(struct m66592 *m66592, struct m66592_ep *ep,
353 const struct usb_endpoint_descriptor *desc,
354 u16 pipenum, int dma)
356 if ((pipenum != 0) && dma) {
357 if (m66592->num_dma == 0) {
360 ep->fifoaddr = M66592_D0FIFO;
361 ep->fifosel = M66592_D0FIFOSEL;
362 ep->fifoctr = M66592_D0FIFOCTR;
363 ep->fifotrn = M66592_D0FIFOTRN;
364 } else if (m66592->num_dma == 1) {
367 ep->fifoaddr = M66592_D1FIFO;
368 ep->fifosel = M66592_D1FIFOSEL;
369 ep->fifoctr = M66592_D1FIFOCTR;
370 ep->fifotrn = M66592_D1FIFOTRN;
373 ep->fifoaddr = M66592_CFIFO;
374 ep->fifosel = M66592_CFIFOSEL;
375 ep->fifoctr = M66592_CFIFOCTR;
380 ep->fifoaddr = M66592_CFIFO;
381 ep->fifosel = M66592_CFIFOSEL;
382 ep->fifoctr = M66592_CFIFOCTR;
386 ep->pipectr = get_pipectr_addr(pipenum);
387 ep->pipenum = pipenum;
388 ep->ep.maxpacket = desc->wMaxPacketSize;
389 m66592->pipenum2ep[pipenum] = ep;
390 m66592->epaddr2ep[desc->bEndpointAddress&USB_ENDPOINT_NUMBER_MASK] = ep;
391 INIT_LIST_HEAD(&ep->queue);
394 static void m66592_ep_release(struct m66592_ep *ep)
396 struct m66592 *m66592 = ep->m66592;
397 u16 pipenum = ep->pipenum;
409 static int alloc_pipe_config(struct m66592_ep *ep,
410 const struct usb_endpoint_descriptor *desc)
412 struct m66592 *m66592 = ep->m66592;
413 struct m66592_pipe_info info;
422 switch(desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
423 case USB_ENDPOINT_XFER_BULK:
424 if (m66592->bulk >= M66592_MAX_NUM_BULK) {
425 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) {
426 printk(KERN_ERR "bulk pipe is insufficient\n");
429 info.pipe = M66592_BASE_PIPENUM_ISOC +
431 counter = &m66592->isochronous;
434 info.pipe = M66592_BASE_PIPENUM_BULK + m66592->bulk;
435 counter = &m66592->bulk;
437 info.type = M66592_BULK;
440 case USB_ENDPOINT_XFER_INT:
441 if (m66592->interrupt >= M66592_MAX_NUM_INT) {
442 printk(KERN_ERR "interrupt pipe is insufficient\n");
445 info.pipe = M66592_BASE_PIPENUM_INT + m66592->interrupt;
446 info.type = M66592_INT;
447 counter = &m66592->interrupt;
449 case USB_ENDPOINT_XFER_ISOC:
450 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) {
451 printk(KERN_ERR "isochronous pipe is insufficient\n");
454 info.pipe = M66592_BASE_PIPENUM_ISOC + m66592->isochronous;
455 info.type = M66592_ISO;
456 counter = &m66592->isochronous;
459 printk(KERN_ERR "unexpect xfer type\n");
462 ep->type = info.type;
464 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
465 info.maxpacket = desc->wMaxPacketSize;
466 info.interval = desc->bInterval;
467 if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
472 ret = pipe_buffer_setting(m66592, &info);
474 printk(KERN_ERR "pipe_buffer_setting fail\n");
479 if ((counter == &m66592->isochronous) && info.type == M66592_BULK)
482 m66592_ep_setting(m66592, ep, desc, info.pipe, dma);
488 static int free_pipe_config(struct m66592_ep *ep)
490 struct m66592 *m66592 = ep->m66592;
491 struct m66592_pipe_info info;
493 info.pipe = ep->pipenum;
494 info.type = ep->type;
495 pipe_buffer_release(m66592, &info);
496 m66592_ep_release(ep);
501 /*-------------------------------------------------------------------------*/
502 static void pipe_irq_enable(struct m66592 *m66592, u16 pipenum)
504 enable_irq_ready(m66592, pipenum);
505 enable_irq_nrdy(m66592, pipenum);
508 static void pipe_irq_disable(struct m66592 *m66592, u16 pipenum)
510 disable_irq_ready(m66592, pipenum);
511 disable_irq_nrdy(m66592, pipenum);
514 /* if complete is true, gadget driver complete function is not call */
515 static void control_end(struct m66592 *m66592, unsigned ccpl)
517 m66592->ep[0].internal_ccpl = ccpl;
518 pipe_start(m66592, 0);
519 m66592_bset(m66592, M66592_CCPL, M66592_DCPCTR);
522 static void start_ep0_write(struct m66592_ep *ep, struct m66592_request *req)
524 struct m66592 *m66592 = ep->m66592;
526 pipe_change(m66592, ep->pipenum);
527 m66592_mdfy(m66592, M66592_ISEL | M66592_PIPE0,
528 (M66592_ISEL | M66592_CURPIPE),
530 m66592_write(m66592, M66592_BCLR, ep->fifoctr);
531 if (req->req.length == 0) {
532 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
533 pipe_start(m66592, 0);
534 transfer_complete(ep, req, 0);
536 m66592_write(m66592, ~M66592_BEMP0, M66592_BEMPSTS);
537 irq_ep0_write(ep, req);
541 static void start_packet_write(struct m66592_ep *ep, struct m66592_request *req)
543 struct m66592 *m66592 = ep->m66592;
546 pipe_change(m66592, ep->pipenum);
547 disable_irq_empty(m66592, ep->pipenum);
548 pipe_start(m66592, ep->pipenum);
550 tmp = m66592_read(m66592, ep->fifoctr);
551 if (unlikely((tmp & M66592_FRDY) == 0))
552 pipe_irq_enable(m66592, ep->pipenum);
554 irq_packet_write(ep, req);
557 static void start_packet_read(struct m66592_ep *ep, struct m66592_request *req)
559 struct m66592 *m66592 = ep->m66592;
560 u16 pipenum = ep->pipenum;
562 if (ep->pipenum == 0) {
563 m66592_mdfy(m66592, M66592_PIPE0,
564 (M66592_ISEL | M66592_CURPIPE),
566 m66592_write(m66592, M66592_BCLR, ep->fifoctr);
567 pipe_start(m66592, pipenum);
568 pipe_irq_enable(m66592, pipenum);
571 m66592_bset(m66592, M66592_TRCLR, ep->fifosel);
572 pipe_change(m66592, pipenum);
573 m66592_bset(m66592, M66592_TRENB, ep->fifosel);
575 (req->req.length + ep->ep.maxpacket - 1) /
576 ep->ep.maxpacket, ep->fifotrn);
578 pipe_start(m66592, pipenum); /* trigger once */
579 pipe_irq_enable(m66592, pipenum);
583 static void start_packet(struct m66592_ep *ep, struct m66592_request *req)
585 if (ep->desc->bEndpointAddress & USB_DIR_IN)
586 start_packet_write(ep, req);
588 start_packet_read(ep, req);
591 static void start_ep0(struct m66592_ep *ep, struct m66592_request *req)
595 ctsq = m66592_read(ep->m66592, M66592_INTSTS0) & M66592_CTSQ;
599 start_ep0_write(ep, req);
602 start_packet_read(ep, req);
606 control_end(ep->m66592, 0);
609 printk(KERN_ERR "start_ep0: unexpect ctsq(%x)\n", ctsq);
614 static void init_controller(struct m66592 *m66592)
616 m66592_bset(m66592, (vif & M66592_LDRV) | (endian & M66592_BIGEND),
618 m66592_bset(m66592, M66592_HSE, M66592_SYSCFG); /* High spd */
619 m66592_mdfy(m66592, clock & M66592_XTAL, M66592_XTAL, M66592_SYSCFG);
621 m66592_bclr(m66592, M66592_USBE, M66592_SYSCFG);
622 m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG);
623 m66592_bset(m66592, M66592_USBE, M66592_SYSCFG);
625 m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG);
629 m66592_bset(m66592, M66592_RCKE | M66592_PLLC, M66592_SYSCFG);
633 m66592_bset(m66592, M66592_SCKE, M66592_SYSCFG);
635 m66592_bset(m66592, irq_sense & M66592_INTL, M66592_INTENB1);
636 m66592_write(m66592, M66592_BURST | M66592_CPU_ADR_RD_WR,
640 static void disable_controller(struct m66592 *m66592)
642 m66592_bclr(m66592, M66592_SCKE, M66592_SYSCFG);
644 m66592_bclr(m66592, M66592_PLLC, M66592_SYSCFG);
646 m66592_bclr(m66592, M66592_RCKE, M66592_SYSCFG);
648 m66592_bclr(m66592, M66592_XCKE, M66592_SYSCFG);
651 static void m66592_start_xclock(struct m66592 *m66592)
655 tmp = m66592_read(m66592, M66592_SYSCFG);
656 if (!(tmp & M66592_XCKE))
657 m66592_bset(m66592, M66592_XCKE, M66592_SYSCFG);
660 /*-------------------------------------------------------------------------*/
661 static void transfer_complete(struct m66592_ep *ep,
662 struct m66592_request *req,
667 if (unlikely(ep->pipenum == 0)) {
668 if (ep->internal_ccpl) {
669 ep->internal_ccpl = 0;
674 list_del_init(&req->queue);
675 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN)
676 req->req.status = -ESHUTDOWN;
678 req->req.status = status;
680 if (!list_empty(&ep->queue))
683 if (likely(req->req.complete))
684 req->req.complete(&ep->ep, &req->req);
687 req = list_entry(ep->queue.next, struct m66592_request, queue);
689 start_packet(ep, req);
693 static void irq_ep0_write(struct m66592_ep *ep, struct m66592_request *req)
700 u16 pipenum = ep->pipenum;
701 struct m66592 *m66592 = ep->m66592;
703 pipe_change(m66592, pipenum);
704 m66592_bset(m66592, M66592_ISEL, ep->fifosel);
708 tmp = m66592_read(m66592, ep->fifoctr);
710 printk(KERN_ERR "pipe0 is busy. maybe cpu i/o bus"
711 "conflict. please power off this controller.");
715 } while ((tmp & M66592_FRDY) == 0);
717 /* prepare parameters */
718 bufsize = get_buffer_size(m66592, pipenum);
719 buf = req->req.buf + req->req.actual;
720 size = min(bufsize, req->req.length - req->req.actual);
725 m66592_write_fifo(m66592, ep->fifoaddr, buf, size);
726 if ((size == 0) || ((size % ep->ep.maxpacket) != 0))
727 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
730 /* update parameters */
731 req->req.actual += size;
733 /* check transfer finish */
734 if ((!req->req.zero && (req->req.actual == req->req.length)) ||
735 (size % ep->ep.maxpacket) || (size == 0)) {
736 disable_irq_ready(m66592, pipenum);
737 disable_irq_empty(m66592, pipenum);
739 disable_irq_ready(m66592, pipenum);
740 enable_irq_empty(m66592, pipenum);
742 pipe_start(m66592, pipenum);
745 static void irq_packet_write(struct m66592_ep *ep, struct m66592_request *req)
751 u16 pipenum = ep->pipenum;
752 struct m66592 *m66592 = ep->m66592;
754 pipe_change(m66592, pipenum);
755 tmp = m66592_read(m66592, ep->fifoctr);
756 if (unlikely((tmp & M66592_FRDY) == 0)) {
757 pipe_stop(m66592, pipenum);
758 pipe_irq_disable(m66592, pipenum);
759 printk(KERN_ERR "write fifo not ready. pipnum=%d\n", pipenum);
763 /* prepare parameters */
764 bufsize = get_buffer_size(m66592, pipenum);
765 buf = req->req.buf + req->req.actual;
766 size = min(bufsize, req->req.length - req->req.actual);
770 m66592_write_fifo(m66592, ep->fifoaddr, buf, size);
771 if ((size == 0) || ((size % ep->ep.maxpacket) != 0) ||
772 ((bufsize != ep->ep.maxpacket) && (bufsize > size)))
773 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
776 /* update parameters */
777 req->req.actual += size;
778 /* check transfer finish */
779 if ((!req->req.zero && (req->req.actual == req->req.length)) ||
780 (size % ep->ep.maxpacket) || (size == 0)) {
781 disable_irq_ready(m66592, pipenum);
782 enable_irq_empty(m66592, pipenum);
784 disable_irq_empty(m66592, pipenum);
785 pipe_irq_enable(m66592, pipenum);
789 static void irq_packet_read(struct m66592_ep *ep, struct m66592_request *req)
792 int rcv_len, bufsize, req_len;
795 u16 pipenum = ep->pipenum;
796 struct m66592 *m66592 = ep->m66592;
799 pipe_change(m66592, pipenum);
800 tmp = m66592_read(m66592, ep->fifoctr);
801 if (unlikely((tmp & M66592_FRDY) == 0)) {
802 req->req.status = -EPIPE;
803 pipe_stop(m66592, pipenum);
804 pipe_irq_disable(m66592, pipenum);
805 printk(KERN_ERR "read fifo not ready");
809 /* prepare parameters */
810 rcv_len = tmp & M66592_DTLN;
811 bufsize = get_buffer_size(m66592, pipenum);
813 buf = req->req.buf + req->req.actual;
814 req_len = req->req.length - req->req.actual;
815 if (rcv_len < bufsize)
816 size = min(rcv_len, req_len);
818 size = min(bufsize, req_len);
820 /* update parameters */
821 req->req.actual += size;
823 /* check transfer finish */
824 if ((!req->req.zero && (req->req.actual == req->req.length)) ||
825 (size % ep->ep.maxpacket) || (size == 0)) {
826 pipe_stop(m66592, pipenum);
827 pipe_irq_disable(m66592, pipenum);
834 m66592_write(m66592, M66592_BCLR, ep->fifoctr);
836 m66592_read_fifo(m66592, ep->fifoaddr, buf, size);
839 if ((ep->pipenum != 0) && finish)
840 transfer_complete(ep, req, 0);
843 static void irq_pipe_ready(struct m66592 *m66592, u16 status, u16 enb)
847 struct m66592_ep *ep;
848 struct m66592_request *req;
850 if ((status & M66592_BRDY0) && (enb & M66592_BRDY0)) {
851 m66592_write(m66592, ~M66592_BRDY0, M66592_BRDYSTS);
852 m66592_mdfy(m66592, M66592_PIPE0, M66592_CURPIPE,
856 req = list_entry(ep->queue.next, struct m66592_request, queue);
857 irq_packet_read(ep, req);
859 for (pipenum = 1; pipenum < M66592_MAX_NUM_PIPE; pipenum++) {
860 check = 1 << pipenum;
861 if ((status & check) && (enb & check)) {
862 m66592_write(m66592, ~check, M66592_BRDYSTS);
863 ep = m66592->pipenum2ep[pipenum];
864 req = list_entry(ep->queue.next,
865 struct m66592_request, queue);
866 if (ep->desc->bEndpointAddress & USB_DIR_IN)
867 irq_packet_write(ep, req);
869 irq_packet_read(ep, req);
875 static void irq_pipe_empty(struct m66592 *m66592, u16 status, u16 enb)
880 struct m66592_ep *ep;
881 struct m66592_request *req;
883 if ((status & M66592_BEMP0) && (enb & M66592_BEMP0)) {
884 m66592_write(m66592, ~M66592_BEMP0, M66592_BEMPSTS);
887 req = list_entry(ep->queue.next, struct m66592_request, queue);
888 irq_ep0_write(ep, req);
890 for (pipenum = 1; pipenum < M66592_MAX_NUM_PIPE; pipenum++) {
891 check = 1 << pipenum;
892 if ((status & check) && (enb & check)) {
893 m66592_write(m66592, ~check, M66592_BEMPSTS);
894 tmp = control_reg_get(m66592, pipenum);
895 if ((tmp & M66592_INBUFM) == 0) {
896 disable_irq_empty(m66592, pipenum);
897 pipe_irq_disable(m66592, pipenum);
898 pipe_stop(m66592, pipenum);
899 ep = m66592->pipenum2ep[pipenum];
900 req = list_entry(ep->queue.next,
901 struct m66592_request,
903 if (!list_empty(&ep->queue))
904 transfer_complete(ep, req, 0);
911 static void get_status(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
913 struct m66592_ep *ep;
917 switch (ctrl->bRequestType & USB_RECIP_MASK) {
918 case USB_RECIP_DEVICE:
919 status = 1; /* selfpower */
921 case USB_RECIP_INTERFACE:
924 case USB_RECIP_ENDPOINT:
925 ep = m66592->epaddr2ep[ctrl->wIndex&USB_ENDPOINT_NUMBER_MASK];
926 pid = control_reg_get_pid(m66592, ep->pipenum);
927 if (pid == M66592_PID_STALL)
933 pipe_stall(m66592, 0);
937 *m66592->ep0_buf = status;
938 m66592->ep0_req->buf = m66592->ep0_buf;
939 m66592->ep0_req->length = 2;
940 /* AV: what happens if we get called again before that gets through? */
941 m66592_queue(m66592->gadget.ep0, m66592->ep0_req, GFP_KERNEL);
944 static void clear_feature(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
946 switch (ctrl->bRequestType & USB_RECIP_MASK) {
947 case USB_RECIP_DEVICE:
948 control_end(m66592, 1);
950 case USB_RECIP_INTERFACE:
951 control_end(m66592, 1);
953 case USB_RECIP_ENDPOINT: {
954 struct m66592_ep *ep;
955 struct m66592_request *req;
957 ep = m66592->epaddr2ep[ctrl->wIndex&USB_ENDPOINT_NUMBER_MASK];
958 pipe_stop(m66592, ep->pipenum);
959 control_reg_sqclr(m66592, ep->pipenum);
961 control_end(m66592, 1);
963 req = list_entry(ep->queue.next,
964 struct m66592_request, queue);
967 if (list_empty(&ep->queue))
969 start_packet(ep, req);
970 } else if (!list_empty(&ep->queue))
971 pipe_start(m66592, ep->pipenum);
975 pipe_stall(m66592, 0);
980 static void set_feature(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
983 switch (ctrl->bRequestType & USB_RECIP_MASK) {
984 case USB_RECIP_DEVICE:
985 control_end(m66592, 1);
987 case USB_RECIP_INTERFACE:
988 control_end(m66592, 1);
990 case USB_RECIP_ENDPOINT: {
991 struct m66592_ep *ep;
993 ep = m66592->epaddr2ep[ctrl->wIndex&USB_ENDPOINT_NUMBER_MASK];
994 pipe_stall(m66592, ep->pipenum);
996 control_end(m66592, 1);
1000 pipe_stall(m66592, 0);
1005 /* if return value is true, call class driver's setup() */
1006 static int setup_packet(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
1008 u16 *p = (u16 *)ctrl;
1009 unsigned long offset = M66592_USBREQ;
1013 m66592_write(m66592, ~M66592_VALID, M66592_INTSTS0);
1015 for (i = 0; i < 4; i++)
1016 p[i] = m66592_read(m66592, offset + i*2);
1019 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) {
1020 switch (ctrl->bRequest) {
1021 case USB_REQ_GET_STATUS:
1022 get_status(m66592, ctrl);
1024 case USB_REQ_CLEAR_FEATURE:
1025 clear_feature(m66592, ctrl);
1027 case USB_REQ_SET_FEATURE:
1028 set_feature(m66592, ctrl);
1039 static void m66592_update_usb_speed(struct m66592 *m66592)
1041 u16 speed = get_usb_speed(m66592);
1045 m66592->gadget.speed = USB_SPEED_HIGH;
1048 m66592->gadget.speed = USB_SPEED_FULL;
1051 m66592->gadget.speed = USB_SPEED_UNKNOWN;
1052 printk(KERN_ERR "USB speed unknown\n");
1056 static void irq_device_state(struct m66592 *m66592)
1060 dvsq = m66592_read(m66592, M66592_INTSTS0) & M66592_DVSQ;
1061 m66592_write(m66592, ~M66592_DVST, M66592_INTSTS0);
1063 if (dvsq == M66592_DS_DFLT) { /* bus reset */
1064 m66592->driver->disconnect(&m66592->gadget);
1065 m66592_update_usb_speed(m66592);
1067 if (m66592->old_dvsq == M66592_DS_CNFG && dvsq != M66592_DS_CNFG)
1068 m66592_update_usb_speed(m66592);
1069 if ((dvsq == M66592_DS_CNFG || dvsq == M66592_DS_ADDS) &&
1070 m66592->gadget.speed == USB_SPEED_UNKNOWN)
1071 m66592_update_usb_speed(m66592);
1073 m66592->old_dvsq = dvsq;
1076 static void irq_control_stage(struct m66592 *m66592)
1078 struct usb_ctrlrequest ctrl;
1081 ctsq = m66592_read(m66592, M66592_INTSTS0) & M66592_CTSQ;
1082 m66592_write(m66592, ~M66592_CTRT, M66592_INTSTS0);
1085 case M66592_CS_IDST: {
1086 struct m66592_ep *ep;
1087 struct m66592_request *req;
1088 ep = &m66592->ep[0];
1089 req = list_entry(ep->queue.next, struct m66592_request, queue);
1090 transfer_complete(ep, req, 0);
1094 case M66592_CS_RDDS:
1095 case M66592_CS_WRDS:
1096 case M66592_CS_WRND:
1097 if (setup_packet(m66592, &ctrl)) {
1098 if (m66592->driver->setup(&m66592->gadget, &ctrl) < 0)
1099 pipe_stall(m66592, 0);
1102 case M66592_CS_RDSS:
1103 case M66592_CS_WRSS:
1104 control_end(m66592, 0);
1107 printk(KERN_ERR "ctrl_stage: unexpect ctsq(%x)\n", ctsq);
1112 static irqreturn_t m66592_irq(int irq, void *_m66592)
1114 struct m66592 *m66592 = _m66592;
1117 u16 brdysts, nrdysts, bempsts;
1118 u16 brdyenb, nrdyenb, bempenb;
1122 intsts0 = m66592_read(m66592, M66592_INTSTS0);
1123 intenb0 = m66592_read(m66592, M66592_INTENB0);
1125 savepipe = m66592_read(m66592, M66592_CFIFOSEL);
1127 mask0 = intsts0 & intenb0;
1129 brdysts = m66592_read(m66592, M66592_BRDYSTS);
1130 nrdysts = m66592_read(m66592, M66592_NRDYSTS);
1131 bempsts = m66592_read(m66592, M66592_BEMPSTS);
1132 brdyenb = m66592_read(m66592, M66592_BRDYENB);
1133 nrdyenb = m66592_read(m66592, M66592_NRDYENB);
1134 bempenb = m66592_read(m66592, M66592_BEMPENB);
1136 if (mask0 & M66592_VBINT) {
1137 m66592_write(m66592, (u16)~M66592_VBINT,
1139 m66592_start_xclock(m66592);
1141 /* start vbus sampling */
1142 m66592->old_vbus = m66592_read(m66592, M66592_INTSTS0)
1144 m66592->scount = M66592_MAX_SAMPLING;
1146 mod_timer(&m66592->timer,
1147 jiffies + msecs_to_jiffies(50));
1149 if (intsts0 & M66592_DVSQ)
1150 irq_device_state(m66592);
1152 if ((intsts0 & M66592_BRDY) && (intenb0 & M66592_BRDYE) &&
1153 (brdysts & brdyenb)) {
1154 irq_pipe_ready(m66592, brdysts, brdyenb);
1156 if ((intsts0 & M66592_BEMP) && (intenb0 & M66592_BEMPE) &&
1157 (bempsts & bempenb)) {
1158 irq_pipe_empty(m66592, bempsts, bempenb);
1161 if (intsts0 & M66592_CTRT)
1162 irq_control_stage(m66592);
1165 m66592_write(m66592, savepipe, M66592_CFIFOSEL);
1170 static void m66592_timer(unsigned long _m66592)
1172 struct m66592 *m66592 = (struct m66592 *)_m66592;
1173 unsigned long flags;
1176 spin_lock_irqsave(&m66592->lock, flags);
1177 tmp = m66592_read(m66592, M66592_SYSCFG);
1178 if (!(tmp & M66592_RCKE)) {
1179 m66592_bset(m66592, M66592_RCKE | M66592_PLLC, M66592_SYSCFG);
1181 m66592_bset(m66592, M66592_SCKE, M66592_SYSCFG);
1183 if (m66592->scount > 0) {
1184 tmp = m66592_read(m66592, M66592_INTSTS0) & M66592_VBSTS;
1185 if (tmp == m66592->old_vbus) {
1187 if (m66592->scount == 0) {
1188 if (tmp == M66592_VBSTS)
1189 m66592_usb_connect(m66592);
1191 m66592_usb_disconnect(m66592);
1193 mod_timer(&m66592->timer,
1194 jiffies + msecs_to_jiffies(50));
1197 m66592->scount = M66592_MAX_SAMPLING;
1198 m66592->old_vbus = tmp;
1199 mod_timer(&m66592->timer,
1200 jiffies + msecs_to_jiffies(50));
1203 spin_unlock_irqrestore(&m66592->lock, flags);
1206 /*-------------------------------------------------------------------------*/
1207 static int m66592_enable(struct usb_ep *_ep,
1208 const struct usb_endpoint_descriptor *desc)
1210 struct m66592_ep *ep;
1212 ep = container_of(_ep, struct m66592_ep, ep);
1213 return alloc_pipe_config(ep, desc);
1216 static int m66592_disable(struct usb_ep *_ep)
1218 struct m66592_ep *ep;
1219 struct m66592_request *req;
1220 unsigned long flags;
1222 ep = container_of(_ep, struct m66592_ep, ep);
1225 while (!list_empty(&ep->queue)) {
1226 req = list_entry(ep->queue.next, struct m66592_request, queue);
1227 spin_lock_irqsave(&ep->m66592->lock, flags);
1228 transfer_complete(ep, req, -ECONNRESET);
1229 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1232 pipe_irq_disable(ep->m66592, ep->pipenum);
1233 return free_pipe_config(ep);
1236 static struct usb_request *m66592_alloc_request(struct usb_ep *_ep,
1239 struct m66592_request *req;
1241 req = kzalloc(sizeof(struct m66592_request), gfp_flags);
1245 INIT_LIST_HEAD(&req->queue);
1250 static void m66592_free_request(struct usb_ep *_ep, struct usb_request *_req)
1252 struct m66592_request *req;
1254 req = container_of(_req, struct m66592_request, req);
1258 static int m66592_queue(struct usb_ep *_ep, struct usb_request *_req,
1261 struct m66592_ep *ep;
1262 struct m66592_request *req;
1263 unsigned long flags;
1266 ep = container_of(_ep, struct m66592_ep, ep);
1267 req = container_of(_req, struct m66592_request, req);
1269 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN)
1272 spin_lock_irqsave(&ep->m66592->lock, flags);
1274 if (list_empty(&ep->queue))
1277 list_add_tail(&req->queue, &ep->queue);
1278 req->req.actual = 0;
1279 req->req.status = -EINPROGRESS;
1281 if (ep->desc == 0) /* control */
1284 if (request && !ep->busy)
1285 start_packet(ep, req);
1288 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1293 static int m66592_dequeue(struct usb_ep *_ep, struct usb_request *_req)
1295 struct m66592_ep *ep;
1296 struct m66592_request *req;
1297 unsigned long flags;
1299 ep = container_of(_ep, struct m66592_ep, ep);
1300 req = container_of(_req, struct m66592_request, req);
1302 spin_lock_irqsave(&ep->m66592->lock, flags);
1303 if (!list_empty(&ep->queue))
1304 transfer_complete(ep, req, -ECONNRESET);
1305 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1310 static int m66592_set_halt(struct usb_ep *_ep, int value)
1312 struct m66592_ep *ep;
1313 struct m66592_request *req;
1314 unsigned long flags;
1317 ep = container_of(_ep, struct m66592_ep, ep);
1318 req = list_entry(ep->queue.next, struct m66592_request, queue);
1320 spin_lock_irqsave(&ep->m66592->lock, flags);
1321 if (!list_empty(&ep->queue)) {
1327 pipe_stall(ep->m66592, ep->pipenum);
1330 pipe_stop(ep->m66592, ep->pipenum);
1334 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1338 static int m66592_fifo_status(struct usb_ep *_ep)
1343 static void m66592_fifo_flush(struct usb_ep *_ep)
1345 struct m66592_ep *ep;
1346 unsigned long flags;
1348 ep = container_of(_ep, struct m66592_ep, ep);
1349 spin_lock_irqsave(&ep->m66592->lock, flags);
1350 if (list_empty(&ep->queue) && !ep->busy) {
1351 pipe_stop(ep->m66592, ep->pipenum);
1352 m66592_bclr(ep->m66592, M66592_BCLR, ep->fifoctr);
1354 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1357 static struct usb_ep_ops m66592_ep_ops = {
1358 .enable = m66592_enable,
1359 .disable = m66592_disable,
1361 .alloc_request = m66592_alloc_request,
1362 .free_request = m66592_free_request,
1364 .queue = m66592_queue,
1365 .dequeue = m66592_dequeue,
1367 .set_halt = m66592_set_halt,
1368 .fifo_status = m66592_fifo_status,
1369 .fifo_flush = m66592_fifo_flush,
1372 /*-------------------------------------------------------------------------*/
1373 static struct m66592 *the_controller;
1375 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1377 struct m66592 *m66592 = the_controller;
1381 driver->speed != USB_SPEED_HIGH ||
1391 /* hook up the driver */
1392 driver->driver.bus = NULL;
1393 m66592->driver = driver;
1394 m66592->gadget.dev.driver = &driver->driver;
1396 retval = device_add(&m66592->gadget.dev);
1398 printk(KERN_ERR "device_add error (%d)\n", retval);
1402 retval = driver->bind (&m66592->gadget);
1404 printk(KERN_ERR "bind to driver error (%d)\n", retval);
1405 device_del(&m66592->gadget.dev);
1409 m66592_bset(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0);
1410 if (m66592_read(m66592, M66592_INTSTS0) & M66592_VBSTS) {
1411 m66592_start_xclock(m66592);
1412 /* start vbus sampling */
1413 m66592->old_vbus = m66592_read(m66592,
1414 M66592_INTSTS0) & M66592_VBSTS;
1415 m66592->scount = M66592_MAX_SAMPLING;
1416 mod_timer(&m66592->timer,
1417 jiffies + msecs_to_jiffies(50));
1423 m66592->driver = NULL;
1424 m66592->gadget.dev.driver = NULL;
1428 EXPORT_SYMBOL(usb_gadget_register_driver);
1430 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1432 struct m66592 *m66592 = the_controller;
1433 unsigned long flags;
1435 spin_lock_irqsave(&m66592->lock, flags);
1436 if (m66592->gadget.speed != USB_SPEED_UNKNOWN)
1437 m66592_usb_disconnect(m66592);
1438 spin_unlock_irqrestore(&m66592->lock, flags);
1440 m66592_bclr(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0);
1442 driver->unbind(&m66592->gadget);
1444 init_controller(m66592);
1445 disable_controller(m66592);
1447 device_del(&m66592->gadget.dev);
1448 m66592->driver = NULL;
1451 EXPORT_SYMBOL(usb_gadget_unregister_driver);
1453 /*-------------------------------------------------------------------------*/
1454 static int m66592_get_frame(struct usb_gadget *_gadget)
1456 struct m66592 *m66592 = gadget_to_m66592(_gadget);
1457 return m66592_read(m66592, M66592_FRMNUM) & 0x03FF;
1460 static struct usb_gadget_ops m66592_gadget_ops = {
1461 .get_frame = m66592_get_frame,
1464 #if defined(CONFIG_PM)
1465 static int m66592_suspend(struct platform_device *pdev, pm_message_t state)
1467 pdev->dev.power.power_state = state;
1471 static int m66592_resume(struct platform_device *pdev)
1473 pdev->dev.power.power_state = PMSG_ON;
1476 #else /* if defined(CONFIG_PM) */
1477 #define m66592_suspend NULL
1478 #define m66592_resume NULL
1481 static int __init_or_module m66592_remove(struct platform_device *pdev)
1483 struct m66592 *m66592 = dev_get_drvdata(&pdev->dev);
1485 del_timer_sync(&m66592->timer);
1486 iounmap(m66592->reg);
1487 free_irq(platform_get_irq(pdev, 0), m66592);
1492 #define resource_len(r) (((r)->end - (r)->start) + 1)
1493 static int __init m66592_probe(struct platform_device *pdev)
1495 struct resource *res = NULL;
1497 void __iomem *reg = NULL;
1498 struct m66592 *m66592 = NULL;
1502 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1506 printk(KERN_ERR "platform_get_resource_byname error.\n");
1510 irq = platform_get_irq(pdev, 0);
1513 printk(KERN_ERR "platform_get_irq error.\n");
1517 reg = ioremap(res->start, resource_len(res));
1520 printk(KERN_ERR "ioremap error.\n");
1524 /* initialize ucd */
1525 m66592 = kzalloc(sizeof(struct m66592), GFP_KERNEL);
1526 if (m66592 == NULL) {
1527 printk(KERN_ERR "kzalloc error\n");
1531 spin_lock_init(&m66592->lock);
1532 dev_set_drvdata(&pdev->dev, m66592);
1534 m66592->gadget.ops = &m66592_gadget_ops;
1535 device_initialize(&m66592->gadget.dev);
1536 strcpy(m66592->gadget.dev.bus_id, "gadget");
1537 m66592->gadget.is_dualspeed = 1;
1538 m66592->gadget.dev.parent = &pdev->dev;
1539 m66592->gadget.dev.dma_mask = pdev->dev.dma_mask;
1540 m66592->gadget.dev.release = pdev->dev.release;
1541 m66592->gadget.name = udc_name;
1543 init_timer(&m66592->timer);
1544 m66592->timer.function = m66592_timer;
1545 m66592->timer.data = (unsigned long)m66592;
1548 m66592->bi_bufnum = M66592_BASE_BUFNUM;
1550 ret = request_irq(irq, m66592_irq, IRQF_DISABLED | IRQF_SHARED,
1553 printk(KERN_ERR "request_irq error (%d)\n", ret);
1557 INIT_LIST_HEAD(&m66592->gadget.ep_list);
1558 m66592->gadget.ep0 = &m66592->ep[0].ep;
1559 INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list);
1560 for (i = 0; i < M66592_MAX_NUM_PIPE; i++) {
1561 struct m66592_ep *ep = &m66592->ep[i];
1564 INIT_LIST_HEAD(&m66592->ep[i].ep.ep_list);
1565 list_add_tail(&m66592->ep[i].ep.ep_list,
1566 &m66592->gadget.ep_list);
1568 ep->m66592 = m66592;
1569 INIT_LIST_HEAD(&ep->queue);
1570 ep->ep.name = m66592_ep_name[i];
1571 ep->ep.ops = &m66592_ep_ops;
1572 ep->ep.maxpacket = 512;
1574 m66592->ep[0].ep.maxpacket = 64;
1575 m66592->ep[0].pipenum = 0;
1576 m66592->ep[0].fifoaddr = M66592_CFIFO;
1577 m66592->ep[0].fifosel = M66592_CFIFOSEL;
1578 m66592->ep[0].fifoctr = M66592_CFIFOCTR;
1579 m66592->ep[0].fifotrn = 0;
1580 m66592->ep[0].pipectr = get_pipectr_addr(0);
1581 m66592->pipenum2ep[0] = &m66592->ep[0];
1582 m66592->epaddr2ep[0] = &m66592->ep[0];
1584 the_controller = m66592;
1587 m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL);
1588 if (m66592->ep0_req == NULL)
1590 /* AV: leaks, and do we really need it separately allocated? */
1591 m66592->ep0_buf = kzalloc(2, GFP_KERNEL);
1592 if (m66592->ep0_buf == NULL)
1595 init_controller(m66592);
1597 printk("driver %s, %s\n", udc_name, DRIVER_VERSION);
1602 if (m66592->ep0_req)
1603 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
1612 /*-------------------------------------------------------------------------*/
1613 static struct platform_driver m66592_driver = {
1614 .probe = m66592_probe,
1615 .remove = m66592_remove,
1616 .suspend = m66592_suspend,
1617 .resume = m66592_resume,
1619 .name = (char *) udc_name,
1623 static int __init m66592_udc_init(void)
1625 return platform_driver_register(&m66592_driver);
1627 module_init(m66592_udc_init);
1629 static void __exit m66592_udc_cleanup(void)
1631 platform_driver_unregister(&m66592_driver);
1633 module_exit(m66592_udc_cleanup);