Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v2 0/4] power: reset: add NVMEM recorder provider for PSCRR
@ 2026-08-19 17:20 Faruque Ansari
  2026-08-19 17:20 ` [PATCH v2 1/4] dt-bindings: power: reset: add PSCRR NVMEM recorder binding Faruque Ansari
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Faruque Ansari @ 2026-08-19 17:20 UTC (permalink / raw)
  To: Oleksij Rempel, Pengutronix Kernel Team, Sebastian Reichel,
	Rob Herring, Krzysztof Kozlowski, Wim Van Sebroeck, Guenter Roeck,
	Benson Leung, Tzung-Bi Shih, Srinivas Kandagatla, Daniel Lezcano
  Cc: linux-arm-msm, linux-kernel, linux-pm, devicetree, linux-watchdog,
	kernel, Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
	Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
	Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda,
	Faruque Ansari, Sebastian Reichel

The PSCRR framework[1] currently does not provide a recorder provider
capable of persisting power state change reasons across power cycles.

This series extends the PSCRR framework[1] with support for an
NVMEM-cell recorder provider, integrating PSCRR-recorded power state
change reasons with the NVMEM subsystem.

The recorder writes the power state change reason into a small NVMEM cell
(e.g. a PMIC SDAM byte or RTC scratch register) before shutdown or reset,
so the cause survives a power cycle and is available via
/sys/kernel/pscrr/ on the next boot.

Only the NVMEM-cell provider is included here. The PMIC hardware-register
provider will be submitted as a separate series.

Change in v2:
	- Add reviewers to To/Cc list.
	- Update patch 1/4:
	   * Rename DT node from pscr-reason to reboot-reason.
	   * Update DT binding example to use fixed-layout NVMEM layout.
	   * Add reboot_reason_persist NVMEM cell under fixed-layout.
	   * Update Qualcomm DTS example accordingly.
	- update patch 2/4 based on Uwe Kleine-König feedback:
	   * Remove unnecessary #include <linux/mod_devicetable.h>
	-v1-link: [2]

[1] https://lore.kernel.org/lkml/20260731095959.296056-1-o.rempel@pengutronix.de/
[2] https://lore.kernel.org/all/20260817-pscrr-provider-v1-0-88a318c13d41@oss.qualcomm.com/

Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
---
Faruque Ansari (4):
      dt-bindings: power: reset: add PSCRR NVMEM recorder binding
      power: reset: add PSCRR NVMEM recorder
      nvmem: provide consumer access to cell size metrics
      arm64: dts: qcom: lemans: Add PSCRR NVMEM recorder node

 .../bindings/power/reset/pscrr-nvmem.yaml          |  59 ++++++++
 MAINTAINERS                                        |   1 +
 arch/arm64/boot/dts/qcom/lemans-pmics.dtsi         |  16 +++
 drivers/nvmem/core.c                               |  29 ++++
 drivers/power/reset/pscrr/Kconfig                  |  14 ++
 drivers/power/reset/pscrr/Makefile                 |   1 +
 drivers/power/reset/pscrr/pscrr-nvmem.c            | 154 +++++++++++++++++++++
 include/linux/nvmem-consumer.h                     |   7 +
 8 files changed, 281 insertions(+)
---
base-commit: be461b2185ea3ff6d9c92deedcee0a62a57e1332
change-id: 20260806-pscrr-provider-b9f8f451701e

Best regards,
--  
Faruque Ansari <faruque.ansari@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/4] dt-bindings: power: reset: add PSCRR NVMEM recorder binding
  2026-08-19 17:20 [PATCH v2 0/4] power: reset: add NVMEM recorder provider for PSCRR Faruque Ansari
@ 2026-08-19 17:20 ` Faruque Ansari
  2026-08-27  9:45   ` Krzysztof Kozlowski
  2026-08-19 17:20 ` [PATCH v2 2/4] power: reset: add PSCRR NVMEM recorder Faruque Ansari
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Faruque Ansari @ 2026-08-19 17:20 UTC (permalink / raw)
  To: Oleksij Rempel, Pengutronix Kernel Team, Sebastian Reichel,
	Rob Herring, Krzysztof Kozlowski, Wim Van Sebroeck, Guenter Roeck,
	Benson Leung, Tzung-Bi Shih, Srinivas Kandagatla, Daniel Lezcano
  Cc: linux-arm-msm, linux-kernel, linux-pm, devicetree, linux-watchdog,
	kernel, Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
	Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
	Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda,
	Faruque Ansari

Add binding for the PSCRR NVMEM recorder. Records the power state
change reason into a small NVMEM cell, such as a PMIC SDAM byte or
RTC scratch register — so the cause survives a power cycle and can be
read back on the next boot.

Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
---
 .../bindings/power/reset/pscrr-nvmem.yaml          | 59 ++++++++++++++++++++++
 MAINTAINERS                                        |  1 +
 2 files changed, 60 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/reset/pscrr-nvmem.yaml b/Documentation/devicetree/bindings/power/reset/pscrr-nvmem.yaml
new file mode 100644
index 000000000000..5334c923d644
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/reset/pscrr-nvmem.yaml
@@ -0,0 +1,59 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/reset/pscrr-nvmem.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVMEM Power State Change Reason recorder
+
+maintainers:
+  - Faruque Ansari <faruque.ansari@oss.qualcomm.com>
+  - Oleksij Rempel <o.rempel@pengutronix.de>
+
+description:
+  An NVMEM-backed recorder for Power State Change Reasons (PSCRR). Persists
+  the reboot or shutdown cause into a small NVMEM cell, such as an RTC
+  scratch register, a PMIC SDAM (Scratch Data Access Memory) byte, or an
+  EEPROM — so the reason survives a power cycle and can be read back on the
+  next boot. The cell is referenced via the standard nvmem-cells consumer
+  binding.
+
+allOf:
+  - $ref: /schemas/nvmem/nvmem-consumer.yaml#
+
+properties:
+  compatible:
+    const: pscrr-nvmem
+
+  nvmem-cells:
+    maxItems: 1
+
+  nvmem-cell-names:
+    items:
+      - const: pscr
+
+required:
+  - compatible
+  - nvmem-cells
+  - nvmem-cell-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    nvmem-layout {
+        compatible = "fixed-layout";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        reboot_reason_persist: reboot-reason-persist@49 {
+            reg = <0x49 0x1>;
+        };
+    };
+
+    reboot-reason {
+        compatible = "pscrr-nvmem";
+        nvmem-cells = <&reboot_reason_persist>;
+        nvmem-cell-names = "pscr";
+    };
+...
diff --git a/MAINTAINERS b/MAINTAINERS
index 19b9f6605d98..f329cd9d0491 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -21693,6 +21693,7 @@ R:	Pengutronix Kernel Team <kernel@pengutronix.de>
 L:	linux-pm@vger.kernel.org
 S:	Maintained
 F:	Documentation/ABI/testing/sysfs-kernel-pscrr
+F:	Documentation/devicetree/bindings/power/reset/pscrr-nvmem.yaml
 F:	drivers/power/reset/pscrr/
 F:	include/linux/pscrr.h
 F:	tools/testing/selftests/pscrr/

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/4] power: reset: add PSCRR NVMEM recorder
  2026-08-19 17:20 [PATCH v2 0/4] power: reset: add NVMEM recorder provider for PSCRR Faruque Ansari
  2026-08-19 17:20 ` [PATCH v2 1/4] dt-bindings: power: reset: add PSCRR NVMEM recorder binding Faruque Ansari
@ 2026-08-19 17:20 ` Faruque Ansari
  2026-08-19 17:20 ` [PATCH v2 3/4] nvmem: provide consumer access to cell size metrics Faruque Ansari
  2026-08-19 17:20 ` [PATCH v2 4/4] arm64: dts: qcom: lemans: Add PSCRR NVMEM recorder node Faruque Ansari
  3 siblings, 0 replies; 8+ messages in thread
From: Faruque Ansari @ 2026-08-19 17:20 UTC (permalink / raw)
  To: Oleksij Rempel, Pengutronix Kernel Team, Sebastian Reichel,
	Rob Herring, Krzysztof Kozlowski, Wim Van Sebroeck, Guenter Roeck,
	Benson Leung, Tzung-Bi Shih, Srinivas Kandagatla, Daniel Lezcano
  Cc: linux-arm-msm, linux-kernel, linux-pm, devicetree, linux-watchdog,
	kernel, Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
	Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
	Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda,
	Faruque Ansari

