Skip to content

Commit dbd6fef

Browse files
arndbkrzk
authored andcommitted
ARM: samsung: make pm-debug platform independent
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>
1 parent 1e574a6 commit dbd6fef

7 files changed

Lines changed: 74 additions & 67 deletions

File tree

‎arch/arm/mach-s3c24xx/include/mach/pm-core.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ static inline void s3c_pm_arch_show_resume_irqs(void)
7777
s3c_irqwake_eintmask);
7878
}
7979

80-
static inline void s3c_pm_arch_update_uart(void __iomem *regs,
81-
struct pm_uart_save *save)
82-
{
83-
}
84-
8580
static inline void s3c_pm_restored_gpios(void) { }
8681
static inline void samsung_pm_saved_gpios(void) { }
8782

‎arch/arm/mach-s3c64xx/include/mach/pm-core.h‎

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -65,48 +65,6 @@ static inline void s3c_pm_arch_show_resume_irqs(void)
6565
#define s3c_irqwake_intallow 0
6666
#endif
6767

68-
static inline void s3c_pm_arch_update_uart(void __iomem *regs,
69-
struct pm_uart_save *save)
70-
{
71-
u32 ucon = __raw_readl(regs + S3C2410_UCON);
72-
u32 ucon_clk = ucon & S3C6400_UCON_CLKMASK;
73-
u32 save_clk = save->ucon & S3C6400_UCON_CLKMASK;
74-
u32 new_ucon;
75-
u32 delta;
76-
77-
/* S3C64XX UART blocks only support level interrupts, so ensure that
78-
* when we restore unused UART blocks we force the level interrupt
79-
* settigs. */
80-
save->ucon |= S3C2410_UCON_TXILEVEL | S3C2410_UCON_RXILEVEL;
81-
82-
/* We have a constraint on changing the clock type of the UART
83-
* between UCLKx and PCLK, so ensure that when we restore UCON
84-
* that the CLK field is correctly modified if the bootloader
85-
* has changed anything.
86-
*/
87-
if (ucon_clk != save_clk) {
88-
new_ucon = save->ucon;
89-
delta = ucon_clk ^ save_clk;
90-
91-
/* change from UCLKx => wrong PCLK,
92-
* either UCLK can be tested for by a bit-test
93-
* with UCLK0 */
94-
if (ucon_clk & S3C6400_UCON_UCLK0 &&
95-
!(save_clk & S3C6400_UCON_UCLK0) &&
96-
delta & S3C6400_UCON_PCLK2) {
97-
new_ucon &= ~S3C6400_UCON_UCLK0;
98-
} else if (delta == S3C6400_UCON_PCLK2) {
99-
/* as an precaution, don't change from
100-
* PCLK2 => PCLK or vice-versa */
101-
new_ucon ^= S3C6400_UCON_PCLK2;
102-
}
103-
104-
S3C_PMDBG("ucon change %04x => %04x (save=%04x)\n",
105-
ucon, new_ucon, save->ucon);
106-
save->ucon = new_ucon;
107-
}
108-
}
109-
11068
static inline void s3c_pm_restored_gpios(void)
11169
{
11270
/* ensure sleep mode has been cleared from the system */

‎arch/arm/mach-s3c64xx/pm.c‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,56 @@ static void s3c64xx_pm_prepare(void)
305305
__raw_writel(__raw_readl(S3C64XX_WAKEUP_STAT), S3C64XX_WAKEUP_STAT);
306306
}
307307

308+
#ifdef CONFIG_SAMSUNG_PM_DEBUG
309+
void s3c_pm_arch_update_uart(void __iomem *regs, struct pm_uart_save *save)
310+
{
311+
u32 ucon;
312+
u32 ucon_clk
313+
u32 save_clk;
314+
u32 new_ucon;
315+
u32 delta;
316+
317+
if (!soc_is_s3c64xx())
318+
return;
319+
320+
ucon = __raw_readl(regs + S3C2410_UCON);
321+
ucon_clk = ucon & S3C6400_UCON_CLKMASK;
322+
sav_clk = save->ucon & S3C6400_UCON_CLKMASK;
323+
324+
/* S3C64XX UART blocks only support level interrupts, so ensure that
325+
* when we restore unused UART blocks we force the level interrupt
326+
* settigs. */
327+
save->ucon |= S3C2410_UCON_TXILEVEL | S3C2410_UCON_RXILEVEL;
328+
329+
/* We have a constraint on changing the clock type of the UART
330+
* between UCLKx and PCLK, so ensure that when we restore UCON
331+
* that the CLK field is correctly modified if the bootloader
332+
* has changed anything.
333+
*/
334+
if (ucon_clk != save_clk) {
335+
new_ucon = save->ucon;
336+
delta = ucon_clk ^ save_clk;
337+
338+
/* change from UCLKx => wrong PCLK,
339+
* either UCLK can be tested for by a bit-test
340+
* with UCLK0 */
341+
if (ucon_clk & S3C6400_UCON_UCLK0 &&
342+
!(save_clk & S3C6400_UCON_UCLK0) &&
343+
delta & S3C6400_UCON_PCLK2) {
344+
new_ucon &= ~S3C6400_UCON_UCLK0;
345+
} else if (delta == S3C6400_UCON_PCLK2) {
346+
/* as an precaution, don't change from
347+
* PCLK2 => PCLK or vice-versa */
348+
new_ucon ^= S3C6400_UCON_PCLK2;
349+
}
350+
351+
S3C_PMDBG("ucon change %04x => %04x (save=%04x)\n",
352+
ucon, new_ucon, save->ucon);
353+
save->ucon = new_ucon;
354+
}
355+
}
356+
#endif
357+
308358
int __init s3c64xx_pm_init(void)
309359
{
310360
int i;

‎arch/arm/mach-s5pv210/pm.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int s5pv210_suspend_enter(suspend_state_t state)
111111
return -EINVAL;
112112
}
113113

114-
s3c_pm_save_uarts();
114+
s3c_pm_save_uarts(false);
115115
s5pv210_pm_prepare();
116116
flush_cache_all();
117117
s3c_pm_check_store();
@@ -120,7 +120,7 @@ static int s5pv210_suspend_enter(suspend_state_t state)
120120
if (ret)
121121
return ret;
122122

123-
s3c_pm_restore_uarts();
123+
s3c_pm_restore_uarts(false);
124124

125125
S3C_PMDBG("%s: wakeup stat: %08x\n", __func__,
126126
__raw_readl(S5P_WAKEUP_STAT));

‎arch/arm/plat-samsung/include/plat/pm-common.h‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,24 @@ extern void s3c_pm_dbg(const char *msg, ...);
7171

7272
#define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
7373

74-
extern void s3c_pm_save_uarts(void);
75-
extern void s3c_pm_restore_uarts(void);
74+
extern void s3c_pm_save_uarts(bool is_s3c24xx);
75+
extern void s3c_pm_restore_uarts(bool is_s3c24xx);
76+
77+
#ifdef CONFIG_ARCH_S3C64XX
78+
extern void s3c_pm_arch_update_uart(void __iomem *regs,
79+
struct pm_uart_save *save);
80+
#else
81+
static inline void
82+
s3c_pm_arch_update_uart(void __iomem *regs, struct pm_uart_save *save)
83+
{
84+
}
85+
#endif
86+
7687
#else
7788
#define S3C_PMDBG(fmt...) pr_debug(fmt)
7889

79-
static inline void s3c_pm_save_uarts(void) { }
80-
static inline void s3c_pm_restore_uarts(void) { }
90+
static inline void s3c_pm_save_uarts(bool is_s3c24xx) { }
91+
static inline void s3c_pm_restore_uarts(bool is_s3c24xx) { }
8192
#endif
8293

8394
/* suspend memory checking */

‎arch/arm/plat-samsung/pm-debug.c‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818
#include <plat/cpu.h>
1919
#include <plat/pm-common.h>
2020

21-
#ifdef CONFIG_SAMSUNG_ATAGS
22-
#include <plat/pm.h>
23-
#include <mach/pm-core.h>
24-
#else
25-
static inline void s3c_pm_arch_update_uart(void __iomem *regs,
26-
struct pm_uart_save *save) {}
27-
#endif
28-
2921
static struct pm_uart_save uart_save;
3022

3123
extern void printascii(const char *);
@@ -52,7 +44,7 @@ static inline void __iomem *s3c_pm_uart_base(void)
5244
return (void __iomem *)vaddr;
5345
}
5446

55-
void s3c_pm_save_uarts(void)
47+
void s3c_pm_save_uarts(bool is_s3c2410)
5648
{
5749
void __iomem *regs = s3c_pm_uart_base();
5850
struct pm_uart_save *save = &uart_save;
@@ -63,14 +55,14 @@ void s3c_pm_save_uarts(void)
6355
save->umcon = __raw_readl(regs + S3C2410_UMCON);
6456
save->ubrdiv = __raw_readl(regs + S3C2410_UBRDIV);
6557

66-
if (!soc_is_s3c2410())
58+
if (!is_s3c2410)
6759
save->udivslot = __raw_readl(regs + S3C2443_DIVSLOT);
6860

6961
S3C_PMDBG("UART[%p]: ULCON=%04x, UCON=%04x, UFCON=%04x, UBRDIV=%04x\n",
7062
regs, save->ulcon, save->ucon, save->ufcon, save->ubrdiv);
7163
}
7264

73-
void s3c_pm_restore_uarts(void)
65+
void s3c_pm_restore_uarts(bool is_s3c2410)
7466
{
7567
void __iomem *regs = s3c_pm_uart_base();
7668
struct pm_uart_save *save = &uart_save;
@@ -83,6 +75,6 @@ void s3c_pm_restore_uarts(void)
8375
__raw_writel(save->umcon, regs + S3C2410_UMCON);
8476
__raw_writel(save->ubrdiv, regs + S3C2410_UBRDIV);
8577

86-
if (!soc_is_s3c2410())
78+
if (!is_s3c2410)
8779
__raw_writel(save->udivslot, regs + S3C2443_DIVSLOT);
8880
}

‎arch/arm/plat-samsung/pm.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <asm/irq.h>
2727

28+
#include <plat/cpu.h>
2829
#include <plat/pm.h>
2930
#include <mach/pm-core.h>
3031

@@ -99,7 +100,7 @@ static int s3c_pm_enter(suspend_state_t state)
99100
samsung_pm_saved_gpios();
100101
}
101102

102-
s3c_pm_save_uarts();
103+
s3c_pm_save_uarts(soc_is_s3c2410());
103104
s3c_pm_save_core();
104105

105106
/* set the irq configuration for wake */
@@ -136,7 +137,7 @@ static int s3c_pm_enter(suspend_state_t state)
136137
/* restore the system state */
137138

138139
s3c_pm_restore_core();
139-
s3c_pm_restore_uarts();
140+
s3c_pm_restore_uarts(soc_is_s3c2410());
140141

141142
if (!of_have_populated_dt()) {
142143
samsung_pm_restore_gpios();

0 commit comments

Comments
 (0)