[PATCH v3 4/5] realtek: Add and enable watchdog node

Sander Vanheule sander at svanheule.net
Sat Nov 6 07:52:49 PDT 2021


Add and enable the Realtek Otto WDT peripheral found on these SoCs.

Devices that require the PLL value fixup before restarting, should pick
the "cpu" or "software" reset mode. These devices also need to provide a
custom reboot mode, by adding the reboot argument to the kernel command
line:

    WDT reset mode  | kernel reboot mode
    ----------------+---------------------------------------
    soc             | reboot=cold (default if not specified)
    cpu             | reboot=warm
    software        | reboot=software

Since RTL838x can only perform cold reboots reliably on selected
devices, default this platform to use reboot=warm and "cpu" reset.
RTL930x devices have more reliable reset logic, and can use the default
(cold) reboot and "soc" resets.

Note that watchdog restarts are not yet exposed, since the
_machine_restart override is still present.

Signed-off-by: Sander Vanheule <sander at svanheule.net>

--
v2:
- Add Kconfig update to patch
- Fix 'clocks' property, change reference to lx_clk
- Add WDT phase interrupt routing
---
 target/linux/realtek/config-5.10           |  2 ++
 target/linux/realtek/dts-5.10/rtl838x.dtsi | 16 +++++++++++++++-
 target/linux/realtek/dts-5.10/rtl930x.dtsi | 18 +++++++++++++++++-
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/target/linux/realtek/config-5.10 b/target/linux/realtek/config-5.10
index 2c5ab1706a2c..00f2a6af13ba 100644
--- a/target/linux/realtek/config-5.10
+++ b/target/linux/realtek/config-5.10
@@ -160,6 +160,7 @@ CONFIG_PINCTRL=y
 CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_RATIONAL=y
+CONFIG_REALTEK_OTTO_WDT=y
 CONFIG_REALTEK_PHY=y
 CONFIG_REALTEK_SOC_PHY=y
 CONFIG_REGMAP=y
@@ -190,5 +191,6 @@ CONFIG_TIMER_PROBE=y
 CONFIG_TINY_SRCU=y
 CONFIG_USE_GENERIC_EARLY_PRINTK_8250=y
 CONFIG_USE_OF=y
+CONFIG_WATCHDOG_CORE=y
 CONFIG_ZLIB_DEFLATE=y
 CONFIG_ZLIB_INFLATE=y
diff --git a/target/linux/realtek/dts-5.10/rtl838x.dtsi b/target/linux/realtek/dts-5.10/rtl838x.dtsi
index a3b15689ed24..0cc0a5172fd3 100644
--- a/target/linux/realtek/dts-5.10/rtl838x.dtsi
+++ b/target/linux/realtek/dts-5.10/rtl838x.dtsi
@@ -66,7 +66,7 @@
 
 	chosen {
 		stdout-path = "uart0:115200";
-		bootargs = "earlycon console=ttyS0,115200";
+		bootargs = "earlycon console=ttyS0,115200 reboot=warm";
 	};
 
 	lx_clk: lx_clk {
@@ -154,6 +154,20 @@
 			status = "disabled";
 		};
 
+		watchdog: watchdog at 3150 {
+			compatible = "realtek,rtl8380-wdt";
+			reg = <0x3150 0xc>;
+
+			realtek,reset-mode = "cpu";
+
+			clocks = <&lx_clk>;
+			timeout-sec = <30>;
+
+			interrupt-parent = <&intc>;
+			interrupt-names = "phase1", "phase2";
+			interrupts = <19>, <18>;
+		};
+
 		gpio0: gpio-controller at 3500 {
 			compatible = "realtek,rtl8380-gpio", "realtek,otto-gpio";
 			reg = <0x3500 0x20>;
diff --git a/target/linux/realtek/dts-5.10/rtl930x.dtsi b/target/linux/realtek/dts-5.10/rtl930x.dtsi
index cd94c880b414..e23e90fd8b81 100644
--- a/target/linux/realtek/dts-5.10/rtl930x.dtsi
+++ b/target/linux/realtek/dts-5.10/rtl930x.dtsi
@@ -110,7 +110,9 @@
 				<10 &cpuintc 1>, /* TC3 */
 				<9 &cpuintc 1>,  /* TC2 */
 				<8 &cpuintc 1>,  /* TC1 */
-				<7 &cpuintc 5>;  /* TC0 */
+				<7 &cpuintc 5>,  /* TC0 */
+				<6 &cpuintc 5>,  /* WDT_IP2 */
+				<5 &cpuintc 4>;  /* WDT_IP1 */
 		};
 
 		timer: timer at 3200 {
@@ -162,6 +164,20 @@
 			status = "disabled";
 		};
 
+		watchdog0: watchdog at 3260 {
+			compatible = "realtek,rtl9300-wdt";
+			reg = <0x3260 0xc>;
+
+			realtek,reset-mode = "soc";
+
+			clocks = <&lx_clk>;
+			timeout-sec = <30>;
+
+			interrupt-parent = <&intc>;
+			interrupt-names = "phase1", "phase2";
+			interrupts = <5>, <6>;
+		};
+
 		gpio0: gpio-controller at 3500 {
 			compatible = "realtek,rtl8380-gpio", "realtek,otto-gpio";
 			reg = <0x3500 0x20>;
-- 
2.33.1




More information about the openwrt-devel mailing list