Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions arch/arm/dts/sc57x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
};

soc {
rcu: rcu@3108C000 {
compatible = "adi,reset-controller", "syscon";
reg = <0x3108C000 0x1000>;
adi,sharc-min = <1>;
adi,sharc-max = <2>;
adi,enable-reboot;
status = "disabled";
};

mmc: mmc0@31010000 {
compatible = "snps,dw-mshc";
reg = <0x31010000 0x400>;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/dts/sc58x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

soc {
rcu: rcu@0x3108B000 {
compatible = "adi,reset-controller";
compatible = "adi,reset-controller", "syscon";
reg = <0x3108B000 0x1000>;
adi,sharc-min = <1>;
adi,sharc-max = <2>;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/dts/sc59x.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

soc {
rcu: rcu@0x3108C000 {
compatible = "adi,reset-controller";
compatible = "adi,reset-controller", "syscon";
reg = <0x3108C000 0x1000>;
adi,sharc-min = <1>;
adi,sharc-max = <2>;
Expand Down
18 changes: 12 additions & 6 deletions arch/arm/dts/sc5xx.dtsi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* (C) Copyright 2024 - Analog Devices, Inc.
Expand Down Expand Up @@ -115,14 +115,20 @@
bootph-pre-ram;
};

sec: sec@31089000 {
compatible = "adi,system-event-controller", "syscon";
reg = <0x31089000 0x1000>;
adi,rcu = <&rcu>;
status = "okay";
};

wdog: watchdog@31008000 {
compatible = "adi,wdt";
reg = <0x3108c000 0x1000>,
<0x31089000 0x1000>,
<0x31008000 0x1000>;
reg-names = "rcu", "sec", "wdt";
compatible = "adi,watchdog";
reg = <0x31008000 0x10>;
adi,rcu = <&rcu>;
adi,sec = <&sec>;
clock-names = "sclk0";
status = "disabled";
status = "okay";
bootph-pre-ram;
};

Expand Down
2 changes: 2 additions & 0 deletions configs/sc573-ezlite_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ CONFIG_MCP230XX_GPIO=y
CONFIG_DM_I2C=y
CONFIG_DM_I2C_GPIO=y
CONFIG_SYS_I2C_ADI=y
CONFIG_WDT=y
CONFIG_WDT_ADI=y
CONFIG_MMC_DW=y
CONFIG_MMC_DW_SNPS=y
CONFIG_MTD=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc584-ezkit_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ CONFIG_MCP230XX_GPIO=y
CONFIG_DM_I2C=y
CONFIG_DM_I2C_GPIO=y
CONFIG_SYS_I2C_ADI=y
CONFIG_WDT=y
CONFIG_WDT_ADI=y
CONFIG_MTD=y
CONFIG_DM_SPI_FLASH=y
CONFIG_SPI_FLASH_WINBOND=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc589-ezkit_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ CONFIG_MCP230XX_GPIO=y
CONFIG_DM_I2C=y
CONFIG_DM_I2C_GPIO=y
CONFIG_SYS_I2C_ADI=y
CONFIG_WDT=y
CONFIG_WDT_ADI=y
CONFIG_MMC_DW=y
CONFIG_MMC_DW_SNPS=y
CONFIG_MTD=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc589-mini_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ CONFIG_SPL_DM_GPIO_LOOKUP_LABEL=y
CONFIG_DM_I2C=y
CONFIG_DM_I2C_GPIO=y
CONFIG_SYS_I2C_ADI=y
CONFIG_WDT=y
CONFIG_WDT_ADI=y
CONFIG_MMC_DW=y
CONFIG_MMC_DW_SNPS=y
CONFIG_MTD=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc594-som-ezkit-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ CONFIG_MCP230XX_GPIO=y
CONFIG_DM_I2C=y
CONFIG_DM_I2C_GPIO=y
CONFIG_SYS_I2C_ADI=y
CONFIG_WDT=y
CONFIG_WDT_ADI=y
CONFIG_MTD=y
CONFIG_DM_SPI_FLASH=y
CONFIG_SPI_FLASH_SFDP_SUPPORT=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc594-som-ezlite-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ CONFIG_ADP5588_GPIO=y
CONFIG_DM_I2C=y
CONFIG_DM_I2C_GPIO=y
CONFIG_SYS_I2C_ADI=y
CONFIG_WDT=y
CONFIG_WDT_ADI=y
CONFIG_MTD=y
CONFIG_DM_SPI_FLASH=y
CONFIG_SPI_FLASH_SFDP_SUPPORT=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc598-htol-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ CONFIG_ADP5588_GPIO=y
CONFIG_DM_I2C=y
CONFIG_DM_I2C_GPIO=y
CONFIG_SYS_I2C_ADI=y
CONFIG_WDT=y
CONFIG_WDT_ADI=y
CONFIG_MMC_BROKEN_CD=y
CONFIG_MMC_SDHCI_ADI=y
CONFIG_MMC_SDHCI=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc598-som-ezkit-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ CONFIG_ADP5588_GPIO=y
CONFIG_DM_I2C=y
CONFIG_DM_I2C_GPIO=y
CONFIG_SYS_I2C_ADI=y
CONFIG_WDT=y
CONFIG_WDT_ADI=y
CONFIG_MMC_BROKEN_CD=y
CONFIG_MMC_SDHCI_ADI=y
CONFIG_MMC_SDHCI=y
Expand Down
2 changes: 2 additions & 0 deletions configs/sc598-som-ezlite-spl_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ CONFIG_ADP5588_GPIO=y
CONFIG_DM_I2C=y
CONFIG_DM_I2C_GPIO=y
CONFIG_SYS_I2C_ADI=y
CONFIG_WDT=y
CONFIG_WDT_ADI=y
CONFIG_MMC_BROKEN_CD=y
CONFIG_MMC_SDHCI_ADI=y
CONFIG_MMC_SDHCI=y
Expand Down
4 changes: 4 additions & 0 deletions drivers/watchdog/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ config WDT_ADI
bool "Analog Devices watchdog timer support"
select WDT
select SPL_WDT if SPL
select REGMAP
select SYSCON
select SPL_REGMAP if SPL
select SPL_SYSCON if SPL
depends on ARCH_SC5XX
help
Enable this to support Watchdog Timer on ADI SC57X, SC58X, SC59X,
Expand Down
64 changes: 31 additions & 33 deletions drivers/watchdog/adi_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

#include <clk.h>
#include <dm.h>
#include <regmap.h>
#include <syscon.h>
#include <wdt.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/io.h>

#define WDOG_CTL 0x0
#define WDOG_CNT 0x4
Expand All @@ -33,59 +33,61 @@
#define WDDIS 0x0AD0

struct adi_wdt_priv {
void __iomem *rcu_base;
void __iomem *sec_base;
void __iomem *wdt_base;
struct regmap *rcu;
struct regmap *sec;
struct regmap *wdt;
struct clk clock;
};

static int adi_wdt_reset(struct udevice *dev)
{
struct adi_wdt_priv *priv = dev_get_priv(dev);

iowrite32(0, priv->wdt_base + WDOG_STAT);
regmap_write(priv->wdt, WDOG_STAT, 0);

return 0;
}

static int adi_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
{
struct adi_wdt_priv *priv = dev_get_priv(dev);
u32 val;

/* Disable SYSCD_RESETb input and clear the RCU0 reset status */
iowrite32(0xf, priv->rcu_base + RCU_STAT);
iowrite32(0x0, priv->rcu_base + RCU_CTL);
regmap_write(priv->rcu, RCU_STAT, 0xf);
regmap_write(priv->rcu, RCU_CTL, 0x0);

/* reset the SEC controller */
iowrite32(0x2, priv->sec_base + SEC_GCTL);
iowrite32(0x2, priv->sec_base + SEC_FCTL);
regmap_write(priv->sec, SEC_GCTL, 0x2);
regmap_write(priv->sec, SEC_FCTL, 0x2);

udelay(50);

/* enable SEC fault event */
iowrite32(0x1, priv->sec_base + SEC_GCTL);
regmap_write(priv->sec, SEC_GCTL, 0x1);

/* ANOMALY 36100004 Spurious External Fault event occurs when FCTL
* is re-programmed when currently active fault is not cleared
*/
iowrite32(0xc0, priv->sec_base + SEC_FCTL);
iowrite32(0xc1, priv->sec_base + SEC_FCTL);
regmap_write(priv->sec, SEC_FCTL, 0xc0);
regmap_write(priv->sec, SEC_FCTL, 0xc1);

/* enable SEC fault source for watchdog0 */
setbits_32(priv->sec_base + SEC_SCTL0 + (3*8), 0x6);
regmap_read(priv->sec, SEC_SCTL0 + (3 * 8), &val);
regmap_write(priv->sec, SEC_SCTL0 + (3 * 8), val | 0x6);

/* Enable SYSCD_RESETb input */
iowrite32(0x100, priv->rcu_base + RCU_CTL);
regmap_write(priv->rcu, RCU_CTL, 0x100);

/* enable watchdog0 */
iowrite32(WDDIS, priv->wdt_base + WDOG_CTL);
regmap_write(priv->wdt, WDOG_CTL, WDDIS);

iowrite32(timeout_ms / 1000 *
(clk_get_rate(&priv->clock) / (IS_ENABLED(CONFIG_SC58X) ? 2 : 1)),
priv->wdt_base + WDOG_CNT);
regmap_write(priv->wdt, WDOG_CNT,
timeout_ms / 1000 *
(clk_get_rate(&priv->clock) / (IS_ENABLED(CONFIG_SC58X) ? 2 : 1)));

iowrite32(0, priv->wdt_base + WDOG_STAT);
iowrite32(WDEN, priv->wdt_base + WDOG_CTL);
regmap_write(priv->wdt, WDOG_STAT, 0);
regmap_write(priv->wdt, WDOG_CTL, WDEN);

return 0;
}
Expand All @@ -94,22 +96,18 @@ static int adi_wdt_probe(struct udevice *dev)
{
struct adi_wdt_priv *priv = dev_get_priv(dev);
int ret;
struct resource res;

ret = dev_read_resource_byname(dev, "rcu", &res);
if (ret)
return ret;
priv->rcu_base = devm_ioremap(dev, res.start, resource_size(&res));
priv->rcu = syscon_regmap_lookup_by_phandle(dev, "adi,rcu");
if (IS_ERR(priv->rcu))
return PTR_ERR(priv->rcu);

ret = dev_read_resource_byname(dev, "sec", &res);
if (ret)
return ret;
priv->sec_base = devm_ioremap(dev, res.start, resource_size(&res));
priv->sec = syscon_regmap_lookup_by_phandle(dev, "adi,sec");
if (IS_ERR(priv->sec))
return PTR_ERR(priv->sec);

ret = dev_read_resource_byname(dev, "wdt", &res);
ret = regmap_init_mem(dev_ofnode(dev), &priv->wdt);
if (ret)
return ret;
priv->wdt_base = devm_ioremap(dev, res.start, resource_size(&res));

ret = clk_get_by_name(dev, "sclk0", &priv->clock);
if (ret < 0) {
Expand All @@ -126,7 +124,7 @@ static const struct wdt_ops adi_wdt_ops = {
};

static const struct udevice_id adi_wdt_ids[] = {
{ .compatible = "adi,wdt" },
{ .compatible = "adi,watchdog" },
{}
};

Expand Down
Loading