Created
April 20, 2016 21:21
-
-
Save landonf/c7289a98ec735430166be7090153c421 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile | |
index 3d87773..8aeb80e 100644 | |
--- a/share/man/man4/Makefile | |
+++ b/share/man/man4/Makefile | |
@@ -71,9 +71,12 @@ MAN= aac.4 \ | |
axe.4 \ | |
axge.4 \ | |
bce.4 \ | |
+ bcma.4 \ | |
bfe.4 \ | |
bge.4 \ | |
${_bhyve.4} \ | |
+ bhnd.4 \ | |
+ bhndb.4 \ | |
bktr.4 \ | |
blackhole.4 \ | |
bpf.4 \ | |
diff --git a/share/man/man4/bcma.4 b/share/man/man4/bcma.4 | |
new file mode 100644 | |
index 0000000..792c607 | |
--- /dev/null | |
+++ b/share/man/man4/bcma.4 | |
@@ -0,0 +1,78 @@ | |
+.\" Copyright (c) 2015 Landon Fuller | |
+.\" Copyright (c) 2010 Weongyo Jeong | |
+.\" 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. | |
+.\" | |
+.\" $FreeBSD$ | |
+.\" | |
+.Dd December 8, 2015 | |
+.Dt BCMA 4 | |
+.Os | |
+.Sh NAME | |
+.Nm bcma | |
+.Nd Broadcom AMBA Backplane driver | |
+.Sh SYNOPSIS | |
+To compile this driver into the kernel, | |
+place the following lines in your kernel configuration file: | |
+.Bd -ragged -offset indent | |
+.Cd "device bhnd" | |
+.Cd "device bcma" | |
+.Ed | |
+.Pp | |
+Alternatively, to load the driver as a module at boot time, | |
+place the following line in | |
+.Xr loader.conf 5 : | |
+.Bd -literal -offset indent | |
+bcma_load="YES" | |
+.Ed | |
+.Sh DESCRIPTION | |
+The | |
+.Nm | |
+driver provides | |
+.Xr bhnd 4 | |
+support for devices using the ARM AMBA-based backplane architecture found | |
+in later Broadcom Home Networking Division's (HND) wireless chipsets and | |
+embedded systems. | |
+.Pp | |
+A common interconnect connects all of the backplane's functional | |
+blocks. These functional blocks, known as cores, use the ARM AMBA AXI or | |
+APB interface to communicate with devices attached to the interconnect. | |
+.Pp | |
+The IP cores used in | |
+.Xr siba 4 | |
+devices were adapted by Broadcom for compatibility with the new | |
+interconnect. | |
+.Sh SEE ALSO | |
+.Xr bcma 4 , | |
+.Xr bhnd 4 | |
+.Sh HISTORY | |
+The | |
+.Nm | |
+device driver first appeared in | |
+.Fx 11.0 . | |
+.Sh AUTHORS | |
+.An -nosplit | |
+The | |
+.Nm | |
+driver was written by | |
+.An Landon Fuller Aq Mt [email protected] . | |
diff --git a/share/man/man4/bhnd.4 b/share/man/man4/bhnd.4 | |
new file mode 100644 | |
index 0000000..5f683c6 | |
--- /dev/null | |
+++ b/share/man/man4/bhnd.4 | |
@@ -0,0 +1,83 @@ | |
+.\" Copyright (c) 2015 Landon Fuller | |
+.\" 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. | |
+.\" | |
+.\" $FreeBSD$ | |
+.\" | |
+.Dd December 8, 2015 | |
+.Dt BHND 4 | |
+.Os | |
+.Sh NAME | |
+.Nm bhnd | |
+.Nd Broadcom Home Networking Division interconnect bus | |
+.Sh SYNOPSIS | |
+To compile this driver into the kernel, | |
+place the following lines in your kernel configuration file: | |
+.Bd -ragged -offset indent | |
+.Cd "device bhnd" | |
+.Ed | |
+.Pp | |
+Alternatively, to load the driver as a module at boot time, | |
+place the following line in | |
+.Xr loader.conf 5 : | |
+.Bd -literal -offset indent | |
+bhnd_load="YES" | |
+.Ed | |
+.Sh DESCRIPTION | |
+The | |
+.Nm | |
+driver provides a unified kernel bus interface to the on-chip | |
+interconnects used in Broadcom Home Networking Division (HND) | |
+devices. | |
+.Pp | |
+The Broadcom HND device family consists of SoCs (System On a Chip) | |
+and host-connected chipsets based on a common library of Broadcom IP | |
+cores connected via an internal hardware bus architecture. Drivers | |
+for these cores are implemented against the unified | |
+.Nm | |
+interface. | |
+.Pp | |
+The Sonic Inc. Silicon Backplane used in earlier HND devices is supported | |
+by the | |
+.Xr siba 4 | |
+BHND driver. | |
+.Pp | |
+The ARM AMBA-based interconnect used in later HND devices is supported by | |
+the | |
+.Xr bcma 4 | |
+BHND driver. | |
+.Sh SEE ALSO | |
+.Xr bhndb 4 , | |
+.Xr bcma 4 , | |
+.Xr siba 4 | |
+.Sh HISTORY | |
+The | |
+.Nm | |
+device driver first appeared in | |
+.Fx 11.0 . | |
+.Sh AUTHORS | |
+.An -nosplit | |
+The | |
+.Nm | |
+driver was written by | |
+.An Landon Fuller Aq Mt [email protected] . | |
diff --git a/share/man/man4/bhndb.4 b/share/man/man4/bhndb.4 | |
new file mode 100644 | |
index 0000000..eb01f66d | |
--- /dev/null | |
+++ b/share/man/man4/bhndb.4 | |
@@ -0,0 +1,72 @@ | |
+.\" Copyright (c) 2015 Landon Fuller | |
+.\" 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. | |
+.\" | |
+.\" $FreeBSD$ | |
+.\" | |
+.Dd December 8, 2015 | |
+.Dt BHNDB 4 | |
+.Os | |
+.Sh NAME | |
+.Nm bhndb | |
+.Nd Broadcom Home Networking Division interconnect bridge driver | |
+.Sh SYNOPSIS | |
+To compile this driver into the kernel, | |
+place the following lines in your kernel configuration file: | |
+.Bd -ragged -offset indent | |
+.Cd "device bhnd" | |
+.Cd "device bhndb" | |
+.Ed | |
+.Pp | |
+Alternatively, to load the driver as a module at boot time, | |
+place the following line in | |
+.Xr loader.conf 5 : | |
+.Bd -literal -offset indent | |
+bhndb_load="YES" | |
+bhndb_pci_load="YES" | |
+.Ed | |
+.Sh DESCRIPTION | |
+The | |
+.Nm | |
+driver supports | |
+.Xr bhnd 4 | |
+host bridge cores such as those used by Broadcom HND PCI, | |
+PCMCIA, and SDIO network adapters. | |
+.Sh SEE ALSO | |
+.Xr bhnd 4 | |
+.Xr bwn 4 | |
+.Sh HISTORY | |
+The | |
+.Nm | |
+device driver first appeared in | |
+.Fx 11.0 . | |
+.Sh AUTHORS | |
+.An -nosplit | |
+The | |
+.Nm | |
+driver was written by | |
+.An Landon Fuller Aq Mt [email protected] . | |
+.Sh CAVEATS | |
+The | |
+.Nm | |
+driver does not currently support PCMCIA or SDIO devices. | |
diff --git a/share/man/man4/siba.4 b/share/man/man4/siba.4 | |
index 6f855d4..5750d3d 100644 | |
--- a/share/man/man4/siba.4 | |
+++ b/share/man/man4/siba.4 | |
@@ -34,6 +34,7 @@ | |
To compile this driver into the kernel, | |
place the following lines in your kernel configuration file: | |
.Bd -ragged -offset indent | |
+.Cd "device bhnd" | |
.Cd "device siba" | |
.Ed | |
.Pp | |
@@ -46,20 +47,17 @@ siba_load="YES" | |
.Sh DESCRIPTION | |
The | |
.Nm | |
-driver supports the Sonic Inc. Silicon Backplane, the interblock | |
-communications architecture that can be found in most Broadcom | |
-wireless NICs. | |
+driver provides | |
+.Xr bhnd 4 | |
+support for devices based on the Sonic Inc. Silicon Backplane, an | |
+interblock communications architecture found in earlier Broadcom Home | |
+Networking Division wireless chipsets and embedded systems. | |
.Pp | |
-A bus connects all of the Silicon Backplane's functional blocks. | |
-These functional blocks, known as cores, use the Open Core Protocol | |
+A common interconnect connects all of the Silicon Backplane's functional | |
+blocks. These functional blocks, known as cores, use the Open Core Protocol | |
(OCP) interface to communicate with agents attached to the Silicon | |
Backplane. | |
.Pp | |
-Each NIC uses a chip from the same chip family. | |
-Each member of the family contains a different set of cores, but | |
-shares basic architectural features such as address space definition, | |
-interrupt and error architecture, and backplane register definitions. | |
-.Pp | |
Each core can have an initiator agent that passes read and write | |
requests onto the system backplane and a target agent that returns | |
responses to those requests. | |
@@ -67,22 +65,29 @@ Not all cores contain both an initiator and a target agent. | |
Initiator agents are present in cores that contain | |
host interfaces (PCI, PCMCIA), embedded processors (MIPS), | |
or DMA processors associated with communications cores. | |
-.Pp | |
-All cores other than PCMCIA have a target agent. | |
.Sh SEE ALSO | |
-.Xr bwn 4 | |
+.Xr bcma 4 , | |
+.Xr bhnd 4 | |
.Sh HISTORY | |
The | |
.Nm | |
device driver first appeared in | |
.Fx 8.0 . | |
+The driver was rewritten for | |
+.Fx 11.0 . | |
+to support the common Broadcom | |
+.Xr bhnd 4 | |
+bus interface. | |
.Sh AUTHORS | |
.An -nosplit | |
The | |
.Nm | |
-driver was written by | |
+driver was originally written by | |
.An Bruce M. Simpson Aq Mt [email protected] | |
and | |
.An Weongyo Jeong Aq Mt [email protected] . | |
-.Sh CAVEATS | |
-Host mode is not supported at this moment. | |
+ | |
+The driver was rewritten for | |
+.Fx 11.0 . | |
+by | |
+.An Landon Fuller Aq Mt [email protected] . | |
diff --git a/sys/conf/files b/sys/conf/files | |
index 6e57021..8acbb4b 100644 | |
--- a/sys/conf/files | |
+++ b/sys/conf/files | |
@@ -1107,9 +1112,34 @@ dev/ath/ath_rate/sample/sample.c optional ath_rate_sample \ | |
dev/ath/ath_dfs/null/dfs_null.c optional ath \ | |
compile-with "${NORMAL_C} -I$S/dev/ath" | |
# | |
-dev/bce/if_bce.c optional bce | |
-dev/bfe/if_bfe.c optional bfe | |
-dev/bge/if_bge.c optional bge | |
+dev/bce/if_bce.c optional bce | |
+dev/bfe/if_bfe.c optional bfe | |
+dev/bge/if_bge.c optional bge | |
+dev/bhnd/bhnd.c optional bhndbus | bhnd | |
+dev/bhnd/bhnd_subr.c optional bhndbus | bhnd | |
+dev/bhnd/bhnd_bus_if.m optional bhndbus | bhnd | |
+dev/bhnd/bhndb/bhndb.c optional bhndbus | bhndb | |
+dev/bhnd/bhndb/bhndb_bus_if.m optional bhndbus | bhndb | |
+dev/bhnd/bhndb/bhndb_hwdata.c optional bhndbus | bhndb | |
+dev/bhnd/bhndb/bhndb_if.m optional bhndbus | bhndb | |
+dev/bhnd/bhndb/bhndb_pci.c optional bhndbus pci | bhndb pci | |
+dev/bhnd/bhndb/bhndb_pci_hwdata.c optional bhndbus pci | bhndb pci | |
+dev/bhnd/bhndb/bhndb_pci_sprom.c optional bhndbus pci | bhndb pci | |
+dev/bhnd/bhndb/bhndb_subr.c optional bhndbus pci | bhndb | |
+dev/bhnd/bcma/bcma.c optional bhndbus | bcma | |
+dev/bhnd/bcma/bcma_bhndb.c optional bhndbus | bcma bhndb | |
+dev/bhnd/bcma/bcma_erom.c optional bhndbus | bcma | |
+dev/bhnd/bcma/bcma_subr.c optional bhndbus | bcma | |
+dev/bhnd/cores/chipc/chipc.c optional bhndbus | bhnd | |
+dev/bhnd/cores/chipc/bhnd_chipc_if.m optional bhndbus | bhnd | |
+dev/bhnd/cores/pci/bhnd_pci.c optional bhndbus pci | bhnd pci | |
+dev/bhnd/cores/pci/bhnd_pci_hostb.c optional bhndbus pci | bhndb pci | |
+dev/bhnd/cores/pci/bhnd_pcib.c optional bhnd_pcib bhnd pci | |
+dev/bhnd/siba/siba.c optional bhndbus | siba | |
+dev/bhnd/siba/siba_bhndb.c optional bhndbus | siba bhndb | |
+dev/bhnd/siba/siba_nexus.c optional siba_nexus siba | |
+dev/bhnd/siba/siba_subr.c optional bhndbus | siba | |
+# | |
dev/bktr/bktr_audio.c optional bktr pci | |
dev/bktr/bktr_card.c optional bktr pci | |
dev/bktr/bktr_core.c optional bktr pci | |
@@ -1127,9 +1160,8 @@ dev/bwi/bwiphy.c optional bwi | |
dev/bwi/bwirf.c optional bwi | |
dev/bwi/if_bwi.c optional bwi | |
dev/bwi/if_bwi_pci.c optional bwi pci | |
-# XXX Work around clang warning, until maintainer approves fix. | |
-dev/bwn/if_bwn.c optional bwn siba_bwn \ | |
- compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}" | |
+dev/bwn/bwn_mac.c optional bwn | |
+dev/bwn/if_bwn_pci.c optional bwn pci | |
dev/cardbus/cardbus.c optional cardbus | |
dev/cardbus/cardbus_cis.c optional cardbus | |
dev/cardbus/cardbus_device.c optional cardbus | |
@@ -2394,11 +2426,6 @@ dev/si/si3_t225.c optional si | |
dev/si/si_eisa.c optional si eisa | |
dev/si/si_isa.c optional si isa | |
dev/si/si_pci.c optional si pci | |
-dev/siba/siba.c optional siba | |
-dev/siba/siba_bwn.c optional siba_bwn pci | |
-dev/siba/siba_cc.c optional siba | |
-dev/siba/siba_core.c optional siba | siba_bwn pci | |
-dev/siba/siba_pcib.c optional siba pci | |
dev/siis/siis.c optional siis pci | |
dev/sis/if_sis.c optional sis pci | |
dev/sk/if_sk.c optional sk pci | |
diff --git a/sys/dev/bwn/bwn_mac.c b/sys/dev/bwn/bwn_mac.c | |
new file mode 100644 | |
index 0000000..6697cc8 | |
--- /dev/null | |
+++ b/sys/dev/bwn/bwn_mac.c | |
@@ -0,0 +1,139 @@ | |
+/*- | |
+ * Copyright (c) 2015 Landon Fuller <[email protected]> | |
+ * 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, | |
+ * without modification. | |
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer | |
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any | |
+ * redistribution must be conditioned upon including a substantially | |
+ * similar Disclaimer requirement for further binary redistribution. | |
+ * | |
+ * NO WARRANTY | |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY | |
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. | |
+ */ | |
+ | |
+#include <sys/cdefs.h> | |
+__FBSDID("$FreeBSD$"); | |
+ | |
+#include <sys/param.h> | |
+#include <sys/kernel.h> | |
+#include <sys/module.h> | |
+#include <sys/systm.h> | |
+ | |
+#include <machine/bus.h> | |
+#include <sys/rman.h> | |
+#include <machine/resource.h> | |
+ | |
+#include <dev/bhnd/bhnd.h> | |
+#include <dev/bhnd/bhnd_ids.h> | |
+ | |
+static const struct resource_spec bwn_rspec[] = { | |
+ { SYS_RES_MEMORY, 0, RF_ACTIVE }, | |
+ { -1, -1, 0 } | |
+}; | |
+ | |
+#define RSPEC_LEN (sizeof(bwn_rspec)/sizeof(bwn_rspec[0])) | |
+ | |
+struct bwn_softc { | |
+ struct resource_spec rspec[RSPEC_LEN]; | |
+ struct bhnd_resource *res[RSPEC_LEN-1]; | |
+}; | |
+ | |
+static const struct bwn_device { | |
+ uint16_t vendor; | |
+ uint16_t device; | |
+} bwn_devices[] = { | |
+ { BHND_MFGID_BCM, BHND_COREID_D11 }, | |
+ { BHND_COREID_INVALID } | |
+}; | |
+ | |
+static int | |
+bwn_probe(device_t dev) | |
+{ | |
+ const struct bwn_device *id; | |
+ | |
+ for (id = bwn_devices; id->device != BHND_COREID_INVALID; id++) | |
+ { | |
+ if (bhnd_get_vendor(dev) == id->vendor && | |
+ bhnd_get_device(dev) == id->device) | |
+ { | |
+ device_set_desc(dev, bhnd_get_device_name(dev)); | |
+ return (BUS_PROBE_DEFAULT); | |
+ } | |
+ } | |
+ | |
+ return (ENXIO); | |
+} | |
+ | |
+static int | |
+bwn_attach(device_t dev) | |
+{ | |
+ struct bwn_softc *sc; | |
+ struct bhnd_resource *r; | |
+ int error; | |
+ | |
+ sc = device_get_softc(dev); | |
+ | |
+ memcpy(sc->rspec, bwn_rspec, sizeof(bwn_rspec)); | |
+ if ((error = bhnd_alloc_resources(dev, sc->rspec, sc->res))) | |
+ return (error); | |
+ | |
+ // XXX TODO | |
+ r = sc->res[0]; | |
+ device_printf(dev, "got rid=%d res=%p\n", sc->rspec[0].rid, r); | |
+ | |
+ return (0); | |
+} | |
+ | |
+static int | |
+bwn_detach(device_t dev) | |
+{ | |
+ struct bwn_softc *sc; | |
+ | |
+ sc = device_get_softc(dev); | |
+ bhnd_release_resources(dev, sc->rspec, sc->res); | |
+ | |
+ return (0); | |
+} | |
+ | |
+static int | |
+bwn_suspend(device_t dev) | |
+{ | |
+ return (0); | |
+} | |
+ | |
+static int | |
+bwn_resume(device_t dev) | |
+{ | |
+ return (0); | |
+} | |
+ | |
+static device_method_t bwn_methods[] = { | |
+ /* Device interface */ | |
+ DEVMETHOD(device_probe, bwn_probe), | |
+ DEVMETHOD(device_attach, bwn_attach), | |
+ DEVMETHOD(device_detach, bwn_detach), | |
+ DEVMETHOD(device_suspend, bwn_suspend), | |
+ DEVMETHOD(device_resume, bwn_resume), | |
+ DEVMETHOD_END | |
+}; | |
+ | |
+static devclass_t bwn_devclass; | |
+ | |
+DEFINE_CLASS_0(bwn, bwn_driver, bwn_methods, sizeof(struct bwn_softc)); | |
+DRIVER_MODULE(bwn, bhnd, bwn_driver, bwn_devclass, 0, 0); | |
diff --git a/sys/dev/bwn/if_bwn_pci.c b/sys/dev/bwn/if_bwn_pci.c | |
new file mode 100644 | |
index 0000000..c08ef9f | |
--- /dev/null | |
+++ b/sys/dev/bwn/if_bwn_pci.c | |
@@ -0,0 +1,274 @@ | |
+/*- | |
+ * Copyright (c) 2015 Landon Fuller <[email protected]> | |
+ * 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, | |
+ * without modification. | |
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer | |
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any | |
+ * redistribution must be conditioned upon including a substantially | |
+ * similar Disclaimer requirement for further binary redistribution. | |
+ * | |
+ * NO WARRANTY | |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY | |
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. | |
+ */ | |
+ | |
+#include <sys/cdefs.h> | |
+__FBSDID("$FreeBSD$"); | |
+ | |
+#include <sys/param.h> | |
+#include <sys/kernel.h> | |
+#include <sys/bus.h> | |
+#include <sys/module.h> | |
+ | |
+#include <dev/pci/pcireg.h> | |
+#include <dev/pci/pcivar.h> | |
+ | |
+#include <dev/bhnd/bhndb/bhndb_pcivar.h> | |
+#include <dev/bhnd/bhndb/bhndb_pci_hwdata.h> | |
+ | |
+#include <dev/bhnd/bhnd_ids.h> | |
+ | |
+#include "bhndb_bus_if.h" | |
+ | |
+#include "if_bwn_pcivar.h" | |
+ | |
+/* If non-zero, enable attachment of BWN_QUIRK_UNTESTED devices */ | |
+static u_int attach_untested = 0; | |
+TUNABLE_INT("hw.bwn_pci.attach_untested", &attach_untested); | |
+ | |
+/* SIBA Devices */ | |
+static const struct bwn_pci_device siba_devices[] = { | |
+ BWN_BCM_DEV(BCM4301, "BCM4301 802.11b", | |
+ BWN_QUIRK_ENET_HW_UNPOPULATED), | |
+ | |
+ BWN_BCM_DEV(BCM4306, "BCM4306 802.11b/g", 0), | |
+ BWN_BCM_DEV(BCM4306_D11G, "BCM4306 802.11g", 0), | |
+ BWN_BCM_DEV(BCM4306_D11A, "BCM4306 802.11a", | |
+ BWN_QUIRK_WLAN_DUALCORE), | |
+ BWN_BCM_DEV(BCM4306_D11DUAL, "BCM4306 802.11a/b", | |
+ BWN_QUIRK_WLAN_DUALCORE), | |
+ BWN_BCM_DEV(BCM4306_D11G_ID2, "BCM4306 802.11g", 0), | |
+ | |
+ BWN_BCM_DEV(BCM4307, "BCM4307 802.11b", 0), | |
+ | |
+ BWN_BCM_DEV(BCM4311_D11G, "BCM4311 802.11b/g", 0), | |
+ BWN_BCM_DEV(BCM4311_D11DUAL, "BCM4311 802.11a/b/g", 0), | |
+ BWN_BCM_DEV(BCM4311_D11A, "BCM4311 802.11a", | |
+ BWN_QUIRK_UNTESTED|BWN_QUIRK_WLAN_DUALCORE), | |
+ | |
+ BWN_BCM_DEV(BCM4318_D11G, "BCM4318 802.11b/g", 0), | |
+ BWN_BCM_DEV(BCM4318_D11DUAL, "BCM4318 802.11a/b/g", 0), | |
+ BWN_BCM_DEV(BCM4318_D11A, "BCM4318 802.11a", | |
+ BWN_QUIRK_UNTESTED|BWN_QUIRK_WLAN_DUALCORE), | |
+ | |
+ BWN_BCM_DEV(BCM4321_D11N, "BCM4321 802.11n Dual-Band", 0), | |
+ BWN_BCM_DEV(BCM4321_D11N2G, "BCM4321 802.11n 2GHz", 0), | |
+ BWN_BCM_DEV(BCM4321_D11N2G, "BCM4321 802.11n 5GHz", | |
+ BWN_QUIRK_UNTESTED), | |
+ | |
+ BWN_BCM_DEV(BCM4322_D11N, "BCM4322 802.11n Dual-Band", 0), | |
+ BWN_BCM_DEV(BCM4322_D11N2G, "BCM4322 802.11n 2GHz", | |
+ BWN_QUIRK_UNTESTED), | |
+ BWN_BCM_DEV(BCM4322_D11N5G, "BCM4322 802.11n 5GHz", | |
+ BWN_QUIRK_UNTESTED), | |
+ | |
+ BWN_BCM_DEV(BCM4328_D11G, "BCM4328/4312 802.11g", 0), | |
+ | |
+ { 0, 0, NULL, 0 } | |
+}; | |
+ | |
+/** BCMA Devices */ | |
+static const struct bwn_pci_device bcma_devices[] = { | |
+ BWN_BCM_DEV(BCM4331_D11N, "BCM4331 802.11n Dual-Band", 0), | |
+ BWN_BCM_DEV(BCM4331_D11N2G, "BCM4331 802.11n 2GHz", 0), | |
+ BWN_BCM_DEV(BCM4331_D11N5G, "BCM4331 802.11n 5GHz", 0), | |
+ | |
+ { 0, 0, NULL, 0} | |
+}; | |
+ | |
+/** Device configuration table */ | |
+static const struct bwn_pci_devcfg bwn_pci_devcfgs[] = { | |
+ /* SIBA devices */ | |
+ { | |
+ .bridge_hwcfg = &bhndb_pci_siba_generic_hwcfg, | |
+ .bridge_hwtable = bhndb_pci_generic_hw_table, | |
+ .devices = siba_devices | |
+ }, | |
+ /* BCMA devices */ | |
+ { | |
+ .bridge_hwcfg = &bhndb_pci_bcma_generic_hwcfg, | |
+ .bridge_hwtable = bhndb_pci_generic_hw_table, | |
+ .devices = bcma_devices | |
+ }, | |
+ { NULL, NULL, NULL } | |
+}; | |
+ | |
+/** Search the device configuration table for an entry matching @p dev. */ | |
+static int | |
+bwn_pci_find_devcfg(device_t dev, const struct bwn_pci_devcfg **cfg, | |
+ const struct bwn_pci_device **device) | |
+{ | |
+ const struct bwn_pci_devcfg *dvc; | |
+ const struct bwn_pci_device *dv; | |
+ | |
+ for (dvc = bwn_pci_devcfgs; dvc->devices != NULL; dvc++) { | |
+ for (dv = dvc->devices; dv->device != 0; dv++) { | |
+ if (pci_get_vendor(dev) == dv->vendor && | |
+ pci_get_device(dev) == dv->device) | |
+ { | |
+ if (cfg != NULL) | |
+ *cfg = dvc; | |
+ | |
+ if (device != NULL) | |
+ *device = dv; | |
+ | |
+ return (0); | |
+ } | |
+ } | |
+ } | |
+ | |
+ return (ENOENT); | |
+} | |
+ | |
+static int | |
+bwn_pci_probe(device_t dev) | |
+{ | |
+ const struct bwn_pci_device *ident; | |
+ | |
+ if (bwn_pci_find_devcfg(dev, NULL, &ident)) | |
+ return (ENXIO); | |
+ | |
+ /* Skip untested devices */ | |
+ if (ident->quirks & BWN_QUIRK_UNTESTED && !attach_untested) | |
+ return (ENXIO); | |
+ | |
+ device_set_desc(dev, ident->desc); | |
+ return (BUS_PROBE_DEFAULT); | |
+} | |
+ | |
+static int | |
+bwn_pci_attach(device_t dev) | |
+{ | |
+ struct bwn_pci_softc *sc; | |
+ const struct bwn_pci_device *ident; | |
+ int error; | |
+ | |
+ sc = device_get_softc(dev); | |
+ sc->dev = dev; | |
+ | |
+ /* Find our hardware config */ | |
+ if (bwn_pci_find_devcfg(dev, &sc->devcfg, &ident)) | |
+ return (ENXIO); | |
+ | |
+ /* Save quirk flags */ | |
+ sc->quirks = ident->quirks; | |
+ | |
+ /* Attach bridge device */ | |
+ if ((error = bhndb_attach_bridge(dev, &sc->bhndb_dev, -1))) | |
+ return (ENXIO); | |
+ | |
+ /* Success */ | |
+ return (0); | |
+} | |
+ | |
+static int | |
+bwn_pci_detach(device_t dev) | |
+{ | |
+ return (bus_generic_detach(dev)); | |
+} | |
+ | |
+static void | |
+bwn_pci_probe_nomatch(device_t dev, device_t child) | |
+{ | |
+ const char *name; | |
+ | |
+ name = device_get_name(child); | |
+ if (name == NULL) | |
+ name = "unknown device"; | |
+ | |
+ device_printf(dev, "<%s> (no driver attached)\n", name); | |
+} | |
+ | |
+static const struct bhndb_hwcfg * | |
+bwn_pci_get_generic_hwcfg(device_t dev, device_t child) | |
+{ | |
+ struct bwn_pci_softc *sc = device_get_softc(dev); | |
+ return (sc->devcfg->bridge_hwcfg); | |
+} | |
+ | |
+static const struct bhndb_hw * | |
+bwn_pci_get_bhndb_hwtable(device_t dev, device_t child) | |
+{ | |
+ struct bwn_pci_softc *sc = device_get_softc(dev); | |
+ return (sc->devcfg->bridge_hwtable); | |
+} | |
+ | |
+static bool | |
+bwn_pci_is_core_disabled(device_t dev, device_t child, | |
+ struct bhnd_core_info *core) | |
+{ | |
+ struct bwn_pci_softc *sc; | |
+ | |
+ sc = device_get_softc(dev); | |
+ | |
+ switch (bhnd_core_class(core)) { | |
+ case BHND_DEVCLASS_WLAN: | |
+ if (core->unit > 0 && !(sc->quirks & BWN_QUIRK_WLAN_DUALCORE)) | |
+ return (true); | |
+ | |
+ return (false); | |
+ | |
+ case BHND_DEVCLASS_ENET: | |
+ case BHND_DEVCLASS_ENET_MAC: | |
+ case BHND_DEVCLASS_ENET_PHY: | |
+ return ((sc->quirks & BWN_QUIRK_ENET_HW_UNPOPULATED) != 0); | |
+ | |
+ default: | |
+ return (false); | |
+ } | |
+} | |
+ | |
+static device_method_t bwn_pci_methods[] = { | |
+ /* Device interface */ | |
+ DEVMETHOD(device_probe, bwn_pci_probe), | |
+ DEVMETHOD(device_attach, bwn_pci_attach), | |
+ DEVMETHOD(device_detach, bwn_pci_detach), | |
+ DEVMETHOD(device_shutdown, bus_generic_shutdown), | |
+ DEVMETHOD(device_suspend, bus_generic_suspend), | |
+ DEVMETHOD(device_resume, bus_generic_resume), | |
+ | |
+ /* Bus interface */ | |
+ DEVMETHOD(bus_probe_nomatch, bwn_pci_probe_nomatch), | |
+ | |
+ /* BHNDB_BUS Interface */ | |
+ DEVMETHOD(bhndb_bus_get_generic_hwcfg, bwn_pci_get_generic_hwcfg), | |
+ DEVMETHOD(bhndb_bus_get_hardware_table, bwn_pci_get_bhndb_hwtable), | |
+ DEVMETHOD(bhndb_bus_is_core_disabled, bwn_pci_is_core_disabled), | |
+ | |
+ DEVMETHOD_END | |
+}; | |
+ | |
+static devclass_t bwn_pci_devclass; | |
+ | |
+DEFINE_CLASS_0(bwn_pci, bwn_pci_driver, bwn_pci_methods, sizeof(struct bwn_pci_softc)); | |
+DRIVER_MODULE(bwn_pci, pci, bwn_pci_driver, bwn_pci_devclass, NULL, NULL); | |
+DRIVER_MODULE(bwn_bcmab, bwn_pci, bhndb_pci_driver, bhndb_devclass, NULL, NULL); | |
+ | |
+MODULE_DEPEND(bwn_pci, bhndb_pci, 1, 1, 1); | |
+MODULE_DEPEND(bwn_pci, siba, 1, 1, 1); | |
+MODULE_DEPEND(bwn_pci, bcma, 1, 1, 1); | |
\ No newline at end of file | |
diff --git a/sys/dev/bwn/if_bwn_pcivar.h b/sys/dev/bwn/if_bwn_pcivar.h | |
new file mode 100644 | |
index 0000000..f0646bf | |
--- /dev/null | |
+++ b/sys/dev/bwn/if_bwn_pcivar.h | |
@@ -0,0 +1,93 @@ | |
+/*- | |
+ * Copyright (c) 2015 Landon Fuller <[email protected]> | |
+ * 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, | |
+ * without modification. | |
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer | |
+ * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any | |
+ * redistribution must be conditioned upon including a substantially | |
+ * similar Disclaimer requirement for further binary redistribution. | |
+ * | |
+ * NO WARRANTY | |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY | |
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. | |
+ * | |
+ * $FreeBSD$ | |
+ */ | |
+ | |
+#ifndef _IF_BWN_PCIVAR_H_ | |
+#define _IF_BWN_PCIVAR_H_ | |
+ | |
+struct bwn_pci_devcfg; | |
+ | |
+/** bwn_pci per-instance state. */ | |
+struct bwn_pci_softc { | |
+ device_t dev; /**< device */ | |
+ device_t bhndb_dev; /**< bhnd bridge device */ | |
+ const struct bwn_pci_devcfg *devcfg; /**< bwn device config */ | |
+ uint32_t quirks; /**< quirk flags */ | |
+}; | |
+ | |
+/* bwn device quirks */ | |
+enum { | |
+ /** No quirks */ | |
+ BWN_QUIRK_NONE = 0, | |
+ | |
+ /** | |
+ * This model/revision has not been tested and may not work. | |
+ */ | |
+ BWN_QUIRK_UNTESTED = 1<<0, | |
+ | |
+ /** | |
+ * Early dual-band devices did not support accessing multiple PHYs | |
+ * from a single WLAN core, and instead used seperate 2GHz and 5GHz | |
+ * WLAN cores. | |
+ * | |
+ * However, not all cards with two WLAN cores are fully populated; | |
+ * we must whitelist the boards on which a second WLAN core is actually | |
+ * usable. | |
+ */ | |
+ BWN_QUIRK_WLAN_DUALCORE = 1<<1, | |
+ | |
+ /** | |
+ * Some early devices shipped with unconnected ethernet cores; set | |
+ * this quirk to treat these cores as unpopulated. | |
+ */ | |
+ BWN_QUIRK_ENET_HW_UNPOPULATED = 1<<2, | |
+}; | |
+ | |
+/* PCI device descriptor */ | |
+struct bwn_pci_device { | |
+ uint16_t vendor; | |
+ uint16_t device; | |
+ const char *desc; | |
+ uint32_t quirks; | |
+}; | |
+ | |
+ | |
+#define BWN_BCM_DEV(_devid, _desc, _quirks) \ | |
+ { PCI_VENDOR_BROADCOM, PCI_DEVID_ ## _devid, \ | |
+ "Broadcom " _desc " Wireless", _quirks } | |
+ | |
+/* Supported device table */ | |
+struct bwn_pci_devcfg { | |
+ const struct bhndb_hwcfg *bridge_hwcfg; | |
+ const struct bhndb_hw *bridge_hwtable; | |
+ const struct bwn_pci_device *devices; | |
+}; | |
+ | |
+#endif /* _IF_BWN_PCIVAR_H_ */ | |
\ No newline at end of file | |
diff --git a/sys/dev/siba/siba_pcib.c b/sys/dev/siba/siba_pcib.c | |
deleted file mode 100644 | |
index 5780e62..0000000 | |
--- a/sys/dev/siba/siba_pcib.c | |
+++ /dev/null | |
@@ -1,430 +0,0 @@ | |
-/*- | |
- * Copyright (c) 2007 Bruce M. Simpson. | |
- * 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. | |
- */ | |
- | |
-/* | |
- * Child driver for PCI host bridge core. | |
- */ | |
- | |
-#include <sys/cdefs.h> | |
-__FBSDID("$FreeBSD$"); | |
- | |
-#include <sys/param.h> | |
-#include <sys/systm.h> | |
-#include <sys/bus.h> | |
-#include <sys/kernel.h> | |
-#include <sys/module.h> | |
-#include <sys/rman.h> | |
-#include <sys/malloc.h> | |
-#include <sys/endian.h> | |
- | |
-#include <vm/vm.h> | |
-#include <vm/pmap.h> | |
-#include <vm/vm_extern.h> | |
- | |
-#include <machine/bus.h> | |
-#include <machine/cpu.h> | |
-#include <machine/pcb.h> | |
- | |
-#include <dev/pci/pcireg.h> | |
-#include <dev/pci/pcivar.h> | |
-#include <dev/pci/pcib_private.h> | |
- | |
-#include "pcib_if.h" | |
- | |
-#include <dev/siba/siba_ids.h> | |
-#include <dev/siba/sibareg.h> | |
-#include <dev/siba/sibavar.h> | |
-#include <dev/siba/siba_pcibvar.h> | |
- | |
-#ifndef MIPS_MEM_RID | |
-#define MIPS_MEM_RID 0x20 | |
-#endif | |
- | |
-#define SBPCI_SLOTMAX 15 | |
- | |
-#define SBPCI_READ_4(sc, reg) \ | |
- bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, (reg)) | |
- | |
-#define SBPCI_WRITE_4(sc, reg, val) \ | |
- bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, (reg), (val)) | |
- | |
-/* | |
- * PCI Configuration space window (64MB). | |
- * contained in SBTOPCI1 window. | |
- */ | |
-#define SBPCI_CFGBASE 0x0C000000 | |
-#define SBPCI_CFGSIZE 0x01000000 | |
- | |
-/* | |
- * TODO: implement type 1 config space access (ie beyond bus 0) | |
- * we may need to tweak the windows to do this | |
- * TODO: interrupt routing. | |
- * TODO: fully implement bus allocation. | |
- * TODO: implement resource managers. | |
- * TODO: code cleanup. | |
- */ | |
- | |
-static int siba_pcib_activate_resource(device_t, device_t, int, | |
- int, struct resource *); | |
-static struct resource * | |
- siba_pcib_alloc_resource(device_t, device_t, int, int *, | |
- rman_res_t , rman_res_t, rman_res_t, u_int); | |
-static int siba_pcib_attach(device_t); | |
-static int siba_pcib_deactivate_resource(device_t, device_t, int, | |
- int, struct resource *); | |
-static int siba_pcib_maxslots(device_t); | |
-static int siba_pcib_probe(device_t); | |
-static u_int32_t | |
- siba_pcib_read_config(device_t, u_int, u_int, u_int, u_int, | |
- int); | |
-static int siba_pcib_read_ivar(device_t, device_t, int, uintptr_t *); | |
-static int siba_pcib_release_resource(device_t, device_t, int, int, | |
- struct resource *); | |
-static int siba_pcib_route_interrupt(device_t, device_t, int); | |
-static int siba_pcib_setup_intr(device_t, device_t, struct resource *, | |
- int, driver_filter_t *, driver_intr_t *, void *, void **); | |
-static int siba_pcib_teardown_intr(device_t, device_t, struct resource *, | |
- void *); | |
-static void siba_pcib_write_config(device_t, u_int, u_int, u_int, u_int, | |
- u_int32_t, int); | |
-static int siba_pcib_write_ivar(device_t, device_t, int, uintptr_t); | |
- | |
-static int | |
-siba_pcib_probe(device_t dev) | |
-{ | |
- | |
- /* TODO: support earlier cores. */ | |
- /* TODO: Check if PCI host mode is enabled in the SPROM. */ | |
- if (siba_get_vendor(dev) == SIBA_VID_BROADCOM && | |
- siba_get_device(dev) == SIBA_DEVID_PCI) { | |
- device_set_desc(dev, "SiBa-to-PCI host bridge"); | |
- return (BUS_PROBE_DEFAULT); | |
- } | |
- | |
- return (ENXIO); | |
-} | |
- | |
-//extern int rman_debug; | |
- | |
-static int | |
-siba_pcib_attach(device_t dev) | |
-{ | |
- struct siba_pcib_softc *sc = device_get_softc(dev); | |
- int rid; | |
- | |
- /* | |
- * Allocate the resources which the parent bus has already | |
- * determined for us. | |
- */ | |
- rid = MIPS_MEM_RID; /* XXX */ | |
- //rman_debug = 1; | |
- sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, | |
- RF_ACTIVE); | |
- if (sc->sc_mem == NULL) { | |
- device_printf(dev, "unable to allocate memory\n"); | |
- return (ENXIO); | |
- } | |
- | |
- sc->sc_bt = rman_get_bustag(sc->sc_mem); | |
- sc->sc_bh = rman_get_bushandle(sc->sc_mem); | |
- | |
- device_printf(dev, "bridge registers addr 0x%08x vaddr %p\n", | |
- (uint32_t)sc->sc_bh, rman_get_virtual(sc->sc_mem)); | |
- | |
- SBPCI_WRITE_4(sc, 0x0000, 0x05); | |
- SBPCI_WRITE_4(sc, 0x0000, 0x0D); | |
- DELAY(150); | |
- SBPCI_WRITE_4(sc, 0x0000, 0x0F); | |
- SBPCI_WRITE_4(sc, 0x0010, 0x01); | |
- DELAY(1); | |
- | |
- bus_space_handle_t sc_cfg_hand; | |
- int error; | |
- | |
- /* | |
- * XXX this doesn't actually do anything on mips; however... should | |
- * we not be mapping to KSEG1? we need to wire down the range. | |
- */ | |
- error = bus_space_map(sc->sc_bt, SBPCI_CFGBASE, SBPCI_CFGSIZE, | |
- 0, &sc_cfg_hand); | |
- if (error) { | |
- device_printf(dev, "cannot map PCI configuration space\n"); | |
- return (ENXIO); | |
- } | |
- device_printf(dev, "mapped pci config space at 0x%08x\n", | |
- (uint32_t)sc_cfg_hand); | |
- | |
- /* | |
- * Setup configuration, io, and dma space windows. | |
- * XXX we need to be able to do type 1 too. | |
- * we probably don't need to be able to do i/o cycles. | |
- */ | |
- | |
- /* I/O read/write window */ | |
- SBPCI_WRITE_4(sc, SIBA_PCICORE_SBTOPCI0, 1); | |
- /* type 0 configuration only */ | |
- SBPCI_WRITE_4(sc, SIBA_PCICORE_SBTOPCI1, 2); | |
- SBPCI_WRITE_4(sc, SIBA_PCICORE_SBTOPCI2, 1 << 30); /* memory only */ | |
- DELAY(500); | |
- | |
- /* XXX resource managers */ | |
- | |
- device_add_child(dev, "pci", -1); | |
- return (bus_generic_attach(dev)); | |
-} | |
- | |
-/* bus functions */ | |
- | |
-static int | |
-siba_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) | |
-{ | |
- struct siba_pcib_softc *sc; | |
- | |
- sc = device_get_softc(dev); | |
- switch (which) { | |
- case PCIB_IVAR_BUS: | |
- *result = sc->sc_bus; | |
- return (0); | |
- } | |
- | |
- return (ENOENT); | |
-} | |
- | |
-static int | |
-siba_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value) | |
-{ | |
- struct siba_pcib_softc *sc; | |
- | |
- sc = device_get_softc(dev); | |
- switch (which) { | |
- case PCIB_IVAR_BUS: | |
- sc->sc_bus = value; | |
- return (0); | |
- } | |
- | |
- return (ENOENT); | |
-} | |
- | |
-static int | |
-siba_pcib_setup_intr(device_t dev, device_t child, struct resource *ires, | |
- int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, | |
- void **cookiep) | |
-{ | |
- | |
- return (BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, | |
- filt, intr, arg, cookiep)); | |
-} | |
- | |
-static int | |
-siba_pcib_teardown_intr(device_t dev, device_t child, struct resource *vec, | |
- void *cookie) | |
-{ | |
- | |
- return (BUS_TEARDOWN_INTR(device_get_parent(dev), child, vec, cookie)); | |
-} | |
- | |
-static struct resource * | |
-siba_pcib_alloc_resource(device_t bus, device_t child, int type, int *rid, | |
- rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) | |
-{ | |
-#if 1 | |
- | |
- //device_printf(bus, "%s: not yet implemented\n", __func__); | |
- return (NULL); | |
-#else | |
- bus_space_tag_t tag; | |
- struct siba_pcib_softc *sc = device_get_softc(bus); | |
- struct rman *rmanp; | |
- struct resource *rv; | |
- | |
- tag = 0; | |
- rv = NULL; | |
- switch (type) { | |
- case SYS_RES_IRQ: | |
- rmanp = &sc->sc_irq_rman; | |
- break; | |
- | |
- case SYS_RES_MEMORY: | |
- rmanp = &sc->sc_mem_rman; | |
- tag = &sc->sc_pci_memt; | |
- break; | |
- | |
- default: | |
- return (rv); | |
- } | |
- | |
- rv = rman_reserve_resource(rmanp, start, end, count, flags, child); | |
- if (rv != NULL) { | |
- rman_set_rid(rv, *rid); | |
- if (type == SYS_RES_MEMORY) { | |
-#if 0 | |
- rman_set_bustag(rv, tag); | |
- rman_set_bushandle(rv, rman_get_bushandle(sc->sc_mem) + | |
- (rman_get_start(rv) - IXP425_PCI_MEM_HWBASE)); | |
-#endif | |
- } | |
- } | |
- | |
- return (rv); | |
-#endif | |
-} | |
- | |
-static int | |
-siba_pcib_activate_resource(device_t bus, device_t child, int type, int rid, | |
- struct resource *r) | |
-{ | |
- | |
- device_printf(bus, "%s: not yet implemented\n", __func__); | |
- device_printf(bus, "%s called activate_resource\n", | |
- device_get_nameunit(child)); | |
- return (ENXIO); | |
-} | |
- | |
-static int | |
-siba_pcib_deactivate_resource(device_t bus, device_t child, int type, int rid, | |
- struct resource *r) | |
-{ | |
- | |
- device_printf(bus, "%s: not yet implemented\n", __func__); | |
- device_printf(bus, "%s called deactivate_resource\n", | |
- device_get_nameunit(child)); | |
- return (ENXIO); | |
-} | |
- | |
-static int | |
-siba_pcib_release_resource(device_t bus, device_t child, int type, int rid, | |
- struct resource *r) | |
-{ | |
- | |
- device_printf(bus, "%s: not yet implemented\n", __func__); | |
- device_printf(bus, "%s called release_resource\n", | |
- device_get_nameunit(child)); | |
- return (ENXIO); | |
-} | |
- | |
-/* pcib interface functions */ | |
- | |
-static int | |
-siba_pcib_maxslots(device_t dev) | |
-{ | |
- | |
- return (SBPCI_SLOTMAX); | |
-} | |
- | |
-/* | |
- * This needs hacking and fixery. It is currently broke and hangs. | |
- * Debugging it will be tricky; there seems to be no way to enable | |
- * a target abort which would cause a nice target abort. | |
- * Look at linux again? | |
- */ | |
-static u_int32_t | |
-siba_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, | |
- u_int reg, int bytes) | |
-{ | |
- struct siba_pcib_softc *sc = device_get_softc(dev); | |
- bus_addr_t cfgaddr; | |
- uint32_t cfgtag; | |
- uint32_t val; | |
- | |
- /* XXX anything higher than slot 2 currently seems to hang the bus. | |
- * not sure why this is; look at linux again | |
- */ | |
- if (bus != 0 || slot > 2) { | |
- printf("%s: bad b/s/f %d/%d/%d\n", __func__, bus, slot, func); | |
- return 0xffffffff; // XXX | |
- } | |
- | |
- device_printf(dev, "requested %d bytes from b/s/f %d/%d/%d reg %d\n", | |
- bytes, bus, slot, func, reg); | |
- | |
- /* | |
- * The configuration tag on the broadcom is weird. | |
- */ | |
- SBPCI_WRITE_4(sc, SIBA_PCICORE_SBTOPCI1, 2); /* XXX again??? */ | |
- cfgtag = ((1 << slot) << 16) | (func << 8); | |
- cfgaddr = SBPCI_CFGBASE | cfgtag | (reg & ~3); | |
- | |
- /* cfg space i/o is always 32 bits on this bridge */ | |
- printf("reading 4 bytes from %08x\n", cfgaddr); | |
- val = *(volatile uint32_t *)MIPS_PHYS_TO_KSEG1(cfgaddr); /* XXX MIPS */ | |
- | |
- val = bswap32(val); /* XXX seems to be needed for now */ | |
- | |
- /* swizzle and return what was asked for */ | |
- val &= 0xffffffff >> ((4 - bytes) * 8); | |
- | |
- return (val); | |
-} | |
- | |
-static void | |
-siba_pcib_write_config(device_t dev, u_int bus, u_int slot, | |
- u_int func, u_int reg, u_int32_t val, int bytes) | |
-{ | |
- | |
- /* write to pci configuration space */ | |
- //device_printf(dev, "%s: not yet implemented\n", __func__); | |
-} | |
- | |
-static int | |
-siba_pcib_route_interrupt(device_t bridge, device_t device, int pin) | |
-{ | |
- | |
- //device_printf(bridge, "%s: not yet implemented\n", __func__); | |
- return (-1); | |
-} | |
- | |
-static device_method_t siba_pcib_methods[] = { | |
- /* Device interface */ | |
- DEVMETHOD(device_attach, siba_pcib_attach), | |
- DEVMETHOD(device_probe, siba_pcib_probe), | |
- | |
- /* Bus interface */ | |
- DEVMETHOD(bus_read_ivar, siba_pcib_read_ivar), | |
- DEVMETHOD(bus_write_ivar, siba_pcib_write_ivar), | |
- DEVMETHOD(bus_setup_intr, siba_pcib_setup_intr), | |
- DEVMETHOD(bus_teardown_intr, siba_pcib_teardown_intr), | |
- DEVMETHOD(bus_alloc_resource, siba_pcib_alloc_resource), | |
- DEVMETHOD(bus_activate_resource, siba_pcib_activate_resource), | |
- DEVMETHOD(bus_deactivate_resource, siba_pcib_deactivate_resource), | |
- DEVMETHOD(bus_release_resource, siba_pcib_release_resource), | |
- | |
- /* pcib interface */ | |
- DEVMETHOD(pcib_maxslots, siba_pcib_maxslots), | |
- DEVMETHOD(pcib_read_config, siba_pcib_read_config), | |
- DEVMETHOD(pcib_write_config, siba_pcib_write_config), | |
- DEVMETHOD(pcib_route_interrupt, siba_pcib_route_interrupt), | |
- | |
- DEVMETHOD_END | |
-}; | |
- | |
-static driver_t siba_pcib_driver = { | |
- "pcib", | |
- siba_pcib_methods, | |
- sizeof(struct siba_softc), | |
-}; | |
-static devclass_t siba_pcib_devclass; | |
- | |
-DRIVER_MODULE(siba_pcib, siba, siba_pcib_driver, siba_pcib_devclass, 0, 0); | |
diff --git a/sys/dev/siba/siba_pcibvar.h b/sys/dev/siba/siba_pcibvar.h | |
deleted file mode 100644 | |
index 6de72ff..0000000 | |
--- a/sys/dev/siba/siba_pcibvar.h | |
+++ /dev/null | |
@@ -1,52 +0,0 @@ | |
-/*- | |
- * Copyright (c) 2007 Bruce M. Simpson. | |
- * 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. | |
- * | |
- * $FreeBSD$ | |
- */ | |
- | |
-#ifndef _SIBA_PCIBVAR_H_ | |
-#define _SIBA_PCIBVAR_H_ | |
- | |
-#include <sys/rman.h> | |
- | |
-struct siba_pcib_softc { | |
- device_t sc_dev; /* Device ID */ | |
- u_int sc_bus; /* PCI bus number */ | |
- struct resource *sc_mem; /* siba memory window */ | |
- struct resource *sc_csr; /* config space */ | |
- | |
- bus_space_tag_t sc_bt; | |
- bus_space_handle_t sc_bh; | |
-#if 0 | |
- bus_addr_t sc_maddr; | |
- bus_size_t sc_msize; | |
- | |
- struct bus_space sc_pci_memt; | |
- struct bus_space sc_pci_iot; | |
- bus_dma_tag_t sc_dmat; | |
-#endif | |
-}; | |
- | |
-#endif /* _SIBA_PCIBVAR_H_ */ | |
diff --git a/sys/mips/conf/SENTRY5 b/sys/mips/conf/SENTRY5 | |
index dadf790..36e06ba 100644 | |
--- a/sys/mips/conf/SENTRY5 | |
+++ b/sys/mips/conf/SENTRY5 | |
@@ -57,8 +57,12 @@ options INVARIANT_SUPPORT | |
#options BUS_DEBUG | |
#makeoptions BUS_DEBUG | |
-device siba # Sonics SiliconBackplane | |
-device pci # siba_pcib | |
+device bhnd # Broadcom Backplane | |
+device siba # Broadcom Sonics Backplane Support | |
+device siba_nexus # Sonics Nexus | |
+ | |
+device bhnd_pcib # Broadcom Host-PCI bridge | |
+device pci | |
# device bfe # XXX will build both pci and siba | |
# device miibus # attachments | |
diff --git a/sys/modules/Makefile b/sys/modules/Makefile | |
index e2c2205..1032a21 100644 | |
--- a/sys/modules/Makefile | |
+++ b/sys/modules/Makefile | |
@@ -51,6 +51,7 @@ SUBDIR= \ | |
${_bce} \ | |
bfe \ | |
bge \ | |
+ bhnd \ | |
${_bxe} \ | |
${_bios} \ | |
${_bktr} \ | |
@@ -327,7 +328,6 @@ SUBDIR= \ | |
${_sfxge} \ | |
sge \ | |
${_si} \ | |
- siba_bwn \ | |
siftr \ | |
siis \ | |
sis \ | |
diff --git a/sys/modules/bhnd/bcma_bhndb/Makefile b/sys/modules/bhnd/bcma_bhndb/Makefile | |
index 5896703..372a7ed 100644 | |
--- a/sys/modules/bhnd/bcma_bhndb/Makefile | |
+++ b/sys/modules/bhnd/bcma_bhndb/Makefile | |
@@ -5,7 +5,7 @@ | |
KMOD= bcma_bhndb | |
SRCS= bcma_bhndb.c | |
-SRCS+= bhnd_bus_if.h bhndb_if.h | |
+SRCS+= bhnd_bus_if.h bhndb_bus_if.h bhndb_if.h | |
SRCS+= device_if.h bus_if.h | |
.include <bsd.kmod.mk> | |
diff --git a/sys/modules/bhnd/siba_bhndb/Makefile b/sys/modules/bhnd/siba_bhndb/Makefile | |
index 2dbef19..ba46a7f 100644 | |
--- a/sys/modules/bhnd/siba_bhndb/Makefile | |
+++ b/sys/modules/bhnd/siba_bhndb/Makefile | |
@@ -5,7 +5,7 @@ | |
KMOD= siba_bhndb | |
SRCS= siba_bhndb.c | |
-SRCS+= bhnd_bus_if.h bhndb_if.h | |
+SRCS+= bhnd_bus_if.h bhndb_bus_if.h bhndb_if.h | |
SRCS+= device_if.h bus_if.h | |
.include <bsd.kmod.mk> | |
diff --git a/sys/modules/bwn/Makefile b/sys/modules/bwn/Makefile | |
index e04ab0b..7766575 100644 | |
--- a/sys/modules/bwn/Makefile | |
+++ b/sys/modules/bwn/Makefile | |
@@ -3,8 +3,10 @@ | |
.PATH: ${.CURDIR}/../../dev/bwn | |
KMOD= if_bwn | |
-SRCS= if_bwn.c if_bwnreg.h if_bwnvar.h | |
-SRCS+= device_if.h bus_if.h pci_if.h | |
+SRCS= if_bwn.c if_bwnreg.h if_bwnvar.h \ | |
+ bwn_mac.c if_bwn_pci.c | |
+SRCS+= device_if.h bus_if.h pci_if.h \ | |
+ bhndb_bus_if.h | |
.include <bsd.kmod.mk> | |
diff --git a/sys/modules/siba_bwn/Makefile b/sys/modules/siba_bwn/Makefile | |
deleted file mode 100644 | |
index 433d37f..0000000 | |
--- a/sys/modules/siba_bwn/Makefile | |
+++ /dev/null | |
@@ -1,9 +0,0 @@ | |
-# $FreeBSD$ | |
- | |
-.PATH: ${.CURDIR}/../../dev/siba | |
- | |
-KMOD= siba_bwn | |
-SRCS= siba_core.c siba_bwn.c sibareg.h sibavar.h | |
-SRCS+= device_if.h bus_if.h pci_if.h | |
- | |
-.include <bsd.kmod.mk> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment