[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <2d539bc944f3e8fc70f39728b0f61fd171b2e5bf.1411513109.git.joshc@codeaurora.org>
Date: Tue, 23 Sep 2014 18:04:38 -0500
From: Josh Cartwright <joshc@...eaurora.org>
To: Wim Van Sebroeck <wim@...ana.be>, linux-watchdog@...r.kernel.org
Cc: linux-arm-msm@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Kumar Gala <galak@...eaurora.org>, linux-kernel@...r.kernel.org
Subject: [PATCH v2 3/3] watchdog: qcom: register a restart notifier
The WDT's BITE_TIME warm-reset behavior can be leveraged as a last
resort mechanism for triggering chip reset. Usually, other restart
methods (such as PS_HOLD) are preferrable for issuing a more complete
reset of the chip. As such, keep the priority of the watchdog notifier
low.
Signed-off-by: Josh Cartwright <joshc@...eaurora.org>
---
drivers/watchdog/qcom-wdt.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
index d5e46e2..eba92ef 100644
--- a/drivers/watchdog/qcom-wdt.c
+++ b/drivers/watchdog/qcom-wdt.c
@@ -16,6 +16,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/reboot.h>
#include <linux/watchdog.h>
#define WDT_RST 0x0
@@ -25,6 +26,7 @@
struct qcom_wdt {
struct watchdog_device wdd;
struct clk *clk;
+ struct notifier_block restart_nb;
void __iomem *base;
};
@@ -86,6 +88,23 @@ static const struct watchdog_info qcom_wdt_info = {
.identity = KBUILD_MODNAME,
};
+static int qcom_wdt_restart(struct notifier_block *nb, unsigned long action,
+ void *data)
+{
+ struct qcom_wdt *wdt = container_of(nb, struct qcom_wdt, restart_nb);
+
+ /*
+ * Trigger watchdog bite:
+ * Setup BITE_TIME to be very low, and enable WDT.
+ * 0x31F3 => 390ms @ 32kHz, also value at reset
+ */
+ writel(0, wdt->base + WDT_EN);
+ writel(1, wdt->base + WDT_RST);
+ writel(0x31F3, wdt->base + WDT_BITE_TIME);
+ writel(1, wdt->base + WDT_EN);
+ return NOTIFY_DONE;
+}
+
static int qcom_wdt_probe(struct platform_device *pdev)
{
struct qcom_wdt *wdt;
@@ -141,6 +160,14 @@ static int qcom_wdt_probe(struct platform_device *pdev)
return ret;
}
+ /*
+ * WDT restart notifier has priority 0 (use as a last resort)
+ */
+ wdt->restart_nb.notifier_call = qcom_wdt_restart;
+ ret = register_restart_handler(&wdt->restart_nb);
+ if (ret)
+ dev_err(&pdev->dev, "failed to setup restart handler\n");
+
platform_set_drvdata(pdev, wdt);
return 0;
}
@@ -149,6 +176,7 @@ static int qcom_wdt_remove(struct platform_device *pdev)
{
struct qcom_wdt *wdt = platform_get_drvdata(pdev);
+ unregister_restart_handler(&wdt->restart_nb);
watchdog_unregister_device(&wdt->wdd);
clk_disable_unprepare(wdt->clk);
return 0;
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists