diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-08-18 07:19:48 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-09-01 10:40:49 +0200 |
commit | 0af90c0b0629b0442b6ccbf73d1d3538e5df019b (patch) | |
tree | ae2523ed8e1c8209cf9975e2f9a42bfa5767f281 /drivers | |
parent | a2d9b1d42d7e5ff060bc42adb7ae0301f78e09f0 (diff) | |
download | barebox-0af90c0b0629b0442b6ccbf73d1d3538e5df019b.tar.gz barebox-0af90c0b0629b0442b6ccbf73d1d3538e5df019b.tar.xz |
driver: featctrl: fixup kernel device tree
barebox not proving feature gated devices is one aspect of the feature
controller framework. The more important one is that Linux doesn't probe
them as these tend to be units like VPUs and GPUs or extra CPU cores, which
barebox usually has no use for anyway. Add a fixup that runs for every
DT and evaluates barebox,feature-gates properties in the barebox device
tree and fixes up the result into the kernel device tree using
reproducible names to match nodes between the two.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220818051955.2088238-4-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/base/featctrl.c | 40 | ||||
-rw-r--r-- | drivers/of/Kconfig | 12 |
2 files changed, 52 insertions, 0 deletions
diff --git a/drivers/base/featctrl.c b/drivers/base/featctrl.c index a5d06323c2..abe21698ed 100644 --- a/drivers/base/featctrl.c +++ b/drivers/base/featctrl.c @@ -118,3 +118,43 @@ int of_feature_controller_check(struct device_node *np) return err ?: FEATCTRL_GATED; } EXPORT_SYMBOL_GPL(of_feature_controller_check); + +static int of_featctrl_fixup(struct device_node *root, void *context) +{ + struct device_node *srcnp, *dstnp; + int err = 0; + + for_each_node_with_property(srcnp, "barebox,feature-gates") { + int ret; + + ret = of_feature_controller_check(srcnp); + if (ret < 0) + err = ret; + if (ret != FEATCTRL_GATED) + continue; + + dstnp = of_get_node_by_reproducible_name(root, srcnp); + if (!dstnp) { + pr_debug("gated node %s not in fixup DT\n", + srcnp->full_name); + continue; + } + + pr_debug("fixing up gating of node %s\n", dstnp->full_name); + /* Convention is deleting non-existing CPUs, not disable them. */ + if (of_property_match_string(srcnp, "device_type", "cpu") >= 0) + of_delete_node(dstnp); + else + of_device_disable(dstnp); + } + + return err; +} + +static __maybe_unused int of_featctrl_fixup_register(void) +{ + return of_register_fixup(of_featctrl_fixup, NULL); +} +#ifdef CONFIG_FEATURE_CONTROLLER_FIXUP +device_initcall(of_featctrl_fixup_register); +#endif diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index f3d2cc00cc..7283331ba9 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -16,6 +16,18 @@ config OFDEVICE select DTC bool "Enable probing of devices from the devicetree" +config FEATURE_CONTROLLER_FIXUP + bool "Fix up DT nodes gated by feature controller" + depends on FEATURE_CONTROLLER + default y + help + When specified, barebox feature controller drivers are consulted + prior to probing nodes to detect whether the device may not + be available (e.g. because support is fused out). + This option additionally fixes up the kernel device tree, + so it doesn't attempt probing these devices either. + If unsure, say y. + config OF_ADDRESS_PCI bool |