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/interrupt.h>
25 #include <linux/delay.h>
27 #include <linux/platform_device.h>
29 #include <linux/usb/ch9.h>
30 #include <linux/usb/gadget.h>
32 #include "m66592-udc.h"
35 MODULE_DESCRIPTION("M66592 USB gadget driver");
36 MODULE_LICENSE("GPL");
37 MODULE_AUTHOR("Yoshihiro Shimoda");
39 #define DRIVER_VERSION "29 May 2007"
41 /* module parameters */
42 static unsigned short clock = M66592_XTAL24;
43 module_param(clock, ushort, 0644);
44 MODULE_PARM_DESC(clock, "input clock: 48MHz=32768, 24MHz=16384, 12MHz=0 "
47 static unsigned short vif = M66592_LDRV;
48 module_param(vif, ushort, 0644);
49 MODULE_PARM_DESC(vif, "input VIF: 3.3V=32768, 1.5V=0 (default=32768)");
51 static unsigned short endian;
52 module_param(endian, ushort, 0644);
53 MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)");
55 static unsigned short irq_sense = M66592_INTL;
56 module_param(irq_sense, ushort, 0644);
57 MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=2, falling edge=0 "
60 static const char udc_name[] = "m66592_udc";
61 static const char *m66592_ep_name[] = {
62 "ep0", "ep1", "ep2", "ep3", "ep4", "ep5", "ep6", "ep7"
65 static void disable_controller(struct m66592 *m66592);
66 static void irq_ep0_write(struct m66592_ep *ep, struct m66592_request *req);
67 static void irq_packet_write(struct m66592_ep *ep, struct m66592_request *req);
68 static int m66592_queue(struct usb_ep *_ep, struct usb_request *_req,
71 static void transfer_complete(struct m66592_ep *ep,
72 struct m66592_request *req, int status);
74 /*-------------------------------------------------------------------------*/
75 static inline u16 get_usb_speed(struct m66592 *m66592)
77 return (m66592_read(m66592, M66592_DVSTCTR) & M66592_RHST);
80 static void enable_pipe_irq(struct m66592 *m66592, u16 pipenum,
85 tmp = m66592_read(m66592, M66592_INTENB0);
86 m66592_bclr(m66592, M66592_BEMPE | M66592_NRDYE | M66592_BRDYE,
88 m66592_bset(m66592, (1 << pipenum), reg);
89 m66592_write(m66592, tmp, M66592_INTENB0);
92 static void disable_pipe_irq(struct m66592 *m66592, u16 pipenum,
97 tmp = m66592_read(m66592, M66592_INTENB0);
98 m66592_bclr(m66592, M66592_BEMPE | M66592_NRDYE | M66592_BRDYE,
100 m66592_bclr(m66592, (1 << pipenum), reg);
101 m66592_write(m66592, tmp, M66592_INTENB0);
104 static void m66592_usb_connect(struct m66592 *m66592)
106 m66592_bset(m66592, M66592_CTRE, M66592_INTENB0);
107 m66592_bset(m66592, M66592_WDST | M66592_RDST | M66592_CMPL,
109 m66592_bset(m66592, M66592_BEMPE | M66592_BRDYE, M66592_INTENB0);
111 m66592_bset(m66592, M66592_DPRPU, M66592_SYSCFG);
114 static void m66592_usb_disconnect(struct m66592 *m66592)
115 __releases(m66592->lock)
116 __acquires(m66592->lock)
118 m66592_bclr(m66592, M66592_CTRE, M66592_INTENB0);
119 m66592_bclr(m66592, M66592_WDST | M66592_RDST | M66592_CMPL,
121 m66592_bclr(m66592, M66592_BEMPE | M66592_BRDYE, M66592_INTENB0);
122 m66592_bclr(m66592, M66592_DPRPU, M66592_SYSCFG);
124 m66592->gadget.speed = USB_SPEED_UNKNOWN;
125 spin_unlock(&m66592->lock);
126 m66592->driver->disconnect(&m66592->gadget);
127 spin_lock(&m66592->lock);
129 disable_controller(m66592);
130 INIT_LIST_HEAD(&m66592->ep[0].queue);
133 static inline u16 control_reg_get_pid(struct m66592 *m66592, u16 pipenum)
136 unsigned long offset;
139 pid = m66592_read(m66592, M66592_DCPCTR) & M66592_PID;
140 else if (pipenum < M66592_MAX_NUM_PIPE) {
141 offset = get_pipectr_addr(pipenum);
142 pid = m66592_read(m66592, offset) & M66592_PID;
144 printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum);
149 static inline void control_reg_set_pid(struct m66592 *m66592, u16 pipenum,
152 unsigned long offset;
155 m66592_mdfy(m66592, pid, M66592_PID, M66592_DCPCTR);
156 else if (pipenum < M66592_MAX_NUM_PIPE) {
157 offset = get_pipectr_addr(pipenum);
158 m66592_mdfy(m66592, pid, M66592_PID, offset);
160 printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum);
163 static inline void pipe_start(struct m66592 *m66592, u16 pipenum)
165 control_reg_set_pid(m66592, pipenum, M66592_PID_BUF);
168 static inline void pipe_stop(struct m66592 *m66592, u16 pipenum)
170 control_reg_set_pid(m66592, pipenum, M66592_PID_NAK);
173 static inline void pipe_stall(struct m66592 *m66592, u16 pipenum)
175 control_reg_set_pid(m66592, pipenum, M66592_PID_STALL);
178 static inline u16 control_reg_get(struct m66592 *m66592, u16 pipenum)
181 unsigned long offset;
184 ret = m66592_read(m66592, M66592_DCPCTR);
185 else if (pipenum < M66592_MAX_NUM_PIPE) {
186 offset = get_pipectr_addr(pipenum);
187 ret = m66592_read(m66592, offset);
189 printk(KERN_ERR "unexpect pipe num (%d)\n", pipenum);
194 static inline void control_reg_sqclr(struct m66592 *m66592, u16 pipenum)
196 unsigned long offset;
198 pipe_stop(m66592, pipenum);
201 m66592_bset(m66592, M66592_SQCLR, M66592_DCPCTR);
202 else if (pipenum < M66592_MAX_NUM_PIPE) {
203 offset = get_pipectr_addr(pipenum);
204 m66592_bset(m66592, M66592_SQCLR, offset);
206 printk(KERN_ERR "unexpect pipe num(%d)\n", pipenum);
209 static inline int get_buffer_size(struct m66592 *m66592, u16 pipenum)
215 tmp = m66592_read(m66592, M66592_DCPCFG);
216 if ((tmp & M66592_CNTMD) != 0)
219 tmp = m66592_read(m66592, M66592_DCPMAXP);
220 size = tmp & M66592_MAXP;
223 m66592_write(m66592, pipenum, M66592_PIPESEL);
224 tmp = m66592_read(m66592, M66592_PIPECFG);
225 if ((tmp & M66592_CNTMD) != 0) {
226 tmp = m66592_read(m66592, M66592_PIPEBUF);
227 size = ((tmp >> 10) + 1) * 64;
229 tmp = m66592_read(m66592, M66592_PIPEMAXP);
230 size = tmp & M66592_MXPS;
237 static inline void pipe_change(struct m66592 *m66592, u16 pipenum)
239 struct m66592_ep *ep = m66592->pipenum2ep[pipenum];
244 m66592_mdfy(m66592, pipenum, M66592_CURPIPE, ep->fifosel);
248 m66592_bset(m66592, M66592_MBW, ep->fifosel);
251 static int pipe_buffer_setting(struct m66592 *m66592,
252 struct m66592_pipe_info *info)
254 u16 bufnum = 0, buf_bsize = 0;
260 m66592_write(m66592, info->pipe, M66592_PIPESEL);
263 pipecfg |= M66592_DIR;
264 pipecfg |= info->type;
265 pipecfg |= info->epnum;
266 switch (info->type) {
268 bufnum = 4 + (info->pipe - M66592_BASE_PIPENUM_INT);
272 bufnum = m66592->bi_bufnum +
273 (info->pipe - M66592_BASE_PIPENUM_BULK) * 16;
274 m66592->bi_bufnum += 16;
276 pipecfg |= M66592_DBLB;
278 pipecfg |= M66592_SHTNAK;
281 bufnum = m66592->bi_bufnum +
282 (info->pipe - M66592_BASE_PIPENUM_ISOC) * 16;
283 m66592->bi_bufnum += 16;
287 if (m66592->bi_bufnum > M66592_MAX_BUFNUM) {
288 printk(KERN_ERR "m66592 pipe memory is insufficient(%d)\n",
293 m66592_write(m66592, pipecfg, M66592_PIPECFG);
294 m66592_write(m66592, (buf_bsize << 10) | (bufnum), M66592_PIPEBUF);
295 m66592_write(m66592, info->maxpacket, M66592_PIPEMAXP);
298 m66592_write(m66592, info->interval, M66592_PIPEPERI);
303 static void pipe_buffer_release(struct m66592 *m66592,
304 struct m66592_pipe_info *info)
309 switch (info->type) {
311 if (is_bulk_pipe(info->pipe))
312 m66592->bi_bufnum -= 16;
315 if (is_isoc_pipe(info->pipe))
316 m66592->bi_bufnum -= 16;
320 if (is_bulk_pipe(info->pipe)) {
322 } else if (is_interrupt_pipe(info->pipe))
324 else if (is_isoc_pipe(info->pipe)) {
325 m66592->isochronous--;
326 if (info->type == M66592_BULK)
329 printk(KERN_ERR "ep_release: unexpect pipenum (%d)\n",
333 static void pipe_initialize(struct m66592_ep *ep)
335 struct m66592 *m66592 = ep->m66592;
337 m66592_mdfy(m66592, 0, M66592_CURPIPE, ep->fifosel);
339 m66592_write(m66592, M66592_ACLRM, ep->pipectr);
340 m66592_write(m66592, 0, ep->pipectr);
341 m66592_write(m66592, M66592_SQCLR, ep->pipectr);
343 m66592_mdfy(m66592, ep->pipenum, M66592_CURPIPE, ep->fifosel);
347 m66592_bset(m66592, M66592_MBW, ep->fifosel);
351 static void m66592_ep_setting(struct m66592 *m66592, struct m66592_ep *ep,
352 const struct usb_endpoint_descriptor *desc,
353 u16 pipenum, int dma)
355 if ((pipenum != 0) && dma) {
356 if (m66592->num_dma == 0) {
359 ep->fifoaddr = M66592_D0FIFO;
360 ep->fifosel = M66592_D0FIFOSEL;
361 ep->fifoctr = M66592_D0FIFOCTR;
362 ep->fifotrn = M66592_D0FIFOTRN;
363 } else if (m66592->num_dma == 1) {
366 ep->fifoaddr = M66592_D1FIFO;
367 ep->fifosel = M66592_D1FIFOSEL;
368 ep->fifoctr = M66592_D1FIFOCTR;
369 ep->fifotrn = M66592_D1FIFOTRN;
372 ep->fifoaddr = M66592_CFIFO;
373 ep->fifosel = M66592_CFIFOSEL;
374 ep->fifoctr = M66592_CFIFOCTR;
379 ep->fifoaddr = M66592_CFIFO;
380 ep->fifosel = M66592_CFIFOSEL;
381 ep->fifoctr = M66592_CFIFOCTR;
385 ep->pipectr = get_pipectr_addr(pipenum);
386 ep->pipenum = pipenum;
387 ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
388 m66592->pipenum2ep[pipenum] = ep;
389 m66592->epaddr2ep[desc->bEndpointAddress&USB_ENDPOINT_NUMBER_MASK] = ep;
390 INIT_LIST_HEAD(&ep->queue);
393 static void m66592_ep_release(struct m66592_ep *ep)
395 struct m66592 *m66592 = ep->m66592;
396 u16 pipenum = ep->pipenum;
408 static int alloc_pipe_config(struct m66592_ep *ep,
409 const struct usb_endpoint_descriptor *desc)
411 struct m66592 *m66592 = ep->m66592;
412 struct m66592_pipe_info info;
421 switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
422 case USB_ENDPOINT_XFER_BULK:
423 if (m66592->bulk >= M66592_MAX_NUM_BULK) {
424 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) {
425 printk(KERN_ERR "bulk pipe is insufficient\n");
428 info.pipe = M66592_BASE_PIPENUM_ISOC
429 + m66592->isochronous;
430 counter = &m66592->isochronous;
433 info.pipe = M66592_BASE_PIPENUM_BULK + m66592->bulk;
434 counter = &m66592->bulk;
436 info.type = M66592_BULK;
439 case USB_ENDPOINT_XFER_INT:
440 if (m66592->interrupt >= M66592_MAX_NUM_INT) {
441 printk(KERN_ERR "interrupt pipe is insufficient\n");
444 info.pipe = M66592_BASE_PIPENUM_INT + m66592->interrupt;
445 info.type = M66592_INT;
446 counter = &m66592->interrupt;
448 case USB_ENDPOINT_XFER_ISOC:
449 if (m66592->isochronous >= M66592_MAX_NUM_ISOC) {
450 printk(KERN_ERR "isochronous pipe is insufficient\n");
453 info.pipe = M66592_BASE_PIPENUM_ISOC + m66592->isochronous;
454 info.type = M66592_ISO;
455 counter = &m66592->isochronous;
458 printk(KERN_ERR "unexpect xfer type\n");
461 ep->type = info.type;
463 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
464 info.maxpacket = le16_to_cpu(desc->wMaxPacketSize);
465 info.interval = desc->bInterval;
466 if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
471 ret = pipe_buffer_setting(m66592, &info);
473 printk(KERN_ERR "pipe_buffer_setting fail\n");
478 if ((counter == &m66592->isochronous) && info.type == M66592_BULK)
481 m66592_ep_setting(m66592, ep, desc, info.pipe, dma);
487 static int free_pipe_config(struct m66592_ep *ep)
489 struct m66592 *m66592 = ep->m66592;
490 struct m66592_pipe_info info;
492 info.pipe = ep->pipenum;
493 info.type = ep->type;
494 pipe_buffer_release(m66592, &info);
495 m66592_ep_release(ep);
500 /*-------------------------------------------------------------------------*/
501 static void pipe_irq_enable(struct m66592 *m66592, u16 pipenum)
503 enable_irq_ready(m66592, pipenum);
504 enable_irq_nrdy(m66592, pipenum);
507 static void pipe_irq_disable(struct m66592 *m66592, u16 pipenum)
509 disable_irq_ready(m66592, pipenum);
510 disable_irq_nrdy(m66592, pipenum);
513 /* if complete is true, gadget driver complete function is not call */
514 static void control_end(struct m66592 *m66592, unsigned ccpl)
516 m66592->ep[0].internal_ccpl = ccpl;
517 pipe_start(m66592, 0);
518 m66592_bset(m66592, M66592_CCPL, M66592_DCPCTR);
521 static void start_ep0_write(struct m66592_ep *ep, struct m66592_request *req)
523 struct m66592 *m66592 = ep->m66592;
525 pipe_change(m66592, ep->pipenum);
526 m66592_mdfy(m66592, M66592_ISEL | M66592_PIPE0,
527 (M66592_ISEL | M66592_CURPIPE),
529 m66592_write(m66592, M66592_BCLR, ep->fifoctr);
530 if (req->req.length == 0) {
531 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
532 pipe_start(m66592, 0);
533 transfer_complete(ep, req, 0);
535 m66592_write(m66592, ~M66592_BEMP0, M66592_BEMPSTS);
536 irq_ep0_write(ep, req);
540 static void start_packet_write(struct m66592_ep *ep, struct m66592_request *req)
542 struct m66592 *m66592 = ep->m66592;
545 pipe_change(m66592, ep->pipenum);
546 disable_irq_empty(m66592, ep->pipenum);
547 pipe_start(m66592, ep->pipenum);
549 tmp = m66592_read(m66592, ep->fifoctr);
550 if (unlikely((tmp & M66592_FRDY) == 0))
551 pipe_irq_enable(m66592, ep->pipenum);
553 irq_packet_write(ep, req);
556 static void start_packet_read(struct m66592_ep *ep, struct m66592_request *req)
558 struct m66592 *m66592 = ep->m66592;
559 u16 pipenum = ep->pipenum;
561 if (ep->pipenum == 0) {
562 m66592_mdfy(m66592, M66592_PIPE0,
563 (M66592_ISEL | M66592_CURPIPE),
565 m66592_write(m66592, M66592_BCLR, ep->fifoctr);
566 pipe_start(m66592, pipenum);
567 pipe_irq_enable(m66592, pipenum);
570 m66592_bset(m66592, M66592_TRCLR, ep->fifosel);
571 pipe_change(m66592, pipenum);
572 m66592_bset(m66592, M66592_TRENB, ep->fifosel);
574 (req->req.length + ep->ep.maxpacket - 1)
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, int status)
663 __releases(m66592->lock)
664 __acquires(m66592->lock)
668 if (unlikely(ep->pipenum == 0)) {
669 if (ep->internal_ccpl) {
670 ep->internal_ccpl = 0;
675 list_del_init(&req->queue);
676 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN)
677 req->req.status = -ESHUTDOWN;
679 req->req.status = status;
681 if (!list_empty(&ep->queue))
684 spin_unlock(&ep->m66592->lock);
685 req->req.complete(&ep->ep, &req->req);
686 spin_lock(&ep->m66592->lock);
689 req = list_entry(ep->queue.next, struct m66592_request, queue);
691 start_packet(ep, req);
695 static void irq_ep0_write(struct m66592_ep *ep, struct m66592_request *req)
702 u16 pipenum = ep->pipenum;
703 struct m66592 *m66592 = ep->m66592;
705 pipe_change(m66592, pipenum);
706 m66592_bset(m66592, M66592_ISEL, ep->fifosel);
710 tmp = m66592_read(m66592, ep->fifoctr);
712 printk(KERN_ERR "pipe0 is busy. maybe cpu i/o bus"
713 "conflict. please power off this controller.");
717 } while ((tmp & M66592_FRDY) == 0);
719 /* prepare parameters */
720 bufsize = get_buffer_size(m66592, pipenum);
721 buf = req->req.buf + req->req.actual;
722 size = min(bufsize, req->req.length - req->req.actual);
727 m66592_write_fifo(m66592, ep->fifoaddr, buf, size);
728 if ((size == 0) || ((size % ep->ep.maxpacket) != 0))
729 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
732 /* update parameters */
733 req->req.actual += size;
735 /* check transfer finish */
736 if ((!req->req.zero && (req->req.actual == req->req.length))
737 || (size % ep->ep.maxpacket)
739 disable_irq_ready(m66592, pipenum);
740 disable_irq_empty(m66592, pipenum);
742 disable_irq_ready(m66592, pipenum);
743 enable_irq_empty(m66592, pipenum);
745 pipe_start(m66592, pipenum);
748 static void irq_packet_write(struct m66592_ep *ep, struct m66592_request *req)
754 u16 pipenum = ep->pipenum;
755 struct m66592 *m66592 = ep->m66592;
757 pipe_change(m66592, pipenum);
758 tmp = m66592_read(m66592, ep->fifoctr);
759 if (unlikely((tmp & M66592_FRDY) == 0)) {
760 pipe_stop(m66592, pipenum);
761 pipe_irq_disable(m66592, pipenum);
762 printk(KERN_ERR "write fifo not ready. pipnum=%d\n", pipenum);
766 /* prepare parameters */
767 bufsize = get_buffer_size(m66592, pipenum);
768 buf = req->req.buf + req->req.actual;
769 size = min(bufsize, req->req.length - req->req.actual);
773 m66592_write_fifo(m66592, ep->fifoaddr, buf, size);
775 || ((size % ep->ep.maxpacket) != 0)
776 || ((bufsize != ep->ep.maxpacket)
777 && (bufsize > size)))
778 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
781 /* update parameters */
782 req->req.actual += size;
783 /* check transfer finish */
784 if ((!req->req.zero && (req->req.actual == req->req.length))
785 || (size % ep->ep.maxpacket)
787 disable_irq_ready(m66592, pipenum);
788 enable_irq_empty(m66592, pipenum);
790 disable_irq_empty(m66592, pipenum);
791 pipe_irq_enable(m66592, pipenum);
795 static void irq_packet_read(struct m66592_ep *ep, struct m66592_request *req)
798 int rcv_len, bufsize, req_len;
801 u16 pipenum = ep->pipenum;
802 struct m66592 *m66592 = ep->m66592;
805 pipe_change(m66592, pipenum);
806 tmp = m66592_read(m66592, ep->fifoctr);
807 if (unlikely((tmp & M66592_FRDY) == 0)) {
808 req->req.status = -EPIPE;
809 pipe_stop(m66592, pipenum);
810 pipe_irq_disable(m66592, pipenum);
811 printk(KERN_ERR "read fifo not ready");
815 /* prepare parameters */
816 rcv_len = tmp & M66592_DTLN;
817 bufsize = get_buffer_size(m66592, pipenum);
819 buf = req->req.buf + req->req.actual;
820 req_len = req->req.length - req->req.actual;
821 if (rcv_len < bufsize)
822 size = min(rcv_len, req_len);
824 size = min(bufsize, req_len);
826 /* update parameters */
827 req->req.actual += size;
829 /* check transfer finish */
830 if ((!req->req.zero && (req->req.actual == req->req.length))
831 || (size % ep->ep.maxpacket)
833 pipe_stop(m66592, pipenum);
834 pipe_irq_disable(m66592, pipenum);
841 m66592_write(m66592, M66592_BCLR, ep->fifoctr);
843 m66592_read_fifo(m66592, ep->fifoaddr, buf, size);
846 if ((ep->pipenum != 0) && finish)
847 transfer_complete(ep, req, 0);
850 static void irq_pipe_ready(struct m66592 *m66592, u16 status, u16 enb)
854 struct m66592_ep *ep;
855 struct m66592_request *req;
857 if ((status & M66592_BRDY0) && (enb & M66592_BRDY0)) {
858 m66592_write(m66592, ~M66592_BRDY0, M66592_BRDYSTS);
859 m66592_mdfy(m66592, M66592_PIPE0, M66592_CURPIPE,
863 req = list_entry(ep->queue.next, struct m66592_request, queue);
864 irq_packet_read(ep, req);
866 for (pipenum = 1; pipenum < M66592_MAX_NUM_PIPE; pipenum++) {
867 check = 1 << pipenum;
868 if ((status & check) && (enb & check)) {
869 m66592_write(m66592, ~check, M66592_BRDYSTS);
870 ep = m66592->pipenum2ep[pipenum];
871 req = list_entry(ep->queue.next,
872 struct m66592_request, queue);
873 if (ep->desc->bEndpointAddress & USB_DIR_IN)
874 irq_packet_write(ep, req);
876 irq_packet_read(ep, req);
882 static void irq_pipe_empty(struct m66592 *m66592, u16 status, u16 enb)
887 struct m66592_ep *ep;
888 struct m66592_request *req;
890 if ((status & M66592_BEMP0) && (enb & M66592_BEMP0)) {
891 m66592_write(m66592, ~M66592_BEMP0, M66592_BEMPSTS);
894 req = list_entry(ep->queue.next, struct m66592_request, queue);
895 irq_ep0_write(ep, req);
897 for (pipenum = 1; pipenum < M66592_MAX_NUM_PIPE; pipenum++) {
898 check = 1 << pipenum;
899 if ((status & check) && (enb & check)) {
900 m66592_write(m66592, ~check, M66592_BEMPSTS);
901 tmp = control_reg_get(m66592, pipenum);
902 if ((tmp & M66592_INBUFM) == 0) {
903 disable_irq_empty(m66592, pipenum);
904 pipe_irq_disable(m66592, pipenum);
905 pipe_stop(m66592, pipenum);
906 ep = m66592->pipenum2ep[pipenum];
907 req = list_entry(ep->queue.next,
908 struct m66592_request,
910 if (!list_empty(&ep->queue))
911 transfer_complete(ep, req, 0);
918 static void get_status(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
919 __releases(m66592->lock)
920 __acquires(m66592->lock)
922 struct m66592_ep *ep;
925 u16 w_index = le16_to_cpu(ctrl->wIndex);
927 switch (ctrl->bRequestType & USB_RECIP_MASK) {
928 case USB_RECIP_DEVICE:
929 status = 1 << USB_DEVICE_SELF_POWERED;
931 case USB_RECIP_INTERFACE:
934 case USB_RECIP_ENDPOINT:
935 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK];
936 pid = control_reg_get_pid(m66592, ep->pipenum);
937 if (pid == M66592_PID_STALL)
938 status = 1 << USB_ENDPOINT_HALT;
943 pipe_stall(m66592, 0);
947 m66592->ep0_data = cpu_to_le16(status);
948 m66592->ep0_req->buf = &m66592->ep0_data;
949 m66592->ep0_req->length = 2;
950 /* AV: what happens if we get called again before that gets through? */
951 spin_unlock(&m66592->lock);
952 m66592_queue(m66592->gadget.ep0, m66592->ep0_req, GFP_KERNEL);
953 spin_lock(&m66592->lock);
956 static void clear_feature(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
958 switch (ctrl->bRequestType & USB_RECIP_MASK) {
959 case USB_RECIP_DEVICE:
960 control_end(m66592, 1);
962 case USB_RECIP_INTERFACE:
963 control_end(m66592, 1);
965 case USB_RECIP_ENDPOINT: {
966 struct m66592_ep *ep;
967 struct m66592_request *req;
968 u16 w_index = le16_to_cpu(ctrl->wIndex);
970 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK];
971 pipe_stop(m66592, ep->pipenum);
972 control_reg_sqclr(m66592, ep->pipenum);
974 control_end(m66592, 1);
976 req = list_entry(ep->queue.next,
977 struct m66592_request, queue);
980 if (list_empty(&ep->queue))
982 start_packet(ep, req);
983 } else if (!list_empty(&ep->queue))
984 pipe_start(m66592, ep->pipenum);
988 pipe_stall(m66592, 0);
993 static void set_feature(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
996 switch (ctrl->bRequestType & USB_RECIP_MASK) {
997 case USB_RECIP_DEVICE:
998 control_end(m66592, 1);
1000 case USB_RECIP_INTERFACE:
1001 control_end(m66592, 1);
1003 case USB_RECIP_ENDPOINT: {
1004 struct m66592_ep *ep;
1005 u16 w_index = le16_to_cpu(ctrl->wIndex);
1007 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK];
1008 pipe_stall(m66592, ep->pipenum);
1010 control_end(m66592, 1);
1014 pipe_stall(m66592, 0);
1019 /* if return value is true, call class driver's setup() */
1020 static int setup_packet(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
1022 u16 *p = (u16 *)ctrl;
1023 unsigned long offset = M66592_USBREQ;
1027 m66592_write(m66592, ~M66592_VALID, M66592_INTSTS0);
1029 for (i = 0; i < 4; i++)
1030 p[i] = m66592_read(m66592, offset + i*2);
1033 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) {
1034 switch (ctrl->bRequest) {
1035 case USB_REQ_GET_STATUS:
1036 get_status(m66592, ctrl);
1038 case USB_REQ_CLEAR_FEATURE:
1039 clear_feature(m66592, ctrl);
1041 case USB_REQ_SET_FEATURE:
1042 set_feature(m66592, ctrl);
1053 static void m66592_update_usb_speed(struct m66592 *m66592)
1055 u16 speed = get_usb_speed(m66592);
1059 m66592->gadget.speed = USB_SPEED_HIGH;
1062 m66592->gadget.speed = USB_SPEED_FULL;
1065 m66592->gadget.speed = USB_SPEED_UNKNOWN;
1066 printk(KERN_ERR "USB speed unknown\n");
1070 static void irq_device_state(struct m66592 *m66592)
1074 dvsq = m66592_read(m66592, M66592_INTSTS0) & M66592_DVSQ;
1075 m66592_write(m66592, ~M66592_DVST, M66592_INTSTS0);
1077 if (dvsq == M66592_DS_DFLT) { /* bus reset */
1078 m66592->driver->disconnect(&m66592->gadget);
1079 m66592_update_usb_speed(m66592);
1081 if (m66592->old_dvsq == M66592_DS_CNFG && dvsq != M66592_DS_CNFG)
1082 m66592_update_usb_speed(m66592);
1083 if ((dvsq == M66592_DS_CNFG || dvsq == M66592_DS_ADDS)
1084 && m66592->gadget.speed == USB_SPEED_UNKNOWN)
1085 m66592_update_usb_speed(m66592);
1087 m66592->old_dvsq = dvsq;
1090 static void irq_control_stage(struct m66592 *m66592)
1091 __releases(m66592->lock)
1092 __acquires(m66592->lock)
1094 struct usb_ctrlrequest ctrl;
1097 ctsq = m66592_read(m66592, M66592_INTSTS0) & M66592_CTSQ;
1098 m66592_write(m66592, ~M66592_CTRT, M66592_INTSTS0);
1101 case M66592_CS_IDST: {
1102 struct m66592_ep *ep;
1103 struct m66592_request *req;
1104 ep = &m66592->ep[0];
1105 req = list_entry(ep->queue.next, struct m66592_request, queue);
1106 transfer_complete(ep, req, 0);
1110 case M66592_CS_RDDS:
1111 case M66592_CS_WRDS:
1112 case M66592_CS_WRND:
1113 if (setup_packet(m66592, &ctrl)) {
1114 spin_unlock(&m66592->lock);
1115 if (m66592->driver->setup(&m66592->gadget, &ctrl) < 0)
1116 pipe_stall(m66592, 0);
1117 spin_lock(&m66592->lock);
1120 case M66592_CS_RDSS:
1121 case M66592_CS_WRSS:
1122 control_end(m66592, 0);
1125 printk(KERN_ERR "ctrl_stage: unexpect ctsq(%x)\n", ctsq);
1130 static irqreturn_t m66592_irq(int irq, void *_m66592)
1132 struct m66592 *m66592 = _m66592;
1135 u16 brdysts, nrdysts, bempsts;
1136 u16 brdyenb, nrdyenb, bempenb;
1140 spin_lock(&m66592->lock);
1142 intsts0 = m66592_read(m66592, M66592_INTSTS0);
1143 intenb0 = m66592_read(m66592, M66592_INTENB0);
1145 savepipe = m66592_read(m66592, M66592_CFIFOSEL);
1147 mask0 = intsts0 & intenb0;
1149 brdysts = m66592_read(m66592, M66592_BRDYSTS);
1150 nrdysts = m66592_read(m66592, M66592_NRDYSTS);
1151 bempsts = m66592_read(m66592, M66592_BEMPSTS);
1152 brdyenb = m66592_read(m66592, M66592_BRDYENB);
1153 nrdyenb = m66592_read(m66592, M66592_NRDYENB);
1154 bempenb = m66592_read(m66592, M66592_BEMPENB);
1156 if (mask0 & M66592_VBINT) {
1157 m66592_write(m66592, 0xffff & ~M66592_VBINT,
1159 m66592_start_xclock(m66592);
1161 /* start vbus sampling */
1162 m66592->old_vbus = m66592_read(m66592, M66592_INTSTS0)
1164 m66592->scount = M66592_MAX_SAMPLING;
1166 mod_timer(&m66592->timer,
1167 jiffies + msecs_to_jiffies(50));
1169 if (intsts0 & M66592_DVSQ)
1170 irq_device_state(m66592);
1172 if ((intsts0 & M66592_BRDY) && (intenb0 & M66592_BRDYE)
1173 && (brdysts & brdyenb)) {
1174 irq_pipe_ready(m66592, brdysts, brdyenb);
1176 if ((intsts0 & M66592_BEMP) && (intenb0 & M66592_BEMPE)
1177 && (bempsts & bempenb)) {
1178 irq_pipe_empty(m66592, bempsts, bempenb);
1181 if (intsts0 & M66592_CTRT)
1182 irq_control_stage(m66592);
1185 m66592_write(m66592, savepipe, M66592_CFIFOSEL);
1187 spin_unlock(&m66592->lock);
1191 static void m66592_timer(unsigned long _m66592)
1193 struct m66592 *m66592 = (struct m66592 *)_m66592;
1194 unsigned long flags;
1197 spin_lock_irqsave(&m66592->lock, flags);
1198 tmp = m66592_read(m66592, M66592_SYSCFG);
1199 if (!(tmp & M66592_RCKE)) {
1200 m66592_bset(m66592, M66592_RCKE | M66592_PLLC, M66592_SYSCFG);
1202 m66592_bset(m66592, M66592_SCKE, M66592_SYSCFG);
1204 if (m66592->scount > 0) {
1205 tmp = m66592_read(m66592, M66592_INTSTS0) & M66592_VBSTS;
1206 if (tmp == m66592->old_vbus) {
1208 if (m66592->scount == 0) {
1209 if (tmp == M66592_VBSTS)
1210 m66592_usb_connect(m66592);
1212 m66592_usb_disconnect(m66592);
1214 mod_timer(&m66592->timer,
1215 jiffies + msecs_to_jiffies(50));
1218 m66592->scount = M66592_MAX_SAMPLING;
1219 m66592->old_vbus = tmp;
1220 mod_timer(&m66592->timer,
1221 jiffies + msecs_to_jiffies(50));
1224 spin_unlock_irqrestore(&m66592->lock, flags);
1227 /*-------------------------------------------------------------------------*/
1228 static int m66592_enable(struct usb_ep *_ep,
1229 const struct usb_endpoint_descriptor *desc)
1231 struct m66592_ep *ep;
1233 ep = container_of(_ep, struct m66592_ep, ep);
1234 return alloc_pipe_config(ep, desc);
1237 static int m66592_disable(struct usb_ep *_ep)
1239 struct m66592_ep *ep;
1240 struct m66592_request *req;
1241 unsigned long flags;
1243 ep = container_of(_ep, struct m66592_ep, ep);
1246 while (!list_empty(&ep->queue)) {
1247 req = list_entry(ep->queue.next, struct m66592_request, queue);
1248 spin_lock_irqsave(&ep->m66592->lock, flags);
1249 transfer_complete(ep, req, -ECONNRESET);
1250 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1253 pipe_irq_disable(ep->m66592, ep->pipenum);
1254 return free_pipe_config(ep);
1257 static struct usb_request *m66592_alloc_request(struct usb_ep *_ep,
1260 struct m66592_request *req;
1262 req = kzalloc(sizeof(struct m66592_request), gfp_flags);
1266 INIT_LIST_HEAD(&req->queue);
1271 static void m66592_free_request(struct usb_ep *_ep, struct usb_request *_req)
1273 struct m66592_request *req;
1275 req = container_of(_req, struct m66592_request, req);
1279 static int m66592_queue(struct usb_ep *_ep, struct usb_request *_req,
1282 struct m66592_ep *ep;
1283 struct m66592_request *req;
1284 unsigned long flags;
1287 ep = container_of(_ep, struct m66592_ep, ep);
1288 req = container_of(_req, struct m66592_request, req);
1290 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN)
1293 spin_lock_irqsave(&ep->m66592->lock, flags);
1295 if (list_empty(&ep->queue))
1298 list_add_tail(&req->queue, &ep->queue);
1299 req->req.actual = 0;
1300 req->req.status = -EINPROGRESS;
1302 if (ep->desc == NULL) /* control */
1305 if (request && !ep->busy)
1306 start_packet(ep, req);
1309 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1314 static int m66592_dequeue(struct usb_ep *_ep, struct usb_request *_req)
1316 struct m66592_ep *ep;
1317 struct m66592_request *req;
1318 unsigned long flags;
1320 ep = container_of(_ep, struct m66592_ep, ep);
1321 req = container_of(_req, struct m66592_request, req);
1323 spin_lock_irqsave(&ep->m66592->lock, flags);
1324 if (!list_empty(&ep->queue))
1325 transfer_complete(ep, req, -ECONNRESET);
1326 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1331 static int m66592_set_halt(struct usb_ep *_ep, int value)
1333 struct m66592_ep *ep;
1334 struct m66592_request *req;
1335 unsigned long flags;
1338 ep = container_of(_ep, struct m66592_ep, ep);
1339 req = list_entry(ep->queue.next, struct m66592_request, queue);
1341 spin_lock_irqsave(&ep->m66592->lock, flags);
1342 if (!list_empty(&ep->queue)) {
1348 pipe_stall(ep->m66592, ep->pipenum);
1351 pipe_stop(ep->m66592, ep->pipenum);
1355 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1359 static void m66592_fifo_flush(struct usb_ep *_ep)
1361 struct m66592_ep *ep;
1362 unsigned long flags;
1364 ep = container_of(_ep, struct m66592_ep, ep);
1365 spin_lock_irqsave(&ep->m66592->lock, flags);
1366 if (list_empty(&ep->queue) && !ep->busy) {
1367 pipe_stop(ep->m66592, ep->pipenum);
1368 m66592_bclr(ep->m66592, M66592_BCLR, ep->fifoctr);
1370 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1373 static struct usb_ep_ops m66592_ep_ops = {
1374 .enable = m66592_enable,
1375 .disable = m66592_disable,
1377 .alloc_request = m66592_alloc_request,
1378 .free_request = m66592_free_request,
1380 .queue = m66592_queue,
1381 .dequeue = m66592_dequeue,
1383 .set_halt = m66592_set_halt,
1384 .fifo_flush = m66592_fifo_flush,
1387 /*-------------------------------------------------------------------------*/
1388 static struct m66592 *the_controller;
1390 int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1392 struct m66592 *m66592 = the_controller;
1396 || driver->speed != USB_SPEED_HIGH
1405 /* hook up the driver */
1406 driver->driver.bus = NULL;
1407 m66592->driver = driver;
1408 m66592->gadget.dev.driver = &driver->driver;
1410 retval = device_add(&m66592->gadget.dev);
1412 printk(KERN_ERR "device_add error (%d)\n", retval);
1416 retval = driver->bind (&m66592->gadget);
1418 printk(KERN_ERR "bind to driver error (%d)\n", retval);
1419 device_del(&m66592->gadget.dev);
1423 m66592_bset(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0);
1424 if (m66592_read(m66592, M66592_INTSTS0) & M66592_VBSTS) {
1425 m66592_start_xclock(m66592);
1426 /* start vbus sampling */
1427 m66592->old_vbus = m66592_read(m66592,
1428 M66592_INTSTS0) & M66592_VBSTS;
1429 m66592->scount = M66592_MAX_SAMPLING;
1430 mod_timer(&m66592->timer, jiffies + msecs_to_jiffies(50));
1436 m66592->driver = NULL;
1437 m66592->gadget.dev.driver = NULL;
1441 EXPORT_SYMBOL(usb_gadget_register_driver);
1443 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1445 struct m66592 *m66592 = the_controller;
1446 unsigned long flags;
1448 if (driver != m66592->driver || !driver->unbind)
1451 spin_lock_irqsave(&m66592->lock, flags);
1452 if (m66592->gadget.speed != USB_SPEED_UNKNOWN)
1453 m66592_usb_disconnect(m66592);
1454 spin_unlock_irqrestore(&m66592->lock, flags);
1456 m66592_bclr(m66592, M66592_VBSE | M66592_URST, M66592_INTENB0);
1458 driver->unbind(&m66592->gadget);
1460 init_controller(m66592);
1461 disable_controller(m66592);
1463 device_del(&m66592->gadget.dev);
1464 m66592->driver = NULL;
1467 EXPORT_SYMBOL(usb_gadget_unregister_driver);
1469 /*-------------------------------------------------------------------------*/
1470 static int m66592_get_frame(struct usb_gadget *_gadget)
1472 struct m66592 *m66592 = gadget_to_m66592(_gadget);
1473 return m66592_read(m66592, M66592_FRMNUM) & 0x03FF;
1476 static struct usb_gadget_ops m66592_gadget_ops = {
1477 .get_frame = m66592_get_frame,
1480 static int __exit m66592_remove(struct platform_device *pdev)
1482 struct m66592 *m66592 = dev_get_drvdata(&pdev->dev);
1484 del_timer_sync(&m66592->timer);
1485 iounmap(m66592->reg);
1486 free_irq(platform_get_irq(pdev, 0), m66592);
1487 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
1492 static void nop_completion(struct usb_ep *ep, struct usb_request *r)
1496 #define resource_len(r) (((r)->end - (r)->start) + 1)
1498 static int __init m66592_probe(struct platform_device *pdev)
1500 struct resource *res;
1502 void __iomem *reg = NULL;
1503 struct m66592 *m66592 = NULL;
1507 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1511 printk(KERN_ERR "platform_get_resource_byname error.\n");
1515 irq = platform_get_irq(pdev, 0);
1518 printk(KERN_ERR "platform_get_irq error.\n");
1522 reg = ioremap(res->start, resource_len(res));
1525 printk(KERN_ERR "ioremap error.\n");
1529 /* initialize ucd */
1530 m66592 = kzalloc(sizeof(struct m66592), GFP_KERNEL);
1531 if (m66592 == NULL) {
1532 printk(KERN_ERR "kzalloc error\n");
1536 spin_lock_init(&m66592->lock);
1537 dev_set_drvdata(&pdev->dev, m66592);
1539 m66592->gadget.ops = &m66592_gadget_ops;
1540 device_initialize(&m66592->gadget.dev);
1541 strcpy(m66592->gadget.dev.bus_id, "gadget");
1542 m66592->gadget.is_dualspeed = 1;
1543 m66592->gadget.dev.parent = &pdev->dev;
1544 m66592->gadget.dev.dma_mask = pdev->dev.dma_mask;
1545 m66592->gadget.dev.release = pdev->dev.release;
1546 m66592->gadget.name = udc_name;
1548 init_timer(&m66592->timer);
1549 m66592->timer.function = m66592_timer;
1550 m66592->timer.data = (unsigned long)m66592;
1553 m66592->bi_bufnum = M66592_BASE_BUFNUM;
1555 ret = request_irq(irq, m66592_irq, IRQF_DISABLED | IRQF_SHARED,
1558 printk(KERN_ERR "request_irq error (%d)\n", ret);
1562 INIT_LIST_HEAD(&m66592->gadget.ep_list);
1563 m66592->gadget.ep0 = &m66592->ep[0].ep;
1564 INIT_LIST_HEAD(&m66592->gadget.ep0->ep_list);
1565 for (i = 0; i < M66592_MAX_NUM_PIPE; i++) {
1566 struct m66592_ep *ep = &m66592->ep[i];
1569 INIT_LIST_HEAD(&m66592->ep[i].ep.ep_list);
1570 list_add_tail(&m66592->ep[i].ep.ep_list,
1571 &m66592->gadget.ep_list);
1573 ep->m66592 = m66592;
1574 INIT_LIST_HEAD(&ep->queue);
1575 ep->ep.name = m66592_ep_name[i];
1576 ep->ep.ops = &m66592_ep_ops;
1577 ep->ep.maxpacket = 512;
1579 m66592->ep[0].ep.maxpacket = 64;
1580 m66592->ep[0].pipenum = 0;
1581 m66592->ep[0].fifoaddr = M66592_CFIFO;
1582 m66592->ep[0].fifosel = M66592_CFIFOSEL;
1583 m66592->ep[0].fifoctr = M66592_CFIFOCTR;
1584 m66592->ep[0].fifotrn = 0;
1585 m66592->ep[0].pipectr = get_pipectr_addr(0);
1586 m66592->pipenum2ep[0] = &m66592->ep[0];
1587 m66592->epaddr2ep[0] = &m66592->ep[0];
1589 the_controller = m66592;
1591 m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL);
1592 if (m66592->ep0_req == NULL)
1594 m66592->ep0_req->complete = nop_completion;
1596 init_controller(m66592);
1598 dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION);
1602 free_irq(irq, m66592);
1605 if (m66592->ep0_req)
1606 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
1615 /*-------------------------------------------------------------------------*/
1616 static struct platform_driver m66592_driver = {
1617 .remove = __exit_p(m66592_remove),
1619 .name = (char *) udc_name,
1623 static int __init m66592_udc_init(void)
1625 return platform_driver_probe(&m66592_driver, m66592_probe);
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);