From nobody Fri Sep 5 08:00:20 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46D3EEB64DC for ; Tue, 18 Jul 2023 02:12:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229969AbjGRCMN (ORCPT ); Mon, 17 Jul 2023 22:12:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbjGRCML (ORCPT ); Mon, 17 Jul 2023 22:12:11 -0400 Received: from mta-65-227.siemens.flowmailer.net (mta-65-227.siemens.flowmailer.net [185.136.65.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C166718B for ; Mon, 17 Jul 2023 19:12:10 -0700 (PDT) Received: by mta-65-227.siemens.flowmailer.net with ESMTPSA id 20230718021208943314f10d940433bd for ; Tue, 18 Jul 2023 04:12:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=huaqian.li@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=vEfG2f2hKFjYPDbtni2Sf1EWNty8c+MQ8mKXu1AGvg4=; b=FbaaJlzbyMrzBrhY5dASym6cN28TZwgAH66Fb22taNFT4Sb4nkLkQI+HVfpPLAwRlH0KMw NUz4W+21tgSLaeyZcq70UKaATlwVEUPkg7UYg5rHJXu30/ftL28AIRcpQB9ZGf/LYqzxhZc0 4f9T5WMIqEv3GVHIernqriojWv6lk=; From: huaqian.li@siemens.com To: wim@linux-watchdog.org, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: huaqianlee@gmail.com, nm@ti.com, vigneshr@ti.com, kristo@kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jan.kiszka@siemens.com, baocheng.su@siemens.com, Li Hua Qian Subject: [PATCH v6 1/3] dt-bindings: watchdog: ti,rti-wdt: Add support for WDIOF_CARDRESET Date: Tue, 18 Jul 2023 10:10:05 +0800 Message-Id: <20230718021007.1338761-2-huaqian.li@siemens.com> In-Reply-To: <20230718021007.1338761-1-huaqian.li@siemens.com> References: <20230718021007.1338761-1-huaqian.li@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-959203:519-21489:flowmailer Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Li Hua Qian 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. Signed-off-by: Li Hua Qian Reviewed-by: Guenter Roeck Reviewed-by: Krzysztof Kozlowski --- .../bindings/watchdog/ti,rti-wdt.yaml | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml b/D= ocumentation/devicetree/bindings/watchdog/ti,rti-wdt.yaml index fc553211e42d..9d847e4b7278 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 =20 + 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. + required: - compatible - reg @@ -47,7 +61,18 @@ examples: /* * 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. + * a 32kHz clock in this case. Add a reserved memory(optional) to keep + * the watchdog reset cause persistent, which was be written in 12 byt= es + * starting from 0xa2200000 by RTI Watchdog Firmware, then make it + * possible to get watchdog reset cause in driver. + * + * Reserved memory should be defined as follows: + * reserved-memory { + * wdt_reset_memory_region: wdt-memory@a2200000 { + * reg =3D <0x00 0xa2200000 0x00 0x1000>; + * no-map; + * }; + * } */ #include =20 @@ -58,4 +83,5 @@ examples: power-domains =3D <&k3_pds 252 TI_SCI_PD_EXCLUSIVE>; assigned-clocks =3D <&k3_clks 252 1>; assigned-clock-parents =3D <&k3_clks 252 5>; + memory-region =3D <&wdt_reset_memory_region>; }; --=20 2.34.1 From nobody Fri Sep 5 08:00:20 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 390FFC001B0 for ; Tue, 18 Jul 2023 02:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229892AbjGRCMT (ORCPT ); Mon, 17 Jul 2023 22:12:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230103AbjGRCMR (ORCPT ); Mon, 17 Jul 2023 22:12:17 -0400 Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net [185.136.64.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1EF410E0 for ; Mon, 17 Jul 2023 19:12:15 -0700 (PDT) Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 202307180212139b6b46617cc0756d13 for ; Tue, 18 Jul 2023 04:12:13 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=huaqian.li@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=jnvC6oqf7550vuX04Y+Pl19iCeyz3P0LnhYgz2I4V6w=; b=j+Qe5PJS31fRn683lpJIQoCf3lVQHyH1rI9C9O77mw7id+Ojb4ij/svhJzm0NRaxDwab5v +9dnLpZufmMg7OefG4RuRquUaYrQ2K6bahLScPMHRSGOWirZSwiF4+r/xXSiqM2UmH5Fi/SD HSMUGzsvOR38JSzkvS0qpAX8sn9Yw=; From: huaqian.li@siemens.com To: wim@linux-watchdog.org, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: huaqianlee@gmail.com, nm@ti.com, vigneshr@ti.com, kristo@kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jan.kiszka@siemens.com, baocheng.su@siemens.com, Li Hua Qian Subject: [DONOTMERGE PATCH v6 2/3] arm64: dts: ti: Add reserved memory for watchdog Date: Tue, 18 Jul 2023 10:10:06 +0800 Message-Id: <20230718021007.1338761-3-huaqian.li@siemens.com> In-Reply-To: <20230718021007.1338761-1-huaqian.li@siemens.com> References: <20230718021007.1338761-1-huaqian.li@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-959203:519-21489:flowmailer Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Li Hua Qian 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 --- 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/arm6= 4/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 =3D <0x1000>; no-map; }; + + /* To reserve the power-on(PON) reason for watchdog reset */ + wdt_reset_memory_region: wdt-memory@a2200000 { + reg =3D <0x00 0xa2200000 0x00 0x1000>; + no-map; + }; }; =20 leds { @@ -718,3 +724,7 @@ &mcu_r5fss0_core1 { <&mcu_r5fss0_core1_memory_region>; mboxes =3D <&mailbox0_cluster1>, <&mbox_mcu_r5fss0_core1>; }; + +&mcu_rti1 { + memory-region =3D <&wdt_reset_memory_region>; +}; --=20 2.34.1 From nobody Fri Sep 5 08:00:20 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1B34C001DE for ; Tue, 18 Jul 2023 02:12:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbjGRCM0 (ORCPT ); Mon, 17 Jul 2023 22:12:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230298AbjGRCMW (ORCPT ); Mon, 17 Jul 2023 22:12:22 -0400 Received: from mta-64-226.siemens.flowmailer.net (mta-64-226.siemens.flowmailer.net [185.136.64.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79B4810F1 for ; Mon, 17 Jul 2023 19:12:19 -0700 (PDT) Received: by mta-64-226.siemens.flowmailer.net with ESMTPSA id 2023071802121993074d7e6a82316320 for ; Tue, 18 Jul 2023 04:12:19 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=huaqian.li@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=P+e4mgQf7YcgATPvUbBvEm5Pd72/FjOAYEsp6bDRqIE=; b=nm92q4mscd4W1AyCnXiVJxwBNnOnefvJdnm4dUNuN6aE2WOJfFs/Q1YaFxQi1LYNe+Pehe C5p3DPvwNrd++0fn0+jdZj7EktIhuvqG5GIPmS+XCfJ/o5ebvrMYqzvTeJwDMUVQuFIc6H26 kD6vPVYTfqeJ6Orkj4A+8yHBeMX4Y=; From: huaqian.li@siemens.com To: wim@linux-watchdog.org, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org Cc: huaqianlee@gmail.com, nm@ti.com, vigneshr@ti.com, kristo@kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jan.kiszka@siemens.com, baocheng.su@siemens.com, Li Hua Qian Subject: [PATCH v6 3/3] watchdog:rit_wdt: Add support for WDIOF_CARDRESET Date: Tue, 18 Jul 2023 10:10:07 +0800 Message-Id: <20230718021007.1338761-4-huaqian.li@siemens.com> In-Reply-To: <20230718021007.1338761-1-huaqian.li@siemens.com> References: <20230718021007.1338761-1-huaqian.li@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-959203:519-21489:flowmailer Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Li Hua Qian 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 Reviewed-by: Guenter Roeck --- 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 #include #include +#include +#include #include #include #include @@ -52,6 +54,11 @@ =20 #define DWDST BIT(1) =20 +#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 =3D DEFAULT_HEARTBEAT; =20 /* @@ -198,6 +205,11 @@ static int rti_wdt_probe(struct platform_device *pdev) struct rti_wdt_device *wdt; struct clk *clk; u32 last_ping =3D 0; + struct device_node *node; + u32 reserved_mem_size; + struct resource res; + u32 *vaddr; + u64 paddr; =20 wdt =3D devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) @@ -284,6 +296,42 @@ static int rti_wdt_probe(struct platform_device *pdev) } } =20 + node =3D of_parse_phandle(pdev->dev.of_node, "memory-region", 0); + if (node) { + ret =3D 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 =3D res.start; + reserved_mem_size =3D resource_size(&res); + if (reserved_mem_size < RESERVED_MEM_MIN_SIZE) { + dev_err(dev, "The size of reserved memory is too small.\n"); + ret =3D -EINVAL; + goto err_iomap; + } + + vaddr =3D memremap(paddr, reserved_mem_size, MEMREMAP_WB); + if (vaddr =3D=3D NULL) { + dev_err(dev, "Failed to map memory-region.\n"); + ret =3D -ENOMEM; + goto err_iomap; + } + + if (vaddr[0] =3D=3D PON_REASON_SOF_NUM && + vaddr[1] =3D=3D PON_REASON_MAGIC_NUM && + vaddr[2] =3D=3D PON_REASON_EOF_NUM) { + wdd->bootstatus |=3D WDIOF_CARDRESET; + } + memset(vaddr, 0, reserved_mem_size); + memunmap(vaddr); + } + watchdog_init_timeout(wdd, heartbeat, dev); =20 ret =3D watchdog_register_device(wdd); --=20 2.34.1