diff options
author | Ben Dooks <ben-linux@fluff.org> | 2008-12-11 19:24:08 -0500 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2009-03-08 08:33:51 -0400 |
commit | 2261e0e6e3991d4c5f33e9fedadfc465eedc05a7 (patch) | |
tree | aa0125f362a24ecaf0cc69ff3715fecf098b4791 /arch/arm/plat-s3c24xx | |
parent | 549c7e33aeb9bfe441ecf68639d2227bb90978e7 (diff) |
[ARM] S3C: Move plat-s3c24xx pm.c support into plat-s3c
Move parts of the core and debug suspend code into the
plat-s3c for use with the new s3c64xx code.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/plat-s3c24xx')
-rw-r--r-- | arch/arm/plat-s3c24xx/include/plat/pm-core.h | 59 | ||||
-rw-r--r-- | arch/arm/plat-s3c24xx/pm.c | 224 |
2 files changed, 73 insertions, 210 deletions
diff --git a/arch/arm/plat-s3c24xx/include/plat/pm-core.h b/arch/arm/plat-s3c24xx/include/plat/pm-core.h new file mode 100644 index 000000000000..c75882113e04 --- /dev/null +++ b/arch/arm/plat-s3c24xx/include/plat/pm-core.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* linux/arch/arm/plat-s3c24xx/include/plat/pll.h | ||
2 | * | ||
3 | * Copyright 2008 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * http://armlinux.simtec.co.uk/ | ||
6 | * | ||
7 | * S3C24xx - PM core support for arch/arm/plat-s3c/pm.c | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | static inline void s3c_pm_debug_init_uart(void) | ||
15 | { | ||
16 | unsigned long tmp = __raw_readl(S3C2410_CLKCON); | ||
17 | |||
18 | /* re-start uart clocks */ | ||
19 | tmp |= S3C2410_CLKCON_UART0; | ||
20 | tmp |= S3C2410_CLKCON_UART1; | ||
21 | tmp |= S3C2410_CLKCON_UART2; | ||
22 | |||
23 | __raw_writel(tmp, S3C2410_CLKCON); | ||
24 | udelay(10); | ||
25 | } | ||
26 | |||
27 | static inline void s3c_pm_arch_prepare_irqs(void) | ||
28 | { | ||
29 | __raw_writel(s3c_irqwake_intmask, S3C2410_INTMSK); | ||
30 | __raw_writel(s3c_irqwake_eintmask, S3C2410_EINTMASK); | ||
31 | |||
32 | /* ack any outstanding external interrupts before we go to sleep */ | ||
33 | |||
34 | __raw_writel(__raw_readl(S3C2410_EINTPEND), S3C2410_EINTPEND); | ||
35 | __raw_writel(__raw_readl(S3C2410_INTPND), S3C2410_INTPND); | ||
36 | __raw_writel(__raw_readl(S3C2410_SRCPND), S3C2410_SRCPND); | ||
37 | |||
38 | } | ||
39 | |||
40 | static inline void s3c_pm_arch_stop_clocks(void) | ||
41 | { | ||
42 | __raw_writel(0x00, S3C2410_CLKCON); /* turn off clocks over sleep */ | ||
43 | } | ||
44 | |||
45 | static void s3c_pm_show_resume_irqs(int start, unsigned long which, | ||
46 | unsigned long mask); | ||
47 | |||
48 | static inline void s3c_pm_arch_show_resume_irqs(void) | ||
49 | { | ||
50 | S3C_PMDBG("post sleep: IRQs 0x%08x, 0x%08x\n", | ||
51 | __raw_readl(S3C2410_SRCPND), | ||
52 | __raw_readl(S3C2410_EINTPEND)); | ||
53 | |||
54 | s3c_pm_show_resume_irqs(IRQ_EINT0, __raw_readl(S3C2410_SRCPND), | ||
55 | s3c_irqwake_intmask); | ||
56 | |||
57 | s3c_pm_show_resume_irqs(IRQ_EINT4-4, __raw_readl(S3C2410_EINTPEND), | ||
58 | s3c_irqwake_eintmask); | ||
59 | } | ||
diff --git a/arch/arm/plat-s3c24xx/pm.c b/arch/arm/plat-s3c24xx/pm.c index e2ae12da16e7..062a29339a91 100644 --- a/arch/arm/plat-s3c24xx/pm.c +++ b/arch/arm/plat-s3c24xx/pm.c | |||
@@ -34,9 +34,6 @@ | |||
34 | #include <linux/serial_core.h> | 34 | #include <linux/serial_core.h> |
35 | #include <linux/io.h> | 35 | #include <linux/io.h> |
36 | 36 | ||
37 | #include <asm/cacheflush.h> | ||
38 | #include <mach/hardware.h> | ||
39 | |||
40 | #include <plat/regs-serial.h> | 37 | #include <plat/regs-serial.h> |
41 | #include <mach/regs-clock.h> | 38 | #include <mach/regs-clock.h> |
42 | #include <mach/regs-gpio.h> | 39 | #include <mach/regs-gpio.h> |
@@ -47,7 +44,6 @@ | |||
47 | 44 | ||
48 | #include <plat/pm.h> | 45 | #include <plat/pm.h> |
49 | 46 | ||
50 | |||
51 | #define PFX "s3c24xx-pm: " | 47 | #define PFX "s3c24xx-pm: " |
52 | 48 | ||
53 | static struct sleep_save core_save[] = { | 49 | static struct sleep_save core_save[] = { |
@@ -115,66 +111,6 @@ static struct sleep_save misc_save[] = { | |||
115 | SAVE_ITEM(S3C2410_DCLKCON), | 111 | SAVE_ITEM(S3C2410_DCLKCON), |
116 | }; | 112 | }; |
117 | 113 | ||
118 | #ifdef CONFIG_S3C2410_PM_DEBUG | ||
119 | |||
120 | #define SAVE_UART(va) \ | ||
121 | SAVE_ITEM((va) + S3C2410_ULCON), \ | ||
122 | SAVE_ITEM((va) + S3C2410_UCON), \ | ||
123 | SAVE_ITEM((va) + S3C2410_UFCON), \ | ||
124 | SAVE_ITEM((va) + S3C2410_UMCON), \ | ||
125 | SAVE_ITEM((va) + S3C2410_UBRDIV) | ||
126 | |||
127 | static struct sleep_save uart_save[] = { | ||
128 | SAVE_UART(S3C24XX_VA_UART0), | ||
129 | SAVE_UART(S3C24XX_VA_UART1), | ||
130 | #ifndef CONFIG_CPU_S3C2400 | ||
131 | SAVE_UART(S3C24XX_VA_UART2), | ||
132 | #endif | ||
133 | }; | ||
134 | |||
135 | /* debug | ||
136 | * | ||
137 | * we send the debug to printascii() to allow it to be seen if the | ||
138 | * system never wakes up from the sleep | ||
139 | */ | ||
140 | |||
141 | static void s3c2410_pm_debug_init(void) | ||
142 | { | ||
143 | unsigned long tmp = __raw_readl(S3C2410_CLKCON); | ||
144 | |||
145 | /* re-start uart clocks */ | ||
146 | tmp |= S3C2410_CLKCON_UART0; | ||
147 | tmp |= S3C2410_CLKCON_UART1; | ||
148 | tmp |= S3C2410_CLKCON_UART2; | ||
149 | |||
150 | __raw_writel(tmp, S3C2410_CLKCON); | ||
151 | udelay(10); | ||
152 | } | ||
153 | |||
154 | #else | ||
155 | #define s3c2410_pm_debug_init() do { } while(0) | ||
156 | |||
157 | static struct sleep_save uart_save[] = {}; | ||
158 | #endif | ||
159 | |||
160 | /* s3c2410_pm_show_resume_irqs | ||
161 | * | ||
162 | * print any IRQs asserted at resume time (ie, we woke from) | ||
163 | */ | ||
164 | |||
165 | static void s3c2410_pm_show_resume_irqs(int start, unsigned long which, | ||
166 | unsigned long mask) | ||
167 | { | ||
168 | int i; | ||
169 | |||
170 | which &= ~mask; | ||
171 | |||
172 | for (i = 0; i <= 31; i++) { | ||
173 | if ((which) & (1L<<i)) { | ||
174 | S3C_PMDBG("IRQ %d asserted at resume\n", start+i); | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | 114 | ||
179 | /* s3c_pm_check_resume_pin | 115 | /* s3c_pm_check_resume_pin |
180 | * | 116 | * |
@@ -206,12 +142,12 @@ static void s3c_pm_check_resume_pin(unsigned int pin, unsigned int irqoffs) | |||
206 | } | 142 | } |
207 | } | 143 | } |
208 | 144 | ||
209 | /* s3c2410_pm_configure_extint | 145 | /* s3c_pm_configure_extint |
210 | * | 146 | * |
211 | * configure all external interrupt pins | 147 | * configure all external interrupt pins |
212 | */ | 148 | */ |
213 | 149 | ||
214 | static void s3c2410_pm_configure_extint(void) | 150 | void s3c_pm_configure_extint(void) |
215 | { | 151 | { |
216 | int pin; | 152 | int pin; |
217 | 153 | ||
@@ -235,12 +171,12 @@ static void s3c2410_pm_configure_extint(void) | |||
235 | #define OFFS_DAT (S3C2410_GPADAT - S3C2410_GPACON) | 171 | #define OFFS_DAT (S3C2410_GPADAT - S3C2410_GPACON) |
236 | #define OFFS_UP (S3C2410_GPBUP - S3C2410_GPBCON) | 172 | #define OFFS_UP (S3C2410_GPBUP - S3C2410_GPBCON) |
237 | 173 | ||
238 | /* s3c2410_pm_save_gpios() | 174 | /* s3c_pm_save_gpios() |
239 | * | 175 | * |
240 | * Save the state of the GPIOs | 176 | * Save the state of the GPIOs |
241 | */ | 177 | */ |
242 | 178 | ||
243 | static void s3c2410_pm_save_gpios(void) | 179 | void s3c_pm_save_gpios(void) |
244 | { | 180 | { |
245 | struct gpio_sleep *gps = gpio_save; | 181 | struct gpio_sleep *gps = gpio_save; |
246 | unsigned int gpio; | 182 | unsigned int gpio; |
@@ -279,7 +215,10 @@ static inline int is_out(unsigned long con) | |||
279 | return con == 1; | 215 | return con == 1; |
280 | } | 216 | } |
281 | 217 | ||
282 | /* s3c2410_pm_restore_gpio() | 218 | /** |
219 | * s3c2410_pm_restore_gpio() - restore the given GPIO bank | ||
220 | * @index: The number of the GPIO bank being resumed. | ||
221 | * @gps: The sleep confgiuration for the bank. | ||
283 | * | 222 | * |
284 | * Restore one of the GPIO banks that was saved during suspend. This is | 223 | * Restore one of the GPIO banks that was saved during suspend. This is |
285 | * not as simple as once thought, due to the possibility of glitches | 224 | * not as simple as once thought, due to the possibility of glitches |
@@ -397,7 +336,7 @@ static void s3c2410_pm_restore_gpio(int index, struct gpio_sleep *gps) | |||
397 | * Restore the state of the GPIOs | 336 | * Restore the state of the GPIOs |
398 | */ | 337 | */ |
399 | 338 | ||
400 | static void s3c2410_pm_restore_gpios(void) | 339 | void s3c_pm_restore_gpios(void) |
401 | { | 340 | { |
402 | struct gpio_sleep *gps = gpio_save; | 341 | struct gpio_sleep *gps = gpio_save; |
403 | int gpio; | 342 | int gpio; |
@@ -407,150 +346,15 @@ static void s3c2410_pm_restore_gpios(void) | |||
407 | } | 346 | } |
408 | } | 347 | } |
409 | 348 | ||
410 | void (*pm_cpu_prep)(void); | 349 | void s3c_pm_restore_core(void) |
411 | void (*pm_cpu_sleep)(void); | ||
412 | |||
413 | #define any_allowed(mask, allow) (((mask) & (allow)) != (allow)) | ||
414 | |||
415 | /* s3c2410_pm_enter | ||
416 | * | ||
417 | * central control for sleep/resume process | ||
418 | */ | ||
419 | |||
420 | static int s3c2410_pm_enter(suspend_state_t state) | ||
421 | { | 350 | { |
422 | unsigned long regs_save[16]; | ||
423 | |||
424 | /* ensure the debug is initialised (if enabled) */ | ||
425 | |||
426 | s3c2410_pm_debug_init(); | ||
427 | |||
428 | S3C_PMDBG("s3c2410_pm_enter(%d)\n", state); | ||
429 | |||
430 | if (pm_cpu_prep == NULL || pm_cpu_sleep == NULL) { | ||
431 | printk(KERN_ERR PFX "error: no cpu sleep functions set\n"); | ||
432 | return -EINVAL; | ||
433 | } | ||
434 | |||
435 | /* check if we have anything to wake-up with... bad things seem | ||
436 | * to happen if you suspend with no wakeup (system will often | ||
437 | * require a full power-cycle) | ||
438 | */ | ||
439 | |||
440 | if (!any_allowed(s3c_irqwake_intmask, s3c_irqwake_intallow) && | ||
441 | !any_allowed(s3c_irqwake_eintmask, s3c_irqwake_eintallow)) { | ||
442 | printk(KERN_ERR PFX "No sources enabled for wake-up!\n"); | ||
443 | printk(KERN_ERR PFX "Aborting sleep\n"); | ||
444 | return -EINVAL; | ||
445 | } | ||
446 | |||
447 | /* prepare check area if configured */ | ||
448 | |||
449 | s3c_pm_check_prepare(); | ||
450 | |||
451 | /* store the physical address of the register recovery block */ | ||
452 | |||
453 | s3c_sleep_save_phys = virt_to_phys(regs_save); | ||
454 | |||
455 | S3C_PMDBG("s3c_sleep_save_phys=0x%08lx\n", s3c_sleep_save_phys); | ||
456 | |||
457 | /* save all necessary core registers not covered by the drivers */ | ||
458 | |||
459 | s3c2410_pm_save_gpios(); | ||
460 | s3c_pm_do_save(misc_save, ARRAY_SIZE(misc_save)); | ||
461 | s3c_pm_do_save(core_save, ARRAY_SIZE(core_save)); | ||
462 | s3c_pm_do_save(uart_save, ARRAY_SIZE(uart_save)); | ||
463 | |||
464 | /* set the irq configuration for wake */ | ||
465 | |||
466 | s3c2410_pm_configure_extint(); | ||
467 | |||
468 | S3C_PMDBG("sleep: irq wakeup masks: %08lx,%08lx\n", | ||
469 | s3c_irqwake_intmask, s3c_irqwake_eintmask); | ||
470 | |||
471 | __raw_writel(s3c_irqwake_intmask, S3C2410_INTMSK); | ||
472 | __raw_writel(s3c_irqwake_eintmask, S3C2410_EINTMASK); | ||
473 | |||
474 | /* ack any outstanding external interrupts before we go to sleep */ | ||
475 | |||
476 | __raw_writel(__raw_readl(S3C2410_EINTPEND), S3C2410_EINTPEND); | ||
477 | __raw_writel(__raw_readl(S3C2410_INTPND), S3C2410_INTPND); | ||
478 | __raw_writel(__raw_readl(S3C2410_SRCPND), S3C2410_SRCPND); | ||
479 | |||
480 | /* call cpu specific preparation */ | ||
481 | |||
482 | pm_cpu_prep(); | ||
483 | |||
484 | /* flush cache back to ram */ | ||
485 | |||
486 | flush_cache_all(); | ||
487 | |||
488 | s3c_pm_check_store(); | ||
489 | |||
490 | /* send the cpu to sleep... */ | ||
491 | |||
492 | __raw_writel(0x00, S3C2410_CLKCON); /* turn off clocks over sleep */ | ||
493 | |||
494 | /* s3c2410_cpu_save will also act as our return point from when | ||
495 | * we resume as it saves its own register state, so use the return | ||
496 | * code to differentiate return from save and return from sleep */ | ||
497 | |||
498 | if (s3c2410_cpu_save(regs_save) == 0) { | ||
499 | flush_cache_all(); | ||
500 | pm_cpu_sleep(); | ||
501 | } | ||
502 | |||
503 | /* restore the cpu state */ | ||
504 | |||
505 | cpu_init(); | ||
506 | |||
507 | /* restore the system state */ | ||
508 | |||
509 | s3c_pm_do_restore_core(core_save, ARRAY_SIZE(core_save)); | 351 | s3c_pm_do_restore_core(core_save, ARRAY_SIZE(core_save)); |
510 | s3c_pm_do_restore(misc_save, ARRAY_SIZE(misc_save)); | 352 | s3c_pm_do_restore(misc_save, ARRAY_SIZE(misc_save)); |
511 | s3c_pm_do_restore(uart_save, ARRAY_SIZE(uart_save)); | ||
512 | s3c2410_pm_restore_gpios(); | ||
513 | |||
514 | s3c2410_pm_debug_init(); | ||
515 | |||
516 | /* check what irq (if any) restored the system */ | ||
517 | |||
518 | S3C_PMDBG("post sleep: IRQs 0x%08x, 0x%08x\n", | ||
519 | __raw_readl(S3C2410_SRCPND), | ||
520 | __raw_readl(S3C2410_EINTPEND)); | ||
521 | |||
522 | s3c2410_pm_show_resume_irqs(IRQ_EINT0, __raw_readl(S3C2410_SRCPND), | ||
523 | s3c_irqwake_intmask); | ||
524 | |||
525 | s3c2410_pm_show_resume_irqs(IRQ_EINT4-4, __raw_readl(S3C2410_EINTPEND), | ||
526 | s3c_irqwake_eintmask); | ||
527 | |||
528 | S3C_PMDBG("post sleep, preparing to return\n"); | ||
529 | |||
530 | s3c_pm_check_restore(); | ||
531 | |||
532 | /* ok, let's return from sleep */ | ||
533 | |||
534 | S3C_PMDBG("S3C2410 PM Resume (post-restore)\n"); | ||
535 | return 0; | ||
536 | } | 353 | } |
537 | 354 | ||
538 | static struct platform_suspend_ops s3c2410_pm_ops = { | 355 | void s3c_pm_save_core(void) |
539 | .enter = s3c2410_pm_enter, | ||
540 | .valid = suspend_valid_only_mem, | ||
541 | }; | ||
542 | |||
543 | /* s3c2410_pm_init | ||
544 | * | ||
545 | * Attach the power management functions. This should be called | ||
546 | * from the board specific initialisation if the board supports | ||
547 | * it. | ||
548 | */ | ||
549 | |||
550 | int __init s3c2410_pm_init(void) | ||
551 | { | 356 | { |
552 | printk("S3C2410 Power Management, (c) 2004 Simtec Electronics\n"); | 357 | s3c_pm_do_save(misc_save, ARRAY_SIZE(misc_save)); |
553 | 358 | s3c_pm_do_save(core_save, ARRAY_SIZE(core_save)); | |
554 | suspend_set_ops(&s3c2410_pm_ops); | ||
555 | return 0; | ||
556 | } | 359 | } |
360 | |||