1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-01 22:35:20 +02:00
openwrt-xburst/target/linux/xburst/files-2.6.31/arch/mips/jz4740/pm.c

86 lines
2.0 KiB
C
Raw Normal View History

2009-08-20 12:38:17 +03:00
/*
* linux/arch/mips/jz4740/common/pm.c
*
* JZ4740 Power Management Routines
*
* Copyright (C) 2006 Ingenic Semiconductor Inc.
* Author: <jlwei@ingenic.cn>
*
* This program is free software; you can distribute it and/or modify it
* under the terms of the GNU General Public License (Version 2) as
* published by the Free Software Foundation.
*
2009-08-20 12:38:17 +03:00
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*
2009-08-20 12:38:17 +03:00
*/
#include <linux/init.h>
#include <linux/pm.h>
#include <linux/delay.h>
2009-08-20 12:38:17 +03:00
#include <linux/suspend.h>
#include <asm/mach-jz4740/regs.h>
2009-08-20 12:38:17 +03:00
extern void jz4740_intc_suspend(void);
extern void jz4740_intc_resume(void);
2009-08-20 12:38:17 +03:00
static int jz_pm_enter(suspend_state_t state)
2009-08-20 12:38:17 +03:00
{
unsigned long nfcsr = REG_EMC_NFCSR;
uint32_t scr = REG_CPM_SCR;
2009-08-20 12:38:17 +03:00
2010-01-08 01:04:01 +02:00
/* Disable nand flash */
2009-08-20 12:38:17 +03:00
REG_EMC_NFCSR = ~0xff;
udelay(100);
2010-01-08 01:04:01 +02:00
/*stop udc and usb*/
2009-08-20 12:38:17 +03:00
REG_CPM_SCR &= ~( 1<<6 | 1<<7);
REG_CPM_SCR |= 0<<6 | 1<<7;
2010-01-08 01:04:01 +02:00
jz4740_intc_suspend();
2009-08-20 12:38:17 +03:00
/* Enter SLEEP mode */
REG_CPM_LCR &= ~CPM_LCR_LPM_MASK;
REG_CPM_LCR |= CPM_LCR_LPM_SLEEP;
__asm__(".set\tmips3\n\t"
"wait\n\t"
".set\tmips0");
/* Restore to IDLE mode */
REG_CPM_LCR &= ~CPM_LCR_LPM_MASK;
REG_CPM_LCR |= CPM_LCR_LPM_IDLE;
2010-01-08 01:04:01 +02:00
/* Restore nand flash control register */
2009-08-20 12:38:17 +03:00
REG_EMC_NFCSR = nfcsr;
2010-01-08 01:04:01 +02:00
jz4740_intc_resume();
2009-08-20 12:38:17 +03:00
/* Restore sleep control register */
REG_CPM_SCR = scr;
return 0;
}
static struct platform_suspend_ops jz_pm_ops = {
.valid = suspend_valid_only_mem,
2009-08-20 12:38:17 +03:00
.enter = jz_pm_enter,
};
/*
* Initialize power interface
*/
int __init jz_pm_init(void)
{
suspend_set_ops(&jz_pm_ops);
return 0;
}
late_initcall(jz_pm_init);