Lines Matching refs:dum
243 struct dummy *dum; member
293 static inline struct usb_hcd *dummy_hcd_to_hcd(struct dummy_hcd *dum) in dummy_hcd_to_hcd() argument
295 return container_of((void *) dum, struct usb_hcd, hcd_priv); in dummy_hcd_to_hcd()
298 static inline struct device *dummy_dev(struct dummy_hcd *dum) in dummy_dev() argument
300 return dummy_hcd_to_hcd(dum)->self.controller; in dummy_dev()
303 static inline struct device *udc_dev(struct dummy *dum) in udc_dev() argument
305 return dum->gadget.dev.parent; in udc_dev()
315 struct dummy *dum = container_of(gadget, struct dummy, gadget); in gadget_to_dummy_hcd() local
316 if (dum->gadget.speed == USB_SPEED_SUPER) in gadget_to_dummy_hcd()
317 return dum->ss_hcd; in gadget_to_dummy_hcd()
319 return dum->hs_hcd; in gadget_to_dummy_hcd()
332 static void nuke(struct dummy *dum, struct dummy_ep *ep) in nuke() argument
341 spin_unlock(&dum->lock); in nuke()
343 spin_lock(&dum->lock); in nuke()
348 static void stop_activity(struct dummy *dum) in stop_activity() argument
353 dum->address = 0; in stop_activity()
359 nuke(dum, &dum->ep[i]); in stop_activity()
374 struct dummy *dum = dum_hcd->dum; in set_link_state_by_speed() local
379 } else if (!dum->pullup || dum->udc_suspended) { in set_link_state_by_speed()
404 } else if (!dum->pullup || dum->udc_suspended) { in set_link_state_by_speed()
433 __must_hold(&dum->lock) in set_link_state()
435 struct dummy *dum = dum_hcd->dum; in set_link_state() local
439 if (dum->pullup) in set_link_state()
441 dum->gadget.speed != USB_SPEED_SUPER) || in set_link_state()
443 dum->gadget.speed == USB_SPEED_SUPER)) in set_link_state()
463 if (dum->ints_enabled && (disconnect || reset)) { in set_link_state()
464 stop_activity(dum); in set_link_state()
465 ++dum->callback_usage; in set_link_state()
466 spin_unlock(&dum->lock); in set_link_state()
468 usb_gadget_udc_reset(&dum->gadget, dum->driver); in set_link_state()
470 dum->driver->disconnect(&dum->gadget); in set_link_state()
471 spin_lock(&dum->lock); in set_link_state()
472 --dum->callback_usage; in set_link_state()
475 dum->ints_enabled) { in set_link_state()
476 ++dum->callback_usage; in set_link_state()
477 spin_unlock(&dum->lock); in set_link_state()
478 if (dum_hcd->old_active && dum->driver->suspend) in set_link_state()
479 dum->driver->suspend(&dum->gadget); in set_link_state()
480 else if (!dum_hcd->old_active && dum->driver->resume) in set_link_state()
481 dum->driver->resume(&dum->gadget); in set_link_state()
482 spin_lock(&dum->lock); in set_link_state()
483 --dum->callback_usage; in set_link_state()
499 #define is_enabled(dum) \ argument
500 (dum->port_status & USB_PORT_STAT_ENABLE)
505 struct dummy *dum; in dummy_enable() local
515 dum = ep_to_dummy(ep); in dummy_enable()
516 if (!dum->driver) in dummy_enable()
519 dum_hcd = gadget_to_dummy_hcd(&dum->gadget); in dummy_enable()
545 switch (dum->gadget.speed) { in dummy_enable()
568 switch (dum->gadget.speed) { in dummy_enable()
591 switch (dum->gadget.speed) { in dummy_enable()
615 dev_err(udc_dev(dum), "Can't enable stream support on " in dummy_enable()
623 dev_dbg(udc_dev(dum), "enabled %s (ep%d%s-%s) maxpacket %d stream %s\n", in dummy_enable()
642 struct dummy *dum; in dummy_disable() local
648 dum = ep_to_dummy(ep); in dummy_disable()
650 spin_lock_irqsave(&dum->lock, flags); in dummy_disable()
653 nuke(dum, ep); in dummy_disable()
654 spin_unlock_irqrestore(&dum->lock, flags); in dummy_disable()
656 dev_dbg(udc_dev(dum), "disabled %s\n", _ep->name); in dummy_disable()
698 struct dummy *dum; in dummy_queue() local
710 dum = ep_to_dummy(ep); in dummy_queue()
711 dum_hcd = gadget_to_dummy_hcd(&dum->gadget); in dummy_queue()
712 if (!dum->driver || !is_enabled(dum_hcd)) in dummy_queue()
716 dev_dbg(udc_dev(dum), "ep %p queue req %p to %s, len %d buf %p\n", in dummy_queue()
721 spin_lock_irqsave(&dum->lock, flags); in dummy_queue()
725 list_empty(&dum->fifo_req.queue) && in dummy_queue()
728 req = &dum->fifo_req; in dummy_queue()
730 req->req.buf = dum->fifo_buf; in dummy_queue()
731 memcpy(dum->fifo_buf, _req->buf, _req->length); in dummy_queue()
732 req->req.context = dum; in dummy_queue()
736 spin_unlock(&dum->lock); in dummy_queue()
740 spin_lock(&dum->lock); in dummy_queue()
743 spin_unlock_irqrestore(&dum->lock, flags); in dummy_queue()
754 struct dummy *dum; in dummy_dequeue() local
762 dum = ep_to_dummy(ep); in dummy_dequeue()
764 if (!dum->driver) in dummy_dequeue()
768 spin_lock(&dum->lock); in dummy_dequeue()
778 spin_unlock(&dum->lock); in dummy_dequeue()
781 dev_dbg(udc_dev(dum), in dummy_dequeue()
794 struct dummy *dum; in dummy_set_halt_and_wedge() local
799 dum = ep_to_dummy(ep); in dummy_set_halt_and_wedge()
800 if (!dum->driver) in dummy_set_halt_and_wedge()
859 if (!(dum_hcd->dum->devstatus & ((1 << USB_DEVICE_B_HNP_ENABLE) in dummy_wakeup()
879 struct dummy *dum; in dummy_set_selfpowered() local
882 dum = gadget_to_dummy_hcd(_gadget)->dum; in dummy_set_selfpowered()
884 dum->devstatus |= (1 << USB_DEVICE_SELF_POWERED); in dummy_set_selfpowered()
886 dum->devstatus &= ~(1 << USB_DEVICE_SELF_POWERED); in dummy_set_selfpowered()
890 static void dummy_udc_update_ep0(struct dummy *dum) in dummy_udc_update_ep0() argument
892 if (dum->gadget.speed == USB_SPEED_SUPER) in dummy_udc_update_ep0()
893 dum->ep[0].ep.maxpacket = 9; in dummy_udc_update_ep0()
895 dum->ep[0].ep.maxpacket = 64; in dummy_udc_update_ep0()
901 struct dummy *dum; in dummy_pullup() local
904 dum = gadget_dev_to_dummy(&_gadget->dev); in dummy_pullup()
907 spin_lock_irqsave(&dum->lock, flags); in dummy_pullup()
908 dum->pullup = (value != 0); in dummy_pullup()
919 while (dum->callback_usage > 0) { in dummy_pullup()
920 spin_unlock_irqrestore(&dum->lock, flags); in dummy_pullup()
922 spin_lock_irqsave(&dum->lock, flags); in dummy_pullup()
925 spin_unlock_irqrestore(&dum->lock, flags); in dummy_pullup()
934 struct dummy *dum; in dummy_udc_set_speed() local
936 dum = gadget_dev_to_dummy(&_gadget->dev); in dummy_udc_set_speed()
937 dum->gadget.speed = speed; in dummy_udc_set_speed()
938 dummy_udc_update_ep0(dum); in dummy_udc_set_speed()
943 struct dummy *dum = gadget_dev_to_dummy(&_gadget->dev); in dummy_udc_async_callbacks() local
945 spin_lock_irq(&dum->lock); in dummy_udc_async_callbacks()
946 dum->ints_enabled = enable; in dummy_udc_async_callbacks()
947 spin_unlock_irq(&dum->lock); in dummy_udc_async_callbacks()
971 struct dummy *dum = gadget_dev_to_dummy(dev); in function_show() local
973 if (!dum->driver || !dum->driver->function) in function_show()
975 return scnprintf(buf, PAGE_SIZE, "%s\n", dum->driver->function); in function_show()
999 struct dummy *dum = dum_hcd->dum; in dummy_udc_start() local
1019 spin_lock_irq(&dum->lock); in dummy_udc_start()
1020 dum->devstatus = 0; in dummy_udc_start()
1021 dum->driver = driver; in dummy_udc_start()
1022 spin_unlock_irq(&dum->lock); in dummy_udc_start()
1030 struct dummy *dum = dum_hcd->dum; in dummy_udc_stop() local
1032 spin_lock_irq(&dum->lock); in dummy_udc_stop()
1033 dum->ints_enabled = 0; in dummy_udc_stop()
1034 stop_activity(dum); in dummy_udc_stop()
1035 dum->driver = NULL; in dummy_udc_stop()
1036 spin_unlock_irq(&dum->lock); in dummy_udc_stop()
1045 static void init_dummy_udc_hw(struct dummy *dum) in init_dummy_udc_hw() argument
1049 INIT_LIST_HEAD(&dum->gadget.ep_list); in init_dummy_udc_hw()
1051 struct dummy_ep *ep = &dum->ep[i]; in init_dummy_udc_hw()
1058 list_add_tail(&ep->ep.ep_list, &dum->gadget.ep_list); in init_dummy_udc_hw()
1064 ep->gadget = &dum->gadget; in init_dummy_udc_hw()
1069 dum->gadget.ep0 = &dum->ep[0].ep; in init_dummy_udc_hw()
1070 list_del_init(&dum->ep[0].ep.ep_list); in init_dummy_udc_hw()
1071 INIT_LIST_HEAD(&dum->fifo_req.queue); in init_dummy_udc_hw()
1074 dum->gadget.is_otg = 1; in init_dummy_udc_hw()
1080 struct dummy *dum; in dummy_udc_probe() local
1083 dum = *((void **)dev_get_platdata(&pdev->dev)); in dummy_udc_probe()
1085 memzero_explicit(&dum->gadget, sizeof(struct usb_gadget)); in dummy_udc_probe()
1086 dum->gadget.name = gadget_name; in dummy_udc_probe()
1087 dum->gadget.ops = &dummy_ops; in dummy_udc_probe()
1089 dum->gadget.max_speed = USB_SPEED_SUPER; in dummy_udc_probe()
1091 dum->gadget.max_speed = USB_SPEED_HIGH; in dummy_udc_probe()
1093 dum->gadget.max_speed = USB_SPEED_FULL; in dummy_udc_probe()
1095 dum->gadget.dev.parent = &pdev->dev; in dummy_udc_probe()
1096 init_dummy_udc_hw(dum); in dummy_udc_probe()
1098 rc = usb_add_gadget_udc(&pdev->dev, &dum->gadget); in dummy_udc_probe()
1102 rc = device_create_file(&dum->gadget.dev, &dev_attr_function); in dummy_udc_probe()
1105 platform_set_drvdata(pdev, dum); in dummy_udc_probe()
1109 usb_del_gadget_udc(&dum->gadget); in dummy_udc_probe()
1116 struct dummy *dum = platform_get_drvdata(pdev); in dummy_udc_remove() local
1118 device_remove_file(&dum->gadget.dev, &dev_attr_function); in dummy_udc_remove()
1119 usb_del_gadget_udc(&dum->gadget); in dummy_udc_remove()
1122 static void dummy_udc_pm(struct dummy *dum, struct dummy_hcd *dum_hcd, in dummy_udc_pm() argument
1125 spin_lock_irq(&dum->lock); in dummy_udc_pm()
1126 dum->udc_suspended = suspend; in dummy_udc_pm()
1128 spin_unlock_irq(&dum->lock); in dummy_udc_pm()
1133 struct dummy *dum = platform_get_drvdata(pdev); in dummy_udc_suspend() local
1134 struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(&dum->gadget); in dummy_udc_suspend()
1137 dummy_udc_pm(dum, dum_hcd, 1); in dummy_udc_suspend()
1144 struct dummy *dum = platform_get_drvdata(pdev); in dummy_udc_resume() local
1145 struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(&dum->gadget); in dummy_udc_resume()
1148 dummy_udc_pm(dum, dum_hcd, 0); in dummy_udc_resume()
1279 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_urb_enqueue()
1314 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_urb_enqueue()
1327 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_urb_dequeue()
1335 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_urb_dequeue()
1409 struct dummy *dum = dum_hcd->dum; in transfer() local
1521 spin_unlock(&dum->lock); in transfer()
1523 spin_lock(&dum->lock); in transfer()
1540 static int periodic_bytes(struct dummy *dum, struct dummy_ep *ep) in periodic_bytes() argument
1544 if (dum->gadget.speed == USB_SPEED_HIGH) { in periodic_bytes()
1552 if (dum->gadget.speed == USB_SPEED_SUPER) { in periodic_bytes()
1575 static struct dummy_ep *find_endpoint(struct dummy *dum, u8 address) in find_endpoint() argument
1579 if (!is_active((dum->gadget.speed == USB_SPEED_SUPER ? in find_endpoint()
1580 dum->ss_hcd : dum->hs_hcd))) in find_endpoint()
1582 if (!dum->ints_enabled) in find_endpoint()
1585 return &dum->ep[0]; in find_endpoint()
1587 struct dummy_ep *ep = &dum->ep[i]; in find_endpoint()
1624 struct dummy *dum = dum_hcd->dum; in handle_control_request() local
1635 dum->address = w_value; in handle_control_request()
1637 dev_dbg(udc_dev(dum), "set_address = %d\n", in handle_control_request()
1648 dum->gadget.b_hnp_enable = 1; in handle_control_request()
1651 dum->gadget.a_hnp_support = 1; in handle_control_request()
1654 dum->gadget.a_alt_hnp_support = 1; in handle_control_request()
1681 dum->devstatus |= (1 << w_value); in handle_control_request()
1686 ep2 = find_endpoint(dum, w_index); in handle_control_request()
1729 dum->devstatus &= ~(1 << w_value); in handle_control_request()
1734 ep2 = find_endpoint(dum, w_index); in handle_control_request()
1758 ep2 = find_endpoint(dum, w_index); in handle_control_request()
1766 buf[0] = (u8)dum->devstatus; in handle_control_request()
1790 struct dummy *dum = dum_hcd->dum; in dummy_timer() local
1798 switch (dum->gadget.speed) { in dummy_timer()
1819 spin_lock_irqsave(&dum->lock, flags); in dummy_timer()
1825 spin_unlock_irqrestore(&dum->lock, flags); in dummy_timer()
1833 dum->ep[i].already_seen = 0; in dummy_timer()
1862 ep = find_endpoint(dum, address); in dummy_timer()
1875 if (ep == &dum->ep[0] && urb->error_count) { in dummy_timer()
1889 if (ep == &dum->ep[0] && ep->setup_stage) { in dummy_timer()
1898 dev_dbg(udc_dev(dum), "stale req = %p\n", in dummy_timer()
1901 spin_unlock(&dum->lock); in dummy_timer()
1903 spin_lock(&dum->lock); in dummy_timer()
1923 ++dum->callback_usage; in dummy_timer()
1924 spin_unlock(&dum->lock); in dummy_timer()
1925 value = dum->driver->setup(&dum->gadget, in dummy_timer()
1927 spin_lock(&dum->lock); in dummy_timer()
1928 --dum->callback_usage; in dummy_timer()
1940 dev_dbg(udc_dev(dum), in dummy_timer()
1963 limit = max(limit, periodic_bytes(dum, ep)); in dummy_timer()
1971 limit = max(limit, periodic_bytes(dum, ep)); in dummy_timer()
1992 spin_unlock(&dum->lock); in dummy_timer()
1994 spin_lock(&dum->lock); in dummy_timer()
2010 spin_unlock_irqrestore(&dum->lock, flags); in dummy_timer()
2032 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_hub_status()
2051 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_hub_status()
2120 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_hub_control()
2210 if (dum_hcd->dum->pullup) { in dummy_hub_control()
2214 switch (dum_hcd->dum->gadget.speed) { in dummy_hub_control()
2220 dum_hcd->dum->gadget.ep0-> in dummy_hub_control()
2278 & dum_hcd->dum->devstatus) != 0) in dummy_hub_control()
2318 dum_hcd->dum->devstatus &= in dummy_hub_control()
2366 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_hub_control()
2379 spin_lock_irq(&dum_hcd->dum->lock); in dummy_bus_suspend()
2383 spin_unlock_irq(&dum_hcd->dum->lock); in dummy_bus_suspend()
2394 spin_lock_irq(&dum_hcd->dum->lock); in dummy_bus_resume()
2406 spin_unlock_irq(&dum_hcd->dum->lock); in dummy_bus_resume()
2465 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in urbs_show()
2473 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in urbs_show()
2510 spin_lock_init(&dum_hcd->dum->lock); in dummy_start()
2548 struct dummy *dum; in dummy_setup() local
2550 dum = *((void **)dev_get_platdata(hcd->self.controller)); in dummy_setup()
2553 dum->hs_hcd = hcd_to_dummy_hcd(hcd); in dummy_setup()
2554 dum->hs_hcd->dum = dum; in dummy_setup()
2563 dum->ss_hcd = hcd_to_dummy_hcd(hcd); in dummy_setup()
2564 dum->ss_hcd->dum = dum; in dummy_setup()
2586 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_alloc_streams()
2614 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_alloc_streams()
2629 spin_lock_irqsave(&dum_hcd->dum->lock, flags); in dummy_free_streams()
2646 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); in dummy_free_streams()
2675 struct dummy *dum; in dummy_hcd_probe() local
2681 dum = *((void **)dev_get_platdata(&pdev->dev)); in dummy_hcd_probe()
2718 dum->hs_hcd = dum->ss_hcd = NULL; in dummy_hcd_probe()
2724 struct dummy *dum; in dummy_hcd_remove() local
2726 dum = hcd_to_dummy_hcd(platform_get_drvdata(pdev))->dum; in dummy_hcd_remove()
2728 if (dum->ss_hcd) { in dummy_hcd_remove()
2729 usb_remove_hcd(dummy_hcd_to_hcd(dum->ss_hcd)); in dummy_hcd_remove()
2730 usb_put_hcd(dummy_hcd_to_hcd(dum->ss_hcd)); in dummy_hcd_remove()
2733 usb_remove_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); in dummy_hcd_remove()
2734 usb_put_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); in dummy_hcd_remove()
2736 dum->hs_hcd = NULL; in dummy_hcd_remove()
2737 dum->ss_hcd = NULL; in dummy_hcd_remove()
2789 struct dummy *dum[MAX_NUM_UDC] = {}; in dummy_hcd_init() local
2822 dum[i] = kzalloc(sizeof(struct dummy), GFP_KERNEL); in dummy_hcd_init()
2823 if (!dum[i]) { in dummy_hcd_init()
2827 retval = platform_device_add_data(the_hcd_pdev[i], &dum[i], in dummy_hcd_init()
2831 retval = platform_device_add_data(the_udc_pdev[i], &dum[i], in dummy_hcd_init()
2854 if (!dum[i]->hs_hcd || in dummy_hcd_init()
2855 (!dum[i]->ss_hcd && mod_data.is_super_speed)) { in dummy_hcd_init()
2899 kfree(dum[i]); in dummy_hcd_init()
2914 struct dummy *dum; in dummy_hcd_cleanup() local
2916 dum = *((void **)dev_get_platdata(&the_udc_pdev[i]->dev)); in dummy_hcd_cleanup()
2920 kfree(dum); in dummy_hcd_cleanup()