mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 0/3] introduce board-driver support
@ 2020-07-15 10:10 Oleksij Rempel
  2020-07-15 10:10 ` [PATCH v2 1/3] of: base: register DT root as device Oleksij Rempel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Oleksij Rempel @ 2020-07-15 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel, david

changes v2:
- move root device registration to the of_probe()
- port one board as example
- fix issue with devinfo

Oleksij Rempel (3):
  of: base: register DT root as device
  ARM: embest-riotboard: port board file to the driver model
  devinfo: do not dump the device node for the root node

 arch/arm/boards/embest-riotboard/board.c | 18 +++++++++++++-----
 commands/devinfo.c                       |  2 +-
 drivers/of/base.c                        |  5 +++++
 3 files changed, 19 insertions(+), 6 deletions(-)

-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] of: base: register DT root as device
  2020-07-15 10:10 [PATCH v2 0/3] introduce board-driver support Oleksij Rempel
@ 2020-07-15 10:10 ` Oleksij Rempel
  2020-07-15 10:10 ` [PATCH v2 2/3] ARM: embest-riotboard: port board file to the driver model Oleksij Rempel
  2020-07-15 10:10 ` [PATCH v2 3/3] devinfo: do not dump the device node for the root node Oleksij Rempel
  2 siblings, 0 replies; 6+ messages in thread
From: Oleksij Rempel @ 2020-07-15 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel, david

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 devicetree 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.of
...

With devinfo, you'll be able to get some board specific information,
if this is implemented:
barebox@Protonic PRTI6Q board:/ devinfo machine.of
Driver: board-protonic-imx6
Bus: platform
Parameters:
  boardid: 0 (type: uint32)
  boardrev: 1 (type: uint32)

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/of/base.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 4c633bcd49..c48bf7a7fb 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2133,6 +2133,7 @@ static void of_probe_memory(void)
 int of_probe(void)
 {
 	struct device_node *firmware;
+	struct device_d *dev;
 
 	if(!root_node)
 		return -ENODEV;
@@ -2149,6 +2150,10 @@ int of_probe(void)
 	if (firmware)
 		of_platform_populate(firmware, NULL, NULL);
 
+	dev = of_platform_device_create(root_node, NULL);
+	if (dev)
+		dev_set_name(dev, "%s.of", "machine");
+
 	of_clk_init(root_node, NULL);
 	of_platform_populate(root_node, of_default_bus_match_table, NULL);
 
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] ARM: embest-riotboard: port board file to the driver model
  2020-07-15 10:10 [PATCH v2 0/3] introduce board-driver support Oleksij Rempel
  2020-07-15 10:10 ` [PATCH v2 1/3] of: base: register DT root as device Oleksij Rempel
@ 2020-07-15 10:10 ` Oleksij Rempel
  2020-07-15 10:10 ` [PATCH v2 3/3] devinfo: do not dump the device node for the root node Oleksij Rempel
  2 siblings, 0 replies; 6+ messages in thread
From: Oleksij Rempel @ 2020-07-15 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel, david

This patch can be used as example for the new board-driver
functionality.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 arch/arm/boards/embest-riotboard/board.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boards/embest-riotboard/board.c b/arch/arm/boards/embest-riotboard/board.c
index eb956f1f50..23eeec075d 100644
--- a/arch/arm/boards/embest-riotboard/board.c
+++ b/arch/arm/boards/embest-riotboard/board.c
@@ -62,11 +62,8 @@ static int ar8035_phy_fixup(struct phy_device *dev)
 	return 0;
 }
 
-static int riotboard_device_init(void)
+static int riotboard_probe(struct device_d *dev)
 {
-	if (!of_machine_is_compatible("riot,imx6s-riotboard"))
-		return 0;
-
 	phy_register_fixup_for_uid(0x004dd072, 0xffffffef, ar8035_phy_fixup);
 
 	imx6_bbu_internal_mmc_register_handler("emmc", "/dev/mmc3.barebox",
@@ -76,4 +73,15 @@ static int riotboard_device_init(void)
 
 	return 0;
 }
-device_initcall(riotboard_device_init);
+
+static const struct of_device_id riotboard_of_match[] = {
+	{ .compatible = "riot,imx6s-riotboard" },
+	{},
+};
+
+static struct driver_d riotboard_driver = {
+	.name = "board-embest-riot",
+	.probe = riotboard_probe,
+	.of_compatible = DRV_OF_COMPAT(riotboard_of_match),
+};
+device_platform_driver(riotboard_driver);
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] devinfo: do not dump the device node for the root node
  2020-07-15 10:10 [PATCH v2 0/3] introduce board-driver support Oleksij Rempel
  2020-07-15 10:10 ` [PATCH v2 1/3] of: base: register DT root as device Oleksij Rempel
  2020-07-15 10:10 ` [PATCH v2 2/3] ARM: embest-riotboard: port board file to the driver model Oleksij Rempel
@ 2020-07-15 10:10 ` Oleksij Rempel
  2020-07-15 12:35   ` Lucas Stach
  2 siblings, 1 reply; 6+ messages in thread
From: Oleksij Rempel @ 2020-07-15 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Oleksij Rempel, david

In case the device is a root node, then do not dump it. Otherwise it will be a
mess.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 commands/devinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands/devinfo.c b/commands/devinfo.c
index 81956b1cc0..018a7c4167 100644
--- a/commands/devinfo.c
+++ b/commands/devinfo.c
@@ -99,7 +99,7 @@ static int do_devinfo(int argc, char *argv[])
 			printf("\n");
 		}
 #ifdef CONFIG_OFDEVICE
-		if (dev->device_node) {
+		if (dev->device_node && dev->device_node != of_get_root_node()) {
 			printf("Device node: %s\n", dev->device_node->full_name);
 			of_print_nodes(dev->device_node, 0);
 		}
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] devinfo: do not dump the device node for the root node
  2020-07-15 10:10 ` [PATCH v2 3/3] devinfo: do not dump the device node for the root node Oleksij Rempel
