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/base | |
parent | a2d9b1d42d7e5ff060bc42adb7ae0301f78e09f0 (diff) | |
download | barebox-0af90c0b0629b0442b6ccbf73d1d3538e5df019b.tar.gz |
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/base')
-rw-r--r-- | drivers/base/featctrl.c | 40 |
1 files changed, 40 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 |