5b484b7343d92c12d9c73c4b4bb1b181680f78e4
[openwrt/openwrt.git] / target / linux / at91 / patches-5.15 / 198-ARM-at91-pm-move-the-setup-of-soc_pm.bu-suspended.patch
1 From c8f2a8aaae41fa0a40ad88855ae82696098230d7 Mon Sep 17 00:00:00 2001
2 From: Claudiu Beznea <claudiu.beznea@microchip.com>
3 Date: Thu, 15 Apr 2021 13:49:48 +0300
4 Subject: [PATCH 198/247] ARM: at91: pm: move the setup of soc_pm.bu->suspended
5
6 Move the setup of soc_pm.bu->suspended in platform_suspend::begin
7 function so that the PMC code in charge with clocks suspend/resume
8 to differentiate b/w standard PM mode and backup mode.
9
10 Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
11 Reviewed-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
12 Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
13 Link: https://lore.kernel.org/r/20210415105010.569620-3-claudiu.beznea@microchip.com
14 ---
15 arch/arm/mach-at91/pm.c | 15 ++++++++++++---
16 1 file changed, 12 insertions(+), 3 deletions(-)
17
18 --- a/arch/arm/mach-at91/pm.c
19 +++ b/arch/arm/mach-at91/pm.c
20 @@ -214,6 +214,8 @@ static int at91_sam9x60_config_pmc_ws(vo
21 */
22 static int at91_pm_begin(suspend_state_t state)
23 {
24 + int ret;
25 +
26 switch (state) {
27 case PM_SUSPEND_MEM:
28 soc_pm.data.mode = soc_pm.data.suspend_mode;
29 @@ -227,7 +229,16 @@ static int at91_pm_begin(suspend_state_t
30 soc_pm.data.mode = -1;
31 }
32
33 - return at91_pm_config_ws(soc_pm.data.mode, true);
34 + ret = at91_pm_config_ws(soc_pm.data.mode, true);
35 + if (ret)
36 + return ret;
37 +
38 + if (soc_pm.data.mode == AT91_PM_BACKUP)
39 + soc_pm.bu->suspended = 1;
40 + else if (soc_pm.bu)
41 + soc_pm.bu->suspended = 0;
42 +
43 + return 0;
44 }
45
46 /*
47 @@ -296,8 +307,6 @@ static int at91_suspend_finish(unsigned
48 static void at91_pm_suspend(suspend_state_t state)
49 {
50 if (soc_pm.data.mode == AT91_PM_BACKUP) {
51 - soc_pm.bu->suspended = 1;
52 -
53 cpu_suspend(0, at91_suspend_finish);
54
55 /* The SRAM is lost between suspend cycles */