Lines Matching refs:hcd

438 rh_string(int id, struct usb_hcd const *hcd, u8 *data, unsigned len)  in rh_string()  argument
455 s = hcd->self.bus_name; in rh_string()
459 s = hcd->product_desc; in rh_string()
464 init_utsname()->release, hcd->driver->description); in rh_string()
477 static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) in rh_call_control() argument
493 status = usb_hcd_link_urb_to_ep(hcd, urb); in rh_call_control()
497 urb->hcpriv = hcd; /* Indicate it's queued */ in rh_call_control()
544 tbuf[0] = (device_may_wakeup(&hcd->self.root_hub->dev) in rh_call_control()
552 device_set_wakeup_enable(&hcd->self.root_hub->dev, 0); in rh_call_control()
557 if (device_can_wakeup(&hcd->self.root_hub->dev) in rh_call_control()
559 device_set_wakeup_enable(&hcd->self.root_hub->dev, 1); in rh_call_control()
572 switch (hcd->speed) { in rh_call_control()
593 if (hcd->has_tt) in rh_call_control()
597 switch (hcd->speed) { in rh_call_control()
616 if (device_can_wakeup(&hcd->self.root_hub->dev)) in rh_call_control()
622 hcd, ubuf, wLength); in rh_call_control()
640 dev_dbg (hcd->self.controller, "root hub device address %d\n", in rh_call_control()
656 dev_dbg (hcd->self.controller, "no endpoint features yet\n"); in rh_call_control()
682 status = hcd->driver->hub_control (hcd, in rh_call_control()
687 usb_hub_adjust_deviceremovable(hcd->self.root_hub, in rh_call_control()
698 dev_dbg (hcd->self.controller, in rh_call_control()
736 usb_hcd_unlink_urb_from_ep(hcd, urb); in rh_call_control()
737 usb_hcd_giveback_urb(hcd, urb, status); in rh_call_control()
752 void usb_hcd_poll_rh_status(struct usb_hcd *hcd) in usb_hcd_poll_rh_status() argument
759 if (unlikely(!hcd->rh_pollable)) in usb_hcd_poll_rh_status()
761 if (!hcd->uses_new_polling && !hcd->status_urb) in usb_hcd_poll_rh_status()
764 length = hcd->driver->hub_status_data(hcd, buffer); in usb_hcd_poll_rh_status()
769 urb = hcd->status_urb; in usb_hcd_poll_rh_status()
771 clear_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); in usb_hcd_poll_rh_status()
772 hcd->status_urb = NULL; in usb_hcd_poll_rh_status()
776 usb_hcd_unlink_urb_from_ep(hcd, urb); in usb_hcd_poll_rh_status()
777 usb_hcd_giveback_urb(hcd, urb, 0); in usb_hcd_poll_rh_status()
780 set_bit(HCD_FLAG_POLL_PENDING, &hcd->flags); in usb_hcd_poll_rh_status()
789 if (hcd->uses_new_polling ? HCD_POLL_RH(hcd) : in usb_hcd_poll_rh_status()
790 (length == 0 && hcd->status_urb != NULL)) in usb_hcd_poll_rh_status()
791 mod_timer (&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); in usb_hcd_poll_rh_status()
805 static int rh_queue_status (struct usb_hcd *hcd, struct urb *urb) in rh_queue_status() argument
812 if (hcd->status_urb || urb->transfer_buffer_length < len) { in rh_queue_status()
813 dev_dbg (hcd->self.controller, "not queuing rh status urb\n"); in rh_queue_status()
818 retval = usb_hcd_link_urb_to_ep(hcd, urb); in rh_queue_status()
822 hcd->status_urb = urb; in rh_queue_status()
823 urb->hcpriv = hcd; /* indicate it's queued */ in rh_queue_status()
824 if (!hcd->uses_new_polling) in rh_queue_status()
825 mod_timer(&hcd->rh_timer, (jiffies/(HZ/4) + 1) * (HZ/4)); in rh_queue_status()
828 else if (HCD_POLL_PENDING(hcd)) in rh_queue_status()
829 mod_timer(&hcd->rh_timer, jiffies); in rh_queue_status()
836 static int rh_urb_enqueue (struct usb_hcd *hcd, struct urb *urb) in rh_urb_enqueue() argument
839 return rh_queue_status (hcd, urb); in rh_urb_enqueue()
841 return rh_call_control (hcd, urb); in rh_urb_enqueue()
850 static int usb_rh_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) in usb_rh_urb_dequeue() argument
856 rc = usb_hcd_check_unlink_urb(hcd, urb, status); in usb_rh_urb_dequeue()
864 if (!hcd->uses_new_polling) in usb_rh_urb_dequeue()
865 del_timer (&hcd->rh_timer); in usb_rh_urb_dequeue()
866 if (urb == hcd->status_urb) { in usb_rh_urb_dequeue()
867 hcd->status_urb = NULL; in usb_rh_urb_dequeue()
868 usb_hcd_unlink_urb_from_ep(hcd, urb); in usb_rh_urb_dequeue()
869 usb_hcd_giveback_urb(hcd, urb, status); in usb_rh_urb_dequeue()
973 static int register_root_hub(struct usb_hcd *hcd) in register_root_hub() argument
975 struct device *parent_dev = hcd->self.controller; in register_root_hub()
976 struct usb_device *usb_dev = hcd->self.root_hub; in register_root_hub()
1014 hcd->rh_registered = 1; in register_root_hub()
1018 if (HCD_DEAD(hcd)) in register_root_hub()
1019 usb_hc_died (hcd); /* This time clean up */ in register_root_hub()
1144 int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_link_urb_to_ep() argument
1170 if (HCD_RH_RUNNING(hcd)) { in usb_hcd_link_urb_to_ep()
1202 int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb, in usb_hcd_check_unlink_urb() argument
1235 void usb_hcd_unlink_urb_from_ep(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_unlink_urb_from_ep() argument
1322 void usb_hcd_unmap_urb_setup_for_dma(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_unmap_urb_setup_for_dma() argument
1326 dma_unmap_single(hcd->self.sysdev, in usb_hcd_unmap_urb_setup_for_dma()
1342 static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) in unmap_urb_for_dma() argument
1344 if (hcd->driver->unmap_urb_for_dma) in unmap_urb_for_dma()
1345 hcd->driver->unmap_urb_for_dma(hcd, urb); in unmap_urb_for_dma()
1347 usb_hcd_unmap_urb_for_dma(hcd, urb); in unmap_urb_for_dma()
1350 void usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) in usb_hcd_unmap_urb_for_dma() argument
1354 usb_hcd_unmap_urb_setup_for_dma(hcd, urb); in usb_hcd_unmap_urb_for_dma()
1359 dma_unmap_sg(hcd->self.sysdev, in usb_hcd_unmap_urb_for_dma()
1365 dma_unmap_page(hcd->self.sysdev, in usb_hcd_unmap_urb_for_dma()
1371 dma_unmap_single(hcd->self.sysdev, in usb_hcd_unmap_urb_for_dma()
1388 static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, in map_urb_for_dma() argument
1391 if (hcd->driver->map_urb_for_dma) in map_urb_for_dma()
1392 return hcd->driver->map_urb_for_dma(hcd, urb, mem_flags); in map_urb_for_dma()
1394 return usb_hcd_map_urb_for_dma(hcd, urb, mem_flags); in map_urb_for_dma()
1397 int usb_hcd_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb, in usb_hcd_map_urb_for_dma() argument
1410 if (hcd->self.uses_pio_for_control) in usb_hcd_map_urb_for_dma()
1412 if (hcd_uses_dma(hcd)) { in usb_hcd_map_urb_for_dma()
1422 hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1426 if (dma_mapping_error(hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1430 } else if (hcd->localmem_pool) { in usb_hcd_map_urb_for_dma()
1446 if (hcd_uses_dma(hcd)) { in usb_hcd_map_urb_for_dma()
1457 hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1472 hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1477 if (dma_mapping_error(hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1490 hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1494 if (dma_mapping_error(hcd->self.sysdev, in usb_hcd_map_urb_for_dma()
1500 } else if (hcd->localmem_pool) { in usb_hcd_map_urb_for_dma()
1512 usb_hcd_unmap_urb_for_dma(hcd, urb); in usb_hcd_map_urb_for_dma()
1528 struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus); in usb_hcd_submit_urb() local
1537 usbmon_urb_submit(&hcd->self, urb); in usb_hcd_submit_urb()
1548 status = rh_urb_enqueue(hcd, urb); in usb_hcd_submit_urb()
1550 status = map_urb_for_dma(hcd, urb, mem_flags); in usb_hcd_submit_urb()
1552 status = hcd->driver->urb_enqueue(hcd, urb, mem_flags); in usb_hcd_submit_urb()
1554 unmap_urb_for_dma(hcd, urb); in usb_hcd_submit_urb()
1559 usbmon_urb_submit_error(&hcd->self, urb, status); in usb_hcd_submit_urb()
1578 static int unlink1(struct usb_hcd *hcd, struct urb *urb, int status) in unlink1() argument
1583 value = usb_rh_urb_dequeue(hcd, urb, status); in unlink1()
1589 value = hcd->driver->urb_dequeue(hcd, urb, status); in unlink1()
1602 struct usb_hcd *hcd; in usb_hcd_unlink_urb() local
1619 hcd = bus_to_hcd(urb->dev->bus); in usb_hcd_unlink_urb()
1620 retval = unlink1(hcd, urb, status); in usb_hcd_unlink_urb()
1635 struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus); in __usb_hcd_giveback_urb() local
1645 unmap_urb_for_dma(hcd, urb); in __usb_hcd_giveback_urb()
1646 usbmon_urb_complete(&hcd->self, urb, status); in __usb_hcd_giveback_urb()
1709 void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status) in usb_hcd_giveback_urb() argument
1718 if (!hcd_giveback_urb_in_bh(hcd) && !is_root_hub(urb->dev)) { in usb_hcd_giveback_urb()
1724 bh = &hcd->high_prio_bh; in usb_hcd_giveback_urb()
1727 bh = &hcd->low_prio_bh; in usb_hcd_giveback_urb()
1754 struct usb_hcd *hcd; in usb_hcd_flush_endpoint() local
1760 hcd = bus_to_hcd(udev->bus); in usb_hcd_flush_endpoint()
1775 unlink1(hcd, urb, -ESHUTDOWN); in usb_hcd_flush_endpoint()
1776 dev_dbg (hcd->self.controller, in usb_hcd_flush_endpoint()
1838 struct usb_hcd *hcd; in usb_hcd_alloc_bandwidth() local
1841 hcd = bus_to_hcd(udev->bus); in usb_hcd_alloc_bandwidth()
1842 if (!hcd->driver->check_bandwidth) in usb_hcd_alloc_bandwidth()
1850 hcd->driver->drop_endpoint(hcd, udev, ep); in usb_hcd_alloc_bandwidth()
1853 hcd->driver->drop_endpoint(hcd, udev, ep); in usb_hcd_alloc_bandwidth()
1855 hcd->driver->check_bandwidth(hcd, udev); in usb_hcd_alloc_bandwidth()
1871 ret = hcd->driver->drop_endpoint(hcd, udev, ep); in usb_hcd_alloc_bandwidth()
1877 ret = hcd->driver->drop_endpoint(hcd, udev, ep); in usb_hcd_alloc_bandwidth()
1895 ret = hcd->driver->add_endpoint(hcd, udev, &alt->endpoint[j]); in usb_hcd_alloc_bandwidth()
1924 ret = hcd->driver->drop_endpoint(hcd, udev, in usb_hcd_alloc_bandwidth()
1931 ret = hcd->driver->add_endpoint(hcd, udev, in usb_hcd_alloc_bandwidth()
1937 ret = hcd->driver->check_bandwidth(hcd, udev); in usb_hcd_alloc_bandwidth()
1940 hcd->driver->reset_bandwidth(hcd, udev); in usb_hcd_alloc_bandwidth()
1955 struct usb_hcd *hcd; in usb_hcd_disable_endpoint() local
1958 hcd = bus_to_hcd(udev->bus); in usb_hcd_disable_endpoint()
1959 if (hcd->driver->endpoint_disable) in usb_hcd_disable_endpoint()
1960 hcd->driver->endpoint_disable(hcd, ep); in usb_hcd_disable_endpoint()
1974 struct usb_hcd *hcd = bus_to_hcd(udev->bus); in usb_hcd_reset_endpoint() local
1976 if (hcd->driver->endpoint_reset) in usb_hcd_reset_endpoint()
1977 hcd->driver->endpoint_reset(hcd, ep); in usb_hcd_reset_endpoint()
2008 struct usb_hcd *hcd; in usb_alloc_streams() local
2013 hcd = bus_to_hcd(dev->bus); in usb_alloc_streams()
2014 if (!hcd->driver->alloc_streams || !hcd->driver->free_streams) in usb_alloc_streams()
2030 ret = hcd->driver->alloc_streams(hcd, dev, eps, num_eps, in usb_alloc_streams()
2058 struct usb_hcd *hcd; in usb_free_streams() local
2063 hcd = bus_to_hcd(dev->bus); in usb_free_streams()
2072 ret = hcd->driver->free_streams(hcd, dev, eps, num_eps, mem_flags); in usb_free_streams()
2099 struct usb_hcd *hcd = bus_to_hcd(udev->bus); in usb_hcd_get_frame_number() local
2101 if (!HCD_RH_RUNNING(hcd)) in usb_hcd_get_frame_number()
2103 return hcd->driver->get_frame_number (hcd); in usb_hcd_get_frame_number()
2112 struct usb_hcd *hcd = bus_to_hcd(rhdev->bus); in hcd_bus_suspend() local
2114 int old_state = hcd->state; in hcd_bus_suspend()
2119 if (HCD_DEAD(hcd)) { in hcd_bus_suspend()
2124 if (!hcd->driver->bus_suspend) { in hcd_bus_suspend()
2127 clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in hcd_bus_suspend()
2128 hcd->state = HC_STATE_QUIESCING; in hcd_bus_suspend()
2129 status = hcd->driver->bus_suspend(hcd); in hcd_bus_suspend()
2133 hcd->state = HC_STATE_SUSPENDED; in hcd_bus_suspend()
2136 usb_phy_roothub_suspend(hcd->self.sysdev, in hcd_bus_suspend()
2137 hcd->phy_roothub); in hcd_bus_suspend()
2143 status = hcd->driver->hub_status_data(hcd, buffer); in hcd_bus_suspend()
2152 if (!HCD_DEAD(hcd)) { in hcd_bus_suspend()
2153 set_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in hcd_bus_suspend()
2154 hcd->state = old_state; in hcd_bus_suspend()
2165 struct usb_hcd *hcd = bus_to_hcd(rhdev->bus); in hcd_bus_resume() local
2167 int old_state = hcd->state; in hcd_bus_resume()
2171 if (HCD_DEAD(hcd)) { in hcd_bus_resume()
2177 status = usb_phy_roothub_resume(hcd->self.sysdev, in hcd_bus_resume()
2178 hcd->phy_roothub); in hcd_bus_resume()
2183 if (!hcd->driver->bus_resume) in hcd_bus_resume()
2185 if (HCD_RH_RUNNING(hcd)) in hcd_bus_resume()
2188 hcd->state = HC_STATE_RESUMING; in hcd_bus_resume()
2189 status = hcd->driver->bus_resume(hcd); in hcd_bus_resume()
2190 clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); in hcd_bus_resume()
2192 status = usb_phy_roothub_calibrate(hcd->phy_roothub); in hcd_bus_resume()
2199 if (!HCD_DEAD(hcd)) { in hcd_bus_resume()
2203 set_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in hcd_bus_resume()
2204 hcd->state = HC_STATE_RUNNING; in hcd_bus_resume()
2222 hcd->state = old_state; in hcd_bus_resume()
2223 usb_phy_roothub_suspend(hcd->self.sysdev, hcd->phy_roothub); in hcd_bus_resume()
2227 usb_hc_died(hcd); in hcd_bus_resume()
2235 struct usb_hcd *hcd = container_of(work, struct usb_hcd, wakeup_work); in hcd_resume_work() local
2236 struct usb_device *udev = hcd->self.root_hub; in hcd_resume_work()
2250 void usb_hcd_resume_root_hub (struct usb_hcd *hcd) in usb_hcd_resume_root_hub() argument
2255 if (hcd->rh_registered) { in usb_hcd_resume_root_hub()
2256 pm_wakeup_event(&hcd->self.root_hub->dev, 0); in usb_hcd_resume_root_hub()
2257 set_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); in usb_hcd_resume_root_hub()
2258 queue_work(pm_wq, &hcd->wakeup_work); in usb_hcd_resume_root_hub()
2285 struct usb_hcd *hcd; in usb_bus_start_enum() local
2292 hcd = bus_to_hcd(bus); in usb_bus_start_enum()
2293 if (port_num && hcd->driver->start_port_reset) in usb_bus_start_enum()
2294 status = hcd->driver->start_port_reset(hcd, port_num); in usb_bus_start_enum()
2300 mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10)); in usb_bus_start_enum()
2321 struct usb_hcd *hcd = __hcd; in usb_hcd_irq() local
2324 if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) in usb_hcd_irq()
2326 else if (hcd->driver->irq(hcd) == IRQ_NONE) in usb_hcd_irq()
2340 struct usb_hcd *hcd = container_of(work, struct usb_hcd, died_work); in hcd_died_work() local
2347 kobject_uevent_env(&hcd->self.root_hub->dev.kobj, KOBJ_OFFLINE, env); in hcd_died_work()
2360 void usb_hc_died (struct usb_hcd *hcd) in usb_hc_died() argument
2364 dev_err (hcd->self.controller, "HC died; cleaning up\n"); in usb_hc_died()
2367 clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in usb_hc_died()
2368 set_bit(HCD_FLAG_DEAD, &hcd->flags); in usb_hc_died()
2369 if (hcd->rh_registered) { in usb_hc_died()
2370 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_hc_died()
2373 usb_set_device_state (hcd->self.root_hub, in usb_hc_died()
2375 usb_kick_hub_wq(hcd->self.root_hub); in usb_hc_died()
2377 if (usb_hcd_is_primary_hcd(hcd) && hcd->shared_hcd) { in usb_hc_died()
2378 hcd = hcd->shared_hcd; in usb_hc_died()
2379 clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in usb_hc_died()
2380 set_bit(HCD_FLAG_DEAD, &hcd->flags); in usb_hc_died()
2381 if (hcd->rh_registered) { in usb_hc_died()
2382 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_hc_died()
2385 usb_set_device_state(hcd->self.root_hub, in usb_hc_died()
2387 usb_kick_hub_wq(hcd->self.root_hub); in usb_hc_died()
2392 if (usb_hcd_is_primary_hcd(hcd)) in usb_hc_died()
2393 schedule_work(&hcd->died_work); in usb_hc_died()
2395 schedule_work(&hcd->primary_hcd->died_work); in usb_hc_died()
2416 struct usb_hcd *hcd; in __usb_create_hcd() local
2418 hcd = kzalloc(sizeof(*hcd) + driver->hcd_priv_size, GFP_KERNEL); in __usb_create_hcd()
2419 if (!hcd) in __usb_create_hcd()
2422 hcd->address0_mutex = kmalloc(sizeof(*hcd->address0_mutex), in __usb_create_hcd()
2424 if (!hcd->address0_mutex) { in __usb_create_hcd()
2425 kfree(hcd); in __usb_create_hcd()
2429 mutex_init(hcd->address0_mutex); in __usb_create_hcd()
2430 hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex), in __usb_create_hcd()
2432 if (!hcd->bandwidth_mutex) { in __usb_create_hcd()
2433 kfree(hcd->address0_mutex); in __usb_create_hcd()
2434 kfree(hcd); in __usb_create_hcd()
2438 mutex_init(hcd->bandwidth_mutex); in __usb_create_hcd()
2439 dev_set_drvdata(dev, hcd); in __usb_create_hcd()
2442 hcd->address0_mutex = primary_hcd->address0_mutex; in __usb_create_hcd()
2443 hcd->bandwidth_mutex = primary_hcd->bandwidth_mutex; in __usb_create_hcd()
2444 hcd->primary_hcd = primary_hcd; in __usb_create_hcd()
2446 hcd->shared_hcd = primary_hcd; in __usb_create_hcd()
2447 primary_hcd->shared_hcd = hcd; in __usb_create_hcd()
2451 kref_init(&hcd->kref); in __usb_create_hcd()
2453 usb_bus_init(&hcd->self); in __usb_create_hcd()
2454 hcd->self.controller = dev; in __usb_create_hcd()
2455 hcd->self.sysdev = sysdev; in __usb_create_hcd()
2456 hcd->self.bus_name = bus_name; in __usb_create_hcd()
2458 timer_setup(&hcd->rh_timer, rh_timer_func, 0); in __usb_create_hcd()
2460 INIT_WORK(&hcd->wakeup_work, hcd_resume_work); in __usb_create_hcd()
2463 INIT_WORK(&hcd->died_work, hcd_died_work); in __usb_create_hcd()
2465 hcd->driver = driver; in __usb_create_hcd()
2466 hcd->speed = driver->flags & HCD_MASK; in __usb_create_hcd()
2467 hcd->product_desc = (driver->product_desc) ? driver->product_desc : in __usb_create_hcd()
2469 return hcd; in __usb_create_hcd()
2529 struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref); in hcd_release() local
2532 if (hcd->shared_hcd) { in hcd_release()
2533 struct usb_hcd *peer = hcd->shared_hcd; in hcd_release()
2538 kfree(hcd->address0_mutex); in hcd_release()
2539 kfree(hcd->bandwidth_mutex); in hcd_release()
2542 kfree(hcd); in hcd_release()
2545 struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd) in usb_get_hcd() argument
2547 if (hcd) in usb_get_hcd()
2548 kref_get (&hcd->kref); in usb_get_hcd()
2549 return hcd; in usb_get_hcd()
2553 void usb_put_hcd (struct usb_hcd *hcd) in usb_put_hcd() argument
2555 if (hcd) in usb_put_hcd()
2556 kref_put (&hcd->kref, hcd_release); in usb_put_hcd()
2560 int usb_hcd_is_primary_hcd(struct usb_hcd *hcd) in usb_hcd_is_primary_hcd() argument
2562 if (!hcd->primary_hcd) in usb_hcd_is_primary_hcd()
2564 return hcd == hcd->primary_hcd; in usb_hcd_is_primary_hcd()
2568 int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1) in usb_hcd_find_raw_port_number() argument
2570 if (!hcd->driver->find_raw_port_number) in usb_hcd_find_raw_port_number()
2573 return hcd->driver->find_raw_port_number(hcd, port1); in usb_hcd_find_raw_port_number()
2576 static int usb_hcd_request_irqs(struct usb_hcd *hcd, in usb_hcd_request_irqs() argument
2581 if (hcd->driver->irq) { in usb_hcd_request_irqs()
2583 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", in usb_hcd_request_irqs()
2584 hcd->driver->description, hcd->self.busnum); in usb_hcd_request_irqs()
2586 hcd->irq_descr, hcd); in usb_hcd_request_irqs()
2588 dev_err(hcd->self.controller, in usb_hcd_request_irqs()
2593 hcd->irq = irqnum; in usb_hcd_request_irqs()
2594 dev_info(hcd->self.controller, "irq %d, %s 0x%08llx\n", irqnum, in usb_hcd_request_irqs()
2595 (hcd->driver->flags & HCD_MEMORY) ? in usb_hcd_request_irqs()
2597 (unsigned long long)hcd->rsrc_start); in usb_hcd_request_irqs()
2599 hcd->irq = 0; in usb_hcd_request_irqs()
2600 if (hcd->rsrc_start) in usb_hcd_request_irqs()
2601 dev_info(hcd->self.controller, "%s 0x%08llx\n", in usb_hcd_request_irqs()
2602 (hcd->driver->flags & HCD_MEMORY) ? in usb_hcd_request_irqs()
2604 (unsigned long long)hcd->rsrc_start); in usb_hcd_request_irqs()
2613 static void usb_put_invalidate_rhdev(struct usb_hcd *hcd) in usb_put_invalidate_rhdev() argument
2618 rhdev = hcd->self.root_hub; in usb_put_invalidate_rhdev()
2619 hcd->self.root_hub = NULL; in usb_put_invalidate_rhdev()
2634 int usb_add_hcd(struct usb_hcd *hcd, in usb_add_hcd() argument
2640 if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) { in usb_add_hcd()
2641 hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev); in usb_add_hcd()
2642 if (IS_ERR(hcd->phy_roothub)) in usb_add_hcd()
2643 return PTR_ERR(hcd->phy_roothub); in usb_add_hcd()
2645 retval = usb_phy_roothub_init(hcd->phy_roothub); in usb_add_hcd()
2649 retval = usb_phy_roothub_set_mode(hcd->phy_roothub, in usb_add_hcd()
2652 retval = usb_phy_roothub_set_mode(hcd->phy_roothub, in usb_add_hcd()
2657 retval = usb_phy_roothub_power_on(hcd->phy_roothub); in usb_add_hcd()
2662 dev_info(hcd->self.controller, "%s\n", hcd->product_desc); in usb_add_hcd()
2666 hcd->dev_policy = USB_DEVICE_AUTHORIZE_NONE; in usb_add_hcd()
2670 hcd->dev_policy = USB_DEVICE_AUTHORIZE_ALL; in usb_add_hcd()
2674 hcd->dev_policy = USB_DEVICE_AUTHORIZE_INTERNAL; in usb_add_hcd()
2679 hcd->dev_policy = hcd->wireless ? in usb_add_hcd()
2684 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); in usb_add_hcd()
2687 set_bit(HCD_FLAG_INTF_AUTHORIZED, &hcd->flags); in usb_add_hcd()
2693 retval = hcd_buffer_create(hcd); in usb_add_hcd()
2695 dev_dbg(hcd->self.sysdev, "pool alloc failed\n"); in usb_add_hcd()
2699 retval = usb_register_bus(&hcd->self); in usb_add_hcd()
2703 rhdev = usb_alloc_dev(NULL, &hcd->self, 0); in usb_add_hcd()
2705 dev_err(hcd->self.sysdev, "unable to allocate root hub\n"); in usb_add_hcd()
2710 hcd->self.root_hub = rhdev; in usb_add_hcd()
2716 switch (hcd->speed) { in usb_add_hcd()
2751 set_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in usb_add_hcd()
2756 if (hcd->driver->reset) { in usb_add_hcd()
2757 retval = hcd->driver->reset(hcd); in usb_add_hcd()
2759 dev_err(hcd->self.controller, "can't setup: %d\n", in usb_add_hcd()
2764 hcd->rh_pollable = 1; in usb_add_hcd()
2766 retval = usb_phy_roothub_calibrate(hcd->phy_roothub); in usb_add_hcd()
2771 if (device_can_wakeup(hcd->self.controller) in usb_add_hcd()
2772 && device_can_wakeup(&hcd->self.root_hub->dev)) in usb_add_hcd()
2773 dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); in usb_add_hcd()
2776 init_giveback_urb_bh(&hcd->high_prio_bh); in usb_add_hcd()
2777 init_giveback_urb_bh(&hcd->low_prio_bh); in usb_add_hcd()
2782 if (usb_hcd_is_primary_hcd(hcd) && irqnum) { in usb_add_hcd()
2783 retval = usb_hcd_request_irqs(hcd, irqnum, irqflags); in usb_add_hcd()
2788 hcd->state = HC_STATE_RUNNING; in usb_add_hcd()
2789 retval = hcd->driver->start(hcd); in usb_add_hcd()
2791 dev_err(hcd->self.controller, "startup error %d\n", retval); in usb_add_hcd()
2796 retval = register_root_hub(hcd); in usb_add_hcd()
2800 if (hcd->uses_new_polling && HCD_POLL_RH(hcd)) in usb_add_hcd()
2801 usb_hcd_poll_rh_status(hcd); in usb_add_hcd()
2806 hcd->rh_pollable = 0; in usb_add_hcd()
2807 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_add_hcd()
2808 del_timer_sync(&hcd->rh_timer); in usb_add_hcd()
2809 hcd->driver->stop(hcd); in usb_add_hcd()
2810 hcd->state = HC_STATE_HALT; in usb_add_hcd()
2811 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_add_hcd()
2812 del_timer_sync(&hcd->rh_timer); in usb_add_hcd()
2814 if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0) in usb_add_hcd()
2815 free_irq(irqnum, hcd); in usb_add_hcd()
2819 usb_put_invalidate_rhdev(hcd); in usb_add_hcd()
2821 usb_deregister_bus(&hcd->self); in usb_add_hcd()
2823 hcd_buffer_destroy(hcd); in usb_add_hcd()
2825 usb_phy_roothub_power_off(hcd->phy_roothub); in usb_add_hcd()
2827 usb_phy_roothub_exit(hcd->phy_roothub); in usb_add_hcd()
2841 void usb_remove_hcd(struct usb_hcd *hcd) in usb_remove_hcd() argument
2843 struct usb_device *rhdev = hcd->self.root_hub; in usb_remove_hcd()
2845 dev_info(hcd->self.controller, "remove, state %x\n", hcd->state); in usb_remove_hcd()
2848 clear_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); in usb_remove_hcd()
2849 if (HC_IS_RUNNING (hcd->state)) in usb_remove_hcd()
2850 hcd->state = HC_STATE_QUIESCING; in usb_remove_hcd()
2852 dev_dbg(hcd->self.controller, "roothub graceful disconnect\n"); in usb_remove_hcd()
2854 hcd->rh_registered = 0; in usb_remove_hcd()
2858 cancel_work_sync(&hcd->wakeup_work); in usb_remove_hcd()
2860 cancel_work_sync(&hcd->died_work); in usb_remove_hcd()
2881 hcd->rh_pollable = 0; in usb_remove_hcd()
2882 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_remove_hcd()
2883 del_timer_sync(&hcd->rh_timer); in usb_remove_hcd()
2885 hcd->driver->stop(hcd); in usb_remove_hcd()
2886 hcd->state = HC_STATE_HALT; in usb_remove_hcd()
2889 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); in usb_remove_hcd()
2890 del_timer_sync(&hcd->rh_timer); in usb_remove_hcd()
2892 if (usb_hcd_is_primary_hcd(hcd)) { in usb_remove_hcd()
2893 if (hcd->irq > 0) in usb_remove_hcd()
2894 free_irq(hcd->irq, hcd); in usb_remove_hcd()
2897 usb_deregister_bus(&hcd->self); in usb_remove_hcd()
2898 hcd_buffer_destroy(hcd); in usb_remove_hcd()
2900 usb_phy_roothub_power_off(hcd->phy_roothub); in usb_remove_hcd()
2901 usb_phy_roothub_exit(hcd->phy_roothub); in usb_remove_hcd()
2903 usb_put_invalidate_rhdev(hcd); in usb_remove_hcd()
2904 hcd->flags = 0; in usb_remove_hcd()
2911 struct usb_hcd *hcd = platform_get_drvdata(dev); in usb_hcd_platform_shutdown() local
2916 if (hcd->driver->shutdown) in usb_hcd_platform_shutdown()
2917 hcd->driver->shutdown(hcd); in usb_hcd_platform_shutdown()
2921 int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr, in usb_hcd_setup_local_mem() argument
2927 hcd->localmem_pool = devm_gen_pool_create(hcd->self.sysdev, 4, in usb_hcd_setup_local_mem()
2928 dev_to_node(hcd->self.sysdev), in usb_hcd_setup_local_mem()
2929 dev_name(hcd->self.sysdev)); in usb_hcd_setup_local_mem()
2930 if (IS_ERR(hcd->localmem_pool)) in usb_hcd_setup_local_mem()
2931 return PTR_ERR(hcd->localmem_pool); in usb_hcd_setup_local_mem()
2933 local_mem = devm_memremap(hcd->self.sysdev, phys_addr, in usb_hcd_setup_local_mem()
2943 err = gen_pool_add_virt(hcd->localmem_pool, (unsigned long)local_mem, in usb_hcd_setup_local_mem()
2944 dma, size, dev_to_node(hcd->self.sysdev)); in usb_hcd_setup_local_mem()
2946 dev_err(hcd->self.sysdev, "gen_pool_add_virt failed with %d\n", in usb_hcd_setup_local_mem()