Commit f34c5125 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'linux-watchdog-6.12-rc1' of git://www.linux-watchdog.org/linux-watchdog

Pull watchdog updates from Wim Van Sebroeck:

 - Add Watchdog Timer driver for RZ/V2H(P)

 - Add Cirrus EP93x

 - Some small fixes and improvements

* tag 'linux-watchdog-6.12-rc1' of git://www.linux-watchdog.org/linux-watchdog:
  watchdog: Convert comma to semicolon
  watchdog: rzv2h_wdt: Add missing MODULE_LICENSE tag to fix modpost error
  dt-bindings: watchdog: Add Cirrus EP93x
  dt-bindings: watchdog: stm32-iwdg: Document interrupt and wakeup properties
  drivers: watchdog: marvell_gti: Convert comma to semicolon
  watchdog: iTCO_wdt: Convert comma to semicolon
  watchdog: Add Watchdog Timer driver for RZ/V2H(P)
  dt-bindings: watchdog: renesas,wdt: Document RZ/V2H(P) SoC
  watchdog: imx_sc_wdt: detect if already running
  watchdog: imx2_wdt: Remove __maybe_unused notations
  watchdog: imx_sc_wdt: Don't disable WDT in suspend
  watchdog: imx7ulp_wdt: move post_rcs_wait into struct imx_wdt_hw_feature
