watchdog: Add tegra watchdog
Subsystems (3)
PATCH v5 1/1 watchdog: Add tegra watchdog
Add a driver for the hardware watchdogs in NVIDIA Tegra SoCs (Tegra30 and later). This driver will configure one watchdog timer that will reset the system in the case of a watchdog timeout.
This driver binds to the nvidia,tegra30-timer device node and gets its register base from there.
---
Changes from v4:
Skip the error check from the platform_get_resources() call, because devm_ioremap_resource() correctly handles the case when res is NULL.
Changes from v3:
Applied Cuenter Roeck <[email protected]>'s comments. In particular, since tegra_wdt_start() and tegra_wdt_stop() always return success, skip error checking for these calls. Also, removed some unnecessarily verbose logging around which watchdog and timer ID is being used. Fixed typo regarding the ref and unref callback setup. Removed miscdev stuff.
Cuenter was right in that the watchdog doesn't need to be stopped prior to changing the timeout. It is sufficient to just reprogram the watchdog with the new timeout.
Tested on T124.
To do a simple test, "echo 0 > /dev/watchdog0". The target will reset when two minutes (the default heartbeat interval) have expired since the last write to /dev/watchdog0.
Documentation/watchdog/watchdog-parameters.txt | 5 + drivers/watchdog/Kconfig | 11 + drivers/watchdog/Makefile | 1 + drivers/watchdog/tegra_wdt.c | 327 +++++++++++++++++++++++++ 4 files changed, 344 insertions(+) create mode 100644 drivers/watchdog/tegra_wdt.c
Documentation/watchdog/watchdog-parameters.txt +5 -0
@@ -325,6 +325,11 @@ soft_noboot: Softdog action, set to 1 to ignore reboots, 0 to reboot stmp3xxx_wdt: heartbeat: Watchdog heartbeat period in seconds from 1 to 4194304, default 19 ------------------------------------------------- +tegra_wdt: +heartbeat: Watchdog heartbeats in seconds. (default = 120) +nowayout: Watchdog cannot be stopped once started + (default=kernel config parameter) +------------------------------------------------- ts72xx_wdt: timeout: Watchdog timeout in seconds. (1 <= timeout <= 8, default=8) nowayout: Disable watchdog shutdown on close
drivers/watchdog/Kconfig +11 -0
@@ -420,6 +420,17 @@ config SIRFSOC_WATCHDOG Support for CSR SiRFprimaII and SiRFatlasVI watchdog. When the watchdog triggers the system will be reset. +config TEGRA_WATCHDOG + tristate "Tegra watchdog" + depends on ARCH_TEGRA || COMPILE_TEST + select WATCHDOG_CORE + help + Say Y here to include support for the watchdog timer + embedded in NVIDIA Tegra SoCs. + + To compile this driver as a module, choose M here: the + module will be called tegra_wdt. + # AVR32 Architecture config AT32AP700X_WDT
drivers/watchdog/Makefile +1 -0
@@ -58,6 +58,7 @@ obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o obj-$(CONFIG_MOXART_WDT) += moxart_wdt.o obj-$(CONFIG_SIRFSOC_WATCHDOG) += sirfsoc_wdt.o obj-$(CONFIG_BCM_KONA_WDT) += bcm_kona_wdt.o +obj-$(CONFIG_TEGRA_WATCHDOG) += tegra_wdt.o # AVR32 Architecture obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
drivers/watchdog/tegra_wdt.c new file +327 -0
327 lines not on this page · raw message
Signature · 1 line
1.8.1.5
Quoted 8 lines · Andrew Chew
Add a driver for the hardware watchdogs in NVIDIA Tegra SoCs (Tegra30 and later). This driver will configure one watchdog timer that will reset the system in the case of a watchdog timeout.
This driver binds to the nvidia,tegra30-timer device node and gets its register base from there.
Signed-off-by Andrew Chew <[email protected]>
Quoted 11 lines · Andrew Chew
Quoted 8 lines
Add a driver for the hardware watchdogs in NVIDIA Tegra SoCs (Tegra30 and later). This driver will configure one watchdog timer that will reset the system in the case of a watchdog timeout.
This driver binds to the nvidia,tegra30-timer device node and gets its register base from there.
Signed-off-by Andrew Chew <[email protected]>Reviewed-by Guenter Roeck <[email protected]>
Thanks, Guenter.
Pinging other potential reviewers. Any other comments for me, guys?
Quoted 6 lines · Andrew Chew
Add a driver for the hardware watchdogs in NVIDIA Tegra SoCs (Tegra30 and later). This driver will configure one watchdog timer that will reset the system in the case of a watchdog timeout.
This driver binds to the nvidia,tegra30-timer device node and gets its register base from there.
Briefly,
Just a couple small comments though.
Quoted 5 lines
drivers/watchdog/tegra_wdt.c +3
-0+static void tegra_wdt_ref (struct watchdog_device *wdd) +{ +struct tegra_wdt *wdt =watchdog_get_drvdata (wdd);
drivers/watchdog/tegra_wdt.c line 188
Quoted 10 lines
drivers/watchdog/tegra_wdt.c +10
-0+ +kref_get (&wdt->kref); +} + +static void tegra_wdt_unref (struct watchdog_device *wdd) +{ +struct tegra_wdt *wdt =watchdog_get_drvdata (wdd); + +kref_put (&wdt->kref, tegra_wdt_release_resources); +}
I forget why these were needed; they seem to do nothing.
Quoted 1 line
+MODULE_LICENSE("GPL");
That should be "GPL v2" according to the license header in the file.
Quoted 6 lines
drivers/watchdog/tegra_wdt.c
Quoted 4 lines
drivers/watchdog/tegra_wdt.c new file +4
-0+static void tegra_wdt_unref (struct watchdog_device *wdd) { +struct tegra_wdt *wdt =watchdog_get_drvdata (wdd); + +kref_put (&wdt->kref, tegra_wdt_release_resources); }I forget why these were needed; they seem to do nothing.
The reason I did the whole kref thing was by following the guidance in Documentation/watchdog/watchdog-kernel-api.txt, which says that if the watchdog_device struct is dynamically allocated, then one needs this.
Quoted 3 lines
Quoted 1 line
+MODULE_LICENSE("GPL");
That should be "GPL v2" according to the license header in the file.
Done. Thanks!
Guenter Roeck
maintainerQuoted 7 lines · Andrew Chew
Quoted 6 lines
drivers/watchdog/tegra_wdt.c
Quoted 4 lines
drivers/watchdog/tegra_wdt.c new file +4
-0+static void tegra_wdt_unref (struct watchdog_device *wdd) { +struct tegra_wdt *wdt =watchdog_get_drvdata (wdd); + +kref_put (&wdt->kref, tegra_wdt_release_resources); }I forget why these were needed; they seem to do nothing.
Quoted 5 lines
The reason I did the whole kref thing was by following the guidance in
Documentation/watchdog/watchdog-kernel-api.txt, which says that if thewatchdog_devicestruct is dynamically allocated, then one needs this.
I read that too, but I could not follow the logic behind it, nor the explanation provided with the commit introducing it ;-)
Guenter