1 From 53ae145a7afa7686e03332d61eed90b7fa7c2529 Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Tue, 4 Feb 2020 19:38:06 +0100
4 Subject: [PATCH v2] watchdog: qcom-wdt: disable pretimeout on timer platform
6 Some platform like ipq806x doesn't support pretimeout and define
7 some interrupts used by qcom,msm-timer. Change the driver to check
8 and use pretimeout only on qcom,kpss-wdt as it's the only platform
9 that actually supports it.
11 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
13 drivers/watchdog/qcom-wdt.c | 31 +++++++++++++++++++++++--------
14 1 file changed, 23 insertions(+), 8 deletions(-)
16 diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
17 index a494543d3ae1..d13c75028985 100644
18 --- a/drivers/watchdog/qcom-wdt.c
19 +++ b/drivers/watchdog/qcom-wdt.c
20 @@ -40,6 +40,11 @@ static const u32 reg_offset_data_kpss[] = {
21 [WDT_BITE_TIME] = 0x14,
24 +struct qcom_wdt_match_data {
30 struct watchdog_device wdd;
32 @@ -179,19 +184,29 @@ static void qcom_clk_disable_unprepare(void *data)
33 clk_disable_unprepare(data);
36 +static const struct qcom_wdt_match_data match_data_apcs_tmr = {
37 + .offset = reg_offset_data_apcs_tmr,
38 + .pretimeout = false,
41 +static const struct qcom_wdt_match_data match_data_kpss = {
42 + .offset = reg_offset_data_kpss,
46 static int qcom_wdt_probe(struct platform_device *pdev)
48 struct device *dev = &pdev->dev;
51 struct device_node *np = dev->of_node;
53 + const struct qcom_wdt_match_data *data;
58 - regs = of_device_get_match_data(dev);
60 + data = of_device_get_match_data(dev);
62 dev_err(dev, "Unsupported QCOM WDT module\n");
65 @@ -247,7 +262,7 @@ static int qcom_wdt_probe(struct platform_device *pdev)
67 /* check if there is pretimeout support */
68 irq = platform_get_irq_optional(pdev, 0);
70 + if (data->pretimeout && irq > 0) {
71 ret = devm_request_irq(dev, irq, qcom_wdt_isr,
73 "wdt_bark", &wdt->wdd);
74 @@ -267,7 +282,7 @@ static int qcom_wdt_probe(struct platform_device *pdev)
75 wdt->wdd.min_timeout = 1;
76 wdt->wdd.max_timeout = 0x10000000U / wdt->rate;
77 wdt->wdd.parent = dev;
79 + wdt->layout = data->offset;
81 if (readl(wdt_addr(wdt, WDT_STS)) & 1)
82 wdt->wdd.bootstatus = WDIOF_CARDRESET;
83 @@ -311,9 +326,9 @@ static int __maybe_unused qcom_wdt_resume(struct device *dev)
84 static SIMPLE_DEV_PM_OPS(qcom_wdt_pm_ops, qcom_wdt_suspend, qcom_wdt_resume);
86 static const struct of_device_id qcom_wdt_of_table[] = {
87 - { .compatible = "qcom,kpss-timer", .data = reg_offset_data_apcs_tmr },
88 - { .compatible = "qcom,scss-timer", .data = reg_offset_data_apcs_tmr },
89 - { .compatible = "qcom,kpss-wdt", .data = reg_offset_data_kpss },
90 + { .compatible = "qcom,kpss-timer", .data = &match_data_apcs_tmr },
91 + { .compatible = "qcom,scss-timer", .data = &match_data_apcs_tmr },
92 + { .compatible = "qcom,kpss-wdt", .data = &match_data_kpss },
95 MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);