at91: kernel v5.15: copy config and patches from 5.10
[openwrt/openwrt.git] / target / linux / at91 / patches-5.15 / 197-ARM-at91-pm-move-pm_bu-to-soc_pm-data-structure.patch
diff --git a/target/linux/at91/patches-5.15/197-ARM-at91-pm-move-pm_bu-to-soc_pm-data-structure.patch b/target/linux/at91/patches-5.15/197-ARM-at91-pm-move-pm_bu-to-soc_pm-data-structure.patch
new file mode 100644 (file)
index 0000000..dfd47d5
--- /dev/null
@@ -0,0 +1,87 @@
+From e41d00bdaa31b36fd314e927104082615aa4643a Mon Sep 17 00:00:00 2001
+From: Claudiu Beznea <claudiu.beznea@microchip.com>
+Date: Thu, 15 Apr 2021 13:49:47 +0300
+Subject: [PATCH 197/247] ARM: at91: pm: move pm_bu to soc_pm data structure
+
+Move pm_bu to soc_pm data structure.
+
+Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
+Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com>
+Link: https://lore.kernel.org/r/20210415105010.569620-2-claudiu.beznea@microchip.com
+---
+ arch/arm/mach-at91/pm.c | 34 +++++++++++++++++++++-------------
+ 1 file changed, 21 insertions(+), 13 deletions(-)
+
+--- a/arch/arm/mach-at91/pm.c
++++ b/arch/arm/mach-at91/pm.c
+@@ -27,10 +27,25 @@
+ #include "generic.h"
+ #include "pm.h"
++/**
++ * struct at91_pm_bu - AT91 power management backup unit data structure
++ * @suspended: true if suspended to backup mode
++ * @reserved: reserved
++ * @canary: canary data for memory checking after exit from backup mode
++ * @resume: resume API
++ */
++struct at91_pm_bu {
++      int suspended;
++      unsigned long reserved;
++      phys_addr_t canary;
++      phys_addr_t resume;
++};
++
+ struct at91_soc_pm {
+       int (*config_shdwc_ws)(void __iomem *shdwc, u32 *mode, u32 *polarity);
+       int (*config_pmc_ws)(void __iomem *pmc, u32 mode, u32 polarity);
+       const struct of_device_id *ws_ids;
++      struct at91_pm_bu *bu;
+       struct at91_pm_data data;
+ };
+@@ -71,13 +86,6 @@ static int at91_pm_valid_state(suspend_s
+ static int canary = 0xA5A5A5A5;
+-static struct at91_pm_bu {
+-      int suspended;
+-      unsigned long reserved;
+-      phys_addr_t canary;
+-      phys_addr_t resume;
+-} *pm_bu;
+-
+ struct wakeup_source_info {
+       unsigned int pmc_fsmr_bit;
+       unsigned int shdwc_mr_bit;
+@@ -288,7 +296,7 @@ static int at91_suspend_finish(unsigned
+ static void at91_pm_suspend(suspend_state_t state)
+ {
+       if (soc_pm.data.mode == AT91_PM_BACKUP) {
+-              pm_bu->suspended = 1;
++              soc_pm.bu->suspended = 1;
+               cpu_suspend(0, at91_suspend_finish);
+@@ -672,16 +680,16 @@ static int __init at91_pm_backup_init(vo
+               goto securam_fail;
+       }
+-      pm_bu = (void *)gen_pool_alloc(sram_pool, sizeof(struct at91_pm_bu));
+-      if (!pm_bu) {
++      soc_pm.bu = (void *)gen_pool_alloc(sram_pool, sizeof(struct at91_pm_bu));
++      if (!soc_pm.bu) {
+               pr_warn("%s: unable to alloc securam!\n", __func__);
+               ret = -ENOMEM;
+               goto securam_fail;
+       }
+-      pm_bu->suspended = 0;
+-      pm_bu->canary = __pa_symbol(&canary);
+-      pm_bu->resume = __pa_symbol(cpu_resume);
++      soc_pm.bu->suspended = 0;
++      soc_pm.bu->canary = __pa_symbol(&canary);
++      soc_pm.bu->resume = __pa_symbol(cpu_resume);
+       return 0;