Lines Matching full:mtu

15 __releases(mep->mtu->lock)  in mtu3_req_complete()
16 __acquires(mep->mtu->lock) in mtu3_req_complete()
19 struct mtu3 *mtu = mreq->mtu; in mtu3_req_complete() local
29 usb_gadget_unmap_request(&mtu->g, req, mep->is_in); in mtu3_req_complete()
31 dev_dbg(mtu->dev, "%s complete req: %p, sts %d, %d/%d\n", in mtu3_req_complete()
34 spin_unlock(&mtu->lock); in mtu3_req_complete()
36 spin_lock(&mtu->lock); in mtu3_req_complete()
46 dev_dbg(mep->mtu->dev, "abort %s's req: sts %d\n", mep->name, status); in nuke()
63 struct mtu3 *mtu = mep->mtu; in mtu3_ep_enable() local
74 switch (mtu->g.speed) { in mtu3_ep_enable()
107 dev_dbg(mtu->dev, "%s maxp:%d, interval:%d, burst:%d, mult:%d\n", in mtu3_ep_enable()
115 mep->slot = usb_endpoint_xfer_int(desc) ? 0 : mtu->slot; in mtu3_ep_enable()
117 ret = mtu3_config_ep(mtu, mep, interval, burst, mult); in mtu3_ep_enable()
123 mtu3_deconfig_ep(mtu, mep); in mtu3_ep_enable()
134 struct mtu3 *mtu = mep->mtu; in mtu3_ep_disable() local
139 mtu3_deconfig_ep(mtu, mep); in mtu3_ep_disable()
155 struct mtu3 *mtu; in mtu3_gadget_ep_enable() local
169 mtu = mep->mtu; in mtu3_gadget_ep_enable()
178 dev_dbg(mtu->dev, "%s %s\n", __func__, ep->name); in mtu3_gadget_ep_enable()
181 dev_WARN_ONCE(mtu->dev, true, "%s is already enabled\n", in mtu3_gadget_ep_enable()
186 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_ep_enable()
195 mtu->active_ep++; in mtu3_gadget_ep_enable()
198 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_ep_enable()
200 dev_dbg(mtu->dev, "%s active_ep=%d\n", __func__, mtu->active_ep); in mtu3_gadget_ep_enable()
209 struct mtu3 *mtu = mep->mtu; in mtu3_gadget_ep_disable() local
212 dev_dbg(mtu->dev, "%s %s\n", __func__, mep->name); in mtu3_gadget_ep_disable()
216 dev_warn(mtu->dev, "%s is already disabled\n", mep->name); in mtu3_gadget_ep_disable()
220 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_ep_disable()
223 mtu->active_ep--; in mtu3_gadget_ep_disable()
224 spin_unlock_irqrestore(&(mtu->lock), flags); in mtu3_gadget_ep_disable()
226 dev_dbg(mtu->dev, "%s active_ep=%d, mtu3 is_active=%d\n", in mtu3_gadget_ep_disable()
227 __func__, mtu->active_ep, mtu->is_active); in mtu3_gadget_ep_disable()
263 struct mtu3 *mtu = mep->mtu; in mtu3_gadget_queue() local
273 dev_dbg(mtu->dev, "%s %s EP%d(%s), req=%p, maxp=%d, len#%d\n", in mtu3_gadget_queue()
278 (mtu->gen2cp && req->length > GPD_BUF_SIZE_EL)) { in mtu3_gadget_queue()
279 dev_warn(mtu->dev, in mtu3_gadget_queue()
281 mtu->gen2cp ? GPD_BUF_SIZE_EL : GPD_BUF_SIZE, in mtu3_gadget_queue()
288 dev_dbg(mtu->dev, "req=%p queued to %s while it's disabled\n", in mtu3_gadget_queue()
293 mreq->mtu = mtu; in mtu3_gadget_queue()
297 ret = usb_gadget_map_request(&mtu->g, req, mep->is_in); in mtu3_gadget_queue()
299 dev_err(mtu->dev, "dma mapping failed\n"); in mtu3_gadget_queue()
303 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_queue()
315 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_queue()
326 struct mtu3 *mtu = mep->mtu; in mtu3_gadget_dequeue() local
333 dev_dbg(mtu->dev, "%s : req=%p\n", __func__, req); in mtu3_gadget_dequeue()
336 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_dequeue()
343 dev_dbg(mtu->dev, "req=%p not queued to %s\n", req, ep->name); in mtu3_gadget_dequeue()
353 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_dequeue()
365 struct mtu3 *mtu = mep->mtu; in mtu3_gadget_ep_set_halt() local
370 dev_dbg(mtu->dev, "%s : %s...", __func__, ep->name); in mtu3_gadget_ep_set_halt()
372 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_ep_set_halt()
387 dev_dbg(mtu->dev, "req in progress, cannot halt %s\n", in mtu3_gadget_ep_set_halt()
396 dev_dbg(mtu->dev, "%s %s stall\n", ep->name, value ? "set" : "clear"); in mtu3_gadget_ep_set_halt()
401 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_ep_set_halt()
430 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_get_frame() local
432 return (int)mtu3_readl(mtu->mac_base, U3D_USB20_FRAME_NUM); in mtu3_gadget_get_frame()
435 static void function_wake_notif(struct mtu3 *mtu, u8 intf) in function_wake_notif() argument
437 mtu3_writel(mtu->mac_base, U3D_DEV_NOTIF_0, in function_wake_notif()
439 mtu3_setbits(mtu->mac_base, U3D_DEV_NOTIF_0, SEND_DEV_NOTIF); in function_wake_notif()
444 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_wakeup() local
447 dev_dbg(mtu->dev, "%s\n", __func__); in mtu3_gadget_wakeup()
450 if (!mtu->may_wakeup) in mtu3_gadget_wakeup()
453 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_wakeup()
454 if (mtu->g.speed >= USB_SPEED_SUPER) { in mtu3_gadget_wakeup()
459 mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT); in mtu3_gadget_wakeup()
466 function_wake_notif(mtu, 0); in mtu3_gadget_wakeup()
468 mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); in mtu3_gadget_wakeup()
469 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_wakeup()
471 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_wakeup()
472 mtu3_clrbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); in mtu3_gadget_wakeup()
474 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_wakeup()
481 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_set_self_powered() local
483 mtu->is_self_powered = !!is_selfpowered; in mtu3_gadget_set_self_powered()
489 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_pullup() local
492 dev_dbg(mtu->dev, "%s (%s) for %sactive device\n", __func__, in mtu3_gadget_pullup()
493 is_on ? "on" : "off", mtu->is_active ? "" : "in"); in mtu3_gadget_pullup()
495 pm_runtime_get_sync(mtu->dev); in mtu3_gadget_pullup()
498 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_pullup()
501 if (!mtu->is_active) { in mtu3_gadget_pullup()
503 mtu->softconnect = is_on; in mtu3_gadget_pullup()
504 } else if (is_on != mtu->softconnect) { in mtu3_gadget_pullup()
505 mtu->softconnect = is_on; in mtu3_gadget_pullup()
506 mtu3_dev_on_off(mtu, is_on); in mtu3_gadget_pullup()
509 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_pullup()
510 pm_runtime_put(mtu->dev); in mtu3_gadget_pullup()
518 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_start() local
521 if (mtu->gadget_driver) { in mtu3_gadget_start()
522 dev_err(mtu->dev, "%s is already bound to %s\n", in mtu3_gadget_start()
523 mtu->g.name, mtu->gadget_driver->driver.name); in mtu3_gadget_start()
527 dev_dbg(mtu->dev, "bind driver %s\n", driver->function); in mtu3_gadget_start()
528 pm_runtime_get_sync(mtu->dev); in mtu3_gadget_start()
530 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_start()
532 mtu->softconnect = 0; in mtu3_gadget_start()
533 mtu->gadget_driver = driver; in mtu3_gadget_start()
535 if (mtu->ssusb->dr_mode == USB_DR_MODE_PERIPHERAL) in mtu3_gadget_start()
536 mtu3_start(mtu); in mtu3_gadget_start()
538 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_start()
539 pm_runtime_put(mtu->dev); in mtu3_gadget_start()
544 static void stop_activity(struct mtu3 *mtu) in stop_activity() argument
546 struct usb_gadget_driver *driver = mtu->gadget_driver; in stop_activity()
550 if (mtu->g.speed == USB_SPEED_UNKNOWN) in stop_activity()
553 mtu->g.speed = USB_SPEED_UNKNOWN; in stop_activity()
556 if (mtu->softconnect) { in stop_activity()
557 mtu->softconnect = 0; in stop_activity()
558 mtu3_dev_on_off(mtu, 0); in stop_activity()
565 nuke(mtu->ep0, -ESHUTDOWN); in stop_activity()
566 for (i = 1; i < mtu->num_eps; i++) { in stop_activity()
567 nuke(mtu->in_eps + i, -ESHUTDOWN); in stop_activity()
568 nuke(mtu->out_eps + i, -ESHUTDOWN); in stop_activity()
572 spin_unlock(&mtu->lock); in stop_activity()
573 driver->disconnect(&mtu->g); in stop_activity()
574 spin_lock(&mtu->lock); in stop_activity()
580 struct mtu3 *mtu = gadget_to_mtu3(g); in mtu3_gadget_stop() local
583 dev_dbg(mtu->dev, "%s\n", __func__); in mtu3_gadget_stop()
585 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_stop()
587 stop_activity(mtu); in mtu3_gadget_stop()
588 mtu->gadget_driver = NULL; in mtu3_gadget_stop()
590 if (mtu->ssusb->dr_mode == USB_DR_MODE_PERIPHERAL) in mtu3_gadget_stop()
591 mtu3_stop(mtu); in mtu3_gadget_stop()
593 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_stop()
595 synchronize_irq(mtu->irq); in mtu3_gadget_stop()
602 struct mtu3 *mtu = gadget_to_mtu3(g); in mtu3_gadget_set_speed() local
605 dev_dbg(mtu->dev, "%s %s\n", __func__, usb_speed_string(speed)); in mtu3_gadget_set_speed()
607 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_set_speed()
608 mtu->speed = speed; in mtu3_gadget_set_speed()
609 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_set_speed()
614 struct mtu3 *mtu = gadget_to_mtu3(g); in mtu3_gadget_async_callbacks() local
617 dev_dbg(mtu->dev, "%s %s\n", __func__, enable ? "en" : "dis"); in mtu3_gadget_async_callbacks()
619 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_async_callbacks()
620 mtu->async_callbacks = enable; in mtu3_gadget_async_callbacks()
621 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_async_callbacks()
635 static void mtu3_state_reset(struct mtu3 *mtu) in mtu3_state_reset() argument
637 mtu->address = 0; in mtu3_state_reset()
638 mtu->ep0_state = MU3D_EP0_STATE_SETUP; in mtu3_state_reset()
639 mtu->may_wakeup = 0; in mtu3_state_reset()
640 mtu->u1_enable = 0; in mtu3_state_reset()
641 mtu->u2_enable = 0; in mtu3_state_reset()
642 mtu->delayed_status = false; in mtu3_state_reset()
643 mtu->test_mode = false; in mtu3_state_reset()
646 static void init_hw_ep(struct mtu3 *mtu, struct mtu3_ep *mep, in init_hw_ep() argument
650 mep->mtu = mtu; in init_hw_ep()
666 mtu->g.ep0 = &mep->ep; in init_hw_ep()
673 list_add_tail(&mep->ep.ep_list, &mtu->g.ep_list); in init_hw_ep()
676 dev_dbg(mtu->dev, "%s, name=%s, maxp=%d\n", __func__, mep->ep.name, in init_hw_ep()
689 static void mtu3_gadget_init_eps(struct mtu3 *mtu) in mtu3_gadget_init_eps() argument
694 INIT_LIST_HEAD(&(mtu->g.ep_list)); in mtu3_gadget_init_eps()
696 dev_dbg(mtu->dev, "%s num_eps(1 for a pair of tx&rx ep)=%d\n", in mtu3_gadget_init_eps()
697 __func__, mtu->num_eps); in mtu3_gadget_init_eps()
699 init_hw_ep(mtu, mtu->ep0, 0, 0); in mtu3_gadget_init_eps()
700 for (epnum = 1; epnum < mtu->num_eps; epnum++) { in mtu3_gadget_init_eps()
701 init_hw_ep(mtu, mtu->in_eps + epnum, epnum, 1); in mtu3_gadget_init_eps()
702 init_hw_ep(mtu, mtu->out_eps + epnum, epnum, 0); in mtu3_gadget_init_eps()
706 int mtu3_gadget_setup(struct mtu3 *mtu) in mtu3_gadget_setup() argument
708 mtu->g.ops = &mtu3_gadget_ops; in mtu3_gadget_setup()
709 mtu->g.max_speed = mtu->max_speed; in mtu3_gadget_setup()
710 mtu->g.speed = USB_SPEED_UNKNOWN; in mtu3_gadget_setup()
711 mtu->g.sg_supported = 0; in mtu3_gadget_setup()
712 mtu->g.name = MTU3_DRIVER_NAME; in mtu3_gadget_setup()
713 mtu->g.irq = mtu->irq; in mtu3_gadget_setup()
714 mtu->is_active = 0; in mtu3_gadget_setup()
715 mtu->delayed_status = false; in mtu3_gadget_setup()
717 mtu3_gadget_init_eps(mtu); in mtu3_gadget_setup()
719 return usb_add_gadget_udc(mtu->dev, &mtu->g); in mtu3_gadget_setup()
722 void mtu3_gadget_cleanup(struct mtu3 *mtu) in mtu3_gadget_cleanup() argument
724 usb_del_gadget_udc(&mtu->g); in mtu3_gadget_cleanup()
727 void mtu3_gadget_resume(struct mtu3 *mtu) in mtu3_gadget_resume() argument
729 dev_dbg(mtu->dev, "gadget RESUME\n"); in mtu3_gadget_resume()
730 if (mtu->async_callbacks && mtu->gadget_driver && mtu->gadget_driver->resume) { in mtu3_gadget_resume()
731 spin_unlock(&mtu->lock); in mtu3_gadget_resume()
732 mtu->gadget_driver->resume(&mtu->g); in mtu3_gadget_resume()
733 spin_lock(&mtu->lock); in mtu3_gadget_resume()
738 void mtu3_gadget_suspend(struct mtu3 *mtu) in mtu3_gadget_suspend() argument
740 dev_dbg(mtu->dev, "gadget SUSPEND\n"); in mtu3_gadget_suspend()
741 if (mtu->async_callbacks && mtu->gadget_driver && mtu->gadget_driver->suspend) { in mtu3_gadget_suspend()
742 spin_unlock(&mtu->lock); in mtu3_gadget_suspend()
743 mtu->gadget_driver->suspend(&mtu->g); in mtu3_gadget_suspend()
744 spin_lock(&mtu->lock); in mtu3_gadget_suspend()
749 void mtu3_gadget_disconnect(struct mtu3 *mtu) in mtu3_gadget_disconnect() argument
751 dev_dbg(mtu->dev, "gadget DISCONNECT\n"); in mtu3_gadget_disconnect()
752 if (mtu->async_callbacks && mtu->gadget_driver && mtu->gadget_driver->disconnect) { in mtu3_gadget_disconnect()
753 spin_unlock(&mtu->lock); in mtu3_gadget_disconnect()
754 mtu->gadget_driver->disconnect(&mtu->g); in mtu3_gadget_disconnect()
755 spin_lock(&mtu->lock); in mtu3_gadget_disconnect()
758 mtu3_state_reset(mtu); in mtu3_gadget_disconnect()
759 usb_gadget_set_state(&mtu->g, USB_STATE_NOTATTACHED); in mtu3_gadget_disconnect()
762 void mtu3_gadget_reset(struct mtu3 *mtu) in mtu3_gadget_reset() argument
764 dev_dbg(mtu->dev, "gadget RESET\n"); in mtu3_gadget_reset()
767 if (mtu->g.speed != USB_SPEED_UNKNOWN) in mtu3_gadget_reset()
768 mtu3_gadget_disconnect(mtu); in mtu3_gadget_reset()
770 mtu3_state_reset(mtu); in mtu3_gadget_reset()