2 * Marvell Armada 370, 38x and XP SoC cpuidle driver
4 * Copyright (C) 2014 Marvell
6 * Nadav Haklai <nadavh@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
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.
13 * Maintainer: Gregory CLEMENT <gregory.clement@free-electrons.com>
16 #include <linux/cpu_pm.h>
17 #include <linux/cpuidle.h>
18 #include <linux/module.h>
20 #include <linux/suspend.h>
21 #include <linux/platform_device.h>
22 #include <asm/cpuidle.h>
24 #define MVEBU_V7_FLAG_DEEP_IDLE 0x10000
26 static int (*mvebu_v7_cpu_suspend
)(int);
28 static int mvebu_v7_enter_idle(struct cpuidle_device
*dev
,
29 struct cpuidle_driver
*drv
,
33 bool deepidle
= false;
36 if (drv
->states
[index
].flags
& MVEBU_V7_FLAG_DEEP_IDLE
)
39 ret
= mvebu_v7_cpu_suspend(deepidle
);
48 static struct cpuidle_driver armadaxp_idle_driver
= {
49 .name
= "armada_xp_idle",
50 .states
[0] = ARM_CPUIDLE_WFI_STATE
,
52 .enter
= mvebu_v7_enter_idle
,
55 .target_residency
= 1000,
56 .name
= "MV CPU IDLE",
57 .desc
= "CPU power down",
60 .enter
= mvebu_v7_enter_idle
,
63 .target_residency
= 10000,
64 .flags
= MVEBU_V7_FLAG_DEEP_IDLE
,
65 .name
= "MV CPU DEEP IDLE",
66 .desc
= "CPU and L2 Fabric power down",
71 static struct cpuidle_driver armada370_idle_driver
= {
72 .name
= "armada_370_idle",
73 .states
[0] = ARM_CPUIDLE_WFI_STATE
,
75 .enter
= mvebu_v7_enter_idle
,
78 .target_residency
= 1000,
79 .flags
= MVEBU_V7_FLAG_DEEP_IDLE
,
81 .desc
= "CPU and L2 Fabric power down",
86 static struct cpuidle_driver armada38x_idle_driver
= {
87 .name
= "armada_38x_idle",
88 .states
[0] = ARM_CPUIDLE_WFI_STATE
,
90 .enter
= mvebu_v7_enter_idle
,
93 .target_residency
= 100,
95 .desc
= "CPU and SCU power down",
100 static int mvebu_v7_cpuidle_probe(struct platform_device
*pdev
)
102 mvebu_v7_cpu_suspend
= pdev
->dev
.platform_data
;
104 if (!strcmp(pdev
->dev
.driver
->name
, "cpuidle-armada-xp"))
105 return cpuidle_register(&armadaxp_idle_driver
, NULL
);
106 else if (!strcmp(pdev
->dev
.driver
->name
, "cpuidle-armada-370"))
107 return cpuidle_register(&armada370_idle_driver
, NULL
);
108 else if (!strcmp(pdev
->dev
.driver
->name
, "cpuidle-armada-38x"))
109 return cpuidle_register(&armada38x_idle_driver
, NULL
);
114 static struct platform_driver armadaxp_cpuidle_plat_driver
= {
116 .name
= "cpuidle-armada-xp",
118 .probe
= mvebu_v7_cpuidle_probe
,
121 module_platform_driver(armadaxp_cpuidle_plat_driver
);
123 static struct platform_driver armada370_cpuidle_plat_driver
= {
125 .name
= "cpuidle-armada-370",
127 .probe
= mvebu_v7_cpuidle_probe
,
130 module_platform_driver(armada370_cpuidle_plat_driver
);
132 static struct platform_driver armada38x_cpuidle_plat_driver
= {
134 .name
= "cpuidle-armada-38x",
136 .probe
= mvebu_v7_cpuidle_probe
,
139 module_platform_driver(armada38x_cpuidle_plat_driver
);
141 MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
142 MODULE_DESCRIPTION("Marvell EBU v7 cpuidle driver");
143 MODULE_LICENSE("GPL");