aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-samsung
diff options
context:
space:
mode:
authorTomasz Figa <t.figa@samsung.com>2014-03-17 18:28:09 -0400
committerKukjin Kim <kgene.kim@samsung.com>2014-03-20 15:09:16 -0400
commit72551f6cf13e2f3a1d273b7007b5d7d7fd69c554 (patch)
treeebc79635f3b76e22d614297953608239b672fee4 /arch/arm/plat-samsung
parentd38688a69fd88269eae3c7c66ec34fb02fb04fd1 (diff)
ARM: SAMSUNG: Move Samsung PM debug code into separate file
Not all Samsung SoC platforms are going to use the legacy Samsung PM code enabled by CONFIG_SAMSUNG_PM_DEBUG. To allow using Samsung PM debug helpers on such platforms, related code is moved to separate file and a plat/pm-common.h header is added to separate legacy and generic code. Signed-off-by: Tomasz Figa <t.figa@samsung.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm/plat-samsung')
-rw-r--r--arch/arm/plat-samsung/Makefile1
-rw-r--r--arch/arm/plat-samsung/include/plat/pm-common.h70
-rw-r--r--arch/arm/plat-samsung/include/plat/pm.h39
-rw-r--r--arch/arm/plat-samsung/pm-debug.c97
-rw-r--r--arch/arm/plat-samsung/pm.c84
5 files changed, 169 insertions, 122 deletions
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile
index 9267d29549b4..ba30a16b3ca8 100644
--- a/arch/arm/plat-samsung/Makefile
+++ b/arch/arm/plat-samsung/Makefile
@@ -50,6 +50,7 @@ obj-$(CONFIG_SAMSUNG_DMADEV) += dma-ops.o
50obj-$(CONFIG_SAMSUNG_PM) += pm.o 50obj-$(CONFIG_SAMSUNG_PM) += pm.o
51obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o 51obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o
52obj-$(CONFIG_SAMSUNG_PM_CHECK) += pm-check.o 52obj-$(CONFIG_SAMSUNG_PM_CHECK) += pm-check.o
53obj-$(CONFIG_SAMSUNG_PM_DEBUG) += pm-debug.o
53 54
54obj-$(CONFIG_SAMSUNG_WAKEMASK) += wakeup-mask.o 55obj-$(CONFIG_SAMSUNG_WAKEMASK) += wakeup-mask.o
55obj-$(CONFIG_SAMSUNG_WDT_RESET) += watchdog-reset.o 56obj-$(CONFIG_SAMSUNG_WDT_RESET) += watchdog-reset.o
diff --git a/arch/arm/plat-samsung/include/plat/pm-common.h b/arch/arm/plat-samsung/include/plat/pm-common.h
new file mode 100644
index 000000000000..f72974a762bf
--- /dev/null
+++ b/arch/arm/plat-samsung/include/plat/pm-common.h
@@ -0,0 +1,70 @@
1/*
2 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
3 * Tomasz Figa <t.figa@samsung.com>
4 * Copyright (c) 2004 Simtec Electronics
5 * http://armlinux.simtec.co.uk/
6 * Written by Ben Dooks, <ben@simtec.co.uk>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __PLAT_SAMSUNG_PM_COMMON_H
14#define __PLAT_SAMSUNG_PM_COMMON_H __FILE__
15
16/* PM debug functions */
17
18/**
19 * struct pm_uart_save - save block for core UART
20 * @ulcon: Save value for S3C2410_ULCON
21 * @ucon: Save value for S3C2410_UCON
22 * @ufcon: Save value for S3C2410_UFCON
23 * @umcon: Save value for S3C2410_UMCON
24 * @ubrdiv: Save value for S3C2410_UBRDIV
25 *
26 * Save block for UART registers to be held over sleep and restored if they
27 * are needed (say by debug).
28*/
29struct pm_uart_save {
30 u32 ulcon;
31 u32 ucon;
32 u32 ufcon;
33 u32 umcon;
34 u32 ubrdiv;
35 u32 udivslot;
36};
37
38#ifdef CONFIG_SAMSUNG_PM_DEBUG
39/**
40 * s3c_pm_dbg() - low level debug function for use in suspend/resume.
41 * @msg: The message to print.
42 *
43 * This function is used mainly to debug the resume process before the system
44 * can rely on printk/console output. It uses the low-level debugging output
45 * routine printascii() to do its work.
46 */
47extern void s3c_pm_dbg(const char *msg, ...);
48
49/**
50 * s3c_pm_debug_init() - suspend/resume low level debug initialization.
51 * @base: Virtual base of UART to use for suspend/resume debugging.
52 *
53 * This function needs to be called before S3C_PMDBG() can be used, to set up
54 * UART port base address and configuration.
55 */
56extern void s3c_pm_debug_init(void);
57
58#define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
59
60extern void s3c_pm_save_uarts(void);
61extern void s3c_pm_restore_uarts(void);
62#else
63#define S3C_PMDBG(fmt...) pr_debug(fmt)
64#define s3c_pm_debug_init() do { } while (0)
65
66static inline void s3c_pm_save_uarts(void) { }
67static inline void s3c_pm_restore_uarts(void) { }
68#endif
69
70#endif
diff --git a/arch/arm/plat-samsung/include/plat/pm.h b/arch/arm/plat-samsung/include/plat/pm.h
index 21758c67bcc0..2e04396eb3f3 100644
--- a/arch/arm/plat-samsung/include/plat/pm.h
+++ b/arch/arm/plat-samsung/include/plat/pm.h
@@ -16,6 +16,7 @@
16*/ 16*/
17 17
18#include <linux/irq.h> 18#include <linux/irq.h>
19#include <plat/pm-common.h>
19 20
20struct device; 21struct device;
21 22
@@ -76,26 +77,6 @@ struct sleep_save {
76#define SAVE_ITEM(x) \ 77#define SAVE_ITEM(x) \
77 { .reg = (x) } 78 { .reg = (x) }
78 79
79/**
80 * struct pm_uart_save - save block for core UART
81 * @ulcon: Save value for S3C2410_ULCON
82 * @ucon: Save value for S3C2410_UCON
83 * @ufcon: Save value for S3C2410_UFCON
84 * @umcon: Save value for S3C2410_UMCON
85 * @ubrdiv: Save value for S3C2410_UBRDIV
86 *
87 * Save block for UART registers to be held over sleep and restored if they
88 * are needed (say by debug).
89*/
90struct pm_uart_save {
91 u32 ulcon;
92 u32 ucon;
93 u32 ufcon;
94 u32 umcon;
95 u32 ubrdiv;
96 u32 udivslot;
97};
98
99/* helper functions to save/restore lists of registers. */ 80/* helper functions to save/restore lists of registers. */
100 81
101extern void s3c_pm_do_save(struct sleep_save *ptr, int count); 82extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
@@ -112,24 +93,6 @@ extern void s3c_cpu_resume(void);
112#define s3c_cpu_resume NULL 93#define s3c_cpu_resume NULL
113#endif 94#endif
114 95
115/* PM debug functions */
116
117#ifdef CONFIG_SAMSUNG_PM_DEBUG
118/**
119 * s3c_pm_dbg() - low level debug function for use in suspend/resume.
120 * @msg: The message to print.
121 *
122 * This function is used mainly to debug the resume process before the system
123 * can rely on printk/console output. It uses the low-level debugging output
124 * routine printascii() to do its work.
125 */
126extern void s3c_pm_dbg(const char *msg, ...);
127
128#define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
129#else
130#define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt)
131#endif
132
133#ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK 96#ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK
134/** 97/**
135 * s3c_pm_debug_smdkled() - Debug PM suspend/resume via SMDK Board LEDs 98 * s3c_pm_debug_smdkled() - Debug PM suspend/resume via SMDK Board LEDs
diff --git a/arch/arm/plat-samsung/pm-debug.c b/arch/arm/plat-samsung/pm-debug.c
new file mode 100644
index 000000000000..8f19f66388dd
--- /dev/null
+++ b/arch/arm/plat-samsung/pm-debug.c
@@ -0,0 +1,97 @@
1/*
2 * Copyright (C) 2013 Samsung Electronics Co., Ltd.
3 * Tomasz Figa <t.figa@samsung.com>
4 * Copyright (C) 2008 Openmoko, Inc.
5 * Copyright (C) 2004-2008 Simtec Electronics
6 * Ben Dooks <ben@simtec.co.uk>
7 * http://armlinux.simtec.co.uk/
8 *
9 * Samsung common power management (suspend to RAM) debug support
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15
16#include <linux/serial_core.h>
17#include <linux/io.h>
18
19#include <asm/mach/map.h>
20
21#include <plat/cpu.h>
22#include <plat/pm-common.h>
23
24#ifdef CONFIG_SAMSUNG_ATAGS
25#include <mach/pm-core.h>
26#else
27static inline void s3c_pm_debug_init_uart(void) {}
28static inline void s3c_pm_arch_update_uart(void __iomem *regs,
29 struct pm_uart_save *save) {}
30#endif
31
32static struct pm_uart_save uart_save;
33
34extern void printascii(const char *);
35
36void s3c_pm_dbg(const char *fmt, ...)
37{
38 va_list va;
39 char buff[256];
40
41 va_start(va, fmt);
42 vsnprintf(buff, sizeof(buff), fmt, va);
43 va_end(va);
44
45 printascii(buff);
46}
47
48void s3c_pm_debug_init(void)
49{
50 /* restart uart clocks so we can use them to output */
51 s3c_pm_debug_init_uart();
52}
53
54static inline void __iomem *s3c_pm_uart_base(void)
55{
56 unsigned long paddr;
57 unsigned long vaddr;
58
59 debug_ll_addr(&paddr, &vaddr);
60
61 return (void __iomem *)vaddr;
62}
63
64void s3c_pm_save_uarts(void)
65{
66 void __iomem *regs = s3c_pm_uart_base();
67 struct pm_uart_save *save = &uart_save;
68
69 save->ulcon = __raw_readl(regs + S3C2410_ULCON);
70 save->ucon = __raw_readl(regs + S3C2410_UCON);
71 save->ufcon = __raw_readl(regs + S3C2410_UFCON);
72 save->umcon = __raw_readl(regs + S3C2410_UMCON);
73 save->ubrdiv = __raw_readl(regs + S3C2410_UBRDIV);
74
75 if (!soc_is_s3c2410())
76 save->udivslot = __raw_readl(regs + S3C2443_DIVSLOT);
77
78 S3C_PMDBG("UART[%p]: ULCON=%04x, UCON=%04x, UFCON=%04x, UBRDIV=%04x\n",
79 regs, save->ulcon, save->ucon, save->ufcon, save->ubrdiv);
80}
81
82void s3c_pm_restore_uarts(void)
83{
84 void __iomem *regs = s3c_pm_uart_base();
85 struct pm_uart_save *save = &uart_save;
86
87 s3c_pm_arch_update_uart(regs, save);
88
89 __raw_writel(save->ulcon, regs + S3C2410_ULCON);
90 __raw_writel(save->ucon, regs + S3C2410_UCON);
91 __raw_writel(save->ufcon, regs + S3C2410_UFCON);
92 __raw_writel(save->umcon, regs + S3C2410_UMCON);
93 __raw_writel(save->ubrdiv, regs + S3C2410_UBRDIV);
94
95 if (!soc_is_s3c2410())
96 __raw_writel(save->udivslot, regs + S3C2443_DIVSLOT);
97}
diff --git a/arch/arm/plat-samsung/pm.c b/arch/arm/plat-samsung/pm.c
index dd70337822da..3d523c90202a 100644
--- a/arch/arm/plat-samsung/pm.c
+++ b/arch/arm/plat-samsung/pm.c
@@ -17,16 +17,12 @@
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/serial_core.h>
21#include <linux/serial_s3c.h> 20#include <linux/serial_s3c.h>
22#include <linux/io.h> 21#include <linux/io.h>
23 22
24#include <asm/cacheflush.h> 23#include <asm/cacheflush.h>
25#include <asm/mach/map.h>
26#include <asm/suspend.h> 24#include <asm/suspend.h>
27 25
28#include <plat/cpu.h>
29
30#ifdef CONFIG_SAMSUNG_ATAGS 26#ifdef CONFIG_SAMSUNG_ATAGS
31#include <mach/hardware.h> 27#include <mach/hardware.h>
32#include <mach/map.h> 28#include <mach/map.h>
@@ -46,86 +42,6 @@
46 42
47unsigned long s3c_pm_flags; 43unsigned long s3c_pm_flags;
48 44
49/* Debug code:
50 *
51 * This code supports debug output to the low level UARTs for use on
52 * resume before the console layer is available.
53*/
54
55#ifdef CONFIG_SAMSUNG_PM_DEBUG
56extern void printascii(const char *);
57
58void s3c_pm_dbg(const char *fmt, ...)
59{
60 va_list va;
61 char buff[256];
62
63 va_start(va, fmt);
64 vsnprintf(buff, sizeof(buff), fmt, va);
65 va_end(va);
66
67 printascii(buff);
68}
69
70static inline void s3c_pm_debug_init(void)
71{
72 /* restart uart clocks so we can use them to output */
73 s3c_pm_debug_init_uart();
74}
75
76static struct pm_uart_save uart_save;
77
78static inline void __iomem *s3c_pm_uart_base(void)
79{
80 unsigned long paddr;
81 unsigned long vaddr;
82
83 debug_ll_addr(&paddr, &vaddr);
84
85 return (void __iomem *)vaddr;
86}
87
88static void s3c_pm_save_uarts(void)
89{
90 void __iomem *regs = s3c_pm_uart_base();
91 struct pm_uart_save *save = &uart_save;
92
93 save->ulcon = __raw_readl(regs + S3C2410_ULCON);
94 save->ucon = __raw_readl(regs + S3C2410_UCON);
95 save->ufcon = __raw_readl(regs + S3C2410_UFCON);
96 save->umcon = __raw_readl(regs + S3C2410_UMCON);
97 save->ubrdiv = __raw_readl(regs + S3C2410_UBRDIV);
98
99 if (!soc_is_s3c2410())
100 save->udivslot = __raw_readl(regs + S3C2443_DIVSLOT);
101
102 S3C_PMDBG("UART[%p]: ULCON=%04x, UCON=%04x, UFCON=%04x, UBRDIV=%04x\n",
103 regs, save->ulcon, save->ucon, save->ufcon, save->ubrdiv);
104}
105
106static void s3c_pm_restore_uarts(void)
107{
108 void __iomem *regs = s3c_pm_uart_base();
109 struct pm_uart_save *save = &uart_save;
110
111 s3c_pm_arch_update_uart(regs, save);
112
113 __raw_writel(save->ulcon, regs + S3C2410_ULCON);
114 __raw_writel(save->ucon, regs + S3C2410_UCON);
115 __raw_writel(save->ufcon, regs + S3C2410_UFCON);
116 __raw_writel(save->umcon, regs + S3C2410_UMCON);
117 __raw_writel(save->ubrdiv, regs + S3C2410_UBRDIV);
118
119 if (!soc_is_s3c2410())
120 __raw_writel(save->udivslot, regs + S3C2443_DIVSLOT);
121}
122#else
123#define s3c_pm_debug_init() do { } while (0)
124
125static void s3c_pm_save_uarts(void) { }
126static void s3c_pm_restore_uarts(void) { }
127#endif
128
129/* The IRQ ext-int code goes here, it is too small to currently bother 45/* The IRQ ext-int code goes here, it is too small to currently bother
130 * with its own file. */ 46 * with its own file. */
131 47