2005-04-17 06:20:36 +08:00
|
|
|
/* linux/arch/arm/mach-s3c2410/pm.c
|
|
|
|
*
|
2007-02-12 01:31:01 +08:00
|
|
|
* Copyright (c) 2006 Simtec Electronics
|
2005-04-17 06:20:36 +08:00
|
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
|
|
*
|
2007-02-12 01:31:01 +08:00
|
|
|
* S3C2410 (and compatible) Power Manager (Suspend-To-RAM) support
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/suspend.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/time.h>
|
2007-02-12 01:31:01 +08:00
|
|
|
#include <linux/sysdev.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-08-04 17:41:28 +08:00
|
|
|
#include <asm/arch/hardware.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/io.h>
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
#include <asm/mach-types.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
#include <asm/arch/regs-gpio.h>
|
|
|
|
#include <asm/arch/h1940.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
#include <asm/plat-s3c24xx/cpu.h>
|
|
|
|
#include <asm/plat-s3c24xx/pm.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_S3C2410_PM_DEBUG
|
2007-02-12 01:31:01 +08:00
|
|
|
extern void pm_dbg(const char *fmt, ...);
|
2005-04-17 06:20:36 +08:00
|
|
|
#define DBG(fmt...) pm_dbg(fmt)
|
|
|
|
#else
|
|
|
|
#define DBG(fmt...) printk(KERN_DEBUG fmt)
|
|
|
|
#endif
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
static void s3c2410_pm_prepare(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-12 01:31:01 +08:00
|
|
|
/* ensure at least GSTATUS3 has the resume address */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
__raw_writel(virt_to_phys(s3c2410_cpu_resume), S3C2410_GSTATUS3);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
DBG("GSTATUS3 0x%08x\n", __raw_readl(S3C2410_GSTATUS3));
|
|
|
|
DBG("GSTATUS4 0x%08x\n", __raw_readl(S3C2410_GSTATUS4));
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
if (machine_is_h1940()) {
|
|
|
|
void *base = phys_to_virt(H1940_SUSPEND_CHECK);
|
|
|
|
unsigned long ptr;
|
|
|
|
unsigned long calc = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
/* generate check for the bootloader to check on resume */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
for (ptr = 0; ptr < 0x40000; ptr += 0x400)
|
|
|
|
calc += __raw_readl(base+ptr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
__raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
/* the RX3715 uses similar code and the same H1940 and the
|
|
|
|
* same offsets for resume and checksum pointers */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
if (machine_is_rx3715()) {
|
|
|
|
void *base = phys_to_virt(H1940_SUSPEND_CHECK);
|
|
|
|
unsigned long ptr;
|
|
|
|
unsigned long calc = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
/* generate check for the bootloader to check on resume */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
for (ptr = 0; ptr < 0x40000; ptr += 0x4)
|
|
|
|
calc += __raw_readl(base+ptr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
__raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
if ( machine_is_aml_m5900() )
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPF2, 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
static int s3c2410_pm_resume(struct sys_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-12 01:31:01 +08:00
|
|
|
unsigned long tmp;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
/* unset the return-from-sleep flag, to ensure reset */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
tmp = __raw_readl(S3C2410_GSTATUS2);
|
|
|
|
tmp &= S3C2410_GSTATUS2_OFFRESET;
|
|
|
|
__raw_writel(tmp, S3C2410_GSTATUS2);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
if ( machine_is_aml_m5900() )
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPF2, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
static int s3c2410_pm_add(struct sys_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-12 01:31:01 +08:00
|
|
|
pm_cpu_prep = s3c2410_pm_prepare;
|
|
|
|
pm_cpu_sleep = s3c2410_cpu_suspend;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
#if defined(CONFIG_CPU_S3C2410)
|
|
|
|
static struct sysdev_driver s3c2410_pm_driver = {
|
|
|
|
.add = s3c2410_pm_add,
|
|
|
|
.resume = s3c2410_pm_resume,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
/* register ourselves */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
static int __init s3c2410_pm_drvinit(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-12 01:31:01 +08:00
|
|
|
return sysdev_driver_register(&s3c2410_sysclass, &s3c2410_pm_driver);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
arch_initcall(s3c2410_pm_drvinit);
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
#if defined(CONFIG_CPU_S3C2440)
|
|
|
|
static struct sysdev_driver s3c2440_pm_driver = {
|
|
|
|
.add = s3c2410_pm_add,
|
|
|
|
.resume = s3c2410_pm_resume,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
static int __init s3c2440_pm_drvinit(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-12 01:31:01 +08:00
|
|
|
return sysdev_driver_register(&s3c2440_sysclass, &s3c2440_pm_driver);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
arch_initcall(s3c2440_pm_drvinit);
|
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
#if defined(CONFIG_CPU_S3C2442)
|
|
|
|
static struct sysdev_driver s3c2442_pm_driver = {
|
|
|
|
.add = s3c2410_pm_add,
|
|
|
|
.resume = s3c2410_pm_resume,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2007-02-12 01:31:01 +08:00
|
|
|
static int __init s3c2442_pm_drvinit(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-02-12 01:31:01 +08:00
|
|
|
return sysdev_driver_register(&s3c2442_sysclass, &s3c2442_pm_driver);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-02-12 01:31:01 +08:00
|
|
|
|
|
|
|
arch_initcall(s3c2442_pm_drvinit);
|
|
|
|
#endif
|