aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/Kconfig.arm11
-rw-r--r--drivers/cpuidle/Makefile2
-rw-r--r--drivers/cpuidle/cpuidle-armada-370-xp.c93
-rw-r--r--drivers/cpuidle/cpuidle-exynos.c99
4 files changed, 205 insertions, 0 deletions
diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm
index 97ccc31dbdd8..ae1d78ea7df7 100644
--- a/drivers/cpuidle/Kconfig.arm
+++ b/drivers/cpuidle/Kconfig.arm
@@ -1,6 +1,11 @@
1# 1#
2# ARM CPU Idle drivers 2# ARM CPU Idle drivers
3# 3#
4config ARM_ARMADA_370_XP_CPUIDLE
5 bool "CPU Idle Driver for Armada 370/XP family processors"
6 depends on ARCH_MVEBU
7 help
8 Select this to enable cpuidle on Armada 370/XP processors.
4 9
5config ARM_BIG_LITTLE_CPUIDLE 10config ARM_BIG_LITTLE_CPUIDLE
6 bool "Support for ARM big.LITTLE processors" 11 bool "Support for ARM big.LITTLE processors"
@@ -44,3 +49,9 @@ config ARM_AT91_CPUIDLE
44 depends on ARCH_AT91 49 depends on ARCH_AT91
45 help 50 help
46 Select this to enable cpuidle for AT91 processors 51 Select this to enable cpuidle for AT91 processors
52
53config ARM_EXYNOS_CPUIDLE
54 bool "Cpu Idle Driver for the Exynos processors"
55 depends on ARCH_EXYNOS
56 help
57 Select this to enable cpuidle for Exynos processors
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index f71ae1b373c5..cd3ab59f8461 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -7,12 +7,14 @@ obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
7 7
8################################################################################## 8##################################################################################
9# ARM SoC drivers 9# ARM SoC drivers
10obj-$(CONFIG_ARM_ARMADA_370_XP_CPUIDLE) += cpuidle-armada-370-xp.o
10obj-$(CONFIG_ARM_BIG_LITTLE_CPUIDLE) += cpuidle-big_little.o 11obj-$(CONFIG_ARM_BIG_LITTLE_CPUIDLE) += cpuidle-big_little.o
11obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE) += cpuidle-calxeda.o 12obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE) += cpuidle-calxeda.o
12obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE) += cpuidle-kirkwood.o 13obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE) += cpuidle-kirkwood.o
13obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o 14obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o
14obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o 15obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o
15obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o 16obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o
17obj-$(CONFIG_ARM_EXYNOS_CPUIDLE) += cpuidle-exynos.o
16 18
17############################################################################### 19###############################################################################
18# POWERPC drivers 20# POWERPC drivers
diff --git a/drivers/cpuidle/cpuidle-armada-370-xp.c b/drivers/cpuidle/cpuidle-armada-370-xp.c
new file mode 100644
index 000000000000..28587d0f3947
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-armada-370-xp.c
@@ -0,0 +1,93 @@
1/*
2 * Marvell Armada 370 and Armada XP SoC cpuidle driver
3 *
4 * Copyright (C) 2014 Marvell
5 *
6 * Nadav Haklai <nadavh@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 *
13 * Maintainer: Gregory CLEMENT <gregory.clement@free-electrons.com>
14 */
15
16#include <linux/cpu_pm.h>
17#include <linux/cpuidle.h>
18#include <linux/module.h>
19#include <linux/of.h>
20#include <linux/suspend.h>
21#include <linux/platform_device.h>
22#include <asm/cpuidle.h>
23
24#define ARMADA_370_XP_MAX_STATES 3
25#define ARMADA_370_XP_FLAG_DEEP_IDLE 0x10000
26
27static int (*armada_370_xp_cpu_suspend)(int);
28
29static int armada_370_xp_enter_idle(struct cpuidle_device *dev,
30 struct cpuidle_driver *drv,
31 int index)
32{
33 int ret;
34 bool deepidle = false;
35 cpu_pm_enter();
36
37 if (drv->states[index].flags & ARMADA_370_XP_FLAG_DEEP_IDLE)
38 deepidle = true;
39
40 ret = armada_370_xp_cpu_suspend(deepidle);
41 if (ret)
42 return ret;
43
44 cpu_pm_exit();
45
46 return index;
47}
48
49static struct cpuidle_driver armada_370_xp_idle_driver = {
50 .name = "armada_370_xp_idle",
51 .states[0] = ARM_CPUIDLE_WFI_STATE,
52 .states[1] = {
53 .enter = armada_370_xp_enter_idle,
54 .exit_latency = 10,
55 .power_usage = 50,
56 .target_residency = 100,
57 .flags = CPUIDLE_FLAG_TIME_VALID,
58 .name = "MV CPU IDLE",
59 .desc = "CPU power down",
60 },
61 .states[2] = {
62 .enter = armada_370_xp_enter_idle,
63 .exit_latency = 100,
64 .power_usage = 5,
65 .target_residency = 1000,
66 .flags = CPUIDLE_FLAG_TIME_VALID |
67 ARMADA_370_XP_FLAG_DEEP_IDLE,
68 .name = "MV CPU DEEP IDLE",
69 .desc = "CPU and L2 Fabric power down",
70 },
71 .state_count = ARMADA_370_XP_MAX_STATES,
72};
73
74static int armada_370_xp_cpuidle_probe(struct platform_device *pdev)
75{
76
77 armada_370_xp_cpu_suspend = (void *)(pdev->dev.platform_data);
78 return cpuidle_register(&armada_370_xp_idle_driver, NULL);
79}
80
81static struct platform_driver armada_370_xp_cpuidle_plat_driver = {
82 .driver = {
83 .name = "cpuidle-armada-370-xp",
84 .owner = THIS_MODULE,
85 },
86 .probe = armada_370_xp_cpuidle_probe,
87};
88
89module_platform_driver(armada_370_xp_cpuidle_plat_driver);
90
91MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
92MODULE_DESCRIPTION("Armada 370/XP cpu idle driver");
93MODULE_LICENSE("GPL");
diff --git a/drivers/cpuidle/cpuidle-exynos.c b/drivers/cpuidle/cpuidle-exynos.c
new file mode 100644
index 000000000000..7c0151263828
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-exynos.c
@@ -0,0 +1,99 @@
1/* linux/arch/arm/mach-exynos/cpuidle.c
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
11#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>
16
17#include <asm/proc-fns.h>
18#include <asm/suspend.h>
19#include <asm/cpuidle.h>
20
21static void (*exynos_enter_aftr)(void);
22
23static int idle_finisher(unsigned long flags)
24{
25 exynos_enter_aftr();
26 cpu_do_idle();
27
28 return 1;
29}
30
31static int exynos_enter_core0_aftr(struct cpuidle_device *dev,
32 struct cpuidle_driver *drv,
33 int index)
34{
35 cpu_pm_enter();
36 cpu_suspend(0, idle_finisher);
37 cpu_pm_exit();
38
39 return index;
40}
41
42static int exynos_enter_lowpower(struct cpuidle_device *dev,
43 struct cpuidle_driver *drv,
44 int index)
45{
46 int new_index = index;
47
48 /* AFTR can only be entered when cores other than CPU0 are offline */
49 if (num_online_cpus() > 1 || dev->cpu != 0)
50 new_index = drv->safe_state_index;
51
52 if (new_index == 0)
53 return arm_cpuidle_simple_enter(dev, drv, new_index);
54 else
55 return exynos_enter_core0_aftr(dev, drv, new_index);
56}
57
58static struct cpuidle_driver exynos_idle_driver = {
59 .name = "exynos_idle",
60 .owner = THIS_MODULE,
61 .states = {
62 [0] = ARM_CPUIDLE_WFI_STATE,
63 [1] = {
64 .enter = exynos_enter_lowpower,
65 .exit_latency = 300,
66 .target_residency = 100000,
67 .flags = CPUIDLE_FLAG_TIME_VALID,
68 .name = "C1",
69 .desc = "ARM power down",
70 },
71 },
72 .state_count = 2,
73 .safe_state_index = 0,
74};
75
76static int exynos_cpuidle_probe(struct platform_device *pdev)
77{
78 int ret;
79
80 exynos_enter_aftr = (void *)(pdev->dev.platform_data);
81
82 ret = cpuidle_register(&exynos_idle_driver, NULL);
83 if (ret) {
84 dev_err(&pdev->dev, "failed to register cpuidle driver\n");
85 return ret;
86 }
87
88 return 0;
89}
90
91static struct platform_driver exynos_cpuidle_driver = {
92 .probe = exynos_cpuidle_probe,
93 .driver = {
94 .name = "exynos_cpuidle",
95 .owner = THIS_MODULE,
96 },
97};
98
99module_platform_driver(exynos_cpuidle_driver);