aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s3c24xx
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-12-11 19:24:06 -0500
committerBen Dooks <ben-linux@fluff.org>2009-03-08 08:23:51 -0400
commit6419711a164ba1304fa8fbb75ae9485455e04dcd (patch)
tree15fe79b0ffff33d253258b849f1b69ac4c2c3bbe /arch/arm/plat-s3c24xx
parenta3f66351b3cc89011e8a34068c245b413ce696d6 (diff)
[ARM] S3C: Move PM support functions to common location
Start moving the PM code by moving all the common support functions to a common location in arch/arm/plat-s3c. With the move we rename the functions from s3cxxx_ to s3c_ to fit the new location. Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s3c24xx')
-rw-r--r--arch/arm/plat-s3c24xx/irq.c4
-rw-r--r--arch/arm/plat-s3c24xx/pm.c113
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x.c4
-rw-r--r--arch/arm/plat-s3c24xx/sleep.S8
4 files changed, 33 insertions, 96 deletions
diff --git a/arch/arm/plat-s3c24xx/irq.c b/arch/arm/plat-s3c24xx/irq.c
index 0192ecdc1442..2fa8c9f4b354 100644
--- a/arch/arm/plat-s3c24xx/irq.c
+++ b/arch/arm/plat-s3c24xx/irq.c
@@ -616,7 +616,7 @@ int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state)
616 for (i = 0; i < ARRAY_SIZE(save_eintflt); i++) 616 for (i = 0; i < ARRAY_SIZE(save_eintflt); i++)
617 save_eintflt[i] = __raw_readl(S3C24XX_EINFLT0 + (i*4)); 617 save_eintflt[i] = __raw_readl(S3C24XX_EINFLT0 + (i*4));
618 618
619 s3c2410_pm_do_save(irq_save, ARRAY_SIZE(irq_save)); 619 s3c_pm_do_save(irq_save, ARRAY_SIZE(irq_save));
620 save_eintmask = __raw_readl(S3C24XX_EINTMASK); 620 save_eintmask = __raw_readl(S3C24XX_EINTMASK);
621 621
622 return 0; 622 return 0;
@@ -632,7 +632,7 @@ int s3c24xx_irq_resume(struct sys_device *dev)
632 for (i = 0; i < ARRAY_SIZE(save_eintflt); i++) 632 for (i = 0; i < ARRAY_SIZE(save_eintflt); i++)
633 __raw_writel(save_eintflt[i], S3C24XX_EINFLT0 + (i*4)); 633 __raw_writel(save_eintflt[i], S3C24XX_EINFLT0 + (i*4));
634 634
635 s3c2410_pm_do_restore(irq_save, ARRAY_SIZE(irq_save)); 635 s3c_pm_do_restore(irq_save, ARRAY_SIZE(irq_save));
636 __raw_writel(save_eintmask, S3C24XX_EINTMASK); 636 __raw_writel(save_eintmask, S3C24XX_EINTMASK);
637 637
638 return 0; 638 return 0;
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
diff --git a/arch/arm/plat-s3c24xx/s3c244x.c b/arch/arm/plat-s3c24xx/s3c244x.c
index c1de6bb0101b..1364317d421e 100644
--- a/arch/arm/plat-s3c24xx/s3c244x.c
+++ b/arch/arm/plat-s3c24xx/s3c244x.c
@@ -145,13 +145,13 @@ static struct sleep_save s3c244x_sleep[] = {
145 145
146static int s3c244x_suspend(struct sys_device *dev, pm_message_t state) 146static int s3c244x_suspend(struct sys_device *dev, pm_message_t state)
147{ 147{
148 s3c2410_pm_do_save(s3c244x_sleep, ARRAY_SIZE(s3c244x_sleep)); 148 s3c_pm_do_save(s3c244x_sleep, ARRAY_SIZE(s3c244x_sleep));
149 return 0; 149 return 0;
150} 150}
151 151
152static int s3c244x_resume(struct sys_device *dev) 152static int s3c244x_resume(struct sys_device *dev)
153{ 153{
154 s3c2410_pm_do_restore(s3c244x_sleep, ARRAY_SIZE(s3c244x_sleep)); 154 s3c_pm_do_restore(s3c244x_sleep, ARRAY_SIZE(s3c244x_sleep));
155 return 0; 155 return 0;
156} 156}
157 157
diff --git a/arch/arm/plat-s3c24xx/sleep.S b/arch/arm/plat-s3c24xx/sleep.S
index 76594b212802..7c1955ff3171 100644
--- a/arch/arm/plat-s3c24xx/sleep.S
+++ b/arch/arm/plat-s3c24xx/sleep.S
@@ -84,7 +84,7 @@ resume_with_mmu:
84 .ltorg 84 .ltorg
85 85
86 @@ the next bits sit in the .data segment, even though they 86 @@ the next bits sit in the .data segment, even though they
87 @@ happen to be code... the s3c2410_sleep_save_phys needs to be 87 @@ happen to be code... the s3c_sleep_save_phys needs to be
88 @@ accessed by the resume code before it can restore the MMU. 88 @@ accessed by the resume code before it can restore the MMU.
89 @@ This means that the variable has to be close enough for the 89 @@ This means that the variable has to be close enough for the
90 @@ code to read it... since the .text segment needs to be RO, 90 @@ code to read it... since the .text segment needs to be RO,
@@ -92,8 +92,8 @@ resume_with_mmu:
92 92
93 .data 93 .data
94 94
95 .global s3c2410_sleep_save_phys 95 .global s3c_sleep_save_phys
96s3c2410_sleep_save_phys: 96s3c_sleep_save_phys:
97 .word 0 97 .word 0
98 98
99 99
@@ -145,7 +145,7 @@ ENTRY(s3c2410_cpu_resume)
145 mcr p15, 0, r1, c8, c7, 0 @@ invalidate I & D TLBs 145 mcr p15, 0, r1, c8, c7, 0 @@ invalidate I & D TLBs
146 mcr p15, 0, r1, c7, c7, 0 @@ invalidate I & D caches 146 mcr p15, 0, r1, c7, c7, 0 @@ invalidate I & D caches
147 147
148 ldr r0, s3c2410_sleep_save_phys @ address of restore block 148 ldr r0, s3c_sleep_save_phys @ address of restore block
149 ldmia r0, { r4 - r13 } 149 ldmia r0, { r4 - r13 }
150 150
151 mcr p15, 0, r4, c13, c0, 0 @ PID 151 mcr p15, 0, r4, c13, c0, 0 @ PID