From: Stefan Roese <sr@denx.de>
To: Greg Malysa <malysagreg@gmail.com>, u-boot@lists.denx.de
Cc: adsp-linux@analog.com,
Nathan Barrett-Morrison <nathan.morrison@timesys.com>,
Ian Roberts <ian.roberts@timesys.com>,
Vasileios Bimpikas <vasileios.bimpikas@analog.com>,
Utsav Agarwal <utsav.agarwal@analog.com>,
Arturs Artamonovs <arturs.artamonovs@analog.com>,
Oliver Gaskell <Oliver.Gaskell@analog.com>,
Bastien Curutchet <bastien.curutchet@bootlin.com>,
Caleb Connolly <caleb.connolly@linaro.org>,
Devarsh Thakkar <devarsht@ti.com>,
Fabio Estevam <festevam@gmail.com>,
Greg Malysa <greg.malysa@timesys.com>,
Heiko Schocher <hs@denx.de>,
Mattijs Korpershoek <mkorpershoek@baylibre.com>,
Rasmus Villemoes <ravi@prevas.dk>,
Robert Marko <robert.marko@sartura.hr>,
Sam Protsenko <semen.protsenko@linaro.org>,
Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH v3 08/12] watchdog: Add support for ADI SC5XX-family watchdog peripheral
Date: Thu, 27 Feb 2025 09:44:16 +0100 [thread overview]
Message-ID: <c1bfbe3c-9d27-4290-a0de-4844734117ca@denx.de> (raw)
In-Reply-To: <20250226173150.13198-9-malysagreg@gmail.com>
On 26.02.25 18:30, Greg Malysa wrote:
> From: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
>
> 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>
>
> ---
>
> Changes in v3:
> - replace readl/writel with ioread32 and iowrite32 and friends
Reviewed-by: Stefan Roese <sr@denx.de>
BTW: I already added my RB tag on v1, please include it in later
versions, if not bigger changes occur.
Thanks,
Stefan
> MAINTAINERS | 1 +
> drivers/watchdog/Kconfig | 9 +++
> drivers/watchdog/Makefile | 1 +
> drivers/watchdog/adi_wdt.c | 143 +++++++++++++++++++++++++++++++++++++
> 4 files changed, 154 insertions(+)
> create mode 100644 drivers/watchdog/adi_wdt.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2c4dc8b14c1..0cefd888885 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -640,6 +640,7 @@ F: drivers/pinctrl/pinctrl-adi-adsp.c
> F: drivers/serial/serial_adi_uart4.c
> F: drivers/timer/adi_sc5xx_timer.c
> F: drivers/usb/musb-new/sc5xx.c
> +F: drivers/watchdog/adi_wdt.c
> F: include/configs/sc5*
> F: include/dt-bindings/pinctrl/adi-adsp.h
> F: include/env/adi/
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index b39b2546e5c..1bb67f50352 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -95,6 +95,15 @@ config WDT_APPLE
> The watchdog will perform a full SoC reset resulting in a
> 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
> bool "Marvell Armada 37xx watchdog timer support"
> depends on WDT && ARMADA_3700
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index 9b6b1a8e8ad..e6bd4c587af 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -53,3 +53,4 @@ obj-$(CONFIG_WDT_STM32MP) += stm32mp_wdt.o
> obj-$(CONFIG_WDT_SUNXI) += sunxi_wdt.o
> obj-$(CONFIG_WDT_TANGIER) += tangier_wdt.o
> obj-$(CONFIG_WDT_XILINX) += xilinx_wwdt.o
> +obj-$(CONFIG_WDT_ADI) += adi_wdt.o
> diff --git a/drivers/watchdog/adi_wdt.c b/drivers/watchdog/adi_wdt.c
> new file mode 100644
> index 00000000000..6f5b3d5d042
> --- /dev/null
> +++ b/drivers/watchdog/adi_wdt.c
> @@ -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,
> +};
Viele Grüße,
Stefan Roese
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de
next prev parent reply other threads:[~2025-02-27 8:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 17:30 [PATCH v3 00/12] drivers: Driver support for ADI SC5xx SoCs Greg Malysa
2025-02-26 17:30 ` [PATCH v3 01/12] pinctrl: Add support for ADI SC5XX-family pinctrl Greg Malysa
2025-02-26 17:30 ` [PATCH v3 02/12] doc: Add dt-bindings and descriptions for ADI SC5xx-family pinctrl Greg Malysa
2025-02-26 17:30 ` [PATCH v3 03/12] gpio: Add support for SC5XX-family processor GPIO driver Greg Malysa
2025-02-26 17:30 ` [PATCH v3 04/12] gpio: Add support for ADI ADP5588 GPIO expander chips Greg Malysa
2025-02-26 17:30 ` [PATCH v3 05/12] usb: musb-new: Add support for Analog Devices SC5xx SoCs Greg Malysa
2025-02-26 17:30 ` [PATCH v3 06/12] i2c: Add support for ADI SC5XX-family I2C peripheral Greg Malysa
2025-03-06 5:56 ` Heiko Schocher
2025-02-26 17:30 ` [PATCH v3 07/12] net: Add support for ADI SC5xx SoCs with DWC QoS ethernet Greg Malysa
2025-02-26 17:30 ` [PATCH v3 08/12] watchdog: Add support for ADI SC5XX-family watchdog peripheral Greg Malysa
2025-02-27 8:44 ` Stefan Roese [this message]
2025-02-26 17:30 ` [PATCH v3 09/12] dma: Add driver for ADI SC5xx-family SoC MDMA functionality Greg Malysa
2025-02-26 17:30 ` [PATCH v3 10/12] remoteproc: Add in SHARC loading for ADI SC5XX-family processors Greg Malysa
2025-02-26 17:30 ` [PATCH v3 11/12] spi: Add support for ADI SC5XX-family processor SPI peripherals Greg Malysa
2025-02-26 17:30 ` [PATCH v3 12/12] mmc: Add support for ADI SC5XX-family processor SDHCI peripherals Greg Malysa
2025-03-12 19:43 ` [PATCH v3 00/12] drivers: Driver support for ADI SC5xx SoCs Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c1bfbe3c-9d27-4290-a0de-4844734117ca@denx.de \
--to=sr@denx.de \
--cc=Oliver.Gaskell@analog.com \
--cc=adsp-linux@analog.com \
--cc=arturs.artamonovs@analog.com \
--cc=bastien.curutchet@bootlin.com \
--cc=caleb.connolly@linaro.org \
--cc=devarsht@ti.com \
--cc=festevam@gmail.com \
--cc=greg.malysa@timesys.com \
--cc=hs@denx.de \
--cc=ian.roberts@timesys.com \
--cc=malysagreg@gmail.com \
--cc=mkorpershoek@baylibre.com \
--cc=nathan.morrison@timesys.com \
--cc=ravi@prevas.dk \
--cc=robert.marko@sartura.hr \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=utsav.agarwal@analog.com \
--cc=vasileios.bimpikas@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox