From: Guenter Roeck <linux@roeck-us.net>
To: Prabhakar <prabhakar.csengg@gmail.com>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Rob Herring <robh@kernel.org>,
linux-watchdog@vger.kernel.org
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-renesas-soc@vger.kernel.org,
Biju Das <biju.das.jz@bp.renesas.com>,
Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: Re: [RFC PATCH] watchdog: rzv2h_wdt: Add support to retrieve the bootstatus information
Date: Fri, 13 Dec 2024 10:03:14 -0800 [thread overview]
Message-ID: <4d3e6f12-7cea-45ce-b1e2-c1fda94b92cd@roeck-us.net> (raw)
In-Reply-To: <20241213174419.908525-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
On 12/13/24 09:44, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> On the RZ/V2H(P) SoC we can determine if the current boot is due to
> `Power-on-Reset` or due to the `Watchdog`. The information used to
> determine this is present on the CPG block.
>
> The CPG_ERROR_RSTm(m = 2 -8 ) registers are set in response to an error
> interrupt causing an reset. CPG_ERROR_RST2[ERROR_RST1] is set if there
> was an underflow/overflow on WDT1 causing an error interrupt.
>
> To fetch this information from CPG block `syscon` is used and bootstatus
> field in the watchdog device is updated based on the
> CPG_ERROR_RST2[ERROR_RST1] bit. Upon consumig CPG_ERROR_RST2[ERROR_RST1]
> bit we are also clearing it.
>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> @Geert, I intend to drop WDT0/2/3 nodes (and related clocks) as HW manual
> says WDT1 is for CA55 (I'll first confirm this internally)
>
> Hi Geert/Rob,
>
> I havent included a binding changes as part of the RFC as I wanted to get
> some initial feedback on the implementation. Currently CPG block doesnt
> have the "syscon" this patch has been tested with below diff to SoC DTSI
>
> Cheers,
> Prabhakar
>
> Changes to SoC DTSI:
> @@ -243,7 +243,7 @@ pinctrl: pinctrl@10410000 {
> };
>
> cpg: clock-controller@10420000 {
> - compatible = "renesas,r9a09g057-cpg";
> + compatible = "renesas,r9a09g057-cpg", "syscon";
> reg = <0 0x10420000 0 0x10000>;
> clocks = <&audio_extal_clk>, <&rtxin_clk>, <&qextal_clk>;
> clock-names = "audio_extal", "rtxin", "qextal";
> @@ -455,6 +456,7 @@ wdt1: watchdog@14400000 {
> clock-names = "pclk", "oscclk";
> resets = <&cpg 0x76>;
> power-domains = <&cpg>;
> + syscon = <&cpg>;
> status = "disabled";
> };
>
> ---
> drivers/watchdog/rzv2h_wdt.c | 27 ++++++++++++++++++++++++++-
> 1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/rzv2h_wdt.c b/drivers/watchdog/rzv2h_wdt.c
> index 8defd0241213..8e0901bb7d2b 100644
> --- a/drivers/watchdog/rzv2h_wdt.c
> +++ b/drivers/watchdog/rzv2h_wdt.c
> @@ -4,14 +4,17 @@
> *
> * Copyright (C) 2024 Renesas Electronics Corporation.
> */
> +#include <linux/bitfield.h>
> #include <linux/clk.h>
> #include <linux/delay.h>
> #include <linux/io.h>
> #include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/pm_runtime.h>
> +#include <linux/regmap.h>
> #include <linux/reset.h>
> #include <linux/units.h>
> #include <linux/watchdog.h>
> @@ -40,6 +43,10 @@
>
> #define WDT_DEFAULT_TIMEOUT 60U
>
> +#define CPG_ERROR_RST2 0xb40
> +#define CPG_ERROR_RST2_ERR_RST1 BIT(1)
> +#define CPG_ERROR_RST2_ERR_RST1_WEN (BIT(1) << 16)
I could understand BIT(17) or BIT(1 + 16) or
#define CPG_ERROR_RST2_ERR_RST1_BIT 1
#define CPG_ERROR_RST2_ERR_RST1 BIT(CPG_ERROR_RST2_ERR_RST1_BIT)
#define CPG_ERROR_RST2_ERR_RST1_WEN BIT(CPG_ERROR_RST2_ERR_RST1_BIT + 16)
but "BIT(1) << 16" really does not add value.
> +
> static bool nowayout = WATCHDOG_NOWAYOUT;
> module_param(nowayout, bool, 0);
> MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
> @@ -135,7 +142,7 @@ static int rzv2h_wdt_stop(struct watchdog_device *wdev)
> }
>
> static const struct watchdog_info rzv2h_wdt_ident = {
> - .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT,
> + .options = WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_CARDRESET,
> .identity = "Renesas RZ/V2H WDT Watchdog",
> };
>
> @@ -207,12 +214,29 @@ static int rzv2h_wdt_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct rzv2h_wdt_priv *priv;
> + struct regmap *regmap;
> + unsigned int buf;
That is a bad variable name since it suggests a buffer, not some
register content.
> int ret;
>
> priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> if (!priv)
> return -ENOMEM;
>
> + regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
That is a change in behavior. Up to now the syscon phandle did not have to exist
for the driver to work. Is it guaranteed to not result in regressions on systems
where it doesn't ? Also, is this documented ? I don't seem to be able to find it.
> + ret = regmap_read(regmap, CPG_ERROR_RST2, &buf);
> + if (ret)
> + return -EINVAL;
Pass error codes back to caller. This is most definitely not an
"Invalid argument".
"
> +
> + if (buf & CPG_ERROR_RST2_ERR_RST1) {
> + ret = regmap_write(regmap, CPG_ERROR_RST2,
> + CPG_ERROR_RST2_ERR_RST1_WEN | CPG_ERROR_RST2_ERR_RST1);
> + if (ret)
> + return -EINVAL;
Same as above.
> + }
> +
> priv->base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(priv->base))
> return PTR_ERR(priv->base);
> @@ -243,6 +267,7 @@ static int rzv2h_wdt_probe(struct platform_device *pdev)
> priv->wdev.info = &rzv2h_wdt_ident;
> priv->wdev.ops = &rzv2h_wdt_ops;
> priv->wdev.parent = dev;
> + priv->wdev.bootstatus = buf & CPG_ERROR_RST2_ERR_RST1 ? WDIOF_CARDRESET : 0;
> watchdog_set_drvdata(&priv->wdev, priv);
> watchdog_set_nowayout(&priv->wdev, nowayout);
> watchdog_stop_on_unregister(&priv->wdev);
next prev parent reply other threads:[~2024-12-13 18:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-13 17:44 Prabhakar
2024-12-13 18:03 ` Guenter Roeck [this message]
2024-12-13 19:08 ` Lad, Prabhakar
2024-12-14 11:32 ` Biju Das
2024-12-14 21:36 ` Lad, Prabhakar
2024-12-15 9:15 ` Biju Das
2024-12-16 13:14 ` Lad, Prabhakar
2024-12-16 15:08 ` Biju Das
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=4d3e6f12-7cea-45ce-b1e2-c1fda94b92cd@roeck-us.net \
--to=linux@roeck-us.net \
--cc=biju.das.jz@bp.renesas.com \
--cc=devicetree@vger.kernel.org \
--cc=fabrizio.castro.jz@renesas.com \
--cc=geert+renesas@glider.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=prabhakar.csengg@gmail.com \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=robh@kernel.org \
--cc=wim@linux-watchdog.org \
/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
all inboxes | Powered by JetHome®