/* minimum and maximum watchdog trigger timeout, in seconds */ #define MIN_WDT_TIMEOUT 1 #define MAX_WDT_TIMEOUT 255
/* * Base of the WDT registers, from the timer base address. There are * actually 5 watchdogs that can be configured (by pairing with an available * timer), at bases 0x100 + (WDT ID) * 0x20, where WDT ID is 0 through 4. * This driver only configures the first watchdog (WDT ID 0).
*/ #define WDT_BASE 0x100 #define WDT_ID 0
/* * Register base of the timer that's selected for pairing with the watchdog. * This driver arbitrarily uses timer 5, which is currently unused by * other drivers (in particular, the Tegra clocksource driver). If this * needs to change, take care that the new timer is not used by the * clocksource driver.
*/ #define WDT_TIMER_BASE 0x60 #define WDT_TIMER_ID 5
/* * This thing has a fixed 1MHz clock. Normally, we would set the * period to 1 second by writing 1000000ul, but the watchdog system * reset actually occurs on the 4th expiration of this counter, * so we set the period to 1/4 of this amount.
*/
val = 1000000ul / 4;
val |= (TIMER_EN | TIMER_PERIODIC);
writel(val, wdt->tmr_regs + TIMER_PTV);
/* * Set number of periods and start counter. * * Interrupt handler is not required for user space * WDT accesses, since the caller is responsible to ping the * WDT to reset the counter before expiration, through ioctls.
*/
val = WDT_TIMER_ID |
(wdd->timeout << WDT_CFG_PERIOD_SHIFT) |
WDT_CFG_PMC2CAR_RST_EN;
writel(val, wdt->wdt_regs + WDT_CFG);
/* Number of expirations (we are waiting for the 4th expiration) */
exp = (val >> WDT_STS_EXP_SHIFT) & WDT_STS_EXP_MASK;
/* * The entire thing is divided by 4 because we are ticking down 4 times * faster due to needing to wait for the 4th expiration.
*/ return (((3 - exp) * wdd->timeout) + count) / 4;
}
/* This is the timer base. */
regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(regs)) return PTR_ERR(regs);
/* * Allocate our watchdog driver data, which has the * struct watchdog_device nested within it.
*/
wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM;
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.