aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/mach-bf609/pm.c
diff options
context:
space:
mode:
authorSonic Zhang <sonic.zhang@analog.com>2012-07-22 23:35:30 -0400
committerBob Liu <lliubbo@gmail.com>2012-07-24 01:39:49 -0400
commitc7e48e1e3e926de21605f959c31689d56fb639e3 (patch)
tree4a598fd55ed79fdcf63077318e04d6f39be594d0 /arch/blackfin/mach-bf609/pm.c
parenta5b4d4be6ce7939d1604fae05786833fffae02f9 (diff)
bfin: pm: add deepsleep for bf60x
Add add deepsleep for bf60x. 1. Call DMC init functions to enter and exit DDR self refresh mode. 2. Wait till CGU PLL is locked after wake up and exit DDR self refresh mode. 3. Make asessembly function enter_deepsleep comply with C funtion ABI in order to call other C functions. 4. Switch kernel stack by register EX_SCRATCH_REG. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Bob Liu <lliubbo@gmail.com>
Diffstat (limited to 'arch/blackfin/mach-bf609/pm.c')
-rw-r--r--arch/blackfin/mach-bf609/pm.c80
1 files changed, 29 insertions, 51 deletions
diff --git a/arch/blackfin/mach-bf609/pm.c b/arch/blackfin/mach-bf609/pm.c
index b76966eb16ad..6094c7d3b1f2 100644
--- a/arch/blackfin/mach-bf609/pm.c
+++ b/arch/blackfin/mach-bf609/pm.c
@@ -18,6 +18,7 @@
18#include <asm/pm.h> 18#include <asm/pm.h>
19#include <mach/pm.h> 19#include <mach/pm.h>
20#include <asm/blackfin.h> 20#include <asm/blackfin.h>
21#include <asm/mem_init.h>
21 22
22/***********************************************************/ 23/***********************************************************/
23/* */ 24/* */
@@ -132,60 +133,30 @@ void bfin_cpu_suspend(void)
132} 133}
133 134
134__attribute__((l1_text)) 135__attribute__((l1_text))
135void bfin_deepsleep(unsigned long mask) 136void bf609_ddr_sr(void)
136{ 137{
137 uint32_t dpm0_ctl; 138 dmc_enter_self_refresh();
138
139 bfin_write32(DPM0_WAKE_EN, 0x10);
140 bfin_write32(DPM0_WAKE_POL, 0x10);
141 dpm0_ctl = 0x00000008;
142 bfin_write32(DPM0_CTL, dpm0_ctl);
143 SSYNC();
144 __asm__ __volatile__( \
145 ".align 8;" \
146 "idle;" \
147 : : \
148 );
149#ifdef CONFIG_BFIN_PM_WAKEUP_TIME_BENCH
150 __asm__ __volatile__(
151 "R0 = 0;"
152 "CYCLES = R0;"
153 "CYCLES2 = R0;"
154 "R0 = SYSCFG;"
155 "BITSET(R0, 1);"
156 "SYSCFG = R0;"
157 : : : "R0"
158 );
159#endif
160
161} 139}
162 140
163__attribute__((l1_text)) 141__attribute__((l1_text))
164void bf609_ddr_sr(void) 142void bf609_ddr_sr_exit(void)
165{ 143{
166 uint32_t reg; 144 dmc_exit_self_refresh();
167
168 reg = bfin_read_DMC0_CTL();
169 reg |= 0x8;
170 bfin_write_DMC0_CTL(reg);
171 145
172 while (!(bfin_read_DMC0_STAT() & 0x8)) 146 /* After wake up from deep sleep and exit DDR from self refress mode,
147 * should wait till CGU PLL is locked.
148 */
149 while (bfin_read32(CGU0_STAT) & CLKSALGN)
173 continue; 150 continue;
174} 151}
175 152
176__attribute__((l1_text)) 153__attribute__((l1_text))
177void bf609_ddr_sr_exit(void) 154void bf609_resume_ccbuf(void)
178{ 155{
179 uint32_t reg; 156 bfin_write32(DPM0_CCBF_EN, 3);
180 while (!(bfin_read_DMC0_STAT() & 0x1)) 157 bfin_write32(DPM0_CTL, 2);
181 continue;
182 158
183 reg = bfin_read_DMC0_CTL(); 159 while ((bfin_read32(DPM0_STAT) & 0xf) != 1);
184 reg &= ~0x8;
185 bfin_write_DMC0_CTL(reg);
186
187 while ((bfin_read_DMC0_STAT() & 0x8))
188 continue;
189} 160}
190 161
191__attribute__((l1_text)) 162__attribute__((l1_text))
@@ -208,6 +179,17 @@ void bfin_hibernate_syscontrol(void)
208#else 179#else
209# define SIC_SYSIRQ(irq) ((irq) - IVG15) 180# define SIC_SYSIRQ(irq) ((irq) - IVG15)
210#endif 181#endif
182asmlinkage void enter_deepsleep(void);
183
184__attribute__((l1_text))
185void bfin_deepsleep(unsigned long mask)
186{
187 bfin_write32(DPM0_WAKE_EN, 0x10);
188 bfin_write32(DPM0_WAKE_POL, 0x10);
189 SSYNC();
190 enter_deepsleep();
191}
192
211void bfin_hibernate(unsigned long mask) 193void bfin_hibernate(unsigned long mask)
212{ 194{
213 bfin_write32(DPM0_WAKE_EN, 0x10); 195 bfin_write32(DPM0_WAKE_EN, 0x10);
@@ -215,8 +197,6 @@ void bfin_hibernate(unsigned long mask)
215 bfin_write32(DPM0_PGCNTR, 0x0000FFFF); 197 bfin_write32(DPM0_PGCNTR, 0x0000FFFF);
216 bfin_write32(DPM0_HIB_DIS, 0xFFFF); 198 bfin_write32(DPM0_HIB_DIS, 0xFFFF);
217 199
218 printk(KERN_DEBUG "hibernate: restore %x pgcnt %x\n", bfin_read32(DPM0_RESTORE0), bfin_read32(DPM0_PGCNTR));
219
220 bf609_hibernate(); 200 bf609_hibernate();
221} 201}
222 202
@@ -294,6 +274,7 @@ void bf609_cpu_pm_enter(suspend_state_t state)
294 else { 274 else {
295 bfin_hibernate(wakeup); 275 bfin_hibernate(wakeup);
296 } 276 }
277
297} 278}
298 279
299int bf609_cpu_pm_prepare(void) 280int bf609_cpu_pm_prepare(void)
@@ -320,21 +301,18 @@ static irqreturn_t test_isr(int irq, void *dev_id)
320 301
321static irqreturn_t dpm0_isr(int irq, void *dev_id) 302static irqreturn_t dpm0_isr(int irq, void *dev_id)
322{ 303{
323 uint32_t wake_stat; 304 bfin_write32(DPM0_WAKE_STAT, bfin_read32(DPM0_WAKE_STAT));
324 305 bfin_write32(CGU0_STAT, bfin_read32(CGU0_STAT));
325 wake_stat = bfin_read32(DPM0_WAKE_STAT);
326 printk(KERN_DEBUG "enter %s wake stat %08x\n", __func__, wake_stat);
327
328 bfin_write32(DPM0_WAKE_STAT, wake_stat);
329 return IRQ_HANDLED; 306 return IRQ_HANDLED;
330} 307}
308#endif
331 309
332static int __init bf609_init_pm(void) 310static int __init bf609_init_pm(void)
333{ 311{
334 int irq; 312 int irq;
335 int error; 313 int error;
336 314
337#if CONFIG_PM_BFIN_WAKE_PE12 315#ifdef CONFIG_PM_BFIN_WAKE_PE12
338 irq = gpio_to_irq(GPIO_PE12); 316 irq = gpio_to_irq(GPIO_PE12);
339 if (irq < 0) { 317 if (irq < 0) {
340 error = irq; 318 error = irq;