// SPDX-License-Identifier: GPL-2.0 /* * Renesas RZ/N1 Watchdog timer. * This is a 12-bit timer driver from a (62.5/16384) MHz clock. It can't even * cope with 2 seconds. * * Copyright 2018 Renesas Electronics Europe Ltd. * * Derived from Ralink RT288x watchdog timer.
*/
/* * The hardware allows you to write to this reg only once. * Since this includes the reload value, there is no way to change the * timeout once started. Also note that the WDT clock is half the bus * fabric clock rate, so if the bus fabric clock rate is changed after * the WDT is started, the WDT interval will be wrong.
*/
val = RZN1_WDT_RETRIGGER_WDSI;
val |= RZN1_WDT_RETRIGGER_ENABLE;
val |= RZN1_WDT_RETRIGGER_PRESCALE;
val |= compute_reload_value(w->max_hw_heartbeat_ms, wdt->clk_rate_khz);
writel(val, wdt->base + RZN1_WDT_RETRIGGER);
wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM;
wdt->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base);
irq = platform_get_irq(pdev, 0); if (irq < 0) return irq;
ret = devm_request_irq(dev, irq, rzn1_wdt_irq, 0,
np->name, wdt); if (ret) {
dev_err(dev, "failed to request irq %d\n", irq); return ret;
}
clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(clk)) {
dev_err(dev, "failed to get the clock\n"); return PTR_ERR(clk);
}
clk_rate = clk_get_rate(clk); if (!clk_rate) {
dev_err(dev, "failed to get the clock rate\n"); return -EINVAL;
}
wdt->clk_rate_khz = clk_rate / 1000;
wdt->wdtdev.info = &rzn1_wdt_info;
wdt->wdtdev.ops = &rzn1_wdt_ops;
wdt->wdtdev.status = WATCHDOG_NOWAYOUT_INIT_STATUS;
wdt->wdtdev.parent = dev; /* * The period of the watchdog cannot be changed once set * and is limited to a very short period. * Configure it for a 1s period once and for all, and * rely on the heart-beat provided by the watchdog core * to make this usable by the user-space.
*/
wdt->wdtdev.max_hw_heartbeat_ms = max_heart_beat_ms(wdt->clk_rate_khz); if (wdt->wdtdev.max_hw_heartbeat_ms > 1000)
wdt->wdtdev.max_hw_heartbeat_ms = 1000;
wdt->wdtdev.timeout = DEFAULT_TIMEOUT;
ret = watchdog_init_timeout(&wdt->wdtdev, 0, dev); if (ret) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.