Record the power state change reason into a small NVMEM cell (an RTC
scratch register or EEPROM) and read it back on the next boot, so the
cause survives a power cycle. The cell is a plain nvmem consumer
reference and the reason value is stored directly.

Co-developed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
---
 drivers/power/reset/pscrr/Kconfig       |  14 +++
 drivers/power/reset/pscrr/Makefile      |   1 +
 drivers/power/reset/pscrr/pscrr-nvmem.c | 154 ++++++++++++++++++++++++++++++++
 3 files changed, 169 insertions(+)

diff --git a/drivers/power/reset/pscrr/Kconfig b/drivers/power/reset/pscrr/Kconfig
index 72de82731b53..bfcf04b0c8f5 100644
--- a/drivers/power/reset/pscrr/Kconfig
+++ b/drivers/power/reset/pscrr/Kconfig
@@ -31,3 +31,17 @@ menuconfig PSCRR
 	  unless hardware provides the reset cause.
 
 	  If unsure, say N.
+
+if PSCRR
+
+config PSCRR_NVMEM
+	tristate "PSCRR NVMEM recorder provider"
+	depends on NVMEM
+	help
+	  PSCRR recorder that stores the power state change reason in a
+	  small NVMEM cell (such as an RTC scratch register) and reads it
+	  back on the next boot, so the cause survives a power cycle.
+
+	  If unsure, say N.
+
+endif # PSCRR
diff --git a/drivers/power/reset/pscrr/Makefile b/drivers/power/reset/pscrr/Makefile
index e5530a858971..95c80c80c7da 100644
--- a/drivers/power/reset/pscrr/Makefile
+++ b/drivers/power/reset/pscrr/Makefile
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_PSCRR) += pscrr.o
+obj-$(CONFIG_PSCRR_NVMEM) += pscrr-nvmem.o
diff --git a/drivers/power/reset/pscrr/pscrr-nvmem.c b/drivers/power/reset/pscrr/pscrr-nvmem.c
new file mode 100644
index 000000000000..1c3145c0d058
--- /dev/null
+++ b/drivers/power/reset/pscrr/pscrr-nvmem.c
@@ -0,0 +1,154 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * pscrr-nvmem.c - NVMEM recorder provider for PSCRR
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ * Copyright (C) 2025 Pengutronix, Oleksij Rempel <o.rempel@pengutronix.de>
+ */
+
+#include <linux/module.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/platform_device.h>
+#include <linux/pscrr.h>
+#include <linux/reboot.h>
+#include <linux/slab.h>
+
+struct pscrr_nvmem {
+	struct nvmem_cell *cell;
+	enum psc_reason reason;
+};
+
+static int pscrr_nvmem_cell_read(struct pscrr_nvmem *priv, u8 *out)
+{
+	size_t len;
+	void *buf;
+
+	buf = nvmem_cell_read(priv->cell, &len);
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
+
+	*out = len ? *(u8 *)buf : 0;
+	kfree(buf);
+
+	return 0;
+}
+
+static int pscrr_nvmem_cell_write(struct pscrr_nvmem *priv, u8 val)
+{
+	int ret;
+
+	/* nvmem_cell_write() returns the byte count on success, not 0. */
+	ret = nvmem_cell_write(priv->cell, &val, sizeof(val));
+
+	return ret < 0 ? ret : 0;
+}
+
+static int pscrr_nvmem_read_reasons(struct pscrr_provider *p,
+				    unsigned long *reasons)
+{
+	struct pscrr_nvmem *priv = p->priv;
+
+	/*
+	 * Report the reason latched at probe (or overwritten by a later
+	 * record); the cell itself was cleared at probe, so it is not read
+	 * live here.
+	 */
+	set_bit(READ_ONCE(priv->reason), reasons);
+
+	return 0;
+}
+
+static int pscrr_nvmem_write_reason(struct pscrr_provider *p,
+				    enum psc_reason reason)
+{
+	struct pscrr_nvmem *priv = p->priv;
+	int ret;
+
+	if (reason >= PSCR_REASON_COUNT)
+		return -EINVAL;
+
+	ret = pscrr_nvmem_cell_write(priv, reason);
+	if (ret)
+		return ret;
+
+	WRITE_ONCE(priv->reason, reason);
+
+	return 0;
+}
+
+static const struct pscrr_provider_ops pscrr_nvmem_ops = {
+	.read_reasons = pscrr_nvmem_read_reasons,
+	.write_reason = pscrr_nvmem_write_reason,
+};
+
+static int pscrr_nvmem_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct pscrr_nvmem *priv;
+	size_t bytes, bits;
+	u8 val;
+	int ret;
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->cell = devm_nvmem_cell_get(dev, "pscr");
+	if (IS_ERR(priv->cell))
+		return dev_err_probe(dev, PTR_ERR(priv->cell),
+				     "failed to get the pscr nvmem cell\n");
+
+	ret = nvmem_cell_get_size(priv->cell, &bytes, &bits);
+	if (ret)
+		return ret;
+
+	/* The reason is a single byte; a bit cell still occupies one. */
+	if ((bytes ?: DIV_ROUND_UP(bits, 8)) != sizeof(val))
+		return dev_err_probe(dev, -EINVAL,
+				     "unsupported pscr nvmem cell size\n");
+
+	/*
+	 * The cell survives resets, so at boot it still holds whatever the
+	 * previous session recorded before it went down. Latch that as this
+	 * boot's reason, then clear the cell back to PSCR_UNKNOWN: if this
+	 * session is later cut short by an abrupt reset that never runs the
+	 * recorder (watchdog power-cycle, sudden power loss), the next boot
+	 * reads "unknown" instead of a stale reason left over from an earlier
+	 * cycle.
+	 */
+	ret = pscrr_nvmem_cell_read(priv, &val);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "failed to read the pscr nvmem cell\n");
+
+	priv->reason = val < PSCR_REASON_COUNT ? val : PSCR_UNKNOWN;
+
+	ret = pscrr_nvmem_cell_write(priv, PSCR_UNKNOWN);
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "failed to clear the pscr nvmem cell\n");
+
+	return PTR_ERR_OR_ZERO(devm_pscrr_provider_register(dev, "nvmem",
+							    &pscrr_nvmem_ops, NULL,
+							    priv));
+}
+
+static const struct of_device_id pscrr_nvmem_of_match[] = {
+	{ .compatible = "pscrr-nvmem" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, pscrr_nvmem_of_match);
+
+static struct platform_driver pscrr_nvmem_driver = {
+	.probe	= pscrr_nvmem_probe,
+	.driver	= {
+		.name		= "pscrr-nvmem",
+		.of_match_table	= pscrr_nvmem_of_match,
+	},
+};
+module_platform_driver(pscrr_nvmem_driver);
+
+MODULE_AUTHOR("Oleksij Rempel <o.rempel@pengutronix.de>");
+MODULE_AUTHOR("Faruque Ansari <faruque.ansari@oss.qualcomm.com>");
+MODULE_DESCRIPTION("NVMEM recorder provider for PSCRR");
+MODULE_LICENSE("GPL");

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/4] nvmem: provide consumer access to cell size metrics
  2026-08-19 17:20 [PATCH v2 0/4] power: reset: add NVMEM recorder provider for PSCRR Faruque Ansari
  2026-08-19 17:20 ` [PATCH v2 1/4] dt-bindings: power: reset: add PSCRR NVMEM recorder binding Faruque Ansari
  2026-08-19 17:20 ` [PATCH v2 2/4] power: reset: add PSCRR NVMEM recorder Faruque Ansari
