Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.
For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:
Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.
siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.
slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.
viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.
While I'm here, make pci_mapreg_submap() static.
With these changes in place, I have tested the compilation of these
kernels:
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:
### evbmips-el GDIUM
nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop
### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'
### ia64 GENERIC
/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type
### sgimips GENERIC32_IP3x
crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
2011-04-05 00:37:44 +04:00
|
|
|
/* $NetBSD: pci_machdep.c,v 1.29 2011/04/04 20:37:47 dyoung Exp $ */
|
2000-03-20 02:07:43 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2000 Soren S. Jorvang. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2003-07-15 05:19:42 +04:00
|
|
|
#include <sys/cdefs.h>
|
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.
For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:
Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.
siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.
slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.
viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.
While I'm here, make pci_mapreg_submap() static.
With these changes in place, I have tested the compilation of these
kernels:
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:
### evbmips-el GDIUM
nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop
### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'
### ia64 GENERIC
/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type
### sgimips GENERIC32_IP3x
crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
2011-04-05 00:37:44 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.29 2011/04/04 20:37:47 dyoung Exp $");
|
2003-07-15 05:19:42 +04:00
|
|
|
|
2000-03-20 02:07:43 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/device.h>
|
2005-03-25 18:01:57 +03:00
|
|
|
#include <sys/extent.h>
|
2000-03-20 02:07:43 +03:00
|
|
|
|
|
|
|
#define _COBALT_BUS_DMA_PRIVATE
|
|
|
|
#include <machine/bus.h>
|
2000-03-31 18:51:49 +04:00
|
|
|
#include <machine/intr.h>
|
2000-03-20 02:07:43 +03:00
|
|
|
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcidevs.h>
|
2005-03-25 18:01:57 +03:00
|
|
|
#include <dev/pci/pciconf.h>
|
2006-07-15 12:08:23 +04:00
|
|
|
#include <dev/pci/pciide_apollo_reg.h>
|
2000-03-20 02:07:43 +03:00
|
|
|
|
2004-08-28 17:33:31 +04:00
|
|
|
#include <cobalt/dev/gtreg.h>
|
|
|
|
|
2000-03-20 02:07:43 +03:00
|
|
|
/*
|
|
|
|
* PCI doesn't have any special needs; just use
|
|
|
|
* the generic versions of these functions.
|
|
|
|
*/
|
|
|
|
struct cobalt_bus_dma_tag pci_bus_dma_tag = {
|
2003-09-12 18:59:11 +04:00
|
|
|
_bus_dmamap_create,
|
2000-03-20 02:07:43 +03:00
|
|
|
_bus_dmamap_destroy,
|
|
|
|
_bus_dmamap_load,
|
|
|
|
_bus_dmamap_load_mbuf,
|
|
|
|
_bus_dmamap_load_uio,
|
|
|
|
_bus_dmamap_load_raw,
|
|
|
|
_bus_dmamap_unload,
|
|
|
|
_bus_dmamap_sync,
|
|
|
|
_bus_dmamem_alloc,
|
|
|
|
_bus_dmamem_free,
|
|
|
|
_bus_dmamem_map,
|
|
|
|
_bus_dmamem_unmap,
|
|
|
|
_bus_dmamem_mmap,
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_attach_hook(struct device *parent, struct device *self,
|
|
|
|
struct pcibus_attach_args *pba)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
|
|
|
/* XXX */
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
2006-04-05 19:46:58 +04:00
|
|
|
|
2000-05-29 19:45:15 +04:00
|
|
|
return 32;
|
2000-03-20 02:07:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pcitag_t
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
2006-04-05 19:46:58 +04:00
|
|
|
|
2000-03-20 02:07:43 +03:00
|
|
|
return (bus << 16) | (device << 11) | (function << 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp, int *dp, int *fp)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
2006-04-05 19:46:58 +04:00
|
|
|
|
2000-03-20 02:07:43 +03:00
|
|
|
if (bp != NULL)
|
|
|
|
*bp = (tag >> 16) & 0xff;
|
|
|
|
if (dp != NULL)
|
|
|
|
*dp = (tag >> 11) & 0x1f;
|
|
|
|
if (fp != NULL)
|
|
|
|
*fp = (tag >> 8) & 0x07;
|
|
|
|
}
|
|
|
|
|
|
|
|
pcireg_t
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
|
|
|
pcireg_t data;
|
2000-05-29 19:45:15 +04:00
|
|
|
int bus, dev, func;
|
2003-09-12 18:59:11 +04:00
|
|
|
|
2011-02-20 10:54:10 +03:00
|
|
|
KASSERT(pc != NULL);
|
|
|
|
|
2000-05-29 19:45:15 +04:00
|
|
|
pci_decompose_tag(pc, tag, &bus, &dev, &func);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 2700 hardware wedges on accesses to device 6.
|
|
|
|
*/
|
|
|
|
if (bus == 0 && dev == 6)
|
|
|
|
return 0;
|
|
|
|
/*
|
|
|
|
* 2800 hardware wedges on accesses to device 31.
|
|
|
|
*/
|
|
|
|
if (bus == 0 && dev == 31)
|
|
|
|
return 0;
|
2000-03-20 02:07:43 +03:00
|
|
|
|
2004-08-28 17:33:31 +04:00
|
|
|
bus_space_write_4(pc->pc_bst, pc->pc_bsh, GT_PCICFG_ADDR,
|
2006-04-09 05:24:05 +04:00
|
|
|
PCICFG_ENABLE | tag | reg);
|
2004-08-28 17:33:31 +04:00
|
|
|
data = bus_space_read_4(pc->pc_bst, pc->pc_bsh, GT_PCICFG_DATA);
|
|
|
|
bus_space_write_4(pc->pc_bst, pc->pc_bsh, GT_PCICFG_ADDR, 0);
|
2000-03-20 02:07:43 +03:00
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
|
|
|
|
2004-08-28 17:33:31 +04:00
|
|
|
bus_space_write_4(pc->pc_bst, pc->pc_bsh, GT_PCICFG_ADDR,
|
2006-04-09 05:24:05 +04:00
|
|
|
PCICFG_ENABLE | tag | reg);
|
2004-08-28 17:33:31 +04:00
|
|
|
bus_space_write_4(pc->pc_bst, pc->pc_bsh, GT_PCICFG_DATA, data);
|
|
|
|
bus_space_write_4(pc->pc_bst, pc->pc_bsh, GT_PCICFG_ADDR, 0);
|
2000-03-20 02:07:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
Neither pci_dma64_available(), pci_probe_device(), pci_mapreg_map(9),
pci_find_rom(), pci_intr_map(9), pci_enumerate_bus(), nor the match
predicate passed to pciide_compat_intr_establish() should ever modify
their pci_attach_args argument, so make their pci_attach_args arguments
const and deal with the fallout throughout the kernel.
For the most part, these changes add a 'const' where there was no
'const' before, however, some drivers and MD code used to modify
pci_attach_args. Now those drivers either copy their pci_attach_args
and modify the copy, or refrain from modifying pci_attach_args:
Xen: according to Manuel Bouyer, writing to pci_attach_args in
pci_intr_map() was a leftover from Xen 2. Probably a bug. I
stopped writing it. I have not tested this change.
siside(4): sis_hostbr_match() needlessly wrote to pci_attach_args.
Probably a bug. I use a temporary variable. I have not tested this
change.
slide(4): sl82c105_chip_map() overwrote the caller's pci_attach_args.
Probably a bug. Use a local pci_attach_args. I have not tested
this change.
viaide(4): via_sata_chip_map() and via_sata_chip_map_new() overwrote the
caller's pci_attach_args. Probably a bug. Make a local copy of the
caller's pci_attach_args and modify the copy. I have not tested
this change.
While I'm here, make pci_mapreg_submap() static.
With these changes in place, I have tested the compilation of these
kernels:
alpha GENERIC
amd64 GENERIC XEN3_DOM0
arc GENERIC
atari HADES MILAN-PCIIDE
bebox GENERIC
cats GENERIC
cobalt GENERIC
evbarm-eb NSLU2
evbarm-el ADI_BRH ARMADILLO9 CP3100 GEMINI GEMINI_MASTER GEMINI_SLAVE GUMSTIX
HDL_G IMX31LITE INTEGRATOR IQ31244 IQ80310 IQ80321 IXDP425 IXM1200
KUROBOX_PRO LUBBOCK MARVELL_NAS NAPPI SHEEVAPLUG SMDK2800 TEAMASA_NPWR
TEAMASA_NPWR_FC TS7200 TWINTAIL ZAO425
evbmips-el AP30 DBAU1500 DBAU1550 MALTA MERAKI MTX-1 OMSAL400 RB153 WGT624V3
evbmips64-el XLSATX
evbppc EV64260 MPC8536DS MPC8548CDS OPENBLOCKS200 OPENBLOCKS266
OPENBLOCKS266_OPT P2020RDB PMPPC RB800 WALNUT
hp700 GENERIC
i386 ALL XEN3_DOM0 XEN3_DOMU
ibmnws GENERIC
macppc GENERIC
mvmeppc GENERIC
netwinder GENERIC
ofppc GENERIC
prep GENERIC
sandpoint GENERIC
sgimips GENERIC32_IP2x
sparc GENERIC_SUN4U KRUPS
sparc64 GENERIC
As of Sun Apr 3 15:26:26 CDT 2011, I could not compile these kernels
with or without my patches in place:
### evbmips-el GDIUM
nbmake: nbmake: don't know how to make /home/dyoung/pristine-nbsd/src/sys/arch/mips/mips/softintr.c. Stop
### evbarm-el MPCSA_GENERIC
src/sys/arch/evbarm/conf/MPCSA_GENERIC:318: ds1672rtc*: unknown device `ds1672rtc'
### ia64 GENERIC
/tmp/genassym.28085/assym.c: In function 'f111':
/tmp/genassym.28085/assym.c:67: error: invalid application of 'sizeof' to incomplete type 'struct pcb'
/tmp/genassym.28085/assym.c:76: error: dereferencing pointer to incomplete type
### sgimips GENERIC32_IP3x
crmfb.o: In function `crmfb_attach':
crmfb.c:(.text+0x2304): undefined reference to `ddc_read_edid'
crmfb.c:(.text+0x2304): relocation truncated to fit: R_MIPS_26 against `ddc_read_edid'
crmfb.c:(.text+0x234c): undefined reference to `edid_parse'
crmfb.c:(.text+0x234c): relocation truncated to fit: R_MIPS_26 against `edid_parse'
crmfb.c:(.text+0x2354): undefined reference to `edid_print'
crmfb.c:(.text+0x2354): relocation truncated to fit: R_MIPS_26 against `edid_print'
2011-04-05 00:37:44 +04:00
|
|
|
pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
2000-12-29 01:59:06 +03:00
|
|
|
pci_chipset_tag_t pc = pa->pa_pc;
|
2001-02-05 16:14:21 +03:00
|
|
|
pcitag_t intrtag = pa->pa_intrtag;
|
2000-12-29 01:59:06 +03:00
|
|
|
int pin = pa->pa_intrpin;
|
|
|
|
int line = pa->pa_intrline;
|
2000-04-09 04:13:27 +04:00
|
|
|
int bus, dev, func;
|
2000-03-20 02:07:43 +03:00
|
|
|
|
2000-04-09 04:13:27 +04:00
|
|
|
pci_decompose_tag(pc, intrtag, &bus, &dev, &func);
|
|
|
|
|
|
|
|
/*
|
2008-03-22 21:32:20 +03:00
|
|
|
* The interrupt lines of the internal Tulips are connected
|
2000-04-09 04:13:27 +04:00
|
|
|
* directly to the CPU.
|
|
|
|
*/
|
2007-02-18 15:22:16 +03:00
|
|
|
if (cobalt_id == COBALT_ID_QUBE2700) {
|
2008-03-22 21:32:20 +03:00
|
|
|
if (bus == 0 && dev == 7 && pin == PCI_INTERRUPT_PIN_A) {
|
|
|
|
/* tulip is connected to CPU INT2 on Qube2700 */
|
|
|
|
*ihp = NICU_INT + 2;
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-18 15:22:16 +03:00
|
|
|
} else {
|
2008-03-22 21:32:20 +03:00
|
|
|
if (bus == 0 && dev == 7 && pin == PCI_INTERRUPT_PIN_A) {
|
|
|
|
/* the primary tulip is connected to CPU INT1 */
|
|
|
|
*ihp = NICU_INT + 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (bus == 0 && dev == 12 && pin == PCI_INTERRUPT_PIN_A) {
|
|
|
|
/* the secondary tulip is connected to CPU INT2 */
|
|
|
|
*ihp = NICU_INT + 2;
|
|
|
|
return 0;
|
|
|
|
}
|
2007-02-18 15:22:16 +03:00
|
|
|
}
|
2000-03-20 02:07:43 +03:00
|
|
|
|
2008-03-22 21:32:20 +03:00
|
|
|
/* sanity check */
|
|
|
|
if (line == 0 || line >= NICU_INT)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
*ihp = line;
|
2000-03-20 02:07:43 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
2000-03-31 18:51:49 +04:00
|
|
|
static char irqstr[8];
|
|
|
|
|
2008-03-22 21:32:20 +03:00
|
|
|
if (ih >= NICU_INT)
|
|
|
|
sprintf(irqstr, "level %d", ih - NICU_INT);
|
2000-03-31 18:51:49 +04:00
|
|
|
else
|
|
|
|
sprintf(irqstr, "irq %d", ih);
|
2000-03-20 02:07:43 +03:00
|
|
|
|
|
|
|
return irqstr;
|
|
|
|
}
|
|
|
|
|
2000-06-04 23:14:14 +04:00
|
|
|
const struct evcnt *
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih)
|
2000-06-04 23:14:14 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
/* XXX for now, no evcnt parent reported */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-05-30 23:26:35 +04:00
|
|
|
int
|
|
|
|
pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ih,
|
|
|
|
int attr, uint64_t data)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (attr) {
|
|
|
|
case PCI_INTR_MPSAFE:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return ENODEV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-20 02:07:43 +03:00
|
|
|
void *
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
|
|
|
|
int (*func)(void *), void *arg)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
2006-04-05 19:46:58 +04:00
|
|
|
|
2008-03-22 21:32:20 +03:00
|
|
|
if (ih >= NICU_INT)
|
|
|
|
return cpu_intr_establish(ih - NICU_INT, level, func, arg);
|
2000-03-31 18:51:49 +04:00
|
|
|
else
|
|
|
|
return icu_intr_establish(ih, IST_LEVEL, level, func, arg);
|
2000-03-20 02:07:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-04-05 19:46:58 +04:00
|
|
|
pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
|
2000-03-20 02:07:43 +03:00
|
|
|
{
|
2006-04-05 19:46:58 +04:00
|
|
|
|
2002-01-14 02:02:33 +03:00
|
|
|
/* Try both, only the valid one will disestablish. */
|
|
|
|
cpu_intr_disestablish(cookie);
|
|
|
|
icu_intr_disestablish(cookie);
|
2000-03-20 02:07:43 +03:00
|
|
|
}
|
2005-03-25 18:01:57 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
pci_conf_interrupt(pci_chipset_tag_t pc, int bus, int dev, int pin, int swiz,
|
|
|
|
int *iline)
|
|
|
|
{
|
|
|
|
|
2008-03-22 21:32:20 +03:00
|
|
|
/*
|
|
|
|
* Use irq 9 on all devices on the Qube's PCI slot.
|
|
|
|
* XXX doesn't handle devices over PCI-PCI bridges
|
|
|
|
*/
|
|
|
|
if (bus == 0 && dev == 10 && pin != PCI_INTERRUPT_PIN_NONE)
|
|
|
|
*iline = 9;
|
2005-03-25 18:01:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
pci_conf_hook(pci_chipset_tag_t pc, int bus, int dev, int func, pcireg_t id)
|
|
|
|
{
|
|
|
|
|
2006-04-18 16:26:45 +04:00
|
|
|
/* ignore bogus IDs */
|
|
|
|
if (PCI_VENDOR(id) == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* 2700 hardware wedges on accesses to device 6. */
|
|
|
|
if (bus == 0 && dev == 6)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* 2800 hardware wedges on accesses to device 31. */
|
|
|
|
if (bus == 0 && dev == 31)
|
|
|
|
return 0;
|
|
|
|
|
2005-03-25 18:01:57 +03:00
|
|
|
/* Don't configure the bridge and PCI probe. */
|
2006-08-23 01:42:19 +04:00
|
|
|
if (PCI_VENDOR(id) == PCI_VENDOR_MARVELL &&
|
|
|
|
PCI_PRODUCT(id) == PCI_PRODUCT_MARVELL_GT64011)
|
2005-03-25 18:01:57 +03:00
|
|
|
return 0;
|
|
|
|
|
2006-07-15 12:08:23 +04:00
|
|
|
/* Don't configure on-board VIA VT82C586 (pcib, uhci) */
|
|
|
|
if (bus == 0 && dev == 9 && (func == 0 || func == 2))
|
2005-03-25 18:01:57 +03:00
|
|
|
return 0;
|
|
|
|
|
2006-07-15 12:08:23 +04:00
|
|
|
/* Enable viaide secondary port. Some firmware doesn't enable it. */
|
|
|
|
if (bus == 0 && dev == 9 && func == 1) {
|
|
|
|
pcitag_t tag;
|
|
|
|
pcireg_t csr;
|
|
|
|
|
|
|
|
#define APO_VIAIDECONF (APO_VIA_REGBASE + 0x00)
|
|
|
|
|
|
|
|
tag = pci_make_tag(pc, bus, dev, func);
|
|
|
|
csr = pci_conf_read(pc, tag, APO_VIAIDECONF);
|
|
|
|
pci_conf_write(pc, tag, APO_VIAIDECONF,
|
|
|
|
csr | APO_IDECONF_EN(1));
|
|
|
|
}
|
2006-02-10 23:52:56 +03:00
|
|
|
return PCI_CONF_DEFAULT & ~(PCI_COMMAND_SERR_ENABLE |
|
|
|
|
PCI_COMMAND_PARITY_ENABLE);
|
2005-03-25 18:01:57 +03:00
|
|
|
}
|