| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: uhci.c,v 1.227 2009/05/02 22:09:39 martin Exp $ */ | | 1 | /* $NetBSD: uhci.c,v 1.228 2009/05/02 22:28:41 martin Exp $ */ |
2 | /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ | | 2 | /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. | | 5 | * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Lennart Augustsson (lennart@augustsson.net) at | | 9 | * by Lennart Augustsson (lennart@augustsson.net) at |
10 | * Carlstedt Research & Technology. | | 10 | * Carlstedt Research & Technology. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -32,27 +32,27 @@ | | | @@ -32,27 +32,27 @@ |
32 | */ | | 32 | */ |
33 | | | 33 | |
34 | /* | | 34 | /* |
35 | * USB Universal Host Controller driver. | | 35 | * USB Universal Host Controller driver. |
36 | * Handles e.g. PIIX3 and PIIX4. | | 36 | * Handles e.g. PIIX3 and PIIX4. |
37 | * | | 37 | * |
38 | * UHCI spec: http://developer.intel.com/design/USB/UHCI11D.htm | | 38 | * UHCI spec: http://developer.intel.com/design/USB/UHCI11D.htm |
39 | * USB spec: http://www.usb.org/developers/docs/usbspec.zip | | 39 | * USB spec: http://www.usb.org/developers/docs/usbspec.zip |
40 | * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf | | 40 | * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf |
41 | * ftp://download.intel.com/design/intarch/datashts/29056201.pdf | | 41 | * ftp://download.intel.com/design/intarch/datashts/29056201.pdf |
42 | */ | | 42 | */ |
43 | | | 43 | |
44 | #include <sys/cdefs.h> | | 44 | #include <sys/cdefs.h> |
45 | __KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.227 2009/05/02 22:09:39 martin Exp $"); | | 45 | __KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.228 2009/05/02 22:28:41 martin Exp $"); |
46 | | | 46 | |
47 | #include <sys/param.h> | | 47 | #include <sys/param.h> |
48 | #include <sys/systm.h> | | 48 | #include <sys/systm.h> |
49 | #include <sys/kernel.h> | | 49 | #include <sys/kernel.h> |
50 | #include <sys/malloc.h> | | 50 | #include <sys/malloc.h> |
51 | #if defined(__NetBSD__) || defined(__OpenBSD__) | | 51 | #if defined(__NetBSD__) || defined(__OpenBSD__) |
52 | #include <sys/device.h> | | 52 | #include <sys/device.h> |
53 | #include <sys/select.h> | | 53 | #include <sys/select.h> |
54 | #include <sys/extent.h> | | 54 | #include <sys/extent.h> |
55 | #include <uvm/uvm_extern.h> | | 55 | #include <uvm/uvm_extern.h> |
56 | #elif defined(__FreeBSD__) | | 56 | #elif defined(__FreeBSD__) |
57 | #include <sys/module.h> | | 57 | #include <sys/module.h> |
58 | #include <sys/bus.h> | | 58 | #include <sys/bus.h> |
| @@ -1030,27 +1030,28 @@ void iidump(void) { uhci_dump_iis(thesc) | | | @@ -1030,27 +1030,28 @@ void iidump(void) { uhci_dump_iis(thesc) |
1030 | * from the root controller interrupt pipe for port status change. | | 1030 | * from the root controller interrupt pipe for port status change. |
1031 | */ | | 1031 | */ |
1032 | void | | 1032 | void |
1033 | uhci_poll_hub(void *addr) | | 1033 | uhci_poll_hub(void *addr) |
1034 | { | | 1034 | { |
1035 | usbd_xfer_handle xfer = addr; | | 1035 | usbd_xfer_handle xfer = addr; |
1036 | usbd_pipe_handle pipe = xfer->pipe; | | 1036 | usbd_pipe_handle pipe = xfer->pipe; |
1037 | uhci_softc_t *sc; | | 1037 | uhci_softc_t *sc; |
1038 | int s; | | 1038 | int s; |
1039 | u_char *p; | | 1039 | u_char *p; |
1040 | | | 1040 | |
1041 | DPRINTFN(20, ("uhci_poll_hub\n")); | | 1041 | DPRINTFN(20, ("uhci_poll_hub\n")); |
1042 | | | 1042 | |
1043 | if (pipe->device == NULL) return; /* device has detached */ | | 1043 | if (__predict_false(pipe->device == NULL || pipe->device->bus == NULL)) |
| | | 1044 | return; /* device has detached */ |
1044 | sc = pipe->device->bus->hci_private; | | 1045 | sc = pipe->device->bus->hci_private; |
1045 | usb_callout(sc->sc_poll_handle, sc->sc_ival, uhci_poll_hub, xfer); | | 1046 | usb_callout(sc->sc_poll_handle, sc->sc_ival, uhci_poll_hub, xfer); |
1046 | | | 1047 | |
1047 | p = KERNADDR(&xfer->dmabuf, 0); | | 1048 | p = KERNADDR(&xfer->dmabuf, 0); |
1048 | p[0] = 0; | | 1049 | p[0] = 0; |
1049 | if (UREAD2(sc, UHCI_PORTSC1) & (UHCI_PORTSC_CSC|UHCI_PORTSC_OCIC)) | | 1050 | if (UREAD2(sc, UHCI_PORTSC1) & (UHCI_PORTSC_CSC|UHCI_PORTSC_OCIC)) |
1050 | p[0] |= 1<<1; | | 1051 | p[0] |= 1<<1; |
1051 | if (UREAD2(sc, UHCI_PORTSC2) & (UHCI_PORTSC_CSC|UHCI_PORTSC_OCIC)) | | 1052 | if (UREAD2(sc, UHCI_PORTSC2) & (UHCI_PORTSC_CSC|UHCI_PORTSC_OCIC)) |
1052 | p[0] |= 1<<2; | | 1053 | p[0] |= 1<<2; |
1053 | if (p[0] == 0) | | 1054 | if (p[0] == 0) |
1054 | /* No change, try again in a while */ | | 1055 | /* No change, try again in a while */ |
1055 | return; | | 1056 | return; |
1056 | | | 1057 | |