2 * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
3 * JZ4740 SoC power management support
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.
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.
16 #include <linux/init.h>
18 #include <linux/delay.h>
19 #include <linux/suspend.h>
20 #include <asm/mach-jz4740/regs.h>
22 extern void jz4740_intc_suspend(void);
23 extern void jz4740_intc_resume(void);
25 static int jz_pm_enter(suspend_state_t state
)
27 unsigned long nfcsr
= REG_EMC_NFCSR
;
28 uint32_t scr
= REG_CPM_SCR
;
30 /* Disable nand flash */
31 REG_EMC_NFCSR
= ~0xff;
36 REG_CPM_SCR
&= ~( 1<<6 | 1<<7);
37 REG_CPM_SCR
|= 0<<6 | 1<<7;
39 jz4740_intc_suspend();
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"
48 /* Restore to IDLE mode */
49 REG_CPM_LCR
&= ~CPM_LCR_LPM_MASK
;
50 REG_CPM_LCR
|= CPM_LCR_LPM_IDLE
;
52 /* Restore nand flash control register */
53 REG_EMC_NFCSR
= nfcsr
;
57 /* Restore sleep control register */
63 static struct platform_suspend_ops jz_pm_ops
= {
64 .valid
= suspend_valid_only_mem
,
69 * Initialize power interface
71 int __init
jz_pm_init(void)
73 suspend_set_ops(&jz_pm_ops
);
77 late_initcall(jz_pm_init
);