4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #include <linux/module.h>
19 #include <linux/platform_device.h>
20 #include <linux/usb/ch9.h>
21 #include <linux/usb/gadget.h>
27 struct usbhsg_request {
28 struct usb_request req;
32 #define EP_NAME_SIZE 8
36 struct usbhs_pipe *pipe;
38 char ep_name[EP_NAME_SIZE];
40 struct usbhsg_gpriv *gpriv;
41 struct usbhs_pkt_handle *handler;
45 struct usb_gadget gadget;
48 struct usbhsg_uep *uep;
51 struct usb_gadget_driver *driver;
54 #define USBHSG_STATUS_STARTED (1 << 0)
55 #define USBHSG_STATUS_REGISTERD (1 << 1)
56 #define USBHSG_STATUS_WEDGE (1 << 2)
59 struct usbhsg_recip_handle {
61 int (*device)(struct usbhs_priv *priv, struct usbhsg_uep *uep,
62 struct usb_ctrlrequest *ctrl);
63 int (*interface)(struct usbhs_priv *priv, struct usbhsg_uep *uep,
64 struct usb_ctrlrequest *ctrl);
65 int (*endpoint)(struct usbhs_priv *priv, struct usbhsg_uep *uep,
66 struct usb_ctrlrequest *ctrl);
72 #define usbhsg_priv_to_gpriv(priv) \
74 usbhs_mod_get(priv, USBHS_GADGET), \
75 struct usbhsg_gpriv, mod)
77 #define __usbhsg_for_each_uep(start, pos, g, i) \
78 for (i = start, pos = (g)->uep; \
80 i++, pos = (g)->uep + i)
82 #define usbhsg_for_each_uep(pos, gpriv, i) \
83 __usbhsg_for_each_uep(1, pos, gpriv, i)
85 #define usbhsg_for_each_uep_with_dcp(pos, gpriv, i) \
86 __usbhsg_for_each_uep(0, pos, gpriv, i)
88 #define usbhsg_gadget_to_gpriv(g)\
89 container_of(g, struct usbhsg_gpriv, gadget)
91 #define usbhsg_req_to_ureq(r)\
92 container_of(r, struct usbhsg_request, req)
94 #define usbhsg_ep_to_uep(e) container_of(e, struct usbhsg_uep, ep)
95 #define usbhsg_gpriv_to_dev(gp) usbhs_priv_to_dev((gp)->mod.priv)
96 #define usbhsg_gpriv_to_priv(gp) ((gp)->mod.priv)
97 #define usbhsg_gpriv_to_dcp(gp) ((gp)->uep)
98 #define usbhsg_gpriv_to_nth_uep(gp, i) ((gp)->uep + i)
99 #define usbhsg_uep_to_gpriv(u) ((u)->gpriv)
100 #define usbhsg_uep_to_pipe(u) ((u)->pipe)
101 #define usbhsg_pipe_to_uep(p) ((p)->mod_private)
102 #define usbhsg_is_dcp(u) ((u) == usbhsg_gpriv_to_dcp((u)->gpriv))
104 #define usbhsg_ureq_to_pkt(u) (&(u)->pkt)
105 #define usbhsg_pkt_to_ureq(i) \
106 container_of(i, struct usbhsg_request, pkt)
108 #define usbhsg_is_not_connected(gp) ((gp)->gadget.speed == USB_SPEED_UNKNOWN)
111 #define usbhsg_status_init(gp) do {(gp)->status = 0; } while (0)
112 #define usbhsg_status_set(gp, b) (gp->status |= b)
113 #define usbhsg_status_clr(gp, b) (gp->status &= ~b)
114 #define usbhsg_status_has(gp, b) (gp->status & b)
119 static void usbhsg_queue_push(struct usbhsg_uep *uep,
120 struct usbhsg_request *ureq)
122 struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
123 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
124 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
125 struct usbhs_pkt *pkt = usbhsg_ureq_to_pkt(ureq);
126 struct usb_request *req = &ureq->req;
128 usbhs_pkt_push(pipe, pkt, uep->handler,
129 req->buf, req->length, req->zero);
131 req->status = -EINPROGRESS;
133 dev_dbg(dev, "pipe %d : queue push (%d)\n",
134 usbhs_pipe_number(pipe),
138 static void usbhsg_queue_start(struct usbhsg_uep *uep)
140 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
142 usbhs_pkt_start(pipe);
145 static void usbhsg_queue_pop(struct usbhsg_uep *uep,
146 struct usbhsg_request *ureq,
149 struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
150 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
151 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
153 dev_dbg(dev, "pipe %d : queue pop\n", usbhs_pipe_number(pipe));
155 ureq->req.status = status;
156 ureq->req.complete(&uep->ep, &ureq->req);
160 usbhsg_queue_start(uep);
163 static void usbhsg_queue_done(struct usbhs_pkt *pkt)
165 struct usbhs_pipe *pipe = pkt->pipe;
166 struct usbhsg_uep *uep = usbhsg_pipe_to_uep(pipe);
167 struct usbhsg_request *ureq = usbhsg_pkt_to_ureq(pkt);
169 ureq->req.actual = pkt->actual;
171 usbhsg_queue_pop(uep, ureq, 0);
175 * USB_TYPE_STANDARD / clear feature functions
177 static int usbhsg_recip_handler_std_control_done(struct usbhs_priv *priv,
178 struct usbhsg_uep *uep,
179 struct usb_ctrlrequest *ctrl)
181 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
182 struct usbhsg_uep *dcp = usbhsg_gpriv_to_dcp(gpriv);
183 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(dcp);
185 usbhs_dcp_control_transfer_done(pipe);
190 static int usbhsg_recip_handler_std_clear_endpoint(struct usbhs_priv *priv,
191 struct usbhsg_uep *uep,
192 struct usb_ctrlrequest *ctrl)
194 struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
195 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
197 if (!usbhsg_status_has(gpriv, USBHSG_STATUS_WEDGE)) {
198 usbhs_pipe_disable(pipe);
199 usbhs_pipe_clear_sequence(pipe);
200 usbhs_pipe_enable(pipe);
203 usbhsg_recip_handler_std_control_done(priv, uep, ctrl);
208 struct usbhsg_recip_handle req_clear_feature = {
209 .name = "clear feature",
210 .device = usbhsg_recip_handler_std_control_done,
211 .interface = usbhsg_recip_handler_std_control_done,
212 .endpoint = usbhsg_recip_handler_std_clear_endpoint,
218 static int usbhsg_recip_run_handle(struct usbhs_priv *priv,
219 struct usbhsg_recip_handle *handler,
220 struct usb_ctrlrequest *ctrl)
222 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
223 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
224 struct usbhsg_uep *uep;
225 int recip = ctrl->bRequestType & USB_RECIP_MASK;
226 int nth = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK;
228 int (*func)(struct usbhs_priv *priv, struct usbhsg_uep *uep,
229 struct usb_ctrlrequest *ctrl);
232 uep = usbhsg_gpriv_to_nth_uep(gpriv, nth);
233 if (!usbhsg_uep_to_pipe(uep)) {
234 dev_err(dev, "wrong recip request\n");
236 goto usbhsg_recip_run_handle_end;
240 case USB_RECIP_DEVICE:
242 func = handler->device;
244 case USB_RECIP_INTERFACE:
246 func = handler->interface;
248 case USB_RECIP_ENDPOINT:
250 func = handler->endpoint;
253 dev_warn(dev, "unsupported RECIP(%d)\n", recip);
261 dev_dbg(dev, "%s (pipe %d :%s)\n", handler->name, nth, msg);
263 /******************** spin lock ********************/
264 usbhs_lock(priv, flags);
265 ret = func(priv, uep, ctrl);
266 usbhs_unlock(priv, flags);
267 /******************** spin unlock ******************/
270 usbhsg_recip_run_handle_end:
271 usbhsg_queue_start(uep);
279 * it will be called from usbhs_interrupt
281 static int usbhsg_irq_dev_state(struct usbhs_priv *priv,
282 struct usbhs_irq_state *irq_state)
284 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
285 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
287 gpriv->gadget.speed = usbhs_status_get_usb_speed(irq_state);
289 dev_dbg(dev, "state = %x : speed : %d\n",
290 usbhs_status_get_device_state(irq_state),
291 gpriv->gadget.speed);
296 static int usbhsg_irq_ctrl_stage(struct usbhs_priv *priv,
297 struct usbhs_irq_state *irq_state)
299 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
300 struct usbhsg_uep *dcp = usbhsg_gpriv_to_dcp(gpriv);
301 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(dcp);
302 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
303 struct usb_ctrlrequest ctrl;
304 struct usbhsg_recip_handle *recip_handler = NULL;
305 int stage = usbhs_status_get_ctrl_stage(irq_state);
308 dev_dbg(dev, "stage = %d\n", stage);
314 * - "Interrupt Function"
315 * - "Control Transfer Stage Transition Interrupt"
316 * - Fig. "Control Transfer Stage Transitions"
320 case READ_DATA_STAGE:
321 dcp->handler = &usbhs_fifo_push_handler;
323 case WRITE_DATA_STAGE:
324 dcp->handler = &usbhs_fifo_pop_handler;
326 case NODATA_STATUS_STAGE:
327 dcp->handler = &usbhs_ctrl_stage_end_handler;
336 usbhs_usbreq_get_val(priv, &ctrl);
338 switch (ctrl.bRequestType & USB_TYPE_MASK) {
339 case USB_TYPE_STANDARD:
340 switch (ctrl.bRequest) {
341 case USB_REQ_CLEAR_FEATURE:
342 recip_handler = &req_clear_feature;
348 * setup stage / run recip
351 ret = usbhsg_recip_run_handle(priv, recip_handler, &ctrl);
353 ret = gpriv->driver->setup(&gpriv->gadget, &ctrl);
356 usbhs_pipe_stall(pipe);
366 static int usbhsg_pipe_disable(struct usbhsg_uep *uep)
368 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
369 struct usbhs_pkt *pkt;
371 usbhs_pipe_disable(pipe);
374 pkt = usbhs_pkt_pop(pipe, NULL);
382 static void usbhsg_uep_init(struct usbhsg_gpriv *gpriv)
385 struct usbhsg_uep *uep;
387 usbhsg_for_each_uep_with_dcp(uep, gpriv, i)
396 static int usbhsg_ep_enable(struct usb_ep *ep,
397 const struct usb_endpoint_descriptor *desc)
399 struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
400 struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
401 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
402 struct usbhs_pipe *pipe;
406 * if it already have pipe,
412 pipe = usbhs_pipe_malloc(priv, desc);
415 pipe->mod_private = uep;
417 if (usb_endpoint_dir_in(desc))
418 uep->handler = &usbhs_fifo_push_handler;
420 uep->handler = &usbhs_fifo_pop_handler;
428 static int usbhsg_ep_disable(struct usb_ep *ep)
430 struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
432 return usbhsg_pipe_disable(uep);
435 static struct usb_request *usbhsg_ep_alloc_request(struct usb_ep *ep,
438 struct usbhsg_request *ureq;
440 ureq = kzalloc(sizeof *ureq, gfp_flags);
444 usbhs_pkt_init(usbhsg_ureq_to_pkt(ureq));
449 static void usbhsg_ep_free_request(struct usb_ep *ep,
450 struct usb_request *req)
452 struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);
454 WARN_ON(!list_empty(&ureq->pkt.node));
458 static int usbhsg_ep_queue(struct usb_ep *ep, struct usb_request *req,
461 struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
462 struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
463 struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);
464 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
467 if (usbhsg_is_not_connected(gpriv) ||
468 unlikely(!gpriv->driver) ||
472 usbhsg_queue_push(uep, ureq);
473 usbhsg_queue_start(uep);
478 static int usbhsg_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
480 struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
481 struct usbhsg_request *ureq = usbhsg_req_to_ureq(req);
482 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
484 usbhs_pkt_pop(pipe, usbhsg_ureq_to_pkt(ureq));
485 usbhsg_queue_pop(uep, ureq, -ECONNRESET);
490 static int __usbhsg_ep_set_halt_wedge(struct usb_ep *ep, int halt, int wedge)
492 struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
493 struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
494 struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep);
495 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
496 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
499 usbhsg_pipe_disable(uep);
501 dev_dbg(dev, "set halt %d (pipe %d)\n",
502 halt, usbhs_pipe_number(pipe));
504 /******************** spin lock ********************/
505 usbhs_lock(priv, flags);
508 usbhs_pipe_stall(pipe);
510 usbhs_pipe_disable(pipe);
513 usbhsg_status_set(gpriv, USBHSG_STATUS_WEDGE);
515 usbhsg_status_clr(gpriv, USBHSG_STATUS_WEDGE);
517 usbhs_unlock(priv, flags);
518 /******************** spin unlock ******************/
523 static int usbhsg_ep_set_halt(struct usb_ep *ep, int value)
525 return __usbhsg_ep_set_halt_wedge(ep, value, 0);
528 static int usbhsg_ep_set_wedge(struct usb_ep *ep)
530 return __usbhsg_ep_set_halt_wedge(ep, 1, 1);
533 static struct usb_ep_ops usbhsg_ep_ops = {
534 .enable = usbhsg_ep_enable,
535 .disable = usbhsg_ep_disable,
537 .alloc_request = usbhsg_ep_alloc_request,
538 .free_request = usbhsg_ep_free_request,
540 .queue = usbhsg_ep_queue,
541 .dequeue = usbhsg_ep_dequeue,
543 .set_halt = usbhsg_ep_set_halt,
544 .set_wedge = usbhsg_ep_set_wedge,
548 * usb module start/end
550 static int usbhsg_try_start(struct usbhs_priv *priv, u32 status)
552 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
553 struct usbhsg_uep *dcp = usbhsg_gpriv_to_dcp(gpriv);
554 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
555 struct device *dev = usbhs_priv_to_dev(priv);
559 /******************** spin lock ********************/
560 usbhs_lock(priv, flags);
562 usbhsg_status_set(gpriv, status);
563 if (!(usbhsg_status_has(gpriv, USBHSG_STATUS_STARTED) &&
564 usbhsg_status_has(gpriv, USBHSG_STATUS_REGISTERD)))
565 ret = -1; /* not ready */
567 usbhs_unlock(priv, flags);
568 /******************** spin unlock ********************/
571 return 0; /* not ready is not error */
574 * enable interrupt and systems if ready
576 dev_dbg(dev, "start gadget\n");
579 * pipe initialize and enable DCP
581 usbhs_pipe_init(priv,
583 usbhs_fifo_init(priv);
584 usbhsg_uep_init(gpriv);
587 dcp->pipe = usbhs_dcp_malloc(priv);
588 dcp->pipe->mod_private = dcp;
591 * system config enble
596 usbhs_sys_hispeed_ctrl(priv, 1);
597 usbhs_sys_function_ctrl(priv, 1);
598 usbhs_sys_usb_ctrl(priv, 1);
601 * enable irq callback
603 mod->irq_dev_state = usbhsg_irq_dev_state;
604 mod->irq_ctrl_stage = usbhsg_irq_ctrl_stage;
605 usbhs_irq_callback_update(priv, mod);
610 static int usbhsg_try_stop(struct usbhs_priv *priv, u32 status)
612 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);
613 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
614 struct usbhsg_uep *dcp = usbhsg_gpriv_to_dcp(gpriv);
615 struct device *dev = usbhs_priv_to_dev(priv);
619 /******************** spin lock ********************/
620 usbhs_lock(priv, flags);
622 usbhsg_status_clr(gpriv, status);
623 if (!usbhsg_status_has(gpriv, USBHSG_STATUS_STARTED) &&
624 !usbhsg_status_has(gpriv, USBHSG_STATUS_REGISTERD))
625 ret = -1; /* already done */
627 usbhs_unlock(priv, flags);
628 /******************** spin unlock ********************/
631 return 0; /* already done is not error */
634 * disable interrupt and systems if 1st try
636 usbhs_fifo_quit(priv);
638 /* disable all irq */
639 mod->irq_dev_state = NULL;
640 mod->irq_ctrl_stage = NULL;
641 usbhs_irq_callback_update(priv, mod);
643 gpriv->gadget.speed = USB_SPEED_UNKNOWN;
646 usbhs_sys_hispeed_ctrl(priv, 0);
647 usbhs_sys_function_ctrl(priv, 0);
648 usbhs_sys_usb_ctrl(priv, 0);
650 usbhsg_pipe_disable(dcp);
653 gpriv->driver->disconnect)
654 gpriv->driver->disconnect(&gpriv->gadget);
656 dev_dbg(dev, "stop gadget\n");
666 struct usbhsg_gpriv *the_controller;
667 int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
668 int (*bind)(struct usb_gadget *))
670 struct usbhsg_gpriv *gpriv = the_controller;
671 struct usbhs_priv *priv;
678 driver->speed != USB_SPEED_HIGH)
685 dev = usbhsg_gpriv_to_dev(gpriv);
686 priv = usbhsg_gpriv_to_priv(gpriv);
688 /* first hook up the driver ... */
689 gpriv->driver = driver;
690 gpriv->gadget.dev.driver = &driver->driver;
692 ret = device_add(&gpriv->gadget.dev);
694 dev_err(dev, "device_add error %d\n", ret);
698 ret = bind(&gpriv->gadget);
700 dev_err(dev, "bind to driver %s error %d\n",
701 driver->driver.name, ret);
705 dev_dbg(dev, "bind %s\n", driver->driver.name);
707 return usbhsg_try_start(priv, USBHSG_STATUS_REGISTERD);
710 device_del(&gpriv->gadget.dev);
712 gpriv->driver = NULL;
713 gpriv->gadget.dev.driver = NULL;
717 EXPORT_SYMBOL(usb_gadget_probe_driver);
719 int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
721 struct usbhsg_gpriv *gpriv = the_controller;
722 struct usbhs_priv *priv;
723 struct device *dev = usbhsg_gpriv_to_dev(gpriv);
730 driver != gpriv->driver)
733 dev = usbhsg_gpriv_to_dev(gpriv);
734 priv = usbhsg_gpriv_to_priv(gpriv);
736 usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD);
737 device_del(&gpriv->gadget.dev);
738 gpriv->driver = NULL;
740 if (driver->disconnect)
741 driver->disconnect(&gpriv->gadget);
743 driver->unbind(&gpriv->gadget);
744 dev_dbg(dev, "unbind %s\n", driver->driver.name);
748 EXPORT_SYMBOL(usb_gadget_unregister_driver);
753 static int usbhsg_get_frame(struct usb_gadget *gadget)
755 struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
756 struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
758 return usbhs_frame_get_num(priv);
761 static struct usb_gadget_ops usbhsg_gadget_ops = {
762 .get_frame = usbhsg_get_frame,
765 static int usbhsg_start(struct usbhs_priv *priv)
767 return usbhsg_try_start(priv, USBHSG_STATUS_STARTED);
770 static int usbhsg_stop(struct usbhs_priv *priv)
772 return usbhsg_try_stop(priv, USBHSG_STATUS_STARTED);
775 int __devinit usbhs_mod_gadget_probe(struct usbhs_priv *priv)
777 struct usbhsg_gpriv *gpriv;
778 struct usbhsg_uep *uep;
779 struct device *dev = usbhs_priv_to_dev(priv);
780 int pipe_size = usbhs_get_dparam(priv, pipe_size);
783 gpriv = kzalloc(sizeof(struct usbhsg_gpriv), GFP_KERNEL);
785 dev_err(dev, "Could not allocate gadget priv\n");
789 uep = kzalloc(sizeof(struct usbhsg_uep) * pipe_size, GFP_KERNEL);
791 dev_err(dev, "Could not allocate ep\n");
792 goto usbhs_mod_gadget_probe_err_gpriv;
798 * There is no guarantee that it is possible to access usb module here.
799 * Don't accesses to it.
800 * The accesse will be enable after "usbhsg_start"
806 usbhs_mod_register(priv, &gpriv->mod, USBHS_GADGET);
809 gpriv->mod.name = "gadget";
810 gpriv->mod.start = usbhsg_start;
811 gpriv->mod.stop = usbhsg_stop;
813 gpriv->uep_size = pipe_size;
814 usbhsg_status_init(gpriv);
819 device_initialize(&gpriv->gadget.dev);
820 dev_set_name(&gpriv->gadget.dev, "gadget");
821 gpriv->gadget.dev.parent = dev;
822 gpriv->gadget.name = "renesas_usbhs_udc";
823 gpriv->gadget.ops = &usbhsg_gadget_ops;
824 gpriv->gadget.is_dualspeed = 1;
826 INIT_LIST_HEAD(&gpriv->gadget.ep_list);
831 usbhsg_for_each_uep_with_dcp(uep, gpriv, i) {
833 snprintf(uep->ep_name, EP_NAME_SIZE, "ep%d", i);
835 uep->ep.name = uep->ep_name;
836 uep->ep.ops = &usbhsg_ep_ops;
837 INIT_LIST_HEAD(&uep->ep.ep_list);
840 if (usbhsg_is_dcp(uep)) {
841 gpriv->gadget.ep0 = &uep->ep;
842 uep->ep.maxpacket = 64;
844 /* init normal pipe */
846 uep->ep.maxpacket = 512;
847 list_add_tail(&uep->ep.ep_list, &gpriv->gadget.ep_list);
851 the_controller = gpriv;
853 dev_info(dev, "gadget probed\n");
857 usbhs_mod_gadget_probe_err_gpriv:
863 void __devexit usbhs_mod_gadget_remove(struct usbhs_priv *priv)
865 struct usbhsg_gpriv *gpriv = usbhsg_priv_to_gpriv(priv);