0007-watchdog-ixp4xx-Make-sure-restart-always-works.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From b09e5ea32e099821b1cddc1e26e625ad994ba11e Mon Sep 17 00:00:00 2001
  2. From: Linus Walleij <[email protected]>
  3. Date: Sun, 24 Sep 2023 21:20:24 +0200
  4. Subject: [PATCH] watchdog: ixp4xx: Make sure restart always works
  5. The IXP4xx watchdog in early "A0" silicon is unreliable and
  6. cannot be registered, however for some systems such as the
  7. USRobotics USR8200 the watchdog is the only restart option,
  8. so implement a "dummy" watchdog that can only support restart
  9. in this case.
  10. Fixes: 1aea522809e6 ("watchdog: ixp4xx: Implement restart")
  11. Signed-off-by: Linus Walleij <[email protected]>
  12. ---
  13. Other solutions like implementing a pure restart notifier
  14. callback catch in the driver is possible, but this method
  15. will minimize the amount of code and reuse infrastructure
  16. in the core.
  17. ---
  18. drivers/watchdog/ixp4xx_wdt.c | 28 +++++++++++++++++++++++++---
  19. 1 file changed, 25 insertions(+), 3 deletions(-)
  20. --- a/drivers/watchdog/ixp4xx_wdt.c
  21. +++ b/drivers/watchdog/ixp4xx_wdt.c
  22. @@ -105,6 +105,25 @@ static const struct watchdog_ops ixp4xx_
  23. .owner = THIS_MODULE,
  24. };
  25. +/*
  26. + * The A0 version of the IXP422 had a bug in the watchdog making
  27. + * is useless, but we still need to use it to restart the system
  28. + * as it is the only way, so in this special case we register a
  29. + * "dummy" watchdog that doesn't really work, but will support
  30. + * the restart operation.
  31. + */
  32. +static int ixp4xx_wdt_dummy(struct watchdog_device *wdd)
  33. +{
  34. + return 0;
  35. +}
  36. +
  37. +static const struct watchdog_ops ixp4xx_wdt_restart_only_ops = {
  38. + .start = ixp4xx_wdt_dummy,
  39. + .stop = ixp4xx_wdt_dummy,
  40. + .restart = ixp4xx_wdt_restart,
  41. + .owner = THIS_MODULE,
  42. +};
  43. +
  44. static const struct watchdog_info ixp4xx_wdt_info = {
  45. .options = WDIOF_KEEPALIVEPING
  46. | WDIOF_MAGICCLOSE
  47. @@ -120,14 +139,17 @@ static void ixp4xx_clock_action(void *d)
  48. static int ixp4xx_wdt_probe(struct platform_device *pdev)
  49. {
  50. + static const struct watchdog_ops *iwdt_ops;
  51. struct device *dev = &pdev->dev;
  52. struct ixp4xx_wdt *iwdt;
  53. struct clk *clk;
  54. int ret;
  55. if (!(read_cpuid_id() & 0xf) && !cpu_is_ixp46x()) {
  56. - dev_err(dev, "Rev. A0 IXP42x CPU detected - watchdog disabled\n");
  57. - return -ENODEV;
  58. + dev_err(dev, "Rev. A0 IXP42x CPU detected - only restart supported\n");
  59. + iwdt_ops = &ixp4xx_wdt_restart_only_ops;
  60. + } else {
  61. + iwdt_ops = &ixp4xx_wdt_ops;
  62. }
  63. iwdt = devm_kzalloc(dev, sizeof(*iwdt), GFP_KERNEL);
  64. @@ -153,7 +175,7 @@ static int ixp4xx_wdt_probe(struct platf
  65. iwdt->rate = IXP4XX_TIMER_FREQ;
  66. iwdt->wdd.info = &ixp4xx_wdt_info;
  67. - iwdt->wdd.ops = &ixp4xx_wdt_ops;
  68. + iwdt->wdd.ops = iwdt_ops;
  69. iwdt->wdd.min_timeout = 1;
  70. iwdt->wdd.max_timeout = U32_MAX / iwdt->rate;
  71. iwdt->wdd.parent = dev;