| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dino.c,v 1.17 2009/12/01 22:36:31 skrll Exp $ */ | | 1 | /* $NetBSD: dino.c,v 1.18 2009/12/03 22:18:04 skrll Exp $ */ |
2 | | | 2 | |
3 | /* $OpenBSD: dino.c,v 1.5 2004/02/13 20:39:31 mickey Exp $ */ | | 3 | /* $OpenBSD: dino.c,v 1.5 2004/02/13 20:39:31 mickey Exp $ */ |
4 | | | 4 | |
5 | /* | | 5 | /* |
6 | * Copyright (c) 2003 Michael Shalayeff | | 6 | * Copyright (c) 2003 Michael Shalayeff |
7 | * All rights reserved. | | 7 | * All rights reserved. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -19,27 +19,27 @@ | | | @@ -19,27 +19,27 @@ |
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, | | 21 | * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT, |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | | 22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
24 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 24 | * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | | 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | | 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
27 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | | 27 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
28 | * THE POSSIBILITY OF SUCH DAMAGE. | | 28 | * THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | | 29 | */ |
30 | | | 30 | |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | __KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.17 2009/12/01 22:36:31 skrll Exp $"); | | 32 | __KERNEL_RCSID(0, "$NetBSD: dino.c,v 1.18 2009/12/03 22:18:04 skrll Exp $"); |
33 | | | 33 | |
34 | /* #include "cardbus.h" */ | | 34 | /* #include "cardbus.h" */ |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/systm.h> | | 37 | #include <sys/systm.h> |
38 | #include <sys/device.h> | | 38 | #include <sys/device.h> |
39 | #include <sys/reboot.h> | | 39 | #include <sys/reboot.h> |
40 | #include <sys/malloc.h> | | 40 | #include <sys/malloc.h> |
41 | #include <sys/extent.h> | | 41 | #include <sys/extent.h> |
42 | | | 42 | |
43 | #include <machine/iomod.h> | | 43 | #include <machine/iomod.h> |
44 | #include <machine/autoconf.h> | | 44 | #include <machine/autoconf.h> |
45 | #include <machine/intr.h> | | 45 | #include <machine/intr.h> |
| @@ -321,48 +321,62 @@ void | | | @@ -321,48 +321,62 @@ void |
321 | dino_decompose_tag(void *v, pcitag_t tag, int *bus, int *dev, int *func) | | 321 | dino_decompose_tag(void *v, pcitag_t tag, int *bus, int *dev, int *func) |
322 | { | | 322 | { |
323 | *bus = (tag >> 16) & 0xff; | | 323 | *bus = (tag >> 16) & 0xff; |
324 | *dev = (tag >> 11) & 0x1f; | | 324 | *dev = (tag >> 11) & 0x1f; |
325 | *func= (tag >> 8) & 0x07; | | 325 | *func= (tag >> 8) & 0x07; |
326 | } | | 326 | } |
327 | | | 327 | |
328 | pcireg_t | | 328 | pcireg_t |
329 | dino_conf_read(void *v, pcitag_t tag, int reg) | | 329 | dino_conf_read(void *v, pcitag_t tag, int reg) |
330 | { | | 330 | { |
331 | struct dino_softc *sc = v; | | 331 | struct dino_softc *sc = v; |
332 | volatile struct dino_regs *r = sc->sc_regs; | | 332 | volatile struct dino_regs *r = sc->sc_regs; |
333 | pcireg_t data; | | 333 | pcireg_t data; |
| | | 334 | uint32_t pamr; |
| | | 335 | |
| | | 336 | /* fix arbitration errata by disabling all pci devs on config read */ |
| | | 337 | pamr = r->pamr; |
| | | 338 | r->pamr = 0; |
334 | | | 339 | |
335 | r->pci_addr = tag | reg; | | 340 | r->pci_addr = tag | reg; |
336 | data = r->pci_conf_data; | | 341 | data = r->pci_conf_data; |
| | | 342 | |
| | | 343 | /* restore arbitration */ |
| | | 344 | r->pamr = pamr; |
| | | 345 | |
337 | return le32toh(data); | | 346 | return le32toh(data); |
338 | } | | 347 | } |
339 | | | 348 | |
340 | void | | 349 | void |
341 | dino_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) | | 350 | dino_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) |
342 | { | | 351 | { |
343 | struct dino_softc *sc = v; | | 352 | struct dino_softc *sc = v; |
344 | volatile struct dino_regs *r = sc->sc_regs; | | 353 | volatile struct dino_regs *r = sc->sc_regs; |
345 | pcireg_t data1; | | 354 | pcireg_t data1; |
| | | 355 | uint32_t pamr; |
346 | | | 356 | |
347 | /* fix coalescing config writes errata by interleaving w/ a read */ | | 357 | /* fix arbitration errata by disabling all pci devs on config read */ |
348 | r->pci_addr = tag | PCI_ID_REG; | | 358 | pamr = r->pamr; |
349 | data1 = r->pci_conf_data; | | 359 | r->pamr = 0; |
350 | | | 360 | |
351 | r->pci_addr = tag | reg; | | 361 | r->pci_addr = tag | reg; |
352 | r->pci_conf_data = htole32(data); | | 362 | r->pci_conf_data = htole32(data); |
353 | | | 363 | |
| | | 364 | /* fix coalescing config and io writes by interleaving w/ a read */ |
354 | r->pci_addr = tag | PCI_ID_REG; | | 365 | r->pci_addr = tag | PCI_ID_REG; |
355 | data1 = r->pci_conf_data; | | 366 | data1 = r->pci_conf_data; |
| | | 367 | |
| | | 368 | /* restore arbitration */ |
| | | 369 | r->pamr = pamr; |
356 | } | | 370 | } |
357 | | | 371 | |
358 | int | | 372 | int |
359 | dino_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) | | 373 | dino_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) |
360 | { | | 374 | { |
361 | pci_chipset_tag_t pc = pa->pa_pc; | | 375 | pci_chipset_tag_t pc = pa->pa_pc; |
362 | pcitag_t tag = pa->pa_tag; | | 376 | pcitag_t tag = pa->pa_tag; |
363 | pcireg_t reg; | | 377 | pcireg_t reg; |
364 | | | 378 | |
365 | reg = pci_conf_read(pc, tag, PCI_INTERRUPT_REG); | | 379 | reg = pci_conf_read(pc, tag, PCI_INTERRUPT_REG); |
366 | *ihp = PCI_INTERRUPT_LINE(reg); | | 380 | *ihp = PCI_INTERRUPT_LINE(reg); |
367 | return *ihp < 0; | | 381 | return *ihp < 0; |
368 | } | | 382 | } |