Deleted Added
full compact
ehci_pci.c (227849) ehci_pci.c (228483)
1/*-
2 * Copyright (c) 1998 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Lennart Augustsson (augustss@carlstedt.se) at
7 * Carlstedt Research & Technology.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Lennart Augustsson (augustss@carlstedt.se) at
7 * Carlstedt Research & Technology.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/usb/controller/ehci_pci.c 227849 2011-11-22 21:56:55Z hselasky $");
32__FBSDID("$FreeBSD: head/sys/dev/usb/controller/ehci_pci.c 228483 2011-12-14 00:28:54Z hselasky $");
33
34/*
35 * USB Enhanced Host Controller Driver, a.k.a. USB 2.0 controller.
36 *
37 * The EHCI 1.0 spec can be found at
38 * http://developer.intel.com/technology/usb/download/ehci-r10.pdf
39 * and the USB 2.0 spec at
40 * http://www.usb.org/developers/docs/usb_20.zip

--- 31 unchanged lines hidden (view full) ---

72#include <dev/usb/usb_process.h>
73#include <dev/usb/usb_util.h>
74
75#include <dev/usb/usb_controller.h>
76#include <dev/usb/usb_bus.h>
77#include <dev/usb/usb_pci.h>
78#include <dev/usb/controller/ehci.h>
79#include <dev/usb/controller/ehcireg.h>
33
34/*
35 * USB Enhanced Host Controller Driver, a.k.a. USB 2.0 controller.
36 *
37 * The EHCI 1.0 spec can be found at
38 * http://developer.intel.com/technology/usb/download/ehci-r10.pdf
39 * and the USB 2.0 spec at
40 * http://www.usb.org/developers/docs/usb_20.zip

--- 31 unchanged lines hidden (view full) ---

72#include <dev/usb/usb_process.h>
73#include <dev/usb/usb_util.h>
74
75#include <dev/usb/usb_controller.h>
76#include <dev/usb/usb_bus.h>
77#include <dev/usb/usb_pci.h>
78#include <dev/usb/controller/ehci.h>
79#include <dev/usb/controller/ehcireg.h>
80#include "usb_if.h"
80
81#define PCI_EHCI_VENDORID_ACERLABS 0x10b9
82#define PCI_EHCI_VENDORID_AMD 0x1022
83#define PCI_EHCI_VENDORID_APPLE 0x106b
84#define PCI_EHCI_VENDORID_ATI 0x1002
85#define PCI_EHCI_VENDORID_CMDTECH 0x1095
86#define PCI_EHCI_VENDORID_INTEL 0x8086
87#define PCI_EHCI_VENDORID_NEC 0x1033
88#define PCI_EHCI_VENDORID_OPTI 0x1045
89#define PCI_EHCI_VENDORID_PHILIPS 0x1131
90#define PCI_EHCI_VENDORID_SIS 0x1039
91#define PCI_EHCI_VENDORID_NVIDIA 0x12D2
92#define PCI_EHCI_VENDORID_NVIDIA2 0x10DE
93#define PCI_EHCI_VENDORID_VIA 0x1106
94
81
82#define PCI_EHCI_VENDORID_ACERLABS 0x10b9
83#define PCI_EHCI_VENDORID_AMD 0x1022
84#define PCI_EHCI_VENDORID_APPLE 0x106b
85#define PCI_EHCI_VENDORID_ATI 0x1002
86#define PCI_EHCI_VENDORID_CMDTECH 0x1095
87#define PCI_EHCI_VENDORID_INTEL 0x8086
88#define PCI_EHCI_VENDORID_NEC 0x1033
89#define PCI_EHCI_VENDORID_OPTI 0x1045
90#define PCI_EHCI_VENDORID_PHILIPS 0x1131
91#define PCI_EHCI_VENDORID_SIS 0x1039
92#define PCI_EHCI_VENDORID_NVIDIA 0x12D2
93#define PCI_EHCI_VENDORID_NVIDIA2 0x10DE
94#define PCI_EHCI_VENDORID_VIA 0x1106
95
95static void ehci_pci_takecontroller(device_t self);
96
97static device_probe_t ehci_pci_probe;
98static device_attach_t ehci_pci_attach;
99static device_detach_t ehci_pci_detach;
96static device_probe_t ehci_pci_probe;
97static device_attach_t ehci_pci_attach;
98static device_detach_t ehci_pci_detach;
100static device_suspend_t ehci_pci_suspend;
101static device_resume_t ehci_pci_resume;
102static device_shutdown_t ehci_pci_shutdown;
99static usb_take_controller_t ehci_pci_take_controller;
103
100
104static int
105ehci_pci_suspend(device_t self)
106{
107 ehci_softc_t *sc = device_get_softc(self);
108 int err;
109
110 err = bus_generic_suspend(self);
111 if (err)
112 return (err);
113 ehci_suspend(sc);
114 return (0);
115}
116
117static int
118ehci_pci_resume(device_t self)
119{
120 ehci_softc_t *sc = device_get_softc(self);
121
122 ehci_pci_takecontroller(self);
123 ehci_resume(sc);
124
125 bus_generic_resume(self);
126
127 return (0);
128}
129
130static int
131ehci_pci_shutdown(device_t self)
132{
133 ehci_softc_t *sc = device_get_softc(self);
134 int err;
135
136 err = bus_generic_shutdown(self);
137 if (err)
138 return (err);
139 ehci_shutdown(sc);
140
141 return (0);
142}
143
144static const char *
145ehci_pci_match(device_t self)
146{
147 uint32_t device_id = pci_get_devid(self);
148
149 switch (device_id) {
150 case 0x268c8086:
151 return ("Intel 63XXESB USB 2.0 controller");

--- 261 unchanged lines hidden (view full) ---

413 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
414 (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
415#endif
416 if (err) {
417 device_printf(self, "Could not setup irq, %d\n", err);
418 sc->sc_intr_hdl = NULL;
419 goto error;
420 }
101static const char *
102ehci_pci_match(device_t self)
103{
104 uint32_t device_id = pci_get_devid(self);
105
106 switch (device_id) {
107 case 0x268c8086:
108 return ("Intel 63XXESB USB 2.0 controller");

--- 261 unchanged lines hidden (view full) ---

370 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
371 (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
372#endif
373 if (err) {
374 device_printf(self, "Could not setup irq, %d\n", err);
375 sc->sc_intr_hdl = NULL;
376 goto error;
377 }
421 ehci_pci_takecontroller(self);
378 ehci_pci_take_controller(self);
422
423 /* Undocumented quirks taken from Linux */
424
425 switch (pci_get_vendor(self)) {
426 case PCI_EHCI_VENDORID_ATI:
427 /* SB600 and SB700 EHCI quirk */
428 switch (pci_get_device(self)) {
429 case 0x4386:

--- 95 unchanged lines hidden (view full) ---

525 sc->sc_io_res);
526 sc->sc_io_res = NULL;
527 }
528 usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);
529
530 return (0);
531}
532
379
380 /* Undocumented quirks taken from Linux */
381
382 switch (pci_get_vendor(self)) {
383 case PCI_EHCI_VENDORID_ATI:
384 /* SB600 and SB700 EHCI quirk */
385 switch (pci_get_device(self)) {
386 case 0x4386:

--- 95 unchanged lines hidden (view full) ---

482 sc->sc_io_res);
483 sc->sc_io_res = NULL;
484 }
485 usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);
486
487 return (0);
488}
489
533static void
534ehci_pci_takecontroller(device_t self)
490static int
491ehci_pci_take_controller(device_t self)
535{
536 ehci_softc_t *sc = device_get_softc(self);
537 uint32_t cparams;
538 uint32_t eec;
539 uint16_t to;
540 uint8_t eecp;
541 uint8_t bios_sem;
542

--- 25 unchanged lines hidden (view full) ---

568 if (--to == 0) {
569 device_printf(sc->sc_bus.bdev,
570 "timed out waiting for BIOS\n");
571 break;
572 }
573 usb_pause_mtx(NULL, hz / 100); /* wait 10ms */
574 }
575 }
492{
493 ehci_softc_t *sc = device_get_softc(self);
494 uint32_t cparams;
495 uint32_t eec;
496 uint16_t to;
497 uint8_t eecp;
498 uint8_t bios_sem;
499

--- 25 unchanged lines hidden (view full) ---

525 if (--to == 0) {
526 device_printf(sc->sc_bus.bdev,
527 "timed out waiting for BIOS\n");
528 break;
529 }
530 usb_pause_mtx(NULL, hz / 100); /* wait 10ms */
531 }
532 }
533 return (0);
576}
577
534}
535
578static driver_t ehci_driver =
579{
580 .name = "ehci",
581 .methods = (device_method_t[]){
582 /* device interface */
583 DEVMETHOD(device_probe, ehci_pci_probe),
584 DEVMETHOD(device_attach, ehci_pci_attach),
585 DEVMETHOD(device_detach, ehci_pci_detach),
586 DEVMETHOD(device_suspend, ehci_pci_suspend),
587 DEVMETHOD(device_resume, ehci_pci_resume),
588 DEVMETHOD(device_shutdown, ehci_pci_shutdown),
536static device_method_t ehci_pci_methods[] = {
537 /* Device interface */
538 DEVMETHOD(device_probe, ehci_pci_probe),
539 DEVMETHOD(device_attach, ehci_pci_attach),
540 DEVMETHOD(device_detach, ehci_pci_detach),
541 DEVMETHOD(device_suspend, bus_generic_suspend),
542 DEVMETHOD(device_resume, bus_generic_resume),
543 DEVMETHOD(device_shutdown, bus_generic_shutdown),
544 DEVMETHOD(usb_take_controller, ehci_pci_take_controller),
589
545
590 DEVMETHOD_END
591 },
546 DEVMETHOD_END
547};
548
549static driver_t ehci_driver = {
550 .name = "ehci",
551 .methods = ehci_pci_methods,
592 .size = sizeof(struct ehci_softc),
593};
594
595static devclass_t ehci_devclass;
596
597DRIVER_MODULE(ehci, pci, ehci_driver, ehci_devclass, 0, 0);
598MODULE_DEPEND(ehci, usb, 1, 1, 1);
552 .size = sizeof(struct ehci_softc),
553};
554
555static devclass_t ehci_devclass;
556
557DRIVER_MODULE(ehci, pci, ehci_driver, ehci_devclass, 0, 0);
558MODULE_DEPEND(ehci, usb, 1, 1, 1);