0076-watchdog-qcom-wdt-disable-pretimeout-on-timer-platfo.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 53ae145a7afa7686e03332d61eed90b7fa7c2529 Mon Sep 17 00:00:00 2001
  2. From: Ansuel Smith <[email protected]>
  3. Date: Tue, 4 Feb 2020 19:38:06 +0100
  4. Subject: [PATCH v2] watchdog: qcom-wdt: disable pretimeout on timer platform
  5. Some platform like ipq806x doesn't support pretimeout and define
  6. some interrupts used by qcom,msm-timer. Change the driver to check
  7. and use pretimeout only on qcom,kpss-wdt as it's the only platform
  8. that actually supports it.
  9. Signed-off-by: Ansuel Smith <[email protected]>
  10. ---
  11. drivers/watchdog/qcom-wdt.c | 31 +++++++++++++++++++++++--------
  12. 1 file changed, 23 insertions(+), 8 deletions(-)
  13. --- a/drivers/watchdog/qcom-wdt.c
  14. +++ b/drivers/watchdog/qcom-wdt.c
  15. @@ -40,6 +40,11 @@ static const u32 reg_offset_data_kpss[]
  16. [WDT_BITE_TIME] = 0x14,
  17. };
  18. +struct qcom_wdt_match_data {
  19. + const u32 *offset;
  20. + bool pretimeout;
  21. +};
  22. +
  23. struct qcom_wdt {
  24. struct watchdog_device wdd;
  25. unsigned long rate;
  26. @@ -179,19 +184,29 @@ static void qcom_clk_disable_unprepare(v
  27. clk_disable_unprepare(data);
  28. }
  29. +static const struct qcom_wdt_match_data match_data_apcs_tmr = {
  30. + .offset = reg_offset_data_apcs_tmr,
  31. + .pretimeout = false,
  32. +};
  33. +
  34. +static const struct qcom_wdt_match_data match_data_kpss = {
  35. + .offset = reg_offset_data_kpss,
  36. + .pretimeout = true,
  37. +};
  38. +
  39. static int qcom_wdt_probe(struct platform_device *pdev)
  40. {
  41. struct device *dev = &pdev->dev;
  42. struct qcom_wdt *wdt;
  43. struct resource *res;
  44. struct device_node *np = dev->of_node;
  45. - const u32 *regs;
  46. + const struct qcom_wdt_match_data *data;
  47. u32 percpu_offset;
  48. int irq, ret;
  49. struct clk *clk;
  50. - regs = of_device_get_match_data(dev);
  51. - if (!regs) {
  52. + data = of_device_get_match_data(dev);
  53. + if (!data) {
  54. dev_err(dev, "Unsupported QCOM WDT module\n");
  55. return -ENODEV;
  56. }
  57. @@ -247,7 +262,7 @@ static int qcom_wdt_probe(struct platfor
  58. /* check if there is pretimeout support */
  59. irq = platform_get_irq_optional(pdev, 0);
  60. - if (irq > 0) {
  61. + if (data->pretimeout && irq > 0) {
  62. ret = devm_request_irq(dev, irq, qcom_wdt_isr,
  63. IRQF_TRIGGER_RISING,
  64. "wdt_bark", &wdt->wdd);
  65. @@ -267,7 +282,7 @@ static int qcom_wdt_probe(struct platfor
  66. wdt->wdd.min_timeout = 1;
  67. wdt->wdd.max_timeout = 0x10000000U / wdt->rate;
  68. wdt->wdd.parent = dev;
  69. - wdt->layout = regs;
  70. + wdt->layout = data->offset;
  71. if (readl(wdt_addr(wdt, WDT_STS)) & 1)
  72. wdt->wdd.bootstatus = WDIOF_CARDRESET;
  73. @@ -311,9 +326,9 @@ static int __maybe_unused qcom_wdt_resum
  74. static SIMPLE_DEV_PM_OPS(qcom_wdt_pm_ops, qcom_wdt_suspend, qcom_wdt_resume);
  75. static const struct of_device_id qcom_wdt_of_table[] = {
  76. - { .compatible = "qcom,kpss-timer", .data = reg_offset_data_apcs_tmr },
  77. - { .compatible = "qcom,scss-timer", .data = reg_offset_data_apcs_tmr },
  78. - { .compatible = "qcom,kpss-wdt", .data = reg_offset_data_kpss },
  79. + { .compatible = "qcom,kpss-timer", .data = &match_data_apcs_tmr },
  80. + { .compatible = "qcom,scss-timer", .data = &match_data_apcs_tmr },
  81. + { .compatible = "qcom,kpss-wdt", .data = &match_data_kpss },
  82. { },
  83. };
  84. MODULE_DEVICE_TABLE(of, qcom_wdt_of_table);