@ 2026-08-19 17:20 ` Faruque Ansari
  2026-08-19 17:20 ` [PATCH v2 4/4] arm64: dts: qcom: lemans: Add PSCRR NVMEM recorder node Faruque Ansari
  3 siblings, 0 replies; 8+ messages in thread
From: Faruque Ansari @ 2026-08-19 17:20 UTC (permalink / raw)
  To: Oleksij Rempel, Pengutronix Kernel Team, Sebastian Reichel,
	Rob Herring, Krzysztof Kozlowski, Wim Van Sebroeck, Guenter Roeck,
	Benson Leung, Tzung-Bi Shih, Srinivas Kandagatla, Daniel Lezcano
  Cc: linux-arm-msm, linux-kernel, linux-pm, devicetree, linux-watchdog,
	kernel, Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
	Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
	Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda,
	Faruque Ansari, Sebastian Reichel

Add nvmem_cell_get_size() to let a consumer query a cell's size before
reading or writing it. Without this, a consumer that assumes a fixed
cell size can pass nvmem_cell_write() a buffer larger than the cell,
which fails with an incorrect-size error instead of succeeding with
the cell's actual capacity.

Co-developed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://lore.kernel.org/lkml/dixmyhyj6b66vyizfotpqw6yzaavi2o2mauloa5x6zn3qgk5ub@huoal5ucdd44/
Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
---
 drivers/nvmem/core.c           | 29 +++++++++++++++++++++++++++++
 include/linux/nvmem-consumer.h |  7 +++++++
 2 files changed, 36 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 0556d140170a..49afcff4c72c 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1790,6 +1790,35 @@ int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len)
 
 EXPORT_SYMBOL_GPL(nvmem_cell_write);
 
