2 * Generic Power Management Routine
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/suspend.h>
10 #include <linux/delay.h>
11 #include <linux/gfp.h>
14 #include <asm/watchdog.h>
17 #define INTR_OFFSET 0x600
19 #define STBCR 0xffffff82
20 #define STBCR2 0xffffff88
22 #define STBCR_STBY 0x80
23 #define STBCR_MSTP2 0x04
25 #define MCR 0xffffff68
26 #define RTCNT 0xffffff70
40 csr
= sh_wdt_read_csr();
42 csr
|= WTCSR_CKS_4096
;
43 sh_wdt_write_csr(csr
);
44 csr
= sh_wdt_read_csr();
48 frqcr
= ctrl_inw(FRQCR
);
49 frqcr
&= ~(FRQCR_PLLEN
| FRQCR_PSTBY
);
50 ctrl_outw(frqcr
, FRQCR
);
53 stbcr
= ctrl_inb(STBCR
);
54 ctrl_outb(stbcr
| STBCR_STBY
| STBCR_MSTP2
, STBCR
);
56 /* set self-refresh */
58 ctrl_outw(mcr
& ~MCR_RFSH
, MCR
);
60 /* set interrupt handler */
61 asm volatile("stc vbr, %0" : "=r" (vbr_old
));
62 vbr_new
= get_zeroed_page(GFP_ATOMIC
);
64 memcpy((void*)(vbr_new
+ INTR_OFFSET
),
65 &wakeup_start
, &wakeup_end
- &wakeup_start
);
66 asm volatile("ldc %0, vbr" : : "r" (vbr_new
));
69 ctrl_outw(mcr
| MCR_RFSH
| MCR_RMODE
, MCR
);
73 asm volatile("ldc %0, vbr" : : "r" (vbr_old
));
78 frqcr
= ctrl_inw(FRQCR
);
80 ctrl_outw(frqcr
, FRQCR
);
83 ctrl_outw(frqcr
, FRQCR
);
85 ctrl_outb(stbcr
, STBCR
);