Skip to content

Commit

Permalink
watchdog: rzg2l_wdt: Add rzv2m support
Browse files Browse the repository at this point in the history
The WDT on RZ/V2M devices is basically the same as RZ/G2L, but without
the parity error registers. This means the driver has to reset the
hardware plus set the minimum timeout in order to do a restart and has
a single interrupt.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20220823093233.8577-3-phil.edworthy@renesas.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
  • Loading branch information
Phil Edworthy authored and Wim Van Sebroeck committed Oct 2, 2022
1 parent d59913b commit ec122fd
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions drivers/watchdog/rzg2l_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/reset.h>
Expand Down Expand Up @@ -40,6 +40,11 @@ module_param(nowayout, bool, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");

enum rz_wdt_type {
WDT_RZG2L,
WDT_RZV2M,
};

struct rzg2l_wdt_priv {
void __iomem *base;
struct watchdog_device wdev;
Expand All @@ -48,6 +53,7 @@ struct rzg2l_wdt_priv {
unsigned long delay;
struct clk *pclk;
struct clk *osc_clk;
enum rz_wdt_type devtype;
};

static void rzg2l_wdt_wait_delay(struct rzg2l_wdt_priv *priv)
Expand Down Expand Up @@ -142,11 +148,29 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev,
clk_prepare_enable(priv->pclk);
clk_prepare_enable(priv->osc_clk);

/* Generate Reset (WDTRSTB) Signal on parity error */
rzg2l_wdt_write(priv, 0, PECR);
if (priv->devtype == WDT_RZG2L) {
/* Generate Reset (WDTRSTB) Signal on parity error */
rzg2l_wdt_write(priv, 0, PECR);

/* Force parity error */
rzg2l_wdt_write(priv, PEEN_FORCE, PEEN);
} else {
/* RZ/V2M doesn't have parity error registers */

wdev->timeout = 0;

/* Initialize time out */
rzg2l_wdt_init_timeout(wdev);

/* Force parity error */
rzg2l_wdt_write(priv, PEEN_FORCE, PEEN);
/* Initialize watchdog counter register */
rzg2l_wdt_write(priv, 0, WDTTIM);

/* Enable watchdog timer*/
rzg2l_wdt_write(priv, WDTCNT_WDTEN, WDTCNT);

/* Wait 2 consecutive overflow cycles for reset */
mdelay(DIV_ROUND_UP(2 * 0xFFFFF * 1000, priv->osc_clk_rate));
}

return 0;
}
Expand Down Expand Up @@ -227,6 +251,8 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret, "failed to deassert");

priv->devtype = (uintptr_t)of_device_get_match_data(dev);

pm_runtime_enable(&pdev->dev);

priv->wdev.info = &rzg2l_wdt_ident;
Expand Down Expand Up @@ -255,7 +281,8 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
}

static const struct of_device_id rzg2l_wdt_ids[] = {
{ .compatible = "renesas,rzg2l-wdt", },
{ .compatible = "renesas,rzg2l-wdt", .data = (void *)WDT_RZG2L },
{ .compatible = "renesas,rzv2m-wdt", .data = (void *)WDT_RZV2M },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, rzg2l_wdt_ids);
Expand Down

0 comments on commit ec122fd

Please sign in to comment.