summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/amd64/amd64/bios.c5
-rw-r--r--sys/arch/amd64/amd64/mainbus.c8
-rw-r--r--sys/arch/amd64/amd64/mpbios.c5
-rw-r--r--sys/arch/amd64/include/pci_machdep.h25
-rw-r--r--sys/arch/amd64/pci/pci_machdep.c230
5 files changed, 28 insertions, 245 deletions
diff --git a/sys/arch/amd64/amd64/bios.c b/sys/arch/amd64/amd64/bios.c
index a913b1883ad..f22e1a69c8e 100644
--- a/sys/arch/amd64/amd64/bios.c
+++ b/sys/arch/amd64/amd64/bios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bios.c,v 1.16 2009/01/13 13:53:50 kettenis Exp $ */
+/* $OpenBSD: bios.c,v 1.17 2009/04/21 19:18:09 kettenis Exp $ */
/*
* Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca>
*
@@ -158,9 +158,6 @@ bios_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
#if NACPI > 0
-#if NPCI > 0
- if (pci_mode != 0)
-#endif
{
struct bios_attach_args ba;
diff --git a/sys/arch/amd64/amd64/mainbus.c b/sys/arch/amd64/amd64/mainbus.c
index bffd3b32e32..3cfd3ab5585 100644
--- a/sys/arch/amd64/amd64/mainbus.c
+++ b/sys/arch/amd64/amd64/mainbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mainbus.c,v 1.18 2009/04/11 17:13:33 kettenis Exp $ */
+/* $OpenBSD: mainbus.c,v 1.19 2009/04/21 19:18:09 kettenis Exp $ */
/* $NetBSD: mainbus.c,v 1.1 2003/04/26 18:39:29 fvdl Exp $ */
/*
@@ -146,10 +146,6 @@ mainbus_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
-#if NPCI > 0
- pci_mode = pci_mode_detect();
-#endif
-
#if NBIOS > 0
{
mba.mba_bios.ba_name = "bios";
@@ -195,7 +191,7 @@ mainbus_attach(struct device *parent, struct device *self, void *aux)
#endif
#if NPCI > 0
- if (pci_mode != 0) {
+ {
pci_init_extents();
bzero(&mba.mba_pba, sizeof(mba.mba_pba));
diff --git a/sys/arch/amd64/amd64/mpbios.c b/sys/arch/amd64/amd64/mpbios.c
index ea9c270d1da..57a3c9e7695 100644
--- a/sys/arch/amd64/amd64/mpbios.c
+++ b/sys/arch/amd64/amd64/mpbios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpbios.c,v 1.17 2009/04/19 17:53:39 deraadt Exp $ */
+/* $OpenBSD: mpbios.c,v 1.18 2009/04/21 19:18:09 kettenis Exp $ */
/* $NetBSD: mpbios.c,v 1.7 2003/05/15 16:32:50 fvdl Exp $ */
/*-
@@ -672,8 +672,7 @@ mpbios_scan(struct device *self)
mpbios_scanned = 1;
#if NPCI > 0
- if (pci_mode != 0)
- mpbios_intr_fixup();
+ mpbios_intr_fixup();
#endif
}
diff --git a/sys/arch/amd64/include/pci_machdep.h b/sys/arch/amd64/include/pci_machdep.h
index f9e754a32df..0a3006bdbd6 100644
--- a/sys/arch/amd64/include/pci_machdep.h
+++ b/sys/arch/amd64/include/pci_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.h,v 1.10 2009/04/11 17:13:33 kettenis Exp $ */
+/* $OpenBSD: pci_machdep.h,v 1.11 2009/04/21 19:18:09 kettenis Exp $ */
/* $NetBSD: pci_machdep.h,v 1.1 2003/02/26 21:26:11 fvdl Exp $ */
/*
@@ -36,24 +36,9 @@
*/
/*
- * i386-specific PCI structure and type definitions.
+ * amd64-specific PCI structure and type definitions.
* NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
- *
- * Configuration tag; created from a {bus,device,function} triplet by
- * pci_make_tag(), and passed to pci_conf_read() and pci_conf_write().
- * We could instead always pass the {bus,device,function} triplet to
- * the read and write routines, but this would cause extra overhead.
- *
- * Mode 2 is historical and deprecated by the Revision 2.0 specification.
*/
-union x86_pci_tag_u {
- u_int32_t mode1;
- struct {
- u_int16_t port;
- u_int8_t enable;
- u_int8_t forward;
- } mode2;
-};
extern struct bus_dma_tag pci_bus_dma_tag;
@@ -61,7 +46,7 @@ extern struct bus_dma_tag pci_bus_dma_tag;
* Types provided to machine-independent PCI code
*/
typedef void *pci_chipset_tag_t;
-typedef union x86_pci_tag_u pcitag_t;
+typedef u_int32_t pcitag_t;
typedef struct {
pcitag_t tag;
@@ -71,11 +56,9 @@ typedef struct {
#define pci_intr_line(ih) ((ih.line) & 0xff)
/*
- * i386-specific PCI variables and functions.
+ * amd64-specific PCI variables and functions.
* NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
*/
-extern int pci_mode;
-int pci_mode_detect(void);
struct pci_attach_args;
extern struct extent *pciio_ex;
diff --git a/sys/arch/amd64/pci/pci_machdep.c b/sys/arch/amd64/pci/pci_machdep.c
index 29d371f7067..19137f17676 100644
--- a/sys/arch/amd64/pci/pci_machdep.c
+++ b/sys/arch/amd64/pci/pci_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.c,v 1.27 2009/04/21 17:05:29 oga Exp $ */
+/* $OpenBSD: pci_machdep.c,v 1.28 2009/04/21 19:18:09 kettenis Exp $ */
/* $NetBSD: pci_machdep.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */
/*-
@@ -63,14 +63,6 @@
/*
* Machine-specific functions for PCI autoconfiguration.
- *
- * On PCs, there are two methods of generating PCI configuration cycles.
- * We try to detect the appropriate mechanism for this machine and set
- * up a few function pointers to access the correct method directly.
- *
- * The configuration method can be hard-coded in the config file by
- * using `options PCI_CONF_MODE=N', where `N' is the configuration mode
- * as defined section 3.6.4.1, `Generating Configuration Cycles'.
*/
#include <sys/types.h>
@@ -104,8 +96,6 @@
#include <machine/mpbiosvar.h>
#endif
-int pci_mode = -1;
-
struct mutex pci_conf_lock = MUTEX_INITIALIZER(IPL_HIGH);
#define PCI_CONF_LOCK() \
@@ -122,30 +112,6 @@ do { \
#define PCI_MODE1_ADDRESS_REG 0x0cf8
#define PCI_MODE1_DATA_REG 0x0cfc
-#define PCI_MODE2_ENABLE_REG 0x0cf8
-#define PCI_MODE2_FORWARD_REG 0x0cfa
-
-#define _m1tag(b, d, f) \
- (PCI_MODE1_ENABLE | ((b) << 16) | ((d) << 11) | ((f) << 8))
-#define _qe(bus, dev, fcn, vend, prod) \
- {_m1tag(bus, dev, fcn), PCI_ID_CODE(vend, prod)}
-struct {
- u_int32_t tag;
- pcireg_t id;
-} pcim1_quirk_tbl[] = {
- _qe(0, 0, 0, PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX1),
- /* XXX Triflex2 not tested */
- _qe(0, 0, 0, PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX2),
- _qe(0, 0, 0, PCI_VENDOR_COMPAQ, PCI_PRODUCT_COMPAQ_TRIFLEX4),
- /* Triton needed for Connectix Virtual PC */
- _qe(0, 0, 0, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82437FX),
- /* Connectix Virtual PC 5 has a 440BX */
- _qe(0, 0, 0, PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82443BX_NOAGP),
- {0, 0xffffffff} /* patchable */
-};
-#undef _m1tag
-#undef _qe
-
/*
* PCI doesn't have any special needs; just use the generic versions
* of these functions.
@@ -173,82 +139,37 @@ void
pci_attach_hook(struct device *parent, struct device *self,
struct pcibus_attach_args *pba)
{
- if (pba->pba_bus == 0) {
- printf(": configuration mode %d", pci_mode);
#ifndef SMALL_KERNEL
+ if (pba->pba_bus == 0)
amdgart_probe(pba);
#endif /* !SMALL_KERNEL */
- }
}
int
pci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
{
-
- /*
- * Bus number is irrelevant. If Configuration Mechanism 2 is in
- * use, can only have devices 0-15 on any bus. If Configuration
- * Mechanism 1 is in use, can have devices 0-32 (i.e. the `normal'
- * range).
- */
- if (pci_mode == 2)
- return (16);
- else
- return (32);
+ return (32);
}
pcitag_t
pci_make_tag(pci_chipset_tag_t pc, int bus, int device, int function)
{
- pcitag_t tag;
-
- switch (pci_mode) {
- case 1:
- if (bus >= 256 || device >= 32 || function >= 8)
- panic("pci_make_tag: bad request");
-
- tag.mode1 = PCI_MODE1_ENABLE |
- (bus << 16) | (device << 11) | (function << 8);
- break;
- case 2:
- if (bus >= 256 || device >= 16 || function >= 8)
- panic("pci_make_tag: bad request");
-
- tag.mode2.port = 0xc000 | (device << 8);
- tag.mode2.enable = 0xf0 | (function << 1);
- tag.mode2.forward = bus;
- break;
- default:
- panic("pci_make_tag: mode not configured");
- }
+ if (bus >= 256 || device >= 32 || function >= 8)
+ panic("pci_make_tag: bad request");
- return tag;
+ return (PCI_MODE1_ENABLE |
+ (bus << 16) | (device << 11) | (function << 8));
}
void
pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *bp, int *dp, int *fp)
{
-
- switch (pci_mode) {
- case 1:
- if (bp != NULL)
- *bp = (tag.mode1 >> 16) & 0xff;
- if (dp != NULL)
- *dp = (tag.mode1 >> 11) & 0x1f;
- if (fp != NULL)
- *fp = (tag.mode1 >> 8) & 0x7;
- break;
- case 2:
- if (bp != NULL)
- *bp = tag.mode2.forward & 0xff;
- if (dp != NULL)
- *dp = (tag.mode2.port >> 8) & 0xf;
- if (fp != NULL)
- *fp = (tag.mode2.enable >> 1) & 0x7;
- break;
- default:
- panic("pci_decompose_tag: mode not configured");
- }
+ if (bp != NULL)
+ *bp = (tag >> 16) & 0xff;
+ if (dp != NULL)
+ *dp = (tag >> 11) & 0x1f;
+ if (fp != NULL)
+ *fp = (tag >> 8) & 0x7;
}
pcireg_t
@@ -257,21 +178,9 @@ pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
pcireg_t data;
PCI_CONF_LOCK();
- switch (pci_mode) {
- case 1:
- outl(PCI_MODE1_ADDRESS_REG, tag.mode1 | reg);
- data = inl(PCI_MODE1_DATA_REG);
- outl(PCI_MODE1_ADDRESS_REG, 0);
- break;
- case 2:
- outb(PCI_MODE2_ENABLE_REG, tag.mode2.enable);
- outb(PCI_MODE2_FORWARD_REG, tag.mode2.forward);
- data = inl(tag.mode2.port | reg);
- outb(PCI_MODE2_ENABLE_REG, 0);
- break;
- default:
- panic("pci_conf_read: mode not configured");
- }
+ outl(PCI_MODE1_ADDRESS_REG, tag | reg);
+ data = inl(PCI_MODE1_DATA_REG);
+ outl(PCI_MODE1_ADDRESS_REG, 0);
PCI_CONF_UNLOCK();
return data;
@@ -280,112 +189,11 @@ pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
void
pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
{
-
PCI_CONF_LOCK();
- switch (pci_mode) {
- case 1:
- outl(PCI_MODE1_ADDRESS_REG, tag.mode1 | reg);
- outl(PCI_MODE1_DATA_REG, data);
- outl(PCI_MODE1_ADDRESS_REG, 0);
- break;
- case 2:
- outb(PCI_MODE2_ENABLE_REG, tag.mode2.enable);
- outb(PCI_MODE2_FORWARD_REG, tag.mode2.forward);
- outl(tag.mode2.port | reg, data);
- outb(PCI_MODE2_ENABLE_REG, 0);
- break;
- default:
- panic("pci_conf_write: mode not configured");
- }
- PCI_CONF_UNLOCK();
-}
-
-int
-pci_mode_detect(void)
-{
-
-#ifdef PCI_CONF_MODE
-#if (PCI_CONF_MODE == 1) || (PCI_CONF_MODE == 2)
- return (pci_mode = PCI_CONF_MODE);
-#else
-#error Invalid PCI configuration mode.
-#endif
-#else
- u_int32_t sav, val;
- int i;
- pcireg_t idreg;
-
- if (pci_mode != -1)
- return pci_mode;
-
- /*
- * We try to divine which configuration mode the host bridge wants.
- */
-
- sav = inl(PCI_MODE1_ADDRESS_REG);
-
- pci_mode = 1; /* assume this for now */
- /*
- * catch some known buggy implementations of mode 1
- */
- for (i = 0; i < sizeof(pcim1_quirk_tbl) / sizeof(pcim1_quirk_tbl[0]);
- i++) {
- pcitag_t t;
-
- if (!pcim1_quirk_tbl[i].tag)
- break;
- t.mode1 = pcim1_quirk_tbl[i].tag;
- idreg = pci_conf_read(0, t, PCI_ID_REG); /* needs "pci_mode" */
- if (idreg == pcim1_quirk_tbl[i].id) {
-#ifdef DEBUG
- printf("known mode 1 PCI chipset (%08x)\n",
- idreg);
-#endif
- return (pci_mode);
- }
- }
-
- /*
- * Strong check for standard compliant mode 1:
- * 1. bit 31 ("enable") can be set
- * 2. byte/word access does not affect register
- */
- outl(PCI_MODE1_ADDRESS_REG, PCI_MODE1_ENABLE);
- outb(PCI_MODE1_ADDRESS_REG + 3, 0);
- outw(PCI_MODE1_ADDRESS_REG + 2, 0);
- val = inl(PCI_MODE1_ADDRESS_REG);
- if ((val & 0x80fffffc) != PCI_MODE1_ENABLE) {
-#ifdef DEBUG
- printf("pci_mode_detect: mode 1 enable failed (%x)\n",
- val);
-#endif
- goto not1;
- }
+ outl(PCI_MODE1_ADDRESS_REG, tag | reg);
+ outl(PCI_MODE1_DATA_REG, data);
outl(PCI_MODE1_ADDRESS_REG, 0);
- val = inl(PCI_MODE1_ADDRESS_REG);
- if ((val & 0x80fffffc) != 0)
- goto not1;
- return (pci_mode);
-not1:
- outl(PCI_MODE1_ADDRESS_REG, sav);
-
- /*
- * This mode 2 check is quite weak (and known to give false
- * positives on some Compaq machines).
- * However, this doesn't matter, because this is the
- * last test, and simply no PCI devices will be found if
- * this happens.
- */
- outb(PCI_MODE2_ENABLE_REG, 0);
- outb(PCI_MODE2_FORWARD_REG, 0);
- if (inb(PCI_MODE2_ENABLE_REG) != 0 ||
- inb(PCI_MODE2_FORWARD_REG) != 0)
- goto not2;
- return (pci_mode = 2);
-not2:
-
- return (pci_mode = 0);
-#endif
+ PCI_CONF_UNLOCK();
}
int