summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-08-26 10:13:22 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-08-28 07:18:14 +0200
commit4a7534bf07ee0fb56cf48501d988234382567481 (patch)
tree0b5c616c5508979b42f925182084029e0af70cb7 /common
parentff2a4a0a138d6cb6addb5a855ea57a0332626d3c (diff)
downloadbarebox-4a7534bf07ee0fb56cf48501d988234382567481.tar.gz
reset-source: Allow different priorities
Different devices may report the reset source with different levels of certainty. For example a SoC may see a power-on reset, but this may only be because an external PMIC has power cycled the SoC. This means the PMIC knows the real reason better and thus the reset reason from the PMIC should be preferred. This patch introduces priorities for the reset_source to handle the above scenario. Also add a of_get_reset_source_priority() function to retrieve the desired priority from the device tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/reset_source.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/common/reset_source.c b/common/reset_source.c
index f9ee99b..b02a694 100644
--- a/common/reset_source.c
+++ b/common/reset_source.c
@@ -30,6 +30,7 @@ static const char * const reset_src_names[] = {
};
static enum reset_src_type reset_source;
+static unsigned int reset_source_priority;
enum reset_src_type reset_source_get(void)
{
@@ -37,9 +38,13 @@ enum reset_src_type reset_source_get(void)
}
EXPORT_SYMBOL(reset_source_get);
-void reset_source_set(enum reset_src_type st)
+void reset_source_set_priority(enum reset_src_type st, unsigned int priority)
{
+ if (priority <= reset_source_priority)
+ return;
+
reset_source = st;
+ reset_source_priority = priority;
}
EXPORT_SYMBOL(reset_source_set);
@@ -52,3 +57,19 @@ static int reset_source_init(void)
}
coredevice_initcall(reset_source_init);
+
+/**
+ * of_get_reset_source_priority() - get the desired reset source priority from
+ * device tree
+ * @node: The device_node to read the property from
+ *
+ * return: The priority
+ */
+unsigned int of_get_reset_source_priority(struct device_node *node)
+{
+ unsigned int priority = RESET_SOURCE_DEFAULT_PRIORITY;
+
+ of_property_read_u32(node, "reset-source-priority", &priority);
+
+ return priority;
+}