uhci.c (227461) | uhci.c (228483) |
---|---|
1/*- 2 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/usb/controller/uhci.c 227461 2011-11-12 08:16:45Z hselasky $"); | 29__FBSDID("$FreeBSD: head/sys/dev/usb/controller/uhci.c 228483 2011-12-14 00:28:54Z hselasky $"); |
30 31/* 32 * USB Universal Host Controller driver. 33 * Handles e.g. PIIX3 and PIIX4. 34 * 35 * UHCI spec: http://developer.intel.com/design/USB/UHCI11D.htm 36 * USB spec: http://www.usb.org/developers/docs/usbspec.zip 37 * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf --- 330 unchanged lines hidden (view full) --- 368 } 369 } 370 371 device_printf(sc->sc_bus.bdev, 372 "controller did not stop\n"); 373 374done_2: 375 | 30 31/* 32 * USB Universal Host Controller driver. 33 * Handles e.g. PIIX3 and PIIX4. 34 * 35 * UHCI spec: http://developer.intel.com/design/USB/UHCI11D.htm 36 * USB spec: http://www.usb.org/developers/docs/usbspec.zip 37 * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf --- 330 unchanged lines hidden (view full) --- 368 } 369 } 370 371 device_printf(sc->sc_bus.bdev, 372 "controller did not stop\n"); 373 374done_2: 375 |
376 /* reload the configuration */ 377 UWRITE2(sc, UHCI_FRNUM, sc->sc_saved_frnum); 378 UWRITE1(sc, UHCI_SOF, sc->sc_saved_sof); | 376 /* reset frame number */ 377 UWRITE2(sc, UHCI_FRNUM, 0); 378 /* set default SOF value */ 379 UWRITE1(sc, UHCI_SOF, 0x40); |
379 380 USB_BUS_UNLOCK(&sc->sc_bus); 381 382 /* stop root interrupt */ 383 usb_callout_drain(&sc->sc_root_intr); 384 385 USB_BUS_LOCK(&sc->sc_bus); 386} --- 71 unchanged lines hidden (view full) --- 458 459 usb_callout_init_mtx(&sc->sc_root_intr, &sc->sc_bus.bus_mtx, 0); 460 461#ifdef USB_DEBUG 462 if (uhcidebug > 2) { 463 uhci_dumpregs(sc); 464 } 465#endif | 380 381 USB_BUS_UNLOCK(&sc->sc_bus); 382 383 /* stop root interrupt */ 384 usb_callout_drain(&sc->sc_root_intr); 385 386 USB_BUS_LOCK(&sc->sc_bus); 387} --- 71 unchanged lines hidden (view full) --- 459 460 usb_callout_init_mtx(&sc->sc_root_intr, &sc->sc_bus.bus_mtx, 0); 461 462#ifdef USB_DEBUG 463 if (uhcidebug > 2) { 464 uhci_dumpregs(sc); 465 } 466#endif |
466 sc->sc_saved_sof = 0x40; /* default value */ 467 sc->sc_saved_frnum = 0; /* default frame number */ 468 | |
469 /* 470 * Setup QH's 471 */ 472 sc->sc_ls_ctl_p_last = 473 uhci_init_qh(&sc->sc_hw.ls_ctl_start_pc); 474 475 sc->sc_fs_ctl_p_last = 476 uhci_init_qh(&sc->sc_hw.fs_ctl_start_pc); --- 176 unchanged lines hidden (view full) --- 653 USB_BUS_UNLOCK(&sc->sc_bus); 654 655 /* catch lost interrupts */ 656 uhci_do_poll(&sc->sc_bus); 657 658 return (0); 659} 660 | 467 /* 468 * Setup QH's 469 */ 470 sc->sc_ls_ctl_p_last = 471 uhci_init_qh(&sc->sc_hw.ls_ctl_start_pc); 472 473 sc->sc_fs_ctl_p_last = 474 uhci_init_qh(&sc->sc_hw.fs_ctl_start_pc); --- 176 unchanged lines hidden (view full) --- 651 USB_BUS_UNLOCK(&sc->sc_bus); 652 653 /* catch lost interrupts */ 654 uhci_do_poll(&sc->sc_bus); 655 656 return (0); 657} 658 |
661/* NOTE: suspend/resume is called from 662 * interrupt context and cannot sleep! 663 */ 664 665void | 659static void |
666uhci_suspend(uhci_softc_t *sc) 667{ | 660uhci_suspend(uhci_softc_t *sc) 661{ |
668 USB_BUS_LOCK(&sc->sc_bus); 669 | |
670#ifdef USB_DEBUG 671 if (uhcidebug > 2) { 672 uhci_dumpregs(sc); 673 } 674#endif | 662#ifdef USB_DEBUG 663 if (uhcidebug > 2) { 664 uhci_dumpregs(sc); 665 } 666#endif |
675 /* save some state if BIOS doesn't */ | |
676 | 667 |
677 sc->sc_saved_frnum = UREAD2(sc, UHCI_FRNUM); 678 sc->sc_saved_sof = UREAD1(sc, UHCI_SOF); | 668 USB_BUS_LOCK(&sc->sc_bus); |
679 680 /* stop the controller */ 681 682 uhci_reset(sc); 683 684 /* enter global suspend */ 685 686 UHCICMD(sc, UHCI_CMD_EGSM); 687 | 669 670 /* stop the controller */ 671 672 uhci_reset(sc); 673 674 /* enter global suspend */ 675 676 UHCICMD(sc, UHCI_CMD_EGSM); 677 |
688 usb_pause_mtx(&sc->sc_bus.bus_mtx, 689 USB_MS_TO_TICKS(USB_RESUME_WAIT)); 690 | |
691 USB_BUS_UNLOCK(&sc->sc_bus); 692} 693 | 678 USB_BUS_UNLOCK(&sc->sc_bus); 679} 680 |
694void | 681static void |
695uhci_resume(uhci_softc_t *sc) 696{ 697 USB_BUS_LOCK(&sc->sc_bus); 698 699 /* reset the controller */ 700 701 uhci_reset(sc); 702 703 /* force global resume */ 704 705 UHCICMD(sc, UHCI_CMD_FGR); 706 | 682uhci_resume(uhci_softc_t *sc) 683{ 684 USB_BUS_LOCK(&sc->sc_bus); 685 686 /* reset the controller */ 687 688 uhci_reset(sc); 689 690 /* force global resume */ 691 692 UHCICMD(sc, UHCI_CMD_FGR); 693 |
707 usb_pause_mtx(&sc->sc_bus.bus_mtx, 708 USB_MS_TO_TICKS(USB_RESUME_DELAY)); 709 | |
710 /* and start traffic again */ 711 712 uhci_start(sc); 713 | 694 /* and start traffic again */ 695 696 uhci_start(sc); 697 |
698 USB_BUS_UNLOCK(&sc->sc_bus); 699 |
|
714#ifdef USB_DEBUG | 700#ifdef USB_DEBUG |
715 if (uhcidebug > 2) { | 701 if (uhcidebug > 2) |
716 uhci_dumpregs(sc); | 702 uhci_dumpregs(sc); |
717 } | |
718#endif 719 | 703#endif 704 |
720 USB_BUS_UNLOCK(&sc->sc_bus); 721 | |
722 /* catch lost interrupts */ 723 uhci_do_poll(&sc->sc_bus); 724} 725 726#ifdef USB_DEBUG 727static void 728uhci_dumpregs(uhci_softc_t *sc) 729{ --- 2444 unchanged lines hidden (view full) --- 3174 } 3175 3176 USB_BUS_UNLOCK(udev->bus); 3177 3178 return; 3179} 3180 3181static void | 705 /* catch lost interrupts */ 706 uhci_do_poll(&sc->sc_bus); 707} 708 709#ifdef USB_DEBUG 710static void 711uhci_dumpregs(uhci_softc_t *sc) 712{ --- 2444 unchanged lines hidden (view full) --- 3157 } 3158 3159 USB_BUS_UNLOCK(udev->bus); 3160 3161 return; 3162} 3163 3164static void |
3165uhci_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) 3166{ 3167 struct uhci_softc *sc = UHCI_BUS2SC(bus); 3168 3169 switch (state) { 3170 case USB_HW_POWER_SUSPEND: 3171 case USB_HW_POWER_SHUTDOWN: 3172 uhci_suspend(sc); 3173 break; 3174 case USB_HW_POWER_RESUME: 3175 uhci_resume(sc); 3176 break; 3177 default: 3178 break; 3179 } 3180} 3181 3182static void |
|
3182uhci_set_hw_power(struct usb_bus *bus) 3183{ 3184 struct uhci_softc *sc = UHCI_BUS2SC(bus); 3185 uint32_t flags; 3186 3187 DPRINTF("\n"); 3188 3189 USB_BUS_LOCK(bus); --- 30 unchanged lines hidden (view full) --- 3220{ 3221 .endpoint_init = uhci_ep_init, 3222 .xfer_setup = uhci_xfer_setup, 3223 .xfer_unsetup = uhci_xfer_unsetup, 3224 .get_dma_delay = uhci_get_dma_delay, 3225 .device_resume = uhci_device_resume, 3226 .device_suspend = uhci_device_suspend, 3227 .set_hw_power = uhci_set_hw_power, | 3183uhci_set_hw_power(struct usb_bus *bus) 3184{ 3185 struct uhci_softc *sc = UHCI_BUS2SC(bus); 3186 uint32_t flags; 3187 3188 DPRINTF("\n"); 3189 3190 USB_BUS_LOCK(bus); --- 30 unchanged lines hidden (view full) --- 3221{ 3222 .endpoint_init = uhci_ep_init, 3223 .xfer_setup = uhci_xfer_setup, 3224 .xfer_unsetup = uhci_xfer_unsetup, 3225 .get_dma_delay = uhci_get_dma_delay, 3226 .device_resume = uhci_device_resume, 3227 .device_suspend = uhci_device_suspend, 3228 .set_hw_power = uhci_set_hw_power, |
3229 .set_hw_power_sleep = uhci_set_hw_power_sleep, |
|
3228 .roothub_exec = uhci_roothub_exec, 3229 .xfer_poll = uhci_do_poll, 3230}; | 3230 .roothub_exec = uhci_roothub_exec, 3231 .xfer_poll = uhci_do_poll, 3232}; |