diff options
author | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | 2015-01-24 00:05:50 -0500 |
---|---|---|
committer | Kukjin Kim <kgene@kernel.org> | 2015-01-29 18:39:15 -0500 |
commit | 712eddf70225ab5ae65e946e22d2dfe6b93e8dd1 (patch) | |
tree | 62477a0a4b364cd2e87786481ee6dfe03e3fd569 /drivers/cpuidle/cpuidle-exynos.c | |
parent | 865e8b76a04d018f23d809ebf735c52105e3adb2 (diff) |
cpuidle: exynos: add coupled cpuidle support for exynos4210
The following patch adds coupled cpuidle support for Exynos4210 to
an existing cpuidle-exynos driver. As a result it enables AFTR mode
to be used by default on Exynos4210 without the need to hot unplug
CPU1 first.
The patch is heavily based on earlier cpuidle-exynos4210 driver from
Daniel Lezcano:
http://www.spinics.net/lists/linux-samsung-soc/msg28134.html
Changes from Daniel's code include:
- porting code to current kernels
- fixing it to work on my setup (by using S5P_INFORM register
instead of S5P_VA_SYSRAM one on Revison 1.1 and retrying poking
CPU1 out of the BOOT ROM if necessary)
- fixing rare lockup caused by waiting for CPU1 to get stuck in
the BOOT ROM (CPU hotplug code in arch/arm/mach-exynos/platsmp.c
doesn't require this and works fine)
- moving Exynos specific code to arch/arm/mach-exynos/pm.c
- using cpu_boot_reg_base() helper instead of BOOT_VECTOR macro
- using exynos_cpu_*() helpers instead of accessing registers
directly
- using arch_send_wakeup_ipi_mask() instead of dsb_sev()
(this matches CPU hotplug code in arch/arm/mach-exynos/platsmp.c)
- integrating separate exynos4210-cpuidle driver into existing
exynos-cpuidle one
Cc: Colin Cross <ccross@google.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Tomasz Figa <tomasz.figa@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Kukjin Kim <kgene@kernel.org>
Diffstat (limited to 'drivers/cpuidle/cpuidle-exynos.c')
-rw-r--r-- | drivers/cpuidle/cpuidle-exynos.c | 76 |
1 files changed, 71 insertions, 5 deletions
diff --git a/drivers/cpuidle/cpuidle-exynos.c b/drivers/cpuidle/cpuidle-exynos.c index 4003a3160865..26f5f29fdb03 100644 --- a/drivers/cpuidle/cpuidle-exynos.c +++ b/drivers/cpuidle/cpuidle-exynos.c | |||
@@ -1,8 +1,11 @@ | |||
1 | /* linux/arch/arm/mach-exynos/cpuidle.c | 1 | /* |
2 | * | 2 | * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd. |
3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. | ||
4 | * http://www.samsung.com | 3 | * http://www.samsung.com |
5 | * | 4 | * |
5 | * Coupled cpuidle support based on the work of: | ||
6 | * Colin Cross <ccross@android.com> | ||
7 | * Daniel Lezcano <daniel.lezcano@linaro.org> | ||
8 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | 9 | * 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 | 10 | * it under the terms of the GNU General Public License version 2 as |
8 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
@@ -13,13 +16,49 @@ | |||
13 | #include <linux/export.h> | 16 | #include <linux/export.h> |
14 | #include <linux/module.h> | 17 | #include <linux/module.h> |
15 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/of.h> | ||
20 | #include <linux/platform_data/cpuidle-exynos.h> | ||
16 | 21 | ||
17 | #include <asm/proc-fns.h> | 22 | #include <asm/proc-fns.h> |
18 | #include <asm/suspend.h> | 23 | #include <asm/suspend.h> |
19 | #include <asm/cpuidle.h> | 24 | #include <asm/cpuidle.h> |
20 | 25 | ||
26 | static atomic_t exynos_idle_barrier; | ||
27 | |||
28 | static struct cpuidle_exynos_data *exynos_cpuidle_pdata; | ||
21 | static void (*exynos_enter_aftr)(void); | 29 | static void (*exynos_enter_aftr)(void); |
22 | 30 | ||
31 | static int exynos_enter_coupled_lowpower(struct cpuidle_device *dev, | ||
32 | struct cpuidle_driver *drv, | ||
33 | int index) | ||
34 | { | ||
35 | int ret; | ||
36 | |||
37 | exynos_cpuidle_pdata->pre_enter_aftr(); | ||
38 | |||
39 | /* | ||
40 | * Waiting all cpus to reach this point at the same moment | ||
41 | */ | ||
42 | cpuidle_coupled_parallel_barrier(dev, &exynos_idle_barrier); | ||
43 | |||
44 | /* | ||
45 | * Both cpus will reach this point at the same time | ||
46 | */ | ||
47 | ret = dev->cpu ? exynos_cpuidle_pdata->cpu1_powerdown() | ||
48 | : exynos_cpuidle_pdata->cpu0_enter_aftr(); | ||
49 | if (ret) | ||
50 | index = ret; | ||
51 | |||
52 | /* | ||
53 | * Waiting all cpus to finish the power sequence before going further | ||
54 | */ | ||
55 | cpuidle_coupled_parallel_barrier(dev, &exynos_idle_barrier); | ||
56 | |||
57 | exynos_cpuidle_pdata->post_enter_aftr(); | ||
58 | |||
59 | return index; | ||
60 | } | ||
61 | |||
23 | static int exynos_enter_lowpower(struct cpuidle_device *dev, | 62 | static int exynos_enter_lowpower(struct cpuidle_device *dev, |
24 | struct cpuidle_driver *drv, | 63 | struct cpuidle_driver *drv, |
25 | int index) | 64 | int index) |
@@ -55,13 +94,40 @@ static struct cpuidle_driver exynos_idle_driver = { | |||
55 | .safe_state_index = 0, | 94 | .safe_state_index = 0, |
56 | }; | 95 | }; |
57 | 96 | ||
97 | static struct cpuidle_driver exynos_coupled_idle_driver = { | ||
98 | .name = "exynos_coupled_idle", | ||
99 | .owner = THIS_MODULE, | ||
100 | .states = { | ||
101 | [0] = ARM_CPUIDLE_WFI_STATE, | ||
102 | [1] = { | ||
103 | .enter = exynos_enter_coupled_lowpower, | ||
104 | .exit_latency = 5000, | ||
105 | .target_residency = 10000, | ||
106 | .flags = CPUIDLE_FLAG_COUPLED | | ||
107 | CPUIDLE_FLAG_TIMER_STOP, | ||
108 | .name = "C1", | ||
109 | .desc = "ARM power down", | ||
110 | }, | ||
111 | }, | ||
112 | .state_count = 2, | ||
113 | .safe_state_index = 0, | ||
114 | }; | ||
115 | |||
58 | static int exynos_cpuidle_probe(struct platform_device *pdev) | 116 | static int exynos_cpuidle_probe(struct platform_device *pdev) |
59 | { | 117 | { |
60 | int ret; | 118 | int ret; |
61 | 119 | ||
62 | exynos_enter_aftr = (void *)(pdev->dev.platform_data); | 120 | if (of_machine_is_compatible("samsung,exynos4210")) { |
121 | exynos_cpuidle_pdata = pdev->dev.platform_data; | ||
122 | |||
123 | ret = cpuidle_register(&exynos_coupled_idle_driver, | ||
124 | cpu_possible_mask); | ||
125 | } else { | ||
126 | exynos_enter_aftr = (void *)(pdev->dev.platform_data); | ||
127 | |||
128 | ret = cpuidle_register(&exynos_idle_driver, NULL); | ||
129 | } | ||
63 | 130 | ||
64 | ret = cpuidle_register(&exynos_idle_driver, NULL); | ||
65 | if (ret) { | 131 | if (ret) { |
66 | dev_err(&pdev->dev, "failed to register cpuidle driver\n"); | 132 | dev_err(&pdev->dev, "failed to register cpuidle driver\n"); |
67 | return ret; | 133 | return ret; |