Commit | Line | Data |
---|---|---|
be6a98d3 RH |
1 | /* |
2 | * Copyright 2012 Calxeda, Inc. | |
3 | * | |
a8e39c35 | 4 | * Based on arch/arm/plat-mxc/cpuidle.c: #v3.7 |
be6a98d3 RH |
5 | * Copyright 2012 Freescale Semiconductor, Inc. |
6 | * Copyright 2012 Linaro Ltd. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify it | |
9 | * under the terms and conditions of the GNU General Public License, | |
10 | * version 2, as published by the Free Software Foundation. | |
11 | * | |
12 | * This program is distributed in the hope it will be useful, but WITHOUT | |
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
15 | * more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License along with | |
18 | * this program. If not, see <http://www.gnu.org/licenses/>. | |
a8e39c35 DL |
19 | * |
20 | * Maintainer: Rob Herring <rob.herring@calxeda.com> | |
be6a98d3 RH |
21 | */ |
22 | ||
23 | #include <linux/cpuidle.h> | |
34a5eeb2 | 24 | #include <linux/cpu_pm.h> |
be6a98d3 | 25 | #include <linux/init.h> |
a410146c | 26 | #include <linux/mm.h> |
60a66e37 | 27 | #include <linux/platform_device.h> |
be120397 MR |
28 | #include <linux/psci.h> |
29 | ||
be6a98d3 | 30 | #include <asm/cpuidle.h> |
be6a98d3 | 31 | #include <asm/suspend.h> |
be120397 MR |
32 | |
33 | #include <uapi/linux/psci.h> | |
34 | ||
35 | #define CALXEDA_IDLE_PARAM \ | |
36 | ((0 << PSCI_0_2_POWER_STATE_ID_SHIFT) | \ | |
37 | (0 << PSCI_0_2_POWER_STATE_AFFL_SHIFT) | \ | |
38 | (PSCI_POWER_STATE_TYPE_POWER_DOWN << PSCI_0_2_POWER_STATE_TYPE_SHIFT)) | |
be6a98d3 RH |
39 | |
40 | static int calxeda_idle_finish(unsigned long val) | |
41 | { | |
be120397 | 42 | return psci_ops.cpu_suspend(CALXEDA_IDLE_PARAM, __pa(cpu_resume)); |
be6a98d3 RH |
43 | } |
44 | ||
45 | static int calxeda_pwrdown_idle(struct cpuidle_device *dev, | |
46 | struct cpuidle_driver *drv, | |
47 | int index) | |
48 | { | |
34a5eeb2 | 49 | cpu_pm_enter(); |
be6a98d3 | 50 | cpu_suspend(0, calxeda_idle_finish); |
34a5eeb2 RH |
51 | cpu_pm_exit(); |
52 | ||
be6a98d3 RH |
53 | return index; |
54 | } | |
55 | ||
be6a98d3 RH |
56 | static struct cpuidle_driver calxeda_idle_driver = { |
57 | .name = "calxeda_idle", | |
be6a98d3 RH |
58 | .states = { |
59 | ARM_CPUIDLE_WFI_STATE, | |
60 | { | |
61 | .name = "PG", | |
62 | .desc = "Power Gate", | |
be6a98d3 RH |
63 | .exit_latency = 30, |
64 | .power_usage = 50, | |
65 | .target_residency = 200, | |
66 | .enter = calxeda_pwrdown_idle, | |
67 | }, | |
68 | }, | |
69 | .state_count = 2, | |
70 | }; | |
71 | ||
5781532e | 72 | static int calxeda_cpuidle_probe(struct platform_device *pdev) |
be6a98d3 | 73 | { |
0b210d96 | 74 | return cpuidle_register(&calxeda_idle_driver, NULL); |
be6a98d3 | 75 | } |
60a66e37 DL |
76 | |
77 | static struct platform_driver calxeda_cpuidle_plat_driver = { | |
78 | .driver = { | |
79 | .name = "cpuidle-calxeda", | |
60a66e37 DL |
80 | }, |
81 | .probe = calxeda_cpuidle_probe, | |
82 | }; | |
090d1cf1 | 83 | builtin_platform_driver(calxeda_cpuidle_plat_driver); |