dfd47d55d263e5d38a8df914363071191cdbaf68
[openwrt/staging/ldir.git] / target / linux / at91 / patches-5.10 / 197-ARM-at91-pm-move-pm_bu-to-soc_pm-data-structure.patch
1 From e41d00bdaa31b36fd314e927104082615aa4643a Mon Sep 17 00:00:00 2001
2 From: Claudiu Beznea <claudiu.beznea@microchip.com>
3 Date: Thu, 15 Apr 2021 13:49:47 +0300
4 Subject: [PATCH 197/247] ARM: at91: pm: move pm_bu to soc_pm data structure
5
6 Move pm_bu to soc_pm data structure.
7
8 Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
9 Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
10 Link: https://lore.kernel.org/r/20210415105010.569620-2-claudiu.beznea@microchip.com
11 ---
12 arch/arm/mach-at91/pm.c | 34 +++++++++++++++++++++-------------
13 1 file changed, 21 insertions(+), 13 deletions(-)
14
15 --- a/arch/arm/mach-at91/pm.c
16 +++ b/arch/arm/mach-at91/pm.c
17 @@ -27,10 +27,25 @@
18 #include "generic.h"
19 #include "pm.h"
20
21 +/**
22 + * struct at91_pm_bu - AT91 power management backup unit data structure
23 + * @suspended: true if suspended to backup mode
24 + * @reserved: reserved
25 + * @canary: canary data for memory checking after exit from backup mode
26 + * @resume: resume API
27 + */
28 +struct at91_pm_bu {
29 + int suspended;
30 + unsigned long reserved;
31 + phys_addr_t canary;
32 + phys_addr_t resume;
33 +};
34 +
35 struct at91_soc_pm {
36 int (*config_shdwc_ws)(void __iomem *shdwc, u32 *mode, u32 *polarity);
37 int (*config_pmc_ws)(void __iomem *pmc, u32 mode, u32 polarity);
38 const struct of_device_id *ws_ids;
39 + struct at91_pm_bu *bu;
40 struct at91_pm_data data;
41 };
42
43 @@ -71,13 +86,6 @@ static int at91_pm_valid_state(suspend_s
44
45 static int canary = 0xA5A5A5A5;
46
47 -static struct at91_pm_bu {
48 - int suspended;
49 - unsigned long reserved;
50 - phys_addr_t canary;
51 - phys_addr_t resume;
52 -} *pm_bu;
53 -
54 struct wakeup_source_info {
55 unsigned int pmc_fsmr_bit;
56 unsigned int shdwc_mr_bit;
57 @@ -288,7 +296,7 @@ static int at91_suspend_finish(unsigned
58 static void at91_pm_suspend(suspend_state_t state)
59 {
60 if (soc_pm.data.mode == AT91_PM_BACKUP) {
61 - pm_bu->suspended = 1;
62 + soc_pm.bu->suspended = 1;
63
64 cpu_suspend(0, at91_suspend_finish);
65
66 @@ -672,16 +680,16 @@ static int __init at91_pm_backup_init(vo
67 goto securam_fail;
68 }
69
70 - pm_bu = (void *)gen_pool_alloc(sram_pool, sizeof(struct at91_pm_bu));
71 - if (!pm_bu) {
72 + soc_pm.bu = (void *)gen_pool_alloc(sram_pool, sizeof(struct at91_pm_bu));
73 + if (!soc_pm.bu) {
74 pr_warn("%s: unable to alloc securam!\n", __func__);
75 ret = -ENOMEM;
76 goto securam_fail;
77 }
78
79 - pm_bu->suspended = 0;
80 - pm_bu->canary = __pa_symbol(&canary);
81 - pm_bu->resume = __pa_symbol(cpu_resume);
82 + soc_pm.bu->suspended = 0;
83 + soc_pm.bu->canary = __pa_symbol(&canary);
84 + soc_pm.bu->resume = __pa_symbol(cpu_resume);
85
86 return 0;
87