watchdog: K3: Add RTI watchdog support
Subsystems (2)
cover watchdog: K3: Add RTI watchdog support
This brings watchdog support for the TI K3 SoCs, derived from the Linux kernel, augmented with firmware loading as needed on the AM65x.
Tested on the AM65x EVM and the IOT2050 (also AM65x-based, upstream support will be posted soon).
Jan
Jan Kiszka (3):
watchdog: Add support for K3 RTI watchdog
watchdog: rti_wdt: Add support for loading firmware
arm: dts: k3: Add RTI watchdogs
arch/arm/dts/k3-am65-mcu.dtsi | 9 ++ arch/arm/dts/k3-j721e-main.dtsi | 18 ++++ drivers/watchdog/Kconfig | 27 ++++++ drivers/watchdog/Makefile | 4 + drivers/watchdog/rti_wdt.c | 157 ++++++++++++++++++++++++++++++++ drivers/watchdog/rti_wdt_fw.S | 20 ++++ 6 files changed, 235 insertions(+) create mode 100644 drivers/watchdog/rti_wdt.c create mode 100644 drivers/watchdog/rti_wdt_fw.S
Signature · 1 line
2.26.2
PATCH 1/3 watchdog: Add support for K3 RTI watchdog
From: Jan Kiszka <[email protected]>
This is based on the Linux kernel driver for the RTI watchdog.
To actually reset the system on an AM65x, it requires firmware running on the R5 that accepts the NMI and issues the actual system reset via TISCI. Kind of an iTCO, except that this watchdog hardware has support for no-way-out, and only for that.
On the J721E, reset works without extra firmware help when routing the RTI interrupt via the ESM.
--- drivers/watchdog/Kconfig | 7 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/rti_wdt.c | 133 +++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 drivers/watchdog/rti_wdt.c
drivers/watchdog/Kconfig +7 -0
@@ -155,6 +155,13 @@ config WDT_ORION Select this to enable Orion watchdog timer, which can be found on some Marvell Armada chips. +config WDT_K3_RTI + bool "Texas Instruments K3 RTI watchdog" + depends on WDT && ARCH_K3 + help + Say Y here if you want to include support for the K3 watchdog + timer (RTI module) available in the K3 generation of processors. + config WDT_SANDBOX bool "Enable Watchdog Timer support for Sandbox" depends on SANDBOX && WDT
drivers/watchdog/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_WDT_MPC8xx) += mpc8xx_wdt.o obj-$(CONFIG_WDT_MT7621) += mt7621_wdt.o obj-$(CONFIG_WDT_MTK) += mtk_wdt.o obj-$(CONFIG_WDT_OMAP3) += omap_wdt.o +obj-$(CONFIG_WDT_K3_RTI) += rti_wdt.o obj-$(CONFIG_WDT_SP805) += sp805_wdt.o obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o
drivers/watchdog/rti_wdt.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.26.2
PATCH 2/3 watchdog: rti_wdt: Add support for loading firmware
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
To avoid the need of extra boot scripting on AM65x for loading a watchdog firmware, add the required rproc init and loading logic for the first R5F core to the watchdog start handler. The firmware itself is embedded into U-Boot binary.
One possible firmware source is https://github.com/siemens/k3-rti-wdt.
--- drivers/watchdog/Kconfig | 20 ++++++++++++++++++++ drivers/watchdog/Makefile | 3 +++ drivers/watchdog/rti_wdt.c | 24 ++++++++++++++++++++++++ drivers/watchdog/rti_wdt_fw.S | 20 ++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 drivers/watchdog/rti_wdt_fw.S
drivers/watchdog/Kconfig +20 -0
@@ -162,6 +162,26 @@ config WDT_K3_RTI Say Y here if you want to include support for the K3 watchdog timer (RTI module) available in the K3 generation of processors. +if WDT_K3_RTI + +config WDT_K3_RTI_LOAD_FW + bool "Load watchdog firmware" + depends on REMOTEPROC + help + Automatically load the specified firmware image into the MCU R5F + core 0. On the AM65x, this firmware is supposed to handle the expiry + of the watchdog timer, typically by resetting the system. + +config WDT_K3_RTI_FW_FILE + string "Watchdog firmware image file" + default "k3-rti-wdt.fw" + depends on WDT_K3_RTI_LOAD_FW + help + Firmware image to be embedded into U-Boot and loaded on watchdog + start. + +endif + config WDT_SANDBOX bool "Enable Watchdog Timer support for Sandbox" depends on SANDBOX && WDT
drivers/watchdog/Makefile +3 -0
@@ -28,7 +28,10 @@ obj-$(CONFIG_WDT_MT7621) += mt7621_wdt.o obj-$(CONFIG_WDT_MTK) += mtk_wdt.o obj-$(CONFIG_WDT_OMAP3) += omap_wdt.o obj-$(CONFIG_WDT_K3_RTI) += rti_wdt.o +obj-$(CONFIG_WDT_K3_RTI_LOAD_FW) += rti_wdt_fw.o obj-$(CONFIG_WDT_SP805) += sp805_wdt.o obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o obj-$(CONFIG_WDT_XILINX) += xilinx_wwdt.o + +$(obj)/rti_wdt_fw.o: $(shell readlink -f $(CONFIG_WDT_K3_RTI_FW_FILE)) FORCE
drivers/watchdog/rti_wdt.c +24 -0
@@ -14,6 +14,7 @@#include <power-domain.h> #include <wdt.h> #include <asm/io.h> +#include <remoteproc.h> /* Timer register set definition */ #define RTIDWDCTRL 0x90
@@ -37,12 +38,17 @@#define WDT_PRELOAD_MAX 0xfff +#define RTI_PROC_ID 0 +struct rti_wdt_priv {phys_addr_t regs;unsigned int clk_khz;struct power_domain pwrdmn; }; +extern const u32 rti_wdt_fw[]; +extern const int rti_wdt_fw_size; +static int rti_wdt_start (struct udevice *dev,u64 timeout_ms,ulong flags) {struct rti_wdt_priv *priv =dev_get_priv (dev);
@@ -58,6 +64,24 @@ static int rti_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)if (readl (priv->regs +RTIDWDCTRL ) ==WDENABLE_KEY )return -EBUSY ; +#ifdef CONFIG_WDT_K3_RTI_LOAD_FW + ret =rproc_dev_init (RTI_PROC_ID ); +if (ret) { + fw_error: +dev_err (dev,"Failed to load watchdog firmware into remote processor %d\n" , +RTI_PROC_ID ); +return ret; + } + + ret =rproc_load (RTI_PROC_ID , (ulong )rti_wdt_fw, rti_wdt_fw_size); +if (ret) + goto fw_error; + + ret =rproc_start (RTI_PROC_ID ); +if (ret) + goto fw_error; +#endif + timer_margin = timeout_ms * priv->clk_khz /1000 ; timer_margin >>=WDT_PRELOAD_SHIFT ;if (timer_margin >WDT_PRELOAD_MAX )
drivers/watchdog/rti_wdt_fw.S new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) Siemens AG, 2020 + * + * Authors: + * Jan Kiszka <[email protected]> + */ + +.section .rodata + +.global rti_wdt_fw +.global rti_wdt_fw_size + +rti_wdt_fw: +.align 4 +.incbin CONFIG_WDT_K3_RTI_FW_FILE +rti_wdt_fw_end: + +rti_wdt_fw_size: +.int rti_wdt_fw_end - rti_wdt_fw
Signature · 1 line
2.26.2
PATCH 3/3 arm: dts: k3: Add RTI watchdogs
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Add DT entries for main domain watchdog0 and 1 instances on the J721e well as RTI1-based watchdog on the AM65x. RTI0 does not work for this purpose on the AM65x, so leave it out.
--- arch/arm/dts/k3-am65-mcu.dtsi | 9 +++++++++ arch/arm/dts/k3-j721e-main.dtsi | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+)
arch/arm/dts/k3-am65-mcu.dtsi +9 -0
@@ -102,4 +102,13 @@ #size-cells = <0>; }; }; + + mcu_rti1: rti at 40610000 { + compatible = "ti,j7-rti-wdt"; + reg = <0x0 0x40610000 0x0 0x100>; + clocks = <&k3_clks 135 0>; + power-domains = <&k3_pds 135 TI_SCI_PD_EXCLUSIVE>; + assigned-clocks = <&k3_clks 135 0>; + assigned-clock-parents = <&k3_clks 135 4>; + }; };
arch/arm/dts/k3-j721e-main.dtsi +18 -0
@@ -543,4 +543,22 @@ clocks = <&k3_clks 193 0>; power-domains = <&k3_pds 193 TI_SCI_PD_EXCLUSIVE>; }; + + watchdog0: watchdog at 2200000 { + compatible = "ti,j7-rti-wdt"; + reg = <0x0 0x2200000 0x0 0x100>; + clocks = <&k3_clks 252 1>; + power-domains = <&k3_pds 252 TI_SCI_PD_EXCLUSIVE>; + assigned-clocks = <&k3_clks 252 1>; + assigned-clock-parents = <&k3_clks 252 5>; + }; + + watchdog1: watchdog at 2210000 { + compatible = "ti,j7-rti-wdt"; + reg = <0x0 0x2210000 0x0 0x100>; + clocks = <&k3_clks 253 1>; + power-domains = <&k3_pds 253 TI_SCI_PD_EXCLUSIVE>; + assigned-clocks = <&k3_clks 253 1>; + assigned-clock-parents = <&k3_clks 253 5>; + }; };
Signature · 1 line
2.26.2