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 <mach/hp6xx.h>
20 #include <asm/watchdog.h>
22 #define INTR_OFFSET 0x600
24 #define STBCR 0xffffff82
25 #define STBCR2 0xffffff88
27 #define STBCR_STBY 0x80
28 #define STBCR_MSTP2 0x04
30 #define MCR 0xffffff68
31 #define RTCNT 0xffffff70
36 extern u8 wakeup_start
;
39 static void pm_enter(void)
48 csr
= sh_wdt_read_csr();
50 csr
|= WTCSR_CKS_4096
;
51 sh_wdt_write_csr(csr
);
52 csr
= sh_wdt_read_csr();
56 frqcr
= ctrl_inw(FRQCR
);
57 frqcr
&= ~(FRQCR_PLLEN
| FRQCR_PSTBY
);
58 ctrl_outw(frqcr
, FRQCR
);
61 stbcr
= ctrl_inb(STBCR
);
62 ctrl_outb(stbcr
| STBCR_STBY
| STBCR_MSTP2
, STBCR
);
64 /* set self-refresh */
66 ctrl_outw(mcr
& ~MCR_RFSH
, MCR
);
68 /* set interrupt handler */
69 asm volatile("stc vbr, %0" : "=r" (vbr_old
));
70 vbr_new
= get_zeroed_page(GFP_ATOMIC
);
72 memcpy((void*)(vbr_new
+ INTR_OFFSET
),
73 &wakeup_start
, &wakeup_end
- &wakeup_start
);
74 asm volatile("ldc %0, vbr" : : "r" (vbr_new
));
77 ctrl_outw(mcr
| MCR_RFSH
| MCR_RMODE
, MCR
);
81 asm volatile("ldc %0, vbr" : : "r" (vbr_old
));
86 frqcr
= ctrl_inw(FRQCR
);
88 ctrl_outw(frqcr
, FRQCR
);
91 ctrl_outw(frqcr
, FRQCR
);
93 ctrl_outb(stbcr
, STBCR
);
98 static int hp6x0_pm_enter(suspend_state_t state
)
101 #ifdef CONFIG_HD64461_ENABLER
106 #ifdef CONFIG_HD64461_ENABLER
107 outb(0, HD64461_PCC1CSCIER
);
109 scr
= inb(HD64461_PCC1SCR
);
110 scr
|= HD64461_PCCSCR_VCC1
;
111 outb(scr
, HD64461_PCC1SCR
);
113 hd64461_stbcr
= inw(HD64461_STBCR
);
114 hd64461_stbcr
|= HD64461_STBCR_SPC1ST
;
115 outw(hd64461_stbcr
, HD64461_STBCR
);
118 ctrl_outb(0x1f, DACR
);
120 stbcr
= ctrl_inb(STBCR
);
121 ctrl_outb(0x01, STBCR
);
123 stbcr2
= ctrl_inb(STBCR2
);
124 ctrl_outb(0x7f , STBCR2
);
126 outw(0xf07f, HD64461_SCPUCR
);
130 outw(0, HD64461_SCPUCR
);
131 ctrl_outb(stbcr
, STBCR
);
132 ctrl_outb(stbcr2
, STBCR2
);
134 #ifdef CONFIG_HD64461_ENABLER
135 hd64461_stbcr
= inw(HD64461_STBCR
);
136 hd64461_stbcr
&= ~HD64461_STBCR_SPC1ST
;
137 outw(hd64461_stbcr
, HD64461_STBCR
);
139 outb(0x4c, HD64461_PCC1CSCIER
);
140 outb(0x00, HD64461_PCC1CSCR
);
146 static struct platform_suspend_ops hp6x0_pm_ops
= {
147 .enter
= hp6x0_pm_enter
,
148 .valid
= suspend_valid_only_mem
,
151 static int __init
hp6x0_pm_init(void)
153 suspend_set_ops(&hp6x0_pm_ops
);
157 late_initcall(hp6x0_pm_init
);