Searched refs:dum_hcd (Results 1 - 1 of 1) sorted by relevance

/linux-4.1.27/drivers/usb/gadget/udc/
H A Ddummy_hcd.c286 * @dum_hcd: pointer to the dummy_hcd structure to update the link state for
291 static void set_link_state_by_speed(struct dummy_hcd *dum_hcd) set_link_state_by_speed() argument
293 struct dummy *dum = dum_hcd->dum; set_link_state_by_speed()
295 if (dummy_hcd_to_hcd(dum_hcd)->speed == HCD_USB3) { set_link_state_by_speed()
296 if ((dum_hcd->port_status & USB_SS_PORT_STAT_POWER) == 0) { set_link_state_by_speed()
297 dum_hcd->port_status = 0; set_link_state_by_speed()
300 dum_hcd->port_status &= ~(USB_PORT_STAT_CONNECTION | set_link_state_by_speed()
302 if ((dum_hcd->old_status & set_link_state_by_speed()
304 dum_hcd->port_status |= set_link_state_by_speed()
308 dum_hcd->port_status |= (USB_PORT_STAT_CONNECTION | set_link_state_by_speed()
310 if ((dum_hcd->old_status & set_link_state_by_speed()
312 dum_hcd->port_status |= set_link_state_by_speed()
314 if ((dum_hcd->port_status & set_link_state_by_speed()
316 (dum_hcd->port_status & set_link_state_by_speed()
318 dum_hcd->rh_state != DUMMY_RH_SUSPENDED) set_link_state_by_speed()
319 dum_hcd->active = 1; set_link_state_by_speed()
322 if ((dum_hcd->port_status & USB_PORT_STAT_POWER) == 0) { set_link_state_by_speed()
323 dum_hcd->port_status = 0; set_link_state_by_speed()
326 dum_hcd->port_status &= ~(USB_PORT_STAT_CONNECTION | set_link_state_by_speed()
331 if ((dum_hcd->old_status & set_link_state_by_speed()
333 dum_hcd->port_status |= set_link_state_by_speed()
336 dum_hcd->port_status |= USB_PORT_STAT_CONNECTION; set_link_state_by_speed()
337 if ((dum_hcd->old_status & set_link_state_by_speed()
339 dum_hcd->port_status |= set_link_state_by_speed()
341 if ((dum_hcd->port_status & USB_PORT_STAT_ENABLE) == 0) set_link_state_by_speed()
342 dum_hcd->port_status &= ~USB_PORT_STAT_SUSPEND; set_link_state_by_speed()
343 else if ((dum_hcd->port_status & set_link_state_by_speed()
345 dum_hcd->rh_state != DUMMY_RH_SUSPENDED) set_link_state_by_speed()
346 dum_hcd->active = 1; set_link_state_by_speed()
352 static void set_link_state(struct dummy_hcd *dum_hcd) set_link_state() argument
354 struct dummy *dum = dum_hcd->dum; set_link_state()
356 dum_hcd->active = 0; set_link_state()
358 if ((dummy_hcd_to_hcd(dum_hcd)->speed == HCD_USB3 && set_link_state()
360 (dummy_hcd_to_hcd(dum_hcd)->speed != HCD_USB3 && set_link_state()
364 set_link_state_by_speed(dum_hcd); set_link_state()
366 if ((dum_hcd->port_status & USB_PORT_STAT_ENABLE) == 0 || set_link_state()
367 dum_hcd->active) set_link_state()
368 dum_hcd->resuming = 0; set_link_state()
371 if ((dum_hcd->port_status & USB_PORT_STAT_CONNECTION) == 0 || set_link_state()
372 (dum_hcd->port_status & USB_PORT_STAT_RESET) != 0) { set_link_state()
374 dum_hcd->old_status & (~dum_hcd->port_status); set_link_state()
376 (~dum_hcd->old_status) & dum_hcd->port_status; set_link_state()
388 } else if (dum_hcd->active != dum_hcd->old_active) { set_link_state()
389 if (dum_hcd->old_active && dum->driver->suspend) { set_link_state()
393 } else if (!dum_hcd->old_active && dum->driver->resume) { set_link_state()
400 dum_hcd->old_status = dum_hcd->port_status; set_link_state()
401 dum_hcd->old_active = dum_hcd->active; set_link_state()
420 struct dummy_hcd *dum_hcd; dummy_enable() local
433 dum_hcd = gadget_to_dummy_hcd(&dum->gadget); dummy_enable()
434 if (!is_enabled(dum_hcd)) dummy_enable()
624 struct dummy_hcd *dum_hcd; dummy_queue() local
636 dum_hcd = gadget_to_dummy_hcd(&dum->gadget); dummy_queue()
637 if (!dum->driver || !is_enabled(dum_hcd)) dummy_queue()
780 struct dummy_hcd *dum_hcd; dummy_wakeup() local
782 dum_hcd = gadget_to_dummy_hcd(_gadget); dummy_wakeup()
783 if (!(dum_hcd->dum->devstatus & ((1 << USB_DEVICE_B_HNP_ENABLE) dummy_wakeup()
786 if ((dum_hcd->port_status & USB_PORT_STAT_CONNECTION) == 0) dummy_wakeup()
788 if ((dum_hcd->port_status & USB_PORT_STAT_SUSPEND) == 0 && dummy_wakeup()
789 dum_hcd->rh_state != DUMMY_RH_SUSPENDED) dummy_wakeup()
795 dum_hcd->resuming = 1; dummy_wakeup()
796 dum_hcd->re_timeout = jiffies + msecs_to_jiffies(20); dummy_wakeup()
797 mod_timer(&dummy_hcd_to_hcd(dum_hcd)->rh_timer, dum_hcd->re_timeout); dummy_wakeup()
824 struct dummy_hcd *dum_hcd; dummy_pullup() local
845 dum_hcd = gadget_to_dummy_hcd(_gadget); dummy_pullup()
849 set_link_state(dum_hcd); dummy_pullup()
852 usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd)); dummy_pullup()
902 struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g); dummy_udc_start() local
903 struct dummy *dum = dum_hcd->dum; dummy_udc_start()
921 struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g); dummy_udc_stop() local
922 struct dummy *dum = dum_hcd->dum; dummy_udc_stop()
1003 static void dummy_udc_pm(struct dummy *dum, struct dummy_hcd *dum_hcd, dummy_udc_pm() argument
1008 set_link_state(dum_hcd); dummy_udc_pm()
1015 struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(&dum->gadget); dummy_udc_suspend() local
1018 dummy_udc_pm(dum, dum_hcd, 1); dummy_udc_suspend()
1019 usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd)); dummy_udc_suspend()
1026 struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(&dum->gadget); dummy_udc_resume() local
1029 dummy_udc_pm(dum, dum_hcd, 0); dummy_udc_resume()
1030 usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd)); dummy_udc_resume()
1068 static int dummy_ep_stream_en(struct dummy_hcd *dum_hcd, struct urb *urb) dummy_ep_stream_en() argument
1077 return (1 << index) & dum_hcd->stream_en_ep; dummy_ep_stream_en()
1087 static int get_max_streams_for_pipe(struct dummy_hcd *dum_hcd, get_max_streams_for_pipe() argument
1092 max_streams = dum_hcd->num_stream[usb_pipeendpoint(pipe)]; get_max_streams_for_pipe()
1101 static void set_max_streams_for_pipe(struct dummy_hcd *dum_hcd, set_max_streams_for_pipe() argument
1107 max_streams = dum_hcd->num_stream[usb_pipeendpoint(pipe)]; set_max_streams_for_pipe()
1115 dum_hcd->num_stream[usb_pipeendpoint(pipe)] = max_streams; set_max_streams_for_pipe()
1118 static int dummy_validate_stream(struct dummy_hcd *dum_hcd, struct urb *urb) dummy_validate_stream() argument
1123 enabled = dummy_ep_stream_en(dum_hcd, urb); dummy_validate_stream()
1132 max_streams = get_max_streams_for_pipe(dum_hcd, dummy_validate_stream()
1135 dev_err(dummy_dev(dum_hcd), "Stream id %d is out of range.\n", dummy_validate_stream()
1148 struct dummy_hcd *dum_hcd; dummy_urb_enqueue() local
1159 dum_hcd = hcd_to_dummy_hcd(hcd); dummy_urb_enqueue()
1160 spin_lock_irqsave(&dum_hcd->dum->lock, flags); dummy_urb_enqueue()
1162 rc = dummy_validate_stream(dum_hcd, urb); dummy_urb_enqueue()
1174 if (!dum_hcd->udev) { dummy_urb_enqueue()
1175 dum_hcd->udev = urb->dev; dummy_urb_enqueue()
1176 usb_get_dev(dum_hcd->udev); dummy_urb_enqueue()
1177 } else if (unlikely(dum_hcd->udev != urb->dev)) dummy_urb_enqueue()
1178 dev_err(dummy_dev(dum_hcd), "usb_device address has changed!\n"); dummy_urb_enqueue()
1180 list_add_tail(&urbp->urbp_list, &dum_hcd->urbp_list); dummy_urb_enqueue()
1186 if (!timer_pending(&dum_hcd->timer)) dummy_urb_enqueue()
1187 mod_timer(&dum_hcd->timer, jiffies + 1); dummy_urb_enqueue()
1190 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); dummy_urb_enqueue()
1196 struct dummy_hcd *dum_hcd; dummy_urb_dequeue() local
1202 dum_hcd = hcd_to_dummy_hcd(hcd); dummy_urb_dequeue()
1203 spin_lock_irqsave(&dum_hcd->dum->lock, flags); dummy_urb_dequeue()
1206 if (!rc && dum_hcd->rh_state != DUMMY_RH_RUNNING && dummy_urb_dequeue()
1207 !list_empty(&dum_hcd->urbp_list)) dummy_urb_dequeue()
1208 mod_timer(&dum_hcd->timer, jiffies); dummy_urb_dequeue()
1210 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); dummy_urb_dequeue()
1281 static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb, transfer() argument
1284 struct dummy *dum = dum_hcd->dum; transfer()
1294 if (dummy_ep_stream_en(dum_hcd, urb)) { transfer()
1432 #define is_active(dum_hcd) ((dum_hcd->port_status & \
1479 static int handle_control_request(struct dummy_hcd *dum_hcd, struct urb *urb, handle_control_request() argument
1484 struct dummy *dum = dum_hcd->dum; handle_control_request()
1517 if (dummy_hcd_to_hcd(dum_hcd)->speed == handle_control_request()
1524 if (dummy_hcd_to_hcd(dum_hcd)->speed == handle_control_request()
1531 if (dummy_hcd_to_hcd(dum_hcd)->speed == handle_control_request()
1564 if (dummy_hcd_to_hcd(dum_hcd)->speed == handle_control_request()
1571 if (dummy_hcd_to_hcd(dum_hcd)->speed == handle_control_request()
1578 if (dummy_hcd_to_hcd(dum_hcd)->speed == handle_control_request()
1647 struct dummy_hcd *dum_hcd = (struct dummy_hcd *) _dum_hcd; dummy_timer() local
1648 struct dummy *dum = dum_hcd->dum; dummy_timer()
1670 dev_err(dummy_dev(dum_hcd), "bogus device speed\n"); dummy_timer()
1679 if (!dum_hcd->udev) { dummy_timer()
1680 dev_err(dummy_dev(dum_hcd), dummy_timer()
1693 list_for_each_entry_safe(urbp, tmp, &dum_hcd->urbp_list, urbp_list) { dummy_timer()
1704 else if (dum_hcd->rh_state != DUMMY_RH_RUNNING) dummy_timer()
1722 dev_dbg(dummy_dev(dum_hcd), dummy_timer()
1738 dev_dbg(dummy_dev(dum_hcd), "ep %s halted, urb %p\n", dummy_timer()
1773 value = handle_control_request(dum_hcd, urb, &setup, dummy_timer()
1828 total = transfer(dum_hcd, urb, ep, limit, &status); dummy_timer()
1842 usb_hcd_unlink_urb_from_ep(dummy_hcd_to_hcd(dum_hcd), urb); dummy_timer()
1844 usb_hcd_giveback_urb(dummy_hcd_to_hcd(dum_hcd), urb, status); dummy_timer()
1850 if (list_empty(&dum_hcd->urbp_list)) { dummy_timer()
1851 usb_put_dev(dum_hcd->udev); dummy_timer()
1852 dum_hcd->udev = NULL; dummy_timer()
1853 } else if (dum_hcd->rh_state == DUMMY_RH_RUNNING) { dummy_timer()
1855 mod_timer(&dum_hcd->timer, jiffies + msecs_to_jiffies(1)); dummy_timer()
1872 struct dummy_hcd *dum_hcd; dummy_hub_status() local
1876 dum_hcd = hcd_to_dummy_hcd(hcd); dummy_hub_status()
1878 spin_lock_irqsave(&dum_hcd->dum->lock, flags); dummy_hub_status()
1882 if (dum_hcd->resuming && time_after_eq(jiffies, dum_hcd->re_timeout)) { dummy_hub_status()
1883 dum_hcd->port_status |= (USB_PORT_STAT_C_SUSPEND << 16); dummy_hub_status()
1884 dum_hcd->port_status &= ~USB_PORT_STAT_SUSPEND; dummy_hub_status()
1885 set_link_state(dum_hcd); dummy_hub_status()
1888 if ((dum_hcd->port_status & PORT_C_MASK) != 0) { dummy_hub_status()
1890 dev_dbg(dummy_dev(dum_hcd), "port status 0x%08x has changes\n", dummy_hub_status()
1891 dum_hcd->port_status); dummy_hub_status()
1893 if (dum_hcd->rh_state == DUMMY_RH_SUSPENDED) dummy_hub_status()
1897 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); dummy_hub_status()
1957 struct dummy_hcd *dum_hcd; dummy_hub_control() local
1964 dum_hcd = hcd_to_dummy_hcd(hcd); dummy_hub_control()
1966 spin_lock_irqsave(&dum_hcd->dum->lock, flags); dummy_hub_control()
1974 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
1979 if (dum_hcd->port_status & USB_PORT_STAT_SUSPEND) { dummy_hub_control()
1981 dum_hcd->resuming = 1; dummy_hub_control()
1982 dum_hcd->re_timeout = jiffies + dummy_hub_control()
1988 if (dum_hcd->port_status & USB_PORT_STAT_POWER) dummy_hub_control()
1989 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
1992 if (dum_hcd->port_status & dummy_hub_control()
1994 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
1998 dum_hcd->port_status &= ~(1 << wValue); dummy_hub_control()
1999 set_link_state(dum_hcd); dummy_hub_control()
2006 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
2038 if (dum_hcd->resuming && dummy_hub_control()
2039 time_after_eq(jiffies, dum_hcd->re_timeout)) { dummy_hub_control()
2040 dum_hcd->port_status |= (USB_PORT_STAT_C_SUSPEND << 16); dummy_hub_control()
2041 dum_hcd->port_status &= ~USB_PORT_STAT_SUSPEND; dummy_hub_control()
2043 if ((dum_hcd->port_status & USB_PORT_STAT_RESET) != 0 && dummy_hub_control()
2044 time_after_eq(jiffies, dum_hcd->re_timeout)) { dummy_hub_control()
2045 dum_hcd->port_status |= (USB_PORT_STAT_C_RESET << 16); dummy_hub_control()
2046 dum_hcd->port_status &= ~USB_PORT_STAT_RESET; dummy_hub_control()
2047 if (dum_hcd->dum->pullup) { dummy_hub_control()
2048 dum_hcd->port_status |= USB_PORT_STAT_ENABLE; dummy_hub_control()
2051 switch (dum_hcd->dum->gadget.speed) { dummy_hub_control()
2053 dum_hcd->port_status |= dummy_hub_control()
2057 dum_hcd->dum->gadget.ep0-> dummy_hub_control()
2059 dum_hcd->port_status |= dummy_hub_control()
2063 dum_hcd->dum->gadget.speed = dummy_hub_control()
2070 set_link_state(dum_hcd); dummy_hub_control()
2071 ((__le16 *) buf)[0] = cpu_to_le16(dum_hcd->port_status); dummy_hub_control()
2072 ((__le16 *) buf)[1] = cpu_to_le16(dum_hcd->port_status >> 16); dummy_hub_control()
2081 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
2095 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
2104 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
2109 if (dum_hcd->active) { dummy_hub_control()
2110 dum_hcd->port_status |= USB_PORT_STAT_SUSPEND; dummy_hub_control()
2115 set_link_state(dum_hcd); dummy_hub_control()
2117 & dum_hcd->dum->devstatus) != 0) dummy_hub_control()
2118 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
2124 dum_hcd->port_status |= USB_SS_PORT_STAT_POWER; dummy_hub_control()
2126 dum_hcd->port_status |= USB_PORT_STAT_POWER; dummy_hub_control()
2127 set_link_state(dum_hcd); dummy_hub_control()
2132 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
2141 dum_hcd->port_status = 0; dummy_hub_control()
2142 dum_hcd->port_status = dummy_hub_control()
2147 dum_hcd->port_status &= ~(USB_PORT_STAT_ENABLE dummy_hub_control()
2154 dum_hcd->dum->devstatus &= dummy_hub_control()
2160 dum_hcd->re_timeout = jiffies + msecs_to_jiffies(50); dummy_hub_control()
2164 if ((dum_hcd->port_status & dummy_hub_control()
2166 dum_hcd->port_status |= (1 << wValue); dummy_hub_control()
2167 set_link_state(dum_hcd); dummy_hub_control()
2170 if ((dum_hcd->port_status & dummy_hub_control()
2172 dum_hcd->port_status |= (1 << wValue); dummy_hub_control()
2173 set_link_state(dum_hcd); dummy_hub_control()
2179 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
2189 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
2196 dev_dbg(dummy_dev(dum_hcd), dummy_hub_control()
2203 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); dummy_hub_control()
2205 if ((dum_hcd->port_status & PORT_C_MASK) != 0) dummy_hub_control()
2212 struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); dummy_bus_suspend() local
2216 spin_lock_irq(&dum_hcd->dum->lock); dummy_bus_suspend()
2217 dum_hcd->rh_state = DUMMY_RH_SUSPENDED; dummy_bus_suspend()
2218 set_link_state(dum_hcd); dummy_bus_suspend()
2220 spin_unlock_irq(&dum_hcd->dum->lock); dummy_bus_suspend()
2226 struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); dummy_bus_resume() local
2231 spin_lock_irq(&dum_hcd->dum->lock); dummy_bus_resume()
2235 dum_hcd->rh_state = DUMMY_RH_RUNNING; dummy_bus_resume()
2236 set_link_state(dum_hcd); dummy_bus_resume()
2237 if (!list_empty(&dum_hcd->urbp_list)) dummy_bus_resume()
2238 mod_timer(&dum_hcd->timer, jiffies); dummy_bus_resume()
2241 spin_unlock_irq(&dum_hcd->dum->lock); dummy_bus_resume()
2295 struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd);
2300 spin_lock_irqsave(&dum_hcd->dum->lock, flags);
2301 list_for_each_entry(urbp, &dum_hcd->urbp_list, urbp_list) {
2308 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags);
2314 static int dummy_start_ss(struct dummy_hcd *dum_hcd)
2316 init_timer(&dum_hcd->timer);
2317 dum_hcd->timer.function = dummy_timer;
2318 dum_hcd->timer.data = (unsigned long)dum_hcd;
2319 dum_hcd->rh_state = DUMMY_RH_RUNNING;
2320 dum_hcd->stream_en_ep = 0;
2321 INIT_LIST_HEAD(&dum_hcd->urbp_list);
2322 dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET;
2323 dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING;
2324 dummy_hcd_to_hcd(dum_hcd)->uses_new_polling = 1;
2326 dummy_hcd_to_hcd(dum_hcd)->self.otg_port = 1;
2331 return device_create_file(dummy_dev(dum_hcd), &dev_attr_urbs);
2336 struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd);
2344 return dummy_start_ss(dum_hcd);
2346 spin_lock_init(&dum_hcd->dum->lock);
2347 init_timer(&dum_hcd->timer);
2348 dum_hcd->timer.function = dummy_timer;
2349 dum_hcd->timer.data = (unsigned long)dum_hcd;
2350 dum_hcd->rh_state = DUMMY_RH_RUNNING;
2352 INIT_LIST_HEAD(&dum_hcd->urbp_list);
2363 return device_create_file(dummy_dev(dum_hcd), &dev_attr_urbs);
2412 struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd);
2422 spin_lock_irqsave(&dum_hcd->dum->lock, flags);
2425 if ((1 << index) & dum_hcd->stream_en_ep) {
2435 dev_dbg(dummy_dev(dum_hcd), "Ep 0x%x only supports %u "
2445 dum_hcd->stream_en_ep |= 1 << index;
2446 set_max_streams_for_pipe(dum_hcd,
2450 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags);
2459 struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd);
2465 spin_lock_irqsave(&dum_hcd->dum->lock, flags);
2468 if (!((1 << index) & dum_hcd->stream_en_ep)) {
2476 dum_hcd->stream_en_ep &= ~(1 << index);
2477 set_max_streams_for_pipe(dum_hcd,
2482 spin_unlock_irqrestore(&dum_hcd->dum->lock, flags);
2579 struct dummy_hcd *dum_hcd;
2585 dum_hcd = hcd_to_dummy_hcd(hcd);
2586 if (dum_hcd->rh_state == DUMMY_RH_RUNNING) {

Completed in 134 milliseconds