ARM: samsung: make pm-debug platform independent
authorArnd Bergmann <arnd@arndb.de>
Thu, 6 Aug 2020 18:20:29 +0000 (20:20 +0200)
committerKrzysztof Kozlowski <krzk@kernel.org>
Wed, 19 Aug 2020 19:10:50 +0000 (21:10 +0200)
The pm-debug code is one of the few things shared between
s3c24xx/s3c64xx and the newer s5pv210. In order to make s5pv210
independent of plat-samsung, change the common bits of this code to no
longer reference the s3c specific bits.

In particular, all the CPU checks need to be moved out of the common
code into platform specific files.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20200806182059.2431-12-krzk@kernel.org
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
arch/arm/mach-s3c24xx/include/mach/pm-core.h
arch/arm/mach-s3c64xx/include/mach/pm-core.h
arch/arm/mach-s3c64xx/pm.c
arch/arm/mach-s5pv210/pm.c
arch/arm/plat-samsung/include/plat/pm-common.h
arch/arm/plat-samsung/pm-debug.c
arch/arm/plat-samsung/pm.c

index cd6406820cb138573a153ceef8fa4c351979ce6c..8f87606c4cdc02b70f5fa6e5a6a090f24de177cf 100644 (file)
@@ -77,11 +77,6 @@ static inline void s3c_pm_arch_show_resume_irqs(void)
                                s3c_irqwake_eintmask);
 }
 
-static inline void s3c_pm_arch_update_uart(void __iomem *regs,
-                                          struct pm_uart_save *save)
-{
-}
-
 static inline void s3c_pm_restored_gpios(void) { }
 static inline void samsung_pm_saved_gpios(void) { }
 
index 1c7d179a86f3b7c95686634bf868fed0df07faf8..33cf242734a05cbf658ff699e1ea79217301ebc1 100644 (file)
@@ -65,48 +65,6 @@ static inline void s3c_pm_arch_show_resume_irqs(void)
 #define s3c_irqwake_intallow  0
 #endif
 
-static inline void s3c_pm_arch_update_uart(void __iomem *regs,
-                                          struct pm_uart_save *save)
-{
-       u32 ucon = __raw_readl(regs + S3C2410_UCON);
-       u32 ucon_clk = ucon & S3C6400_UCON_CLKMASK;
-       u32 save_clk = save->ucon & S3C6400_UCON_CLKMASK;
-       u32 new_ucon;
-       u32 delta;
-
-       /* S3C64XX UART blocks only support level interrupts, so ensure that
-        * when we restore unused UART blocks we force the level interrupt
-        * settigs. */
-       save->ucon |= S3C2410_UCON_TXILEVEL | S3C2410_UCON_RXILEVEL;
-
-       /* We have a constraint on changing the clock type of the UART
-        * between UCLKx and PCLK, so ensure that when we restore UCON
-        * that the CLK field is correctly modified if the bootloader
-        * has changed anything.
-        */
-       if (ucon_clk != save_clk) {
-               new_ucon = save->ucon;
-               delta = ucon_clk ^ save_clk;
-
-               /* change from UCLKx => wrong PCLK,
-                * either UCLK can be tested for by a bit-test
-                * with UCLK0 */
-               if (ucon_clk & S3C6400_UCON_UCLK0 &&
-                   !(save_clk & S3C6400_UCON_UCLK0) &&
-                   delta & S3C6400_UCON_PCLK2) {
-                       new_ucon &= ~S3C6400_UCON_UCLK0;
-               } else if (delta == S3C6400_UCON_PCLK2) {
-                       /* as an precaution, don't change from
-                        * PCLK2 => PCLK or vice-versa */
-                       new_ucon ^= S3C6400_UCON_PCLK2;
-               }
-
-               S3C_PMDBG("ucon change %04x => %04x (save=%04x)\n",
-                         ucon, new_ucon, save->ucon);
-               save->ucon = new_ucon;
-       }
-}
-
 static inline void s3c_pm_restored_gpios(void)
 {
        /* ensure sleep mode has been cleared from the system */
index fd6dbb263ed57f7472f32e61d262d3d7a225ce81..a612e97790578f0779aee04285abe2af8910d540 100644 (file)
@@ -305,6 +305,56 @@ static void s3c64xx_pm_prepare(void)
        __raw_writel(__raw_readl(S3C64XX_WAKEUP_STAT), S3C64XX_WAKEUP_STAT);
 }
 