+/**
+ * nvmem_cell_get_size() - Retrieve the storage size of an NVMEM cell.
+ * @cell: Pointer to the NVMEM cell structure.
+ * @bytes: Optional pointer to store the cell size in bytes (can be NULL).
+ * @bits: Optional pointer to store the cell size in bits (can be NULL).
+ *
+ * This function allows consumers to retrieve the size of a specific NVMEM
+ * cell before performing read/write operations. It is useful for validating
+ * buffer sizes to prevent mismatched writes.
+ *
+ * Return: 0 on success or negative on failure.
+ */
+int nvmem_cell_get_size(struct nvmem_cell *cell, size_t *bytes, size_t *bits)
+{
+	struct nvmem_cell_entry *entry = cell->entry;
+
+	if (!entry->nvmem)
+		return -EINVAL;
+
+	if (bytes)
+		*bytes = entry->bytes;
+
+	if (bits)
+		*bits = entry->nbits;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(nvmem_cell_get_size);
+
 static int nvmem_cell_read_common(struct device *dev, const char *cell_id,
 				  void *val, size_t count)
 {
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index 34c0e58dfa26..bcb0e17e415d 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -56,6 +56,7 @@ void nvmem_cell_put(struct nvmem_cell *cell);
 void devm_nvmem_cell_put(struct device *dev, struct nvmem_cell *cell);
 void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len);
 int nvmem_cell_write(struct nvmem_cell *cell, void *buf, size_t len);
+int nvmem_cell_get_size(struct nvmem_cell *cell, size_t *bytes, size_t *bits);
 int nvmem_cell_read_u8(struct device *dev, const char *cell_id, u8 *val);
 int nvmem_cell_read_u16(struct device *dev, const char *cell_id, u16 *val);
 int nvmem_cell_read_u32(struct device *dev, const char *cell_id, u32 *val);
@@ -128,6 +129,12 @@ static inline int nvmem_cell_write(struct nvmem_cell *cell,
 	return -EOPNOTSUPP;
 }
 
+static inline int nvmem_cell_get_size(struct nvmem_cell *cell, size_t *bytes,
+				      size_t *bits)
+{
+	return -EOPNOTSUPP;
+}
+
 static inline int nvmem_cell_read_u8(struct device *dev,
 				     const char *cell_id, u8 *val)
 {

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 4/4] arm64: dts: qcom: lemans: Add PSCRR NVMEM recorder node
  2026-08-19 17:20 [PATCH v2 0/4] power: reset: add NVMEM recorder provider for PSCRR Faruque Ansari
                   ` (2 preceding siblings ...)
  2026-08-19 17:20 ` [PATCH v2 3/4] nvmem: provide consumer access to cell size metrics Faruque Ansari
@ 2026-08-19 17:20 ` Faruque Ansari
  2026-08-19 18:55   ` Abel Vesa
  3 siblings, 1 reply; 8+ messages in thread
From: Faruque Ansari @ 2026-08-19 17:20 UTC (permalink / raw)
  To: Oleksij Rempel, Pengutronix Kernel Team, Sebastian Reichel,
	Rob Herring, Krzysztof Kozlowski, Wim Van Sebroeck, Guenter Roeck,
	Benson Leung, Tzung-Bi Shih, Srinivas Kandagatla, Daniel Lezcano
  Cc: linux-arm-msm, linux-kernel, linux-pm, devicetree, linux-watchdog,
	kernel, Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
	Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
	Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda,
	Faruque Ansari

Add a one-byte NVMEM cell node  in the SDAM to persist the power
state change reason across resets, and wire it to a pscrr-nvmem
recorder consumer node so the reason is recorded before
shutdown/reboot and read back on the next boot.

Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
---
 arch/arm64/boot/dts/qcom/lemans-pmics.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/lemans-pmics.dtsi b/arch/arm64/boot/dts/qcom/lemans-pmics.dtsi
index 500f715931aa..96db3f57969f 100644
--- a/arch/arm64/boot/dts/qcom/lemans-pmics.dtsi
+++ b/arch/arm64/boot/dts/qcom/lemans-pmics.dtsi
@@ -97,6 +97,12 @@ reboot-mode {
 		mode-recovery = <0x01>;
 		mode-bootloader = <0x02>;
 	};
+
+	reboot-reason {
+		compatible = "pscrr-nvmem";
+		nvmem-cells = <&reboot_reason_persist>;
+		nvmem-cell-names = "pscr";
+	};
 };
 
 &spmi_bus {
@@ -186,6 +192,16 @@ reboot_reason: reboot-reason@48 {
 				reg = <0x48 0x1>;
 				bits = <1 7>;
 			};
+
+			nvmem-layout {
+				compatible = "fixed-layout";
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				reboot_reason_persist: reboot-reason-persist@49 {
+					reg = <0x49 0x1>;
+				};
+			};
 		};
 	};
 

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 4/4] arm64: dts: qcom: lemans: Add PSCRR NVMEM recorder node
  2026-08-19 17:20 ` [PATCH v2 4/4] arm64: dts: qcom: lemans: Add PSCRR NVMEM recorder node Faruque Ansari
@ 2026-08-19 18:55   ` Abel Vesa
  2026-08-24  9:17     ` Faruque Ansari
  0 siblings, 1 reply; 8+ messages in thread
From: Abel Vesa @ 2026-08-19 18:55 UTC (permalink / raw)
  To: Faruque Ansari
  Cc: Oleksij Rempel, Pengutronix Kernel Team, Sebastian Reichel,
	Rob Herring, Krzysztof Kozlowski, Wim Van Sebroeck, Guenter Roeck,
	Benson Leung, Tzung-Bi Shih, Srinivas Kandagatla, Daniel Lezcano,
	linux-arm-msm, linux-kernel, linux-pm, devicetree, linux-watchdog,
	Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
	Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
	Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda

On 26-08-19 22:50:46, Faruque Ansari wrote:
> Add a one-byte NVMEM cell node  in the SDAM to persist the power

Super nit: If you respin, drop the extra space between node and in.

> state change reason across resets, and wire it to a pscrr-nvmem
> recorder consumer node so the reason is recorded before
> shutdown/reboot and read back on the next boot.
> 
> Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>

Reviewed-by: Abel Vesa <abel.vesa@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 4/4] arm64: dts: qcom: lemans: Add PSCRR NVMEM recorder node
  2026-08-19 18:55   ` Abel Vesa
