* [PATCH v8 0/5] Add support to read the watchdog bootstatus from IMEM
@ 2026-02-26 16:59 Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 1/5] dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram Kathiravan Thirumoorthy
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Kathiravan Thirumoorthy @ 2026-02-26 16:59 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
Konrad Dybcio, Wim Van Sebroeck, Guenter Roeck, Rajendra Nayak
Cc: linux-arm-msm, devicetree, linux-kernel, linux-watchdog,
Kathiravan Thirumoorthy, Dmitry Baryshkov, Konrad Dybcio
In Qualcomm IPQ SoCs, if the system is rebooted due to the watchdog
timeout, there is no way to identify it. Current approach of checking
the EXPIRED_STATUS in WDT_STS is not working.
To achieve this, if the system is rebooted due to watchdog timeout, the
information is captured in the IMEM by the bootloader (along with other
reason codes as well).
This series attempts to address this by adding the support to read the
IMEM and populate the information via bootstatus sysfs file.
With the CONFIG_WATCHDOG_SYSFS enabled, user can extract the information
as below:
cat
/sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus
32
Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
---
Changes in v8:
- Collected the tags
- Updated the commit msg with reasoning in 1/5
- Updated the comment in 4/5
- Link to v7: https://lore.kernel.org/r/20260225-wdt_reset_reason-v7-0-65d5b7e3e1eb@oss.qualcomm.com
Changes in v7:
- Collected the tags
- Added the reference link in 1/5
- Added the flag 'no-memory-wc' in 2/5
- Link to v6: https://lore.kernel.org/r/20260130-wdt_reset_reason-v6-0-417ab789cd97@oss.qualcomm.com
Changes in v6:
- Moved the IMEM compatible from qcom,imem to sram binding
- Updated the 'sram' property in watchdog binding to point to SRAM
region and update the watchdog driver accordingly
- Dropped the Konrad's R-b tag in 2/5
Changes in v5:
- Rename property 'qcom,imem' to 'sram'
- Use dev_err_probe instead of dev_err
- Link to v4:
https://lore.kernel.org/linux-arm-msm/20250519-wdt_reset_reason-v4-0-d59d21275c75@oss.qualcomm.com/
Changes in v4:
- Kept only the WDIOF_CARDRESET and dropped other codes (Guenter)
- Renamed qcom_wdt_get_restart_reason() to qcom_wdt_get_bootstatus()
- Dropped the device data and describe the required information in the
DT (Konrad)
- Link to v3:
https://lore.kernel.org/linux-arm-msm/20250502-wdt_reset_reason-v3-0-b2dc7ace38ca@oss.qualcomm.com/
Changes in v3:
- Picked up the relevant tags
- Dropped the fallback compatible handling
- Split the driver changes into 2. Introduce the device data in one and
extend the same in another for the use case
- Link to v2:
https://lore.kernel.org/linux-arm-msm/20250416-wdt_reset_reason-v2-0-c65bba312914@oss.qualcomm.com/
Changes in v2:
- Dropped the RFC tag
- Reworked the driver changes to use the syscon API
- Link to v1:
https://lore.kernel.org/linux-arm-msm/20250408-wdt_reset_reason-v1-0-e6ec30c2c926@oss.qualcomm.com/
Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
---
Kathiravan Thirumoorthy (5):
dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram
arm64: dts: qcom: ipq5424: Add the IMEM node
dt-bindings: watchdog: qcom-wdt: Document sram property
watchdog: qcom: add support to get the bootstatus from IMEM
arm64: dts: qcom: ipq5424: add support to get watchdog bootstatus from IMEM
.../devicetree/bindings/sram/qcom,imem.yaml | 1 -
Documentation/devicetree/bindings/sram/sram.yaml | 1 +
.../devicetree/bindings/watchdog/qcom-wdt.yaml | 6 ++++
arch/arm64/boot/dts/qcom/ipq5424.dtsi | 16 +++++++++
drivers/watchdog/qcom-wdt.c | 42 ++++++++++++++++++++--
5 files changed, 63 insertions(+), 3 deletions(-)
---
base-commit: 7d6661873f6b54c75195780a40d66bad3d482d8f
change-id: 20250610-wdt_reset_reason-7a5afe702075
Best regards,
--
Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v8 1/5] dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram
2026-02-26 16:59 [PATCH v8 0/5] Add support to read the watchdog bootstatus from IMEM Kathiravan Thirumoorthy
@ 2026-02-26 16:59 ` Kathiravan Thirumoorthy
2026-02-27 7:30 ` Krzysztof Kozlowski
2026-02-26 16:59 ` [PATCH v8 2/5] arm64: dts: qcom: ipq5424: Add the IMEM node Kathiravan Thirumoorthy
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Kathiravan Thirumoorthy @ 2026-02-26 16:59 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
Konrad Dybcio, Wim Van Sebroeck, Guenter Roeck, Rajendra Nayak
Cc: linux-arm-msm, devicetree, linux-kernel, linux-watchdog,
Kathiravan Thirumoorthy
IMEM shouldn’t be treated as a syscon or simple-mfd because it’s really
just on‑chip SRAM, not a block of control registers or a device with
multiple hardware functions.
Describing it as generic mmio‑sram keeps the model simple and closer to
what the hardware actually is.
Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
---
Changes in v8:
* Updated the commit with the reasoning to move to mmio-sram
Changes in v7:
* Added the reference link
Changes in v6:
* New patch
---
Documentation/devicetree/bindings/sram/qcom,imem.yaml | 1 -
Documentation/devicetree/bindings/sram/sram.yaml | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sram/qcom,imem.yaml b/Documentation/devicetree/bindings/sram/qcom,imem.yaml
index 6a627c57ae2fecdbb81cae710f6fb5e48156b1f5..72d35e30c439ccf4901d937f838fe7c7a81f33b1 100644
--- a/Documentation/devicetree/bindings/sram/qcom,imem.yaml
+++ b/Documentation/devicetree/bindings/sram/qcom,imem.yaml
@@ -18,7 +18,6 @@ properties:
items:
- enum:
- qcom,apq8064-imem
- - qcom,ipq5424-imem
- qcom,msm8226-imem
- qcom,msm8974-imem
- qcom,msm8976-imem
diff --git a/Documentation/devicetree/bindings/sram/sram.yaml b/Documentation/devicetree/bindings/sram/sram.yaml
index c451140962c86f4e8f98437a2830cb2c6a697e63..7bd24305a8c7d98dc6efad81e72dc8d86d8b212b 100644
--- a/Documentation/devicetree/bindings/sram/sram.yaml
+++ b/Documentation/devicetree/bindings/sram/sram.yaml
@@ -34,6 +34,7 @@ properties:
- nvidia,tegra186-sysram
- nvidia,tegra194-sysram
- nvidia,tegra234-sysram
+ - qcom,ipq5424-imem
- qcom,kaanapali-imem
- qcom,rpm-msg-ram
- rockchip,rk3288-pmu-sram
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v8 2/5] arm64: dts: qcom: ipq5424: Add the IMEM node
2026-02-26 16:59 [PATCH v8 0/5] Add support to read the watchdog bootstatus from IMEM Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 1/5] dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram Kathiravan Thirumoorthy
@ 2026-02-26 16:59 ` Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 3/5] dt-bindings: watchdog: qcom-wdt: Document sram property Kathiravan Thirumoorthy
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Kathiravan Thirumoorthy @ 2026-02-26 16:59 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
Konrad Dybcio, Wim Van Sebroeck, Guenter Roeck, Rajendra Nayak
Cc: linux-arm-msm, devicetree, linux-kernel, linux-watchdog,
Kathiravan Thirumoorthy, Dmitry Baryshkov, Konrad Dybcio
Add the IMEM node to the device tree to extract debugging information
like system restart reason, which is populated via IMEM. Define the
IMEM region to enable this functionality.
As described, overall IMEM region is 112KB but only initial 4KB is
accessible by all masters in the SoC.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
---
Changes in v8:
- Picked up the R-b tag
Changes in v7:
- added the flag 'no-memory-wc'
- Picked up the R-b tag
Changes in v6:
- move to mmio-sram and drop the Konrad's R-b tag
Changes in v5:
- No changes
Changes in v4:
- No changes
Changes in v3:
- Picked up the R-b tag
Changes in v2:
- Describe the entire IMEM region in the node
- Explicitly call out that initial 4K only accessible by all
masters in the commit message
---
arch/arm64/boot/dts/qcom/ipq5424.dtsi | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/ipq5424.dtsi b/arch/arm64/boot/dts/qcom/ipq5424.dtsi
index eb393f3fd728f0b2fc8cd93c849f8c170d76e312..491bc3b00494c47c5524df069e9d65bb4654e863 100644
--- a/arch/arm64/boot/dts/qcom/ipq5424.dtsi
+++ b/arch/arm64/boot/dts/qcom/ipq5424.dtsi
@@ -697,6 +697,17 @@ ssphy_0: phy@7d000 {
status = "disabled";
};
+ sram@8600000 {
+ compatible = "qcom,ipq5424-imem", "mmio-sram";
+ reg = <0 0x08600000 0 0x1c000>;
+ ranges = <0 0 0x08600000 0x1c000>;
+
+ no-memory-wc;
+
+ #address-cells = <1>;
+ #size-cells = <1>;
+ };
+
usb3: usb3@8a00000 {
compatible = "qcom,ipq5424-dwc3", "qcom,dwc3";
reg = <0 0x08af8800 0 0x400>;
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v8 3/5] dt-bindings: watchdog: qcom-wdt: Document sram property
2026-02-26 16:59 [PATCH v8 0/5] Add support to read the watchdog bootstatus from IMEM Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 1/5] dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 2/5] arm64: dts: qcom: ipq5424: Add the IMEM node Kathiravan Thirumoorthy
@ 2026-02-26 16:59 ` Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 4/5] watchdog: qcom: add support to get the bootstatus from IMEM Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 5/5] arm64: dts: qcom: ipq5424: add support to get watchdog " Kathiravan Thirumoorthy
4 siblings, 0 replies; 10+ messages in thread
From: Kathiravan Thirumoorthy @ 2026-02-26 16:59 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
Konrad Dybcio, Wim Van Sebroeck, Guenter Roeck, Rajendra Nayak
Cc: linux-arm-msm, devicetree, linux-kernel, linux-watchdog,
Kathiravan Thirumoorthy
Document the "sram" property for the watchdog device on Qualcomm
IPQ platforms. Use this property to extract the restart reason from
IMEM, which is updated by XBL. Populate the watchdog's bootstatus sysFS
entry with this information, when the system reboots due to a watchdog
timeout.
Describe this property for the IPQ5424 watchdog device and extend support
to other targets subsequently.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
---
Changes in v8:
- no changes
Changes in v7:
- Picked up the R-b tag
Changes in v6:
- Update the 'sram' property to point to the SRAM region
Changes in v5:
- Rename the property 'qcom,imem' to 'sram'
Changes in v4:
- New patch
---
Documentation/devicetree/bindings/watchdog/qcom-wdt.yaml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/watchdog/qcom-wdt.yaml b/Documentation/devicetree/bindings/watchdog/qcom-wdt.yaml
index 9f861045b71e8316ae88f8078a86043a6d04def8..3ead00da3cd6ffa0f6102179565723d4ab6c2929 100644
--- a/Documentation/devicetree/bindings/watchdog/qcom-wdt.yaml
+++ b/Documentation/devicetree/bindings/watchdog/qcom-wdt.yaml
@@ -84,6 +84,12 @@ properties:
minItems: 1
maxItems: 5
+ sram:
+ maxItems: 1
+ description:
+ A reference to an region residing in IMEM(on-chip SRAM), which contains
+ the system restart reason value populated by the bootloader.
+
required:
- compatible
- reg
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v8 4/5] watchdog: qcom: add support to get the bootstatus from IMEM
2026-02-26 16:59 [PATCH v8 0/5] Add support to read the watchdog bootstatus from IMEM Kathiravan Thirumoorthy
` (2 preceding siblings ...)
2026-02-26 16:59 ` [PATCH v8 3/5] dt-bindings: watchdog: qcom-wdt: Document sram property Kathiravan Thirumoorthy
@ 2026-02-26 16:59 ` Kathiravan Thirumoorthy
2026-02-27 7:42 ` Guenter Roeck
2026-02-26 16:59 ` [PATCH v8 5/5] arm64: dts: qcom: ipq5424: add support to get watchdog " Kathiravan Thirumoorthy
4 siblings, 1 reply; 10+ messages in thread
From: Kathiravan Thirumoorthy @ 2026-02-26 16:59 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
Konrad Dybcio, Wim Van Sebroeck, Guenter Roeck, Rajendra Nayak
Cc: linux-arm-msm, devicetree, linux-kernel, linux-watchdog,
Kathiravan Thirumoorthy, Konrad Dybcio
When the system boots up after a watchdog reset, the EXPIRED_STATUS bit
in the WDT_STS register is cleared. To identify if the system was
restarted due to WDT expiry, XBL update the information in the IMEM region.
Update the driver to read the restart reason from IMEM and populate the
bootstatus accordingly.
With the CONFIG_WATCHDOG_SYSFS enabled, user can extract the information
as below:
cat /sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus
32
For backward compatibility, keep the EXPIRED_STATUS bit check. Add a new
function qcom_wdt_get_bootstatus() to read the restart reason from
IMEM.
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
---
Changes in v8:
- Picked up the R-b tag
- Updated the comment as suggested by Konrad
Changes in v7:
- no changes
Changes in v6:
- Reworked to get the restart reason code from SRAM region
Changes in v5:
- Use dev_err_probe instead of dev_err
Changes in v4:
- Kept only WDIOF_CARDRESET and dropped other codes
- Renamed qcom_wdt_get_reason_reason() to
qcom_wdt_get_bootstatus()
- Moved the existing check inside qcom_wdt_get_bootstatus()
- Dropped the device data and put all the details in the DT node
Changes in v3:
- Split the introduction of device data into separate patch
- s/bootloaders/XBL - for clarity of which bootloader is
involved
- Mention the sysfs path on to extract this information
- s/compatible/imem_compatible in the device data structure to
avoid the confusion / better naming
Changes in v2:
- Use the syscon API to access the IMEM region
- Handle the error cases returned by qcom_wdt_get_restart_reason
- Define device specific data to retrieve the IMEM compatible,
offset and the value for non secure WDT, which allows to
extend the support for other SoCs
---
drivers/watchdog/qcom-wdt.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
index dfaac5995c84c1f377023e6e62770c5548528a4c..bbf229a7b5840714b9429f4b092ec3f7a6a26961 100644
--- a/drivers/watchdog/qcom-wdt.c
+++ b/drivers/watchdog/qcom-wdt.c
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/watchdog.h>
@@ -42,6 +43,7 @@ struct qcom_wdt_match_data {
const u32 *offset;
bool pretimeout;
u32 max_tick_count;
+ u32 wdt_reason_val;
};
struct qcom_wdt {
@@ -185,6 +187,7 @@ static const struct qcom_wdt_match_data match_data_ipq5424 = {
.offset = reg_offset_data_kpss,
.pretimeout = true,
.max_tick_count = 0xFFFFFU,
+ .wdt_reason_val = 5,
};
static const struct qcom_wdt_match_data match_data_kpss = {
@@ -193,6 +196,40 @@ static const struct qcom_wdt_match_data match_data_kpss = {
.max_tick_count = 0xFFFFFU,
};
+static int qcom_wdt_get_bootstatus(struct device *dev, struct qcom_wdt *wdt,
+ u32 val)
+{
+ struct device_node *imem;
+ struct resource res;
+ void __iomem *addr;
+ int ret;
+
+ imem = of_parse_phandle(dev->of_node, "sram", 0);
+ if (!imem) {
+ /* Read the EXPIRED_STATUS bit as a fallback */
+ if (readl(wdt_addr(wdt, WDT_STS)) & 1)
+ wdt->wdd.bootstatus = WDIOF_CARDRESET;
+
+ return 0;
+ }
+
+ ret = of_address_to_resource(imem, 0, &res);
+ of_node_put(imem);
+ if (ret)
+ return ret;
+
+ addr = ioremap(res.start, resource_size(&res));
+ if (!addr)
+ return -ENOMEM;
+
+ if (readl(addr) == val)
+ wdt->wdd.bootstatus = WDIOF_CARDRESET;
+
+ iounmap(addr);
+
+ return 0;
+}
+
static int qcom_wdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -273,8 +310,9 @@ static int qcom_wdt_probe(struct platform_device *pdev)
wdt->wdd.parent = dev;
wdt->layout = data->offset;
- if (readl(wdt_addr(wdt, WDT_STS)) & 1)
- wdt->wdd.bootstatus = WDIOF_CARDRESET;
+ ret = qcom_wdt_get_bootstatus(dev, wdt, data->wdt_reason_val);
+ if (ret)
+ return ret;
/*
* If 'timeout-sec' unspecified in devicetree, assume a 30 second
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v8 5/5] arm64: dts: qcom: ipq5424: add support to get watchdog bootstatus from IMEM
2026-02-26 16:59 [PATCH v8 0/5] Add support to read the watchdog bootstatus from IMEM Kathiravan Thirumoorthy
` (3 preceding siblings ...)
2026-02-26 16:59 ` [PATCH v8 4/5] watchdog: qcom: add support to get the bootstatus from IMEM Kathiravan Thirumoorthy
@ 2026-02-26 16:59 ` Kathiravan Thirumoorthy
4 siblings, 0 replies; 10+ messages in thread
From: Kathiravan Thirumoorthy @ 2026-02-26 16:59 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
Konrad Dybcio, Wim Van Sebroeck, Guenter Roeck, Rajendra Nayak
Cc: linux-arm-msm, devicetree, linux-kernel, linux-watchdog,
Kathiravan Thirumoorthy, Dmitry Baryshkov, Konrad Dybcio
Add the "sram" property to the watchdog device node to enable
retrieval of the system restart reason from IMEM, populated by XBL.
Parse this information in the watchdog driver and update the bootstatus
sysFS if the restart was triggered by a watchdog timeout.
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
---
Changes in v8:
- Picked up the R-b tag
Changes in v7:
- Picked up the R-b tag
Changes in v6:
- Update the 'sram' property to point to the SRAM region
Changes in v5:
- Rename the property 'qcom,imem' to 'sram'
Changes in v4:
- New patch
---
arch/arm64/boot/dts/qcom/ipq5424.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/ipq5424.dtsi b/arch/arm64/boot/dts/qcom/ipq5424.dtsi
index 491bc3b00494c47c5524df069e9d65bb4654e863..86de974949f48269170a2bfbeb64214d37fbe488 100644
--- a/arch/arm64/boot/dts/qcom/ipq5424.dtsi
+++ b/arch/arm64/boot/dts/qcom/ipq5424.dtsi
@@ -591,6 +591,7 @@ watchdog@f410000 {
reg = <0 0x0f410000 0 0x1000>;
interrupts = <GIC_SPI 0 IRQ_TYPE_EDGE_RISING>;
clocks = <&sleep_clk>;
+ sram = <&restart_reason>;
};
qusb_phy_1: phy@71000 {
@@ -706,6 +707,10 @@ sram@8600000 {
#address-cells = <1>;
#size-cells = <1>;
+
+ restart_reason: restartreason-sram@7b0 {
+ reg = <0x7b0 0x4>;
+ };
};
usb3: usb3@8a00000 {
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 1/5] dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram
2026-02-26 16:59 ` [PATCH v8 1/5] dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram Kathiravan Thirumoorthy
@ 2026-02-27 7:30 ` Krzysztof Kozlowski
0 siblings, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2026-02-27 7:30 UTC (permalink / raw)
To: Kathiravan Thirumoorthy
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
Konrad Dybcio, Wim Van Sebroeck, Guenter Roeck, Rajendra Nayak,
linux-arm-msm, devicetree, linux-kernel, linux-watchdog
On Thu, Feb 26, 2026 at 10:29:36PM +0530, Kathiravan Thirumoorthy wrote:
> IMEM shouldn’t be treated as a syscon or simple-mfd because it’s really
> just on‑chip SRAM, not a block of control registers or a device with
> multiple hardware functions.
>
> Describing it as generic mmio‑sram keeps the model simple and closer to
> what the hardware actually is.
>
> Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
> ---
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 4/5] watchdog: qcom: add support to get the bootstatus from IMEM
2026-02-26 16:59 ` [PATCH v8 4/5] watchdog: qcom: add support to get the bootstatus from IMEM Kathiravan Thirumoorthy
@ 2026-02-27 7:42 ` Guenter Roeck
2026-02-27 9:35 ` Kathiravan Thirumoorthy
2026-02-27 11:00 ` Konrad Dybcio
0 siblings, 2 replies; 10+ messages in thread
From: Guenter Roeck @ 2026-02-27 7:42 UTC (permalink / raw)
To: Kathiravan Thirumoorthy, Rob Herring, Krzysztof Kozlowski,
Conor Dooley, Bjorn Andersson, Konrad Dybcio, Wim Van Sebroeck,
Rajendra Nayak
Cc: linux-arm-msm, devicetree, linux-kernel, linux-watchdog, Konrad Dybcio
On 2/26/26 08:59, Kathiravan Thirumoorthy wrote:
> When the system boots up after a watchdog reset, the EXPIRED_STATUS bit
> in the WDT_STS register is cleared. To identify if the system was
> restarted due to WDT expiry, XBL update the information in the IMEM region.
> Update the driver to read the restart reason from IMEM and populate the
> bootstatus accordingly.
>
> With the CONFIG_WATCHDOG_SYSFS enabled, user can extract the information
> as below:
>
> cat /sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus
> 32
>
> For backward compatibility, keep the EXPIRED_STATUS bit check. Add a new
> function qcom_wdt_get_bootstatus() to read the restart reason from
> IMEM.
>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
> Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
> ---
> Changes in v8:
> - Picked up the R-b tag
> - Updated the comment as suggested by Konrad
> Changes in v7:
> - no changes
> Changes in v6:
> - Reworked to get the restart reason code from SRAM region
>
> Changes in v5:
> - Use dev_err_probe instead of dev_err
>
> Changes in v4:
> - Kept only WDIOF_CARDRESET and dropped other codes
> - Renamed qcom_wdt_get_reason_reason() to
> qcom_wdt_get_bootstatus()
> - Moved the existing check inside qcom_wdt_get_bootstatus()
> - Dropped the device data and put all the details in the DT node
>
> Changes in v3:
> - Split the introduction of device data into separate patch
> - s/bootloaders/XBL - for clarity of which bootloader is
> involved
> - Mention the sysfs path on to extract this information
> - s/compatible/imem_compatible in the device data structure to
> avoid the confusion / better naming
>
> Changes in v2:
> - Use the syscon API to access the IMEM region
> - Handle the error cases returned by qcom_wdt_get_restart_reason
> - Define device specific data to retrieve the IMEM compatible,
> offset and the value for non secure WDT, which allows to
> extend the support for other SoCs
> ---
> drivers/watchdog/qcom-wdt.c | 42 ++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
> index dfaac5995c84c1f377023e6e62770c5548528a4c..bbf229a7b5840714b9429f4b092ec3f7a6a26961 100644
> --- a/drivers/watchdog/qcom-wdt.c
> +++ b/drivers/watchdog/qcom-wdt.c
> @@ -9,6 +9,7 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/of.h>
> +#include <linux/of_address.h>
> #include <linux/platform_device.h>
> #include <linux/watchdog.h>
>
> @@ -42,6 +43,7 @@ struct qcom_wdt_match_data {
> const u32 *offset;
> bool pretimeout;
> u32 max_tick_count;
> + u32 wdt_reason_val;
> };
>
> struct qcom_wdt {
> @@ -185,6 +187,7 @@ static const struct qcom_wdt_match_data match_data_ipq5424 = {
> .offset = reg_offset_data_kpss,
> .pretimeout = true,
> .max_tick_count = 0xFFFFFU,
> + .wdt_reason_val = 5,
> };
>
> static const struct qcom_wdt_match_data match_data_kpss = {
> @@ -193,6 +196,40 @@ static const struct qcom_wdt_match_data match_data_kpss = {
> .max_tick_count = 0xFFFFFU,
> };
>
> +static int qcom_wdt_get_bootstatus(struct device *dev, struct qcom_wdt *wdt,
> + u32 val)
> +{
> + struct device_node *imem;
> + struct resource res;
> + void __iomem *addr;
> + int ret;
> +
> + imem = of_parse_phandle(dev->of_node, "sram", 0);
> + if (!imem) {
> + /* Read the EXPIRED_STATUS bit as a fallback */
> + if (readl(wdt_addr(wdt, WDT_STS)) & 1)
> + wdt->wdd.bootstatus = WDIOF_CARDRESET;
> +
> + return 0;
> + }
> +
> + ret = of_address_to_resource(imem, 0, &res);
> + of_node_put(imem);
> + if (ret)
> + return ret;
> +
> + addr = ioremap(res.start, resource_size(&res));
> + if (!addr)
> + return -ENOMEM;
> +
> + if (readl(addr) == val)
> + wdt->wdd.bootstatus = WDIOF_CARDRESET;
> +
> + iounmap(addr);
> +
> + return 0;
> +}
> +
> static int qcom_wdt_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -273,8 +310,9 @@ static int qcom_wdt_probe(struct platform_device *pdev)
> wdt->wdd.parent = dev;
> wdt->layout = data->offset;
>
> - if (readl(wdt_addr(wdt, WDT_STS)) & 1)
> - wdt->wdd.bootstatus = WDIOF_CARDRESET;
> + ret = qcom_wdt_get_bootstatus(dev, wdt, data->wdt_reason_val);
> + if (ret)
> + return ret;
>
Why is reporting the boot status so important that the failure to read it
results in refusing to instantiate the driver ? That warrants a detailed
explanation, even more so since it is not backward compatible.
Guenter
> /*
> * If 'timeout-sec' unspecified in devicetree, assume a 30 second
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 4/5] watchdog: qcom: add support to get the bootstatus from IMEM
2026-02-27 7:42 ` Guenter Roeck
@ 2026-02-27 9:35 ` Kathiravan Thirumoorthy
2026-02-27 11:00 ` Konrad Dybcio
1 sibling, 0 replies; 10+ messages in thread
From: Kathiravan Thirumoorthy @ 2026-02-27 9:35 UTC (permalink / raw)
To: Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Bjorn Andersson, Konrad Dybcio, Wim Van Sebroeck, Rajendra Nayak
Cc: linux-arm-msm, devicetree, linux-kernel, linux-watchdog, Konrad Dybcio
On 2/27/2026 1:12 PM, Guenter Roeck wrote:
>> - if (readl(wdt_addr(wdt, WDT_STS)) & 1)
>> - wdt->wdd.bootstatus = WDIOF_CARDRESET;
>> + ret = qcom_wdt_get_bootstatus(dev, wdt, data->wdt_reason_val);
>> + if (ret)
>> + return ret;
>
> Why is reporting the boot status so important that the failure to read it
> results in refusing to instantiate the driver ? That warrants a detailed
> explanation, even more so since it is not backward compatible.
Ack. Let me just log the error message and continue the probe.
>
> Guenter
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 4/5] watchdog: qcom: add support to get the bootstatus from IMEM
2026-02-27 7:42 ` Guenter Roeck
2026-02-27 9:35 ` Kathiravan Thirumoorthy
@ 2026-02-27 11:00 ` Konrad Dybcio
1 sibling, 0 replies; 10+ messages in thread
From: Konrad Dybcio @ 2026-02-27 11:00 UTC (permalink / raw)
To: Guenter Roeck, Kathiravan Thirumoorthy, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Bjorn Andersson,
Konrad Dybcio, Wim Van Sebroeck, Rajendra Nayak
Cc: linux-arm-msm, devicetree, linux-kernel, linux-watchdog
On 2/27/26 8:42 AM, Guenter Roeck wrote:
> On 2/26/26 08:59, Kathiravan Thirumoorthy wrote:
>> When the system boots up after a watchdog reset, the EXPIRED_STATUS bit
>> in the WDT_STS register is cleared. To identify if the system was
>> restarted due to WDT expiry, XBL update the information in the IMEM region.
>> Update the driver to read the restart reason from IMEM and populate the
>> bootstatus accordingly.
>>
>> With the CONFIG_WATCHDOG_SYSFS enabled, user can extract the information
>> as below:
>>
>> cat /sys/devices/platform/soc@0/f410000.watchdog/watchdog/watchdog0/bootstatus
>> 32
>>
>> For backward compatibility, keep the EXPIRED_STATUS bit check. Add a new
>> function qcom_wdt_get_bootstatus() to read the restart reason from
>> IMEM.
>>
>> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
>> Signed-off-by: Kathiravan Thirumoorthy <kathiravan.thirumoorthy@oss.qualcomm.com>
>> ---
>> Changes in v8:
>> - Picked up the R-b tag
>> - Updated the comment as suggested by Konrad
>> Changes in v7:
>> - no changes
>> Changes in v6:
>> - Reworked to get the restart reason code from SRAM region
>>
>> Changes in v5:
>> - Use dev_err_probe instead of dev_err
>>
>> Changes in v4:
>> - Kept only WDIOF_CARDRESET and dropped other codes
>> - Renamed qcom_wdt_get_reason_reason() to
>> qcom_wdt_get_bootstatus()
>> - Moved the existing check inside qcom_wdt_get_bootstatus()
>> - Dropped the device data and put all the details in the DT node
>>
>> Changes in v3:
>> - Split the introduction of device data into separate patch
>> - s/bootloaders/XBL - for clarity of which bootloader is
>> involved
>> - Mention the sysfs path on to extract this information
>> - s/compatible/imem_compatible in the device data structure to
>> avoid the confusion / better naming
>>
>> Changes in v2:
>> - Use the syscon API to access the IMEM region
>> - Handle the error cases returned by qcom_wdt_get_restart_reason
>> - Define device specific data to retrieve the IMEM compatible,
>> offset and the value for non secure WDT, which allows to
>> extend the support for other SoCs
>> ---
>> drivers/watchdog/qcom-wdt.c | 42 ++++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 40 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
>> index dfaac5995c84c1f377023e6e62770c5548528a4c..bbf229a7b5840714b9429f4b092ec3f7a6a26961 100644
>> --- a/drivers/watchdog/qcom-wdt.c
>> +++ b/drivers/watchdog/qcom-wdt.c
>> @@ -9,6 +9,7 @@
>> #include <linux/kernel.h>
>> #include <linux/module.h>
>> #include <linux/of.h>
>> +#include <linux/of_address.h>
>> #include <linux/platform_device.h>
>> #include <linux/watchdog.h>
>> @@ -42,6 +43,7 @@ struct qcom_wdt_match_data {
>> const u32 *offset;
>> bool pretimeout;
>> u32 max_tick_count;
>> + u32 wdt_reason_val;
>> };
>> struct qcom_wdt {
>> @@ -185,6 +187,7 @@ static const struct qcom_wdt_match_data match_data_ipq5424 = {
>> .offset = reg_offset_data_kpss,
>> .pretimeout = true,
>> .max_tick_count = 0xFFFFFU,
>> + .wdt_reason_val = 5,
>> };
>> static const struct qcom_wdt_match_data match_data_kpss = {
>> @@ -193,6 +196,40 @@ static const struct qcom_wdt_match_data match_data_kpss = {
>> .max_tick_count = 0xFFFFFU,
>> };
>> +static int qcom_wdt_get_bootstatus(struct device *dev, struct qcom_wdt *wdt,
>> + u32 val)
>> +{
>> + struct device_node *imem;
>> + struct resource res;
>> + void __iomem *addr;
>> + int ret;
>> +
>> + imem = of_parse_phandle(dev->of_node, "sram", 0);
>> + if (!imem) {
>> + /* Read the EXPIRED_STATUS bit as a fallback */
>> + if (readl(wdt_addr(wdt, WDT_STS)) & 1)
>> + wdt->wdd.bootstatus = WDIOF_CARDRESET;
>> +
>> + return 0;
>> + }
>> +
>> + ret = of_address_to_resource(imem, 0, &res);
>> + of_node_put(imem);
>> + if (ret)
>> + return ret;
>> +
>> + addr = ioremap(res.start, resource_size(&res));
>> + if (!addr)
>> + return -ENOMEM;
>> +
>> + if (readl(addr) == val)
>> + wdt->wdd.bootstatus = WDIOF_CARDRESET;
>> +
>> + iounmap(addr);
>> +
>> + return 0;
>> +}
>> +
>> static int qcom_wdt_probe(struct platform_device *pdev)
>> {
>> struct device *dev = &pdev->dev;
>> @@ -273,8 +310,9 @@ static int qcom_wdt_probe(struct platform_device *pdev)
>> wdt->wdd.parent = dev;
>> wdt->layout = data->offset;
>> - if (readl(wdt_addr(wdt, WDT_STS)) & 1)
>> - wdt->wdd.bootstatus = WDIOF_CARDRESET;
>> + ret = qcom_wdt_get_bootstatus(dev, wdt, data->wdt_reason_val);
>> + if (ret)
>> + return ret;
>>
>
> Why is reporting the boot status so important that the failure to read it
> results in refusing to instantiate the driver ? That warrants a detailed
> explanation, even more so since it is not backward compatible.
This only fails if the reference passed in the new 'sram' property is present,
but invalid
Konrad
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-02-27 11:01 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-26 16:59 [PATCH v8 0/5] Add support to read the watchdog bootstatus from IMEM Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 1/5] dt-bindings: sram: describe the IPQ5424 IMEM as mmio-sram Kathiravan Thirumoorthy
2026-02-27 7:30 ` Krzysztof Kozlowski
2026-02-26 16:59 ` [PATCH v8 2/5] arm64: dts: qcom: ipq5424: Add the IMEM node Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 3/5] dt-bindings: watchdog: qcom-wdt: Document sram property Kathiravan Thirumoorthy
2026-02-26 16:59 ` [PATCH v8 4/5] watchdog: qcom: add support to get the bootstatus from IMEM Kathiravan Thirumoorthy
2026-02-27 7:42 ` Guenter Roeck
2026-02-27 9:35 ` Kathiravan Thirumoorthy
2026-02-27 11:00 ` Konrad Dybcio
2026-02-26 16:59 ` [PATCH v8 5/5] arm64: dts: qcom: ipq5424: add support to get watchdog " Kathiravan Thirumoorthy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®