302-arm-compressed-set-ipq40xx-watchdog-to-allow-boot.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From 11d6a6128a5a07c429941afc202b6e62a19771be Mon Sep 17 00:00:00 2001
  2. From: John Thomson <[email protected]>
  3. Date: Fri, 23 Oct 2020 19:42:36 +1000
  4. Subject: [PATCH 2/2] arm: compressed: set ipq40xx watchdog to allow boot
  5. For IPQ40XX systems where the SoC watchdog is activated before linux,
  6. the watchdog timer may be too small for linux to finish uncompress,
  7. boot, and watchdog management start.
  8. If the watchdog is enabled, set the timeout for it to 30 seconds.
  9. The functionality and offsets were copied from:
  10. drivers/watchdog/qcom-wdt.c qcom_wdt_set_timeout & qcom_wdt_start
  11. The watchdog memory address was taken from:
  12. arch/arm/boot/dts/qcom-ipq4019.dtsi
  13. This was required on Mikrotik IPQ40XX consumer hardware using Mikrotik's
  14. RouterBoot bootloader.
  15. Signed-off-by: John Thomson <[email protected]>
  16. ---
  17. arch/arm/boot/compressed/head.S | 35 +++++++++++++++++++++++++++++++++
  18. 1 file changed, 35 insertions(+)
  19. --- a/arch/arm/boot/compressed/head.S
  20. +++ b/arch/arm/boot/compressed/head.S
  21. @@ -620,6 +620,41 @@ not_relocated: mov r0, #0
  22. bic r4, r4, #1
  23. blne cache_on
  24. +/* Set the Qualcom IPQ40xx watchdog timeout to 30 seconds
  25. + * if it is enabled, so that there is time for kernel
  26. + * to decompress, boot, and take over the watchdog.
  27. + * data and functionality from drivers/watchdog/qcom-wdt.c
  28. + * address from arch/arm/boot/dts/qcom-ipq4019.dtsi
  29. + */
  30. +#ifdef CONFIG_ARCH_IPQ40XX
  31. +watchdog_set:
  32. + /* offsets:
  33. + * 0x04 reset (=1 resets countdown)
  34. + * 0x08 enable (=0 disables)
  35. + * 0x0c status (=1 when SoC was reset by watchdog)
  36. + * 0x10 bark (=timeout warning in ticks)
  37. + * 0x14 bite (=timeout reset in ticks)
  38. + * clock rate is 1<<15 hertz
  39. + */
  40. + .equ watchdog, 0x0b017000 @Store watchdog base address
  41. + movw r0, #:lower16:watchdog
  42. + movt r0, #:upper16:watchdog
  43. + ldr r1, [r0, #0x08] @Get enabled?
  44. + cmp r1, #1 @If not enabled, do not change
  45. + bne watchdog_finished
  46. + mov r1, #0
  47. + str r1, [r0, #0x08] @Disable the watchdog
  48. + mov r1, #1
  49. + str r1, [r0, #0x04] @Pet the watchdog
  50. + mov r1, #30 @30 seconds timeout
  51. + lsl r1, r1, #15 @converted to ticks
  52. + str r1, [r0, #0x10] @Set the bark timeout
  53. + str r1, [r0, #0x14] @Set the bite timeout
  54. + mov r1, #1
  55. + str r1, [r0, #0x08] @Enable the watchdog
  56. +watchdog_finished:
  57. +#endif /* CONFIG_ARCH_IPQ40XX */
  58. +
  59. /*
  60. * The C runtime environment should now be setup sufficiently.
  61. * Set up some pointers, and start decompressing.