2 * hp6x0 Power Management Routines
4 * Copyright (c) 2006 Andriy Skulysh <askulsyh@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License.
9 #include <linux/init.h>
10 #include <linux/suspend.h>
11 #include <linux/errno.h>
12 #include <linux/time.h>
13 #include <linux/delay.h>
14 #include <linux/gfp.h>
16 #include <asm/hd64461.h>
17 #include <asm/bl_bit.h>
18 #include <mach/hp6xx.h>
21 #include <asm/watchdog.h>
23 #define INTR_OFFSET 0x600
25 #define STBCR 0xffffff82
26 #define STBCR2 0xffffff88
28 #define STBCR_STBY 0x80
29 #define STBCR_MSTP2 0x04
31 #define MCR 0xffffff68
32 #define RTCNT 0xffffff70
37 extern u8 wakeup_start
;
40 static void pm_enter(void)
49 csr
= sh_wdt_read_csr();
51 csr
|= WTCSR_CKS_4096
;
52 sh_wdt_write_csr(csr
);
53 csr
= sh_wdt_read_csr();
57 frqcr
= __raw_readw(FRQCR
);
58 frqcr
&= ~(FRQCR_PLLEN
| FRQCR_PSTBY
);
59 __raw_writew(frqcr
, FRQCR
);
62 stbcr
= __raw_readb(STBCR
);
63 __raw_writeb(stbcr
| STBCR_STBY
| STBCR_MSTP2
, STBCR
);
65 /* set self-refresh */
66 mcr
= __raw_readw(MCR
);
67 __raw_writew(mcr
& ~MCR_RFSH
, MCR
);
69 /* set interrupt handler */
70 asm volatile("stc vbr, %0" : "=r" (vbr_old
));
71 vbr_new
= get_zeroed_page(GFP_ATOMIC
);
73 memcpy((void*)(vbr_new
+ INTR_OFFSET
),
74 &wakeup_start
, &wakeup_end
- &wakeup_start
);
75 asm volatile("ldc %0, vbr" : : "r" (vbr_new
));
77 __raw_writew(0, RTCNT
);
78 __raw_writew(mcr
| MCR_RFSH
| MCR_RMODE
, MCR
);
82 asm volatile("ldc %0, vbr" : : "r" (vbr_old
));
87 frqcr
= __raw_readw(FRQCR
);
89 __raw_writew(frqcr
, FRQCR
);
92 __raw_writew(frqcr
, FRQCR
);
94 __raw_writeb(stbcr
, STBCR
);
99 static int hp6x0_pm_enter(suspend_state_t state
)
102 #ifdef CONFIG_HD64461_ENABLER
107 #ifdef CONFIG_HD64461_ENABLER
108 outb(0, HD64461_PCC1CSCIER
);
110 scr
= inb(HD64461_PCC1SCR
);
111 scr
|= HD64461_PCCSCR_VCC1
;
112 outb(scr
, HD64461_PCC1SCR
);
114 hd64461_stbcr
= inw(HD64461_STBCR
);
115 hd64461_stbcr
|= HD64461_STBCR_SPC1ST
;
116 outw(hd64461_stbcr
, HD64461_STBCR
);
119 __raw_writeb(0x1f, DACR
);
121 stbcr
= __raw_readb(STBCR
);
122 __raw_writeb(0x01, STBCR
);
124 stbcr2
= __raw_readb(STBCR2
);
125 __raw_writeb(0x7f , STBCR2
);
127 outw(0xf07f, HD64461_SCPUCR
);
131 outw(0, HD64461_SCPUCR
);
132 __raw_writeb(stbcr
, STBCR
);
133 __raw_writeb(stbcr2
, STBCR2
);
135 #ifdef CONFIG_HD64461_ENABLER
136 hd64461_stbcr
= inw(HD64461_STBCR
);
137 hd64461_stbcr
&= ~HD64461_STBCR_SPC1ST
;
138 outw(hd64461_stbcr
, HD64461_STBCR
);
140 outb(0x4c, HD64461_PCC1CSCIER
);
141 outb(0x00, HD64461_PCC1CSCR
);
147 static const struct platform_suspend_ops hp6x0_pm_ops
= {
148 .enter
= hp6x0_pm_enter
,
149 .valid
= suspend_valid_only_mem
,
152 static int __init
hp6x0_pm_init(void)
154 suspend_set_ops(&hp6x0_pm_ops
);
158 late_initcall(hp6x0_pm_init
);