git: 53ad4781f550 - stable/13 - ofwbus: remove arm64 ifdefs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 17 Apr 2023 17:04:01 UTC
The branch stable/13 has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=53ad4781f5503b55db4c86dca7cade7c9cd9c991
commit 53ad4781f5503b55db4c86dca7cade7c9cd9c991
Author: Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-02-13 17:43:25 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-04-17 16:54:04 +0000
ofwbus: remove arm64 ifdefs
Rather than using the DEVICE_IDENTIFY method, let's have other
ofwbus-using platforms add ofwbus0 explicitly in nexus, like arm64. This
gives them the same flexibility, e.g. if riscv starts supporting ACPI,
and cleans up the #ifdefs.
We were doing this already on riscv, but adjust the 'order' parameters.
Reviewed by: andrew, jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38492
(cherry picked from commit 53d5e65eead0f713c5e256018d46edbec0a96c11)
---
sys/arm/arm/nexus.c | 5 ++++-
sys/dev/ofw/ofwbus.c | 25 ++-----------------------
sys/powerpc/powerpc/nexus.c | 4 ++++
sys/riscv/riscv/nexus.c | 10 +++++++---
4 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c
index 3991ec91ed0d..c6c511b85fe3 100644
--- a/sys/arm/arm/nexus.c
+++ b/sys/arm/arm/nexus.c
@@ -182,8 +182,11 @@ nexus_attach(device_t dev)
if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, ~0))
panic("nexus_attach irq_rman");
+ /* First, add ofwbus0. */
+ device_add_child(dev, "ofwbus", 0);
+
/*
- * First, deal with the children we know about already
+ * Next, deal with the children we know about already.
*/
bus_generic_probe(dev);
bus_generic_attach(dev);
diff --git a/sys/dev/ofw/ofwbus.c b/sys/dev/ofw/ofwbus.c
index 4432f1704392..7660be8cec39 100644
--- a/sys/dev/ofw/ofwbus.c
+++ b/sys/dev/ofw/ofwbus.c
@@ -62,12 +62,10 @@ __FBSDID("$FreeBSD$");
* The ofwbus (which is a pseudo-bus actually) iterates over the nodes that
* hang from the Open Firmware root node and adds them as devices to this bus
* (except some special nodes which are excluded) so that drivers can be
- * attached to them.
+ * attached to them. There should be only one ofwbus in the system, added
+ * directly as a child of nexus0.
*/
-#ifndef __aarch64__
-static device_identify_t ofwbus_identify;
-#endif
static device_probe_t ofwbus_probe;
static device_attach_t ofwbus_attach;
static bus_alloc_resource_t ofwbus_alloc_resource;
@@ -75,9 +73,6 @@ static bus_release_resource_t ofwbus_release_resource;
static device_method_t ofwbus_methods[] = {
/* Device interface */
-#ifndef __aarch64__
- DEVMETHOD(device_identify, ofwbus_identify),
-#endif
DEVMETHOD(device_probe, ofwbus_probe),
DEVMETHOD(device_attach, ofwbus_attach),
@@ -96,28 +91,12 @@ EARLY_DRIVER_MODULE(ofwbus, nexus, ofwbus_driver, ofwbus_devclass, 0, 0,
BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
MODULE_VERSION(ofwbus, 1);
-#ifndef __aarch64__
-static void
-ofwbus_identify(driver_t *driver, device_t parent)
-{
-
- /* Check if Open Firmware has been instantiated */
- if (OF_peer(0) == 0)
- return;
-
- if (device_find_child(parent, "ofwbus", -1) == NULL)
- BUS_ADD_CHILD(parent, 0, "ofwbus", -1);
-}
-#endif
-
static int
ofwbus_probe(device_t dev)
{
-#ifdef __aarch64__
if (OF_peer(0) == 0)
return (ENXIO);
-#endif
device_set_desc(dev, "Open Firmware Device Tree");
return (BUS_PROBE_NOWILDCARD);
diff --git a/sys/powerpc/powerpc/nexus.c b/sys/powerpc/powerpc/nexus.c
index 6edc7f258d39..78bcf6363d60 100644
--- a/sys/powerpc/powerpc/nexus.c
+++ b/sys/powerpc/powerpc/nexus.c
@@ -146,6 +146,10 @@ nexus_attach(device_t dev)
rman_manage_region(&mem_rman, 0, BUS_SPACE_MAXADDR) != 0)
panic("%s: failed to set up rmans.", __func__);
+ /* Add ofwbus0. */
+ device_add_child(dev, "ofwbus", 0);
+
+ /* Now, probe children. */
bus_generic_probe(dev);
bus_generic_attach(dev);
diff --git a/sys/riscv/riscv/nexus.c b/sys/riscv/riscv/nexus.c
index 9cafb90fd34a..0333c851af2c 100644
--- a/sys/riscv/riscv/nexus.c
+++ b/sys/riscv/riscv/nexus.c
@@ -165,9 +165,13 @@ nexus_attach(device_t dev)
if (rman_init(&irq_rman) || rman_manage_region(&irq_rman, 0, ~0))
panic("nexus_attach irq_rman");
- nexus_add_child(dev, 8, "timer", 0);
- nexus_add_child(dev, 9, "rcons", 0);
- nexus_add_child(dev, 10, "ofwbus", 0);
+ /*
+ * Add direct children of nexus. Devices will be probed and attached
+ * through ofwbus0.
+ */
+ nexus_add_child(dev, 0, "timer", 0);
+ nexus_add_child(dev, 1, "rcons", 0);
+ nexus_add_child(dev, 2, "ofwbus", 0);
bus_generic_probe(dev);
bus_generic_attach(dev);