+#ifdef CONFIG_SAMSUNG_PM_DEBUG
+void s3c_pm_arch_update_uart(void __iomem *regs, struct pm_uart_save *save)
+{
+       u32 ucon;
+       u32 ucon_clk
+       u32 save_clk;
+       u32 new_ucon;
+       u32 delta;
+
+       if (!soc_is_s3c64xx())
+               return;
+
+       ucon = __raw_readl(regs + S3C2410_UCON);
+       ucon_clk = ucon & S3C6400_UCON_CLKMASK;
+       sav_clk = save->ucon & S3C6400_UCON_CLKMASK;
+
+       /* S3C64XX UART blocks only support level interrupts, so ensure that
+        * when we restore unused UART blocks we force the level interrupt
+        * settigs. */
+       save->ucon |= S3C2410_UCON_TXILEVEL | S3C2410_UCON_RXILEVEL;
+
+       /* We have a constraint on changing the clock type of the UART
+        * between UCLKx and PCLK, so ensure that when we restore UCON
+        * that the CLK field is correctly modified if the bootloader
+        * has changed anything.
+        */
+       if (ucon_clk != save_clk) {
+               new_ucon = save->ucon;
+               delta = ucon_clk ^ save_clk;
+
+               /* change from UCLKx => wrong PCLK,
+                * either UCLK can be tested for by a bit-test
+                * with UCLK0 */
+               if (ucon_clk & S3C6400_UCON_UCLK0 &&
+                   !(save_clk & S3C6400_UCON_UCLK0) &&
+                   delta & S3C6400_UCON_PCLK2) {
+                       new_ucon &= ~S3C6400_UCON_UCLK0;
+               } else if (delta == S3C6400_UCON_PCLK2) {
+                       /* as an precaution, don't change from
+                        * PCLK2 => PCLK or vice-versa */
+                       new_ucon ^= S3C6400_UCON_PCLK2;
+               }
+
+               S3C_PMDBG("ucon change %04x => %04x (save=%04x)\n",
+                         ucon, new_ucon, save->ucon);
+               save->ucon = new_ucon;
+       }
+}
+#endif
+
 int __init s3c64xx_pm_init(void)
 {
        int i;
index 725e6746f345b4446071eb00e569437dd5a7564b..efdb5a27c060e50c64b40dfa79c82f8d23b1673a 100644 (file)
@@ -111,7 +111,7 @@ static int s5pv210_suspend_enter(suspend_state_t state)
                return -EINVAL;
        }
 
-       s3c_pm_save_uarts();
+       s3c_pm_save_uarts(false);
        s5pv210_pm_prepare();
        flush_cache_all();
        s3c_pm_check_store();
@@ -120,7 +120,7 @@ static int s5pv210_suspend_enter(suspend_state_t state)
        if (ret)
                return ret;
 
-       s3c_pm_restore_uarts();
+       s3c_pm_restore_uarts(false);
 
        S3C_PMDBG("%s: wakeup stat: %08x\n", __func__,
                        __raw_readl(S5P_WAKEUP_STAT));
index 467e7c867c46e1512d3c5311304c24f1dc6707e0..87fa97fd6e8bfd957b35c5dd247f5a781999f26b 100644 (file)
@@ -71,13 +71,24 @@ extern void s3c_pm_dbg(const char *msg, ...);
 
 #define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
 
