Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / arch / sh / boards / hp6xx / pm.c
blobd22f6eac9ccabb1816e76e10a0a0263e0c00b69c
1 /*
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.
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 <asm/cpu/dac.h>
17 #include <asm/pm.h>
19 #define STBCR 0xffffff82
20 #define STBCR2 0xffffff88
22 static int hp6x0_pm_enter(suspend_state_t state)
24 u8 stbcr, stbcr2;
25 #ifdef CONFIG_HD64461_ENABLER
26 u8 scr;
27 u16 hd64461_stbcr;
28 #endif
30 #ifdef CONFIG_HD64461_ENABLER
31 outb(0, HD64461_PCC1CSCIER);
33 scr = inb(HD64461_PCC1SCR);
34 scr |= HD64461_PCCSCR_VCC1;
35 outb(scr, HD64461_PCC1SCR);
37 hd64461_stbcr = inw(HD64461_STBCR);
38 hd64461_stbcr |= HD64461_STBCR_SPC1ST;
39 outw(hd64461_stbcr, HD64461_STBCR);
40 #endif
42 ctrl_outb(0x1f, DACR);
44 stbcr = ctrl_inb(STBCR);
45 ctrl_outb(0x01, STBCR);
47 stbcr2 = ctrl_inb(STBCR2);
48 ctrl_outb(0x7f , STBCR2);
50 outw(0xf07f, HD64461_SCPUCR);
52 pm_enter();
54 outw(0, HD64461_SCPUCR);
55 ctrl_outb(stbcr, STBCR);
56 ctrl_outb(stbcr2, STBCR2);
58 #ifdef CONFIG_HD64461_ENABLER
59 hd64461_stbcr = inw(HD64461_STBCR);
60 hd64461_stbcr &= ~HD64461_STBCR_SPC1ST;
61 outw(hd64461_stbcr, HD64461_STBCR);
63 outb(0x4c, HD64461_PCC1CSCIER);
64 outb(0x00, HD64461_PCC1CSCR);
65 #endif
67 return 0;
70 static struct platform_suspend_ops hp6x0_pm_ops = {
71 .enter = hp6x0_pm_enter,
72 .valid = suspend_valid_only_mem,
75 static int __init hp6x0_pm_init(void)
77 suspend_set_ops(&hp6x0_pm_ops);
78 return 0;
81 late_initcall(hp6x0_pm_init);