@ 2026-08-24  9:17     ` Faruque Ansari
  0 siblings, 0 replies; 8+ messages in thread
From: Faruque Ansari @ 2026-08-24  9:17 UTC (permalink / raw)
  To: Abel Vesa
  Cc: Oleksij Rempel, Pengutronix Kernel Team, Sebastian Reichel,
	Rob Herring, Krzysztof Kozlowski, Wim Van Sebroeck, Guenter Roeck,
	Benson Leung, Tzung-Bi Shih, Srinivas Kandagatla, Daniel Lezcano,
	linux-arm-msm, linux-kernel, linux-pm, devicetree, linux-watchdog,
	Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
	Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
	Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda

Hi Abel Vesa,

On 20-Aug-26 12:25 AM, Abel Vesa wrote:
> On 26-08-19 22:50:46, Faruque Ansari wrote:
>> Add a one-byte NVMEM cell node  in the SDAM to persist the power
> 
> Super nit: If you respin, drop the extra space between node and in.

Thanks for the review.
I'll fix this in V3.

Thanks
Faruque Ansari>
>> state change reason across resets, and wire it to a pscrr-nvmem
>> recorder consumer node so the reason is recorded before
>> shutdown/reboot and read back on the next boot.
>>
>> Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
> 
> Reviewed-by: Abel Vesa <abel.vesa@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/4] dt-bindings: power: reset: add PSCRR NVMEM recorder binding
  2026-08-19 17:20 ` [PATCH v2 1/4] dt-bindings: power: reset: add PSCRR NVMEM recorder binding Faruque Ansari
