aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s3c24xx/pm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-s3c24xx/pm.c')
-rw-r--r--arch/arm/plat-s3c24xx/pm.c113
1 files changed, 25 insertions, 88 deletions
diff --git a/arch/arm/plat-s3c24xx/pm.c b/arch/arm/plat-s3c24xx/pm.c
index 34ef18e5b2a1..c161f9c9a1d4 100644
--- a/arch/arm/plat-s3c24xx/pm.c
+++ b/arch/arm/plat-s3c24xx/pm.c
@@ -49,9 +49,6 @@
49 49
50#include <plat/pm.h> 50#include <plat/pm.h>
51 51
52/* for external use */
53
54unsigned long s3c_pm_flags;
55 52
56#define PFX "s3c24xx-pm: " 53#define PFX "s3c24xx-pm: "
57 54
@@ -143,20 +140,6 @@ static struct sleep_save uart_save[] = {
143 * system never wakes up from the sleep 140 * system never wakes up from the sleep
144*/ 141*/
145 142
146extern void printascii(const char *);
147
148void pm_dbg(const char *fmt, ...)
149{
150 va_list va;
151 char buff[256];
152
153 va_start(va, fmt);
154 vsprintf(buff, fmt, va);
155 va_end(va);
156
157 printascii(buff);
158}
159
160static void s3c2410_pm_debug_init(void) 143static void s3c2410_pm_debug_init(void)
161{ 144{
162 unsigned long tmp = __raw_readl(S3C2410_CLKCON); 145 unsigned long tmp = __raw_readl(S3C2410_CLKCON);
@@ -170,10 +153,7 @@ static void s3c2410_pm_debug_init(void)
170 udelay(10); 153 udelay(10);
171} 154}
172 155
173#define DBG(fmt...) pm_dbg(fmt)
174#else 156#else
175#define DBG(fmt...) printk(KERN_DEBUG fmt)
176
177#define s3c2410_pm_debug_init() do { } while(0) 157#define s3c2410_pm_debug_init() do { } while(0)
178 158
179static struct sleep_save uart_save[] = {}; 159static struct sleep_save uart_save[] = {};
@@ -211,7 +191,7 @@ static void s3c2410_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg)
211 191
212 if ((ptr->flags & IORESOURCE_MEM) && 192 if ((ptr->flags & IORESOURCE_MEM) &&
213 strcmp(ptr->name, "System RAM") == 0) { 193 strcmp(ptr->name, "System RAM") == 0) {
214 DBG("Found system RAM at %08lx..%08lx\n", 194 S3C_PMDBG("Found system RAM at %08lx..%08lx\n",
215 ptr->start, ptr->end); 195 ptr->start, ptr->end);
216 arg = (fn)(ptr, arg); 196 arg = (fn)(ptr, arg);
217 } 197 }
@@ -232,7 +212,7 @@ static u32 *s3c2410_pm_countram(struct resource *res, u32 *val)
232 size += CHECK_CHUNKSIZE-1; 212 size += CHECK_CHUNKSIZE-1;
233 size /= CHECK_CHUNKSIZE; 213 size /= CHECK_CHUNKSIZE;
234 214
235 DBG("Area %08lx..%08lx, %d blocks\n", res->start, res->end, size); 215 S3C_PMDBG("Area %08lx..%08lx, %d blocks\n", res->start, res->end, size);
236 216
237 *val += size * sizeof(u32); 217 *val += size * sizeof(u32);
238 return val; 218 return val;
@@ -252,7 +232,7 @@ static void s3c2410_pm_check_prepare(void)
252 232
253 s3c2410_pm_run_sysram(s3c2410_pm_countram, &crc_size); 233 s3c2410_pm_run_sysram(s3c2410_pm_countram, &crc_size);
254 234
255 DBG("s3c2410_pm_prepare_check: %u checks needed\n", crc_size); 235 S3C_PMDBG("s3c2410_pm_prepare_check: %u checks needed\n", crc_size);
256 236
257 crcs = kmalloc(crc_size+4, GFP_KERNEL); 237 crcs = kmalloc(crc_size+4, GFP_KERNEL);
258 if (crcs == NULL) 238 if (crcs == NULL)
@@ -308,7 +288,7 @@ static inline int in_region(void *ptr, int size, void *what, size_t whatsz)
308 288
309static u32 *s3c2410_pm_runcheck(struct resource *res, u32 *val) 289static u32 *s3c2410_pm_runcheck(struct resource *res, u32 *val)
310{ 290{
311 void *save_at = phys_to_virt(s3c2410_sleep_save_phys); 291 void *save_at = phys_to_virt(s3c_sleep_save_phys);
312 unsigned long addr; 292 unsigned long addr;
313 unsigned long left; 293 unsigned long left;
314 void *ptr; 294 void *ptr;
@@ -324,12 +304,12 @@ static u32 *s3c2410_pm_runcheck(struct resource *res, u32 *val)
324 ptr = phys_to_virt(addr); 304 ptr = phys_to_virt(addr);
325 305
326 if (in_region(ptr, left, crcs, crc_size)) { 306 if (in_region(ptr, left, crcs, crc_size)) {
327 DBG("skipping %08lx, has crc block in\n", addr); 307 S3C_PMDBG("skipping %08lx, has crc block in\n", addr);
328 goto skip_check; 308 goto skip_check;
329 } 309 }
330 310
331 if (in_region(ptr, left, save_at, 32*4 )) { 311 if (in_region(ptr, left, save_at, 32*4 )) {
332 DBG("skipping %08lx, has save block in\n", addr); 312 S3C_PMDBG("skipping %08lx, has save block in\n", addr);
333 goto skip_check; 313 goto skip_check;
334 } 314 }
335 315
@@ -340,7 +320,7 @@ static u32 *s3c2410_pm_runcheck(struct resource *res, u32 *val)
340 printk(KERN_ERR PFX "Restore CRC error at " 320 printk(KERN_ERR PFX "Restore CRC error at "
341 "%08lx (%08x vs %08x)\n", addr, calc, *val); 321 "%08lx (%08x vs %08x)\n", addr, calc, *val);
342 322
343 DBG("Restore CRC error at %08lx (%08x vs %08x)\n", 323 S3C_PMDBG("Restore CRC error at %08lx (%08x vs %08x)\n",
344 addr, calc, *val); 324 addr, calc, *val);
345 } 325 }
346 326
@@ -373,49 +353,6 @@ static void s3c2410_pm_check_restore(void)
373#define s3c2410_pm_check_store() do { } while(0) 353#define s3c2410_pm_check_store() do { } while(0)
374#endif 354#endif
375 355
376/* helper functions to save and restore register state */
377
378void s3c2410_pm_do_save(struct sleep_save *ptr, int count)
379{
380 for (; count > 0; count--, ptr++) {
381 ptr->val = __raw_readl(ptr->reg);
382 DBG("saved %p value %08lx\n", ptr->reg, ptr->val);
383 }
384}
385
386/* s3c2410_pm_do_restore
387 *
388 * restore the system from the given list of saved registers
389 *
390 * Note, we do not use DBG() in here, as the system may not have
391 * restore the UARTs state yet
392*/
393
394void s3c2410_pm_do_restore(struct sleep_save *ptr, int count)
395{
396 for (; count > 0; count--, ptr++) {
397 printk(KERN_DEBUG "restore %p (restore %08lx, was %08x)\n",
398 ptr->reg, ptr->val, __raw_readl(ptr->reg));
399
400 __raw_writel(ptr->val, ptr->reg);
401 }
402}
403
404/* s3c2410_pm_do_restore_core
405 *
406 * similar to s3c2410_pm_do_restore_core
407 *
408 * WARNING: Do not put any debug in here that may effect memory or use
409 * peripherals, as things may be changing!
410*/
411
412static void s3c2410_pm_do_restore_core(struct sleep_save *ptr, int count)
413{
414 for (; count > 0; count--, ptr++) {
415 __raw_writel(ptr->val, ptr->reg);
416 }
417}
418
419/* s3c2410_pm_show_resume_irqs 356/* s3c2410_pm_show_resume_irqs
420 * 357 *
421 * print any IRQs asserted at resume time (ie, we woke from) 358 * print any IRQs asserted at resume time (ie, we woke from)
@@ -430,7 +367,7 @@ static void s3c2410_pm_show_resume_irqs(int start, unsigned long which,
430 367
431 for (i = 0; i <= 31; i++) { 368 for (i = 0; i <= 31; i++) {
432 if ((which) & (1L<<i)) { 369 if ((which) & (1L<<i)) {
433 DBG("IRQ %d asserted at resume\n", start+i); 370 S3C_PMDBG("IRQ %d asserted at resume\n", start+i);
434 } 371 }
435 } 372 }
436} 373}
@@ -456,10 +393,10 @@ static void s3c2410_pm_check_resume_pin(unsigned int pin, unsigned int irqoffs)
456 393
457 if (!irqstate) { 394 if (!irqstate) {
458 if (pinstate == S3C2410_GPIO_IRQ) 395 if (pinstate == S3C2410_GPIO_IRQ)
459 DBG("Leaving IRQ %d (pin %d) enabled\n", irq, pin); 396 S3C_PMDBG("Leaving IRQ %d (pin %d) enabled\n", irq, pin);
460 } else { 397 } else {
461 if (pinstate == S3C2410_GPIO_IRQ) { 398 if (pinstate == S3C2410_GPIO_IRQ) {
462 DBG("Disabling IRQ %d (pin %d)\n", irq, pin); 399 S3C_PMDBG("Disabling IRQ %d (pin %d)\n", irq, pin);
463 s3c2410_gpio_cfgpin(pin, S3C2410_GPIO_INPUT); 400 s3c2410_gpio_cfgpin(pin, S3C2410_GPIO_INPUT);
464 } 401 }
465 } 402 }
@@ -646,8 +583,8 @@ static void s3c2410_pm_restore_gpio(int index, struct gpio_sleep *gps)
646 __raw_writel(gps->gpup, base + OFFS_UP); 583 __raw_writel(gps->gpup, base + OFFS_UP);
647 } 584 }
648 585
649 DBG("GPIO[%d] CON %08lx => %08lx, DAT %08lx => %08lx\n", 586 S3C_PMDBG("GPIO[%d] CON %08lx => %08lx, DAT %08lx => %08lx\n",
650 index, old_gpcon, gps_gpcon, old_gpdat, gps_gpdat); 587 index, old_gpcon, gps_gpcon, old_gpdat, gps_gpdat);
651} 588}
652 589
653 590
@@ -684,7 +621,7 @@ static int s3c2410_pm_enter(suspend_state_t state)
684 621
685 s3c2410_pm_debug_init(); 622 s3c2410_pm_debug_init();
686 623
687 DBG("s3c2410_pm_enter(%d)\n", state); 624 S3C_PMDBG("s3c2410_pm_enter(%d)\n", state);
688 625
689 if (pm_cpu_prep == NULL || pm_cpu_sleep == NULL) { 626 if (pm_cpu_prep == NULL || pm_cpu_sleep == NULL) {
690 printk(KERN_ERR PFX "error: no cpu sleep functions set\n"); 627 printk(KERN_ERR PFX "error: no cpu sleep functions set\n");
@@ -709,22 +646,22 @@ static int s3c2410_pm_enter(suspend_state_t state)
709 646
710 /* store the physical address of the register recovery block */ 647 /* store the physical address of the register recovery block */
711 648
712 s3c2410_sleep_save_phys = virt_to_phys(regs_save); 649 s3c_sleep_save_phys = virt_to_phys(regs_save);
713 650
714 DBG("s3c2410_sleep_save_phys=0x%08lx\n", s3c2410_sleep_save_phys); 651 S3C_PMDBG("s3c_sleep_save_phys=0x%08lx\n", s3c_sleep_save_phys);
715 652
716 /* save all necessary core registers not covered by the drivers */ 653 /* save all necessary core registers not covered by the drivers */
717 654
718 s3c2410_pm_save_gpios(); 655 s3c2410_pm_save_gpios();
719 s3c2410_pm_do_save(misc_save, ARRAY_SIZE(misc_save)); 656 s3c_pm_do_save(misc_save, ARRAY_SIZE(misc_save));
720 s3c2410_pm_do_save(core_save, ARRAY_SIZE(core_save)); 657 s3c_pm_do_save(core_save, ARRAY_SIZE(core_save));
721 s3c2410_pm_do_save(uart_save, ARRAY_SIZE(uart_save)); 658 s3c_pm_do_save(uart_save, ARRAY_SIZE(uart_save));
722 659
723 /* set the irq configuration for wake */ 660 /* set the irq configuration for wake */
724 661
725 s3c2410_pm_configure_extint(); 662 s3c2410_pm_configure_extint();
726 663
727 DBG("sleep: irq wakeup masks: %08lx,%08lx\n", 664 S3C_PMDBG("sleep: irq wakeup masks: %08lx,%08lx\n",
728 s3c_irqwake_intmask, s3c_irqwake_eintmask); 665 s3c_irqwake_intmask, s3c_irqwake_eintmask);
729 666
730 __raw_writel(s3c_irqwake_intmask, S3C2410_INTMSK); 667 __raw_writel(s3c_irqwake_intmask, S3C2410_INTMSK);
@@ -765,16 +702,16 @@ static int s3c2410_pm_enter(suspend_state_t state)
765 702
766 /* restore the system state */ 703 /* restore the system state */
767 704
768 s3c2410_pm_do_restore_core(core_save, ARRAY_SIZE(core_save)); 705 s3c_pm_do_restore_core(core_save, ARRAY_SIZE(core_save));
769 s3c2410_pm_do_restore(misc_save, ARRAY_SIZE(misc_save)); 706 s3c_pm_do_restore(misc_save, ARRAY_SIZE(misc_save));
770 s3c2410_pm_do_restore(uart_save, ARRAY_SIZE(uart_save)); 707 s3c_pm_do_restore(uart_save, ARRAY_SIZE(uart_save));
771 s3c2410_pm_restore_gpios(); 708 s3c2410_pm_restore_gpios();
772 709
773 s3c2410_pm_debug_init(); 710 s3c2410_pm_debug_init();
774 711
775 /* check what irq (if any) restored the system */ 712 /* check what irq (if any) restored the system */
776 713
777 DBG("post sleep: IRQs 0x%08x, 0x%08x\n", 714 S3C_PMDBG("post sleep: IRQs 0x%08x, 0x%08x\n",
778 __raw_readl(S3C2410_SRCPND), 715 __raw_readl(S3C2410_SRCPND),
779 __raw_readl(S3C2410_EINTPEND)); 716 __raw_readl(S3C2410_EINTPEND));
780 717
@@ -784,13 +721,13 @@ static int s3c2410_pm_enter(suspend_state_t state)
784 s3c2410_pm_show_resume_irqs(IRQ_EINT4-4, __raw_readl(S3C2410_EINTPEND), 721 s3c2410_pm_show_resume_irqs(IRQ_EINT4-4, __raw_readl(S3C2410_EINTPEND),
785 s3c_irqwake_eintmask); 722 s3c_irqwake_eintmask);
786 723
787 DBG("post sleep, preparing to return\n"); 724 S3C_PMDBG("post sleep, preparing to return\n");
788 725
789 s3c2410_pm_check_restore(); 726 s3c2410_pm_check_restore();
790 727
791 /* ok, let's return from sleep */ 728 /* ok, let's return from sleep */
792 729
793 DBG("S3C2410 PM Resume (post-restore)\n"); 730 S3C_PMDBG("S3C2410 PM Resume (post-restore)\n");
794 return 0; 731 return 0;
795} 732}
796 733