summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-10-17 09:09:54 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-27 11:13:29 +0200
commit21dda946e7aa86246bf7ca22fb1a1609407c4bb9 (patch)
treef0d9175cf0387e7972b92927dbfcd30cd0d2ca54
parent1c32f4eb396c20af8031df10b3239b32d3b64005 (diff)
downloadbarebox-21dda946e7aa86246bf7ca22fb1a1609407c4bb9.tar.gz
barebox-21dda946e7aa86246bf7ca22fb1a1609407c4bb9.tar.xz
restart: do restart-priority OF parsing in restart_handler_register
The restart-priority OF property is parsed for a number of MFDs, but there is no reason really not to parse it for every restart handler that has a device tree node like we already do for watchdogs. Add a new struct restart_handler::of_node field and look into it if populated. With this of_get_restart_priority, is no longer used, so drop it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221017071000.1458292-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--Documentation/devicetree/bindings/power/restart.rst10
-rw-r--r--common/restart.c20
-rw-r--r--drivers/mfd/da9053.c2
-rw-r--r--drivers/mfd/da9063.c2
-rw-r--r--drivers/mfd/rn5t568.c2
-rw-r--r--include/restart.h5
6 files changed, 21 insertions, 20 deletions
diff --git a/Documentation/devicetree/bindings/power/restart.rst b/Documentation/devicetree/bindings/power/restart.rst
new file mode 100644
index 0000000000..8c866f6e0d
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/restart.rst
@@ -0,0 +1,10 @@
+System Restart Controllers
+==========================
+
+In addition to upstream bindings, following properties are understood:
+
+Optional properties:
+
+- ``restart-priority`` : Overrides the priority set by the driver. Normally,
+ the device with the biggest reach should reset the system.
+ See :ref:`_system_reset` for more information.
diff --git a/common/restart.c b/common/restart.c
index b6f2bbf25b..9e988838bc 100644
--- a/common/restart.c
+++ b/common/restart.c
@@ -27,6 +27,11 @@ int restart_handler_register(struct restart_handler *rst)
if (!rst->priority)
rst->priority = RESTART_DEFAULT_PRIORITY;
+ if (rst->of_node) {
+ of_property_read_u32(rst->of_node, "restart-priority",
+ &rst->priority);
+ }
+
list_add_tail(&rst->list, &restart_handler_list);
pr_debug("registering restart handler \"%s\" with priority %d\n",
@@ -102,21 +107,6 @@ void __noreturn restart_machine(void)
hang();
}
-/**
- * of_get_restart_priority() - get the desired restart priority from device tree
- * @node: The device_node to read the property from
- *
- * return: The priority
- */
-unsigned int of_get_restart_priority(struct device_node *node)
-{
- unsigned int priority = RESTART_DEFAULT_PRIORITY;
-
- of_property_read_u32(node, "restart-priority", &priority);
-
- return priority;
-}
-
/*
* restart_handlers_print - print informations about all restart handlers
*/
diff --git a/drivers/mfd/da9053.c b/drivers/mfd/da9053.c
index 99827c9689..693c0ca606 100644
--- a/drivers/mfd/da9053.c
+++ b/drivers/mfd/da9053.c
@@ -272,7 +272,7 @@ static int da9053_probe(struct device_d *dev)
da9053_detect_reset_source(da9053);
- da9053->restart.priority = of_get_restart_priority(dev->device_node);
+ da9053->restart.of_node = dev->device_node;
da9053->restart.name = "da9063";
da9053->restart.restart = &da9053_force_system_reset;
diff --git a/drivers/mfd/da9063.c b/drivers/mfd/da9063.c
index a4e5226f3c..4627dd1aa5 100644
--- a/drivers/mfd/da9063.c
+++ b/drivers/mfd/da9063.c
@@ -383,7 +383,7 @@ static int da9063_probe(struct device_d *dev)
da9063_detect_reset_source(priv);
- priv->restart.priority = of_get_restart_priority(dev->device_node);
+ priv->restart.of_node = dev->device_node;
priv->restart.name = "da9063";
priv->restart.restart = &da9063_restart;
diff --git a/drivers/mfd/rn5t568.c b/drivers/mfd/rn5t568.c
index c1c792cbec..4bbab54fe4 100644
--- a/drivers/mfd/rn5t568.c
+++ b/drivers/mfd/rn5t568.c
@@ -138,7 +138,7 @@ static int __init rn5t568_i2c_probe(struct device_d *dev)
regmap_write(pmic_instance->regmap, RN5T568_REPCNT, RN5T568_REPCNT_OFF_RESETO_16MS |
RN5T568_REPCNT_OFF_REPWRTIM_1000MS | RN5T568_REPCNT_OFF_REPWRON);
- pmic_instance->restart.priority = of_get_restart_priority(dev->device_node);
+ pmic_instance->restart.of_node = dev->device_node;
pmic_instance->restart.name = "RN5T568";
pmic_instance->restart.restart = &rn5t568_restart;
restart_handler_register(&pmic_instance->restart);
diff --git a/include/restart.h b/include/restart.h
index 27fab1b80d..330b50a53a 100644
--- a/include/restart.h
+++ b/include/restart.h
@@ -11,9 +11,12 @@ void restart_handlers_print(void);
void __noreturn restart_machine(void);
struct restart_handler *restart_handler_get_by_name(const char *name);
+struct device_node;
+
struct restart_handler {
void (*restart)(struct restart_handler *);
int priority;
+ struct device_node *of_node;
const char *name;
struct list_head list;
};
@@ -24,6 +27,4 @@ int restart_handler_register_fn(const char *name,
#define RESTART_DEFAULT_PRIORITY 100
-unsigned int of_get_restart_priority(struct device_node *node);
-
#endif /* __INCLUDE_RESTART_H */