@ 2026-08-27  9:45   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-27  9:45 UTC (permalink / raw)
  To: Faruque Ansari
  Cc: Oleksij Rempel, Pengutronix Kernel Team, Sebastian Reichel,
	Rob Herring, Krzysztof Kozlowski, Wim Van Sebroeck, Guenter Roeck,
	Benson Leung, Tzung-Bi Shih, Srinivas Kandagatla, Daniel Lezcano,
	linux-arm-msm, linux-kernel, linux-pm, devicetree, linux-watchdog,
	Liam Girdwood, Mark Brown, Rafael J. Wysocki, Zhang Rui,
	Lukasz Luba, Søren Andersen, Guenter Roeck, Matti Vaittinen,
	Ahmad Fatoum, Andrew Morton, avaneesh.dwivedi, Umang Chheda

On Wed, Aug 19, 2026 at 10:50:43PM +0530, Faruque Ansari wrote:
> Add binding for the PSCRR NVMEM recorder. Records the power state
> change reason into a small NVMEM cell, such as a PMIC SDAM byte or
> RTC scratch register — so the cause survives a power cycle and can be
> read back on the next boot.

A nit, subject: drop second/last, redundant "binding". The
"dt-bindings" prefix is already stating that these are bindings.
See also:
https://elixir.bootlin.com/linux/v7.1-rc7/source/Documentation/devicetree/bindings/submitting-patches.rst#L23

> 
> Signed-off-by: Faruque Ansari <faruque.ansari@oss.qualcomm.com>
> ---
>  .../bindings/power/reset/pscrr-nvmem.yaml          | 59 ++++++++++++++++++++++
>  MAINTAINERS                                        |  1 +
>  2 files changed, 60 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/power/reset/pscrr-nvmem.yaml b/Documentation/devicetree/bindings/power/reset/pscrr-nvmem.yaml
> new file mode 100644
> index 000000000000..5334c923d644
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/reset/pscrr-nvmem.yaml
> @@ -0,0 +1,59 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/power/reset/pscrr-nvmem.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: NVMEM Power State Change Reason recorder
> +
> +maintainers:
> +  - Faruque Ansari <faruque.ansari@oss.qualcomm.com>
> +  - Oleksij Rempel <o.rempel@pengutronix.de>
> +
> +description:
> +  An NVMEM-backed recorder for Power State Change Reasons (PSCRR). Persists
> +  the reboot or shutdown cause into a small NVMEM cell, such as an RTC
> +  scratch register, a PMIC SDAM (Scratch Data Access Memory) byte, or an
> +  EEPROM — so the reason survives a power cycle and can be read back on the
> +  next boot. The cell is referenced via the standard nvmem-cells consumer
> +  binding.

I do not see how this should be a separate device. This should be rather part
of PSCRR, reboot handler or just the nvmem. Otherwise it is just device
node for instantiating driver.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-08-27  9:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 17:20 [PATCH v2 0/4] power: reset: add NVMEM recorder provider for PSCRR Faruque Ansari
2026-08-19 17:20 ` [PATCH v2 1/4] dt-bindings: power: reset: add PSCRR NVMEM recorder binding Faruque Ansari
2026-08-27  9:45   ` Krzysztof Kozlowski
2026-08-19 17:20 ` [PATCH v2 2/4] power: reset: add PSCRR NVMEM recorder Faruque Ansari
2026-08-19 17:20 ` [PATCH v2 3/4] nvmem: provide consumer access to cell size metrics Faruque Ansari
2026-08-19 17:20 ` [PATCH v2 4/4] arm64: dts: qcom: lemans: Add PSCRR NVMEM recorder node Faruque Ansari
2026-08-19 18:55   ` Abel Vesa
2026-08-24  9:17     ` Faruque Ansari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox