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
26 spin_unlock(&mtu->lock); in mtu3_req_complete()
30 usb_gadget_unmap_request(&mtu->g, req, mep->is_in); in mtu3_req_complete()
32 dev_dbg(mtu->dev, "%s complete req: %p, sts %d, %d/%d\n", 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
140 mtu3_deconfig_ep(mtu, mep); in mtu3_ep_disable()
156 struct mtu3 *mtu; in mtu3_gadget_ep_enable() local
170 mtu = mep->mtu; in mtu3_gadget_ep_enable()
179 dev_dbg(mtu->dev, "%s %s\n", __func__, ep->name); in mtu3_gadget_ep_enable()
182 dev_WARN_ONCE(mtu->dev, true, "%s is already enabled\n", in mtu3_gadget_ep_enable()
187 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_ep_enable()
196 mtu->active_ep++; in mtu3_gadget_ep_enable()
199 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_ep_enable()
201 dev_dbg(mtu->dev, "%s active_ep=%d\n", __func__, mtu->active_ep); in mtu3_gadget_ep_enable()
210 struct mtu3 *mtu = mep->mtu; in mtu3_gadget_ep_disable() local
213 dev_dbg(mtu->dev, "%s %s\n", __func__, mep->name); in mtu3_gadget_ep_disable()
217 dev_warn(mtu->dev, "%s is already disabled\n", mep->name); in mtu3_gadget_ep_disable()
221 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_ep_disable()
224 mtu->active_ep--; in mtu3_gadget_ep_disable()
225 spin_unlock_irqrestore(&(mtu->lock), flags); in mtu3_gadget_ep_disable()
227 dev_dbg(mtu->dev, "%s active_ep=%d, mtu3 is_active=%d\n", in mtu3_gadget_ep_disable()
228 __func__, mtu->active_ep, mtu->is_active); in mtu3_gadget_ep_disable()
264 struct mtu3 *mtu = mep->mtu; in mtu3_gadget_queue() local
274 dev_dbg(mtu->dev, "%s %s EP%d(%s), req=%p, maxp=%d, len#%d\n", in mtu3_gadget_queue()
279 (mtu->gen2cp && req->length > GPD_BUF_SIZE_EL)) { in mtu3_gadget_queue()
280 dev_warn(mtu->dev, in mtu3_gadget_queue()
282 mtu->gen2cp ? GPD_BUF_SIZE_EL : GPD_BUF_SIZE, in mtu3_gadget_queue()
289 dev_dbg(mtu->dev, "req=%p queued to %s while it's disabled\n", in mtu3_gadget_queue()
294 mreq->mtu = mtu; in mtu3_gadget_queue()
298 ret = usb_gadget_map_request(&mtu->g, req, mep->is_in); in mtu3_gadget_queue()
300 dev_err(mtu->dev, "dma mapping failed\n"); in mtu3_gadget_queue()
304 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_queue()
316 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_queue()
327 struct mtu3 *mtu = mep->mtu; in mtu3_gadget_dequeue() local
334 dev_dbg(mtu->dev, "%s : req=%p\n", __func__, req); in mtu3_gadget_dequeue()
337 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_dequeue()
344 dev_dbg(mtu->dev, "req=%p not queued to %s\n", req, ep->name); in mtu3_gadget_dequeue()
354 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_dequeue()
366 struct mtu3 *mtu = mep->mtu; in mtu3_gadget_ep_set_halt() local
371 dev_dbg(mtu->dev, "%s : %s...", __func__, ep->name); in mtu3_gadget_ep_set_halt()
373 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_ep_set_halt()
388 dev_dbg(mtu->dev, "req in progress, cannot halt %s\n", in mtu3_gadget_ep_set_halt()
397 dev_dbg(mtu->dev, "%s %s stall\n", ep->name, value ? "set" : "clear"); in mtu3_gadget_ep_set_halt()
402 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_ep_set_halt()
431 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_get_frame() local
433 return (int)mtu3_readl(mtu->mac_base, U3D_USB20_FRAME_NUM); in mtu3_gadget_get_frame()
436 static void function_wake_notif(struct mtu3 *mtu, u8 intf) in function_wake_notif() argument
438 mtu3_writel(mtu->mac_base, U3D_DEV_NOTIF_0, in function_wake_notif()
440 mtu3_setbits(mtu->mac_base, U3D_DEV_NOTIF_0, SEND_DEV_NOTIF); in function_wake_notif()
445 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_wakeup() local
448 dev_dbg(mtu->dev, "%s\n", __func__); in mtu3_gadget_wakeup()
451 if (!mtu->may_wakeup) in mtu3_gadget_wakeup()
454 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_wakeup()
455 if (mtu->g.speed >= USB_SPEED_SUPER) { in mtu3_gadget_wakeup()
460 mtu3_setbits(mtu->mac_base, U3D_LINK_POWER_CONTROL, UX_EXIT); in mtu3_gadget_wakeup()
467 function_wake_notif(mtu, 0); in mtu3_gadget_wakeup()
469 mtu3_setbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); in mtu3_gadget_wakeup()
470 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_wakeup()
472 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_wakeup()
473 mtu3_clrbits(mtu->mac_base, U3D_POWER_MANAGEMENT, RESUME); in mtu3_gadget_wakeup()
475 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_wakeup()
482 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_set_self_powered() local
484 mtu->is_self_powered = !!is_selfpowered; in mtu3_gadget_set_self_powered()
490 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_pullup() local
493 dev_dbg(mtu->dev, "%s (%s) for %sactive device\n", __func__, in mtu3_gadget_pullup()
494 is_on ? "on" : "off", mtu->is_active ? "" : "in"); in mtu3_gadget_pullup()
496 pm_runtime_get_sync(mtu->dev); in mtu3_gadget_pullup()
499 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_pullup()
502 if (!mtu->is_active) { in mtu3_gadget_pullup()
504 mtu->softconnect = is_on; in mtu3_gadget_pullup()
505 } else if (is_on != mtu->softconnect) { in mtu3_gadget_pullup()
506 mtu->softconnect = is_on; in mtu3_gadget_pullup()
507 mtu3_dev_on_off(mtu, is_on); in mtu3_gadget_pullup()
510 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_pullup()
511 pm_runtime_put(mtu->dev); in mtu3_gadget_pullup()
519 struct mtu3 *mtu = gadget_to_mtu3(gadget); in mtu3_gadget_start() local
522 if (mtu->gadget_driver) { in mtu3_gadget_start()
523 dev_err(mtu->dev, "%s is already bound to %s\n", in mtu3_gadget_start()
524 mtu->g.name, mtu->gadget_driver->driver.name); in mtu3_gadget_start()
528 dev_dbg(mtu->dev, "bind driver %s\n", driver->function); in mtu3_gadget_start()
529 pm_runtime_get_sync(mtu->dev); in mtu3_gadget_start()
531 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_start()
533 mtu->softconnect = 0; in mtu3_gadget_start()
534 mtu->gadget_driver = driver; in mtu3_gadget_start()
536 if (mtu->ssusb->dr_mode == USB_DR_MODE_PERIPHERAL) in mtu3_gadget_start()
537 mtu3_start(mtu); in mtu3_gadget_start()
539 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_start()
540 pm_runtime_put(mtu->dev); in mtu3_gadget_start()
545 static void stop_activity(struct mtu3 *mtu) in stop_activity() argument
547 struct usb_gadget_driver *driver = mtu->gadget_driver; in stop_activity()
551 if (mtu->g.speed == USB_SPEED_UNKNOWN) in stop_activity()
554 mtu->g.speed = USB_SPEED_UNKNOWN; in stop_activity()
557 if (mtu->softconnect) { in stop_activity()
558 mtu->softconnect = 0; in stop_activity()
559 mtu3_dev_on_off(mtu, 0); in stop_activity()
566 nuke(mtu->ep0, -ESHUTDOWN); in stop_activity()
567 for (i = 1; i < mtu->num_eps; i++) { in stop_activity()
568 nuke(mtu->in_eps + i, -ESHUTDOWN); in stop_activity()
569 nuke(mtu->out_eps + i, -ESHUTDOWN); in stop_activity()
573 spin_unlock(&mtu->lock); in stop_activity()
574 driver->disconnect(&mtu->g); in stop_activity()
575 spin_lock(&mtu->lock); in stop_activity()
581 struct mtu3 *mtu = gadget_to_mtu3(g); in mtu3_gadget_stop() local
584 dev_dbg(mtu->dev, "%s\n", __func__); in mtu3_gadget_stop()
586 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_stop()
588 stop_activity(mtu); in mtu3_gadget_stop()
589 mtu->gadget_driver = NULL; in mtu3_gadget_stop()
591 if (mtu->ssusb->dr_mode == USB_DR_MODE_PERIPHERAL) in mtu3_gadget_stop()
592 mtu3_stop(mtu); in mtu3_gadget_stop()
594 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_stop()
596 synchronize_irq(mtu->irq); in mtu3_gadget_stop()
603 struct mtu3 *mtu = gadget_to_mtu3(g); in mtu3_gadget_set_speed() local
606 dev_dbg(mtu->dev, "%s %s\n", __func__, usb_speed_string(speed)); in mtu3_gadget_set_speed()
608 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_set_speed()
609 mtu->speed = speed; in mtu3_gadget_set_speed()
610 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_set_speed()
615 struct mtu3 *mtu = gadget_to_mtu3(g); in mtu3_gadget_async_callbacks() local
618 dev_dbg(mtu->dev, "%s %s\n", __func__, enable ? "en" : "dis"); in mtu3_gadget_async_callbacks()
620 spin_lock_irqsave(&mtu->lock, flags); in mtu3_gadget_async_callbacks()
621 mtu->async_callbacks = enable; in mtu3_gadget_async_callbacks()
622 spin_unlock_irqrestore(&mtu->lock, flags); in mtu3_gadget_async_callbacks()
636 static void mtu3_state_reset(struct mtu3 *mtu) in mtu3_state_reset() argument
638 mtu->address = 0; in mtu3_state_reset()
639 mtu->ep0_state = MU3D_EP0_STATE_SETUP; in mtu3_state_reset()
640 mtu->may_wakeup = 0; in mtu3_state_reset()
641 mtu->u1_enable = 0; in mtu3_state_reset()
642 mtu->u2_enable = 0; in mtu3_state_reset()
643 mtu->delayed_status = false; in mtu3_state_reset()
644 mtu->test_mode = false; in mtu3_state_reset()
647 static void init_hw_ep(struct mtu3 *mtu, struct mtu3_ep *mep, in init_hw_ep() argument
651 mep->mtu = mtu; in init_hw_ep()
667 mtu->g.ep0 = &mep->ep; in init_hw_ep()
674 list_add_tail(&mep->ep.ep_list, &mtu->g.ep_list); in init_hw_ep()
677 dev_dbg(mtu->dev, "%s, name=%s, maxp=%d\n", __func__, mep->ep.name, in init_hw_ep()
690 static void mtu3_gadget_init_eps(struct mtu3 *mtu) in mtu3_gadget_init_eps() argument
695 INIT_LIST_HEAD(&(mtu->g.ep_list)); in mtu3_gadget_init_eps()
697 dev_dbg(mtu->dev, "%s num_eps(1 for a pair of tx&rx ep)=%d\n", in mtu3_gadget_init_eps()
698 __func__, mtu->num_eps); in mtu3_gadget_init_eps()
700 init_hw_ep(mtu, mtu->ep0, 0, 0); in mtu3_gadget_init_eps()
701 for (epnum = 1; epnum < mtu->num_eps; epnum++) { in mtu3_gadget_init_eps()
702 init_hw_ep(mtu, mtu->in_eps + epnum, epnum, 1); in mtu3_gadget_init_eps()
703 init_hw_ep(mtu, mtu->out_eps + epnum, epnum, 0); in mtu3_gadget_init_eps()
707 int mtu3_gadget_setup(struct mtu3 *mtu) in mtu3_gadget_setup() argument
709 mtu->g.ops = &mtu3_gadget_ops; in mtu3_gadget_setup()
710 mtu->g.max_speed = mtu->max_speed; in mtu3_gadget_setup()
711 mtu->g.speed = USB_SPEED_UNKNOWN; in mtu3_gadget_setup()
712 mtu->g.sg_supported = 0; in mtu3_gadget_setup()
713 mtu->g.name = MTU3_DRIVER_NAME; in mtu3_gadget_setup()
714 mtu->g.irq = mtu->irq; in mtu3_gadget_setup()
715 mtu->is_active = 0; in mtu3_gadget_setup()
716 mtu->delayed_status = false; in mtu3_gadget_setup()
718 mtu3_gadget_init_eps(mtu); in mtu3_gadget_setup()
720 return usb_add_gadget_udc(mtu->dev, &mtu->g); in mtu3_gadget_setup()
723 void mtu3_gadget_cleanup(struct mtu3 *mtu) in mtu3_gadget_cleanup() argument
725 usb_del_gadget_udc(&mtu->g); in mtu3_gadget_cleanup()
728 void mtu3_gadget_resume(struct mtu3 *mtu) in mtu3_gadget_resume() argument
730 dev_dbg(mtu->dev, "gadget RESUME\n"); in mtu3_gadget_resume()
731 if (mtu->async_callbacks && mtu->gadget_driver && mtu->gadget_driver->resume) { in mtu3_gadget_resume()
732 spin_unlock(&mtu->lock); in mtu3_gadget_resume()
733 mtu->gadget_driver->resume(&mtu->g); in mtu3_gadget_resume()
734 spin_lock(&mtu->lock); in mtu3_gadget_resume()
739 void mtu3_gadget_suspend(struct mtu3 *mtu) in mtu3_gadget_suspend() argument
741 dev_dbg(mtu->dev, "gadget SUSPEND\n"); in mtu3_gadget_suspend()
742 if (mtu->async_callbacks && mtu->gadget_driver && mtu->gadget_driver->suspend) { in mtu3_gadget_suspend()
743 spin_unlock(&mtu->lock); in mtu3_gadget_suspend()
744 mtu->gadget_driver->suspend(&mtu->g); in mtu3_gadget_suspend()
745 spin_lock(&mtu->lock); in mtu3_gadget_suspend()
750 void mtu3_gadget_disconnect(struct mtu3 *mtu) in mtu3_gadget_disconnect() argument
752 dev_dbg(mtu->dev, "gadget DISCONNECT\n"); in mtu3_gadget_disconnect()
753 if (mtu->async_callbacks && mtu->gadget_driver && mtu->gadget_driver->disconnect) { in mtu3_gadget_disconnect()
754 spin_unlock(&mtu->lock); in mtu3_gadget_disconnect()
755 mtu->gadget_driver->disconnect(&mtu->g); in mtu3_gadget_disconnect()
756 spin_lock(&mtu->lock); in mtu3_gadget_disconnect()
759 mtu3_state_reset(mtu); in mtu3_gadget_disconnect()
760 usb_gadget_set_state(&mtu->g, USB_STATE_NOTATTACHED); in mtu3_gadget_disconnect()
763 void mtu3_gadget_reset(struct mtu3 *mtu) in mtu3_gadget_reset() argument
765 dev_dbg(mtu->dev, "gadget RESET\n"); in mtu3_gadget_reset()
768 if (mtu->g.speed != USB_SPEED_UNKNOWN) in mtu3_gadget_reset()
769 mtu3_gadget_disconnect(mtu); in mtu3_gadget_reset()
771 mtu3_state_reset(mtu); in mtu3_gadget_reset()