From: Guenter Roeck <linux@roeck-us.net>
To: Rong Zhang <rongrong@oss.cipunited.com>,
Keguang Zhang <keguang.zhang@gmail.com>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Rong Zhang <i@rong.moe>, Yao Zi <me@ziyao.cc>,
Icenowy Zheng <uwu@icenowy.me>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
linux-mips@vger.kernel.org, linux-watchdog@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/4] watchdog: loongson1: Add Loongson-7A watchdog support
Date: Mon, 9 Nov 2026 23:47:26 -0800 [thread overview]
Message-ID: <9525d680-71e7-4dc8-a1fc-1be178453cb2@roeck-us.net> (raw)
In-Reply-To: <20261110-mips-ls7a-wdt-v1-2-968bb85122e6@oss.cipunited.com>
On 11/9/26 23:02, Rong Zhang wrote:
> The Loongson-7A watchdog is similar to Loongson 2K0300, except that it
> has no clock controller.
>
> Retrieve clock frequency from OF to make it work.
>
> Tested on Loongson-LS3A4000-7A1000-NUC-SE and Lenovo KaiTian M530Z.
>
> Signed-off-by: Rong Zhang <rongrong@oss.cipunited.com>
> ---
> drivers/watchdog/loongson1_wdt.c | 29 +++++++++++++++++++++++++----
> 1 file changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/watchdog/loongson1_wdt.c b/drivers/watchdog/loongson1_wdt.c
> index 2811e7eab631..57b9e699c131 100644
> --- a/drivers/watchdog/loongson1_wdt.c
> +++ b/drivers/watchdog/loongson1_wdt.c
> @@ -31,6 +31,7 @@ struct ls1x_wdt_pdata {
> u32 timer_offset;
> u32 set_offset;
> u32 wdt_en_bit;
> + bool no_clk;
> };
>
> static const struct ls1x_wdt_pdata ls1b_wdt_pdata = {
> @@ -45,6 +46,13 @@ static const struct ls1x_wdt_pdata ls2k0300_wdt_pdata = {
> .wdt_en_bit = BIT(1),
> };
>
> +static const struct ls1x_wdt_pdata ls7a_wdt_pdata = {
> + .timer_offset = 0x8,
> + .set_offset = 0x4,
> + .wdt_en_bit = BIT(1),
> + .no_clk = true,
> +};
> +
> struct ls1x_wdt_drvdata {
> void __iomem *base;
> struct clk *clk;
> @@ -129,6 +137,8 @@ static int ls1x_wdt_probe(struct platform_device *pdev)
> struct ls1x_wdt_drvdata *drvdata;
> struct watchdog_device *ls1x_wdt;
> unsigned long clk_rate;
> + u32 freq;
> + int ret;
>
> drvdata = devm_kzalloc_obj(dev, *drvdata);
> if (!drvdata)
> @@ -136,16 +146,26 @@ static int ls1x_wdt_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, drvdata);
>
> drvdata->pdata = of_device_get_match_data(dev);
> + if (!drvdata->pdata)
> + return -ENODEV;
>
> drvdata->base = devm_platform_ioremap_resource(pdev, 0);
> if (IS_ERR(drvdata->base))
> return PTR_ERR(drvdata->base);
>
> - drvdata->clk = devm_clk_get_enabled(dev, NULL);
> - if (IS_ERR(drvdata->clk))
> - return PTR_ERR(drvdata->clk);
> + if (drvdata->pdata->no_clk) {
> + ret = of_property_read_u32(dev->of_node, "clock-frequency", &freq);
> + if (ret)
> + return ret;
> +
> + clk_rate = freq;
> + } else {
> + drvdata->clk = devm_clk_get_enabled(dev, NULL);
> + if (IS_ERR(drvdata->clk))
> + return PTR_ERR(drvdata->clk);
>
Wouldn't it be much easier to just create a fixed rate clock and use it
(as suggested by Sashiko in the devicetree patch) ?
Guenter
> - clk_rate = clk_get_rate(drvdata->clk);
> + clk_rate = clk_get_rate(drvdata->clk);
> + }
> if (!clk_rate)
> return -EINVAL;
> drvdata->clk_rate = clk_rate;
> @@ -191,6 +211,7 @@ static const struct of_device_id ls1x_wdt_dt_ids[] = {
> { .compatible = "loongson,ls1b-wdt", .data = &ls1b_wdt_pdata },
> { .compatible = "loongson,ls1c-wdt", .data = &ls1b_wdt_pdata },
> { .compatible = "loongson,ls2k0300-wdt", .data = &ls2k0300_wdt_pdata },
> + { .compatible = "loongson,ls7a-wdt", .data = &ls7a_wdt_pdata },
> { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, ls1x_wdt_dt_ids);
>
next prev parent reply other threads:[~2026-11-10 7:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 7:02 [PATCH 0/4] " Rong Zhang
2026-11-10 7:02 ` [PATCH 1/4] dt-bindings: watchdog: loongson,ls1x-wdt: Add ls7a-wdt compatible Rong Zhang
2026-11-10 7:02 ` [PATCH 2/4] watchdog: loongson1: Add Loongson-7A watchdog support Rong Zhang
2026-11-10 7:47 ` Guenter Roeck [this message]
2026-11-10 7:59 ` Rong Zhang
2026-11-10 7:02 ` [PATCH 3/4] MIPS: Loongson64: Add watchdog node for LS7A PCH Rong Zhang
2026-11-10 7:02 ` [PATCH 4/4] MIPS: loongson3_defconfig: Enable LOONGSON1_WDT by default Rong Zhang
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=9525d680-71e7-4dc8-a1fc-1be178453cb2@roeck-us.net \
--to=linux@roeck-us.net \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=i@rong.moe \
--cc=jiaxun.yang@flygoat.com \
--cc=keguang.zhang@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=me@ziyao.cc \
--cc=robh@kernel.org \
--cc=rongrong@oss.cipunited.com \
--cc=tsbogend@alpha.franken.de \
--cc=uwu@icenowy.me \
--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®