struct bcm_kona_wdt { void __iomem *base; /* * One watchdog tick is 1/(2^resolution) seconds. Resolution can take * the values 0-15, meaning one tick can be 1s to 30.52us. Our default * resolution of 4 means one tick is 62.5ms. * * The watchdog counter is 20 bits. Depending on resolution, the maximum * counter value of 0xfffff expires after about 12 days (resolution 0) * down to only 32s (resolution 15). The default resolution of 4 gives * us a maximum of about 18 hours and 12 minutes before the watchdog * times out.
*/ int resolution;
spinlock_t lock; #ifdef CONFIG_BCM_KONA_WDT_DEBUG unsignedlong busy_count; struct dentry *debugfs; #endif
};
/* * If the WD_LOAD_FLAG is set, the watchdog counter field is being * updated in hardware. Once the WD timer is updated in hardware, it * gets cleared.
*/ do { if (unlikely(count > 1))
udelay(5);
val = readl_relaxed(wdt->base + offset);
count++;
} while ((val & SECWDOG_WD_LOAD_FLAG) && count < SECWDOG_MAX_TRY);
#ifdef CONFIG_BCM_KONA_WDT_DEBUG /* Remember the maximum number iterations due to WD_LOAD_FLAG */ if (count > wdt->busy_count)
wdt->busy_count = count; #endif
/* This is the only place we return a negative value. */ if (val & SECWDOG_WD_LOAD_FLAG) return -ETIMEDOUT;
/* We always mask out reserved bits. */
val &= SECWDOG_RESERVED_MASK;
wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM;
spin_lock_init(&wdt->lock);
wdt->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(wdt->base)) return PTR_ERR(wdt->base);
wdt->resolution = SECWDOG_DEFAULT_RESOLUTION;
ret = bcm_kona_wdt_set_resolution_reg(wdt); if (ret) {
dev_err(dev, "Failed to set resolution (error: %d)", ret); return ret;
}
ret = bcm_kona_wdt_set_timeout_reg(&bcm_kona_wdt_wdd, 0); if (ret) {
dev_err(dev, "Failed set watchdog timeout"); return ret;
}
watchdog_stop_on_reboot(&bcm_kona_wdt_wdd);
watchdog_stop_on_unregister(&bcm_kona_wdt_wdd);
ret = devm_watchdog_register_device(dev, &bcm_kona_wdt_wdd); if (ret) return ret;
bcm_kona_wdt_debug_init(pdev);
dev_dbg(dev, "Broadcom Kona Watchdog Timer");
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.