cc60cd7a08dd90de302bb2e5d74042204019b703
[openwrt/staging/chunkeey.git] / target / linux / ipq806x / patches-5.4 / 0076-watchdog-qcom-wdt-disable-pretimeout-on-timer-platfo.patch
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
5
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.
10
11 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
12 ---
13 drivers/watchdog/qcom-wdt.c | 31 +++++++++++++++++++++++--------
14 1 file changed, 23 insertions(+), 8 deletions(-)
15
16 --- a/drivers/watchdog/qcom-wdt.c
17 +++ b/drivers/watchdog/qcom-wdt.c
18 @@ -40,6 +40,11 @@ static const u32 reg_offset_data_kpss[]
19 [WDT_BITE_TIME] = 0x14,
20 };
21
22 +struct qcom_wdt_match_data {
23 + const u32 *offset;
24 + bool pretimeout;
25 +};
26 +
27 struct qcom_wdt {
28 struct watchdog_device wdd;
29 unsigned long rate;
30 @@ -179,19 +184,29 @@ static void qcom_clk_disable_unprepare(v
31 clk_disable_unprepare(data);
32 }
33
34 +static const struct qcom_wdt_match_data match_data_apcs_tmr = {
35 + .offset = reg_offset_data_apcs_tmr,
36 + .pretimeout = false,
37 +};
38 +
39 +static const struct qcom_wdt_match_data match_data_kpss = {
40 + .offset = reg_offset_data_kpss,
41 + .pretimeout = true,
42 +};
43 +
44 static int qcom_wdt_probe(struct platform_device *pdev)
45 {
46 struct device *dev = &pdev->dev;
47 struct qcom_wdt *wdt;
48 struct resource *res;
49 struct device_node *np = dev->of_node;
50 - const u32 *regs;
51 + const struct qcom_wdt_match_data *data;
52 u32 percpu_offset;
53 int irq, ret;
54 struct clk *clk;
55
56 - regs = of_device_get_match_data(dev);
57 - if (!regs) {
58 + data = of_device_get_match_data(dev);
59 + if (!data) {
60 dev_err(dev, "Unsupported QCOM WDT module\n");
61 return -ENODEV;
62 }
63 @@ -247,7 +262,7 @@ static int qcom_wdt_probe(struct platfor
64
65 /* check if there is pretimeout support */
66 irq = platform_get_irq_optional(pdev, 0);
67 - if (irq > 0) {
68 + if (data->pretimeout && irq > 0) {
69 ret = devm_request_irq(dev, irq, qcom_wdt_isr,
70 IRQF_TRIGGER_RISING,
71 "wdt_bark", &wdt->wdd);
72 @@ -267,7 +282,7 @@ static int qcom_wdt_probe(struct platfor
73 wdt->wdd.min_timeout = 1;
74 wdt->wdd.max_timeout = 0x10000000U / wdt->rate;
75 wdt->wdd.parent = dev;
76 - wdt->layout = regs;
77 + wdt->layout = data->offset;
78
79 if (readl(wdt_addr(wdt, WDT_STS)) & 1)
80 wdt->wdd.bootstatus = WDIOF_CARDRESET;
81 @@ -311,9 +326,9 @@ static int __maybe_unused qcom_wdt_resum
82 static SIMPLE_DEV_PM_OPS(qcom_wdt_pm_ops, qcom_wdt_suspend, qcom_wdt_resume);
83
84 static const struct of_device_id qcom_wdt_of_table[] = {
85 - { .compatible = "qcom,kpss-timer", .data = reg_offset_data_apcs_tmr },
86 - { .compatible = "qcom,scss-timer", .data = reg_offset_data_apcs_tmr },
87 - { .compatible = "qcom,kpss-wdt", .data = reg_offset_data_kpss },
88 + { .compatible = "qcom,kpss-timer", .data = &match_data_apcs_tmr },
89 + { .compatible = "qcom,scss-timer", .data = &match_data_apcs_tmr },
90 + { .compatible = "qcom,kpss-wdt", .data = &match_data_kpss },
91 { },
92 };
93 MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);