watchdog: Add support for ADI SC5XX-family watchdog peripheral
Co-developed-by: Greg Malysa <malysagreg@gmail.com> Signed-off-by: Greg Malysa <malysagreg@gmail.com> Co-developed-by: Ian Roberts <ian.roberts@timesys.com> Signed-off-by: Ian Roberts <ian.roberts@timesys.com> Signed-off-by: Vasileios Bimpikas <vasileios.bimpikas@analog.com> Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com> Signed-off-by: Arturs Artamonovs <arturs.artamonovs@analog.com> Signed-off-by: Oliver Gaskell <Oliver.Gaskell@analog.com> Signed-off-by: Nathan Barrett-Morrison <nathan.morrison@timesys.com> Reviewed-by: Stefan Roese <sr@denx.de>
This commit is contained in:

committed by
Tom Rini

parent
df831ebf61
commit
cbc0dfd424
@@ -640,6 +640,7 @@ F: drivers/pinctrl/pinctrl-adi-adsp.c
|
|||||||
F: drivers/serial/serial_adi_uart4.c
|
F: drivers/serial/serial_adi_uart4.c
|
||||||
F: drivers/timer/adi_sc5xx_timer.c
|
F: drivers/timer/adi_sc5xx_timer.c
|
||||||
F: drivers/usb/musb-new/sc5xx.c
|
F: drivers/usb/musb-new/sc5xx.c
|
||||||
|
F: drivers/watchdog/adi_wdt.c
|
||||||
F: include/configs/sc5*
|
F: include/configs/sc5*
|
||||||
F: include/dt-bindings/pinctrl/adi-adsp.h
|
F: include/dt-bindings/pinctrl/adi-adsp.h
|
||||||
F: include/env/adi/
|
F: include/env/adi/
|
||||||
|
@@ -95,6 +95,15 @@ config WDT_APPLE
|
|||||||
The watchdog will perform a full SoC reset resulting in a
|
The watchdog will perform a full SoC reset resulting in a
|
||||||
reboot of the entire system.
|
reboot of the entire system.
|
||||||
|
|
||||||
|
config WDT_ADI
|
||||||
|
bool "Analog Devices watchdog timer support"
|
||||||
|
select WDT
|
||||||
|
select SPL_WDT if SPL
|
||||||
|
depends on ARCH_SC5XX
|
||||||
|
help
|
||||||
|
Enable this to support Watchdog Timer on ADI SC57X, SC58X, SC59X,
|
||||||
|
and SC59X_64 processors
|
||||||
|
|
||||||
config WDT_ARMADA_37XX
|
config WDT_ARMADA_37XX
|
||||||
bool "Marvell Armada 37xx watchdog timer support"
|
bool "Marvell Armada 37xx watchdog timer support"
|
||||||
depends on WDT && ARMADA_3700
|
depends on WDT && ARMADA_3700
|
||||||
|
@@ -53,3 +53,4 @@ obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o
|
|||||||
obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o
|
obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o
|
||||||
obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o
|
obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o
|
||||||
obj-$(CONFIG_WDT_XILINX) += xilinx_wwdt.o
|
obj-$(CONFIG_WDT_XILINX) += xilinx_wwdt.o
|
||||||
|
obj-$(CONFIG_WDT_ADI) += adi_wdt.o
|
||||||
|
143
drivers/watchdog/adi_wdt.c
Normal file
143
drivers/watchdog/adi_wdt.c
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2022 - Analog Devices, Inc.
|
||||||
|
*
|
||||||
|
* Written and/or maintained by Timesys Corporation
|
||||||
|
*
|
||||||
|
* Converted to driver model by Nathan Barrett-Morrison
|
||||||
|
*
|
||||||
|
* Contact: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
|
||||||
|
* Contact: Greg Malysa <greg.malysa@timesys.com>
|
||||||
|
*
|
||||||
|
* adi_wtd.c - driver for ADI on-chip watchdog
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <clk.h>
|
||||||
|
#include <dm.h>
|
||||||
|
#include <wdt.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
#include <linux/ioport.h>
|
||||||
|
#include <linux/io.h>
|
||||||
|
|
||||||
|
#define WDOG_CTL 0x0
|
||||||
|
#define WDOG_CNT 0x4
|
||||||
|
#define WDOG_STAT 0x8
|
||||||
|
|
||||||
|
#define RCU_CTL 0x0
|
||||||
|
#define RCU_STAT 0x4
|
||||||
|
|
||||||
|
#define SEC_GCTL 0x0
|
||||||
|
#define SEC_FCTL 0x10
|
||||||
|
#define SEC_SCTL0 0x800
|
||||||
|
|
||||||
|
#define WDEN 0x0010
|
||||||
|
#define WDDIS 0x0AD0
|
||||||
|
|
||||||
|
struct adi_wdt_priv {
|
||||||
|
void __iomem *rcu_base;
|
||||||
|
void __iomem *sec_base;
|
||||||
|
void __iomem *wdt_base;
|
||||||
|
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);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int adi_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
|
||||||
|
{
|
||||||
|
struct adi_wdt_priv *priv = dev_get_priv(dev);
|
||||||
|
|
||||||
|
/* Disable SYSCD_RESETb input and clear the RCU0 reset status */
|
||||||
|
iowrite32(0xf, priv->rcu_base + RCU_STAT);
|
||||||
|
iowrite32(0x0, priv->rcu_base + RCU_CTL);
|
||||||
|
|
||||||
|
/* reset the SEC controller */
|
||||||
|
iowrite32(0x2, priv->sec_base + SEC_GCTL);
|
||||||
|
iowrite32(0x2, priv->sec_base + SEC_FCTL);
|
||||||
|
|
||||||
|
udelay(50);
|
||||||
|
|
||||||
|
/* enable SEC fault event */
|
||||||
|
iowrite32(0x1, priv->sec_base + SEC_GCTL);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
|
/* enable SEC fault source for watchdog0 */
|
||||||
|
setbits_32(priv->sec_base + SEC_SCTL0 + (3*8), 0x6);
|
||||||
|
|
||||||
|
/* Enable SYSCD_RESETb input */
|
||||||
|
iowrite32(0x100, priv->rcu_base + RCU_CTL);
|
||||||
|
|
||||||
|
/* enable watchdog0 */
|
||||||
|
iowrite32(WDDIS, priv->wdt_base + WDOG_CTL);
|
||||||
|
|
||||||
|
iowrite32(timeout_ms / 1000 *
|
||||||
|
(clk_get_rate(&priv->clock) / (IS_ENABLED(CONFIG_SC58X) ? 2 : 1)),
|
||||||
|
priv->wdt_base + WDOG_CNT);
|
||||||
|
|
||||||
|
iowrite32(0, priv->wdt_base + WDOG_STAT);
|
||||||
|
iowrite32(WDEN, priv->wdt_base + WDOG_CTL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
ret = dev_read_resource_byname(dev, "sec", &res);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
priv->sec_base = devm_ioremap(dev, res.start, resource_size(&res));
|
||||||
|
|
||||||
|
ret = dev_read_resource_byname(dev, "wdt", &res);
|
||||||
|
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) {
|
||||||
|
printf("Can't get WDT clk: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct wdt_ops adi_wdt_ops = {
|
||||||
|
.start = adi_wdt_start,
|
||||||
|
.reset = adi_wdt_reset,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct udevice_id adi_wdt_ids[] = {
|
||||||
|
{ .compatible = "adi,wdt" },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
U_BOOT_DRIVER(adi_wdt) = {
|
||||||
|
.name = "adi_wdt",
|
||||||
|
.id = UCLASS_WDT,
|
||||||
|
.of_match = adi_wdt_ids,
|
||||||
|
.probe = adi_wdt_probe,
|
||||||
|
.ops = &adi_wdt_ops,
|
||||||
|
.priv_auto = sizeof(struct adi_wdt_priv),
|
||||||
|
.flags = DM_FLAG_PRE_RELOC,
|
||||||
|
};
|
Reference in New Issue
Block a user