cc5f4aec0a608dd1fa97f6dd0039d667e68f2418
[openwrt/staging/ldir.git] / target / linux / at91 / patches-5.10 / 215-ARM-at91-pm-add-backup-mode-support-for-SAMA7G5.patch
1 From 62be32b56ff31b2cd048a53fac40a165c5bc66cd Mon Sep 17 00:00:00 2001
2 From: Claudiu Beznea <claudiu.beznea@microchip.com>
3 Date: Thu, 15 Apr 2021 13:50:06 +0300
4 Subject: [PATCH 215/247] ARM: at91: pm: add backup mode support for SAMA7G5
5
6 Adapt at91_pm_backup_init() to work for SAMA7G5. Also, set the LPM pin
7 to shutdown controller. This will signal to PMIC that it needs to switch
8 to the state corresponding to backup mode.
9
10 Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
11 Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
12 Link: https://lore.kernel.org/r/20210415105010.569620-21-claudiu.beznea@microchip.com
13 ---
14 arch/arm/mach-at91/pm.c | 3 ++-
15 arch/arm/mach-at91/pm_suspend.S | 7 +++++++
16 2 files changed, 9 insertions(+), 1 deletion(-)
17
18 --- a/arch/arm/mach-at91/pm.c
19 +++ b/arch/arm/mach-at91/pm.c
20 @@ -744,7 +744,8 @@ static int __init at91_pm_backup_init(vo
21 struct platform_device *pdev;
22 int ret = -ENODEV, located = 0;
23
24 - if (!IS_ENABLED(CONFIG_SOC_SAMA5D2))
25 + if (!IS_ENABLED(CONFIG_SOC_SAMA5D2) &&
26 + !IS_ENABLED(CONFIG_SOC_SAMA7G5))
27 return -EPERM;
28
29 if (!at91_is_pm_mode_active(AT91_PM_BACKUP))
30 --- a/arch/arm/mach-at91/pm_suspend.S
31 +++ b/arch/arm/mach-at91/pm_suspend.S
32 @@ -106,6 +106,12 @@ lp_done_\ena:
33 #endif
34 .endm
35
36 + .macro at91_backup_set_lpm reg
37 +#ifdef CONFIG_SOC_SAMA7
38 + orr \reg, \reg, #0x200000
39 +#endif
40 + .endm
41 +
42 .text
43
44 .arm
45 @@ -989,6 +995,7 @@ ulp_exit:
46 ldr r0, .shdwc
47 mov tmp1, #0xA5000000
48 add tmp1, tmp1, #0x1
49 + at91_backup_set_lpm tmp1
50 str tmp1, [r0, #0]
51 .endm
52