summaryrefslogtreecommitdiffstats
path: root/drivers/of
diff options
context:
space:
mode:
authorOleksij Rempel <o.rempel@pengutronix.de>2020-08-20 09:34:43 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-08-24 08:48:36 +0200
commit5e1fc532538ad1cec643eb61b8f248dd98a54efc (patch)
treeb28a68d5d6ae29968db0ff30a56b0e36971778dc /drivers/of
parent90566f5c77e06de1a031c2b30a7472362ff9a75e (diff)
downloadbarebox-5e1fc532538ad1cec643eb61b8f248dd98a54efc.tar.gz
barebox-5e1fc532538ad1cec643eb61b8f248dd98a54efc.tar.xz
of: base: register DT root as device
A usual board file contains at least one of_machine_is_compatible(). Some of the have a rather long list with complicated version logic. To avoid own implementation for driver management, register the root node of device tree as platform device. So, the main platform bus can attach proper board driver. After this patch a typical board.c file can reuse existing driver infrastructure. After this patch, you will be able to see all registered board drivers with drvinfo as fallow: ... board-embest-riot board-protonic-imx6 machine ... With devinfo, you'll be able to get some board specific information, if this is implemented: barebox@Protonic PRTI6Q board:/ devinfo machine Driver: board-protonic-imx6 Bus: platform Parameters: boardid: 0 (type: uint32) boardrev: 1 (type: uint32) Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/base.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 4c633bcd49..0a2632f963 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2130,6 +2130,21 @@ static void of_probe_memory(void)
}
}
+static void of_platform_device_create_root(struct device_node *np)
+{
+ struct device_d *dev;
+ int ret;
+
+ dev = xzalloc(sizeof(*dev));
+ dev->id = DEVICE_ID_SINGLE;
+ dev->device_node = np;
+ dev_set_name(dev, "machine");
+
+ ret = platform_device_register(dev);
+ if (ret)
+ free(dev);
+}
+
int of_probe(void)
{
struct device_node *firmware;
@@ -2149,6 +2164,8 @@ int of_probe(void)
if (firmware)
of_platform_populate(firmware, NULL, NULL);
+ of_platform_device_create_root(root_node);
+
of_clk_init(root_node, NULL);
of_platform_populate(root_node, of_default_bus_match_table, NULL);