2005-04-17 00:20:36 +02:00
|
|
|
|
/* linux/arch/arm/mach-s3c2410/pm.c
|
|
|
|
|
*
|
2007-02-11 18:31:01 +01:00
|
|
|
|
* Copyright (c) 2006 Simtec Electronics
|
2005-04-17 00:20:36 +02:00
|
|
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
|
|
|
*
|
2007-02-11 18:31:01 +01:00
|
|
|
|
* S3C2410 (and compatible) Power Manager (Suspend-To-RAM) support
|
2005-04-17 00:20:36 +02: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>
|
2011-12-22 01:01:38 +01:00
|
|
|
|
#include <linux/device.h>
|
2011-04-22 22:03:21 +02:00
|
|
|
|
#include <linux/syscore_ops.h>
|
2009-05-13 23:52:24 +02:00
|
|
|
|
#include <linux/gpio.h>
|
2008-09-06 13:10:45 +02:00
|
|
|
|
#include <linux/io.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
#include <asm/mach-types.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2013-01-02 19:18:58 +01:00
|
|
|
|
#include <mach/hardware.h>
|
2008-08-05 17:14:15 +02:00
|
|
|
|
#include <mach/regs-gpio.h>
|
2014-01-14 14:24:24 +01:00
|
|
|
|
#include <mach/gpio-samsung.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2014-01-14 15:05:22 +01:00
|
|
|
|
#include <plat/gpio-cfg.h>
|
2008-10-07 23:26:09 +02:00
|
|
|
|
#include <plat/cpu.h>
|
|
|
|
|
#include <plat/pm.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2013-01-02 19:18:58 +01:00
|
|
|
|
#include "h1940.h"
|
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
static void s3c2410_pm_prepare(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
{
|
2007-02-11 18:31:01 +01:00
|
|
|
|
/* ensure at least GSTATUS3 has the resume address */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2008-12-12 01:24:19 +01:00
|
|
|
|
__raw_writel(virt_to_phys(s3c_cpu_resume), S3C2410_GSTATUS3);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2008-12-12 01:24:06 +01:00
|
|
|
|
S3C_PMDBG("GSTATUS3 0x%08x\n", __raw_readl(S3C2410_GSTATUS3));
|
|
|
|
|
S3C_PMDBG("GSTATUS4 0x%08x\n", __raw_readl(S3C2410_GSTATUS4));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
if (machine_is_h1940()) {
|
|
|
|
|
void *base = phys_to_virt(H1940_SUSPEND_CHECK);
|
|
|
|
|
unsigned long ptr;
|
|
|
|
|
unsigned long calc = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
/* generate check for the bootloader to check on resume */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
for (ptr = 0; ptr < 0x40000; ptr += 0x400)
|
|
|
|
|
calc += __raw_readl(base+ptr);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
__raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-11 08:55:10 +02:00
|
|
|
|
/* RX3715 and RX1950 use similar to H1940 code and the
|
2007-02-11 18:31:01 +01:00
|
|
|
|
* same offsets for resume and checksum pointers */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2010-05-11 08:55:10 +02:00
|
|
|
|
if (machine_is_rx3715() || machine_is_rx1950()) {
|
2007-02-11 18:31:01 +01:00
|
|
|
|
void *base = phys_to_virt(H1940_SUSPEND_CHECK);
|
|
|
|
|
unsigned long ptr;
|
|
|
|
|
unsigned long calc = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
/* generate check for the bootloader to check on resume */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
for (ptr = 0; ptr < 0x40000; ptr += 0x4)
|
|
|
|
|
calc += __raw_readl(base+ptr);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
__raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-13 11:05:00 +02:00
|
|
|
|
if (machine_is_aml_m5900()) {
|
|
|
|
|
gpio_request_one(S3C2410_GPF(2), GPIOF_OUT_INIT_HIGH, NULL);
|
|
|
|
|
gpio_free(S3C2410_GPF(2));
|
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2010-05-11 08:55:11 +02:00
|
|
|
|
if (machine_is_rx1950()) {
|
|
|
|
|
/* According to S3C2442 user's manual, page 7-17,
|
|
|
|
|
* when the system is operating in NAND boot mode,
|
|
|
|
|
* the hardware pin configuration - EINT[23:21] –
|
|
|
|
|
* must be set as input for starting up after
|
|
|
|
|
* wakeup from sleep mode
|
|
|
|
|
*/
|
|
|
|
|
s3c_gpio_cfgpin(S3C2410_GPG(13), S3C2410_GPIO_INPUT);
|
|
|
|
|
s3c_gpio_cfgpin(S3C2410_GPG(14), S3C2410_GPIO_INPUT);
|
|
|
|
|
s3c_gpio_cfgpin(S3C2410_GPG(15), S3C2410_GPIO_INPUT);
|
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-22 22:03:21 +02:00
|
|
|
|
static void s3c2410_pm_resume(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
{
|
2007-02-11 18:31:01 +01:00
|
|
|
|
unsigned long tmp;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
/* unset the return-from-sleep flag, to ensure reset */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
tmp = __raw_readl(S3C2410_GSTATUS2);
|
|
|
|
|
tmp &= S3C2410_GSTATUS2_OFFRESET;
|
|
|
|
|
__raw_writel(tmp, S3C2410_GSTATUS2);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2012-07-13 11:05:00 +02:00
|
|
|
|
if (machine_is_aml_m5900()) {
|
|
|
|
|
gpio_request_one(S3C2410_GPF(2), GPIOF_OUT_INIT_LOW, NULL);
|
|
|
|
|
gpio_free(S3C2410_GPF(2));
|
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-22 22:03:21 +02:00
|
|
|
|
struct syscore_ops s3c2410_pm_syscore_ops = {
|
|
|
|
|
.resume = s3c2410_pm_resume,
|
|
|
|
|
};
|
|
|
|
|
|
2012-01-27 07:35:25 +01:00
|
|
|
|
static int s3c2410_pm_add(struct device *dev, struct subsys_interface *sif)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
{
|
2007-02-11 18:31:01 +01:00
|
|
|
|
pm_cpu_prep = s3c2410_pm_prepare;
|
|
|
|
|
pm_cpu_sleep = s3c2410_cpu_suspend;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
#if defined(CONFIG_CPU_S3C2410)
|
2011-12-22 01:01:38 +01:00
|
|
|
|
static struct subsys_interface s3c2410_pm_interface = {
|
|
|
|
|
.name = "s3c2410_pm",
|
|
|
|
|
.subsys = &s3c2410_subsys,
|
|
|
|
|
.add_dev = s3c2410_pm_add,
|
2007-02-11 18:31:01 +01:00
|
|
|
|
};
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
/* register ourselves */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
static int __init s3c2410_pm_drvinit(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
{
|
2011-12-22 01:01:38 +01:00
|
|
|
|
return subsys_interface_register(&s3c2410_pm_interface);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
arch_initcall(s3c2410_pm_drvinit);
|
2009-07-31 00:23:38 +02:00
|
|
|
|
|
2011-12-22 01:01:38 +01:00
|
|
|
|
static struct subsys_interface s3c2410a_pm_interface = {
|
|
|
|
|
.name = "s3c2410a_pm",
|
2012-01-06 08:08:09 +01:00
|
|
|
|
.subsys = &s3c2410a_subsys,
|
2011-12-22 01:01:38 +01:00
|
|
|
|
.add_dev = s3c2410_pm_add,
|
2009-07-31 00:23:38 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int __init s3c2410a_pm_drvinit(void)
|
|
|
|
|
{
|
2011-12-22 01:01:38 +01:00
|
|
|
|
return subsys_interface_register(&s3c2410a_pm_interface);
|
2009-07-31 00:23:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
arch_initcall(s3c2410a_pm_drvinit);
|
2007-02-11 18:31:01 +01:00
|
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
#if defined(CONFIG_CPU_S3C2440)
|
2011-12-22 01:01:38 +01:00
|
|
|
|
static struct subsys_interface s3c2440_pm_interface = {
|
|
|
|
|
.name = "s3c2440_pm",
|
|
|
|
|
.subsys = &s3c2440_subsys,
|
|
|
|
|
.add_dev = s3c2410_pm_add,
|
2007-02-11 18:31:01 +01:00
|
|
|
|
};
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
static int __init s3c2440_pm_drvinit(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
{
|
2011-12-22 01:01:38 +01:00
|
|
|
|
return subsys_interface_register(&s3c2440_pm_interface);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
arch_initcall(s3c2440_pm_drvinit);
|
|
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
#if defined(CONFIG_CPU_S3C2442)
|
2011-12-22 01:01:38 +01:00
|
|
|
|
static struct subsys_interface s3c2442_pm_interface = {
|
|
|
|
|
.name = "s3c2442_pm",
|
|
|
|
|
.subsys = &s3c2442_subsys,
|
|
|
|
|
.add_dev = s3c2410_pm_add,
|
2005-04-17 00:20:36 +02:00
|
|
|
|
};
|
|
|
|
|
|
2007-02-11 18:31:01 +01:00
|
|
|
|
static int __init s3c2442_pm_drvinit(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
{
|
2011-12-22 01:01:38 +01:00
|
|
|
|
return subsys_interface_register(&s3c2442_pm_interface);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
}
|
2007-02-11 18:31:01 +01:00
|
|
|
|
|
|
|
|
|
arch_initcall(s3c2442_pm_drvinit);
|
|
|
|
|
#endif
|