• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/usb/core/

Lines Matching defs:hub

2  * USB hub driver.
32 #include "hub.h"
43 struct usb_hub_status hub;
104 * hub driver's behavior. On the first initialization attempt, if the
187 struct usb_hub *hub,
192 int status = set_port_feature(hub->hdev, (selector << 8) | port1,
195 dev_dbg (hub->intfdev,
212 struct usb_hub *hub =
214 struct usb_device *hdev = hub->hdev;
219 if (hdev->state != USB_STATE_CONFIGURED || hub->quiescing)
222 for (i = 0; i < hub->descriptor->bNbrPorts; i++) {
227 switch (hub->indicator[i]) {
266 set_port_led(hub, i + 1, selector);
267 hub->indicator[i] = mode;
271 cursor %= hub->descriptor->bNbrPorts;
272 set_port_led(hub, cursor + 1, HUB_LED_GREEN);
273 hub->indicator[cursor] = INDICATOR_CYCLE;
277 schedule_delayed_work(&hub->leds, LED_CYCLE_PERIOD);
280 /* use a short timeout for hub/port status fetches */
316 static void kick_khubd(struct usb_hub *hub)
321 to_usb_interface(hub->intfdev)->pm_usage_cnt = 1;
324 if (list_empty(&hub->event_list)) {
325 list_add_tail(&hub->event_list, &hub_event_list);
340 struct usb_hub *hub = urb->context;
352 /* Cause a hub reset after 10 consecutive errors */
353 dev_dbg (hub->intfdev, "transfer --> %d\n", urb->status);
354 if ((++hub->nerrors < 10) || hub->error)
356 hub->error = urb->status;
363 bits |= ((unsigned long) ((*hub->buffer)[i]))
365 hub->event_bits[0] = bits;
369 hub->nerrors = 0;
372 kick_khubd(hub);
375 if (hub->quiescing)
378 if ((status = usb_submit_urb (hub->urb, GFP_ATOMIC)) != 0
380 dev_err (hub->intfdev, "resubmit --> %d\n", status);
396 * both can talk to the same hub concurrently.
400 struct usb_hub *hub =
404 spin_lock_irqsave (&hub->tt.lock, flags);
405 while (!list_empty (&hub->tt.clear_list)) {
408 struct usb_device *hdev = hub->hdev;
411 temp = hub->tt.clear_list.next;
416 spin_unlock_irqrestore (&hub->tt.lock, flags);
418 spin_lock_irqsave (&hub->tt.lock, flags);
426 spin_unlock_irqrestore (&hub->tt.lock, flags);
430 * usb_hub_tt_clear_buffer - clear control/bulk TT state in high speed hub
434 * High speed HCDs use this to tell the hub driver that some split control or
439 * It may not be possible for that hub to handle additional full (or low)
450 * there can be many TTs per hub). even if they're uncommon.
474 static void hub_power_on(struct usb_hub *hub)
477 unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2;
479 le16_to_cpu(hub->descriptor->wHubCharacteristics);
485 * unless we send these messages to the hub.
488 dev_dbg(hub->intfdev, "enabling power on all ports\n");
490 dev_dbg(hub->intfdev, "trying to enable port power on "
491 "non-switchable hub\n");
492 for (port1 = 1; port1 <= hub->descriptor->bNbrPorts; port1++)
493 set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
499 static void hub_quiesce(struct usb_hub *hub)
502 hub->quiescing = 1;
503 hub->activating = 0;
506 usb_kill_urb(hub->urb);
507 if (hub->has_indicators)
508 cancel_delayed_work(&hub->leds);
509 if (hub->has_indicators || hub->tt.hub)
513 static void hub_activate(struct usb_hub *hub)
517 hub->quiescing = 0;
518 hub->activating = 1;
520 status = usb_submit_urb(hub->urb, GFP_NOIO);
522 dev_err(hub->intfdev, "activate --> %d\n", status);
523 if (hub->has_indicators && blinkenlights)
524 schedule_delayed_work(&hub->leds, LED_CYCLE_PERIOD);
527 kick_khubd(hub);
530 static int hub_hub_status(struct usb_hub *hub,
535 mutex_lock(&hub->status_mutex);
536 ret = get_hub_status(hub->hdev, &hub->status->hub);
538 dev_err (hub->intfdev,
541 *status = le16_to_cpu(hub->status->hub.wHubStatus);
542 *change = le16_to_cpu(hub->status->hub.wHubChange);
545 mutex_unlock(&hub->status_mutex);
549 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
551 struct usb_device *hdev = hub->hdev;
560 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
567 /* caller has locked the hub device */
570 struct usb_hub *hub = usb_get_intfdata(intf);
571 struct usb_device *hdev = hub->hdev;
577 if (hub->error == 0)
578 hub_port_disable(hub, port1, 0);
581 hub_quiesce(hub);
584 /* caller has locked the hub device */
587 struct usb_hub *hub = usb_get_intfdata(intf);
589 hub_activate(hub);
590 hub_power_on(hub);
594 static int hub_configure(struct usb_hub *hub,
597 struct usb_device *hdev = hub->hdev;
598 struct device *hub_dev = hub->intfdev;
605 hub->buffer = usb_buffer_alloc(hdev, sizeof(*hub->buffer), GFP_KERNEL,
606 &hub->buffer_dma);
607 if (!hub->buffer) {
608 message = "can't allocate hub irq buffer";
613 hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL);
614 if (!hub->status) {
615 message = "can't kmalloc hub status buffer";
619 mutex_init(&hub->status_mutex);
621 hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL);
622 if (!hub->descriptor) {
623 message = "can't kmalloc hub descriptor";
628 /* Request the entire hub descriptor.
629 * hub->descriptor can handle USB_MAXCHILDREN ports,
630 * but the hub can/will return fewer bytes here.
632 ret = get_hub_descriptor(hdev, hub->descriptor,
633 sizeof(*hub->descriptor));
635 message = "can't read hub descriptor";
637 } else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) {
638 message = "hub has too many ports!";
643 hdev->maxchild = hub->descriptor->bNbrPorts;
647 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
654 portstr[i] = hub->descriptor->DeviceRemovable
660 dev_dbg(hub_dev, "standalone hub\n");
688 spin_lock_init (&hub->tt.lock);
689 INIT_LIST_HEAD (&hub->tt.clear_list);
690 INIT_WORK (&hub->tt.kevent, hub_tt_kevent);
696 hub->tt.hub = hdev;
702 hub->tt.multi = 1;
706 hub->tt.hub = hdev;
709 dev_dbg(hub_dev, "Unrecognized hub protocol %d\n",
718 hub->tt.think_time = 666;
721 8, hub->tt.think_time);
725 hub->tt.think_time = 666 * 2;
728 16, hub->tt.think_time);
731 hub->tt.think_time = 666 * 3;
734 24, hub->tt.think_time);
737 hub->tt.think_time = 666 * 4;
740 32, hub->tt.think_time);
744 /* probe() zeroes hub->indicator[] */
746 hub->has_indicators = 1;
751 hub->descriptor->bPwrOn2PwrGood * 2);
758 message = "can't get hub status";
764 hub->mA_per_port = 500;
766 hub->mA_per_port = hdev->bus_mA;
767 hub->limited_power = 1;
770 dev_dbg(hub_dev, "hub controller current requirement: %dmA\n",
771 hub->descriptor->bHubContrCurrent);
772 hub->limited_power = 1;
775 hub->descriptor->bHubContrCurrent;
781 hub->mA_per_port = 100; /* 7.2.1.1 */
783 } else { /* Self-powered external hub */
784 hub->mA_per_port = 500;
786 if (hub->mA_per_port < 500)
788 hub->mA_per_port);
790 ret = hub_hub_status(hub, &hubstatus, &hubchange);
792 message = "can't get hub status";
815 if (maxp > sizeof(*hub->buffer))
816 maxp = sizeof(*hub->buffer);
818 hub->urb = usb_alloc_urb(0, GFP_KERNEL);
819 if (!hub->urb) {
825 usb_fill_int_urb(hub->urb, hdev, pipe, *hub->buffer, maxp, hub_irq,
826 hub, endpoint->bInterval);
827 hub->urb->transfer_dma = hub->buffer_dma;
828 hub->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
830 /* maybe cycle the hub leds */
831 if (hub->has_indicators && blinkenlights)
832 hub->indicator [0] = INDICATOR_CYCLE;
834 hub_power_on(hub);
835 hub_activate(hub);
849 struct usb_hub *hub = usb_get_intfdata (intf);
852 /* Disconnect all children and quiesce the hub */
853 hub->error = 0;
857 hdev = hub->hdev;
862 usb_free_urb(hub->urb);
863 hub->urb = NULL;
866 list_del_init(&hub->event_list);
869 kfree(hub->descriptor);
870 hub->descriptor = NULL;
872 kfree(hub->status);
873 hub->status = NULL;
875 if (hub->buffer) {
876 usb_buffer_free(hdev, sizeof(*hub->buffer), hub->buffer,
877 hub->buffer_dma);
878 hub->buffer = NULL;
881 kfree(hub);
889 struct usb_hub *hub;
896 dev_warn(&intf->dev, "ignoring external hub\n");
906 dev_err (&intf->dev, "bad descriptor, ignoring hub\n");
910 /* Multiple endpoints? What kind of mutant ninja-hub is this? */
920 /* We found a hub */
921 dev_info (&intf->dev, "USB hub found\n");
923 hub = kzalloc(sizeof(*hub), GFP_KERNEL);
924 if (!hub) {
925 dev_dbg (&intf->dev, "couldn't kmalloc hub struct\n");
929 INIT_LIST_HEAD(&hub->event_list);
930 hub->intfdev = &intf->dev;
931 hub->hdev = hdev;
932 INIT_DELAYED_WORK(&hub->leds, led_work);
934 usb_set_intfdata (intf, hub);
940 if (hub_configure(hub, endpoint) >= 0)
952 /* assert ifno == 0 (part of hub spec) */
995 /* root hub is always the first lock in the series */
1069 /* root hub wakeup capabilities are managed out-of-band
1093 * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power
1094 * @rhdev: struct usb_device for the root hub
1096 * The USB host controller driver calls this function when its root hub
1098 * has been reset. The routine marks all the children of the root hub
1103 struct usb_hub *hub;
1107 dev_warn(&rhdev->dev, "root hub lost power or was reset\n");
1110 * by forcing the root hub to be resumed.
1115 hub = hdev_to_hub(rhdev);
1120 set_bit(port1, hub->change_bits);
1189 * If *pdev is a normal device then the parent hub must already be locked.
1190 * If *pdev is a root hub then this routine will acquire the
1193 * Only hub drivers (including virtual root hub drivers for host
1279 * the parent hub (if udev is a normal device) or else the
1280 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1290 * Only the hub driver or root-hub registrar should ever call this.
1410 static int hub_port_status(struct usb_hub *hub, int port1,
1415 mutex_lock(&hub->status_mutex);
1416 ret = get_port_status(hub->hdev, port1, &hub->status->port);
1418 dev_err (hub->intfdev,
1423 *status = le16_to_cpu(hub->status->port.wPortStatus);
1424 *change = le16_to_cpu(hub->status->port.wPortChange);
1427 mutex_unlock(&hub->status_mutex);
1432 /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */
1433 static unsigned hub_is_wusb(struct usb_hub *hub)
1436 if (hub->hdev->parent != NULL) /* not a root hub? */
1438 hcd = container_of(hub->hdev->bus, struct usb_hcd, self);
1454 static int hub_port_wait_reset(struct usb_hub *hub, int port1,
1468 ret = hub_port_status(hub, port1, &portstatus, &portchange);
1483 if (hub_is_wusb(hub))
1498 dev_dbg (hub->intfdev,
1506 static int hub_port_reset(struct usb_hub *hub, int port1,
1513 status = set_port_feature(hub->hdev,
1516 dev_err(hub->intfdev,
1520 status = hub_port_wait_reset(hub, port1, udev, delay);
1522 dev_dbg(hub->intfdev,
1535 clear_port_feature(hub->hdev,
1543 dev_dbg (hub->intfdev,
1549 dev_err (hub->intfdev,
1561 static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
1563 dev_dbg(hub->intfdev, "logical disconnect on port %d\n", port1);
1564 hub_port_disable(hub, port1, 1);
1567 set_bit(port1, hub->change_bits);
1568 kick_khubd(hub);
1585 static int hub_port_suspend(struct usb_hub *hub, int port1,
1590 // dev_dbg(hub->intfdev, "suspend port %d\n", port1);
1593 * wake up the upstream hub (including maybe the root hub).
1611 status = set_port_feature(hub->hdev, port1, USB_PORT_FEAT_SUSPEND);
1613 dev_dbg(hub->intfdev,
1633 * Devices on USB hub ports have only one "suspend" state, corresponding
1642 * Other than re-initializing the hub (plug/unplug, except for root hubs),
1647 * the root hub for their bus goes into global suspend ... so we don't
1759 hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1765 status = hub_port_status(hub, port1, &portstatus, &portchange);
1769 // dev_dbg(hub->intfdev, "resume port %d\n", port1);
1771 set_bit(port1, hub->busy_bits);
1774 status = clear_port_feature(hub->hdev,
1777 dev_dbg(hub->intfdev,
1795 status = hub_port_status(hub, port1, &portstatus, &portchange);
1801 dev_dbg(hub->intfdev,
1808 clear_port_feature(hub->hdev, port1,
1817 hub_port_logical_disconnect(hub, port1);
1819 clear_bit(port1, hub->busy_bits);
1820 if (!hub->hdev->parent && !hub->busy_bits[0])
1821 usb_enable_root_hub_irq(hub->hdev->bus);
1890 hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1909 struct usb_hub *hub = usb_get_intfdata (intf);
1910 struct usb_device *hdev = hub->hdev;
1937 hub_quiesce(hub);
1944 hub_activate(hub);
1952 struct usb_hub *hub = usb_get_intfdata (intf);
1953 struct usb_device *hdev = hub->hdev;
1976 /* tell khubd to look for changes on this hub */
1977 hub_activate(hub);
2013 static int hub_port_debounce(struct usb_hub *hub, int port1)
2021 ret = hub_port_status(hub, port1, &portstatus, &portchange);
2036 clear_port_feature(hub->hdev, port1,
2045 dev_dbg (hub->intfdev,
2094 hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2099 struct usb_device *hdev = hub->hdev;
2105 /* root hub ports have a slightly longer reset period
2122 retval = hub_port_reset(hub, port1, udev, delay);
2182 udev->tt = &hub->tt;
2241 retval = hub_port_reset(hub, port1, udev, delay);
2323 hub_port_disable(hub, port1, 0);
2329 check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
2342 "connect to a high speed hub\n");
2343 /* hub LEDs are probably harder to miss than syslog */
2344 if (hub->has_indicators) {
2345 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK;
2346 schedule_delayed_work (&hub->leds, 0);
2353 hub_power_remaining (struct usb_hub *hub)
2355 struct usb_device *hdev = hub->hdev;
2359 if (!hub->limited_power)
2362 remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent;
2378 if (delta > hub->mA_per_port)
2381 delta, hub->mA_per_port, port1);
2385 dev_warn(hub->intfdev, "%dmA over power budget!\n",
2398 * caller already locked the hub
2400 static void hub_port_connect_change(struct usb_hub *hub, int port1,
2403 struct usb_device *hdev = hub->hdev;
2404 struct device *hub_dev = hub->intfdev;
2405 u16 wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics);
2412 if (hub->has_indicators) {
2413 set_port_led(hub, port1, HUB_LED_AUTO);
2414 hub->indicator[port1-1] = INDICATOR_AUTO;
2420 clear_bit(port1, hub->change_bits);
2429 status = hub_port_debounce(hub, port1);
2442 /* maybe switch power back on (e.g. root hub was reset) */
2455 status = hub_port_resume(hub, port1, NULL);
2481 udev->bus_mA = hub->mA_per_port;
2492 status = hub_port_init(hub, udev, port1, i);
2515 "can't connect bus-powered hub "
2517 if (hub->has_indicators) {
2518 hub->indicator[port1-1] =
2520 schedule_delayed_work (&hub->leds, 0);
2531 check_highspeed (hub, udev, port1);
2539 /* We mustn't add new devices if the parent hub has
2563 status = hub_power_remaining(hub);
2570 hub_port_disable(hub, port1, 1);
2580 hub_port_disable(hub, port1, 1);
2588 struct usb_hub *hub;
2600 * safe since we delete the hub from the event list.
2615 hub = list_entry(tmp, struct usb_hub, event_list);
2616 hdev = hub->hdev;
2617 intf = to_usb_interface(hub->intfdev);
2621 hdev->state, hub->descriptor
2622 ? hub->descriptor->bNbrPorts
2625 (u16) hub->change_bits[0],
2626 (u16) hub->event_bits[0]);
2637 if (hub != usb_get_intfdata(intf))
2640 /* If the hub has died, clean up after it */
2642 hub->error = -ENODEV;
2654 /* If this is an inactive hub, do nothing */
2655 if (hub->quiescing)
2658 if (hub->error) {
2660 hub->error);
2665 "error resetting hub: %d\n", ret);
2669 hub->nerrors = 0;
2670 hub->error = 0;
2674 for (i = 1; i <= hub->descriptor->bNbrPorts; i++) {
2675 if (test_bit(i, hub->busy_bits))
2677 connect_change = test_bit(i, hub->change_bits);
2678 if (!test_and_clear_bit(i, hub->event_bits) &&
2679 !connect_change && !hub->activating)
2682 ret = hub_port_status(hub, i,
2687 if (hub->activating && !hdev->children[i-1] &&
2710 * the hub, this hack enables them again.
2718 "disabled by hub (EMI?), "
2735 hub_port_disable(hub, i, 1);
2748 hub_power_on(hub);
2760 hub_port_connect_change(hub, i,
2764 /* deal with hub status changes */
2765 if (test_and_clear_bit(0, hub->event_bits) == 0)
2767 else if (hub_hub_status(hub, &hubstatus, &hubchange) < 0)
2774 hub->limited_power = 0;
2776 hub->limited_power = 1;
2782 hub_power_on(hub);
2786 hub->activating = 0;
2788 /* If this is a root hub, tell the HCD it's okay to
2790 if (!hdev->parent && !hub->busy_bits[0])
2795 if (list_empty(&hub->event_list))
2829 .name = "hub",
2844 printk(KERN_ERR "%s: can't register hub driver\n",
2869 * individual hub resources. -greg
2954 dev_dbg(&udev->dev, "%s for root hub!\n", __FUNCTION__);