pm_runtime.c 1.4 KB
Newer Older
M
Magnus Damm 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * arch/arm/mach-shmobile/pm_runtime.c
 *
 * Runtime PM support code for SuperH Mobile ARM
 *
 *  Copyright (C) 2009-2010 Magnus Damm
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 */

#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/io.h>
#include <linux/pm_runtime.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/sh_clk.h>
#include <linux/bitmap.h>
21
#include <linux/slab.h>
M
Magnus Damm 已提交
22 23 24

#ifdef CONFIG_PM_RUNTIME

25
static int default_platform_runtime_idle(struct device *dev)
M
Magnus Damm 已提交
26 27 28 29 30
{
	/* suspend synchronously to disable clocks immediately */
	return pm_runtime_suspend(dev);
}

31 32
static struct dev_power_domain default_power_domain = {
	.ops = {
33 34
		.runtime_suspend = pm_runtime_clk_suspend,
		.runtime_resume = pm_runtime_clk_resume,
35 36 37 38 39
		.runtime_idle = default_platform_runtime_idle,
		USE_PLATFORM_PM_SLEEP_OPS
	},
};

40
#define DEFAULT_PWR_DOMAIN_PTR	(&default_power_domain)
41

42
#else
M
Magnus Damm 已提交
43

44
#define DEFAULT_PWR_DOMAIN_PTR	NULL
M
Magnus Damm 已提交
45 46 47

#endif /* CONFIG_PM_RUNTIME */

48 49 50
static struct pm_clk_notifier_block platform_bus_notifier = {
	.pwr_domain = DEFAULT_PWR_DOMAIN_PTR,
	.con_ids = { NULL, },
M
Magnus Damm 已提交
51 52 53 54
};

static int __init sh_pm_runtime_init(void)
{
55
	pm_runtime_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
M
Magnus Damm 已提交
56 57 58
	return 0;
}
core_initcall(sh_pm_runtime_init);