common: oftree: Add fuction to register set status fixup
PATCH v2 1/3 common: oftree: Add fuction to register set status fixup
Added a function to register a fixup to enable or disable device tree nodes.
--- common/oftree.c | 36 ++++++++++++++++++++++++++++++++++++ include/of.h | 1 + 2 files changed, 37 insertions(+)
common/oftree.c +36 -0
@@ -139,6 +139,42 @@ static int of_register_bootargs_fixup(void) }late_initcall (of_register_bootargs_fixup); +struct of_fixup_status_data { +char *node; +bool status; +}; + +static int of_fixup_status (struct device_node *root,void *context) +{ +struct of_fixup_status_data *data = context; +struct device_node *node; + + node =of_find_node_by_path_or_alias (root, data->node); +if (!node) +return -ENODEV ; + +if (data->status) +return of_device_enable (node); +else +return of_device_disable (node); +} + +/** +* of_register_set_status_fixup - register fix up to set status of nodes +* Register a fixup to enable or disable a node in the devicet tree by +* passing the path or alias. +*/ +int of_register_set_status_fixup (char *node,bool status) +{ +struct of_fixup_status_data *data; + + data =xzalloc (sizeof (*data)); + data->node = node; + data->status = status; + +return of_register_fixup (of_fixup_status, (void *)data); +} +struct of_fixup {int (*fixup)(struct device_node *,void *);void *context;
include/of.h +1 -0
@@ -249,6 +249,7 @@ int of_find_path(struct device_node *node, const char *propname, char **outpath,int of_find_path_by_node (struct device_node *node,char **outpath,unsigned flags);int of_register_fixup (int (*fixup)(struct device_node *,void *),void *context);int of_unregister_fixup (int (*fixup)(struct device_node *,void *),void *context); +int of_register_set_status_fixup (char *node,bool status);struct device_node *of_find_node_by_alias (struct device_node *root,const char *alias); struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/3 commands: Add of_fixup_status
of_fixup_status enables or disables the status property of a given node with a device tree fixup.
--- commands/Kconfig | 16 ++++++++++ commands/Makefile | 1 + commands/of_fixup_status.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 commands/of_fixup_status.c
commands/Kconfig +16 -0
@@ -2114,6 +2114,22 @@ config CMD_OF_DISPLAY_TIMINGS -s path select display-timings and register oftree fixup -f dtb work on dtb. Has no effect on -s option +config CMD_OF_FIXUP_STATUS + tristate + select OFTREE + prompt "of_fixup_status" + help + Register a fixup to enable or disable node + + Usage: of_fixup_node [-d] path + + Options: + -d disable node + path Node path or alias + + Register a fixup to enable or disable a device tree node. + Nodes are enabled on default. Disabled with -d. + config CMD_OFTREE tristate select OFTREE
commands/Makefile +1 -0
@@ -78,6 +78,7 @@ obj-$(CONFIG_CMD_OF_PROPERTY) += of_property.o obj-$(CONFIG_CMD_OF_NODE) += of_node.o obj-$(CONFIG_CMD_OF_DUMP) += of_dump.o obj-$(CONFIG_CMD_OF_DISPLAY_TIMINGS) += of_display_timings.o +obj-$(CONFIG_CMD_OF_FIXUP_STATUS) += of_fixup_status.o obj-$(CONFIG_CMD_MAGICVAR) += magicvar.o obj-$(CONFIG_CMD_IOMEM) += iomemport.o obj-$(CONFIG_CMD_LINUX_EXEC) += linux_exec.o
commands/of_fixup_status.c new file +74 -0
74 lines not on this page · raw message
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/3 ARM: am335x_defconfig: Enable the of_fixup_status command
In reply to Teresa Remmet--- arch/arm/configs/am335x_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/am335x_defconfig +1 -0
@@ -84,6 +84,7 @@ CONFIG_CMD_BAREBOX_UPDATE=y CONFIG_CMD_OF_NODE=y CONFIG_CMD_OF_PROPERTY=y CONFIG_CMD_OF_DISPLAY_TIMINGS=y +CONFIG_CMD_OF_FIXUP_STATUS=y CONFIG_CMD_OFTREE=y CONFIG_CMD_TIME=y CONFIG_NET=y
Signature · 7 lines
1.9.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 8 lines · Teresa Remmet
Added a function to register a fixup to enable or disable device tree nodes.
Signed-off-by Teresa Remmet <[email protected]>--- common/oftree.c | 36 ++++++++++++++++++++++++++++++++++++ include/of.h | 1 + 2 files changed, 37 insertions(+)
Applied, thanks
Possible future enhancements could be that we can list the fixups and maybe even remove them.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
common/oftree.c static int of_register_bootargs_fixup(void) · line 143
Quoted 3 lines · Teresa Remmet
common/oftree.c +2
-0+struct of_fixup_status_data { +char *node;
const char *node.
I think path would be a better name, as node usually is a device_node pointer, not a path.
common/oftree.c static int of_register_bootargs_fixup(void) · line 149
Quoted 6 lines
common/oftree.c +6
-0+bool status; +}; + +static int of_fixup_status (struct device_node *root,void *context) +{ +struct of_fixup_status_data *data = context;
const struct of_fixup_status_data *data
Quoted 8 lines
common/oftree.c +8
-0+struct device_node *node; + + node =of_find_node_by_path_or_alias (root, data->node); +if (!node) +return -ENODEV ; + +if (data->status) +return of_device_enable (node);
common/oftree.c static int of_register_bootargs_fixup(void) · line 167
Quoted 10 lines
common/oftree.c +10
-0+else +return of_device_disable (node); +} + +/** +* of_register_set_status_fixup - register fix up to set status of nodes +* Register a fixup to enable or disable a node in the devicet tree by +* passing the path or alias. +*/ +int of_register_set_status_fixup (char *node,bool status)
(const char *path, bool status)
common/oftree.c static int of_register_bootargs_fixup(void) · line 176
Quoted 9 lines
common/oftree.c +9
-0+{ +struct of_fixup_status_data *data; + + data =xzalloc (sizeof (*data)); + data->node = node; + data->status = status; + +return of_register_fixup (of_fixup_status, (void *)data); +}
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Hello Trent,
Am Donnerstag, den 25.02.2016, 18:18 +0000 schrieb Trent Piepho:
Quoted 10 lines · Teresa Remmet
common/oftree.c static int of_register_bootargs_fixup(void) · line 143
Quoted 4 lines
common/oftree.c +2
-0+struct of_fixup_status_data { +char *node;const char *node.
I think path would be a better name, as node usually is a
device_nodepointer, not a path.
I named it node as it could also be an alias and not only a path. But I don't might to rename it.
I'll send a fixup, also for the rest.
Regards,
Teresa
Quoted 31 lines
common/oftree.c static int of_register_bootargs_fixup(void) · line 149
Quoted 7 lines
common/oftree.c +6
-0+bool status; +}; + +static int of_fixup_status (struct device_node *root,void *context) +{ +struct of_fixup_status_data *data = context;const struct
of_fixup_status_data*dataQuoted 8 lines
common/oftree.c +8
-0+struct device_node *node; + + node =of_find_node_by_path_or_alias (root, data->node); +if (!node) +return -ENODEV ; + +if (data->status) +return of_device_enable (node);common/oftree.c static int of_register_bootargs_fixup(void) · line 167
Quoted 10 lines
common/oftree.c +10
-0+else +return of_device_disable (node); +} + +/** +* of_register_set_status_fixup - register fix up to set status of nodes +* Register a fixup to enable or disable a node in the devicet tree by +* passing the path or alias. +*/ +int of_register_set_status_fixup (char *node,bool status)(const char *path, bool status)
Quoted 9 lines
common/oftree.c static int of_register_bootargs_fixup(void) · line 176
Quoted 9 lines
common/oftree.c +9
-0+{ +struct of_fixup_status_data *data; + + data =xzalloc (sizeof (*data)); + data->node = node; + data->status = status; + +return of_register_fixup (of_fixup_status, (void *)data); +}
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox