]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/cpuidle/cpuidle-exynos.c
Merge branch 'for-3.17/drivers' of git://git.kernel.dk/linux-block
[mirror_ubuntu-artful-kernel.git] / drivers / cpuidle / cpuidle-exynos.c
CommitLineData
7880e45e 1/* linux/arch/arm/mach-exynos/cpuidle.c
3d739985
JL
2 *
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
3d739985 11#include <linux/cpuidle.h>
67173ca4 12#include <linux/cpu_pm.h>
76ee4557 13#include <linux/export.h>
96c3a250 14#include <linux/module.h>
35baa336 15#include <linux/platform_device.h>
3d739985
JL
16
17#include <asm/proc-fns.h>
67173ca4 18#include <asm/suspend.h>
06c77b3c 19#include <asm/cpuidle.h>
67173ca4 20
277f5046 21static void (*exynos_enter_aftr)(void);
ccd458c1 22
7880e45e 23static int exynos_enter_lowpower(struct cpuidle_device *dev,
67173ca4
ADK
24 struct cpuidle_driver *drv,
25 int index)
26{
27 int new_index = index;
28
118f5c1d
BZ
29 /* AFTR can only be entered when cores other than CPU0 are offline */
30 if (num_online_cpus() > 1 || dev->cpu != 0)
67173ca4
ADK
31 new_index = drv->safe_state_index;
32
33 if (new_index == 0)
06c77b3c 34 return arm_cpuidle_simple_enter(dev, drv, new_index);
01601b34
TF
35
36 exynos_enter_aftr();
37
38 return new_index;
67173ca4
ADK
39}
40
7880e45e
DL
41static struct cpuidle_driver exynos_idle_driver = {
42 .name = "exynos_idle",
53af16a1
DL
43 .owner = THIS_MODULE,
44 .states = {
45 [0] = ARM_CPUIDLE_WFI_STATE,
46 [1] = {
7880e45e 47 .enter = exynos_enter_lowpower,
53af16a1
DL
48 .exit_latency = 300,
49 .target_residency = 100000,
50 .flags = CPUIDLE_FLAG_TIME_VALID,
51 .name = "C1",
52 .desc = "ARM power down",
53 },
54 },
55 .state_count = 2,
56 .safe_state_index = 0,
57};
58
f612a4fb 59static int exynos_cpuidle_probe(struct platform_device *pdev)
3d739985 60{
043c86b6 61 int ret;
46bcfad7 62
277f5046
DL
63 exynos_enter_aftr = (void *)(pdev->dev.platform_data);
64
7880e45e 65 ret = cpuidle_register(&exynos_idle_driver, NULL);
5db9f436 66 if (ret) {
ae7c4c87 67 dev_err(&pdev->dev, "failed to register cpuidle driver\n");
5db9f436 68 return ret;
46bcfad7 69 }
3d739985 70
3d739985
JL
71 return 0;
72}
35baa336
BZ
73
74static struct platform_driver exynos_cpuidle_driver = {
75 .probe = exynos_cpuidle_probe,
76 .driver = {
77 .name = "exynos_cpuidle",
78 .owner = THIS_MODULE,
79 },
80};
81
82module_platform_driver(exynos_cpuidle_driver);