Skip to content

Commit ef6080f

Browse files
prabhakarladWim Van Sebroeck
authored andcommitted
watchdog: rzv2h: Add support for configurable count clock source
Add support for selecting the count clock source used by the watchdog timer. The RZ/V2H(P) SoC uses the LOCO as the count source, whereas on RZ/T2H and RZ/N2H SoCs, the count source is the peripheral clock (PCLKL). Introduce a `count_source` field in the SoC-specific data structure and refactor the clock rate selection logic accordingly. This prepares the driver for supporting the RZ/T2H and RZ/N2H SoCs, which differ in their watchdog clocking architecture from RZ/V2H(P). Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
1 parent 6229b35 commit ef6080f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

drivers/watchdog/rzv2h_wdt.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,18 @@ module_param(nowayout, bool, 0);
4242
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
4343
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
4444

45+
enum rzv2h_wdt_count_source {
46+
COUNT_SOURCE_LOCO,
47+
COUNT_SOURCE_PCLK,
48+
};
49+
4550
struct rzv2h_of_data {
4651
u8 cks_min;
4752
u8 cks_max;
4853
u16 cks_div;
4954
u8 tops;
5055
u16 timeout_cycles;
56+
enum rzv2h_wdt_count_source count_source;
5157
};
5258

5359
struct rzv2h_wdt_priv {
@@ -214,6 +220,7 @@ static int rzv2h_wdt_probe(struct platform_device *pdev)
214220
{
215221
struct device *dev = &pdev->dev;
216222
struct rzv2h_wdt_priv *priv;
223+
struct clk *count_clk;
217224
int ret;
218225

219226
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -239,8 +246,19 @@ static int rzv2h_wdt_probe(struct platform_device *pdev)
239246
return dev_err_probe(dev, PTR_ERR(priv->rstc),
240247
"failed to get cpg reset");
241248

249+
switch (priv->of_data->count_source) {
250+
case COUNT_SOURCE_LOCO:
251+
count_clk = priv->oscclk;
252+
break;
253+
case COUNT_SOURCE_PCLK:
254+
count_clk = priv->pclk;
255+
break;
256+
default:
257+
return dev_err_probe(dev, -EINVAL, "Invalid count source\n");
258+
}
259+
242260
priv->wdev.max_hw_heartbeat_ms = (MILLI * priv->of_data->timeout_cycles *
243-
priv->of_data->cks_div) / clk_get_rate(priv->oscclk);
261+
priv->of_data->cks_div) / clk_get_rate(count_clk);
244262
dev_dbg(dev, "max hw timeout of %dms\n", priv->wdev.max_hw_heartbeat_ms);
245263

246264
ret = devm_pm_runtime_enable(dev);
@@ -269,6 +287,7 @@ static const struct rzv2h_of_data rzv2h_wdt_of_data = {
269287
.cks_div = 256,
270288
.tops = WDTCR_TOPS_16384,
271289
.timeout_cycles = 16384,
290+
.count_source = COUNT_SOURCE_LOCO,
272291
};
273292

274293
static const struct of_device_id rzv2h_wdt_ids[] = {

0 commit comments

Comments
 (0)