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