usb_hub.c (187970) | usb_hub.c (188411) |
---|---|
1/* $FreeBSD: head/sys/dev/usb2/core/usb2_hub.c 187970 2009-02-01 00:51:25Z thompsa $ */ | 1/* $FreeBSD: head/sys/dev/usb2/core/usb2_hub.c 188411 2009-02-09 21:56:33Z thompsa $ */ |
2/*- 3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 5 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: --- 320 unchanged lines hidden (view full) --- 330 "suspended, clearing.\n", portno); 331 err = usb2_req_clear_port_feature(sc->sc_udev, 332 &Giant, portno, UHF_PORT_SUSPEND); 333 } 334 /* USB Host Mode */ 335 336 /* wait for maximum device power up time */ 337 | 2/*- 3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 5 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: --- 320 unchanged lines hidden (view full) --- 330 "suspended, clearing.\n", portno); 331 err = usb2_req_clear_port_feature(sc->sc_udev, 332 &Giant, portno, UHF_PORT_SUSPEND); 333 } 334 /* USB Host Mode */ 335 336 /* wait for maximum device power up time */ 337 |
338 usb2_pause_mtx(&Giant, USB_PORT_POWERUP_DELAY); | 338 usb2_pause_mtx(&Giant, 339 USB_MS_TO_TICKS(USB_PORT_POWERUP_DELAY)); |
339 340 /* reset port, which implies enabling it */ 341 342 err = usb2_req_reset_port(udev, &Giant, portno); 343 344 if (err) { 345 DPRINTFN(0, "port %d reset " 346 "failed, error=%s\n", --- 384 unchanged lines hidden (view full) --- 731 err = usb2_transfer_setup(udev, &iface_index, sc->sc_xfer, 732 uhub_config, UHUB_N_TRANSFER, sc, &Giant); 733 if (err) { 734 DPRINTFN(0, "cannot setup interrupt transfer, " 735 "errstr=%s!\n", usb2_errstr(err)); 736 goto error; 737 } 738 /* wait with power off for a while */ | 340 341 /* reset port, which implies enabling it */ 342 343 err = usb2_req_reset_port(udev, &Giant, portno); 344 345 if (err) { 346 DPRINTFN(0, "port %d reset " 347 "failed, error=%s\n", --- 384 unchanged lines hidden (view full) --- 732 err = usb2_transfer_setup(udev, &iface_index, sc->sc_xfer, 733 uhub_config, UHUB_N_TRANSFER, sc, &Giant); 734 if (err) { 735 DPRINTFN(0, "cannot setup interrupt transfer, " 736 "errstr=%s!\n", usb2_errstr(err)); 737 goto error; 738 } 739 /* wait with power off for a while */ |
739 usb2_pause_mtx(&Giant, USB_POWER_DOWN_TIME); | 740 usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(USB_POWER_DOWN_TIME)); |
740 741 /* 742 * To have the best chance of success we do things in the exact same 743 * order as Windoze98. This should not be necessary, but some 744 * devices do not follow the USB specs to the letter. 745 * 746 * These are the events on the bus when a hub is attached: 747 * Get device and config descriptors (see attach code) --- 41 unchanged lines hidden (view full) --- 789 if (err) { 790 DPRINTFN(0, "port %d power on failed, %s\n", 791 portno, usb2_errstr(err)); 792 } 793 DPRINTF("turn on port %d power\n", 794 portno); 795 796 /* wait for stable power */ | 741 742 /* 743 * To have the best chance of success we do things in the exact same 744 * order as Windoze98. This should not be necessary, but some 745 * devices do not follow the USB specs to the letter. 746 * 747 * These are the events on the bus when a hub is attached: 748 * Get device and config descriptors (see attach code) --- 41 unchanged lines hidden (view full) --- 790 if (err) { 791 DPRINTFN(0, "port %d power on failed, %s\n", 792 portno, usb2_errstr(err)); 793 } 794 DPRINTF("turn on port %d power\n", 795 portno); 796 797 /* wait for stable power */ |
797 usb2_pause_mtx(&Giant, pwrdly); | 798 usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(pwrdly)); |
798 } 799 800 device_printf(dev, "%d port%s with %d " 801 "removable, %s powered\n", nports, (nports != 1) ? "s" : "", 802 removable, udev->flags.self_powered ? "self" : "bus"); 803 804 /* start the interrupt endpoint */ 805 --- 855 unchanged lines hidden (view full) --- 1661 /* resume current port (Valid in Host and Device Mode) */ 1662 err = usb2_req_clear_port_feature(udev->parent_hub, 1663 &Giant, udev->port_no, UHF_PORT_SUSPEND); 1664 if (err) { 1665 DPRINTFN(0, "Resuming port failed!\n"); 1666 return; 1667 } 1668 /* resume settle time */ | 799 } 800 801 device_printf(dev, "%d port%s with %d " 802 "removable, %s powered\n", nports, (nports != 1) ? "s" : "", 803 removable, udev->flags.self_powered ? "self" : "bus"); 804 805 /* start the interrupt endpoint */ 806 --- 855 unchanged lines hidden (view full) --- 1662 /* resume current port (Valid in Host and Device Mode) */ 1663 err = usb2_req_clear_port_feature(udev->parent_hub, 1664 &Giant, udev->port_no, UHF_PORT_SUSPEND); 1665 if (err) { 1666 DPRINTFN(0, "Resuming port failed!\n"); 1667 return; 1668 } 1669 /* resume settle time */ |
1669 usb2_pause_mtx(&Giant, USB_PORT_RESUME_DELAY); | 1670 usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(USB_PORT_RESUME_DELAY)); |
1670 1671 if (bus->methods->device_resume != NULL) { 1672 /* resume USB device on the USB controller */ 1673 (bus->methods->device_resume) (udev); 1674 } 1675 USB_BUS_LOCK(bus); 1676 /* set that this device is now resumed */ 1677 udev->pwr_save.suspended = 0; --- 119 unchanged lines hidden (view full) --- 1797 1798 if (udev->bus->methods->device_suspend != NULL) { 1799 1800 /* suspend device on the USB controller */ 1801 (udev->bus->methods->device_suspend) (udev); 1802 1803 /* do DMA delay */ 1804 temp = usb2_get_dma_delay(udev->bus); | 1671 1672 if (bus->methods->device_resume != NULL) { 1673 /* resume USB device on the USB controller */ 1674 (bus->methods->device_resume) (udev); 1675 } 1676 USB_BUS_LOCK(bus); 1677 /* set that this device is now resumed */ 1678 udev->pwr_save.suspended = 0; --- 119 unchanged lines hidden (view full) --- 1798 1799 if (udev->bus->methods->device_suspend != NULL) { 1800 1801 /* suspend device on the USB controller */ 1802 (udev->bus->methods->device_suspend) (udev); 1803 1804 /* do DMA delay */ 1805 temp = usb2_get_dma_delay(udev->bus); |
1805 usb2_pause_mtx(&Giant, temp); | 1806 usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(temp)); |
1806 1807 } 1808 /* suspend current port */ 1809 err = usb2_req_set_port_feature(udev->parent_hub, 1810 &Giant, udev->port_no, UHF_PORT_SUSPEND); 1811 if (err) { 1812 DPRINTFN(0, "Suspending port failed\n"); 1813 return; --- 28 unchanged lines hidden --- | 1807 1808 } 1809 /* suspend current port */ 1810 err = usb2_req_set_port_feature(udev->parent_hub, 1811 &Giant, udev->port_no, UHF_PORT_SUSPEND); 1812 if (err) { 1813 DPRINTFN(0, "Suspending port failed\n"); 1814 return; --- 28 unchanged lines hidden --- |