-extern void s3c_pm_save_uarts(void);
-extern void s3c_pm_restore_uarts(void);
+extern void s3c_pm_save_uarts(bool is_s3c24xx);
+extern void s3c_pm_restore_uarts(bool is_s3c24xx);
+
+#ifdef CONFIG_ARCH_S3C64XX
+extern void s3c_pm_arch_update_uart(void __iomem *regs,
+                                   struct pm_uart_save *save);
+#else
+static inline void
+s3c_pm_arch_update_uart(void __iomem *regs, struct pm_uart_save *save)
+{
+}
+#endif
+
 #else
 #define S3C_PMDBG(fmt...) pr_debug(fmt)
 
-static inline void s3c_pm_save_uarts(void) { }
-static inline void s3c_pm_restore_uarts(void) { }
+static inline void s3c_pm_save_uarts(bool is_s3c24xx) { }
+static inline void s3c_pm_restore_uarts(bool is_s3c24xx) { }
 #endif
 
 /* suspend memory checking */
index 105b61f3304eb538da7b759e5cb62a51c75ecbc4..482d53753e9304b01f1c21a0389fa5c14ded83bd 100644 (file)
 #include <plat/cpu.h>
 #include <plat/pm-common.h>
 
-#ifdef CONFIG_SAMSUNG_ATAGS
-#include <plat/pm.h>
-#include <mach/pm-core.h>
-#else
-static inline void s3c_pm_arch_update_uart(void __iomem *regs,
-                                          struct pm_uart_save *save) {}
-#endif
-
 static struct pm_uart_save uart_save;
 
 extern void printascii(const char *);
@@ -52,7 +44,7 @@ static inline void __iomem *s3c_pm_uart_base(void)
        return (void __iomem *)vaddr;
 }
 
-void s3c_pm_save_uarts(void)
+void s3c_pm_save_uarts(bool is_s3c2410)
 {
        void __iomem *regs = s3c_pm_uart_base();
        struct pm_uart_save *save = &uart_save;
@@ -63,14 +55,14 @@ void s3c_pm_save_uarts(void)
        save->umcon = __raw_readl(regs + S3C2410_UMCON);
        save->ubrdiv = __raw_readl(regs + S3C2410_UBRDIV);
 
-       if (!soc_is_s3c2410())
+       if (!is_s3c2410)
                save->udivslot = __raw_readl(regs + S3C2443_DIVSLOT);
 
        S3C_PMDBG("UART[%p]: ULCON=%04x, UCON=%04x, UFCON=%04x, UBRDIV=%04x\n",
                  regs, save->ulcon, save->ucon, save->ufcon, save->ubrdiv);
 }
 
-void s3c_pm_restore_uarts(void)
+void s3c_pm_restore_uarts(bool is_s3c2410)
 {
        void __iomem *regs = s3c_pm_uart_base();
        struct pm_uart_save *save = &uart_save;
@@ -83,6 +75,6 @@ void s3c_pm_restore_uarts(void)
        __raw_writel(save->umcon, regs + S3C2410_UMCON);
        __raw_writel(save->ubrdiv, regs + S3C2410_UBRDIV);
 
-       if (!soc_is_s3c2410())
+       if (!is_s3c2410)
                __raw_writel(save->udivslot, regs + S3C2443_DIVSLOT);
 }
index b40ab7abe6a931d01de653a51e6b43140c6f0b8a..03c22a9dee21efcdfbc903c4b5c855fb7a30519d 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <asm/irq.h>
 
+#include <plat/cpu.h>
 #include <plat/pm.h>
 #include <mach/pm-core.h>
 
@@ -99,7 +100,7 @@ static int s3c_pm_enter(suspend_state_t state)
                samsung_pm_saved_gpios();
        }
 
-       s3c_pm_save_uarts();
+       s3c_pm_save_uarts(soc_is_s3c2410());
        s3c_pm_save_core();
 
        /* set the irq configuration for wake */
@@ -136,7 +137,7 @@ static int s3c_pm_enter(suspend_state_t state)
        /* restore the system state */
 
        s3c_pm_restore_core();
-       s3c_pm_restore_uarts();
+       s3c_pm_restore_uarts(soc_is_s3c2410());
 
        if (!of_have_populated_dt()) {
                samsung_pm_restore_gpios();