sh: Kill off remaining config.h references.
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / sh / boards / hp6xx / pm.c
CommitLineData
3aa770e7
AS
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 */
3aa770e7
AS
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/hp6xx.h>
16#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
30 if (state != PM_SUSPEND_MEM)
31 return -EINVAL;
32
33#ifdef CONFIG_HD64461_ENABLER
34 outb(0, HD64461_PCC1CSCIER);
35
36 scr = inb(HD64461_PCC1SCR);
37 scr |= HD64461_PCCSCR_VCC1;
38 outb(scr, HD64461_PCC1SCR);
39
40 hd64461_stbcr = inw(HD64461_STBCR);
41 hd64461_stbcr |= HD64461_STBCR_SPC1ST;
42 outw(hd64461_stbcr, HD64461_STBCR);
43#endif
44
45 ctrl_outb(0x1f, DACR);
46
47 stbcr = ctrl_inb(STBCR);
48 ctrl_outb(0x01, STBCR);
49
50 stbcr2 = ctrl_inb(STBCR2);
51 ctrl_outb(0x7f , STBCR2);
52
53 outw(0xf07f, HD64461_SCPUCR);
54
55 pm_enter();
56
57 outw(0, HD64461_SCPUCR);
58 ctrl_outb(stbcr, STBCR);
59 ctrl_outb(stbcr2, STBCR2);
60
61#ifdef CONFIG_HD64461_ENABLER
62 hd64461_stbcr = inw(HD64461_STBCR);
63 hd64461_stbcr &= ~HD64461_STBCR_SPC1ST;
64 outw(hd64461_stbcr, HD64461_STBCR);
65
66 outb(0x4c, HD64461_PCC1CSCIER);
67 outb(0x00, HD64461_PCC1CSCR);
68#endif
69
70 return 0;
71}
72
73/*
74 * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
75 */
76static struct pm_ops hp6x0_pm_ops = {
77 .pm_disk_mode = PM_DISK_FIRMWARE,
78 .enter = hp6x0_pm_enter,
79};
80
81static int __init hp6x0_pm_init(void)
82{
83 pm_set_ops(&hp6x0_pm_ops);
84 return 0;
85}
86
87late_initcall(hp6x0_pm_init);