summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-09-28 16:45:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-29 10:25:02 +0200
commitfc8511d20ab32a31e9502c54a28a3f7f55223f39 (patch)
treefbc05fee8e84068489490060be1e3889c0b2b61c /include
parent5a5c5178e7dc6a58a059fe4a1f4167a31809ccaf (diff)
downloadbarebox-fc8511d20ab32a31e9502c54a28a3f7f55223f39.tar.gz
barebox-fc8511d20ab32a31e9502c54a28a3f7f55223f39.tar.xz
drivers: add reboot-mode infrastructure
Reboot modes provide a well-defined way to exchange information between different stage of the boot process. When configured, users can type `reboot bootloader` in the OS and barebox can read it out a device parameter. Likewise barebox can write a reboot mode for the BootROM to evaluate and then reset to fall into a serial recovery mode for example. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/reboot-mode.h36
-rw-r--r--include/of.h2
2 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h
new file mode 100644
index 0000000000..92a1da7b55
--- /dev/null
+++ b/include/linux/reboot-mode.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __REBOOT_MODE_H__
+#define __REBOOT_MODE_H__
+
+#include <linux/types.h>
+
+struct device_d;
+
+#ifdef CONFIG_REBOOT_MODE
+struct reboot_mode_driver {
+ struct device_d *dev;
+ int (*write)(struct reboot_mode_driver *reboot, u32 magic);
+ int priority;
+
+ /* filled by reboot_mode_register */
+ int reboot_mode_prev, reboot_mode_next;
+ unsigned nmodes;
+ const char **modes;
+ u32 *magics;
+};
+
+int reboot_mode_register(struct reboot_mode_driver *reboot, u32 reboot_mode);
+const char *reboot_mode_get(void);
+
+#define REBOOT_MODE_DEFAULT_PRIORITY 100
+
+#else
+
+static inline const char *reboot_mode_get(void)
+{
+ return NULL;
+}
+
+#endif
+
+#endif
diff --git a/include/of.h b/include/of.h
index d548e51789..b9b3a10228 100644
--- a/include/of.h
+++ b/include/of.h
@@ -732,6 +732,8 @@ static inline int of_autoenable_i2c_by_component(char *path)
#endif
+#define for_each_property_of_node(dn, pp) \
+ list_for_each_entry(pp, &dn->properties, list)
#define for_each_node_by_name(dn, name) \
for (dn = of_find_node_by_name(NULL, name); dn; \
dn = of_find_node_by_name(dn, name))