at91: kernel v5.15: copy config and patches from 5.10
[openwrt/staging/ansuel.git] / target / linux / at91 / patches-5.15 / 231-ARM-at91-pm-preload-base-address-of-controllers-in-t.patch
1 From 6075bbc75e55258a762d618cd459dbe0dd38aff9 Mon Sep 17 00:00:00 2001
2 From: Claudiu Beznea <claudiu.beznea@microchip.com>
3 Date: Thu, 30 Sep 2021 18:42:19 +0300
4 Subject: [PATCH 231/247] ARM: at91: pm: preload base address of controllers in
5 tlb
6
7 In suspend/resume procedure for AT91 architecture different controllers
8 (PMC, SHDWC, RAM, RAM PHY, SFRBU) are accessed to do the proper settings
9 for power saving. Commit f0bbf17958e8 ("ARM: at91: pm: add self-refresh
10 support for sama7g5") introduced the access to RAMC PHY controller for
11 SAMA7G5. The access to this controller is done after RAMC ports are
12 closed, thus any TLB walk necessary for RAMC PHY virtual address will
13 fail. In the development branch this was not encountered. However, on
14 current kernel the issue is reproducible.
15
16 To solve the issue the previous mechanism of pre-loading the TLB with
17 the RAMC PHY virtual address has been used. However, only the addition
18 of this new pre-load breaks the functionality for ARMv5 based
19 devices (SAM9X60). This behavior has been encountered previously
20 while debugging this code and using the same mechanism for pre-loading
21 address for different controllers (e.g. pin controller, the assumption
22 being that other requested translations are replaced from TLB).
23
24 To solve this new issue the TLB flush + the extension of pre-loading
25 the rest of controllers to TLB (e.g. PMC, RAMC) has been added. The
26 rest of the controllers should have been pre-loaded previously, anyway.
27
28 Fixes: f0bbf17958e8 ("ARM: at91: pm: add self-refresh support for sama7g5")
29 Depends-on: e42cbbe5c9a2 ("ARM: at91: pm: group constants and addresses loading")
30 Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
31 Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
32 Link: https://lore.kernel.org/r/20210930154219.2214051-4-claudiu.beznea@microchip.com
33 ---
34 arch/arm/mach-at91/pm_suspend.S | 25 ++++++++++++++++++++++++-
35 1 file changed, 24 insertions(+), 1 deletion(-)
36
37 --- a/arch/arm/mach-at91/pm_suspend.S
38 +++ b/arch/arm/mach-at91/pm_suspend.S
39 @@ -1014,6 +1014,10 @@ ENTRY(at91_pm_suspend_in_sram)
40 mov tmp1, #0
41 mcr p15, 0, tmp1, c7, c10, 4
42
43 + /* Flush tlb. */
44 + mov r4, #0
45 + mcr p15, 0, r4, c8, c7, 0
46 +
47 ldr tmp1, [r0, #PM_DATA_PMC_MCKR_OFFSET]
48 str tmp1, .mckr_offset
49 ldr tmp1, [r0, #PM_DATA_PMC_VERSION]
50 @@ -1023,23 +1027,42 @@ ENTRY(at91_pm_suspend_in_sram)
51 ldr tmp1, [r0, #PM_DATA_MODE]
52 str tmp1, .pm_mode
53
54 + /*
55 + * ldrne below are here to preload their address in the TLB as access
56 + * to RAM may be limited while in self-refresh.
57 + */
58 ldr tmp1, [r0, #PM_DATA_PMC]
59 str tmp1, .pmc_base
60 + cmp tmp1, #0
61 + ldrne tmp2, [tmp1, #0]
62 +
63 ldr tmp1, [r0, #PM_DATA_RAMC0]
64 str tmp1, .sramc_base
65 + cmp tmp1, #0
66 + ldrne tmp2, [tmp1, #0]
67 +
68 ldr tmp1, [r0, #PM_DATA_RAMC1]
69 str tmp1, .sramc1_base
70 + cmp tmp1, #0
71 + ldrne tmp2, [tmp1, #0]
72 +
73 +#ifndef CONFIG_SOC_SAM_V4_V5
74 + /* ldrne below are here to preload their address in the TLB */
75 ldr tmp1, [r0, #PM_DATA_RAMC_PHY]
76 str tmp1, .sramc_phy_base
77 - /* Both ldrne below are here to preload their address in the TLB */
78 + cmp tmp1, #0
79 + ldrne tmp2, [tmp1, #0]
80 +
81 ldr tmp1, [r0, #PM_DATA_SHDWC]
82 str tmp1, .shdwc
83 cmp tmp1, #0
84 ldrne tmp2, [tmp1, #0]
85 +
86 ldr tmp1, [r0, #PM_DATA_SFRBU]
87 str tmp1, .sfrbu
88 cmp tmp1, #0
89 ldrne tmp2, [tmp1, #0x10]
90 +#endif
91
92 /* Active the self-refresh mode */
93 at91_sramc_self_refresh_ena