ehci_pci.c revision 1.30.8.2 1 1.30.8.2 tsutsui /* $NetBSD: ehci_pci.c,v 1.30.8.2 2007/08/04 10:36:07 tsutsui Exp $ */
2 1.30.8.2 tsutsui
3 1.30.8.2 tsutsui /*
4 1.30.8.2 tsutsui * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
5 1.30.8.2 tsutsui * All rights reserved.
6 1.30.8.2 tsutsui *
7 1.30.8.2 tsutsui * This code is derived from software contributed to The NetBSD Foundation
8 1.30.8.2 tsutsui * by Lennart Augustsson (lennart (at) augustsson.net).
9 1.30.8.2 tsutsui *
10 1.30.8.2 tsutsui * Redistribution and use in source and binary forms, with or without
11 1.30.8.2 tsutsui * modification, are permitted provided that the following conditions
12 1.30.8.2 tsutsui * are met:
13 1.30.8.2 tsutsui * 1. Redistributions of source code must retain the above copyright
14 1.30.8.2 tsutsui * notice, this list of conditions and the following disclaimer.
15 1.30.8.2 tsutsui * 2. Redistributions in binary form must reproduce the above copyright
16 1.30.8.2 tsutsui * notice, this list of conditions and the following disclaimer in the
17 1.30.8.2 tsutsui * documentation and/or other materials provided with the distribution.
18 1.30.8.2 tsutsui * 3. All advertising materials mentioning features or use of this software
19 1.30.8.2 tsutsui * must display the following acknowledgement:
20 1.30.8.2 tsutsui * This product includes software developed by the NetBSD
21 1.30.8.2 tsutsui * Foundation, Inc. and its contributors.
22 1.30.8.2 tsutsui * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.30.8.2 tsutsui * contributors may be used to endorse or promote products derived
24 1.30.8.2 tsutsui * from this software without specific prior written permission.
25 1.30.8.2 tsutsui *
26 1.30.8.2 tsutsui * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.30.8.2 tsutsui * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.30.8.2 tsutsui * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.30.8.2 tsutsui * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.30.8.2 tsutsui * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.30.8.2 tsutsui * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.30.8.2 tsutsui * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.30.8.2 tsutsui * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.30.8.2 tsutsui * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.30.8.2 tsutsui * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.30.8.2 tsutsui * POSSIBILITY OF SUCH DAMAGE.
37 1.30.8.2 tsutsui */
38 1.30.8.2 tsutsui
39 1.30.8.2 tsutsui #include <sys/cdefs.h>
40 1.30.8.2 tsutsui __KERNEL_RCSID(0, "$NetBSD: ehci_pci.c,v 1.30.8.2 2007/08/04 10:36:07 tsutsui Exp $");
41 1.30.8.2 tsutsui
42 1.30.8.2 tsutsui #include <sys/param.h>
43 1.30.8.2 tsutsui #include <sys/systm.h>
44 1.30.8.2 tsutsui #include <sys/kernel.h>
45 1.30.8.2 tsutsui #include <sys/device.h>
46 1.30.8.2 tsutsui #include <sys/proc.h>
47 1.30.8.2 tsutsui #include <sys/queue.h>
48 1.30.8.2 tsutsui
49 1.30.8.2 tsutsui #include <machine/bus.h>
50 1.30.8.2 tsutsui
51 1.30.8.2 tsutsui #include <dev/pci/pcidevs.h>
52 1.30.8.2 tsutsui #include <dev/pci/pcivar.h>
53 1.30.8.2 tsutsui #include <dev/pci/usb_pci.h>
54 1.30.8.2 tsutsui
55 1.30.8.2 tsutsui #include <dev/usb/usb.h>
56 1.30.8.2 tsutsui #include <dev/usb/usbdi.h>
57 1.30.8.2 tsutsui #include <dev/usb/usbdivar.h>
58 1.30.8.2 tsutsui #include <dev/usb/usb_mem.h>
59 1.30.8.2 tsutsui
60 1.30.8.2 tsutsui #include <dev/usb/ehcireg.h>
61 1.30.8.2 tsutsui #include <dev/usb/ehcivar.h>
62 1.30.8.2 tsutsui
63 1.30.8.2 tsutsui #ifdef EHCI_DEBUG
64 1.30.8.2 tsutsui #define DPRINTF(x) if (ehcidebug) printf x
65 1.30.8.2 tsutsui extern int ehcidebug;
66 1.30.8.2 tsutsui #else
67 1.30.8.2 tsutsui #define DPRINTF(x)
68 1.30.8.2 tsutsui #endif
69 1.30.8.2 tsutsui
70 1.30.8.2 tsutsui static void ehci_get_ownership(ehci_softc_t *sc, pci_chipset_tag_t pc,
71 1.30.8.2 tsutsui pcitag_t tag);
72 1.30.8.2 tsutsui static void ehci_pci_powerhook(int, void *);
73 1.30.8.2 tsutsui
74 1.30.8.2 tsutsui struct ehci_pci_softc {
75 1.30.8.2 tsutsui ehci_softc_t sc;
76 1.30.8.2 tsutsui pci_chipset_tag_t sc_pc;
77 1.30.8.2 tsutsui pcitag_t sc_tag;
78 1.30.8.2 tsutsui void *sc_ih; /* interrupt vectoring */
79 1.30.8.2 tsutsui
80 1.30.8.2 tsutsui void *sc_powerhook;
81 1.30.8.2 tsutsui struct pci_conf_state sc_pciconf;
82 1.30.8.2 tsutsui };
83 1.30.8.2 tsutsui
84 1.30.8.2 tsutsui #define EHCI_MAX_BIOS_WAIT 1000 /* ms */
85 1.30.8.2 tsutsui
86 1.30.8.2 tsutsui static int
87 1.30.8.2 tsutsui ehci_pci_match(struct device *parent, struct cfdata *match,
88 1.30.8.2 tsutsui void *aux)
89 1.30.8.2 tsutsui {
90 1.30.8.2 tsutsui struct pci_attach_args *pa = (struct pci_attach_args *) aux;
91 1.30.8.2 tsutsui
92 1.30.8.2 tsutsui if (PCI_CLASS(pa->pa_class) == PCI_CLASS_SERIALBUS &&
93 1.30.8.2 tsutsui PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_SERIALBUS_USB &&
94 1.30.8.2 tsutsui PCI_INTERFACE(pa->pa_class) == PCI_INTERFACE_EHCI)
95 1.30.8.2 tsutsui return (1);
96 1.30.8.2 tsutsui
97 1.30.8.2 tsutsui return (0);
98 1.30.8.2 tsutsui }
99 1.30.8.2 tsutsui
100 1.30.8.2 tsutsui static void
101 1.30.8.2 tsutsui ehci_pci_attach(struct device *parent, struct device *self, void *aux)
102 1.30.8.2 tsutsui {
103 1.30.8.2 tsutsui struct ehci_pci_softc *sc = (struct ehci_pci_softc *)self;
104 1.30.8.2 tsutsui struct pci_attach_args *pa = (struct pci_attach_args *)aux;
105 1.30.8.2 tsutsui pci_chipset_tag_t pc = pa->pa_pc;
106 1.30.8.2 tsutsui pcitag_t tag = pa->pa_tag;
107 1.30.8.2 tsutsui char const *intrstr;
108 1.30.8.2 tsutsui pci_intr_handle_t ih;
109 1.30.8.2 tsutsui pcireg_t csr;
110 1.30.8.2 tsutsui const char *vendor;
111 1.30.8.2 tsutsui const char *devname = sc->sc.sc_bus.bdev.dv_xname;
112 1.30.8.2 tsutsui char devinfo[256];
113 1.30.8.2 tsutsui usbd_status r;
114 1.30.8.2 tsutsui int ncomp;
115 1.30.8.2 tsutsui struct usb_pci *up;
116 1.30.8.2 tsutsui
117 1.30.8.2 tsutsui aprint_naive(": USB controller\n");
118 1.30.8.2 tsutsui
119 1.30.8.2 tsutsui pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
120 1.30.8.2 tsutsui aprint_normal(": %s (rev. 0x%02x)\n", devinfo,
121 1.30.8.2 tsutsui PCI_REVISION(pa->pa_class));
122 1.30.8.2 tsutsui
123 1.30.8.2 tsutsui /* Map I/O registers */
124 1.30.8.2 tsutsui if (pci_mapreg_map(pa, PCI_CBMEM, PCI_MAPREG_TYPE_MEM, 0,
125 1.30.8.2 tsutsui &sc->sc.iot, &sc->sc.ioh, NULL, &sc->sc.sc_size)) {
126 1.30.8.2 tsutsui aprint_error("%s: can't map memory space\n", devname);
127 1.30.8.2 tsutsui return;
128 1.30.8.2 tsutsui }
129 1.30.8.2 tsutsui
130 1.30.8.2 tsutsui sc->sc_pc = pc;
131 1.30.8.2 tsutsui sc->sc_tag = tag;
132 1.30.8.2 tsutsui sc->sc.sc_bus.dmatag = pa->pa_dmat;
133 1.30.8.2 tsutsui
134 1.30.8.2 tsutsui /* Enable the device. */
135 1.30.8.2 tsutsui csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
136 1.30.8.2 tsutsui pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG,
137 1.30.8.2 tsutsui csr | PCI_COMMAND_MASTER_ENABLE);
138 1.30.8.2 tsutsui
139 1.30.8.2 tsutsui /* Disable interrupts, so we don't get any spurious ones. */
140 1.30.8.2 tsutsui sc->sc.sc_offs = EREAD1(&sc->sc, EHCI_CAPLENGTH);
141 1.30.8.2 tsutsui DPRINTF(("%s: offs=%d\n", devname, sc->sc.sc_offs));
142 1.30.8.2 tsutsui EOWRITE2(&sc->sc, EHCI_USBINTR, 0);
143 1.30.8.2 tsutsui
144 1.30.8.2 tsutsui /* Map and establish the interrupt. */
145 1.30.8.2 tsutsui if (pci_intr_map(pa, &ih)) {
146 1.30.8.2 tsutsui aprint_error("%s: couldn't map interrupt\n", devname);
147 1.30.8.2 tsutsui return;
148 1.30.8.2 tsutsui }
149 1.30.8.2 tsutsui intrstr = pci_intr_string(pc, ih);
150 1.30.8.2 tsutsui sc->sc_ih = pci_intr_establish(pc, ih, IPL_USB, ehci_intr, sc);
151 1.30.8.2 tsutsui if (sc->sc_ih == NULL) {
152 1.30.8.2 tsutsui aprint_error("%s: couldn't establish interrupt", devname);
153 1.30.8.2 tsutsui if (intrstr != NULL)
154 1.30.8.2 tsutsui aprint_normal(" at %s", intrstr);
155 1.30.8.2 tsutsui aprint_normal("\n");
156 1.30.8.2 tsutsui return;
157 1.30.8.2 tsutsui }
158 1.30.8.2 tsutsui aprint_normal("%s: interrupting at %s\n", devname, intrstr);
159 1.30.8.2 tsutsui
160 1.30.8.2 tsutsui switch(pci_conf_read(pc, tag, PCI_USBREV) & PCI_USBREV_MASK) {
161 1.30.8.2 tsutsui case PCI_USBREV_PRE_1_0:
162 1.30.8.2 tsutsui case PCI_USBREV_1_0:
163 1.30.8.2 tsutsui case PCI_USBREV_1_1:
164 1.30.8.2 tsutsui sc->sc.sc_bus.usbrev = USBREV_UNKNOWN;
165 1.30.8.2 tsutsui aprint_verbose("%s: pre-2.0 USB rev\n", devname);
166 1.30.8.2 tsutsui return;
167 1.30.8.2 tsutsui case PCI_USBREV_2_0:
168 1.30.8.2 tsutsui sc->sc.sc_bus.usbrev = USBREV_2_0;
169 1.30.8.2 tsutsui break;
170 1.30.8.2 tsutsui default:
171 1.30.8.2 tsutsui sc->sc.sc_bus.usbrev = USBREV_UNKNOWN;
172 1.30.8.2 tsutsui break;
173 1.30.8.2 tsutsui }
174 1.30.8.2 tsutsui
175 1.30.8.2 tsutsui /* Figure out vendor for root hub descriptor. */
176 1.30.8.2 tsutsui vendor = pci_findvendor(pa->pa_id);
177 1.30.8.2 tsutsui sc->sc.sc_id_vendor = PCI_VENDOR(pa->pa_id);
178 1.30.8.2 tsutsui if (vendor)
179 1.30.8.2 tsutsui strlcpy(sc->sc.sc_vendor, vendor, sizeof(sc->sc.sc_vendor));
180 1.30.8.2 tsutsui else
181 1.30.8.2 tsutsui snprintf(sc->sc.sc_vendor, sizeof(sc->sc.sc_vendor),
182 1.30.8.2 tsutsui "vendor 0x%04x", PCI_VENDOR(pa->pa_id));
183 1.30.8.2 tsutsui
184 1.30.8.2 tsutsui /* Enable workaround for dropped interrupts as required */
185 1.30.8.2 tsutsui switch (sc->sc.sc_id_vendor) {
186 1.30.8.2 tsutsui case PCI_VENDOR_ATI:
187 1.30.8.2 tsutsui case PCI_VENDOR_VIATECH:
188 1.30.8.2 tsutsui sc->sc.sc_flags |= EHCIF_DROPPED_INTR_WORKAROUND;
189 1.30.8.2 tsutsui aprint_normal("%s: dropped intr workaround enabled\n", devname);
190 1.30.8.2 tsutsui break;
191 1.30.8.2 tsutsui default:
192 1.30.8.2 tsutsui break;
193 1.30.8.2 tsutsui }
194 1.30.8.2 tsutsui
195 1.30.8.2 tsutsui /*
196 1.30.8.2 tsutsui * Find companion controllers. According to the spec they always
197 1.30.8.2 tsutsui * have lower function numbers so they should be enumerated already.
198 1.30.8.2 tsutsui */
199 1.30.8.2 tsutsui ncomp = 0;
200 1.30.8.2 tsutsui TAILQ_FOREACH(up, &ehci_pci_alldevs, next) {
201 1.30.8.2 tsutsui if (up->bus == pa->pa_bus && up->device == pa->pa_device) {
202 1.30.8.2 tsutsui DPRINTF(("ehci_pci_attach: companion %s\n",
203 1.30.8.2 tsutsui USBDEVNAME(up->usb->bdev)));
204 1.30.8.2 tsutsui sc->sc.sc_comps[ncomp++] = up->usb;
205 1.30.8.2 tsutsui if (ncomp >= EHCI_COMPANION_MAX)
206 1.30.8.2 tsutsui break;
207 1.30.8.2 tsutsui }
208 1.30.8.2 tsutsui }
209 1.30.8.2 tsutsui sc->sc.sc_ncomp = ncomp;
210 1.30.8.2 tsutsui
211 1.30.8.2 tsutsui ehci_get_ownership(&sc->sc, pc, tag);
212 1.30.8.2 tsutsui
213 1.30.8.2 tsutsui /*
214 1.30.8.2 tsutsui * Establish our powerhook before ehci_init() does its powerhook.
215 1.30.8.2 tsutsui */
216 1.30.8.2 tsutsui sc->sc_powerhook = powerhook_establish(
217 1.30.8.2 tsutsui USBDEVNAME(sc->sc.sc_bus.bdev) , ehci_pci_powerhook, sc);
218 1.30.8.2 tsutsui if (sc->sc_powerhook == NULL)
219 1.30.8.2 tsutsui aprint_error("%s: couldn't establish powerhook\n",
220 1.30.8.2 tsutsui devname);
221 1.30.8.2 tsutsui
222 1.30.8.2 tsutsui r = ehci_init(&sc->sc);
223 1.30.8.2 tsutsui if (r != USBD_NORMAL_COMPLETION) {
224 1.30.8.2 tsutsui aprint_error("%s: init failed, error=%d\n", devname, r);
225 1.30.8.2 tsutsui return;
226 1.30.8.2 tsutsui }
227 1.30.8.2 tsutsui
228 1.30.8.2 tsutsui /* Attach usb device. */
229 1.30.8.2 tsutsui sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus,
230 1.30.8.2 tsutsui usbctlprint);
231 1.30.8.2 tsutsui }
232 1.30.8.2 tsutsui
233 1.30.8.2 tsutsui static int
234 1.30.8.2 tsutsui ehci_pci_detach(device_ptr_t self, int flags)
235 1.30.8.2 tsutsui {
236 1.30.8.2 tsutsui struct ehci_pci_softc *sc = (struct ehci_pci_softc *)self;
237 1.30.8.2 tsutsui int rv;
238 1.30.8.2 tsutsui
239 1.30.8.2 tsutsui if (sc->sc_powerhook != NULL)
240 1.30.8.2 tsutsui powerhook_disestablish(sc->sc_powerhook);
241 1.30.8.2 tsutsui
242 1.30.8.2 tsutsui rv = ehci_detach(&sc->sc, flags);
243 1.30.8.2 tsutsui if (rv)
244 1.30.8.2 tsutsui return (rv);
245 1.30.8.2 tsutsui if (sc->sc_ih != NULL) {
246 1.30.8.2 tsutsui pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
247 1.30.8.2 tsutsui sc->sc_ih = NULL;
248 1.30.8.2 tsutsui }
249 1.30.8.2 tsutsui if (sc->sc.sc_size) {
250 1.30.8.2 tsutsui bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size);
251 1.30.8.2 tsutsui sc->sc.sc_size = 0;
252 1.30.8.2 tsutsui }
253 1.30.8.2 tsutsui return (0);
254 1.30.8.2 tsutsui }
255 1.30.8.2 tsutsui
256 1.30.8.2 tsutsui CFATTACH_DECL(ehci_pci, sizeof(struct ehci_pci_softc),
257 1.30.8.2 tsutsui ehci_pci_match, ehci_pci_attach, ehci_pci_detach, ehci_activate);
258 1.30.8.2 tsutsui
259 1.30.8.2 tsutsui #ifdef EHCI_DEBUG
260 1.30.8.2 tsutsui static void
261 1.30.8.2 tsutsui ehci_dump_caps(ehci_softc_t *sc, pci_chipset_tag_t pc, pcitag_t tag)
262 1.30.8.2 tsutsui {
263 1.30.8.2 tsutsui u_int32_t cparams, legctlsts, addr, cap, id;
264 1.30.8.2 tsutsui int maxdump = 10;
265 1.30.8.2 tsutsui
266 1.30.8.2 tsutsui cparams = EREAD4(sc, EHCI_HCCPARAMS);
267 1.30.8.2 tsutsui addr = EHCI_HCC_EECP(cparams);
268 1.30.8.2 tsutsui while (addr != 0) {
269 1.30.8.2 tsutsui cap = pci_conf_read(pc, tag, addr);
270 1.30.8.2 tsutsui id = EHCI_CAP_GET_ID(cap);
271 1.30.8.2 tsutsui switch (id) {
272 1.30.8.2 tsutsui case EHCI_CAP_ID_LEGACY:
273 1.30.8.2 tsutsui legctlsts = pci_conf_read(pc, tag,
274 1.30.8.2 tsutsui addr + PCI_EHCI_USBLEGCTLSTS);
275 1.30.8.2 tsutsui printf("ehci_dump_caps: legsup=0x%08x "
276 1.30.8.2 tsutsui "legctlsts=0x%08x\n", cap, legctlsts);
277 1.30.8.2 tsutsui break;
278 1.30.8.2 tsutsui default:
279 1.30.8.2 tsutsui printf("ehci_dump_caps: cap=0x%08x\n", cap);
280 1.30.8.2 tsutsui break;
281 1.30.8.2 tsutsui }
282 1.30.8.2 tsutsui if (--maxdump < 0)
283 1.30.8.2 tsutsui break;
284 1.30.8.2 tsutsui addr = EHCI_CAP_GET_NEXT(cap);
285 1.30.8.2 tsutsui }
286 1.30.8.2 tsutsui }
287 1.30.8.2 tsutsui #endif
288 1.30.8.2 tsutsui
289 1.30.8.2 tsutsui static void
290 1.30.8.2 tsutsui ehci_get_ownership(ehci_softc_t *sc, pci_chipset_tag_t pc, pcitag_t tag)
291 1.30.8.2 tsutsui {
292 1.30.8.2 tsutsui const char *devname = sc->sc_bus.bdev.dv_xname;
293 1.30.8.2 tsutsui u_int32_t cparams, addr, cap, legsup;
294 1.30.8.2 tsutsui int maxcap = 10;
295 1.30.8.2 tsutsui int ms;
296 1.30.8.2 tsutsui
297 1.30.8.2 tsutsui #ifdef EHCI_DEBUG
298 1.30.8.2 tsutsui if (ehcidebug)
299 1.30.8.2 tsutsui ehci_dump_caps(sc, pc, tag);
300 1.30.8.2 tsutsui #endif
301 1.30.8.2 tsutsui cparams = EREAD4(sc, EHCI_HCCPARAMS);
302 1.30.8.2 tsutsui addr = EHCI_HCC_EECP(cparams);
303 1.30.8.2 tsutsui while (addr != 0) {
304 1.30.8.2 tsutsui cap = pci_conf_read(pc, tag, addr);
305 1.30.8.2 tsutsui if (EHCI_CAP_GET_ID(cap) == EHCI_CAP_ID_LEGACY)
306 1.30.8.2 tsutsui break;
307 1.30.8.2 tsutsui if (--maxcap < 0) {
308 1.30.8.2 tsutsui aprint_normal("%s: broken extended capabilities "
309 1.30.8.2 tsutsui "ignored\n", devname);
310 1.30.8.2 tsutsui return;
311 1.30.8.2 tsutsui }
312 1.30.8.2 tsutsui addr = EHCI_CAP_GET_NEXT(cap);
313 1.30.8.2 tsutsui }
314 1.30.8.2 tsutsui
315 1.30.8.2 tsutsui /* If the USB legacy capability is not specified, we are done */
316 1.30.8.2 tsutsui if (addr == 0)
317 1.30.8.2 tsutsui return;
318 1.30.8.2 tsutsui
319 1.30.8.2 tsutsui legsup = pci_conf_read(pc, tag, addr + PCI_EHCI_USBLEGSUP);
320 1.30.8.2 tsutsui /* Ask BIOS to give up ownership */
321 1.30.8.2 tsutsui legsup |= EHCI_LEG_HC_OS_OWNED;
322 1.30.8.2 tsutsui pci_conf_write(pc, tag, addr + PCI_EHCI_USBLEGSUP, legsup);
323 1.30.8.2 tsutsui for (ms = 0; ms < EHCI_MAX_BIOS_WAIT; ms++) {
324 1.30.8.2 tsutsui legsup = pci_conf_read(pc, tag, addr + PCI_EHCI_USBLEGSUP);
325 1.30.8.2 tsutsui if (!(legsup & EHCI_LEG_HC_BIOS_OWNED))
326 1.30.8.2 tsutsui break;
327 1.30.8.2 tsutsui delay(1000);
328 1.30.8.2 tsutsui }
329 1.30.8.2 tsutsui if (ms == EHCI_MAX_BIOS_WAIT) {
330 1.30.8.2 tsutsui aprint_normal("%s: BIOS refuses to give up ownership, "
331 1.30.8.2 tsutsui "using force\n", devname);
332 1.30.8.2 tsutsui pci_conf_write(pc, tag, addr + PCI_EHCI_USBLEGSUP, 0);
333 1.30.8.2 tsutsui pci_conf_write(pc, tag, addr + PCI_EHCI_USBLEGCTLSTS, 0);
334 1.30.8.2 tsutsui } else {
335 1.30.8.2 tsutsui aprint_verbose("%s: BIOS has given up ownership\n", devname);
336 1.30.8.2 tsutsui }
337 1.30.8.2 tsutsui }
338 1.30.8.2 tsutsui
339 1.30.8.2 tsutsui static void
340 1.30.8.2 tsutsui ehci_pci_powerhook(int why, void *opaque)
341 1.30.8.2 tsutsui {
342 1.30.8.2 tsutsui struct ehci_pci_softc *sc;
343 1.30.8.2 tsutsui pci_chipset_tag_t pc;
344 1.30.8.2 tsutsui pcitag_t tag;
345 1.30.8.2 tsutsui
346 1.30.8.2 tsutsui sc = (struct ehci_pci_softc *)opaque;
347 1.30.8.2 tsutsui pc = sc->sc_pc;
348 1.30.8.2 tsutsui tag = sc->sc_tag;
349 1.30.8.2 tsutsui
350 1.30.8.2 tsutsui switch (why) {
351 1.30.8.2 tsutsui case PWR_STANDBY:
352 1.30.8.2 tsutsui case PWR_SUSPEND:
353 1.30.8.2 tsutsui pci_conf_capture(pc, tag, &sc->sc_pciconf);
354 1.30.8.2 tsutsui break;
355 1.30.8.2 tsutsui case PWR_RESUME:
356 1.30.8.2 tsutsui pci_conf_restore(pc, tag, &sc->sc_pciconf);
357 1.30.8.2 tsutsui ehci_get_ownership(&sc->sc, pc, tag);
358 1.30.8.2 tsutsui break;
359 1.30.8.2 tsutsui }
360 1.30.8.2 tsutsui
361 1.30.8.2 tsutsui return;
362 1.30.8.2 tsutsui }
363