pm.c 2.6 KB
Newer Older
1
/* linux/arch/arm/mach-s3c2412/pm.c
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * Copyright (c) 2006 Simtec Electronics
 *	Ben Dooks <ben@simtec.co.uk>
 *
 * http://armlinux.simtec.co.uk/.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/init.h>
#include <linux/sysdev.h>
20
#include <linux/syscore_ops.h>
21
#include <linux/platform_device.h>
22
#include <linux/io.h>
23

24
#include <mach/hardware.h>
25
#include <asm/cacheflush.h>
26 27
#include <asm/irq.h>

28 29 30 31
#include <mach/regs-power.h>
#include <mach/regs-gpioj.h>
#include <mach/regs-gpio.h>
#include <mach/regs-dsc.h>
32

33 34
#include <plat/cpu.h>
#include <plat/pm.h>
35

36
#include <plat/s3c2412.h>
37

38 39
extern void s3c2412_sleep_enter(void);

40
static void s3c2412_cpu_suspend(unsigned long arg)
41 42 43 44 45 46 47 48 49
{
	unsigned long tmp;

	/* set our standby method to sleep */

	tmp = __raw_readl(S3C2412_PWRCFG);
	tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
	__raw_writel(tmp, S3C2412_PWRCFG);

50
	s3c2412_sleep_enter();
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
}

static void s3c2412_pm_prepare(void)
{
}

static int s3c2412_pm_add(struct sys_device *sysdev)
{
	pm_cpu_prep = s3c2412_pm_prepare;
	pm_cpu_sleep = s3c2412_cpu_suspend;

	return 0;
}

static struct sleep_save s3c2412_sleep[] = {
	SAVE_ITEM(S3C2412_DSC0),
	SAVE_ITEM(S3C2412_DSC1),
	SAVE_ITEM(S3C2413_GPJDAT),
	SAVE_ITEM(S3C2413_GPJCON),
	SAVE_ITEM(S3C2413_GPJUP),

	/* save the PWRCFG to get back to original sleep method */

	SAVE_ITEM(S3C2412_PWRCFG),

	/* save the sleep configuration anyway, just in case these
	 * get damaged during wakeup */

	SAVE_ITEM(S3C2412_GPBSLPCON),
	SAVE_ITEM(S3C2412_GPCSLPCON),
	SAVE_ITEM(S3C2412_GPDSLPCON),
	SAVE_ITEM(S3C2412_GPFSLPCON),
	SAVE_ITEM(S3C2412_GPGSLPCON),
	SAVE_ITEM(S3C2412_GPHSLPCON),
	SAVE_ITEM(S3C2413_GPJSLPCON),
};

88 89 90 91 92 93 94 95 96 97 98 99
static struct sysdev_driver s3c2412_pm_driver = {
	.add		= s3c2412_pm_add,
};

static __init int s3c2412_pm_init(void)
{
	return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver);
}

arch_initcall(s3c2412_pm_init);

static int s3c2412_pm_suspend(void)
100
{
101
	s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
102 103 104
	return 0;
}

105
static void s3c2412_pm_resume(void)
106 107 108 109 110 111 112 113
{
	unsigned long tmp;

	tmp = __raw_readl(S3C2412_PWRCFG);
	tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
	tmp |=  S3C2412_PWRCFG_STANDBYWFI_IDLE;
	__raw_writel(tmp, S3C2412_PWRCFG);

114
	s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
115 116
}

117
struct syscore_ops s3c2412_pm_syscore_ops = {
118 119 120
	.suspend	= s3c2412_pm_suspend,
	.resume		= s3c2412_pm_resume,
};