From fc8511d20ab32a31e9502c54a28a3f7f55223f39 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 28 Sep 2020 16:45:06 +0200 Subject: 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 Signed-off-by: Sascha Hauer --- include/linux/reboot-mode.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/linux/reboot-mode.h (limited to 'include/linux') 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 + +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 -- cgit v1.2.3