From: UtsavAgarwalADI <[email protected]> The ADI watchdog drives a reset through a Security (SEC) controller fault source. The source index was hardcoded to 3 in adi_wdt_start(), which is only correct for the SC5xx parts that happen to use that index; other ADI SoCs map WDOG0 to a different SEC fault source.
Read the index from a new "adi,secid" device tree property so boards that route the watchdog fault to a different SEC source can configure it. The property is required; if it is absent the driver prints a diagnostic and fails to probe, which makes a stale device tree from before this change easy to spot. Set adi,secid = <3> in the SC57x, SC58x, SC594 and SC598 device trees to match the value they relied on before. Co-developed-by: Ozan Durgut <[email protected]> Signed-off-by: Ozan Durgut <[email protected]> Signed-off-by: UtsavAgarwalADI <[email protected]> --- Changes in v2: - Rename the property to "adi,secid" (vendor prefix, matches the future kernel binding so we can switch to OF_UPSTREAM without a driver change) - Read directly into priv->secid, drop the temporary variable - Keep the property required and print a diagnostic if it is missing, so a stale device tree from before this change is easy to spot arch/arm/dts/sc57x.dtsi | 1 + arch/arm/dts/sc58x.dtsi | 1 + arch/arm/dts/sc594-som.dtsi | 1 + arch/arm/dts/sc598-som.dtsi | 1 + drivers/watchdog/adi_wdt.c | 10 +++++++++- 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/arm/dts/sc57x.dtsi b/arch/arm/dts/sc57x.dtsi index e4cc612959f..3eff76c9409 100644 --- a/arch/arm/dts/sc57x.dtsi +++ b/arch/arm/dts/sc57x.dtsi @@ -113,6 +113,7 @@ &wdog { clocks = <&clk ADSP_SC57X_CLK_CGU0_SCLK0>; + adi,secid = <3>; }; ð0 { diff --git a/arch/arm/dts/sc58x.dtsi b/arch/arm/dts/sc58x.dtsi index 7b07589de47..abc58adf847 100644 --- a/arch/arm/dts/sc58x.dtsi +++ b/arch/arm/dts/sc58x.dtsi @@ -158,6 +158,7 @@ &wdog { clocks = <&clk ADSP_SC58X_CLK_CGU0_SCLK0>; + adi,secid = <3>; }; ð0 { diff --git a/arch/arm/dts/sc594-som.dtsi b/arch/arm/dts/sc594-som.dtsi index c4373aea60f..bfb3dc6c889 100644 --- a/arch/arm/dts/sc594-som.dtsi +++ b/arch/arm/dts/sc594-som.dtsi @@ -67,6 +67,7 @@ &wdog { clocks = <&clk ADSP_SC594_CLK_CGU0_SCLK0>; + adi,secid = <3>; }; &i2c0 { diff --git a/arch/arm/dts/sc598-som.dtsi b/arch/arm/dts/sc598-som.dtsi index ac1f24c86c3..026ee11c49c 100644 --- a/arch/arm/dts/sc598-som.dtsi +++ b/arch/arm/dts/sc598-som.dtsi @@ -124,6 +124,7 @@ &wdog { clocks = <&clk ADSP_SC598_CLK_CGU0_SCLK0>; + adi,secid = <3>; }; &i2c0 { diff --git a/drivers/watchdog/adi_wdt.c b/drivers/watchdog/adi_wdt.c index 7d7cf98b55e..55a68ea0b32 100644 --- a/drivers/watchdog/adi_wdt.c +++ b/drivers/watchdog/adi_wdt.c @@ -14,6 +14,7 @@ #include <clk.h> #include <dm.h> #include <wdt.h> +#include <dm/device_compat.h> #include <linux/delay.h> #include <linux/ioport.h> #include <linux/io.h> @@ -36,6 +37,7 @@ struct adi_wdt_priv { void __iomem *rcu_base; void __iomem *sec_base; void __iomem *wdt_base; + u32 secid; struct clk clock; }; @@ -72,7 +74,7 @@ static int adi_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) iowrite32(0xc1, priv->sec_base + SEC_FCTL); /* enable SEC fault source for watchdog0 */ - setbits_32(priv->sec_base + SEC_SCTL0 + (3*8), 0x6); + setbits_32(priv->sec_base + SEC_SCTL0 + (priv->secid * 8), 0x6); /* Enable SYSCD_RESETb input */ iowrite32(0x100, priv->rcu_base + RCU_CTL); @@ -111,6 +113,12 @@ static int adi_wdt_probe(struct udevice *dev) return ret; priv->wdt_base = devm_ioremap(dev, res.start, resource_size(&res)); + ret = dev_read_u32(dev, "adi,secid", &priv->secid); + if (ret) { + dev_err(dev, "Missing property 'adi,secid'\n"); + return ret; + } + ret = clk_get_by_name(dev, "sclk0", &priv->clock); if (ret < 0) { printf("Can't get WDT clk: %d\n", ret); -- 2.43.0