parents 962ad087 134d2531
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/watchdog/cirrus,ep9301-wdt.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Cirrus Logic EP93xx Watchdog Timer
maintainers:
- Nikita Shubin <nikita.shubin@maquefel.me>
- Alexander Sverdlin <alexander.sverdlin@gmail.com>
allOf:
- $ref: watchdog.yaml#
properties:
compatible:
oneOf:
- const: cirrus,ep9301-wdt
- items:
- enum:
- cirrus,ep9302-wdt
- cirrus,ep9307-wdt
- cirrus,ep9312-wdt
- cirrus,ep9315-wdt
- const: cirrus,ep9301-wdt
reg:
maxItems: 1
required:
- compatible
- reg
unevaluatedProperties: false
examples:
- |
watchdog@80940000 {
compatible = "cirrus,ep9301-wdt";
reg = <0x80940000 0x08>;
};
......@@ -75,6 +75,8 @@ properties:
- renesas,r8a779h0-wdt # R-Car V4M
- const: renesas,rcar-gen4-wdt # R-Car Gen4
- const: renesas,r9a09g057-wdt # RZ/V2H(P)
reg:
maxItems: 1
......@@ -113,7 +115,6 @@ properties:
required:
- compatible
- reg
- interrupts
- clocks
allOf:
......@@ -137,6 +138,7 @@ allOf:
compatible:
contains:
enum:
- renesas,r9a09g057-wdt
- renesas,rzg2l-wdt
- renesas,rzv2m-wdt
then:
......@@ -171,6 +173,19 @@ allOf:
interrupts:
maxItems: 1
- if:
properties:
compatible:
contains:
const: renesas,r9a09g057-wdt
then:
properties:
interrupts: false
interrupt-names: false
else:
required:
- interrupts
additionalProperties: false
examples:
......
......@@ -36,6 +36,12 @@ properties:
minItems: 1
maxItems: 2
interrupts:
maxItems: 1
description: Pre-timeout interrupt from the watchdog.
wakeup-source: true
required:
- compatible
- reg
......
......@@ -953,6 +953,15 @@ config RENESAS_RZG2LWDT
This driver adds watchdog support for the integrated watchdogs in the
Renesas RZ/G2L SoCs. These watchdogs can be used to reset a system.
config RENESAS_RZV2HWDT
tristate "Renesas RZ/V2H(P) WDT Watchdog"
depends on ARCH_R9A09G057 || COMPILE_TEST
depends on PM || COMPILE_TEST
select WATCHDOG_CORE
help
This driver adds watchdog support for the integrated watchdogs in the
Renesas RZ/V2H(P) SoCs. These watchdogs can be used to reset a system.
config ASPEED_WATCHDOG
tristate "Aspeed BMC watchdog support"
depends on ARCH_ASPEED || COMPILE_TEST
......
......@@ -86,6 +86,7 @@ obj-$(CONFIG_RENESAS_WDT) += renesas_wdt.o
obj-$(CONFIG_RENESAS_RZAWDT) += rza_wdt.o
obj-$(CONFIG_RENESAS_RZN1WDT) += rzn1_wdt.o
obj-$(CONFIG_RENESAS_RZG2LWDT) += rzg2l_wdt.o
obj-$(CONFIG_RENESAS_RZV2HWDT) += rzv2h_wdt.o
obj-$(CONFIG_ASPEED_WATCHDOG) += aspeed_wdt.o
obj-$(CONFIG_STM32_WATCHDOG) += stm32_iwdg.o
obj-$(CONFIG_UNIPHIER_WATCHDOG) += uniphier_wdt.o
......
......@@ -563,8 +563,8 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
}
ident.firmware_version = p->iTCO_version;
p->wddev.info = &ident,
p->wddev.ops = &iTCO_wdt_ops,
p->wddev.info = &ident;
p->wddev.ops = &iTCO_wdt_ops;
p->wddev.bootstatus = 0;
p->wddev.timeout = WATCHDOG_TIMEOUT;
watchdog_set_nowayout(&p->wddev, nowayout);
......
......@@ -379,7 +379,7 @@ static void imx2_wdt_shutdown(struct platform_device *pdev)
}
/* Disable watchdog if it is active or non-active but still running */
static int __maybe_unused imx2_wdt_suspend(struct device *dev)
static int imx2_wdt_suspend(struct device *dev)
{
struct watchdog_device *wdog = dev_get_drvdata(dev);
struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
......@@ -404,7 +404,7 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev)
}
/* Enable watchdog and configure it if necessary */
static int __maybe_unused imx2_wdt_resume(struct device *dev)
static int imx2_wdt_resume(struct device *dev)
{
struct watchdog_device *wdog = dev_get_drvdata(dev);
struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
......@@ -435,7 +435,7 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev)
return 0;
}
static SIMPLE_DEV_PM_OPS(imx2_wdt_pm_ops, imx2_wdt_suspend,
static DEFINE_SIMPLE_DEV_PM_OPS(imx2_wdt_pm_ops, imx2_wdt_suspend,
imx2_wdt_resume);
static struct imx2_wdt_data imx_wdt = {
......@@ -476,7 +476,7 @@ static struct platform_driver imx2_wdt_driver = {
.shutdown = imx2_wdt_shutdown,
.driver = {
.name = DRIVER_NAME,
.pm = &imx2_wdt_pm_ops,
.pm = pm_sleep_ptr(&imx2_wdt_pm_ops),
.of_match_table = imx2_wdt_dt_ids,
},
};
......
......@@ -55,6 +55,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
struct imx_wdt_hw_feature {
bool prescaler_enable;
bool post_rcs_wait;
u32 wdog_clock_rate;
};
......@@ -62,7 +63,6 @@ struct imx7ulp_wdt_device {
struct watchdog_device wdd;
void __iomem *base;
struct clk *clk;
bool post_rcs_wait;
bool ext_reset;
const struct imx_wdt_hw_feature *hw;
};
......@@ -95,7 +95,7 @@ static int imx7ulp_wdt_wait_rcs(struct imx7ulp_wdt_device *wdt)
ret = -ETIMEDOUT;
/* Wait 2.5 clocks after RCS done */
if (wdt->post_rcs_wait)
if (wdt->hw->post_rcs_wait)
usleep_range(wait_min, wait_min + 2000);
return ret;
......@@ -334,15 +334,6 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev)
/* The WDOG may need to do external reset through dedicated pin */
imx7ulp_wdt->ext_reset = of_property_read_bool(dev->of_node, "fsl,ext-reset-output");
imx7ulp_wdt->post_rcs_wait = true;
if (of_device_is_compatible(dev->of_node,
"fsl,imx8ulp-wdt")) {
dev_info(dev, "imx8ulp wdt probe\n");
imx7ulp_wdt->post_rcs_wait = false;
} else {
dev_info(dev, "imx7ulp wdt probe\n");
}
wdog = &imx7ulp_wdt->wdd;
wdog->info = &imx7ulp_wdt_info;
wdog->ops = &imx7ulp_wdt_ops;
......@@ -403,6 +394,12 @@ static const struct dev_pm_ops imx7ulp_wdt_pm_ops = {
static const struct imx_wdt_hw_feature imx7ulp_wdt_hw = {
.prescaler_enable = false,
.wdog_clock_rate = 1000,
.post_rcs_wait = true,
};
static const struct imx_wdt_hw_feature imx8ulp_wdt_hw = {
.prescaler_enable = false,
.wdog_clock_rate = 1000,
};
static const struct imx_wdt_hw_feature imx93_wdt_hw = {
......@@ -411,8 +408,8 @@ static const struct imx_wdt_hw_feature imx93_wdt_hw = {
};
static const struct of_device_id imx7ulp_wdt_dt_ids[] = {
{ .compatible = "fsl,imx8ulp-wdt", .data = &imx7ulp_wdt_hw, },
{ .compatible = "fsl,imx7ulp-wdt", .data = &imx7ulp_wdt_hw, },
{ .compatible = "fsl,imx8ulp-wdt", .data = &imx8ulp_wdt_hw, },
{ .compatible = "fsl,imx93-wdt", .data = &imx93_wdt_hw, },
{ /* sentinel */ }
};
......
......@@ -56,6 +56,25 @@ static int imx_sc_wdt_ping(struct watchdog_device *wdog)
return 0;
}
static bool imx_sc_wdt_is_running(void)
{
struct arm_smccc_res res;
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_START_WDOG,
0, 0, 0, 0, 0, 0, &res);
/* Already enabled (SC_TIMER_ERR_BUSY)? */
if (res.a0 == SC_TIMER_ERR_BUSY)
return true;
/* Undo only if that was us who has (successfully) enabled the WDT */
if (!res.a0)
arm_smccc_smc(IMX_SIP_TIMER, IMX_SIP_TIMER_STOP_WDOG,
0, 0, 0, 0, 0, 0, &res);
return false;
}
static int imx_sc_wdt_start(struct watchdog_device *wdog)
{
struct arm_smccc_res res;
......@@ -183,6 +202,9 @@ static int imx_sc_wdt_probe(struct platform_device *pdev)
if (ret)
return ret;
if (imx_sc_wdt_is_running())
set_bit(WDOG_HW_RUNNING, &wdog->status);
watchdog_stop_on_reboot(wdog);
watchdog_stop_on_unregister(wdog);
......@@ -216,29 +238,6 @@ static int imx_sc_wdt_probe(struct platform_device *pdev)
return devm_watchdog_register_device(dev, wdog);
}
static int __maybe_unused imx_sc_wdt_suspend(struct device *dev)
{
struct imx_sc_wdt_device *imx_sc_wdd = dev_get_drvdata(dev);
if (watchdog_active(&imx_sc_wdd->wdd))
imx_sc_wdt_stop(&imx_sc_wdd->wdd);
return 0;
}
static int __maybe_unused imx_sc_wdt_resume(struct device *dev)
{
struct imx_sc_wdt_device *imx_sc_wdd = dev_get_drvdata(dev);
if (watchdog_active(&imx_sc_wdd->wdd))
imx_sc_wdt_start(&imx_sc_wdd->wdd);
return 0;
}
static SIMPLE_DEV_PM_OPS(imx_sc_wdt_pm_ops,
imx_sc_wdt_suspend, imx_sc_wdt_resume);
static const struct of_device_id imx_sc_wdt_dt_ids[] = {
{ .compatible = "fsl,imx-sc-wdt", },
{ /* sentinel */ }
......@@ -250,7 +249,6 @@ static struct platform_driver imx_sc_wdt_driver = {
.driver = {
.name = "imx-sc-wdt",
.of_match_table = imx_sc_wdt_dt_ids,
.pm = &imx_sc_wdt_pm_ops,
},
};
module_platform_driver(imx_sc_wdt_driver);
......
......@@ -285,8 +285,8 @@ static int gti_wdt_probe(struct platform_device *pdev)
}
wdog_dev = &priv->wdev;
wdog_dev->info = &gti_wdt_ident,
wdog_dev->ops = &gti_wdt_ops,
wdog_dev->info = &gti_wdt_ident;
wdog_dev->ops = &gti_wdt_ops;
wdog_dev->parent = dev;
/*
* Watchdog counter is 24 bit where lower 8 bits are zeros
......
......@@ -218,7 +218,7 @@ static int pm8916_wdt_probe(struct platform_device *pdev)
return err;
}
wdt->wdev.ops = &pm8916_wdt_ops,
wdt->wdev.ops = &pm8916_wdt_ops;
wdt->wdev.parent = dev;
wdt->wdev.min_timeout = PM8916_WDT_MIN_TIMEOUT;
wdt->wdev.max_timeout = PM8916_WDT_MAX_TIMEOUT;
......
// SPDX-License-Identifier: GPL-2.0
/*
* Renesas RZ/V2H(P) WDT Watchdog Driver
*
* Copyright (C) 2024 Renesas Electronics Corporation.
*/
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>
#include <linux/units.h>
#include <linux/watchdog.h>
#define WDTRR 0x00 /* WDT Refresh Register RW, 8 */
#define WDTCR 0x02 /* WDT Control Register RW, 16 */
#define WDTSR 0x04 /* WDT Status Register RW, 16 */
#define WDTRCR 0x06 /* WDT Reset Control Register RW, 8 */
#define WDTCR_TOPS_1024 0x00
#define WDTCR_TOPS_16384 0x03
#define WDTCR_CKS_CLK_1 0x00
#define WDTCR_CKS_CLK_256 0x50
#define WDTCR_RPES_0 0x300
#define WDTCR_RPES_75 0x000
#define WDTCR_RPSS_25 0x00
#define WDTCR_RPSS_100 0x3000
#define WDTRCR_RSTIRQS BIT(7)
#define MAX_TIMEOUT_CYCLES 16384
#define CLOCK_DIV_BY_256 256
#define WDT_DEFAULT_TIMEOUT 60U
static bool nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
struct rzv2h_wdt_priv {
void __iomem *base;
struct clk *pclk;
struct clk *oscclk;
struct reset_control *rstc;
struct watchdog_device wdev;
};
static int rzv2h_wdt_ping(struct watchdog_device *wdev)
{
struct rzv2h_wdt_priv *priv = watchdog_get_drvdata(wdev);
/*
* The down-counter is refreshed and starts counting operation on
* a write of the values 00h and FFh to the WDTRR register.
*/
writeb(0x0, priv->base + WDTRR);
writeb(0xFF, priv->base + WDTRR);
return 0;
}
static void rzv2h_wdt_setup(struct watchdog_device *wdev, u16 wdtcr)
{
struct rzv2h_wdt_priv *priv = watchdog_get_drvdata(wdev);
/* Configure the timeout, clock division ratio, and window start and end positions. */
writew(wdtcr, priv->base + WDTCR);
/* Enable interrupt output to the ICU. */
writeb(0, priv->base + WDTRCR);
/* Clear underflow flag and refresh error flag. */
writew(0, priv->base + WDTSR);
}
static int rzv2h_wdt_start(struct watchdog_device *wdev)
{
struct rzv2h_wdt_priv *priv = watchdog_get_drvdata(wdev);
int ret;
ret = pm_runtime_resume_and_get(wdev->parent);
if (ret)
return ret;
ret = reset_control_deassert(priv->rstc);
if (ret) {
pm_runtime_put(wdev->parent);
return ret;
}
/* delay to handle clock halt after de-assert operation */
udelay(3);
/*
* WDTCR
* - CKS[7:4] - Clock Division Ratio Select - 0101b: oscclk/256
* - RPSS[13:12] - Window Start Position Select - 11b: 100%
* - RPES[9:8] - Window End Position Select - 11b: 0%
* - TOPS[1:0] - Timeout Period Select - 11b: 16384 cycles (3FFFh)
*/
rzv2h_wdt_setup(wdev, WDTCR_CKS_CLK_256 | WDTCR_RPSS_100 |
WDTCR_RPES_0 | WDTCR_TOPS_16384);
/*
* Down counting starts after writing the sequence 00h -> FFh to the
* WDTRR register. Hence, call the ping operation after loading the counter.
*/
rzv2h_wdt_ping(wdev);
return 0;
}
static int rzv2h_wdt_stop(struct watchdog_device *wdev)
{
struct rzv2h_wdt_priv *priv = watchdog_get_drvdata(wdev);
int ret;
ret = reset_control_assert(priv->rstc);
if (ret)
return ret;
ret = pm_runtime_put(wdev->parent);
if (ret < 0)
return ret;
return 0;
}
static const struct watchdog_info rzv2h_wdt_ident = {
.options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT,
.identity = "Renesas RZ/V2H WDT Watchdog",
};
static int rzv2h_wdt_restart(struct watchdog_device *wdev,
unsigned long action, void *data)
{
struct rzv2h_wdt_priv *priv = watchdog_get_drvdata(wdev);
int ret;
if (!watchdog_active(wdev)) {
ret = clk_enable(priv->pclk);
if (ret)
return ret;
ret = clk_enable(priv->oscclk);
if (ret) {
clk_disable(priv->pclk);
return ret;
}
ret = reset_control_deassert(priv->rstc);
if (ret) {
clk_disable(priv->oscclk);
clk_disable(priv->pclk);
return ret;
}
} else {
/*
* Writing to the WDT Control Register (WDTCR) or WDT Reset
* Control Register (WDTRCR) is possible once between the
* release from the reset state and the first refresh operation.
* Therefore, issue a reset if the watchdog is active.
*/
ret = reset_control_reset(priv->rstc);
if (ret)
return ret;
}
/* delay to handle clock halt after de-assert operation */
udelay(3);
/*
* WDTCR
* - CKS[7:4] - Clock Division Ratio Select - 0000b: oscclk/1
* - RPSS[13:12] - Window Start Position Select - 00b: 25%
* - RPES[9:8] - Window End Position Select - 00b: 75%
* - TOPS[1:0] - Timeout Period Select - 00b: 1024 cycles (03FFh)
*/
rzv2h_wdt_setup(wdev, WDTCR_CKS_CLK_1 | WDTCR_RPSS_25 |
WDTCR_RPES_75 | WDTCR_TOPS_1024);
rzv2h_wdt_ping(wdev);
/* wait for underflow to trigger... */
udelay(5);
return 0;
}
static const struct watchdog_ops rzv2h_wdt_ops = {
.owner = THIS_MODULE,
.start = rzv2h_wdt_start,
.stop = rzv2h_wdt_stop,
.ping = rzv2h_wdt_ping,
.restart = rzv2h_wdt_restart,
};
static int rzv2h_wdt_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct rzv2h_wdt_priv *priv;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
priv->pclk = devm_clk_get_prepared(&pdev->dev, "pclk");
if (IS_ERR(priv->pclk))
return dev_err_probe(&pdev->dev, PTR_ERR(priv->pclk), "no pclk");
priv->oscclk = devm_clk_get_prepared(&pdev->dev, "oscclk");
if (IS_ERR(priv->oscclk))
return dev_err_probe(&pdev->dev, PTR_ERR(priv->oscclk), "no oscclk");
priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(priv->rstc))
return dev_err_probe(&pdev->dev, PTR_ERR(priv->rstc),
"failed to get cpg reset");
priv->wdev.max_hw_heartbeat_ms = (MILLI * MAX_TIMEOUT_CYCLES * CLOCK_DIV_BY_256) /
clk_get_rate(priv->oscclk);
dev_dbg(dev, "max hw timeout of %dms\n", priv->wdev.max_hw_heartbeat_ms);
ret = devm_pm_runtime_enable(&pdev->dev);
if (ret)
return ret;
priv->wdev.min_timeout = 1;
priv->wdev.timeout = WDT_DEFAULT_TIMEOUT;
priv->wdev.info = &rzv2h_wdt_ident;
priv->wdev.ops = &rzv2h_wdt_ops;
priv->wdev.parent = dev;
watchdog_set_drvdata(&priv->wdev, priv);
watchdog_set_nowayout(&priv->wdev, nowayout);
watchdog_stop_on_unregister(&priv->wdev);
ret = watchdog_init_timeout(&priv->wdev, 0, dev);
if (ret)
dev_warn(dev, "Specified timeout invalid, using default");
return devm_watchdog_register_device(&pdev->dev, &priv->wdev);
}
static const struct of_device_id rzv2h_wdt_ids[] = {
{ .compatible = "renesas,r9a09g057-wdt", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, rzv2h_wdt_ids);
static struct platform_driver rzv2h_wdt_driver = {
.driver = {
.name = "rzv2h_wdt",
.of_match_table = rzv2h_wdt_ids,
},
.probe = rzv2h_wdt_probe,
};
module_platform_driver(rzv2h_wdt_driver);
MODULE_AUTHOR("Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>");
MODULE_DESCRIPTION("Renesas RZ/V2H(P) WDT Watchdog Driver");
MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment