diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2012-05-17 05:33:00 -0400 |
---|---|---|
committer | Bob Liu <lliubbo@gmail.com> | 2012-05-21 02:54:52 -0400 |
commit | 72b099ed93989575b0c447023748968d30059e8f (patch) | |
tree | 0e5bb7040da26232d66c2fb6c24854566ed9a07a /arch/blackfin | |
parent | 0fbd88ca20a68a633b565e1f5ba18ca64afb0c78 (diff) |
blackfin: bf60x: pm: Add a debug option to calculate kernel wakeup time.
Display the total time when kernel resumes normal from standby or suspend to mem
mode.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bob Liu <lliubbo@gmail.com>
Diffstat (limited to 'arch/blackfin')
-rw-r--r-- | arch/blackfin/Kconfig.debug | 7 | ||||
-rw-r--r-- | arch/blackfin/include/asm/dpmc.h | 14 | ||||
-rw-r--r-- | arch/blackfin/mach-bf609/hibernate.S | 3 | ||||
-rw-r--r-- | arch/blackfin/mach-bf609/pm.c | 12 | ||||
-rw-r--r-- | arch/blackfin/mach-common/dpmc_modes.S | 8 | ||||
-rw-r--r-- | arch/blackfin/mach-common/pm.c | 30 |
6 files changed, 74 insertions, 0 deletions
diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug index e2a3d4c8ab9a..79594694ee90 100644 --- a/arch/blackfin/Kconfig.debug +++ b/arch/blackfin/Kconfig.debug | |||
@@ -253,4 +253,11 @@ config BFIN_PSEUDODBG_INSNS | |||
253 | 253 | ||
254 | Most people should say N here. | 254 | Most people should say N here. |
255 | 255 | ||
256 | config BFIN_PM_WAKEUP_TIME_BENCH | ||
257 | bool "Display the total time for kernel to resume from power saving mode" | ||
258 | default n | ||
259 | help | ||
260 | Display the total time when kernel resumes normal from standby or | ||
261 | suspend to mem mode. | ||
262 | |||
256 | endmenu | 263 | endmenu |
diff --git a/arch/blackfin/include/asm/dpmc.h b/arch/blackfin/include/asm/dpmc.h index 528f47685781..e91eae8330a6 100644 --- a/arch/blackfin/include/asm/dpmc.h +++ b/arch/blackfin/include/asm/dpmc.h | |||
@@ -53,6 +53,16 @@ | |||
53 | #define PM_SYS_PUSH16(n, x) _PM_PUSH(n, x, w, SYSMMR_BASE) | 53 | #define PM_SYS_PUSH16(n, x) _PM_PUSH(n, x, w, SYSMMR_BASE) |
54 | #define PM_SYS_POP16(n, x) _PM_POP(n, x, w, SYSMMR_BASE) | 54 | #define PM_SYS_POP16(n, x) _PM_POP(n, x, w, SYSMMR_BASE) |
55 | 55 | ||
56 | .macro bfin_init_pm_bench_cycles | ||
57 | #ifdef CONFIG_BFIN_PM_WAKEUP_TIME_BENCH | ||
58 | R4 = 0; | ||
59 | CYCLES = R4; | ||
60 | CYCLES2 = R4; | ||
61 | R4 = SYSCFG; | ||
62 | BITSET(R4, 1); | ||
63 | SYSCFG = R4; | ||
64 | #endif | ||
65 | .endm | ||
56 | 66 | ||
57 | .macro bfin_cpu_reg_save | 67 | .macro bfin_cpu_reg_save |
58 | /* | 68 | /* |
@@ -98,8 +108,10 @@ | |||
98 | r7 = RETI; | 108 | r7 = RETI; |
99 | [--sp] = RETS; | 109 | [--sp] = RETS; |
100 | [--sp] = ASTAT; | 110 | [--sp] = ASTAT; |
111 | #ifndef CONFIG_BFIN_PM_WAKEUP_TIME_BENCH | ||
101 | [--sp] = CYCLES; | 112 | [--sp] = CYCLES; |
102 | [--sp] = CYCLES2; | 113 | [--sp] = CYCLES2; |
114 | #endif | ||
103 | [--sp] = SYSCFG; | 115 | [--sp] = SYSCFG; |
104 | [--sp] = RETX; | 116 | [--sp] = RETX; |
105 | [--sp] = SEQSTAT; | 117 | [--sp] = SEQSTAT; |
@@ -115,8 +127,10 @@ | |||
115 | SEQSTAT = [sp++]; | 127 | SEQSTAT = [sp++]; |
116 | RETX = [sp++]; | 128 | RETX = [sp++]; |
117 | SYSCFG = [sp++]; | 129 | SYSCFG = [sp++]; |
130 | #ifndef CONFIG_BFIN_PM_WAKEUP_TIME_BENCH | ||
118 | CYCLES2 = [sp++]; | 131 | CYCLES2 = [sp++]; |
119 | CYCLES = [sp++]; | 132 | CYCLES = [sp++]; |
133 | #endif | ||
120 | ASTAT = [sp++]; | 134 | ASTAT = [sp++]; |
121 | RETS = [sp++]; | 135 | RETS = [sp++]; |
122 | 136 | ||
diff --git a/arch/blackfin/mach-bf609/hibernate.S b/arch/blackfin/mach-bf609/hibernate.S index baedd6e6abf4..d37a532519c8 100644 --- a/arch/blackfin/mach-bf609/hibernate.S +++ b/arch/blackfin/mach-bf609/hibernate.S | |||
@@ -24,6 +24,9 @@ ENTRY(_enter_hibernate) | |||
24 | P0.L = LO(DPM0_CTL); | 24 | P0.L = LO(DPM0_CTL); |
25 | R3.H = HI(0x00000010); | 25 | R3.H = HI(0x00000010); |
26 | R3.L = LO(0x00000010); | 26 | R3.L = LO(0x00000010); |
27 | |||
28 | bfin_init_pm_bench_cycles; | ||
29 | |||
27 | [P0] = R3; | 30 | [P0] = R3; |
28 | 31 | ||
29 | SSYNC; | 32 | SSYNC; |
diff --git a/arch/blackfin/mach-bf609/pm.c b/arch/blackfin/mach-bf609/pm.c index 79cdf41096c2..849d77e5631c 100644 --- a/arch/blackfin/mach-bf609/pm.c +++ b/arch/blackfin/mach-bf609/pm.c | |||
@@ -147,6 +147,18 @@ void bfin_deepsleep(unsigned long mask) | |||
147 | "idle;" \ | 147 | "idle;" \ |
148 | : : \ | 148 | : : \ |
149 | ); | 149 | ); |
150 | #ifdef CONFIG_BFIN_PM_WAKEUP_TIME_BENCH | ||
151 | __asm__ __volatile__( | ||
152 | "%0 = 0;" | ||
153 | "CYCLES = %0;" | ||
154 | "CYCLES2 = %0;" | ||
155 | "%0 = SYSCFG;" | ||
156 | "BITSET(%0, 1);" | ||
157 | "SYSCFG = %0;" | ||
158 | : "=d,a" (dpm0_ctl) : | ||
159 | ); | ||
160 | #endif | ||
161 | |||
150 | } | 162 | } |
151 | 163 | ||
152 | __attribute__((l1_text)) | 164 | __attribute__((l1_text)) |
diff --git a/arch/blackfin/mach-common/dpmc_modes.S b/arch/blackfin/mach-common/dpmc_modes.S index cfb7c3c00370..de99f3aac2c5 100644 --- a/arch/blackfin/mach-common/dpmc_modes.S +++ b/arch/blackfin/mach-common/dpmc_modes.S | |||
@@ -42,6 +42,9 @@ ENTRY(_sleep_mode) | |||
42 | BITCLR (R7, 5); | 42 | BITCLR (R7, 5); |
43 | w[p0] = R7.L; | 43 | w[p0] = R7.L; |
44 | IDLE; | 44 | IDLE; |
45 | |||
46 | bfin_init_pm_bench_cycles; | ||
47 | |||
45 | call _test_pll_locked; | 48 | call _test_pll_locked; |
46 | 49 | ||
47 | RETS = [SP++]; | 50 | RETS = [SP++]; |
@@ -74,6 +77,9 @@ ENTRY(_hibernate_mode) | |||
74 | 77 | ||
75 | /* Finally, we climb into our cave to hibernate */ | 78 | /* Finally, we climb into our cave to hibernate */ |
76 | W[P3] = R4.L; | 79 | W[P3] = R4.L; |
80 | |||
81 | bfin_init_pm_bench_cycles; | ||
82 | |||
77 | CLI R2; | 83 | CLI R2; |
78 | IDLE; | 84 | IDLE; |
79 | .Lforever: | 85 | .Lforever: |
@@ -158,6 +164,8 @@ ENTRY(_sleep_deeper) | |||
158 | SSYNC; | 164 | SSYNC; |
159 | IDLE; | 165 | IDLE; |
160 | 166 | ||
167 | bfin_init_pm_bench_cycles; | ||
168 | |||
161 | call _test_pll_locked; | 169 | call _test_pll_locked; |
162 | 170 | ||
163 | P0.H = hi(PLL_DIV); | 171 | P0.H = hi(PLL_DIV); |
diff --git a/arch/blackfin/mach-common/pm.c b/arch/blackfin/mach-common/pm.c index 610a3cdf3998..ca6655e0d653 100644 --- a/arch/blackfin/mach-common/pm.c +++ b/arch/blackfin/mach-common/pm.c | |||
@@ -247,9 +247,39 @@ static int bfin_pm_enter(suspend_state_t state) | |||
247 | return 0; | 247 | return 0; |
248 | } | 248 | } |
249 | 249 | ||
250 | #ifdef CONFIG_BFIN_PM_WAKEUP_TIME_BENCH | ||
251 | void bfin_pm_end(void) | ||
252 | { | ||
253 | u32 cycle, cycle2; | ||
254 | u64 usec64; | ||
255 | u32 usec; | ||
256 | |||
257 | __asm__ __volatile__ ( | ||
258 | "1: %0 = CYCLES2\n" | ||
259 | "%1 = CYCLES\n" | ||
260 | "%2 = CYCLES2\n" | ||
261 | "CC = %2 == %0\n" | ||
262 | "if ! CC jump 1b\n" | ||
263 | : "=d,a" (cycle2), "=d,a" (cycle), "=d,a" (usec) : : "CC" | ||
264 | ); | ||
265 | |||
266 | usec64 = ((u64)cycle2 << 32) + cycle; | ||
267 | do_div(usec64, get_cclk() / USEC_PER_SEC); | ||
268 | usec = usec64; | ||
269 | if (usec == 0) | ||
270 | usec = 1; | ||
271 | |||
272 | pr_info("PM: resume of kernel completes after %ld msec %03ld usec\n", | ||
273 | usec / USEC_PER_MSEC, usec % USEC_PER_MSEC); | ||
274 | } | ||
275 | #endif | ||
276 | |||
250 | static const struct platform_suspend_ops bfin_pm_ops = { | 277 | static const struct platform_suspend_ops bfin_pm_ops = { |
251 | .enter = bfin_pm_enter, | 278 | .enter = bfin_pm_enter, |
252 | .valid = bfin_pm_valid, | 279 | .valid = bfin_pm_valid, |
280 | #ifdef CONFIG_BFIN_PM_WAKEUP_TIME_BENCH | ||
281 | .end = bfin_pm_end, | ||
282 | #endif | ||
253 | }; | 283 | }; |
254 | 284 | ||
255 | static int __init bfin_pm_init(void) | 285 | static int __init bfin_pm_init(void) |