cpuidle-exynos.c 1.8 KB
Newer Older
1
/* linux/arch/arm/mach-exynos/cpuidle.c
J
Jaecheol Lee 已提交
2 3 4 5 6 7 8 9 10 11
 *
 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
 *
 * 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/cpuidle.h>
12
#include <linux/cpu_pm.h>
13
#include <linux/export.h>
14
#include <linux/module.h>
15
#include <linux/platform_device.h>
J
Jaecheol Lee 已提交
16 17

#include <asm/proc-fns.h>
18
#include <asm/suspend.h>
19
#include <asm/cpuidle.h>
20

21
static void (*exynos_enter_aftr)(void);
22

23
static int exynos_enter_lowpower(struct cpuidle_device *dev,
24 25 26 27 28
				struct cpuidle_driver *drv,
				int index)
{
	int new_index = index;

29 30
	/* AFTR can only be entered when cores other than CPU0 are offline */
	if (num_online_cpus() > 1 || dev->cpu != 0)
31 32 33
		new_index = drv->safe_state_index;

	if (new_index == 0)
34
		return arm_cpuidle_simple_enter(dev, drv, new_index);
35 36 37 38

	exynos_enter_aftr();

	return new_index;
39 40
}

41 42
static struct cpuidle_driver exynos_idle_driver = {
	.name			= "exynos_idle",
43 44 45 46
	.owner			= THIS_MODULE,
	.states = {
		[0] = ARM_CPUIDLE_WFI_STATE,
		[1] = {
47
			.enter			= exynos_enter_lowpower,
48 49 50 51 52 53 54 55 56 57
			.exit_latency		= 300,
			.target_residency	= 100000,
			.name			= "C1",
			.desc			= "ARM power down",
		},
	},
	.state_count = 2,
	.safe_state_index = 0,
};

58
static int exynos_cpuidle_probe(struct platform_device *pdev)
J
Jaecheol Lee 已提交
59
{
60
	int ret;
61

62 63
	exynos_enter_aftr = (void *)(pdev->dev.platform_data);

64
	ret = cpuidle_register(&exynos_idle_driver, NULL);
65
	if (ret) {
66
		dev_err(&pdev->dev, "failed to register cpuidle driver\n");
67
		return ret;
68
	}
J
Jaecheol Lee 已提交
69 70 71

	return 0;
}
72 73 74 75 76 77 78 79 80 81

static struct platform_driver exynos_cpuidle_driver = {
	.probe	= exynos_cpuidle_probe,
	.driver = {
		.name = "exynos_cpuidle",
		.owner = THIS_MODULE,
	},
};

module_platform_driver(exynos_cpuidle_driver);