Merge xburst target.
[openwrt.git] / target / linux / xburst / files-2.6.32 / arch / mips / jz4740 / pm.c
1 /*
2 * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
3 * JZ4740 SoC power management support
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * You should have received a copy of the GNU General Public License along
11 * with this program; if not, write to the Free Software Foundation, Inc.,
12 * 675 Mass Ave, Cambridge, MA 02139, USA.
13 *
14 */
15
16 #include <linux/init.h>
17 #include <linux/pm.h>
18 #include <linux/delay.h>
19 #include <linux/suspend.h>
20 #include <asm/mach-jz4740/regs.h>
21
22 extern void jz4740_intc_suspend(void);
23 extern void jz4740_intc_resume(void);
24
25 static int jz_pm_enter(suspend_state_t state)
26 {
27 unsigned long nfcsr = REG_EMC_NFCSR;
28 uint32_t scr = REG_CPM_SCR;
29
30 /* Disable nand flash */
31 REG_EMC_NFCSR = ~0xff;
32
33 udelay(100);
34
35 /*stop udc and usb*/
36 REG_CPM_SCR &= ~( 1<<6 | 1<<7);
37 REG_CPM_SCR |= 0<<6 | 1<<7;
38
39 jz4740_intc_suspend();
40
41 /* Enter SLEEP mode */
42 REG_CPM_LCR &= ~CPM_LCR_LPM_MASK;
43 REG_CPM_LCR |= CPM_LCR_LPM_SLEEP;
44 __asm__(".set\tmips3\n\t"
45 "wait\n\t"
46 ".set\tmips0");
47
48 /* Restore to IDLE mode */
49 REG_CPM_LCR &= ~CPM_LCR_LPM_MASK;
50 REG_CPM_LCR |= CPM_LCR_LPM_IDLE;
51
52 /* Restore nand flash control register */
53 REG_EMC_NFCSR = nfcsr;
54
55 jz4740_intc_resume();
56
57 /* Restore sleep control register */
58 REG_CPM_SCR = scr;
59
60 return 0;
61 }
62
63 static struct platform_suspend_ops jz_pm_ops = {
64 .valid = suspend_valid_only_mem,
65 .enter = jz_pm_enter,
66 };
67
68 /*
69 * Initialize power interface
70 */
71 int __init jz_pm_init(void)
72 {
73 suspend_set_ops(&jz_pm_ops);
74 return 0;
75
76 }
77 late_initcall(jz_pm_init);
This page took 0.051117 seconds and 5 git commands to generate.