* [PATCH v5 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET
2023-07-17 6:41 [PATCH v5 0/3] Add support for WDIOF_CARDRESET on TI AM65x huaqian.li
@ 2023-07-17 6:41 ` huaqian.li
2023-07-17 13:26 ` Guenter Roeck
2023-07-17 6:41 ` [DONOTMERGE PATCH v5 2/3] arm64: dts: ti: Add reserved memory for watchdog huaqian.li
2023-07-17 6:41 ` [PATCH v5 3/3] watchdog:rit_wdt: Add support for WDIOF_CARDRESET huaqian.li
2 siblings, 1 reply; 5+ messages in thread
From: huaqian.li @ 2023-07-17 6:41 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su,
Li Hua Qian
From: Li Hua Qian <huaqian.li@siemens.com>
TI RTI (Real Time Interrupt) Watchdog doesn't support to record the
watchdog cause. Add a reserved memory to know the last reboot was caused
by the watchdog card. In the reserved memory, some specific info will be
saved to indicate whether the watchdog reset was triggered in last
boot.
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
---
.../bindings/watchdog/ti,rti-wdt.yaml | 41 +++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml b/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml
index fc553211e42d..4b66c4fcdf35 100644
--- a/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml
+++ b/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml
@@ -34,6 +34,20 @@ properties:
power-domains:
maxItems: 1
+ memory-region:
+ maxItems: 1
+ description:
+ Contains the watchdog reserved memory. It is optional.
+ In the reserved memory, the specified values, which are
+ PON_REASON_SOF_NUM(0xBBBBCCCC), PON_REASON_MAGIC_NUM(0xDDDDDDDD),
+ and PON_REASON_EOF_NUM(0xCCCCBBBB), are pre-stored at the first
+ 3 * 4 bytes to tell that last boot was caused by watchdog reset.
+ Once the PON reason is captured by driver(rti_wdt.c), the driver
+ is supposed to wipe the whole memory region. Surely, if this
+ property is set, at least 12 bytes reserved memory starting from
+ specific memory address(0xa220000) should be set. More please
+ refer to Example 2.
+
required:
- compatible
- reg
@@ -59,3 +73,30 @@ examples:
assigned-clocks = <&k3_clks 252 1>;
assigned-clock-parents = <&k3_clks 252 5>;
};
+
+ - |
+ // Example 2 (Add reserved memory for watchdog reset cause):
+ /*
+ * RTI WDT in main domain on J721e SoC. Assigned clocks are used to
+ * select the source clock for the watchdog, forcing it to tick with
+ * a 32kHz clock in this case. Add a reserved memory to keep the
+ * watchdog reset cause persistent, which was be written in 12 bytes
+ * starting from 0xa2200000 by RTI Watchdog Firmware.
+ *
+ * Reserved memory should be defined as follows:
+ * reserved-memory {
+ * wdt_reset_memory_region: wdt-memory@a2200000 {
+ * reg = <0x00 0xa2200000 0x00 0x1000>;
+ * no-map;
+ * };
+ * }
+ */
+ watchdog@40610000 {
+ compatible = "ti,j7-rti-wdt";
+ reg = <0x40610000 0x100>;
+ clocks = <&k3_clks 135 1>;
+ power-domains = <&k3_pds 135 TI_SCI_PD_EXCLUSIVE>;
+ assigned-clocks = <&k3_clks 135 0>;
+ assigned-clock-parents = <&k3_clks 135 4>;
+ memory-region = <&wdt_reset_memory_region>;
+ };
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v5 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET
2023-07-17 6:41 ` [PATCH v5 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET huaqian.li
@ 2023-07-17 13:26 ` Guenter Roeck
0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2023-07-17 13:26 UTC (permalink / raw)
To: huaqian.li, wim, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su
On 7/16/23 23:41, huaqian.li@siemens.com wrote:
> From: Li Hua Qian <huaqian.li@siemens.com>
>
> TI RTI (Real Time Interrupt) Watchdog doesn't support to record the
> watchdog cause. Add a reserved memory to know the last reboot was caused
> by the watchdog card. In the reserved memory, some specific info will be
> saved to indicate whether the watchdog reset was triggered in last
> boot.
>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Drop that. I did not realize you cheated, and I was just trying
to match the other (apparently fake) Reviewed-by: tags.
Guenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* [DONOTMERGE PATCH v5 2/3] arm64: dts: ti: Add reserved memory for watchdog
2023-07-17 6:41 [PATCH v5 0/3] Add support for WDIOF_CARDRESET on TI AM65x huaqian.li
2023-07-17 6:41 ` [PATCH v5 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET huaqian.li
@ 2023-07-17 6:41 ` huaqian.li
2023-07-17 6:41 ` [PATCH v5 3/3] watchdog:rit_wdt: Add support for WDIOF_CARDRESET huaqian.li
2 siblings, 0 replies; 5+ messages in thread
From: huaqian.li @ 2023-07-17 6:41 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su,
Li Hua Qian
From: Li Hua Qian <huaqian.li@siemens.com>
This patch adds a reserved memory for the TI AM65X platform watchdog to
reserve the specific info, triggering the watchdog reset in last boot,
to know if the board reboot is due to a watchdog reset.
Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
---
arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi
index e26bd988e522..4bb20d493651 100644
--- a/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi
+++ b/arch/arm64/boot/dts/ti/k3-am65-iot2050-common.dtsi
@@ -63,6 +63,12 @@ rtos_ipc_memory_region: ipc-memories@a2000000 {
alignment = <0x1000>;
no-map;
};
+
+ /* To reserve the power-on(PON) reason for watchdog reset */
+ wdt_reset_memory_region: wdt-memory@a2200000 {
+ reg = <0x00 0xa2200000 0x00 0x1000>;
+ no-map;
+ };
};
leds {
@@ -718,3 +724,7 @@ &mcu_r5fss0_core1 {
<&mcu_r5fss0_core1_memory_region>;
mboxes = <&mailbox0_cluster1>, <&mbox_mcu_r5fss0_core1>;
};
+
+&mcu_rti1 {
+ memory-region = <&wdt_reset_memory_region>;
+};
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v5 3/3] watchdog:rit_wdt: Add support for WDIOF_CARDRESET
2023-07-17 6:41 [PATCH v5 0/3] Add support for WDIOF_CARDRESET on TI AM65x huaqian.li
2023-07-17 6:41 ` [PATCH v5 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET huaqian.li
2023-07-17 6:41 ` [DONOTMERGE PATCH v5 2/3] arm64: dts: ti: Add reserved memory for watchdog huaqian.li
@ 2023-07-17 6:41 ` huaqian.li
2 siblings, 0 replies; 5+ messages in thread
From: huaqian.li @ 2023-07-17 6:41 UTC (permalink / raw)
To: wim, linux, robh+dt, krzysztof.kozlowski+dt, conor+dt
Cc: huaqianlee, nm, vigneshr, kristo, linux-watchdog, devicetree,
linux-kernel, linux-arm-kernel, jan.kiszka, baocheng.su,
Li Hua Qian
From: Li Hua Qian <huaqian.li@siemens.com>
This patch adds the WDIOF_CARDRESET support for the platform watchdog
whose hardware does not support this feature, to know if the board
reboot is due to a watchdog reset.
This is done via reserved memory(RAM), which indicates if specific
info saved, triggering the watchdog reset in last boot.
Signed-off-by: Li Hua Qian <huaqian.li@siemens.com>
---
drivers/watchdog/rti_wdt.c | 48 ++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
index ce8f18e93aa9..901109d979f0 100644
--- a/drivers/watchdog/rti_wdt.c
+++ b/drivers/watchdog/rti_wdt.c
@@ -14,6 +14,8 @@
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/types.h>
@@ -52,6 +54,11 @@
#define DWDST BIT(1)
+#define PON_REASON_SOF_NUM 0xBBBBCCCC
+#define PON_REASON_MAGIC_NUM 0xDDDDDDDD
+#define PON_REASON_EOF_NUM 0xCCCCBBBB
+#define RESERVED_MEM_MIN_SIZE 12
+
static int heartbeat = DEFAULT_HEARTBEAT;
/*
@@ -198,6 +205,11 @@ static int rti_wdt_probe(struct platform_device *pdev)
struct rti_wdt_device *wdt;
struct clk *clk;
u32 last_ping = 0;
+ struct device_node *node;
+ u32 reserved_mem_size;
+ struct resource res;
+ u32 *vaddr;
+ u64 paddr;
wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
if (!wdt)
@@ -284,6 +296,42 @@ static int rti_wdt_probe(struct platform_device *pdev)
}
}
+ node = of_parse_phandle(pdev->dev.of_node, "memory-region", 0);
+ if (node) {
+ ret = of_address_to_resource(node, 0, &res);
+ if (ret) {
+ dev_err(dev, "No memory address assigned to the region.\n");
+ goto err_iomap;
+ }
+
+ /*
+ * If reserved memory is defined for watchdog reset cause.
+ * Readout the Power-on(PON) reason and pass to bootstatus.
+ */
+ paddr = res.start;
+ reserved_mem_size = resource_size(&res);
+ if (reserved_mem_size < RESERVED_MEM_MIN_SIZE) {
+ dev_err(dev, "The size of reserved memory is too small.\n");
+ ret = -EINVAL;
+ goto err_iomap;
+ }
+
+ vaddr = memremap(paddr, reserved_mem_size, MEMREMAP_WB);
+ if (vaddr == NULL) {
+ dev_err(dev, "Failed to map memory-region.\n");
+ ret = -ENOMEM;
+ goto err_iomap;
+ }
+
+ if (vaddr[0] == PON_REASON_SOF_NUM &&
+ vaddr[1] == PON_REASON_MAGIC_NUM &&
+ vaddr[2] == PON_REASON_EOF_NUM) {
+ wdd->bootstatus |= WDIOF_CARDRESET;
+ }
+ memset(vaddr, 0, reserved_mem_size);
+ memunmap(vaddr);
+ }
+
watchdog_init_timeout(wdd, heartbeat, dev);
ret = watchdog_register_device(wdd);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread