summaryrefslogtreecommitdiffstats
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2011-06-24 21:39:38 +0000
committerjhb <jhb@FreeBSD.org>2011-06-24 21:39:38 +0000
commit960e1ff18c7cb3dcf4b5df7ce4af59f81edcfc80 (patch)
tree3a382b1e6296daa700119cc20ae2f75f99ce8254 /sys/dev/pci
parente68086fe4990438ffb7c4cff48df0152f7ddfc11 (diff)
downloadFreeBSD-src-960e1ff18c7cb3dcf4b5df7ce4af59f81edcfc80.zip
FreeBSD-src-960e1ff18c7cb3dcf4b5df7ce4af59f81edcfc80.tar.gz
Split out host_pcib_get_busno() from the generic PCI-PCI bridge driver to
start a new file that will hold utility APIs used by various Host-PCI bridge drivers and drivers that provide PCI domains.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/pci_pci.c92
-rw-r--r--sys/dev/pci/pci_subr.c130
2 files changed, 130 insertions, 92 deletions
diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index da8465c..93bbf3a 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -38,16 +38,12 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/kernel.h>
-#include <sys/libkern.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/rman.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pci_private.h>
@@ -1432,91 +1428,3 @@ pcib_power_for_sleep(device_t pcib, device_t dev, int *pstate)
bus = device_get_parent(pcib);
return (PCIB_POWER_FOR_SLEEP(bus, dev, pstate));
}
-
-/*
- * Try to read the bus number of a host-PCI bridge using appropriate config
- * registers.
- */
-int
-host_pcib_get_busno(pci_read_config_fn read_config, int bus, int slot, int func,
- uint8_t *busnum)
-{
- uint32_t id;
-
- id = read_config(bus, slot, func, PCIR_DEVVENDOR, 4);
- if (id == 0xffffffff)
- return (0);
-
- switch (id) {
- case 0x12258086:
- /* Intel 824?? */
- /* XXX This is a guess */
- /* *busnum = read_config(bus, slot, func, 0x41, 1); */
- *busnum = bus;
- break;
- case 0x84c48086:
- /* Intel 82454KX/GX (Orion) */
- *busnum = read_config(bus, slot, func, 0x4a, 1);
- break;
- case 0x84ca8086:
- /*
- * For the 450nx chipset, there is a whole bundle of
- * things pretending to be host bridges. The MIOC will
- * be seen first and isn't really a pci bridge (the
- * actual busses are attached to the PXB's). We need to
- * read the registers of the MIOC to figure out the
- * bus numbers for the PXB channels.
- *
- * Since the MIOC doesn't have a pci bus attached, we
- * pretend it wasn't there.
- */
- return (0);
- case 0x84cb8086:
- switch (slot) {
- case 0x12:
- /* Intel 82454NX PXB#0, Bus#A */
- *busnum = read_config(bus, 0x10, func, 0xd0, 1);
- break;
- case 0x13:
- /* Intel 82454NX PXB#0, Bus#B */
- *busnum = read_config(bus, 0x10, func, 0xd1, 1) + 1;
- break;
- case 0x14:
- /* Intel 82454NX PXB#1, Bus#A */
- *busnum = read_config(bus, 0x10, func, 0xd3, 1);
- break;
- case 0x15:
- /* Intel 82454NX PXB#1, Bus#B */
- *busnum = read_config(bus, 0x10, func, 0xd4, 1) + 1;
- break;
- }
- break;
-
- /* ServerWorks -- vendor 0x1166 */
- case 0x00051166:
- case 0x00061166:
- case 0x00081166:
- case 0x00091166:
- case 0x00101166:
- case 0x00111166:
- case 0x00171166:
- case 0x01011166:
- case 0x010f1014:
- case 0x01101166:
- case 0x02011166:
- case 0x02251166:
- case 0x03021014:
- *busnum = read_config(bus, slot, func, 0x44, 1);
- break;
-
- /* Compaq/HP -- vendor 0x0e11 */
- case 0x60100e11:
- *busnum = read_config(bus, slot, func, 0xc8, 1);
- break;
- default:
- /* Don't know how to read bus number. */
- return 0;
- }
-
- return 1;
-}
diff --git a/sys/dev/pci/pci_subr.c b/sys/dev/pci/pci_subr.c
new file mode 100644
index 0000000..7f0c806
--- /dev/null
+++ b/sys/dev/pci/pci_subr.c
@@ -0,0 +1,130 @@
+/*-
+ * Copyright (c) 2011 Advanced Computing Technologies LLC
+ * Written by: John H. Baldwin <jhb@FreeBSD.org>
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+/*
+ * Support APIs for Host to PCI bridge drivers and drivers that
+ * provide PCI domains.
+ */
+
+#include <sys/types.h>
+#include <sys/bus.h>
+#include <sys/rman.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcib_private.h>
+
+/*
+ * Try to read the bus number of a host-PCI bridge using appropriate config
+ * registers.
+ */
+int
+host_pcib_get_busno(pci_read_config_fn read_config, int bus, int slot, int func,
+ uint8_t *busnum)
+{
+ uint32_t id;
+
+ id = read_config(bus, slot, func, PCIR_DEVVENDOR, 4);
+ if (id == 0xffffffff)
+ return (0);
+
+ switch (id) {
+ case 0x12258086:
+ /* Intel 824?? */
+ /* XXX This is a guess */
+ /* *busnum = read_config(bus, slot, func, 0x41, 1); */
+ *busnum = bus;
+ break;
+ case 0x84c48086:
+ /* Intel 82454KX/GX (Orion) */
+ *busnum = read_config(bus, slot, func, 0x4a, 1);
+ break;
+ case 0x84ca8086:
+ /*
+ * For the 450nx chipset, there is a whole bundle of
+ * things pretending to be host bridges. The MIOC will
+ * be seen first and isn't really a pci bridge (the
+ * actual busses are attached to the PXB's). We need to
+ * read the registers of the MIOC to figure out the
+ * bus numbers for the PXB channels.
+ *
+ * Since the MIOC doesn't have a pci bus attached, we
+ * pretend it wasn't there.
+ */
+ return (0);
+ case 0x84cb8086:
+ switch (slot) {
+ case 0x12:
+ /* Intel 82454NX PXB#0, Bus#A */
+ *busnum = read_config(bus, 0x10, func, 0xd0, 1);
+ break;
+ case 0x13:
+ /* Intel 82454NX PXB#0, Bus#B */
+ *busnum = read_config(bus, 0x10, func, 0xd1, 1) + 1;
+ break;
+ case 0x14:
+ /* Intel 82454NX PXB#1, Bus#A */
+ *busnum = read_config(bus, 0x10, func, 0xd3, 1);
+ break;
+ case 0x15:
+ /* Intel 82454NX PXB#1, Bus#B */
+ *busnum = read_config(bus, 0x10, func, 0xd4, 1) + 1;
+ break;
+ }
+ break;
+
+ /* ServerWorks -- vendor 0x1166 */
+ case 0x00051166:
+ case 0x00061166:
+ case 0x00081166:
+ case 0x00091166:
+ case 0x00101166:
+ case 0x00111166:
+ case 0x00171166:
+ case 0x01011166:
+ case 0x010f1014:
+ case 0x01101166:
+ case 0x02011166:
+ case 0x02251166:
+ case 0x03021014:
+ *busnum = read_config(bus, slot, func, 0x44, 1);
+ break;
+
+ /* Compaq/HP -- vendor 0x0e11 */
+ case 0x60100e11:
+ *busnum = read_config(bus, slot, func, 0xc8, 1);
+ break;
+ default:
+ /* Don't know how to read bus number. */
+ return 0;
+ }
+
+ return 1;
+}
OpenPOWER on IntegriCloud