[PATCH 09/11] reboot-mode: reboot method activation support
Sam Day via B4 Relay
devnull+me.samcday.com at kernel.org
Sat Jun 6 10:47:40 CEST 2026
From: Sam Day <me at samcday.com>
Until now, the reboot-mode uclass didn't wire up a producer path to
allow arbitrary changes to the reboot mode. The current impl only uses
reboot_mode_ops->set to clear the reboot mode once it has been read at
boot-time.
The public API is expanded with a dm_reboot_mode_activate method, which
will instruct the given device to activate a particular reboot mode.
The first producer, `fastboot reboot`, will be introduced in the next
commit.
Signed-off-by: Sam Day <me at samcday.com>
---
drivers/reboot-mode/reboot-mode-uclass.c | 18 ++++++++++++++++++
include/reboot-mode/reboot-mode.h | 12 ++++++++++++
2 files changed, 30 insertions(+)
diff --git a/drivers/reboot-mode/reboot-mode-uclass.c b/drivers/reboot-mode/reboot-mode-uclass.c
index 7cbe02eb4ed..c47d11b681e 100644
--- a/drivers/reboot-mode/reboot-mode-uclass.c
+++ b/drivers/reboot-mode/reboot-mode-uclass.c
@@ -9,6 +9,24 @@
#include <exports.h>
#include <reboot-mode/reboot-mode.h>
+int dm_reboot_mode_activate(struct udevice *dev, const char *mode)
+{
+ struct reboot_mode_ops *ops = reboot_mode_get_ops(dev);
+ int i;
+ const struct reboot_mode_uclass_platdata *plat_data =
+ dev_get_uclass_plat(dev);
+
+ if (!ops || !ops->set)
+ return -ENOSYS;
+
+ for (i = 0; i < plat_data->count; i++) {
+ if (!strcmp(plat_data->modes[i].mode_name, mode))
+ return ops->set(dev, plat_data->modes[i].mode_id);
+ }
+
+ return -ENOENT;
+}
+
int dm_reboot_mode_update(struct udevice *dev)
{
struct reboot_mode_ops *ops = reboot_mode_get_ops(dev);
diff --git a/include/reboot-mode/reboot-mode.h b/include/reboot-mode/reboot-mode.h
index 5fbd7c801af..6510141ff89 100644
--- a/include/reboot-mode/reboot-mode.h
+++ b/include/reboot-mode/reboot-mode.h
@@ -53,4 +53,16 @@ struct reboot_mode_ops {
*/
int dm_reboot_mode_update(struct udevice *dev);
+/**
+ * dm_reboot_mode_activate() - activate a reboot mode by name
+ *
+ * This will read the given @dev plat_data for a named mode, and write the
+ * magic value for that mode to the device.
+ *
+ * @dev Device to write reboot magic to
+ * @mode name of the mode to lookup for magic value
+ * Return: 0 on success, -ve on error
+ */
+int dm_reboot_mode_activate(struct udevice *dev, const char *mode);
+
#endif /* REBOOT_MODE_REBOOT_MODE_H__ */
--
2.54.0
More information about the U-Boot
mailing list