@ 2020-07-15 12:35   ` Lucas Stach
  2020-07-15 13:57     ` Ahmad Fatoum
  0 siblings, 1 reply; 6+ messages in thread
From: Lucas Stach @ 2020-07-15 12:35 UTC (permalink / raw)
  To: Oleksij Rempel, barebox; +Cc: david

Am Mittwoch, den 15.07.2020, 12:10 +0200 schrieb Oleksij Rempel:
> In case the device is a root node, then do not dump it. Otherwise it will be a
> mess.

This is waaay too unspecific for a commit message. What happens without
this patch and how does this patch fix it?

Regards,
Lucas

> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  commands/devinfo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/commands/devinfo.c b/commands/devinfo.c
> index 81956b1cc0..018a7c4167 100644
> --- a/commands/devinfo.c
> +++ b/commands/devinfo.c
> @@ -99,7 +99,7 @@ static int do_devinfo(int argc, char *argv[])
>  			printf("\n");
>  		}
>  #ifdef CONFIG_OFDEVICE
> -		if (dev->device_node) {
> +		if (dev->device_node && dev->device_node != of_get_root_node()) {
>  			printf("Device node: %s\n", dev->device_node->full_name);
>  			of_print_nodes(dev->device_node, 0);
>  		}


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 3/3] devinfo: do not dump the device node for the root node
  2020-07-15 12:35   ` Lucas Stach
@ 2020-07-15 13:57     ` Ahmad Fatoum
  0 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2020-07-15 13:57 UTC (permalink / raw)
  To: Lucas Stach, Oleksij Rempel, barebox; +Cc: david


On 7/15/20 2:35 PM, Lucas Stach wrote:
> Am Mittwoch, den 15.07.2020, 12:10 +0200 schrieb Oleksij Rempel:
>> In case the device is a root node, then do not dump it. Otherwise it will be a
>> mess.
> 
> This is waaay too unspecific for a commit message. What happens without
> this patch and how does this patch fix it?

While at it, you could move this patch here to the series start, so bisection can't
end on a patch with the messy devinfo output.

> 
> Regards,
> Lucas
> 
>> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
>> ---
>>  commands/devinfo.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/commands/devinfo.c b/commands/devinfo.c
>> index 81956b1cc0..018a7c4167 100644
>> --- a/commands/devinfo.c
>> +++ b/commands/devinfo.c
>> @@ -99,7 +99,7 @@ static int do_devinfo(int argc, char *argv[])
>>  			printf("\n");
>>  		}
>>  #ifdef CONFIG_OFDEVICE
>> -		if (dev->device_node) {
>> +		if (dev->device_node && dev->device_node != of_get_root_node()) {
>>  			printf("Device node: %s\n", dev->device_node->full_name);
>>  			of_print_nodes(dev->device_node, 0);
>>  		}
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-15 13:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 10:10 [PATCH v2 0/3] introduce board-driver support Oleksij Rempel
2020-07-15 10:10 ` [PATCH v2 1/3] of: base: register DT root as device Oleksij Rempel
2020-07-15 10:10 ` [PATCH v2 2/3] ARM: embest-riotboard: port board file to the driver model Oleksij Rempel
2020-07-15 10:10 ` [PATCH v2 3/3] devinfo: do not dump the device node for the root node Oleksij Rempel
2020-07-15 12:35   ` Lucas Stach
2020-07-15 13:57     ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox