* [PATCH] reboot-mode: Add NVMEM reboot mode
@ 2022-12-02 16:03 Sean Anderson
2022-12-04 21:16 ` Simon Glass
2023-01-12 15:17 ` Tom Rini
0 siblings, 2 replies; 3+ messages in thread
From: Sean Anderson @ 2022-12-02 16:03 UTC (permalink / raw)
To: Simon Glass, u-boot; +Cc: Patrick Delaunay, Nandor Han, Sean Anderson
This adds an NVMEM reboot mode driver, similar to Linux's
implementation. This allows using the same device tree binding for Linux
and U-Boot in most cases.
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---
MAINTAINERS | 1 +
drivers/reboot-mode/Kconfig | 7 +++
drivers/reboot-mode/Makefile | 1 +
drivers/reboot-mode/reboot-mode-nvmem.c | 57 +++++++++++++++++++++++++
4 files changed, 66 insertions(+)
create mode 100644 drivers/reboot-mode/reboot-mode-nvmem.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 97b2f69f65..15321ce9bc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1190,6 +1190,7 @@ M: Sean Anderson <seanga2@gmail.com>
S: Maintained
F: doc/api/nvmem.rst
F: drivers/misc/nvmem.c
+F: drivers/reboot-mode/reboot-mode-nvmem.c
F: include/nvmem.h
NXP C45 TJA11XX PHY DRIVER
diff --git a/drivers/reboot-mode/Kconfig b/drivers/reboot-mode/Kconfig
index 63ea18cdf0..d57baacc93 100644
--- a/drivers/reboot-mode/Kconfig
+++ b/drivers/reboot-mode/Kconfig
@@ -30,4 +30,11 @@ config DM_REBOOT_MODE_RTC
a device in a specific mode by using a register(s) that can be controlled
outside U-Boot (e.g. Kernel).
+config REBOOT_MODE_NVMEM
+ bool "Use NVMEM reboot mode"
+ depends on DM_REBOOT_MODE && NVMEM
+ help
+ Use any kind of non-volatile memory (EEPROM, RTC, etc) to control the
+ reboot mode.
+
endmenu
diff --git a/drivers/reboot-mode/Makefile b/drivers/reboot-mode/Makefile
index 2c13780ced..48c8ab7fe7 100644
--- a/drivers/reboot-mode/Makefile
+++ b/drivers/reboot-mode/Makefile
@@ -7,3 +7,4 @@
obj-$(CONFIG_DM_REBOOT_MODE) += reboot-mode-uclass.o
obj-$(CONFIG_DM_REBOOT_MODE_GPIO) += reboot-mode-gpio.o
obj-$(CONFIG_DM_REBOOT_MODE_RTC) += reboot-mode-rtc.o
+obj-$(CONFIG_REBOOT_MODE_NVMEM) += reboot-mode-nvmem.o
diff --git a/drivers/reboot-mode/reboot-mode-nvmem.c b/drivers/reboot-mode/reboot-mode-nvmem.c
new file mode 100644
index 0000000000..da41ca41d9
--- /dev/null
+++ b/drivers/reboot-mode/reboot-mode-nvmem.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 Sean Anderson <sean.anderson@seco.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <nvmem.h>
+#include <reboot-mode/reboot-mode.h>
+
+/**
+ * struct nvmem_reboot_mode_priv - Private data for the nvmem reboot mode device
+ * @cell: The nvmem cell to store the mode in
+ */
+struct nvmem_reboot_mode_priv {
+ struct nvmem_cell cell;
+};
+
+static int reboot_mode_get(struct udevice *dev, u32 *mode)
+{
+ struct nvmem_reboot_mode_priv *priv = dev_get_priv(dev);
+
+ return nvmem_cell_read(&priv->cell, mode, sizeof(*mode));
+}
+
+static int reboot_mode_set(struct udevice *dev, u32 mode)
+{
+ struct nvmem_reboot_mode_priv *priv = dev_get_priv(dev);
+
+ return nvmem_cell_write(&priv->cell, &mode, sizeof(mode));
+}
+
+static const struct reboot_mode_ops nvmem_reboot_mode_ops = {
+ .get = reboot_mode_get,
+ .set = reboot_mode_set,
+};
+
+static int reboot_mode_probe(struct udevice *dev)
+{
+ struct nvmem_reboot_mode_priv *priv = dev_get_priv(dev);
+
+ return nvmem_cell_get_by_name(dev, "reboot-mode", &priv->cell);
+}
+
+static const struct udevice_id nvmem_reboot_mode_ids[] = {
+ { .compatible = "nvmem-reboot-mode" },
+ { }
+};
+
+U_BOOT_DRIVER(nvmem_reboot_mode) = {
+ .name = "nvmem-reboot-mode",
+ .id = UCLASS_REBOOT_MODE,
+ .of_match = nvmem_reboot_mode_ids,
+ .probe = reboot_mode_probe,
+ .priv_auto = sizeof(struct nvmem_reboot_mode_priv),
+ .ops = &nvmem_reboot_mode_ops,
+};
--
2.35.1.1320.gc452695387.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] reboot-mode: Add NVMEM reboot mode
2022-12-02 16:03 [PATCH] reboot-mode: Add NVMEM reboot mode Sean Anderson
@ 2022-12-04 21:16 ` Simon Glass
2023-01-12 15:17 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2022-12-04 21:16 UTC (permalink / raw)
To: Sean Anderson; +Cc: u-boot, Patrick Delaunay, Nandor Han
On Sat, 3 Dec 2022 at 05:04, Sean Anderson <sean.anderson@seco.com> wrote:
>
> This adds an NVMEM reboot mode driver, similar to Linux's
> implementation. This allows using the same device tree binding for Linux
> and U-Boot in most cases.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
> MAINTAINERS | 1 +
> drivers/reboot-mode/Kconfig | 7 +++
> drivers/reboot-mode/Makefile | 1 +
> drivers/reboot-mode/reboot-mode-nvmem.c | 57 +++++++++++++++++++++++++
> 4 files changed, 66 insertions(+)
> create mode 100644 drivers/reboot-mode/reboot-mode-nvmem.c
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] reboot-mode: Add NVMEM reboot mode
2022-12-02 16:03 [PATCH] reboot-mode: Add NVMEM reboot mode Sean Anderson
2022-12-04 21:16 ` Simon Glass
@ 2023-01-12 15:17 ` Tom Rini
1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2023-01-12 15:17 UTC (permalink / raw)
To: Sean Anderson; +Cc: Simon Glass, u-boot, Patrick Delaunay, Nandor Han
[-- Attachment #1: Type: text/plain, Size: 389 bytes --]
On Fri, Dec 02, 2022 at 11:03:53AM -0500, Sean Anderson wrote:
> This adds an NVMEM reboot mode driver, similar to Linux's
> implementation. This allows using the same device tree binding for Linux
> and U-Boot in most cases.
>
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-12 15:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02 16:03 [PATCH] reboot-mode: Add NVMEM reboot mode Sean Anderson
2022-12-04 21:16 ` Simon Glass
2023-01-12 15:17 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.