mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/3] common: oftree: Add fuction to register set status fixup
@ 2016-02-25  7:36 Teresa Remmet
  2016-02-25  7:36 ` [PATCH v2 2/3] commands: Add of_fixup_status Teresa Remmet
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Teresa Remmet @ 2016-02-25  7:36 UTC (permalink / raw)
  To: barebox

Added a function to register a fixup to enable or disable
device tree nodes.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
---
 common/oftree.c | 36 ++++++++++++++++++++++++++++++++++++
 include/of.h    |  1 +
 2 files changed, 37 insertions(+)

diff --git a/common/oftree.c b/common/oftree.c
index d408f14..3103bb1 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -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;
diff --git a/include/of.h b/include/of.h
index 75cc3c1..ae65409 100644
--- a/include/of.h
+++ b/include/of.h
@@ -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,
-- 
1.9.1


_______________________________________________
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:[~2016-02-26  7:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-25  7:36 [PATCH v2 1/3] common: oftree: Add fuction to register set status fixup Teresa Remmet
2016-02-25  7:36 ` [PATCH v2 2/3] commands: Add of_fixup_status Teresa Remmet
2016-02-25  7:36 ` [PATCH v2 3/3] ARM: am335x_defconfig: Enable the of_fixup_status command Teresa Remmet
2016-02-25  8:53 ` [PATCH v2 1/3] common: oftree: Add fuction to register set status fixup Sascha Hauer
2016-02-25 18:18 ` Trent Piepho
2016-02-26  7:52   ` Teresa Remmet

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