blob: d22f6eac9ccabb1816e76e10a0a0263e0c00b69c [file] [log] [blame]
Andriy Skulysh3aa770e2006-09-27 16:20:22 +09001/*
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 */
Andriy Skulysh3aa770e2006-09-27 16:20:22 +09009#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>
Paul Mundt082c44d2006-10-19 16:16:18 +090015#include <asm/hp6xx.h>
Andriy Skulysh3aa770e2006-09-27 16:20:22 +090016#include <asm/cpu/dac.h>
17#include <asm/pm.h>
18
19#define STBCR 0xffffff82
20#define STBCR2 0xffffff88
21
22static 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
Andriy Skulysh3aa770e2006-09-27 16:20:22 +090030#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
Rafael J. Wysocki26398a72007-10-18 03:04:40 -070070static struct platform_suspend_ops hp6x0_pm_ops = {
Andriy Skulysh3aa770e2006-09-27 16:20:22 +090071 .enter = hp6x0_pm_enter,
Rafael J. Wysocki26398a72007-10-18 03:04:40 -070072 .valid = suspend_valid_only_mem,
Andriy Skulysh3aa770e2006-09-27 16:20:22 +090073};
74
75static int __init hp6x0_pm_init(void)
76{
Rafael J. Wysocki26398a72007-10-18 03:04:40 -070077 suspend_set_ops(&hp6x0_pm_ops);
Andriy Skulysh3aa770e2006-09-27 16:20:22 +090078 return 0;
79}
80
81late_initcall(hp6x0_pm_init);