Merge branch 'x86/fpu' into x86/urgent
[linux-2.6] / arch / sh / boards / mach-hp6xx / pm.c
1 /*
2  * hp6x0 Power Management Routines
3  *
4  * Copyright (c) 2006 Andriy Skulysh <askulsyh@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License.
8  */
9 #include <linux/init.h>
10 #include <linux/suspend.h>
11 #include <linux/errno.h>
12 #include <linux/time.h>
13 #include <asm/io.h>
14 #include <asm/hd64461.h>
15 #include <asm/hp6xx.h>
16 #include <cpu/dac.h>
17 #include <asm/pm.h>
18
19 #define STBCR           0xffffff82
20 #define STBCR2          0xffffff88
21
22 static int hp6x0_pm_enter(suspend_state_t state)
23 {
24         u8 stbcr, stbcr2;
25 #ifdef CONFIG_HD64461_ENABLER
26         u8 scr;
27         u16 hd64461_stbcr;
28 #endif
29
30 #ifdef CONFIG_HD64461_ENABLER
31         outb(0, HD64461_PCC1CSCIER);
32
33         scr = inb(HD64461_PCC1SCR);
34         scr |= HD64461_PCCSCR_VCC1;
35         outb(scr, HD64461_PCC1SCR);
36
37         hd64461_stbcr = inw(HD64461_STBCR);
38         hd64461_stbcr |= HD64461_STBCR_SPC1ST;
39         outw(hd64461_stbcr, HD64461_STBCR);
40 #endif
41
42         ctrl_outb(0x1f, DACR);
43
44         stbcr = ctrl_inb(STBCR);
45         ctrl_outb(0x01, STBCR);
46
47         stbcr2 = ctrl_inb(STBCR2);
48         ctrl_outb(0x7f , STBCR2);
49
50         outw(0xf07f, HD64461_SCPUCR);
51
52         pm_enter();
53
54         outw(0, HD64461_SCPUCR);
55         ctrl_outb(stbcr, STBCR);
56         ctrl_outb(stbcr2, STBCR2);
57
58 #ifdef CONFIG_HD64461_ENABLER
59         hd64461_stbcr = inw(HD64461_STBCR);
60         hd64461_stbcr &= ~HD64461_STBCR_SPC1ST;
61         outw(hd64461_stbcr, HD64461_STBCR);
62
63         outb(0x4c, HD64461_PCC1CSCIER);
64         outb(0x00, HD64461_PCC1CSCR);
65 #endif
66
67         return 0;
68 }
69
70 static struct platform_suspend_ops hp6x0_pm_ops = {
71         .enter          = hp6x0_pm_enter,
72         .valid          = suspend_valid_only_mem,
73 };
74
75 static int __init hp6x0_pm_init(void)
76 {
77         suspend_set_ops(&hp6x0_pm_ops);
78         return 0;
79 }
80
81 late_initcall(hp6x0_pm_init);