Lines Matching refs:dum
163 struct dummy *dum; member
208 static inline struct usb_hcd *dummy_hcd_to_hcd(struct dummy_hcd *dum) in dummy_hcd_to_hcd() argument
210 return container_of((void *) dum, struct usb_hcd, hcd_priv); in dummy_hcd_to_hcd()
213 static inline struct device *dummy_dev(struct dummy_hcd *dum) in dummy_dev() argument
215 return dummy_hcd_to_hcd(dum)->self.controller; in dummy_dev()
218 static inline struct device *udc_dev(struct dummy *dum) in udc_dev() argument
220 return dum->gadget.dev.parent; in udc_dev()
230 struct dummy *dum = container_of(gadget, struct dummy, gadget); in gadget_to_dummy_hcd() local
231 if (dum->gadget.speed == USB_SPEED_SUPER) in gadget_to_dummy_hcd()
232 return dum->ss_hcd; in gadget_to_dummy_hcd()
234 return dum->hs_hcd; in gadget_to_dummy_hcd()
249 static void nuke(struct dummy *dum, struct dummy_ep *ep) in nuke() argument
258 spin_unlock(&dum->lock); in nuke()
260 spin_lock(&dum->lock); in nuke()
265 static void stop_activity(struct dummy *dum) in stop_activity() argument
270 dum->address = 0; in stop_activity()
275 list_for_each_entry(ep, &dum->gadget.ep_list, ep.ep_list) in stop_activity()
276 nuke(dum, ep); in stop_activity()
291 struct dummy *dum = dum_hcd->dum; in set_link_state_by_speed() local
296 } else if (!dum->pullup || dum->udc_suspended) { in set_link_state_by_speed()
322 } else if (!dum->pullup || dum->udc_suspended) { in set_link_state_by_speed()
352 struct dummy *dum = dum_hcd->dum; in set_link_state() local
355 if (dum->pullup) in set_link_state()
357 dum->gadget.speed != USB_SPEED_SUPER) || in set_link_state()
359 dum->gadget.speed == USB_SPEED_SUPER)) in set_link_state()
377 dum->driver) { in set_link_state()
378 stop_activity(dum); in set_link_state()
379 spin_unlock(&dum->lock); in set_link_state()
380 dum->driver->disconnect(&dum->gadget); in set_link_state()
381 spin_lock(&dum->lock); in set_link_state()
384 if (dum_hcd->old_active && dum->driver->suspend) { in set_link_state()
385 spin_unlock(&dum->lock); in set_link_state()
386 dum->driver->suspend(&dum->gadget); in set_link_state()
387 spin_lock(&dum->lock); in set_link_state()
388 } else if (!dum_hcd->old_active && dum->driver->resume) { in set_link_state()
389 spin_unlock(&dum->lock); in set_link_state()
390 dum->driver->resume(&dum->gadget); in set_link_state()
391 spin_lock(&dum->lock); in set_link_state()
408 #define is_enabled(dum) \ argument
409 (dum->port_status & USB_PORT_STAT_ENABLE)
414 struct dummy *dum; in dummy_enable() local
424 dum = ep_to_dummy(ep); in dummy_enable()
425 if (!dum->driver) in dummy_enable()
428 dum_hcd = gadget_to_dummy_hcd(&dum->gadget); in dummy_enable()
454 switch (dum->gadget.speed) { in dummy_enable()
476 switch (dum->gadget.speed) { in dummy_enable()
497 switch (dum->gadget.speed) { in dummy_enable()
519 dev_err(udc_dev(dum), "Can't enable stream support on " in dummy_enable()
527 dev_dbg(udc_dev(dum), "enabled %s (ep%d%s-%s) maxpacket %d stream %s\n", in dummy_enable()
560 struct dummy *dum; in dummy_disable() local
567 dum = ep_to_dummy(ep); in dummy_disable()
569 spin_lock_irqsave(&dum->lock, flags); in dummy_disable()
573 nuke(dum, ep); in dummy_disable()
574 spin_unlock_irqrestore(&dum->lock, flags); in dummy_disable()
576 dev_dbg(udc_dev(dum), "disabled %s\n", _ep->name); in dummy_disable()
622 struct dummy *dum; in dummy_queue() local
634 dum = ep_to_dummy(ep); in dummy_queue()
635 dum_hcd = gadget_to_dummy_hcd(&dum->gadget); in dummy_queue()
636 if (!dum->driver || !is_enabled(dum_hcd)) in dummy_queue()
640 dev_dbg(udc_dev(dum), "ep %p queue req %p to %s, len %d buf %p\n", in dummy_queue()
645 spin_lock_irqsave(&dum->lock, flags); in dummy_queue()
649 list_empty(&dum->fifo_req.queue) && in dummy_queue()
652 req = &dum->fifo_req; in dummy_queue()
654 req->req.buf = dum->fifo_buf; in dummy_queue()
655 memcpy(dum->fifo_buf, _req->buf, _req->length); in dummy_queue()
656 req->req.context = dum; in dummy_queue()
660 spin_unlock(&dum->lock); in dummy_queue()
664 spin_lock(&dum->lock); in dummy_queue()
667 spin_unlock_irqrestore(&dum->lock, flags); in dummy_queue()
678 struct dummy *dum; in dummy_dequeue() local
686 dum = ep_to_dummy(ep); in dummy_dequeue()
688 if (!dum->driver) in dummy_dequeue()
692 spin_lock(&dum->lock); in dummy_dequeue()
701 spin_unlock(&dum->lock); in dummy_dequeue()
704 dev_dbg(udc_dev(dum), in dummy_dequeue()
717 struct dummy *dum; in dummy_set_halt_and_wedge() local
722 dum = ep_to_dummy(ep); in dummy_set_halt_and_wedge()
723 if (!dum->driver) in dummy_set_halt_and_wedge()
782 if (!(dum_hcd->dum->devstatus & ((1 << USB_DEVICE_B_HNP_ENABLE) in dummy_wakeup()
802 struct dummy *dum; in dummy_set_selfpowered() local
804 dum = gadget_to_dummy_hcd(_gadget)->dum; in dummy_set_selfpowered()
806 dum->devstatus |= (1 << USB_DEVICE_SELF_POWERED); in dummy_set_selfpowered()
808 dum->devstatus &= ~(1 << USB_DEVICE_SELF_POWERED); in dummy_set_selfpowered()
812 static void dummy_udc_update_ep0(struct dummy *dum) in dummy_udc_update_ep0() argument
814 if (dum->gadget.speed == USB_SPEED_SUPER) in dummy_udc_update_ep0()
815 dum->ep[0].ep.maxpacket = 9; in dummy_udc_update_ep0()
817 dum->ep[0].ep.maxpacket = 64; in dummy_udc_update_ep0()
823 struct dummy *dum; in dummy_pullup() local
826 dum = gadget_dev_to_dummy(&_gadget->dev); in dummy_pullup()
828 if (value && dum->driver) { in dummy_pullup()
830 dum->gadget.speed = dum->driver->max_speed; in dummy_pullup()
832 dum->gadget.speed = min_t(u8, USB_SPEED_HIGH, in dummy_pullup()
833 dum->driver->max_speed); in dummy_pullup()
835 dum->gadget.speed = USB_SPEED_FULL; in dummy_pullup()
836 dummy_udc_update_ep0(dum); in dummy_pullup()
838 if (dum->gadget.speed < dum->driver->max_speed) in dummy_pullup()
839 dev_dbg(udc_dev(dum), "This device can perform faster" in dummy_pullup()
841 usb_speed_string(dum->driver->max_speed)); in dummy_pullup()
845 spin_lock_irqsave(&dum->lock, flags); in dummy_pullup()
846 dum->pullup = (value != 0); in dummy_pullup()
848 spin_unlock_irqrestore(&dum->lock, flags); in dummy_pullup()
874 struct dummy *dum = gadget_dev_to_dummy(dev); in show_function() local
876 if (!dum->driver || !dum->driver->function) in show_function()
878 return scnprintf(buf, PAGE_SIZE, "%s\n", dum->driver->function); in show_function()
902 struct dummy *dum = dum_hcd->dum; in dummy_udc_start() local
912 dum->devstatus = 0; in dummy_udc_start()
914 dum->driver = driver; in dummy_udc_start()
915 dev_dbg(udc_dev(dum), "binding gadget driver '%s'\n", in dummy_udc_start()
924 struct dummy *dum = dum_hcd->dum; in dummy_udc_stop() local
926 dev_dbg(udc_dev(dum), "unregister gadget driver '%s'\n", in dummy_udc_stop()
929 dum->driver = NULL; in dummy_udc_stop()
943 static void init_dummy_udc_hw(struct dummy *dum) in init_dummy_udc_hw() argument
947 INIT_LIST_HEAD(&dum->gadget.ep_list); in init_dummy_udc_hw()
949 struct dummy_ep *ep = &dum->ep[i]; in init_dummy_udc_hw()
955 list_add_tail(&ep->ep.ep_list, &dum->gadget.ep_list); in init_dummy_udc_hw()
961 ep->gadget = &dum->gadget; in init_dummy_udc_hw()
966 dum->gadget.ep0 = &dum->ep[0].ep; in init_dummy_udc_hw()
967 list_del_init(&dum->ep[0].ep.ep_list); in init_dummy_udc_hw()
968 INIT_LIST_HEAD(&dum->fifo_req.queue); in init_dummy_udc_hw()
971 dum->gadget.is_otg = 1; in init_dummy_udc_hw()
977 struct dummy *dum = &the_controller; in dummy_udc_probe() local
980 dum->gadget.name = gadget_name; in dummy_udc_probe()
981 dum->gadget.ops = &dummy_ops; in dummy_udc_probe()
982 dum->gadget.max_speed = USB_SPEED_SUPER; in dummy_udc_probe()
984 dev_set_name(&dum->gadget.dev, "gadget"); in dummy_udc_probe()
985 dum->gadget.dev.parent = &pdev->dev; in dummy_udc_probe()
986 dum->gadget.dev.release = dummy_gadget_release; in dummy_udc_probe()
987 rc = device_register(&dum->gadget.dev); in dummy_udc_probe()
989 put_device(&dum->gadget.dev); in dummy_udc_probe()
993 init_dummy_udc_hw(dum); in dummy_udc_probe()
995 rc = usb_add_gadget_udc(&pdev->dev, &dum->gadget); in dummy_udc_probe()
999 rc = device_create_file(&dum->gadget.dev, &dev_attr_function); in dummy_udc_probe()
1002 platform_set_drvdata(pdev, dum); in dummy_udc_probe()
1006 usb_del_gadget_udc(&dum->gadget); in dummy_udc_probe()
1008 device_unregister(&dum->gadget.dev); in dummy_udc_probe()
1014 struct dummy *dum = platform_get_drvdata(pdev); in dummy_udc_remove() local
1016 usb_del_gadget_udc(&dum->gadget); in dummy_udc_remove()
1018 device_remove_file(&dum->gadget.dev, &dev_attr_function); in dummy_udc_remove()
1019 device_unregister(&dum->gadget.dev); in dummy_udc_remove()
1023 static void dummy_udc_pm(struct dummy *dum, struct dummy_hcd *dum_hcd, in dummy_udc_pm() argument
1026 spin_lock_irq(&dum->lock); in dummy_udc_pm()
1027 dum->udc_suspended = suspend; in dummy_udc_pm()
1029 spin_unlock_irq(&dum->lock); in dummy_udc_pm()
1034 struct dummy *dum = platform_get_drvdata(pdev); in dummy_udc_suspend() local
1035 struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(&dum->gadget); in dummy_udc_suspend()
1038 dummy_udc_pm(dum, dum_hcd, 1); in dummy_udc_suspend()
1045 struct dummy *dum = platform_get_drvdata(pdev); in dummy_udc_resume() local
1046 struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(&dum->gadget); in dummy_udc_resume()
1049 dummy_udc_pm(dum, dum_hcd, 0); in dummy_udc_resume()
1181 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_urb_enqueue()
1211 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_urb_enqueue()
1224 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_urb_dequeue()
1231 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_urb_dequeue()
1305 struct dummy *dum = dum_hcd->dum; in transfer() local
1403 spin_unlock(&dum->lock); in transfer()
1405 spin_lock(&dum->lock); in transfer()
1422 static int periodic_bytes(struct dummy *dum, struct dummy_ep *ep) in periodic_bytes() argument
1426 if (dum->gadget.speed == USB_SPEED_HIGH) { in periodic_bytes()
1435 if (dum->gadget.speed == USB_SPEED_SUPER) { in periodic_bytes()
1458 static struct dummy_ep *find_endpoint(struct dummy *dum, u8 address) in find_endpoint() argument
1462 if (!is_active((dum->gadget.speed == USB_SPEED_SUPER ? in find_endpoint()
1463 dum->ss_hcd : dum->hs_hcd))) in find_endpoint()
1466 return &dum->ep[0]; in find_endpoint()
1468 struct dummy_ep *ep = &dum->ep[i]; in find_endpoint()
1505 struct dummy *dum = dum_hcd->dum; in handle_control_request() local
1516 dum->address = w_value; in handle_control_request()
1518 dev_dbg(udc_dev(dum), "set_address = %d\n", in handle_control_request()
1529 dum->gadget.b_hnp_enable = 1; in handle_control_request()
1532 dum->gadget.a_hnp_support = 1; in handle_control_request()
1535 dum->gadget.a_alt_hnp_support = 1; in handle_control_request()
1562 dum->devstatus |= (1 << w_value); in handle_control_request()
1567 ep2 = find_endpoint(dum, w_index); in handle_control_request()
1610 dum->devstatus &= ~(1 << w_value); in handle_control_request()
1615 ep2 = find_endpoint(dum, w_index); in handle_control_request()
1639 ep2 = find_endpoint(dum, w_index); in handle_control_request()
1647 buf[0] = (u8)dum->devstatus; in handle_control_request()
1669 struct dummy *dum = dum_hcd->dum; in dummy_timer() local
1676 switch (dum->gadget.speed) { in dummy_timer()
1698 spin_lock_irqsave(&dum->lock, flags); in dummy_timer()
1703 spin_unlock_irqrestore(&dum->lock, flags); in dummy_timer()
1710 dum->ep[i].already_seen = 0; in dummy_timer()
1740 ep = find_endpoint(dum, address); in dummy_timer()
1753 if (ep == &dum->ep[0] && urb->error_count) { in dummy_timer()
1767 if (ep == &dum->ep[0] && ep->setup_stage) { in dummy_timer()
1776 dev_dbg(udc_dev(dum), "stale req = %p\n", in dummy_timer()
1779 spin_unlock(&dum->lock); in dummy_timer()
1781 spin_lock(&dum->lock); in dummy_timer()
1801 spin_unlock(&dum->lock); in dummy_timer()
1802 value = dum->driver->setup(&dum->gadget, in dummy_timer()
1804 spin_lock(&dum->lock); in dummy_timer()
1816 dev_dbg(udc_dev(dum), in dummy_timer()
1835 limit = max(limit, periodic_bytes(dum, ep)); in dummy_timer()
1843 limit = max(limit, periodic_bytes(dum, ep)); in dummy_timer()
1864 spin_unlock(&dum->lock); in dummy_timer()
1866 spin_lock(&dum->lock); in dummy_timer()
1879 spin_unlock_irqrestore(&dum->lock, flags); in dummy_timer()
1899 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_hub_status()
1918 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_hub_status()
1962 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_hub_control()
2031 if (dum_hcd->dum->pullup) { in dummy_hub_control()
2035 switch (dum_hcd->dum->gadget.speed) { in dummy_hub_control()
2041 dum_hcd->dum->gadget.ep0-> in dummy_hub_control()
2047 dum_hcd->dum->gadget.speed = in dummy_hub_control()
2101 & dum_hcd->dum->devstatus) != 0) in dummy_hub_control()
2138 dum_hcd->dum->devstatus &= in dummy_hub_control()
2187 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_hub_control()
2200 spin_lock_irq(&dum_hcd->dum->lock); in dummy_bus_suspend()
2204 spin_unlock_irq(&dum_hcd->dum->lock); in dummy_bus_suspend()
2215 spin_lock_irq(&dum_hcd->dum->lock); in dummy_bus_resume()
2225 spin_unlock_irq(&dum_hcd->dum->lock); in dummy_bus_resume()
2284 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in show_urbs()
2292 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in show_urbs()
2330 spin_lock_init(&dum_hcd->dum->lock); in dummy_start()
2352 struct dummy *dum; in dummy_stop() local
2354 dum = hcd_to_dummy_hcd(hcd)->dum; in dummy_stop()
2356 usb_gadget_unregister_driver(dum->driver); in dummy_stop()
2372 the_controller.hs_hcd->dum = &the_controller; in dummy_setup()
2382 the_controller.ss_hcd->dum = &the_controller; in dummy_setup()
2404 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_alloc_streams()
2432 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_alloc_streams()
2447 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_free_streams()
2464 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_free_streams()
2538 struct dummy *dum; in dummy_hcd_remove() local
2540 dum = hcd_to_dummy_hcd(platform_get_drvdata(pdev))->dum; in dummy_hcd_remove()
2542 if (dum->ss_hcd) { in dummy_hcd_remove()
2543 usb_remove_hcd(dummy_hcd_to_hcd(dum->ss_hcd)); in dummy_hcd_remove()
2544 usb_put_hcd(dummy_hcd_to_hcd(dum->ss_hcd)); in dummy_hcd_remove()
2547 usb_remove_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); in dummy_hcd_remove()
2548 usb_put_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); in dummy_hcd_remove()