diff options
author | Magnus Damm <damm@igel.co.jp> | 2008-12-04 08:45:03 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-12-22 04:43:52 -0500 |
commit | 3e51762759db9e26c6c3e4e1010d80a50c62ca03 (patch) | |
tree | 6cfbcc3d318b0cb36e7a3d106698dbf9d361ec6a /arch/sh/boards/mach-hp6xx | |
parent | 04645185d06e8b0c92f6f1f9d76ede45637afc09 (diff) |
sh: move the hp6xx pm code
Move the not-so-generic pm code from arch/sh/kernel/pm.c to the
platform directory together with the rest of the hp6xx pm code.
This is done to let non-hp6xx platforms enable CONFIG_PM.
Signed-off-by: Magnus Damm <damm@igel.co.jp>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/boards/mach-hp6xx')
-rw-r--r-- | arch/sh/boards/mach-hp6xx/pm.c | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/arch/sh/boards/mach-hp6xx/pm.c b/arch/sh/boards/mach-hp6xx/pm.c index 64af1f2eef05..d936c1af7620 100644 --- a/arch/sh/boards/mach-hp6xx/pm.c +++ b/arch/sh/boards/mach-hp6xx/pm.c | |||
@@ -10,15 +10,91 @@ | |||
10 | #include <linux/suspend.h> | 10 | #include <linux/suspend.h> |
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/time.h> | 12 | #include <linux/time.h> |
13 | #include <linux/delay.h> | ||
14 | #include <linux/gfp.h> | ||
13 | #include <asm/io.h> | 15 | #include <asm/io.h> |
14 | #include <asm/hd64461.h> | 16 | #include <asm/hd64461.h> |
15 | #include <mach/hp6xx.h> | 17 | #include <mach/hp6xx.h> |
16 | #include <cpu/dac.h> | 18 | #include <cpu/dac.h> |
17 | #include <asm/pm.h> | 19 | #include <asm/freq.h> |
20 | #include <asm/watchdog.h> | ||
21 | |||
22 | #define INTR_OFFSET 0x600 | ||
18 | 23 | ||
19 | #define STBCR 0xffffff82 | 24 | #define STBCR 0xffffff82 |
20 | #define STBCR2 0xffffff88 | 25 | #define STBCR2 0xffffff88 |
21 | 26 | ||
27 | #define STBCR_STBY 0x80 | ||
28 | #define STBCR_MSTP2 0x04 | ||
29 | |||
30 | #define MCR 0xffffff68 | ||
31 | #define RTCNT 0xffffff70 | ||
32 | |||
33 | #define MCR_RMODE 2 | ||
34 | #define MCR_RFSH 4 | ||
35 | |||
36 | extern u8 wakeup_start; | ||
37 | extern u8 wakeup_end; | ||
38 | |||
39 | static void pm_enter(void) | ||
40 | { | ||
41 | u8 stbcr, csr; | ||
42 | u16 frqcr, mcr; | ||
43 | u32 vbr_new, vbr_old; | ||
44 | |||
45 | set_bl_bit(); | ||
46 | |||
47 | /* set wdt */ | ||
48 | csr = sh_wdt_read_csr(); | ||
49 | csr &= ~WTCSR_TME; | ||
50 | csr |= WTCSR_CKS_4096; | ||
51 | sh_wdt_write_csr(csr); | ||
52 | csr = sh_wdt_read_csr(); | ||
53 | sh_wdt_write_cnt(0); | ||
54 | |||
55 | /* disable PLL1 */ | ||
56 | frqcr = ctrl_inw(FRQCR); | ||
57 | frqcr &= ~(FRQCR_PLLEN | FRQCR_PSTBY); | ||
58 | ctrl_outw(frqcr, FRQCR); | ||
59 | |||
60 | /* enable standby */ | ||
61 | stbcr = ctrl_inb(STBCR); | ||
62 | ctrl_outb(stbcr | STBCR_STBY | STBCR_MSTP2, STBCR); | ||
63 | |||
64 | /* set self-refresh */ | ||
65 | mcr = ctrl_inw(MCR); | ||
66 | ctrl_outw(mcr & ~MCR_RFSH, MCR); | ||
67 | |||
68 | /* set interrupt handler */ | ||
69 | asm volatile("stc vbr, %0" : "=r" (vbr_old)); | ||
70 | vbr_new = get_zeroed_page(GFP_ATOMIC); | ||
71 | udelay(50); | ||
72 | memcpy((void*)(vbr_new + INTR_OFFSET), | ||
73 | &wakeup_start, &wakeup_end - &wakeup_start); | ||
74 | asm volatile("ldc %0, vbr" : : "r" (vbr_new)); | ||
75 | |||
76 | ctrl_outw(0, RTCNT); | ||
77 | ctrl_outw(mcr | MCR_RFSH | MCR_RMODE, MCR); | ||
78 | |||
79 | cpu_sleep(); | ||
80 | |||
81 | asm volatile("ldc %0, vbr" : : "r" (vbr_old)); | ||
82 | |||
83 | free_page(vbr_new); | ||
84 | |||
85 | /* enable PLL1 */ | ||
86 | frqcr = ctrl_inw(FRQCR); | ||
87 | frqcr |= FRQCR_PSTBY; | ||
88 | ctrl_outw(frqcr, FRQCR); | ||
89 | udelay(50); | ||
90 | frqcr |= FRQCR_PLLEN; | ||
91 | ctrl_outw(frqcr, FRQCR); | ||
92 | |||
93 | ctrl_outb(stbcr, STBCR); | ||
94 | |||
95 | clear_bl_bit(); | ||
96 | } | ||
97 | |||
22 | static int hp6x0_pm_enter(suspend_state_t state) | 98 | static int hp6x0_pm_enter(suspend_state_t state) |
23 | { | 99 | { |
24 | u8 stbcr, stbcr2; | 100 | u8 stbcr, stbcr2; |