diff options
Diffstat (limited to 'drivers/cpufreq')
65 files changed, 405 insertions, 1443 deletions
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index 534fcb825153..38093e272377 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig | |||
| @@ -17,15 +17,11 @@ config CPU_FREQ | |||
| 17 | 17 | ||
| 18 | if CPU_FREQ | 18 | if CPU_FREQ |
| 19 | 19 | ||
| 20 | config CPU_FREQ_TABLE | ||
| 21 | tristate | ||
| 22 | |||
| 23 | config CPU_FREQ_GOV_COMMON | 20 | config CPU_FREQ_GOV_COMMON |
| 24 | bool | 21 | bool |
| 25 | 22 | ||
| 26 | config CPU_FREQ_STAT | 23 | config CPU_FREQ_STAT |
| 27 | tristate "CPU frequency translation statistics" | 24 | tristate "CPU frequency translation statistics" |
| 28 | select CPU_FREQ_TABLE | ||
| 29 | default y | 25 | default y |
| 30 | help | 26 | help |
| 31 | This driver exports CPU frequency statistics information through sysfs | 27 | This driver exports CPU frequency statistics information through sysfs |
| @@ -143,7 +139,6 @@ config CPU_FREQ_GOV_USERSPACE | |||
| 143 | 139 | ||
| 144 | config CPU_FREQ_GOV_ONDEMAND | 140 | config CPU_FREQ_GOV_ONDEMAND |
| 145 | tristate "'ondemand' cpufreq policy governor" | 141 | tristate "'ondemand' cpufreq policy governor" |
| 146 | select CPU_FREQ_TABLE | ||
| 147 | select CPU_FREQ_GOV_COMMON | 142 | select CPU_FREQ_GOV_COMMON |
| 148 | help | 143 | help |
| 149 | 'ondemand' - This driver adds a dynamic cpufreq policy governor. | 144 | 'ondemand' - This driver adds a dynamic cpufreq policy governor. |
| @@ -187,7 +182,6 @@ config CPU_FREQ_GOV_CONSERVATIVE | |||
| 187 | config GENERIC_CPUFREQ_CPU0 | 182 | config GENERIC_CPUFREQ_CPU0 |
| 188 | tristate "Generic CPU0 cpufreq driver" | 183 | tristate "Generic CPU0 cpufreq driver" |
| 189 | depends on HAVE_CLK && REGULATOR && PM_OPP && OF | 184 | depends on HAVE_CLK && REGULATOR && PM_OPP && OF |
| 190 | select CPU_FREQ_TABLE | ||
| 191 | help | 185 | help |
| 192 | This adds a generic cpufreq driver for CPU0 frequency management. | 186 | This adds a generic cpufreq driver for CPU0 frequency management. |
| 193 | It supports both uniprocessor (UP) and symmetric multiprocessor (SMP) | 187 | It supports both uniprocessor (UP) and symmetric multiprocessor (SMP) |
| @@ -223,7 +217,6 @@ depends on IA64 | |||
| 223 | 217 | ||
| 224 | config IA64_ACPI_CPUFREQ | 218 | config IA64_ACPI_CPUFREQ |
| 225 | tristate "ACPI Processor P-States driver" | 219 | tristate "ACPI Processor P-States driver" |
| 226 | select CPU_FREQ_TABLE | ||
| 227 | depends on ACPI_PROCESSOR | 220 | depends on ACPI_PROCESSOR |
| 228 | help | 221 | help |
| 229 | This driver adds a CPUFreq driver which utilizes the ACPI | 222 | This driver adds a CPUFreq driver which utilizes the ACPI |
| @@ -240,7 +233,6 @@ depends on MIPS | |||
| 240 | 233 | ||
| 241 | config LOONGSON2_CPUFREQ | 234 | config LOONGSON2_CPUFREQ |
| 242 | tristate "Loongson2 CPUFreq Driver" | 235 | tristate "Loongson2 CPUFreq Driver" |
| 243 | select CPU_FREQ_TABLE | ||
| 244 | help | 236 | help |
| 245 | This option adds a CPUFreq driver for loongson processors which | 237 | This option adds a CPUFreq driver for loongson processors which |
| 246 | support software configurable cpu frequency. | 238 | support software configurable cpu frequency. |
| @@ -262,7 +254,6 @@ menu "SPARC CPU frequency scaling drivers" | |||
| 262 | depends on SPARC64 | 254 | depends on SPARC64 |
| 263 | config SPARC_US3_CPUFREQ | 255 | config SPARC_US3_CPUFREQ |
| 264 | tristate "UltraSPARC-III CPU Frequency driver" | 256 | tristate "UltraSPARC-III CPU Frequency driver" |
| 265 | select CPU_FREQ_TABLE | ||
| 266 | help | 257 | help |
| 267 | This adds the CPUFreq driver for UltraSPARC-III processors. | 258 | This adds the CPUFreq driver for UltraSPARC-III processors. |
| 268 | 259 | ||
| @@ -272,7 +263,6 @@ config SPARC_US3_CPUFREQ | |||
| 272 | 263 | ||
| 273 | config SPARC_US2E_CPUFREQ | 264 | config SPARC_US2E_CPUFREQ |
| 274 | tristate "UltraSPARC-IIe CPU Frequency driver" | 265 | tristate "UltraSPARC-IIe CPU Frequency driver" |
| 275 | select CPU_FREQ_TABLE | ||
| 276 | help | 266 | help |
| 277 | This adds the CPUFreq driver for UltraSPARC-IIe processors. | 267 | This adds the CPUFreq driver for UltraSPARC-IIe processors. |
| 278 | 268 | ||
| @@ -285,7 +275,6 @@ menu "SH CPU Frequency scaling" | |||
| 285 | depends on SUPERH | 275 | depends on SUPERH |
| 286 | config SH_CPU_FREQ | 276 | config SH_CPU_FREQ |
| 287 | tristate "SuperH CPU Frequency driver" | 277 | tristate "SuperH CPU Frequency driver" |
| 288 | select CPU_FREQ_TABLE | ||
| 289 | help | 278 | help |
| 290 | This adds the cpufreq driver for SuperH. Any CPU that supports | 279 | This adds the cpufreq driver for SuperH. Any CPU that supports |
| 291 | clock rate rounding through the clock framework can use this | 280 | clock rate rounding through the clock framework can use this |
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index 0fa204b244bd..701ec95ce954 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | config ARM_BIG_LITTLE_CPUFREQ | 5 | config ARM_BIG_LITTLE_CPUFREQ |
| 6 | tristate "Generic ARM big LITTLE CPUfreq driver" | 6 | tristate "Generic ARM big LITTLE CPUfreq driver" |
| 7 | depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK | 7 | depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK |
| 8 | select CPU_FREQ_TABLE | ||
| 9 | help | 8 | help |
| 10 | This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. | 9 | This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. |
| 11 | 10 | ||
| @@ -18,7 +17,6 @@ config ARM_DT_BL_CPUFREQ | |||
| 18 | 17 | ||
| 19 | config ARM_EXYNOS_CPUFREQ | 18 | config ARM_EXYNOS_CPUFREQ |
| 20 | bool | 19 | bool |
| 21 | select CPU_FREQ_TABLE | ||
| 22 | 20 | ||
| 23 | config ARM_EXYNOS4210_CPUFREQ | 21 | config ARM_EXYNOS4210_CPUFREQ |
| 24 | bool "SAMSUNG EXYNOS4210" | 22 | bool "SAMSUNG EXYNOS4210" |
| @@ -58,7 +56,6 @@ config ARM_EXYNOS5440_CPUFREQ | |||
| 58 | depends on SOC_EXYNOS5440 | 56 | depends on SOC_EXYNOS5440 |
| 59 | depends on HAVE_CLK && PM_OPP && OF | 57 | depends on HAVE_CLK && PM_OPP && OF |
| 60 | default y | 58 | default y |
| 61 | select CPU_FREQ_TABLE | ||
| 62 | help | 59 | help |
| 63 | This adds the CPUFreq driver for Samsung EXYNOS5440 | 60 | This adds the CPUFreq driver for Samsung EXYNOS5440 |
| 64 | SoC. The nature of exynos5440 clock controller is | 61 | SoC. The nature of exynos5440 clock controller is |
| @@ -85,7 +82,6 @@ config ARM_IMX6Q_CPUFREQ | |||
| 85 | tristate "Freescale i.MX6Q cpufreq support" | 82 | tristate "Freescale i.MX6Q cpufreq support" |
| 86 | depends on SOC_IMX6Q | 83 | depends on SOC_IMX6Q |
| 87 | depends on REGULATOR_ANATOP | 84 | depends on REGULATOR_ANATOP |
| 88 | select CPU_FREQ_TABLE | ||
| 89 | help | 85 | help |
| 90 | This adds cpufreq driver support for Freescale i.MX6Q SOC. | 86 | This adds cpufreq driver support for Freescale i.MX6Q SOC. |
| 91 | 87 | ||
| @@ -101,7 +97,6 @@ config ARM_INTEGRATOR | |||
| 101 | 97 | ||
| 102 | config ARM_KIRKWOOD_CPUFREQ | 98 | config ARM_KIRKWOOD_CPUFREQ |
| 103 | def_bool ARCH_KIRKWOOD && OF | 99 | def_bool ARCH_KIRKWOOD && OF |
| 104 | select CPU_FREQ_TABLE | ||
| 105 | help | 100 | help |
| 106 | This adds the CPUFreq driver for Marvell Kirkwood | 101 | This adds the CPUFreq driver for Marvell Kirkwood |
| 107 | SoCs. | 102 | SoCs. |
| @@ -110,7 +105,6 @@ config ARM_OMAP2PLUS_CPUFREQ | |||
| 110 | bool "TI OMAP2+" | 105 | bool "TI OMAP2+" |
| 111 | depends on ARCH_OMAP2PLUS | 106 | depends on ARCH_OMAP2PLUS |
| 112 | default ARCH_OMAP2PLUS | 107 | default ARCH_OMAP2PLUS |
| 113 | select CPU_FREQ_TABLE | ||
| 114 | 108 | ||
| 115 | config ARM_S3C_CPUFREQ | 109 | config ARM_S3C_CPUFREQ |
| 116 | bool | 110 | bool |
| @@ -165,7 +159,6 @@ config ARM_S3C2412_CPUFREQ | |||
| 165 | config ARM_S3C2416_CPUFREQ | 159 | config ARM_S3C2416_CPUFREQ |
| 166 | bool "S3C2416 CPU Frequency scaling support" | 160 | bool "S3C2416 CPU Frequency scaling support" |
| 167 | depends on CPU_S3C2416 | 161 | depends on CPU_S3C2416 |
| 168 | select CPU_FREQ_TABLE | ||
| 169 | help | 162 | help |
| 170 | This adds the CPUFreq driver for the Samsung S3C2416 and | 163 | This adds the CPUFreq driver for the Samsung S3C2416 and |
| 171 | S3C2450 SoC. The S3C2416 supports changing the rate of the | 164 | S3C2450 SoC. The S3C2416 supports changing the rate of the |
| @@ -196,7 +189,6 @@ config ARM_S3C2440_CPUFREQ | |||
| 196 | config ARM_S3C64XX_CPUFREQ | 189 | config ARM_S3C64XX_CPUFREQ |
| 197 | bool "Samsung S3C64XX" | 190 | bool "Samsung S3C64XX" |
| 198 | depends on CPU_S3C6410 | 191 | depends on CPU_S3C6410 |
| 199 | select CPU_FREQ_TABLE | ||
| 200 | default y | 192 | default y |
| 201 | help | 193 | help |
| 202 | This adds the CPUFreq driver for Samsung S3C6410 SoC. | 194 | This adds the CPUFreq driver for Samsung S3C6410 SoC. |
| @@ -206,7 +198,6 @@ config ARM_S3C64XX_CPUFREQ | |||
| 206 | config ARM_S5PV210_CPUFREQ | 198 | config ARM_S5PV210_CPUFREQ |
| 207 | bool "Samsung S5PV210 and S5PC110" | 199 | bool "Samsung S5PV210 and S5PC110" |
| 208 | depends on CPU_S5PV210 | 200 | depends on CPU_S5PV210 |
| 209 | select CPU_FREQ_TABLE | ||
| 210 | default y | 201 | default y |
| 211 | help | 202 | help |
| 212 | This adds the CPUFreq driver for Samsung S5PV210 and | 203 | This adds the CPUFreq driver for Samsung S5PV210 and |
| @@ -223,7 +214,6 @@ config ARM_SA1110_CPUFREQ | |||
| 223 | config ARM_SPEAR_CPUFREQ | 214 | config ARM_SPEAR_CPUFREQ |
| 224 | bool "SPEAr CPUFreq support" | 215 | bool "SPEAr CPUFreq support" |
| 225 | depends on PLAT_SPEAR | 216 | depends on PLAT_SPEAR |
| 226 | select CPU_FREQ_TABLE | ||
| 227 | default y | 217 | default y |
| 228 | help | 218 | help |
| 229 | This adds the CPUFreq driver support for SPEAr SOCs. | 219 | This adds the CPUFreq driver support for SPEAr SOCs. |
| @@ -231,7 +221,6 @@ config ARM_SPEAR_CPUFREQ | |||
| 231 | config ARM_TEGRA_CPUFREQ | 221 | config ARM_TEGRA_CPUFREQ |
| 232 | bool "TEGRA CPUFreq support" | 222 | bool "TEGRA CPUFreq support" |
| 233 | depends on ARCH_TEGRA | 223 | depends on ARCH_TEGRA |
| 234 | select CPU_FREQ_TABLE | ||
| 235 | default y | 224 | default y |
| 236 | help | 225 | help |
| 237 | This adds the CPUFreq driver support for TEGRA SOCs. | 226 | This adds the CPUFreq driver support for TEGRA SOCs. |
diff --git a/drivers/cpufreq/Kconfig.powerpc b/drivers/cpufreq/Kconfig.powerpc index 25ca9db62e09..ca0021a96e19 100644 --- a/drivers/cpufreq/Kconfig.powerpc +++ b/drivers/cpufreq/Kconfig.powerpc | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | config CPU_FREQ_CBE | 1 | config CPU_FREQ_CBE |
| 2 | tristate "CBE frequency scaling" | 2 | tristate "CBE frequency scaling" |
| 3 | depends on CBE_RAS && PPC_CELL | 3 | depends on CBE_RAS && PPC_CELL |
| 4 | select CPU_FREQ_TABLE | ||
| 5 | default m | 4 | default m |
| 6 | help | 5 | help |
| 7 | This adds the cpufreq driver for Cell BE processors. | 6 | This adds the cpufreq driver for Cell BE processors. |
| @@ -20,7 +19,6 @@ config CPU_FREQ_CBE_PMI | |||
| 20 | config CPU_FREQ_MAPLE | 19 | config CPU_FREQ_MAPLE |
| 21 | bool "Support for Maple 970FX Evaluation Board" | 20 | bool "Support for Maple 970FX Evaluation Board" |
| 22 | depends on PPC_MAPLE | 21 | depends on PPC_MAPLE |
| 23 | select CPU_FREQ_TABLE | ||
| 24 | help | 22 | help |
| 25 | This adds support for frequency switching on Maple 970FX | 23 | This adds support for frequency switching on Maple 970FX |
| 26 | Evaluation Board and compatible boards (IBM JS2x blades). | 24 | Evaluation Board and compatible boards (IBM JS2x blades). |
| @@ -28,7 +26,6 @@ config CPU_FREQ_MAPLE | |||
| 28 | config PPC_CORENET_CPUFREQ | 26 | config PPC_CORENET_CPUFREQ |
| 29 | tristate "CPU frequency scaling driver for Freescale E500MC SoCs" | 27 | tristate "CPU frequency scaling driver for Freescale E500MC SoCs" |
| 30 | depends on PPC_E500MC && OF && COMMON_CLK | 28 | depends on PPC_E500MC && OF && COMMON_CLK |
| 31 | select CPU_FREQ_TABLE | ||
| 32 | select CLK_PPC_CORENET | 29 | select CLK_PPC_CORENET |
| 33 | help | 30 | help |
| 34 | This adds the CPUFreq driver support for Freescale e500mc, | 31 | This adds the CPUFreq driver support for Freescale e500mc, |
| @@ -38,7 +35,6 @@ config PPC_CORENET_CPUFREQ | |||
| 38 | config CPU_FREQ_PMAC | 35 | config CPU_FREQ_PMAC |
| 39 | bool "Support for Apple PowerBooks" | 36 | bool "Support for Apple PowerBooks" |
| 40 | depends on ADB_PMU && PPC32 | 37 | depends on ADB_PMU && PPC32 |
| 41 | select CPU_FREQ_TABLE | ||
| 42 | help | 38 | help |
| 43 | This adds support for frequency switching on Apple PowerBooks, | 39 | This adds support for frequency switching on Apple PowerBooks, |
| 44 | this currently includes some models of iBook & Titanium | 40 | this currently includes some models of iBook & Titanium |
| @@ -47,7 +43,6 @@ config CPU_FREQ_PMAC | |||
| 47 | config CPU_FREQ_PMAC64 | 43 | config CPU_FREQ_PMAC64 |
| 48 | bool "Support for some Apple G5s" | 44 | bool "Support for some Apple G5s" |
| 49 | depends on PPC_PMAC && PPC64 | 45 | depends on PPC_PMAC && PPC64 |
| 50 | select CPU_FREQ_TABLE | ||
| 51 | help | 46 | help |
| 52 | This adds support for frequency switching on Apple iMac G5, | 47 | This adds support for frequency switching on Apple iMac G5, |
| 53 | and some of the more recent desktop G5 machines as well. | 48 | and some of the more recent desktop G5 machines as well. |
| @@ -55,7 +50,6 @@ config CPU_FREQ_PMAC64 | |||
| 55 | config PPC_PASEMI_CPUFREQ | 50 | config PPC_PASEMI_CPUFREQ |
| 56 | bool "Support for PA Semi PWRficient" | 51 | bool "Support for PA Semi PWRficient" |
| 57 | depends on PPC_PASEMI | 52 | depends on PPC_PASEMI |
| 58 | select CPU_FREQ_TABLE | ||
| 59 | default y | 53 | default y |
| 60 | help | 54 | help |
| 61 | This adds the support for frequency switching on PA Semi | 55 | This adds the support for frequency switching on PA Semi |
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index e2b6eabef221..6897ad85b046 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 | |||
| @@ -31,7 +31,6 @@ config X86_PCC_CPUFREQ | |||
| 31 | 31 | ||
| 32 | config X86_ACPI_CPUFREQ | 32 | config X86_ACPI_CPUFREQ |
| 33 | tristate "ACPI Processor P-States driver" | 33 | tristate "ACPI Processor P-States driver" |
| 34 | select CPU_FREQ_TABLE | ||
| 35 | depends on ACPI_PROCESSOR | 34 | depends on ACPI_PROCESSOR |
| 36 | help | 35 | help |
| 37 | This driver adds a CPUFreq driver which utilizes the ACPI | 36 | This driver adds a CPUFreq driver which utilizes the ACPI |
| @@ -60,7 +59,6 @@ config X86_ACPI_CPUFREQ_CPB | |||
| 60 | 59 | ||
| 61 | config ELAN_CPUFREQ | 60 | config ELAN_CPUFREQ |
| 62 | tristate "AMD Elan SC400 and SC410" | 61 | tristate "AMD Elan SC400 and SC410" |
| 63 | select CPU_FREQ_TABLE | ||
| 64 | depends on MELAN | 62 | depends on MELAN |
| 65 | ---help--- | 63 | ---help--- |
| 66 | This adds the CPUFreq driver for AMD Elan SC400 and SC410 | 64 | This adds the CPUFreq driver for AMD Elan SC400 and SC410 |
| @@ -76,7 +74,6 @@ config ELAN_CPUFREQ | |||
| 76 | 74 | ||
| 77 | config SC520_CPUFREQ | 75 | config SC520_CPUFREQ |
| 78 | tristate "AMD Elan SC520" | 76 | tristate "AMD Elan SC520" |
| 79 | select CPU_FREQ_TABLE | ||
| 80 | depends on MELAN | 77 | depends on MELAN |
| 81 | ---help--- | 78 | ---help--- |
| 82 | This adds the CPUFreq driver for AMD Elan SC520 processor. | 79 | This adds the CPUFreq driver for AMD Elan SC520 processor. |
| @@ -88,7 +85,6 @@ config SC520_CPUFREQ | |||
| 88 | 85 | ||
| 89 | config X86_POWERNOW_K6 | 86 | config X86_POWERNOW_K6 |
| 90 | tristate "AMD Mobile K6-2/K6-3 PowerNow!" | 87 | tristate "AMD Mobile K6-2/K6-3 PowerNow!" |
| 91 | select CPU_FREQ_TABLE | ||
| 92 | depends on X86_32 | 88 | depends on X86_32 |
| 93 | help | 89 | help |
| 94 | This adds the CPUFreq driver for mobile AMD K6-2+ and mobile | 90 | This adds the CPUFreq driver for mobile AMD K6-2+ and mobile |
| @@ -100,7 +96,6 @@ config X86_POWERNOW_K6 | |||
| 100 | 96 | ||
| 101 | config X86_POWERNOW_K7 | 97 | config X86_POWERNOW_K7 |
| 102 | tristate "AMD Mobile Athlon/Duron PowerNow!" | 98 | tristate "AMD Mobile Athlon/Duron PowerNow!" |
| 103 | select CPU_FREQ_TABLE | ||
| 104 | depends on X86_32 | 99 | depends on X86_32 |
| 105 | help | 100 | help |
| 106 | This adds the CPUFreq driver for mobile AMD K7 mobile processors. | 101 | This adds the CPUFreq driver for mobile AMD K7 mobile processors. |
| @@ -118,7 +113,6 @@ config X86_POWERNOW_K7_ACPI | |||
| 118 | 113 | ||
| 119 | config X86_POWERNOW_K8 | 114 | config X86_POWERNOW_K8 |
| 120 | tristate "AMD Opteron/Athlon64 PowerNow!" | 115 | tristate "AMD Opteron/Athlon64 PowerNow!" |
| 121 | select CPU_FREQ_TABLE | ||
| 122 | depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ | 116 | depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ |
| 123 | help | 117 | help |
| 124 | This adds the CPUFreq driver for K8/early Opteron/Athlon64 processors. | 118 | This adds the CPUFreq driver for K8/early Opteron/Athlon64 processors. |
| @@ -132,7 +126,6 @@ config X86_POWERNOW_K8 | |||
| 132 | config X86_AMD_FREQ_SENSITIVITY | 126 | config X86_AMD_FREQ_SENSITIVITY |
| 133 | tristate "AMD frequency sensitivity feedback powersave bias" | 127 | tristate "AMD frequency sensitivity feedback powersave bias" |
| 134 | depends on CPU_FREQ_GOV_ONDEMAND && X86_ACPI_CPUFREQ && CPU_SUP_AMD | 128 | depends on CPU_FREQ_GOV_ONDEMAND && X86_ACPI_CPUFREQ && CPU_SUP_AMD |
| 135 | select CPU_FREQ_TABLE | ||
| 136 | help | 129 | help |
| 137 | This adds AMD-specific powersave bias function to the ondemand | 130 | This adds AMD-specific powersave bias function to the ondemand |
| 138 | governor, which allows it to make more power-conscious frequency | 131 | governor, which allows it to make more power-conscious frequency |
| @@ -160,7 +153,6 @@ config X86_GX_SUSPMOD | |||
| 160 | 153 | ||
| 161 | config X86_SPEEDSTEP_CENTRINO | 154 | config X86_SPEEDSTEP_CENTRINO |
| 162 | tristate "Intel Enhanced SpeedStep (deprecated)" | 155 | tristate "Intel Enhanced SpeedStep (deprecated)" |
| 163 | select CPU_FREQ_TABLE | ||
| 164 | select X86_SPEEDSTEP_CENTRINO_TABLE if X86_32 | 156 | select X86_SPEEDSTEP_CENTRINO_TABLE if X86_32 |
| 165 | depends on X86_32 || (X86_64 && ACPI_PROCESSOR) | 157 | depends on X86_32 || (X86_64 && ACPI_PROCESSOR) |
| 166 | help | 158 | help |
| @@ -190,7 +182,6 @@ config X86_SPEEDSTEP_CENTRINO_TABLE | |||
| 190 | 182 | ||
| 191 | config X86_SPEEDSTEP_ICH | 183 | config X86_SPEEDSTEP_ICH |
| 192 | tristate "Intel Speedstep on ICH-M chipsets (ioport interface)" | 184 | tristate "Intel Speedstep on ICH-M chipsets (ioport interface)" |
| 193 | select CPU_FREQ_TABLE | ||
| 194 | depends on X86_32 | 185 | depends on X86_32 |
| 195 | help | 186 | help |
| 196 | This adds the CPUFreq driver for certain mobile Intel Pentium III | 187 | This adds the CPUFreq driver for certain mobile Intel Pentium III |
| @@ -204,7 +195,6 @@ config X86_SPEEDSTEP_ICH | |||
| 204 | 195 | ||
| 205 | config X86_SPEEDSTEP_SMI | 196 | config X86_SPEEDSTEP_SMI |
| 206 | tristate "Intel SpeedStep on 440BX/ZX/MX chipsets (SMI interface)" | 197 | tristate "Intel SpeedStep on 440BX/ZX/MX chipsets (SMI interface)" |
| 207 | select CPU_FREQ_TABLE | ||
| 208 | depends on X86_32 | 198 | depends on X86_32 |
| 209 | help | 199 | help |
| 210 | This adds the CPUFreq driver for certain mobile Intel Pentium III | 200 | This adds the CPUFreq driver for certain mobile Intel Pentium III |
| @@ -217,7 +207,6 @@ config X86_SPEEDSTEP_SMI | |||
| 217 | 207 | ||
| 218 | config X86_P4_CLOCKMOD | 208 | config X86_P4_CLOCKMOD |
| 219 | tristate "Intel Pentium 4 clock modulation" | 209 | tristate "Intel Pentium 4 clock modulation" |
| 220 | select CPU_FREQ_TABLE | ||
| 221 | help | 210 | help |
| 222 | This adds the CPUFreq driver for Intel Pentium 4 / XEON | 211 | This adds the CPUFreq driver for Intel Pentium 4 / XEON |
| 223 | processors. When enabled it will lower CPU temperature by skipping | 212 | processors. When enabled it will lower CPU temperature by skipping |
| @@ -259,7 +248,6 @@ config X86_LONGRUN | |||
| 259 | 248 | ||
| 260 | config X86_LONGHAUL | 249 | config X86_LONGHAUL |
| 261 | tristate "VIA Cyrix III Longhaul" | 250 | tristate "VIA Cyrix III Longhaul" |
| 262 | select CPU_FREQ_TABLE | ||
| 263 | depends on X86_32 && ACPI_PROCESSOR | 251 | depends on X86_32 && ACPI_PROCESSOR |
| 264 | help | 252 | help |
| 265 | This adds the CPUFreq driver for VIA Samuel/CyrixIII, | 253 | This adds the CPUFreq driver for VIA Samuel/CyrixIII, |
| @@ -272,7 +260,6 @@ config X86_LONGHAUL | |||
| 272 | 260 | ||
| 273 | config X86_E_POWERSAVER | 261 | config X86_E_POWERSAVER |
| 274 | tristate "VIA C7 Enhanced PowerSaver (DANGEROUS)" | 262 | tristate "VIA C7 Enhanced PowerSaver (DANGEROUS)" |
| 275 | select CPU_FREQ_TABLE | ||
| 276 | depends on X86_32 && ACPI_PROCESSOR | 263 | depends on X86_32 && ACPI_PROCESSOR |
| 277 | help | 264 | help |
| 278 | This adds the CPUFreq driver for VIA C7 processors. However, this driver | 265 | This adds the CPUFreq driver for VIA C7 processors. However, this driver |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index ad5866c2ada0..b7948bbbbf1f 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # CPUfreq core | 1 | # CPUfreq core |
| 2 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o | 2 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o |
| 3 | # CPUfreq stats | 3 | # CPUfreq stats |
| 4 | obj-$(CONFIG_CPU_FREQ_STAT) += cpufreq_stats.o | 4 | obj-$(CONFIG_CPU_FREQ_STAT) += cpufreq_stats.o |
| 5 | 5 | ||
| @@ -11,9 +11,6 @@ obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND) += cpufreq_ondemand.o | |||
| 11 | obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o | 11 | obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o |
| 12 | obj-$(CONFIG_CPU_FREQ_GOV_COMMON) += cpufreq_governor.o | 12 | obj-$(CONFIG_CPU_FREQ_GOV_COMMON) += cpufreq_governor.o |
| 13 | 13 | ||
| 14 | # CPUfreq cross-arch helpers | ||
| 15 | obj-$(CONFIG_CPU_FREQ_TABLE) += freq_table.o | ||
| 16 | |||
| 17 | obj-$(CONFIG_GENERIC_CPUFREQ_CPU0) += cpufreq-cpu0.o | 14 | obj-$(CONFIG_GENERIC_CPUFREQ_CPU0) += cpufreq-cpu0.o |
| 18 | 15 | ||
| 19 | ################################################################################## | 16 | ################################################################################## |
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index d2c3253e015e..a1717d7367c1 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
| @@ -516,15 +516,6 @@ out: | |||
| 516 | return result; | 516 | return result; |
| 517 | } | 517 | } |
| 518 | 518 | ||
| 519 | static int acpi_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 520 | { | ||
| 521 | struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu); | ||
| 522 | |||
| 523 | pr_debug("acpi_cpufreq_verify\n"); | ||
| 524 | |||
| 525 | return cpufreq_frequency_table_verify(policy, data->freq_table); | ||
| 526 | } | ||
| 527 | |||
| 528 | static unsigned long | 519 | static unsigned long |
| 529 | acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu) | 520 | acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu) |
| 530 | { | 521 | { |
| @@ -837,7 +828,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 837 | data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END; | 828 | data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END; |
| 838 | perf->state = 0; | 829 | perf->state = 0; |
| 839 | 830 | ||
| 840 | result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table); | 831 | result = cpufreq_table_validate_and_show(policy, data->freq_table); |
| 841 | if (result) | 832 | if (result) |
| 842 | goto err_freqfree; | 833 | goto err_freqfree; |
| 843 | 834 | ||
| @@ -846,12 +837,16 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 846 | 837 | ||
| 847 | switch (perf->control_register.space_id) { | 838 | switch (perf->control_register.space_id) { |
| 848 | case ACPI_ADR_SPACE_SYSTEM_IO: | 839 | case ACPI_ADR_SPACE_SYSTEM_IO: |
| 849 | /* Current speed is unknown and not detectable by IO port */ | 840 | /* |
| 841 | * The core will not set policy->cur, because | ||
| 842 | * cpufreq_driver->get is NULL, so we need to set it here. | ||
| 843 | * However, we have to guess it, because the current speed is | ||
| 844 | * unknown and not detectable via IO ports. | ||
| 845 | */ | ||
| 850 | policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu); | 846 | policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu); |
| 851 | break; | 847 | break; |
| 852 | case ACPI_ADR_SPACE_FIXED_HARDWARE: | 848 | case ACPI_ADR_SPACE_FIXED_HARDWARE: |
| 853 | acpi_cpufreq_driver.get = get_cur_freq_on_cpu; | 849 | acpi_cpufreq_driver.get = get_cur_freq_on_cpu; |
| 854 | policy->cur = get_cur_freq_on_cpu(cpu); | ||
| 855 | break; | 850 | break; |
| 856 | default: | 851 | default: |
| 857 | break; | 852 | break; |
| @@ -868,8 +863,6 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 868 | (u32) perf->states[i].power, | 863 | (u32) perf->states[i].power, |
| 869 | (u32) perf->states[i].transition_latency); | 864 | (u32) perf->states[i].transition_latency); |
| 870 | 865 | ||
| 871 | cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu); | ||
| 872 | |||
| 873 | /* | 866 | /* |
| 874 | * the first call to ->target() should result in us actually | 867 | * the first call to ->target() should result in us actually |
| 875 | * writing something to the appropriate registers. | 868 | * writing something to the appropriate registers. |
| @@ -929,7 +922,7 @@ static struct freq_attr *acpi_cpufreq_attr[] = { | |||
| 929 | }; | 922 | }; |
| 930 | 923 | ||
| 931 | static struct cpufreq_driver acpi_cpufreq_driver = { | 924 | static struct cpufreq_driver acpi_cpufreq_driver = { |
| 932 | .verify = acpi_cpufreq_verify, | 925 | .verify = cpufreq_generic_frequency_table_verify, |
| 933 | .target = acpi_cpufreq_target, | 926 | .target = acpi_cpufreq_target, |
| 934 | .bios_limit = acpi_processor_get_bios_limit, | 927 | .bios_limit = acpi_processor_get_bios_limit, |
| 935 | .init = acpi_cpufreq_cpu_init, | 928 | .init = acpi_cpufreq_cpu_init, |
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index e010fb722c6b..086f7c17ff58 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c | |||
| @@ -47,14 +47,6 @@ static unsigned int bL_cpufreq_get(unsigned int cpu) | |||
| 47 | return clk_get_rate(clk[cur_cluster]) / 1000; | 47 | return clk_get_rate(clk[cur_cluster]) / 1000; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | /* Validate policy frequency range */ | ||
| 51 | static int bL_cpufreq_verify_policy(struct cpufreq_policy *policy) | ||
| 52 | { | ||
| 53 | u32 cur_cluster = cpu_to_cluster(policy->cpu); | ||
| 54 | |||
| 55 | return cpufreq_frequency_table_verify(policy, freq_table[cur_cluster]); | ||
| 56 | } | ||
| 57 | |||
| 58 | /* Set clock frequency */ | 50 | /* Set clock frequency */ |
| 59 | static int bL_cpufreq_set_target(struct cpufreq_policy *policy, | 51 | static int bL_cpufreq_set_target(struct cpufreq_policy *policy, |
| 60 | unsigned int target_freq, unsigned int relation) | 52 | unsigned int target_freq, unsigned int relation) |
| @@ -127,7 +119,7 @@ static int get_cluster_clk_and_freq_table(struct device *cpu_dev) | |||
| 127 | } | 119 | } |
| 128 | 120 | ||
| 129 | name[12] = cluster + '0'; | 121 | name[12] = cluster + '0'; |
| 130 | clk[cluster] = clk_get_sys(name, NULL); | 122 | clk[cluster] = clk_get(cpu_dev, name); |
| 131 | if (!IS_ERR(clk[cluster])) { | 123 | if (!IS_ERR(clk[cluster])) { |
| 132 | dev_dbg(cpu_dev, "%s: clk: %p & freq table: %p, cluster: %d\n", | 124 | dev_dbg(cpu_dev, "%s: clk: %p & freq table: %p, cluster: %d\n", |
| 133 | __func__, clk[cluster], freq_table[cluster], | 125 | __func__, clk[cluster], freq_table[cluster], |
| @@ -165,7 +157,7 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy) | |||
| 165 | if (ret) | 157 | if (ret) |
| 166 | return ret; | 158 | return ret; |
| 167 | 159 | ||
| 168 | ret = cpufreq_frequency_table_cpuinfo(policy, freq_table[cur_cluster]); | 160 | ret = cpufreq_table_validate_and_show(policy, freq_table[cur_cluster]); |
| 169 | if (ret) { | 161 | if (ret) { |
| 170 | dev_err(cpu_dev, "CPU %d, cluster: %d invalid freq table\n", | 162 | dev_err(cpu_dev, "CPU %d, cluster: %d invalid freq table\n", |
| 171 | policy->cpu, cur_cluster); | 163 | policy->cpu, cur_cluster); |
| @@ -173,16 +165,12 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy) | |||
| 173 | return ret; | 165 | return ret; |
| 174 | } | 166 | } |
| 175 | 167 | ||
| 176 | cpufreq_frequency_table_get_attr(freq_table[cur_cluster], policy->cpu); | ||
| 177 | |||
| 178 | if (arm_bL_ops->get_transition_latency) | 168 | if (arm_bL_ops->get_transition_latency) |
| 179 | policy->cpuinfo.transition_latency = | 169 | policy->cpuinfo.transition_latency = |
| 180 | arm_bL_ops->get_transition_latency(cpu_dev); | 170 | arm_bL_ops->get_transition_latency(cpu_dev); |
| 181 | else | 171 | else |
| 182 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 172 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
| 183 | 173 | ||
| 184 | policy->cur = bL_cpufreq_get(policy->cpu); | ||
| 185 | |||
| 186 | cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); | 174 | cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu)); |
| 187 | 175 | ||
| 188 | dev_info(cpu_dev, "%s: CPU %d initialized\n", __func__, policy->cpu); | 176 | dev_info(cpu_dev, "%s: CPU %d initialized\n", __func__, policy->cpu); |
| @@ -200,28 +188,23 @@ static int bL_cpufreq_exit(struct cpufreq_policy *policy) | |||
| 200 | return -ENODEV; | 188 | return -ENODEV; |
| 201 | } | 189 | } |
| 202 | 190 | ||
| 191 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 203 | put_cluster_clk_and_freq_table(cpu_dev); | 192 | put_cluster_clk_and_freq_table(cpu_dev); |
| 204 | dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu); | 193 | dev_dbg(cpu_dev, "%s: Exited, cpu: %d\n", __func__, policy->cpu); |
| 205 | 194 | ||
| 206 | return 0; | 195 | return 0; |
| 207 | } | 196 | } |
| 208 | 197 | ||
| 209 | /* Export freq_table to sysfs */ | ||
| 210 | static struct freq_attr *bL_cpufreq_attr[] = { | ||
| 211 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 212 | NULL, | ||
| 213 | }; | ||
| 214 | |||
| 215 | static struct cpufreq_driver bL_cpufreq_driver = { | 198 | static struct cpufreq_driver bL_cpufreq_driver = { |
| 216 | .name = "arm-big-little", | 199 | .name = "arm-big-little", |
| 217 | .flags = CPUFREQ_STICKY, | 200 | .flags = CPUFREQ_STICKY | |
| 218 | .verify = bL_cpufreq_verify_policy, | 201 | CPUFREQ_HAVE_GOVERNOR_PER_POLICY, |
| 202 | .verify = cpufreq_generic_frequency_table_verify, | ||
| 219 | .target = bL_cpufreq_set_target, | 203 | .target = bL_cpufreq_set_target, |
| 220 | .get = bL_cpufreq_get, | 204 | .get = bL_cpufreq_get, |
| 221 | .init = bL_cpufreq_init, | 205 | .init = bL_cpufreq_init, |
| 222 | .exit = bL_cpufreq_exit, | 206 | .exit = bL_cpufreq_exit, |
| 223 | .have_governor_per_policy = true, | 207 | .attr = cpufreq_generic_attr, |
| 224 | .attr = bL_cpufreq_attr, | ||
| 225 | }; | 208 | }; |
| 226 | 209 | ||
| 227 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops) | 210 | int bL_cpufreq_register(struct cpufreq_arm_bL_ops *ops) |
diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c index e0c38d938997..7439deddd5cf 100644 --- a/drivers/cpufreq/at32ap-cpufreq.c +++ b/drivers/cpufreq/at32ap-cpufreq.c | |||
| @@ -19,18 +19,10 @@ | |||
| 19 | #include <linux/clk.h> | 19 | #include <linux/clk.h> |
| 20 | #include <linux/err.h> | 20 | #include <linux/err.h> |
| 21 | #include <linux/export.h> | 21 | #include <linux/export.h> |
| 22 | #include <linux/slab.h> | ||
| 22 | 23 | ||
| 23 | static struct clk *cpuclk; | 24 | static struct clk *cpuclk; |
| 24 | 25 | static struct cpufreq_frequency_table *freq_table; | |
| 25 | static int at32_verify_speed(struct cpufreq_policy *policy) | ||
| 26 | { | ||
| 27 | if (policy->cpu != 0) | ||
| 28 | return -EINVAL; | ||
| 29 | |||
| 30 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | ||
| 31 | policy->cpuinfo.max_freq); | ||
| 32 | return 0; | ||
| 33 | } | ||
| 34 | 26 | ||
| 35 | static unsigned int at32_get_speed(unsigned int cpu) | 27 | static unsigned int at32_get_speed(unsigned int cpu) |
| 36 | { | 28 | { |
| @@ -85,31 +77,68 @@ static int at32_set_target(struct cpufreq_policy *policy, | |||
| 85 | 77 | ||
| 86 | static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy) | 78 | static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy) |
| 87 | { | 79 | { |
| 80 | unsigned int frequency, rate, min_freq; | ||
| 81 | int retval, steps, i; | ||
| 82 | |||
| 88 | if (policy->cpu != 0) | 83 | if (policy->cpu != 0) |
| 89 | return -EINVAL; | 84 | return -EINVAL; |
| 90 | 85 | ||
| 91 | cpuclk = clk_get(NULL, "cpu"); | 86 | cpuclk = clk_get(NULL, "cpu"); |
| 92 | if (IS_ERR(cpuclk)) { | 87 | if (IS_ERR(cpuclk)) { |
| 93 | pr_debug("cpufreq: could not get CPU clk\n"); | 88 | pr_debug("cpufreq: could not get CPU clk\n"); |
| 94 | return PTR_ERR(cpuclk); | 89 | retval = PTR_ERR(cpuclk); |
| 90 | goto out_err; | ||
| 95 | } | 91 | } |
| 96 | 92 | ||
| 97 | policy->cpuinfo.min_freq = (clk_round_rate(cpuclk, 1) + 500) / 1000; | 93 | min_freq = (clk_round_rate(cpuclk, 1) + 500) / 1000; |
| 98 | policy->cpuinfo.max_freq = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; | 94 | frequency = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; |
| 99 | policy->cpuinfo.transition_latency = 0; | 95 | policy->cpuinfo.transition_latency = 0; |
| 100 | policy->cur = at32_get_speed(0); | ||
| 101 | policy->min = policy->cpuinfo.min_freq; | ||
| 102 | policy->max = policy->cpuinfo.max_freq; | ||
| 103 | 96 | ||
| 104 | printk("cpufreq: AT32AP CPU frequency driver\n"); | 97 | /* |
| 98 | * AVR32 CPU frequency rate scales in power of two between maximum and | ||
| 99 | * minimum, also add space for the table end marker. | ||
| 100 | * | ||
| 101 | * Further validate that the frequency is usable, and append it to the | ||
| 102 | * frequency table. | ||
| 103 | */ | ||
| 104 | steps = fls(frequency / min_freq) + 1; | ||
| 105 | freq_table = kzalloc(steps * sizeof(struct cpufreq_frequency_table), | ||
| 106 | GFP_KERNEL); | ||
| 107 | if (!freq_table) { | ||
| 108 | retval = -ENOMEM; | ||
| 109 | goto out_err_put_clk; | ||
| 110 | } | ||
| 111 | |||
| 112 | for (i = 0; i < (steps - 1); i++) { | ||
| 113 | rate = clk_round_rate(cpuclk, frequency * 1000) / 1000; | ||
| 105 | 114 | ||
| 106 | return 0; | 115 | if (rate != frequency) |
| 116 | freq_table[i].frequency = CPUFREQ_ENTRY_INVALID; | ||
| 117 | else | ||
| 118 | freq_table[i].frequency = frequency; | ||
| 119 | |||
| 120 | frequency /= 2; | ||
| 121 | } | ||
| 122 | |||
| 123 | freq_table[steps - 1].frequency = CPUFREQ_TABLE_END; | ||
| 124 | |||
| 125 | retval = cpufreq_table_validate_and_show(policy, freq_table); | ||
| 126 | if (!retval) { | ||
| 127 | printk("cpufreq: AT32AP CPU frequency driver\n"); | ||
| 128 | return 0; | ||
| 129 | } | ||
| 130 | |||
| 131 | kfree(freq_table); | ||
| 132 | out_err_put_clk: | ||
| 133 | clk_put(cpuclk); | ||
| 134 | out_err: | ||
| 135 | return retval; | ||
| 107 | } | 136 | } |
| 108 | 137 | ||
| 109 | static struct cpufreq_driver at32_driver = { | 138 | static struct cpufreq_driver at32_driver = { |
| 110 | .name = "at32ap", | 139 | .name = "at32ap", |
| 111 | .init = at32_cpufreq_driver_init, | 140 | .init = at32_cpufreq_driver_init, |
| 112 | .verify = at32_verify_speed, | 141 | .verify = cpufreq_generic_frequency_table_verify, |
| 113 | .target = at32_set_target, | 142 | .target = at32_set_target, |
| 114 | .get = at32_get_speed, | 143 | .get = at32_get_speed, |
| 115 | .flags = CPUFREQ_STICKY, | 144 | .flags = CPUFREQ_STICKY, |
diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c index ef05978a7237..0bc9e8c2c79b 100644 --- a/drivers/cpufreq/blackfin-cpufreq.c +++ b/drivers/cpufreq/blackfin-cpufreq.c | |||
| @@ -191,11 +191,6 @@ static int bfin_target(struct cpufreq_policy *policy, | |||
| 191 | return ret; | 191 | return ret; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | static int bfin_verify_speed(struct cpufreq_policy *policy) | ||
| 195 | { | ||
| 196 | return cpufreq_frequency_table_verify(policy, bfin_freq_table); | ||
| 197 | } | ||
| 198 | |||
| 199 | static int __bfin_cpu_init(struct cpufreq_policy *policy) | 194 | static int __bfin_cpu_init(struct cpufreq_policy *policy) |
| 200 | { | 195 | { |
| 201 | 196 | ||
| @@ -209,23 +204,17 @@ static int __bfin_cpu_init(struct cpufreq_policy *policy) | |||
| 209 | 204 | ||
| 210 | policy->cpuinfo.transition_latency = 50000; /* 50us assumed */ | 205 | policy->cpuinfo.transition_latency = 50000; /* 50us assumed */ |
| 211 | 206 | ||
| 212 | policy->cur = cclk; | 207 | return cpufreq_table_validate_and_show(policy, bfin_freq_table); |
| 213 | cpufreq_frequency_table_get_attr(bfin_freq_table, policy->cpu); | ||
| 214 | return cpufreq_frequency_table_cpuinfo(policy, bfin_freq_table); | ||
| 215 | } | 208 | } |
| 216 | 209 | ||
| 217 | static struct freq_attr *bfin_freq_attr[] = { | ||
| 218 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 219 | NULL, | ||
| 220 | }; | ||
| 221 | |||
| 222 | static struct cpufreq_driver bfin_driver = { | 210 | static struct cpufreq_driver bfin_driver = { |
| 223 | .verify = bfin_verify_speed, | 211 | .verify = cpufreq_generic_frequency_table_verify, |
| 224 | .target = bfin_target, | 212 | .target = bfin_target, |
| 225 | .get = bfin_getfreq_khz, | 213 | .get = bfin_getfreq_khz, |
| 226 | .init = __bfin_cpu_init, | 214 | .init = __bfin_cpu_init, |
| 215 | .exit = cpufreq_generic_exit, | ||
| 227 | .name = "bfin cpufreq", | 216 | .name = "bfin cpufreq", |
| 228 | .attr = bfin_freq_attr, | 217 | .attr = cpufreq_generic_attr, |
| 229 | }; | 218 | }; |
| 230 | 219 | ||
| 231 | static int __init bfin_cpu_init(void) | 220 | static int __init bfin_cpu_init(void) |
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index 242d4900de47..33ab6504c447 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c | |||
| @@ -30,11 +30,6 @@ static struct clk *cpu_clk; | |||
| 30 | static struct regulator *cpu_reg; | 30 | static struct regulator *cpu_reg; |
| 31 | static struct cpufreq_frequency_table *freq_table; | 31 | static struct cpufreq_frequency_table *freq_table; |
| 32 | 32 | ||
| 33 | static int cpu0_verify_speed(struct cpufreq_policy *policy) | ||
| 34 | { | ||
| 35 | return cpufreq_frequency_table_verify(policy, freq_table); | ||
| 36 | } | ||
| 37 | |||
| 38 | static unsigned int cpu0_get_speed(unsigned int cpu) | 33 | static unsigned int cpu0_get_speed(unsigned int cpu) |
| 39 | { | 34 | { |
| 40 | return clk_get_rate(cpu_clk) / 1000; | 35 | return clk_get_rate(cpu_clk) / 1000; |
| @@ -127,50 +122,18 @@ post_notify: | |||
| 127 | 122 | ||
| 128 | static int cpu0_cpufreq_init(struct cpufreq_policy *policy) | 123 | static int cpu0_cpufreq_init(struct cpufreq_policy *policy) |
| 129 | { | 124 | { |
| 130 | int ret; | 125 | return cpufreq_generic_init(policy, freq_table, transition_latency); |
| 131 | |||
| 132 | ret = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
| 133 | if (ret) { | ||
| 134 | pr_err("invalid frequency table: %d\n", ret); | ||
| 135 | return ret; | ||
| 136 | } | ||
| 137 | |||
| 138 | policy->cpuinfo.transition_latency = transition_latency; | ||
| 139 | policy->cur = clk_get_rate(cpu_clk) / 1000; | ||
| 140 | |||
| 141 | /* | ||
| 142 | * The driver only supports the SMP configuartion where all processors | ||
| 143 | * share the clock and voltage and clock. Use cpufreq affected_cpus | ||
| 144 | * interface to have all CPUs scaled together. | ||
| 145 | */ | ||
| 146 | cpumask_setall(policy->cpus); | ||
| 147 | |||
| 148 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | ||
| 149 | |||
| 150 | return 0; | ||
| 151 | } | ||
| 152 | |||
| 153 | static int cpu0_cpufreq_exit(struct cpufreq_policy *policy) | ||
| 154 | { | ||
| 155 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 156 | |||
| 157 | return 0; | ||
| 158 | } | 126 | } |
| 159 | 127 | ||
| 160 | static struct freq_attr *cpu0_cpufreq_attr[] = { | ||
| 161 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 162 | NULL, | ||
| 163 | }; | ||
| 164 | |||
| 165 | static struct cpufreq_driver cpu0_cpufreq_driver = { | 128 | static struct cpufreq_driver cpu0_cpufreq_driver = { |
| 166 | .flags = CPUFREQ_STICKY, | 129 | .flags = CPUFREQ_STICKY, |
| 167 | .verify = cpu0_verify_speed, | 130 | .verify = cpufreq_generic_frequency_table_verify, |
| 168 | .target = cpu0_set_target, | 131 | .target = cpu0_set_target, |
| 169 | .get = cpu0_get_speed, | 132 | .get = cpu0_get_speed, |
| 170 | .init = cpu0_cpufreq_init, | 133 | .init = cpu0_cpufreq_init, |
| 171 | .exit = cpu0_cpufreq_exit, | 134 | .exit = cpufreq_generic_exit, |
| 172 | .name = "generic_cpu0", | 135 | .name = "generic_cpu0", |
| 173 | .attr = cpu0_cpufreq_attr, | 136 | .attr = cpufreq_generic_attr, |
| 174 | }; | 137 | }; |
| 175 | 138 | ||
| 176 | static int cpu0_cpufreq_probe(struct platform_device *pdev) | 139 | static int cpu0_cpufreq_probe(struct platform_device *pdev) |
diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nforce2.c index b83d45f68574..a05b876f375e 100644 --- a/drivers/cpufreq/cpufreq-nforce2.c +++ b/drivers/cpufreq/cpufreq-nforce2.c | |||
| @@ -303,9 +303,7 @@ static int nforce2_verify(struct cpufreq_policy *policy) | |||
| 303 | if (policy->min < (fsb_pol_max * fid * 100)) | 303 | if (policy->min < (fsb_pol_max * fid * 100)) |
| 304 | policy->max = (fsb_pol_max + 1) * fid * 100; | 304 | policy->max = (fsb_pol_max + 1) * fid * 100; |
| 305 | 305 | ||
| 306 | cpufreq_verify_within_limits(policy, | 306 | cpufreq_verify_within_cpu_limits(policy); |
| 307 | policy->cpuinfo.min_freq, | ||
| 308 | policy->cpuinfo.max_freq); | ||
| 309 | return 0; | 307 | return 0; |
| 310 | } | 308 | } |
| 311 | 309 | ||
| @@ -362,7 +360,6 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy) | |||
| 362 | policy->min = policy->cpuinfo.min_freq = min_fsb * fid * 100; | 360 | policy->min = policy->cpuinfo.min_freq = min_fsb * fid * 100; |
| 363 | policy->max = policy->cpuinfo.max_freq = max_fsb * fid * 100; | 361 | policy->max = policy->cpuinfo.max_freq = max_fsb * fid * 100; |
| 364 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 362 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
| 365 | policy->cur = nforce2_get(policy->cpu); | ||
| 366 | 363 | ||
| 367 | return 0; | 364 | return 0; |
| 368 | } | 365 | } |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 04548f7023af..ec391d7f010b 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
| @@ -67,13 +67,11 @@ static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); | |||
| 67 | static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); | 67 | static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); |
| 68 | 68 | ||
| 69 | #define lock_policy_rwsem(mode, cpu) \ | 69 | #define lock_policy_rwsem(mode, cpu) \ |
| 70 | static int lock_policy_rwsem_##mode(int cpu) \ | 70 | static void lock_policy_rwsem_##mode(int cpu) \ |
| 71 | { \ | 71 | { \ |
| 72 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); \ | 72 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); \ |
| 73 | BUG_ON(!policy); \ | 73 | BUG_ON(!policy); \ |
| 74 | down_##mode(&per_cpu(cpu_policy_rwsem, policy->cpu)); \ | 74 | down_##mode(&per_cpu(cpu_policy_rwsem, policy->cpu)); \ |
| 75 | \ | ||
| 76 | return 0; \ | ||
| 77 | } | 75 | } |
| 78 | 76 | ||
| 79 | lock_policy_rwsem(read, cpu); | 77 | lock_policy_rwsem(read, cpu); |
| @@ -135,7 +133,7 @@ static DEFINE_MUTEX(cpufreq_governor_mutex); | |||
| 135 | 133 | ||
| 136 | bool have_governor_per_policy(void) | 134 | bool have_governor_per_policy(void) |
| 137 | { | 135 | { |
| 138 | return cpufreq_driver->have_governor_per_policy; | 136 | return !!(cpufreq_driver->flags & CPUFREQ_HAVE_GOVERNOR_PER_POLICY); |
| 139 | } | 137 | } |
| 140 | EXPORT_SYMBOL_GPL(have_governor_per_policy); | 138 | EXPORT_SYMBOL_GPL(have_governor_per_policy); |
| 141 | 139 | ||
| @@ -183,6 +181,37 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) | |||
| 183 | } | 181 | } |
| 184 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); | 182 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); |
| 185 | 183 | ||
| 184 | /* | ||
| 185 | * This is a generic cpufreq init() routine which can be used by cpufreq | ||
| 186 | * drivers of SMP systems. It will do following: | ||
| 187 | * - validate & show freq table passed | ||
| 188 | * - set policies transition latency | ||
| 189 | * - policy->cpus with all possible CPUs | ||
| 190 | */ | ||
| 191 | int cpufreq_generic_init(struct cpufreq_policy *policy, | ||
| 192 | struct cpufreq_frequency_table *table, | ||
| 193 | unsigned int transition_latency) | ||
| 194 | { | ||
| 195 | int ret; | ||
| 196 | |||
| 197 | ret = cpufreq_table_validate_and_show(policy, table); | ||
| 198 | if (ret) { | ||
| 199 | pr_err("%s: invalid frequency table: %d\n", __func__, ret); | ||
| 200 | return ret; | ||
| 201 | } | ||
| 202 | |||
| 203 | policy->cpuinfo.transition_latency = transition_latency; | ||
| 204 | |||
| 205 | /* | ||
| 206 | * The driver only supports the SMP configuartion where all processors | ||
| 207 | * share the clock and voltage and clock. | ||
| 208 | */ | ||
| 209 | cpumask_setall(policy->cpus); | ||
| 210 | |||
| 211 | return 0; | ||
| 212 | } | ||
| 213 | EXPORT_SYMBOL_GPL(cpufreq_generic_init); | ||
| 214 | |||
| 186 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) | 215 | struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) |
| 187 | { | 216 | { |
| 188 | struct cpufreq_policy *policy = NULL; | 217 | struct cpufreq_policy *policy = NULL; |
| @@ -414,7 +443,7 @@ show_one(scaling_min_freq, min); | |||
| 414 | show_one(scaling_max_freq, max); | 443 | show_one(scaling_max_freq, max); |
| 415 | show_one(scaling_cur_freq, cur); | 444 | show_one(scaling_cur_freq, cur); |
| 416 | 445 | ||
| 417 | static int __cpufreq_set_policy(struct cpufreq_policy *policy, | 446 | static int cpufreq_set_policy(struct cpufreq_policy *policy, |
| 418 | struct cpufreq_policy *new_policy); | 447 | struct cpufreq_policy *new_policy); |
| 419 | 448 | ||
| 420 | /** | 449 | /** |
| @@ -435,7 +464,7 @@ static ssize_t store_##file_name \ | |||
| 435 | if (ret != 1) \ | 464 | if (ret != 1) \ |
| 436 | return -EINVAL; \ | 465 | return -EINVAL; \ |
| 437 | \ | 466 | \ |
| 438 | ret = __cpufreq_set_policy(policy, &new_policy); \ | 467 | ret = cpufreq_set_policy(policy, &new_policy); \ |
| 439 | policy->user_policy.object = policy->object; \ | 468 | policy->user_policy.object = policy->object; \ |
| 440 | \ | 469 | \ |
| 441 | return ret ? ret : count; \ | 470 | return ret ? ret : count; \ |
| @@ -493,11 +522,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy, | |||
| 493 | &new_policy.governor)) | 522 | &new_policy.governor)) |
| 494 | return -EINVAL; | 523 | return -EINVAL; |
| 495 | 524 | ||
| 496 | /* | 525 | ret = cpufreq_set_policy(policy, &new_policy); |
| 497 | * Do not use cpufreq_set_policy here or the user_policy.max | ||
| 498 | * will be wrongly overridden | ||
| 499 | */ | ||
| 500 | ret = __cpufreq_set_policy(policy, &new_policy); | ||
| 501 | 526 | ||
| 502 | policy->user_policy.policy = policy->policy; | 527 | policy->user_policy.policy = policy->policy; |
| 503 | policy->user_policy.governor = policy->governor; | 528 | policy->user_policy.governor = policy->governor; |
| @@ -653,13 +678,12 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf) | |||
| 653 | { | 678 | { |
| 654 | struct cpufreq_policy *policy = to_policy(kobj); | 679 | struct cpufreq_policy *policy = to_policy(kobj); |
| 655 | struct freq_attr *fattr = to_attr(attr); | 680 | struct freq_attr *fattr = to_attr(attr); |
| 656 | ssize_t ret = -EINVAL; | 681 | ssize_t ret; |
| 657 | 682 | ||
| 658 | if (!down_read_trylock(&cpufreq_rwsem)) | 683 | if (!down_read_trylock(&cpufreq_rwsem)) |
| 659 | goto exit; | 684 | return -EINVAL; |
| 660 | 685 | ||
| 661 | if (lock_policy_rwsem_read(policy->cpu) < 0) | 686 | lock_policy_rwsem_read(policy->cpu); |
| 662 | goto up_read; | ||
| 663 | 687 | ||
| 664 | if (fattr->show) | 688 | if (fattr->show) |
| 665 | ret = fattr->show(policy, buf); | 689 | ret = fattr->show(policy, buf); |
| @@ -667,10 +691,8 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf) | |||
| 667 | ret = -EIO; | 691 | ret = -EIO; |
| 668 | 692 | ||
| 669 | unlock_policy_rwsem_read(policy->cpu); | 693 | unlock_policy_rwsem_read(policy->cpu); |
| 670 | |||
| 671 | up_read: | ||
| 672 | up_read(&cpufreq_rwsem); | 694 | up_read(&cpufreq_rwsem); |
| 673 | exit: | 695 | |
| 674 | return ret; | 696 | return ret; |
| 675 | } | 697 | } |
| 676 | 698 | ||
| @@ -689,8 +711,7 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr, | |||
| 689 | if (!down_read_trylock(&cpufreq_rwsem)) | 711 | if (!down_read_trylock(&cpufreq_rwsem)) |
| 690 | goto unlock; | 712 | goto unlock; |
| 691 | 713 | ||
| 692 | if (lock_policy_rwsem_write(policy->cpu) < 0) | 714 | lock_policy_rwsem_write(policy->cpu); |
| 693 | goto up_read; | ||
| 694 | 715 | ||
| 695 | if (fattr->store) | 716 | if (fattr->store) |
| 696 | ret = fattr->store(policy, buf, count); | 717 | ret = fattr->store(policy, buf, count); |
| @@ -699,7 +720,6 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr, | |||
| 699 | 720 | ||
| 700 | unlock_policy_rwsem_write(policy->cpu); | 721 | unlock_policy_rwsem_write(policy->cpu); |
| 701 | 722 | ||
| 702 | up_read: | ||
| 703 | up_read(&cpufreq_rwsem); | 723 | up_read(&cpufreq_rwsem); |
| 704 | unlock: | 724 | unlock: |
| 705 | put_online_cpus(); | 725 | put_online_cpus(); |
| @@ -844,11 +864,11 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) | |||
| 844 | int ret = 0; | 864 | int ret = 0; |
| 845 | 865 | ||
| 846 | memcpy(&new_policy, policy, sizeof(*policy)); | 866 | memcpy(&new_policy, policy, sizeof(*policy)); |
| 847 | /* assure that the starting sequence is run in __cpufreq_set_policy */ | 867 | /* assure that the starting sequence is run in cpufreq_set_policy */ |
| 848 | policy->governor = NULL; | 868 | policy->governor = NULL; |
| 849 | 869 | ||
| 850 | /* set default policy */ | 870 | /* set default policy */ |
| 851 | ret = __cpufreq_set_policy(policy, &new_policy); | 871 | ret = cpufreq_set_policy(policy, &new_policy); |
| 852 | policy->user_policy.policy = policy->policy; | 872 | policy->user_policy.policy = policy->policy; |
| 853 | policy->user_policy.governor = policy->governor; | 873 | policy->user_policy.governor = policy->governor; |
| 854 | 874 | ||
| @@ -949,7 +969,7 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) | |||
| 949 | 969 | ||
| 950 | static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | 970 | static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) |
| 951 | { | 971 | { |
| 952 | if (cpu == policy->cpu) | 972 | if (WARN_ON(cpu == policy->cpu)) |
| 953 | return; | 973 | return; |
| 954 | 974 | ||
| 955 | /* | 975 | /* |
| @@ -966,9 +986,7 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | |||
| 966 | 986 | ||
| 967 | up_write(&per_cpu(cpu_policy_rwsem, policy->last_cpu)); | 987 | up_write(&per_cpu(cpu_policy_rwsem, policy->last_cpu)); |
| 968 | 988 | ||
| 969 | #ifdef CONFIG_CPU_FREQ_TABLE | ||
| 970 | cpufreq_frequency_table_update_policy_cpu(policy); | 989 | cpufreq_frequency_table_update_policy_cpu(policy); |
| 971 | #endif | ||
| 972 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 990 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
| 973 | CPUFREQ_UPDATE_POLICY_CPU, policy); | 991 | CPUFREQ_UPDATE_POLICY_CPU, policy); |
| 974 | } | 992 | } |
| @@ -1053,6 +1071,14 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, | |||
| 1053 | goto err_set_policy_cpu; | 1071 | goto err_set_policy_cpu; |
| 1054 | } | 1072 | } |
| 1055 | 1073 | ||
| 1074 | if (cpufreq_driver->get) { | ||
| 1075 | policy->cur = cpufreq_driver->get(policy->cpu); | ||
| 1076 | if (!policy->cur) { | ||
| 1077 | pr_err("%s: ->get() failed\n", __func__); | ||
| 1078 | goto err_get_freq; | ||
| 1079 | } | ||
| 1080 | } | ||
| 1081 | |||
| 1056 | /* related cpus should atleast have policy->cpus */ | 1082 | /* related cpus should atleast have policy->cpus */ |
| 1057 | cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus); | 1083 | cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus); |
| 1058 | 1084 | ||
| @@ -1107,6 +1133,9 @@ err_out_unregister: | |||
| 1107 | per_cpu(cpufreq_cpu_data, j) = NULL; | 1133 | per_cpu(cpufreq_cpu_data, j) = NULL; |
| 1108 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1134 | write_unlock_irqrestore(&cpufreq_driver_lock, flags); |
| 1109 | 1135 | ||
| 1136 | err_get_freq: | ||
| 1137 | if (cpufreq_driver->exit) | ||
| 1138 | cpufreq_driver->exit(policy); | ||
| 1110 | err_set_policy_cpu: | 1139 | err_set_policy_cpu: |
| 1111 | cpufreq_policy_free(policy); | 1140 | cpufreq_policy_free(policy); |
| 1112 | nomem_out: | 1141 | nomem_out: |
| @@ -1147,7 +1176,7 @@ static int cpufreq_nominate_new_policy_cpu(struct cpufreq_policy *policy, | |||
| 1147 | if (ret) { | 1176 | if (ret) { |
| 1148 | pr_err("%s: Failed to move kobj: %d", __func__, ret); | 1177 | pr_err("%s: Failed to move kobj: %d", __func__, ret); |
| 1149 | 1178 | ||
| 1150 | WARN_ON(lock_policy_rwsem_write(old_cpu)); | 1179 | lock_policy_rwsem_write(old_cpu); |
| 1151 | cpumask_set_cpu(old_cpu, policy->cpus); | 1180 | cpumask_set_cpu(old_cpu, policy->cpus); |
| 1152 | unlock_policy_rwsem_write(old_cpu); | 1181 | unlock_policy_rwsem_write(old_cpu); |
| 1153 | 1182 | ||
| @@ -1208,14 +1237,13 @@ static int __cpufreq_remove_dev_prepare(struct device *dev, | |||
| 1208 | if (!frozen) | 1237 | if (!frozen) |
| 1209 | sysfs_remove_link(&dev->kobj, "cpufreq"); | 1238 | sysfs_remove_link(&dev->kobj, "cpufreq"); |
| 1210 | } else if (cpus > 1) { | 1239 | } else if (cpus > 1) { |
| 1211 | |||
| 1212 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); | 1240 | new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen); |
| 1213 | if (new_cpu >= 0) { | 1241 | if (new_cpu >= 0) { |
| 1214 | update_policy_cpu(policy, new_cpu); | 1242 | update_policy_cpu(policy, new_cpu); |
| 1215 | 1243 | ||
| 1216 | if (!frozen) { | 1244 | if (!frozen) { |
| 1217 | pr_debug("%s: policy Kobject moved to cpu: %d " | 1245 | pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n", |
| 1218 | "from: %d\n",__func__, new_cpu, cpu); | 1246 | __func__, new_cpu, cpu); |
| 1219 | } | 1247 | } |
| 1220 | } | 1248 | } |
| 1221 | } | 1249 | } |
| @@ -1243,7 +1271,7 @@ static int __cpufreq_remove_dev_finish(struct device *dev, | |||
| 1243 | return -EINVAL; | 1271 | return -EINVAL; |
| 1244 | } | 1272 | } |
| 1245 | 1273 | ||
| 1246 | WARN_ON(lock_policy_rwsem_write(cpu)); | 1274 | lock_policy_rwsem_write(cpu); |
| 1247 | cpus = cpumask_weight(policy->cpus); | 1275 | cpus = cpumask_weight(policy->cpus); |
| 1248 | 1276 | ||
| 1249 | if (cpus > 1) | 1277 | if (cpus > 1) |
| @@ -1310,36 +1338,24 @@ static int __cpufreq_remove_dev_finish(struct device *dev, | |||
| 1310 | } | 1338 | } |
| 1311 | 1339 | ||
| 1312 | /** | 1340 | /** |
| 1313 | * __cpufreq_remove_dev - remove a CPU device | 1341 | * cpufreq_remove_dev - remove a CPU device |
| 1314 | * | 1342 | * |
| 1315 | * Removes the cpufreq interface for a CPU device. | 1343 | * Removes the cpufreq interface for a CPU device. |
| 1316 | * Caller should already have policy_rwsem in write mode for this CPU. | ||
| 1317 | * This routine frees the rwsem before returning. | ||
| 1318 | */ | 1344 | */ |
| 1319 | static inline int __cpufreq_remove_dev(struct device *dev, | ||
| 1320 | struct subsys_interface *sif, | ||
| 1321 | bool frozen) | ||
| 1322 | { | ||
| 1323 | int ret; | ||
| 1324 | |||
| 1325 | ret = __cpufreq_remove_dev_prepare(dev, sif, frozen); | ||
| 1326 | |||
| 1327 | if (!ret) | ||
| 1328 | ret = __cpufreq_remove_dev_finish(dev, sif, frozen); | ||
| 1329 | |||
| 1330 | return ret; | ||
| 1331 | } | ||
| 1332 | |||
| 1333 | static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) | 1345 | static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) |
| 1334 | { | 1346 | { |
| 1335 | unsigned int cpu = dev->id; | 1347 | unsigned int cpu = dev->id; |
| 1336 | int retval; | 1348 | int ret; |
| 1337 | 1349 | ||
| 1338 | if (cpu_is_offline(cpu)) | 1350 | if (cpu_is_offline(cpu)) |
| 1339 | return 0; | 1351 | return 0; |
| 1340 | 1352 | ||
| 1341 | retval = __cpufreq_remove_dev(dev, sif, false); | 1353 | ret = __cpufreq_remove_dev_prepare(dev, sif, false); |
| 1342 | return retval; | 1354 | |
| 1355 | if (!ret) | ||
| 1356 | ret = __cpufreq_remove_dev_finish(dev, sif, false); | ||
| 1357 | |||
| 1358 | return ret; | ||
| 1343 | } | 1359 | } |
| 1344 | 1360 | ||
| 1345 | static void handle_update(struct work_struct *work) | 1361 | static void handle_update(struct work_struct *work) |
| @@ -1466,14 +1482,11 @@ unsigned int cpufreq_get(unsigned int cpu) | |||
| 1466 | if (!down_read_trylock(&cpufreq_rwsem)) | 1482 | if (!down_read_trylock(&cpufreq_rwsem)) |
| 1467 | return 0; | 1483 | return 0; |
| 1468 | 1484 | ||
| 1469 | if (unlikely(lock_policy_rwsem_read(cpu))) | 1485 | lock_policy_rwsem_read(cpu); |
| 1470 | goto out_policy; | ||
| 1471 | 1486 | ||
| 1472 | ret_freq = __cpufreq_get(cpu); | 1487 | ret_freq = __cpufreq_get(cpu); |
| 1473 | 1488 | ||
| 1474 | unlock_policy_rwsem_read(cpu); | 1489 | unlock_policy_rwsem_read(cpu); |
| 1475 | |||
| 1476 | out_policy: | ||
| 1477 | up_read(&cpufreq_rwsem); | 1490 | up_read(&cpufreq_rwsem); |
| 1478 | 1491 | ||
| 1479 | return ret_freq; | 1492 | return ret_freq; |
| @@ -1697,14 +1710,12 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, | |||
| 1697 | { | 1710 | { |
| 1698 | int ret = -EINVAL; | 1711 | int ret = -EINVAL; |
| 1699 | 1712 | ||
| 1700 | if (unlikely(lock_policy_rwsem_write(policy->cpu))) | 1713 | lock_policy_rwsem_write(policy->cpu); |
| 1701 | goto fail; | ||
| 1702 | 1714 | ||
| 1703 | ret = __cpufreq_driver_target(policy, target_freq, relation); | 1715 | ret = __cpufreq_driver_target(policy, target_freq, relation); |
| 1704 | 1716 | ||
| 1705 | unlock_policy_rwsem_write(policy->cpu); | 1717 | unlock_policy_rwsem_write(policy->cpu); |
| 1706 | 1718 | ||
| 1707 | fail: | ||
| 1708 | return ret; | 1719 | return ret; |
| 1709 | } | 1720 | } |
| 1710 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); | 1721 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); |
| @@ -1871,10 +1882,10 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) | |||
| 1871 | EXPORT_SYMBOL(cpufreq_get_policy); | 1882 | EXPORT_SYMBOL(cpufreq_get_policy); |
| 1872 | 1883 | ||
| 1873 | /* | 1884 | /* |
| 1874 | * data : current policy. | 1885 | * policy : current policy. |
| 1875 | * policy : policy to be set. | 1886 | * new_policy: policy to be set. |
| 1876 | */ | 1887 | */ |
| 1877 | static int __cpufreq_set_policy(struct cpufreq_policy *policy, | 1888 | static int cpufreq_set_policy(struct cpufreq_policy *policy, |
| 1878 | struct cpufreq_policy *new_policy) | 1889 | struct cpufreq_policy *new_policy) |
| 1879 | { | 1890 | { |
| 1880 | int ret = 0, failed = 1; | 1891 | int ret = 0, failed = 1; |
| @@ -1995,10 +2006,7 @@ int cpufreq_update_policy(unsigned int cpu) | |||
| 1995 | goto no_policy; | 2006 | goto no_policy; |
| 1996 | } | 2007 | } |
| 1997 | 2008 | ||
| 1998 | if (unlikely(lock_policy_rwsem_write(cpu))) { | 2009 | lock_policy_rwsem_write(cpu); |
| 1999 | ret = -EINVAL; | ||
| 2000 | goto fail; | ||
| 2001 | } | ||
| 2002 | 2010 | ||
| 2003 | pr_debug("updating policy for CPU %u\n", cpu); | 2011 | pr_debug("updating policy for CPU %u\n", cpu); |
| 2004 | memcpy(&new_policy, policy, sizeof(*policy)); | 2012 | memcpy(&new_policy, policy, sizeof(*policy)); |
| @@ -2023,11 +2031,10 @@ int cpufreq_update_policy(unsigned int cpu) | |||
| 2023 | } | 2031 | } |
| 2024 | } | 2032 | } |
| 2025 | 2033 | ||
| 2026 | ret = __cpufreq_set_policy(policy, &new_policy); | 2034 | ret = cpufreq_set_policy(policy, &new_policy); |
| 2027 | 2035 | ||
| 2028 | unlock_policy_rwsem_write(cpu); | 2036 | unlock_policy_rwsem_write(cpu); |
| 2029 | 2037 | ||
| 2030 | fail: | ||
| 2031 | cpufreq_cpu_put(policy); | 2038 | cpufreq_cpu_put(policy); |
| 2032 | no_policy: | 2039 | no_policy: |
| 2033 | return ret; | 2040 | return ret; |
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index 88cd39f7b0e9..b5f2b8618949 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h | |||
| @@ -191,7 +191,10 @@ struct common_dbs_data { | |||
| 191 | struct attribute_group *attr_group_gov_sys; /* one governor - system */ | 191 | struct attribute_group *attr_group_gov_sys; /* one governor - system */ |
| 192 | struct attribute_group *attr_group_gov_pol; /* one governor - policy */ | 192 | struct attribute_group *attr_group_gov_pol; /* one governor - policy */ |
| 193 | 193 | ||
| 194 | /* Common data for platforms that don't set have_governor_per_policy */ | 194 | /* |
| 195 | * Common data for platforms that don't set | ||
| 196 | * CPUFREQ_HAVE_GOVERNOR_PER_POLICY | ||
| 197 | */ | ||
| 195 | struct dbs_data *gdbs_data; | 198 | struct dbs_data *gdbs_data; |
| 196 | 199 | ||
| 197 | struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu); | 200 | struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu); |
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index 03078090b5f7..4dbf1db16aca 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c | |||
| @@ -38,18 +38,7 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) | |||
| 38 | if (!per_cpu(cpu_is_managed, policy->cpu)) | 38 | if (!per_cpu(cpu_is_managed, policy->cpu)) |
| 39 | goto err; | 39 | goto err; |
| 40 | 40 | ||
| 41 | /* | ||
| 42 | * We're safe from concurrent calls to ->target() here | ||
| 43 | * as we hold the userspace_mutex lock. If we were calling | ||
| 44 | * cpufreq_driver_target, a deadlock situation might occur: | ||
| 45 | * A: cpufreq_set (lock userspace_mutex) -> | ||
| 46 | * cpufreq_driver_target(lock policy->lock) | ||
| 47 | * B: cpufreq_set_policy(lock policy->lock) -> | ||
| 48 | * __cpufreq_governor -> | ||
| 49 | * cpufreq_governor_userspace (lock userspace_mutex) | ||
| 50 | */ | ||
| 51 | ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L); | 41 | ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L); |
| 52 | |||
| 53 | err: | 42 | err: |
| 54 | mutex_unlock(&userspace_mutex); | 43 | mutex_unlock(&userspace_mutex); |
| 55 | return ret; | 44 | return ret; |
diff --git a/drivers/cpufreq/cris-artpec3-cpufreq.c b/drivers/cpufreq/cris-artpec3-cpufreq.c index cb8276dd19ca..05fdc7e40257 100644 --- a/drivers/cpufreq/cris-artpec3-cpufreq.c +++ b/drivers/cpufreq/cris-artpec3-cpufreq.c | |||
| @@ -54,11 +54,6 @@ static void cris_freq_set_cpu_state(struct cpufreq_policy *policy, | |||
| 54 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 54 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | static int cris_freq_verify(struct cpufreq_policy *policy) | ||
| 58 | { | ||
| 59 | return cpufreq_frequency_table_verify(policy, &cris_freq_table[0]); | ||
| 60 | } | ||
| 61 | |||
| 62 | static int cris_freq_target(struct cpufreq_policy *policy, | 57 | static int cris_freq_target(struct cpufreq_policy *policy, |
| 63 | unsigned int target_freq, | 58 | unsigned int target_freq, |
| 64 | unsigned int relation) | 59 | unsigned int relation) |
| @@ -76,42 +71,17 @@ static int cris_freq_target(struct cpufreq_policy *policy, | |||
| 76 | 71 | ||
| 77 | static int cris_freq_cpu_init(struct cpufreq_policy *policy) | 72 | static int cris_freq_cpu_init(struct cpufreq_policy *policy) |
| 78 | { | 73 | { |
| 79 | int result; | 74 | return cpufreq_generic_init(policy, cris_freq_table, 1000000); |
| 80 | |||
| 81 | /* cpuinfo and default policy values */ | ||
| 82 | policy->cpuinfo.transition_latency = 1000000; /* 1ms */ | ||
| 83 | policy->cur = cris_freq_get_cpu_frequency(0); | ||
| 84 | |||
| 85 | result = cpufreq_frequency_table_cpuinfo(policy, cris_freq_table); | ||
| 86 | if (result) | ||
| 87 | return (result); | ||
| 88 | |||
| 89 | cpufreq_frequency_table_get_attr(cris_freq_table, policy->cpu); | ||
| 90 | |||
| 91 | return 0; | ||
| 92 | } | ||
| 93 | |||
| 94 | |||
| 95 | static int cris_freq_cpu_exit(struct cpufreq_policy *policy) | ||
| 96 | { | ||
| 97 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 98 | return 0; | ||
| 99 | } | 75 | } |
| 100 | 76 | ||
| 101 | |||
| 102 | static struct freq_attr *cris_freq_attr[] = { | ||
| 103 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 104 | NULL, | ||
| 105 | }; | ||
| 106 | |||
| 107 | static struct cpufreq_driver cris_freq_driver = { | 77 | static struct cpufreq_driver cris_freq_driver = { |
| 108 | .get = cris_freq_get_cpu_frequency, | 78 | .get = cris_freq_get_cpu_frequency, |
| 109 | .verify = cris_freq_verify, | 79 | .verify = cpufreq_generic_frequency_table_verify, |
| 110 | .target = cris_freq_target, | 80 | .target = cris_freq_target, |
| 111 | .init = cris_freq_cpu_init, | 81 | .init = cris_freq_cpu_init, |
| 112 | .exit = cris_freq_cpu_exit, | 82 | .exit = cpufreq_generic_exit, |
| 113 | .name = "cris_freq", | 83 | .name = "cris_freq", |
| 114 | .attr = cris_freq_attr, | 84 | .attr = cpufreq_generic_attr, |
| 115 | }; | 85 | }; |
| 116 | 86 | ||
| 117 | static int __init cris_freq_init(void) | 87 | static int __init cris_freq_init(void) |
diff --git a/drivers/cpufreq/cris-etraxfs-cpufreq.c b/drivers/cpufreq/cris-etraxfs-cpufreq.c index 72328f77dc53..fac2b26932dd 100644 --- a/drivers/cpufreq/cris-etraxfs-cpufreq.c +++ b/drivers/cpufreq/cris-etraxfs-cpufreq.c | |||
| @@ -54,11 +54,6 @@ static void cris_freq_set_cpu_state(struct cpufreq_policy *policy, | |||
| 54 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 54 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | static int cris_freq_verify(struct cpufreq_policy *policy) | ||
| 58 | { | ||
| 59 | return cpufreq_frequency_table_verify(policy, &cris_freq_table[0]); | ||
| 60 | } | ||
| 61 | |||
| 62 | static int cris_freq_target(struct cpufreq_policy *policy, | 57 | static int cris_freq_target(struct cpufreq_policy *policy, |
| 63 | unsigned int target_freq, unsigned int relation) | 58 | unsigned int target_freq, unsigned int relation) |
| 64 | { | 59 | { |
| @@ -75,40 +70,17 @@ static int cris_freq_target(struct cpufreq_policy *policy, | |||
| 75 | 70 | ||
| 76 | static int cris_freq_cpu_init(struct cpufreq_policy *policy) | 71 | static int cris_freq_cpu_init(struct cpufreq_policy *policy) |
| 77 | { | 72 | { |
| 78 | int result; | 73 | return cpufreq_generic_init(policy, cris_freq_table, 1000000); |
| 79 | |||
| 80 | /* cpuinfo and default policy values */ | ||
| 81 | policy->cpuinfo.transition_latency = 1000000; /* 1ms */ | ||
| 82 | policy->cur = cris_freq_get_cpu_frequency(0); | ||
| 83 | |||
| 84 | result = cpufreq_frequency_table_cpuinfo(policy, cris_freq_table); | ||
| 85 | if (result) | ||
| 86 | return (result); | ||
| 87 | |||
| 88 | cpufreq_frequency_table_get_attr(cris_freq_table, policy->cpu); | ||
| 89 | |||
| 90 | return 0; | ||
| 91 | } | ||
| 92 | |||
| 93 | static int cris_freq_cpu_exit(struct cpufreq_policy *policy) | ||
| 94 | { | ||
| 95 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 96 | return 0; | ||
| 97 | } | 74 | } |
| 98 | 75 | ||
| 99 | static struct freq_attr *cris_freq_attr[] = { | ||
| 100 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 101 | NULL, | ||
| 102 | }; | ||
| 103 | |||
| 104 | static struct cpufreq_driver cris_freq_driver = { | 76 | static struct cpufreq_driver cris_freq_driver = { |
| 105 | .get = cris_freq_get_cpu_frequency, | 77 | .get = cris_freq_get_cpu_frequency, |
| 106 | .verify = cris_freq_verify, | 78 | .verify = cpufreq_generic_frequency_table_verify, |
| 107 | .target = cris_freq_target, | 79 | .target = cris_freq_target, |
| 108 | .init = cris_freq_cpu_init, | 80 | .init = cris_freq_cpu_init, |
| 109 | .exit = cris_freq_cpu_exit, | 81 | .exit = cpufreq_generic_exit, |
| 110 | .name = "cris_freq", | 82 | .name = "cris_freq", |
| 111 | .attr = cris_freq_attr, | 83 | .attr = cpufreq_generic_attr, |
| 112 | }; | 84 | }; |
| 113 | 85 | ||
| 114 | static int __init cris_freq_init(void) | 86 | static int __init cris_freq_init(void) |
diff --git a/drivers/cpufreq/davinci-cpufreq.c b/drivers/cpufreq/davinci-cpufreq.c index 551dd655c6f2..972583baf9e8 100644 --- a/drivers/cpufreq/davinci-cpufreq.c +++ b/drivers/cpufreq/davinci-cpufreq.c | |||
| @@ -50,9 +50,7 @@ static int davinci_verify_speed(struct cpufreq_policy *policy) | |||
| 50 | if (policy->cpu) | 50 | if (policy->cpu) |
| 51 | return -EINVAL; | 51 | return -EINVAL; |
| 52 | 52 | ||
| 53 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 53 | cpufreq_verify_within_cpu_limits(policy); |
| 54 | policy->cpuinfo.max_freq); | ||
| 55 | |||
| 56 | policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000; | 54 | policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000; |
| 57 | policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000; | 55 | policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000; |
| 58 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 56 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, |
| @@ -138,47 +136,24 @@ static int davinci_cpu_init(struct cpufreq_policy *policy) | |||
| 138 | return result; | 136 | return result; |
| 139 | } | 137 | } |
| 140 | 138 | ||
| 141 | policy->cur = davinci_getspeed(0); | ||
| 142 | |||
| 143 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
| 144 | if (result) { | ||
| 145 | pr_err("%s: cpufreq_frequency_table_cpuinfo() failed", | ||
| 146 | __func__); | ||
| 147 | return result; | ||
| 148 | } | ||
| 149 | |||
| 150 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | ||
| 151 | |||
| 152 | /* | 139 | /* |
| 153 | * Time measurement across the target() function yields ~1500-1800us | 140 | * Time measurement across the target() function yields ~1500-1800us |
| 154 | * time taken with no drivers on notification list. | 141 | * time taken with no drivers on notification list. |
| 155 | * Setting the latency to 2000 us to accommodate addition of drivers | 142 | * Setting the latency to 2000 us to accommodate addition of drivers |
| 156 | * to pre/post change notification list. | 143 | * to pre/post change notification list. |
| 157 | */ | 144 | */ |
| 158 | policy->cpuinfo.transition_latency = 2000 * 1000; | 145 | return cpufreq_generic_init(policy, freq_table, 2000 * 1000); |
| 159 | return 0; | ||
| 160 | } | 146 | } |
| 161 | 147 | ||
| 162 | static int davinci_cpu_exit(struct cpufreq_policy *policy) | ||
| 163 | { | ||
| 164 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 165 | return 0; | ||
| 166 | } | ||
| 167 | |||
| 168 | static struct freq_attr *davinci_cpufreq_attr[] = { | ||
| 169 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 170 | NULL, | ||
| 171 | }; | ||
| 172 | |||
| 173 | static struct cpufreq_driver davinci_driver = { | 148 | static struct cpufreq_driver davinci_driver = { |
| 174 | .flags = CPUFREQ_STICKY, | 149 | .flags = CPUFREQ_STICKY, |
| 175 | .verify = davinci_verify_speed, | 150 | .verify = davinci_verify_speed, |
| 176 | .target = davinci_target, | 151 | .target = davinci_target, |
| 177 | .get = davinci_getspeed, | 152 | .get = davinci_getspeed, |
| 178 | .init = davinci_cpu_init, | 153 | .init = davinci_cpu_init, |
| 179 | .exit = davinci_cpu_exit, | 154 | .exit = cpufreq_generic_exit, |
| 180 | .name = "davinci", | 155 | .name = "davinci", |
| 181 | .attr = davinci_cpufreq_attr, | 156 | .attr = cpufreq_generic_attr, |
| 182 | }; | 157 | }; |
| 183 | 158 | ||
| 184 | static int __init davinci_cpufreq_probe(struct platform_device *pdev) | 159 | static int __init davinci_cpufreq_probe(struct platform_device *pdev) |
diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c index 26321cdc1946..a60f7693c18e 100644 --- a/drivers/cpufreq/dbx500-cpufreq.c +++ b/drivers/cpufreq/dbx500-cpufreq.c | |||
| @@ -19,16 +19,6 @@ | |||
| 19 | static struct cpufreq_frequency_table *freq_table; | 19 | static struct cpufreq_frequency_table *freq_table; |
| 20 | static struct clk *armss_clk; | 20 | static struct clk *armss_clk; |
| 21 | 21 | ||
| 22 | static struct freq_attr *dbx500_cpufreq_attr[] = { | ||
| 23 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 24 | NULL, | ||
| 25 | }; | ||
| 26 | |||
| 27 | static int dbx500_cpufreq_verify_speed(struct cpufreq_policy *policy) | ||
| 28 | { | ||
| 29 | return cpufreq_frequency_table_verify(policy, freq_table); | ||
| 30 | } | ||
| 31 | |||
| 32 | static int dbx500_cpufreq_target(struct cpufreq_policy *policy, | 22 | static int dbx500_cpufreq_target(struct cpufreq_policy *policy, |
| 33 | unsigned int target_freq, | 23 | unsigned int target_freq, |
| 34 | unsigned int relation) | 24 | unsigned int relation) |
| @@ -84,43 +74,17 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu) | |||
| 84 | 74 | ||
| 85 | static int dbx500_cpufreq_init(struct cpufreq_policy *policy) | 75 | static int dbx500_cpufreq_init(struct cpufreq_policy *policy) |
| 86 | { | 76 | { |
| 87 | int res; | 77 | return cpufreq_generic_init(policy, freq_table, 20 * 1000); |
| 88 | |||
| 89 | /* get policy fields based on the table */ | ||
| 90 | res = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
| 91 | if (!res) | ||
| 92 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | ||
| 93 | else { | ||
| 94 | pr_err("dbx500-cpufreq: Failed to read policy table\n"); | ||
| 95 | return res; | ||
| 96 | } | ||
| 97 | |||
| 98 | policy->min = policy->cpuinfo.min_freq; | ||
| 99 | policy->max = policy->cpuinfo.max_freq; | ||
| 100 | policy->cur = dbx500_cpufreq_getspeed(policy->cpu); | ||
| 101 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; | ||
| 102 | |||
| 103 | /* | ||
| 104 | * FIXME : Need to take time measurement across the target() | ||
| 105 | * function with no/some/all drivers in the notification | ||
| 106 | * list. | ||
| 107 | */ | ||
| 108 | policy->cpuinfo.transition_latency = 20 * 1000; /* in ns */ | ||
| 109 | |||
| 110 | /* policy sharing between dual CPUs */ | ||
| 111 | cpumask_setall(policy->cpus); | ||
| 112 | |||
| 113 | return 0; | ||
| 114 | } | 78 | } |
| 115 | 79 | ||
| 116 | static struct cpufreq_driver dbx500_cpufreq_driver = { | 80 | static struct cpufreq_driver dbx500_cpufreq_driver = { |
| 117 | .flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS, | 81 | .flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS, |
| 118 | .verify = dbx500_cpufreq_verify_speed, | 82 | .verify = cpufreq_generic_frequency_table_verify, |
| 119 | .target = dbx500_cpufreq_target, | 83 | .target = dbx500_cpufreq_target, |
| 120 | .get = dbx500_cpufreq_getspeed, | 84 | .get = dbx500_cpufreq_getspeed, |
| 121 | .init = dbx500_cpufreq_init, | 85 | .init = dbx500_cpufreq_init, |
| 122 | .name = "DBX500", | 86 | .name = "DBX500", |
| 123 | .attr = dbx500_cpufreq_attr, | 87 | .attr = cpufreq_generic_attr, |
| 124 | }; | 88 | }; |
| 125 | 89 | ||
| 126 | static int dbx500_cpufreq_probe(struct platform_device *pdev) | 90 | static int dbx500_cpufreq_probe(struct platform_device *pdev) |
diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index 09f64cc83019..2c11ce3c67bd 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c | |||
| @@ -198,12 +198,6 @@ static int eps_target(struct cpufreq_policy *policy, | |||
| 198 | return ret; | 198 | return ret; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | static int eps_verify(struct cpufreq_policy *policy) | ||
| 202 | { | ||
| 203 | return cpufreq_frequency_table_verify(policy, | ||
| 204 | &eps_cpu[policy->cpu]->freq_table[0]); | ||
| 205 | } | ||
| 206 | |||
| 207 | static int eps_cpu_init(struct cpufreq_policy *policy) | 201 | static int eps_cpu_init(struct cpufreq_policy *policy) |
| 208 | { | 202 | { |
| 209 | unsigned int i; | 203 | unsigned int i; |
| @@ -401,15 +395,13 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
| 401 | } | 395 | } |
| 402 | 396 | ||
| 403 | policy->cpuinfo.transition_latency = 140000; /* 844mV -> 700mV in ns */ | 397 | policy->cpuinfo.transition_latency = 140000; /* 844mV -> 700mV in ns */ |
| 404 | policy->cur = fsb * current_multiplier; | ||
| 405 | 398 | ||
| 406 | ret = cpufreq_frequency_table_cpuinfo(policy, ¢aur->freq_table[0]); | 399 | ret = cpufreq_table_validate_and_show(policy, ¢aur->freq_table[0]); |
| 407 | if (ret) { | 400 | if (ret) { |
| 408 | kfree(centaur); | 401 | kfree(centaur); |
| 409 | return ret; | 402 | return ret; |
| 410 | } | 403 | } |
| 411 | 404 | ||
| 412 | cpufreq_frequency_table_get_attr(¢aur->freq_table[0], policy->cpu); | ||
| 413 | return 0; | 405 | return 0; |
| 414 | } | 406 | } |
| 415 | 407 | ||
| @@ -424,19 +416,14 @@ static int eps_cpu_exit(struct cpufreq_policy *policy) | |||
| 424 | return 0; | 416 | return 0; |
| 425 | } | 417 | } |
| 426 | 418 | ||
| 427 | static struct freq_attr *eps_attr[] = { | ||
| 428 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 429 | NULL, | ||
| 430 | }; | ||
| 431 | |||
| 432 | static struct cpufreq_driver eps_driver = { | 419 | static struct cpufreq_driver eps_driver = { |
| 433 | .verify = eps_verify, | 420 | .verify = cpufreq_generic_frequency_table_verify, |
| 434 | .target = eps_target, | 421 | .target = eps_target, |
| 435 | .init = eps_cpu_init, | 422 | .init = eps_cpu_init, |
| 436 | .exit = eps_cpu_exit, | 423 | .exit = eps_cpu_exit, |
| 437 | .get = eps_get, | 424 | .get = eps_get, |
| 438 | .name = "e_powersaver", | 425 | .name = "e_powersaver", |
| 439 | .attr = eps_attr, | 426 | .attr = cpufreq_generic_attr, |
| 440 | }; | 427 | }; |
| 441 | 428 | ||
| 442 | 429 | ||
diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c index 823a400d98fd..d91a645a27ae 100644 --- a/drivers/cpufreq/elanfreq.c +++ b/drivers/cpufreq/elanfreq.c | |||
| @@ -165,19 +165,6 @@ static void elanfreq_set_cpu_state(struct cpufreq_policy *policy, | |||
| 165 | }; | 165 | }; |
| 166 | 166 | ||
| 167 | 167 | ||
| 168 | /** | ||
| 169 | * elanfreq_validatespeed: test if frequency range is valid | ||
| 170 | * @policy: the policy to validate | ||
| 171 | * | ||
| 172 | * This function checks if a given frequency range in kHz is valid | ||
| 173 | * for the hardware supported by the driver. | ||
| 174 | */ | ||
| 175 | |||
| 176 | static int elanfreq_verify(struct cpufreq_policy *policy) | ||
| 177 | { | ||
| 178 | return cpufreq_frequency_table_verify(policy, &elanfreq_table[0]); | ||
| 179 | } | ||
| 180 | |||
| 181 | static int elanfreq_target(struct cpufreq_policy *policy, | 168 | static int elanfreq_target(struct cpufreq_policy *policy, |
| 182 | unsigned int target_freq, | 169 | unsigned int target_freq, |
| 183 | unsigned int relation) | 170 | unsigned int relation) |
| @@ -202,7 +189,6 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy) | |||
| 202 | { | 189 | { |
| 203 | struct cpuinfo_x86 *c = &cpu_data(0); | 190 | struct cpuinfo_x86 *c = &cpu_data(0); |
| 204 | unsigned int i; | 191 | unsigned int i; |
| 205 | int result; | ||
| 206 | 192 | ||
| 207 | /* capability check */ | 193 | /* capability check */ |
| 208 | if ((c->x86_vendor != X86_VENDOR_AMD) || | 194 | if ((c->x86_vendor != X86_VENDOR_AMD) || |
| @@ -221,21 +207,8 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy) | |||
| 221 | 207 | ||
| 222 | /* cpuinfo and default policy values */ | 208 | /* cpuinfo and default policy values */ |
| 223 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 209 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
| 224 | policy->cur = elanfreq_get_cpu_frequency(0); | ||
| 225 | 210 | ||
| 226 | result = cpufreq_frequency_table_cpuinfo(policy, elanfreq_table); | 211 | return cpufreq_table_validate_and_show(policy, elanfreq_table); |
| 227 | if (result) | ||
| 228 | return result; | ||
| 229 | |||
| 230 | cpufreq_frequency_table_get_attr(elanfreq_table, policy->cpu); | ||
| 231 | return 0; | ||
| 232 | } | ||
| 233 | |||
| 234 | |||
| 235 | static int elanfreq_cpu_exit(struct cpufreq_policy *policy) | ||
| 236 | { | ||
| 237 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 238 | return 0; | ||
| 239 | } | 212 | } |
| 240 | 213 | ||
| 241 | 214 | ||
| @@ -261,20 +234,14 @@ __setup("elanfreq=", elanfreq_setup); | |||
| 261 | #endif | 234 | #endif |
| 262 | 235 | ||
| 263 | 236 | ||
| 264 | static struct freq_attr *elanfreq_attr[] = { | ||
| 265 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 266 | NULL, | ||
| 267 | }; | ||
| 268 | |||
| 269 | |||
| 270 | static struct cpufreq_driver elanfreq_driver = { | 237 | static struct cpufreq_driver elanfreq_driver = { |
| 271 | .get = elanfreq_get_cpu_frequency, | 238 | .get = elanfreq_get_cpu_frequency, |
| 272 | .verify = elanfreq_verify, | 239 | .verify = cpufreq_generic_frequency_table_verify, |
| 273 | .target = elanfreq_target, | 240 | .target = elanfreq_target, |
| 274 | .init = elanfreq_cpu_init, | 241 | .init = elanfreq_cpu_init, |
| 275 | .exit = elanfreq_cpu_exit, | 242 | .exit = cpufreq_generic_exit, |
| 276 | .name = "elanfreq", | 243 | .name = "elanfreq", |
| 277 | .attr = elanfreq_attr, | 244 | .attr = cpufreq_generic_attr, |
| 278 | }; | 245 | }; |
| 279 | 246 | ||
| 280 | static const struct x86_cpu_id elan_id[] = { | 247 | static const struct x86_cpu_id elan_id[] = { |
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c index 0fac34439e31..3e4af676f43d 100644 --- a/drivers/cpufreq/exynos-cpufreq.c +++ b/drivers/cpufreq/exynos-cpufreq.c | |||
| @@ -31,12 +31,6 @@ static unsigned int locking_frequency; | |||
| 31 | static bool frequency_locked; | 31 | static bool frequency_locked; |
| 32 | static DEFINE_MUTEX(cpufreq_lock); | 32 | static DEFINE_MUTEX(cpufreq_lock); |
| 33 | 33 | ||
| 34 | static int exynos_verify_speed(struct cpufreq_policy *policy) | ||
| 35 | { | ||
| 36 | return cpufreq_frequency_table_verify(policy, | ||
| 37 | exynos_info->freq_table); | ||
| 38 | } | ||
| 39 | |||
| 40 | static unsigned int exynos_getspeed(unsigned int cpu) | 34 | static unsigned int exynos_getspeed(unsigned int cpu) |
| 41 | { | 35 | { |
| 42 | return clk_get_rate(exynos_info->cpu_clk) / 1000; | 36 | return clk_get_rate(exynos_info->cpu_clk) / 1000; |
| @@ -141,7 +135,7 @@ post_notify: | |||
| 141 | if ((freqs.new < freqs.old) || | 135 | if ((freqs.new < freqs.old) || |
| 142 | ((freqs.new > freqs.old) && safe_arm_volt)) { | 136 | ((freqs.new > freqs.old) && safe_arm_volt)) { |
| 143 | /* down the voltage after frequency change */ | 137 | /* down the voltage after frequency change */ |
| 144 | regulator_set_voltage(arm_regulator, arm_volt, | 138 | ret = regulator_set_voltage(arm_regulator, arm_volt, |
| 145 | arm_volt); | 139 | arm_volt); |
| 146 | if (ret) { | 140 | if (ret) { |
| 147 | pr_err("%s: failed to set cpu voltage to %d\n", | 141 | pr_err("%s: failed to set cpu voltage to %d\n", |
| @@ -247,38 +241,18 @@ static struct notifier_block exynos_cpufreq_nb = { | |||
| 247 | 241 | ||
| 248 | static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) | 242 | static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) |
| 249 | { | 243 | { |
| 250 | policy->cur = policy->min = policy->max = exynos_getspeed(policy->cpu); | 244 | return cpufreq_generic_init(policy, exynos_info->freq_table, 100000); |
| 251 | |||
| 252 | cpufreq_frequency_table_get_attr(exynos_info->freq_table, policy->cpu); | ||
| 253 | |||
| 254 | /* set the transition latency value */ | ||
| 255 | policy->cpuinfo.transition_latency = 100000; | ||
| 256 | |||
| 257 | cpumask_setall(policy->cpus); | ||
| 258 | |||
| 259 | return cpufreq_frequency_table_cpuinfo(policy, exynos_info->freq_table); | ||
| 260 | } | 245 | } |
| 261 | 246 | ||
| 262 | static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy) | ||
| 263 | { | ||
| 264 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 265 | return 0; | ||
| 266 | } | ||
| 267 | |||
| 268 | static struct freq_attr *exynos_cpufreq_attr[] = { | ||
| 269 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 270 | NULL, | ||
| 271 | }; | ||
| 272 | |||
| 273 | static struct cpufreq_driver exynos_driver = { | 247 | static struct cpufreq_driver exynos_driver = { |
| 274 | .flags = CPUFREQ_STICKY, | 248 | .flags = CPUFREQ_STICKY, |
| 275 | .verify = exynos_verify_speed, | 249 | .verify = cpufreq_generic_frequency_table_verify, |
| 276 | .target = exynos_target, | 250 | .target = exynos_target, |
| 277 | .get = exynos_getspeed, | 251 | .get = exynos_getspeed, |
| 278 | .init = exynos_cpufreq_cpu_init, | 252 | .init = exynos_cpufreq_cpu_init, |
| 279 | .exit = exynos_cpufreq_cpu_exit, | 253 | .exit = cpufreq_generic_exit, |
| 280 | .name = "exynos_cpufreq", | 254 | .name = "exynos_cpufreq", |
| 281 | .attr = exynos_cpufreq_attr, | 255 | .attr = cpufreq_generic_attr, |
| 282 | #ifdef CONFIG_PM | 256 | #ifdef CONFIG_PM |
| 283 | .suspend = exynos_cpufreq_suspend, | 257 | .suspend = exynos_cpufreq_suspend, |
| 284 | .resume = exynos_cpufreq_resume, | 258 | .resume = exynos_cpufreq_resume, |
diff --git a/drivers/cpufreq/exynos4210-cpufreq.c b/drivers/cpufreq/exynos4210-cpufreq.c index add7fbec4fc9..f2c75065ce19 100644 --- a/drivers/cpufreq/exynos4210-cpufreq.c +++ b/drivers/cpufreq/exynos4210-cpufreq.c | |||
| @@ -81,9 +81,9 @@ static void exynos4210_set_clkdiv(unsigned int div_index) | |||
| 81 | 81 | ||
| 82 | static void exynos4210_set_apll(unsigned int index) | 82 | static void exynos4210_set_apll(unsigned int index) |
| 83 | { | 83 | { |
| 84 | unsigned int tmp; | 84 | unsigned int tmp, freq = apll_freq_4210[index].freq; |
| 85 | 85 | ||
| 86 | /* 1. MUX_CORE_SEL = MPLL, ARMCLK uses MPLL for lock time */ | 86 | /* MUX_CORE_SEL = MPLL, ARMCLK uses MPLL for lock time */ |
| 87 | clk_set_parent(moutcore, mout_mpll); | 87 | clk_set_parent(moutcore, mout_mpll); |
| 88 | 88 | ||
| 89 | do { | 89 | do { |
| @@ -92,21 +92,9 @@ static void exynos4210_set_apll(unsigned int index) | |||
| 92 | tmp &= 0x7; | 92 | tmp &= 0x7; |
| 93 | } while (tmp != 0x2); | 93 | } while (tmp != 0x2); |
| 94 | 94 | ||
| 95 | /* 2. Set APLL Lock time */ | 95 | clk_set_rate(mout_apll, freq * 1000); |
| 96 | __raw_writel(EXYNOS4_APLL_LOCKTIME, EXYNOS4_APLL_LOCK); | ||
| 97 | |||
| 98 | /* 3. Change PLL PMS values */ | ||
| 99 | tmp = __raw_readl(EXYNOS4_APLL_CON0); | ||
| 100 | tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0)); | ||
| 101 | tmp |= apll_freq_4210[index].mps; | ||
| 102 | __raw_writel(tmp, EXYNOS4_APLL_CON0); | ||
| 103 | 96 | ||
| 104 | /* 4. wait_lock_time */ | 97 | /* MUX_CORE_SEL = APLL */ |
| 105 | do { | ||
| 106 | tmp = __raw_readl(EXYNOS4_APLL_CON0); | ||
| 107 | } while (!(tmp & (0x1 << EXYNOS4_APLLCON0_LOCKED_SHIFT))); | ||
| 108 | |||
| 109 | /* 5. MUX_CORE_SEL = APLL */ | ||
| 110 | clk_set_parent(moutcore, mout_apll); | 98 | clk_set_parent(moutcore, mout_apll); |
| 111 | 99 | ||
| 112 | do { | 100 | do { |
| @@ -115,53 +103,15 @@ static void exynos4210_set_apll(unsigned int index) | |||
| 115 | } while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT)); | 103 | } while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT)); |
| 116 | } | 104 | } |
| 117 | 105 | ||
| 118 | static bool exynos4210_pms_change(unsigned int old_index, unsigned int new_index) | ||
| 119 | { | ||
| 120 | unsigned int old_pm = apll_freq_4210[old_index].mps >> 8; | ||
| 121 | unsigned int new_pm = apll_freq_4210[new_index].mps >> 8; | ||
| 122 | |||
| 123 | return (old_pm == new_pm) ? 0 : 1; | ||
| 124 | } | ||
| 125 | |||
| 126 | static void exynos4210_set_frequency(unsigned int old_index, | 106 | static void exynos4210_set_frequency(unsigned int old_index, |
| 127 | unsigned int new_index) | 107 | unsigned int new_index) |
| 128 | { | 108 | { |
| 129 | unsigned int tmp; | ||
| 130 | |||
| 131 | if (old_index > new_index) { | 109 | if (old_index > new_index) { |
| 132 | if (!exynos4210_pms_change(old_index, new_index)) { | 110 | exynos4210_set_clkdiv(new_index); |
| 133 | /* 1. Change the system clock divider values */ | 111 | exynos4210_set_apll(new_index); |
| 134 | exynos4210_set_clkdiv(new_index); | ||
| 135 | |||
| 136 | /* 2. Change just s value in apll m,p,s value */ | ||
| 137 | tmp = __raw_readl(EXYNOS4_APLL_CON0); | ||
| 138 | tmp &= ~(0x7 << 0); | ||
| 139 | tmp |= apll_freq_4210[new_index].mps & 0x7; | ||
| 140 | __raw_writel(tmp, EXYNOS4_APLL_CON0); | ||
| 141 | } else { | ||
| 142 | /* Clock Configuration Procedure */ | ||
| 143 | /* 1. Change the system clock divider values */ | ||
| 144 | exynos4210_set_clkdiv(new_index); | ||
| 145 | /* 2. Change the apll m,p,s value */ | ||
| 146 | exynos4210_set_apll(new_index); | ||
| 147 | } | ||
| 148 | } else if (old_index < new_index) { | 112 | } else if (old_index < new_index) { |
| 149 | if (!exynos4210_pms_change(old_index, new_index)) { | 113 | exynos4210_set_apll(new_index); |
| 150 | /* 1. Change just s value in apll m,p,s value */ | 114 | exynos4210_set_clkdiv(new_index); |
| 151 | tmp = __raw_readl(EXYNOS4_APLL_CON0); | ||
| 152 | tmp &= ~(0x7 << 0); | ||
| 153 | tmp |= apll_freq_4210[new_index].mps & 0x7; | ||
| 154 | __raw_writel(tmp, EXYNOS4_APLL_CON0); | ||
| 155 | |||
| 156 | /* 2. Change the system clock divider values */ | ||
| 157 | exynos4210_set_clkdiv(new_index); | ||
| 158 | } else { | ||
| 159 | /* Clock Configuration Procedure */ | ||
| 160 | /* 1. Change the apll m,p,s value */ | ||
| 161 | exynos4210_set_apll(new_index); | ||
| 162 | /* 2. Change the system clock divider values */ | ||
| 163 | exynos4210_set_clkdiv(new_index); | ||
| 164 | } | ||
| 165 | } | 115 | } |
| 166 | } | 116 | } |
| 167 | 117 | ||
| @@ -194,7 +144,6 @@ int exynos4210_cpufreq_init(struct exynos_dvfs_info *info) | |||
| 194 | info->volt_table = exynos4210_volt_table; | 144 | info->volt_table = exynos4210_volt_table; |
| 195 | info->freq_table = exynos4210_freq_table; | 145 | info->freq_table = exynos4210_freq_table; |
| 196 | info->set_freq = exynos4210_set_frequency; | 146 | info->set_freq = exynos4210_set_frequency; |
| 197 | info->need_apll_change = exynos4210_pms_change; | ||
| 198 | 147 | ||
| 199 | return 0; | 148 | return 0; |
| 200 | 149 | ||
diff --git a/drivers/cpufreq/exynos4x12-cpufreq.c b/drivers/cpufreq/exynos4x12-cpufreq.c index 08b7477b0aa2..8683304ce62c 100644 --- a/drivers/cpufreq/exynos4x12-cpufreq.c +++ b/drivers/cpufreq/exynos4x12-cpufreq.c | |||
| @@ -128,9 +128,9 @@ static void exynos4x12_set_clkdiv(unsigned int div_index) | |||
| 128 | 128 | ||
| 129 | static void exynos4x12_set_apll(unsigned int index) | 129 | static void exynos4x12_set_apll(unsigned int index) |
| 130 | { | 130 | { |
| 131 | unsigned int tmp, pdiv; | 131 | unsigned int tmp, freq = apll_freq_4x12[index].freq; |
| 132 | 132 | ||
| 133 | /* 1. MUX_CORE_SEL = MPLL, ARMCLK uses MPLL for lock time */ | 133 | /* MUX_CORE_SEL = MPLL, ARMCLK uses MPLL for lock time */ |
| 134 | clk_set_parent(moutcore, mout_mpll); | 134 | clk_set_parent(moutcore, mout_mpll); |
| 135 | 135 | ||
| 136 | do { | 136 | do { |
| @@ -140,24 +140,9 @@ static void exynos4x12_set_apll(unsigned int index) | |||
| 140 | tmp &= 0x7; | 140 | tmp &= 0x7; |
| 141 | } while (tmp != 0x2); | 141 | } while (tmp != 0x2); |
| 142 | 142 | ||
| 143 | /* 2. Set APLL Lock time */ | 143 | clk_set_rate(mout_apll, freq * 1000); |
| 144 | pdiv = ((apll_freq_4x12[index].mps >> 8) & 0x3f); | ||
| 145 | 144 | ||
| 146 | __raw_writel((pdiv * 250), EXYNOS4_APLL_LOCK); | 145 | /* MUX_CORE_SEL = APLL */ |
| 147 | |||
| 148 | /* 3. Change PLL PMS values */ | ||
| 149 | tmp = __raw_readl(EXYNOS4_APLL_CON0); | ||
| 150 | tmp &= ~((0x3ff << 16) | (0x3f << 8) | (0x7 << 0)); | ||
| 151 | tmp |= apll_freq_4x12[index].mps; | ||
| 152 | __raw_writel(tmp, EXYNOS4_APLL_CON0); | ||
| 153 | |||
| 154 | /* 4. wait_lock_time */ | ||
| 155 | do { | ||
| 156 | cpu_relax(); | ||
| 157 | tmp = __raw_readl(EXYNOS4_APLL_CON0); | ||
| 158 | } while (!(tmp & (0x1 << EXYNOS4_APLLCON0_LOCKED_SHIFT))); | ||
| 159 | |||
| 160 | /* 5. MUX_CORE_SEL = APLL */ | ||
| 161 | clk_set_parent(moutcore, mout_apll); | 146 | clk_set_parent(moutcore, mout_apll); |
| 162 | 147 | ||
| 163 | do { | 148 | do { |
| @@ -167,52 +152,15 @@ static void exynos4x12_set_apll(unsigned int index) | |||
| 167 | } while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT)); | 152 | } while (tmp != (0x1 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT)); |
| 168 | } | 153 | } |
| 169 | 154 | ||
| 170 | static bool exynos4x12_pms_change(unsigned int old_index, unsigned int new_index) | ||
| 171 | { | ||
| 172 | unsigned int old_pm = apll_freq_4x12[old_index].mps >> 8; | ||
| 173 | unsigned int new_pm = apll_freq_4x12[new_index].mps >> 8; | ||
| 174 | |||
| 175 | return (old_pm == new_pm) ? 0 : 1; | ||
| 176 | } | ||
| 177 | |||
| 178 | static void exynos4x12_set_frequency(unsigned int old_index, | 155 | static void exynos4x12_set_frequency(unsigned int old_index, |
| 179 | unsigned int new_index) | 156 | unsigned int new_index) |
| 180 | { | 157 | { |
| 181 | unsigned int tmp; | ||
| 182 | |||
| 183 | if (old_index > new_index) { | 158 | if (old_index > new_index) { |
| 184 | if (!exynos4x12_pms_change(old_index, new_index)) { | 159 | exynos4x12_set_clkdiv(new_index); |
| 185 | /* 1. Change the system clock divider values */ | 160 | exynos4x12_set_apll(new_index); |
| 186 | exynos4x12_set_clkdiv(new_index); | ||
| 187 | /* 2. Change just s value in apll m,p,s value */ | ||
| 188 | tmp = __raw_readl(EXYNOS4_APLL_CON0); | ||
| 189 | tmp &= ~(0x7 << 0); | ||
| 190 | tmp |= apll_freq_4x12[new_index].mps & 0x7; | ||
| 191 | __raw_writel(tmp, EXYNOS4_APLL_CON0); | ||
| 192 | |||
| 193 | } else { | ||
| 194 | /* Clock Configuration Procedure */ | ||
| 195 | /* 1. Change the system clock divider values */ | ||
| 196 | exynos4x12_set_clkdiv(new_index); | ||
| 197 | /* 2. Change the apll m,p,s value */ | ||
| 198 | exynos4x12_set_apll(new_index); | ||
| 199 | } | ||
| 200 | } else if (old_index < new_index) { | 161 | } else if (old_index < new_index) { |
| 201 | if (!exynos4x12_pms_change(old_index, new_index)) { | 162 | exynos4x12_set_apll(new_index); |
| 202 | /* 1. Change just s value in apll m,p,s value */ | 163 | exynos4x12_set_clkdiv(new_index); |
| 203 | tmp = __raw_readl(EXYNOS4_APLL_CON0); | ||
| 204 | tmp &= ~(0x7 << 0); | ||
| 205 | tmp |= apll_freq_4x12[new_index].mps & 0x7; | ||
| 206 | __raw_writel(tmp, EXYNOS4_APLL_CON0); | ||
| 207 | /* 2. Change the system clock divider values */ | ||
| 208 | exynos4x12_set_clkdiv(new_index); | ||
| 209 | } else { | ||
| 210 | /* Clock Configuration Procedure */ | ||
| 211 | /* 1. Change the apll m,p,s value */ | ||
| 212 | exynos4x12_set_apll(new_index); | ||
| 213 | /* 2. Change the system clock divider values */ | ||
| 214 | exynos4x12_set_clkdiv(new_index); | ||
| 215 | } | ||
| 216 | } | 164 | } |
| 217 | } | 165 | } |
| 218 | 166 | ||
| @@ -250,7 +198,6 @@ int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info) | |||
| 250 | info->volt_table = exynos4x12_volt_table; | 198 | info->volt_table = exynos4x12_volt_table; |
| 251 | info->freq_table = exynos4x12_freq_table; | 199 | info->freq_table = exynos4x12_freq_table; |
| 252 | info->set_freq = exynos4x12_set_frequency; | 200 | info->set_freq = exynos4x12_set_frequency; |
| 253 | info->need_apll_change = exynos4x12_pms_change; | ||
| 254 | 201 | ||
| 255 | return 0; | 202 | return 0; |
| 256 | 203 | ||
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c index d41e77769d1a..8ae5e2925bf1 100644 --- a/drivers/cpufreq/exynos5440-cpufreq.c +++ b/drivers/cpufreq/exynos5440-cpufreq.c | |||
| @@ -209,12 +209,6 @@ static void exynos_enable_dvfs(void) | |||
| 209 | dvfs_info->base + XMU_DVFS_CTRL); | 209 | dvfs_info->base + XMU_DVFS_CTRL); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | static int exynos_verify_speed(struct cpufreq_policy *policy) | ||
| 213 | { | ||
| 214 | return cpufreq_frequency_table_verify(policy, | ||
| 215 | dvfs_info->freq_table); | ||
| 216 | } | ||
| 217 | |||
| 218 | static unsigned int exynos_getspeed(unsigned int cpu) | 212 | static unsigned int exynos_getspeed(unsigned int cpu) |
| 219 | { | 213 | { |
| 220 | return dvfs_info->cur_frequency; | 214 | return dvfs_info->cur_frequency; |
| @@ -324,30 +318,19 @@ static void exynos_sort_descend_freq_table(void) | |||
| 324 | 318 | ||
| 325 | static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) | 319 | static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) |
| 326 | { | 320 | { |
| 327 | int ret; | 321 | return cpufreq_generic_init(policy, dvfs_info->freq_table, |
| 328 | 322 | dvfs_info->latency); | |
| 329 | ret = cpufreq_frequency_table_cpuinfo(policy, dvfs_info->freq_table); | ||
| 330 | if (ret) { | ||
| 331 | dev_err(dvfs_info->dev, "Invalid frequency table: %d\n", ret); | ||
| 332 | return ret; | ||
| 333 | } | ||
| 334 | |||
| 335 | policy->cur = dvfs_info->cur_frequency; | ||
| 336 | policy->cpuinfo.transition_latency = dvfs_info->latency; | ||
| 337 | cpumask_setall(policy->cpus); | ||
| 338 | |||
| 339 | cpufreq_frequency_table_get_attr(dvfs_info->freq_table, policy->cpu); | ||
| 340 | |||
| 341 | return 0; | ||
| 342 | } | 323 | } |
| 343 | 324 | ||
| 344 | static struct cpufreq_driver exynos_driver = { | 325 | static struct cpufreq_driver exynos_driver = { |
| 345 | .flags = CPUFREQ_STICKY, | 326 | .flags = CPUFREQ_STICKY, |
| 346 | .verify = exynos_verify_speed, | 327 | .verify = cpufreq_generic_frequency_table_verify, |
| 347 | .target = exynos_target, | 328 | .target = exynos_target, |
| 348 | .get = exynos_getspeed, | 329 | .get = exynos_getspeed, |
| 349 | .init = exynos_cpufreq_cpu_init, | 330 | .init = exynos_cpufreq_cpu_init, |
| 331 | .exit = cpufreq_generic_exit, | ||
| 350 | .name = CPUFREQ_NAME, | 332 | .name = CPUFREQ_NAME, |
| 333 | .attr = cpufreq_generic_attr, | ||
| 351 | }; | 334 | }; |
| 352 | 335 | ||
| 353 | static const struct of_device_id exynos_cpufreq_match[] = { | 336 | static const struct of_device_id exynos_cpufreq_match[] = { |
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index f111454a7aea..3458d27f63b4 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
| @@ -54,31 +54,30 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_cpuinfo); | |||
| 54 | int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | 54 | int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, |
| 55 | struct cpufreq_frequency_table *table) | 55 | struct cpufreq_frequency_table *table) |
| 56 | { | 56 | { |
| 57 | unsigned int next_larger = ~0; | 57 | unsigned int next_larger = ~0, freq, i = 0; |
| 58 | unsigned int i; | 58 | bool found = false; |
| 59 | unsigned int count = 0; | ||
| 60 | 59 | ||
| 61 | pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", | 60 | pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", |
| 62 | policy->min, policy->max, policy->cpu); | 61 | policy->min, policy->max, policy->cpu); |
| 63 | 62 | ||
| 64 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 63 | cpufreq_verify_within_cpu_limits(policy); |
| 65 | policy->cpuinfo.max_freq); | ||
| 66 | 64 | ||
| 67 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { | 65 | for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) { |
| 68 | unsigned int freq = table[i].frequency; | ||
| 69 | if (freq == CPUFREQ_ENTRY_INVALID) | 66 | if (freq == CPUFREQ_ENTRY_INVALID) |
| 70 | continue; | 67 | continue; |
| 71 | if ((freq >= policy->min) && (freq <= policy->max)) | 68 | if ((freq >= policy->min) && (freq <= policy->max)) { |
| 72 | count++; | 69 | found = true; |
| 73 | else if ((next_larger > freq) && (freq > policy->max)) | 70 | break; |
| 71 | } | ||
| 72 | |||
| 73 | if ((next_larger > freq) && (freq > policy->max)) | ||
| 74 | next_larger = freq; | 74 | next_larger = freq; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | if (!count) | 77 | if (!found) { |
| 78 | policy->max = next_larger; | 78 | policy->max = next_larger; |
| 79 | 79 | cpufreq_verify_within_cpu_limits(policy); | |
| 80 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 80 | } |
| 81 | policy->cpuinfo.max_freq); | ||
| 82 | 81 | ||
| 83 | pr_debug("verification lead to (%u - %u kHz) for cpu %u\n", | 82 | pr_debug("verification lead to (%u - %u kHz) for cpu %u\n", |
| 84 | policy->min, policy->max, policy->cpu); | 83 | policy->min, policy->max, policy->cpu); |
| @@ -87,6 +86,20 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | |||
| 87 | } | 86 | } |
| 88 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); | 87 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); |
| 89 | 88 | ||
| 89 | /* | ||
| 90 | * Generic routine to verify policy & frequency table, requires driver to call | ||
| 91 | * cpufreq_frequency_table_get_attr() prior to it. | ||
| 92 | */ | ||
| 93 | int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) | ||
| 94 | { | ||
| 95 | struct cpufreq_frequency_table *table = | ||
| 96 | cpufreq_frequency_get_table(policy->cpu); | ||
| 97 | if (!table) | ||
| 98 | return -ENODEV; | ||
| 99 | |||
| 100 | return cpufreq_frequency_table_verify(policy, table); | ||
| 101 | } | ||
| 102 | EXPORT_SYMBOL_GPL(cpufreq_generic_frequency_table_verify); | ||
| 90 | 103 | ||
| 91 | int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | 104 | int cpufreq_frequency_table_target(struct cpufreq_policy *policy, |
| 92 | struct cpufreq_frequency_table *table, | 105 | struct cpufreq_frequency_table *table, |
| @@ -200,6 +213,12 @@ struct freq_attr cpufreq_freq_attr_scaling_available_freqs = { | |||
| 200 | }; | 213 | }; |
| 201 | EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs); | 214 | EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs); |
| 202 | 215 | ||
| 216 | struct freq_attr *cpufreq_generic_attr[] = { | ||
| 217 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 218 | NULL, | ||
| 219 | }; | ||
| 220 | EXPORT_SYMBOL_GPL(cpufreq_generic_attr); | ||
| 221 | |||
| 203 | /* | 222 | /* |
| 204 | * if you use these, you must assure that the frequency table is valid | 223 | * if you use these, you must assure that the frequency table is valid |
| 205 | * all the time between get_attr and put_attr! | 224 | * all the time between get_attr and put_attr! |
| @@ -219,6 +238,18 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu) | |||
| 219 | } | 238 | } |
| 220 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr); | 239 | EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr); |
| 221 | 240 | ||
| 241 | int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, | ||
| 242 | struct cpufreq_frequency_table *table) | ||
| 243 | { | ||
| 244 | int ret = cpufreq_frequency_table_cpuinfo(policy, table); | ||
| 245 | |||
| 246 | if (!ret) | ||
| 247 | cpufreq_frequency_table_get_attr(table, policy->cpu); | ||
| 248 | |||
| 249 | return ret; | ||
| 250 | } | ||
| 251 | EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show); | ||
| 252 | |||
| 222 | void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy) | 253 | void cpufreq_frequency_table_update_policy_cpu(struct cpufreq_policy *policy) |
| 223 | { | 254 | { |
| 224 | pr_debug("Updating show_table for new_cpu %u from last_cpu %u\n", | 255 | pr_debug("Updating show_table for new_cpu %u from last_cpu %u\n", |
diff --git a/drivers/cpufreq/gx-suspmod.c b/drivers/cpufreq/gx-suspmod.c index 70442c7b5e71..d83e8266a58e 100644 --- a/drivers/cpufreq/gx-suspmod.c +++ b/drivers/cpufreq/gx-suspmod.c | |||
| @@ -401,7 +401,7 @@ static int cpufreq_gx_target(struct cpufreq_policy *policy, | |||
| 401 | 401 | ||
| 402 | static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy) | 402 | static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy) |
| 403 | { | 403 | { |
| 404 | unsigned int maxfreq, curfreq; | 404 | unsigned int maxfreq; |
| 405 | 405 | ||
| 406 | if (!policy || policy->cpu != 0) | 406 | if (!policy || policy->cpu != 0) |
| 407 | return -ENODEV; | 407 | return -ENODEV; |
| @@ -415,10 +415,8 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy) | |||
| 415 | maxfreq = 30000 * gx_freq_mult[getCx86(CX86_DIR1) & 0x0f]; | 415 | maxfreq = 30000 * gx_freq_mult[getCx86(CX86_DIR1) & 0x0f]; |
| 416 | 416 | ||
| 417 | stock_freq = maxfreq; | 417 | stock_freq = maxfreq; |
| 418 | curfreq = gx_get_cpuspeed(0); | ||
| 419 | 418 | ||
| 420 | pr_debug("cpu max frequency is %d.\n", maxfreq); | 419 | pr_debug("cpu max frequency is %d.\n", maxfreq); |
| 421 | pr_debug("cpu current frequency is %dkHz.\n", curfreq); | ||
| 422 | 420 | ||
| 423 | /* setup basic struct for cpufreq API */ | 421 | /* setup basic struct for cpufreq API */ |
| 424 | policy->cpu = 0; | 422 | policy->cpu = 0; |
| @@ -428,7 +426,6 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy) | |||
| 428 | else | 426 | else |
| 429 | policy->min = maxfreq / POLICY_MIN_DIV; | 427 | policy->min = maxfreq / POLICY_MIN_DIV; |
| 430 | policy->max = maxfreq; | 428 | policy->max = maxfreq; |
| 431 | policy->cur = curfreq; | ||
| 432 | policy->cpuinfo.min_freq = maxfreq / max_duration; | 429 | policy->cpuinfo.min_freq = maxfreq / max_duration; |
| 433 | policy->cpuinfo.max_freq = maxfreq; | 430 | policy->cpuinfo.max_freq = maxfreq; |
| 434 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 431 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c index 794123fcf3e3..bf8902a0866d 100644 --- a/drivers/cpufreq/highbank-cpufreq.c +++ b/drivers/cpufreq/highbank-cpufreq.c | |||
| @@ -66,7 +66,8 @@ static int hb_cpufreq_driver_init(void) | |||
| 66 | struct device_node *np; | 66 | struct device_node *np; |
| 67 | int ret; | 67 | int ret; |
| 68 | 68 | ||
| 69 | if (!of_machine_is_compatible("calxeda,highbank")) | 69 | if ((!of_machine_is_compatible("calxeda,highbank")) && |
| 70 | (!of_machine_is_compatible("calxeda,ecx-2000"))) | ||
| 70 | return -ENODEV; | 71 | return -ENODEV; |
| 71 | 72 | ||
| 72 | cpu_dev = get_cpu_device(0); | 73 | cpu_dev = get_cpu_device(0); |
diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c index 3e14f0317175..90c6598415fd 100644 --- a/drivers/cpufreq/ia64-acpi-cpufreq.c +++ b/drivers/cpufreq/ia64-acpi-cpufreq.c | |||
| @@ -248,22 +248,6 @@ acpi_cpufreq_target ( | |||
| 248 | 248 | ||
| 249 | 249 | ||
| 250 | static int | 250 | static int |
| 251 | acpi_cpufreq_verify ( | ||
| 252 | struct cpufreq_policy *policy) | ||
| 253 | { | ||
| 254 | unsigned int result = 0; | ||
| 255 | struct cpufreq_acpi_io *data = acpi_io_data[policy->cpu]; | ||
| 256 | |||
| 257 | pr_debug("acpi_cpufreq_verify\n"); | ||
| 258 | |||
| 259 | result = cpufreq_frequency_table_verify(policy, | ||
| 260 | data->freq_table); | ||
| 261 | |||
| 262 | return (result); | ||
| 263 | } | ||
| 264 | |||
| 265 | |||
| 266 | static int | ||
| 267 | acpi_cpufreq_cpu_init ( | 251 | acpi_cpufreq_cpu_init ( |
| 268 | struct cpufreq_policy *policy) | 252 | struct cpufreq_policy *policy) |
| 269 | { | 253 | { |
| @@ -321,7 +305,6 @@ acpi_cpufreq_cpu_init ( | |||
| 321 | data->acpi_data.states[i].transition_latency * 1000; | 305 | data->acpi_data.states[i].transition_latency * 1000; |
| 322 | } | 306 | } |
| 323 | } | 307 | } |
| 324 | policy->cur = processor_get_freq(data, policy->cpu); | ||
| 325 | 308 | ||
| 326 | /* table init */ | 309 | /* table init */ |
| 327 | for (i = 0; i <= data->acpi_data.state_count; i++) | 310 | for (i = 0; i <= data->acpi_data.state_count; i++) |
| @@ -335,7 +318,7 @@ acpi_cpufreq_cpu_init ( | |||
| 335 | } | 318 | } |
| 336 | } | 319 | } |
| 337 | 320 | ||
| 338 | result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table); | 321 | result = cpufreq_table_validate_and_show(policy, data->freq_table); |
| 339 | if (result) { | 322 | if (result) { |
| 340 | goto err_freqfree; | 323 | goto err_freqfree; |
| 341 | } | 324 | } |
| @@ -356,8 +339,6 @@ acpi_cpufreq_cpu_init ( | |||
| 356 | (u32) data->acpi_data.states[i].status, | 339 | (u32) data->acpi_data.states[i].status, |
| 357 | (u32) data->acpi_data.states[i].control); | 340 | (u32) data->acpi_data.states[i].control); |
| 358 | 341 | ||
| 359 | cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu); | ||
| 360 | |||
| 361 | /* the first call to ->target() should result in us actually | 342 | /* the first call to ->target() should result in us actually |
| 362 | * writing something to the appropriate registers. */ | 343 | * writing something to the appropriate registers. */ |
| 363 | data->resume = 1; | 344 | data->resume = 1; |
| @@ -396,20 +377,14 @@ acpi_cpufreq_cpu_exit ( | |||
| 396 | } | 377 | } |
| 397 | 378 | ||
| 398 | 379 | ||
| 399 | static struct freq_attr* acpi_cpufreq_attr[] = { | ||
| 400 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 401 | NULL, | ||
| 402 | }; | ||
| 403 | |||
| 404 | |||
| 405 | static struct cpufreq_driver acpi_cpufreq_driver = { | 380 | static struct cpufreq_driver acpi_cpufreq_driver = { |
| 406 | .verify = acpi_cpufreq_verify, | 381 | .verify = cpufreq_generic_frequency_table_verify, |
| 407 | .target = acpi_cpufreq_target, | 382 | .target = acpi_cpufreq_target, |
| 408 | .get = acpi_cpufreq_get, | 383 | .get = acpi_cpufreq_get, |
| 409 | .init = acpi_cpufreq_cpu_init, | 384 | .init = acpi_cpufreq_cpu_init, |
| 410 | .exit = acpi_cpufreq_cpu_exit, | 385 | .exit = acpi_cpufreq_cpu_exit, |
| 411 | .name = "acpi-cpufreq", | 386 | .name = "acpi-cpufreq", |
| 412 | .attr = acpi_cpufreq_attr, | 387 | .attr = cpufreq_generic_attr, |
| 413 | }; | 388 | }; |
| 414 | 389 | ||
| 415 | 390 | ||
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index e4c914066601..be23892282e3 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c | |||
| @@ -35,11 +35,6 @@ static struct device *cpu_dev; | |||
| 35 | static struct cpufreq_frequency_table *freq_table; | 35 | static struct cpufreq_frequency_table *freq_table; |
| 36 | static unsigned int transition_latency; | 36 | static unsigned int transition_latency; |
| 37 | 37 | ||
| 38 | static int imx6q_verify_speed(struct cpufreq_policy *policy) | ||
| 39 | { | ||
| 40 | return cpufreq_frequency_table_verify(policy, freq_table); | ||
| 41 | } | ||
| 42 | |||
| 43 | static unsigned int imx6q_get_speed(unsigned int cpu) | 38 | static unsigned int imx6q_get_speed(unsigned int cpu) |
| 44 | { | 39 | { |
| 45 | return clk_get_rate(arm_clk) / 1000; | 40 | return clk_get_rate(arm_clk) / 1000; |
| @@ -159,41 +154,17 @@ post_notify: | |||
| 159 | 154 | ||
| 160 | static int imx6q_cpufreq_init(struct cpufreq_policy *policy) | 155 | static int imx6q_cpufreq_init(struct cpufreq_policy *policy) |
| 161 | { | 156 | { |
| 162 | int ret; | 157 | return cpufreq_generic_init(policy, freq_table, transition_latency); |
| 163 | |||
| 164 | ret = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
| 165 | if (ret) { | ||
| 166 | dev_err(cpu_dev, "invalid frequency table: %d\n", ret); | ||
| 167 | return ret; | ||
| 168 | } | ||
| 169 | |||
| 170 | policy->cpuinfo.transition_latency = transition_latency; | ||
| 171 | policy->cur = clk_get_rate(arm_clk) / 1000; | ||
| 172 | cpumask_setall(policy->cpus); | ||
| 173 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | ||
| 174 | |||
| 175 | return 0; | ||
| 176 | } | ||
| 177 | |||
| 178 | static int imx6q_cpufreq_exit(struct cpufreq_policy *policy) | ||
| 179 | { | ||
| 180 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 181 | return 0; | ||
| 182 | } | 158 | } |
| 183 | 159 | ||
| 184 | static struct freq_attr *imx6q_cpufreq_attr[] = { | ||
| 185 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 186 | NULL, | ||
| 187 | }; | ||
| 188 | |||
| 189 | static struct cpufreq_driver imx6q_cpufreq_driver = { | 160 | static struct cpufreq_driver imx6q_cpufreq_driver = { |
| 190 | .verify = imx6q_verify_speed, | 161 | .verify = cpufreq_generic_frequency_table_verify, |
| 191 | .target = imx6q_set_target, | 162 | .target = imx6q_set_target, |
| 192 | .get = imx6q_get_speed, | 163 | .get = imx6q_get_speed, |
| 193 | .init = imx6q_cpufreq_init, | 164 | .init = imx6q_cpufreq_init, |
| 194 | .exit = imx6q_cpufreq_exit, | 165 | .exit = cpufreq_generic_exit, |
| 195 | .name = "imx6q-cpufreq", | 166 | .name = "imx6q-cpufreq", |
| 196 | .attr = imx6q_cpufreq_attr, | 167 | .attr = cpufreq_generic_attr, |
| 197 | }; | 168 | }; |
| 198 | 169 | ||
| 199 | static int imx6q_cpufreq_probe(struct platform_device *pdev) | 170 | static int imx6q_cpufreq_probe(struct platform_device *pdev) |
diff --git a/drivers/cpufreq/integrator-cpufreq.c b/drivers/cpufreq/integrator-cpufreq.c index f7c99df0880b..babf3e40e9fa 100644 --- a/drivers/cpufreq/integrator-cpufreq.c +++ b/drivers/cpufreq/integrator-cpufreq.c | |||
| @@ -59,9 +59,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy) | |||
| 59 | { | 59 | { |
| 60 | struct icst_vco vco; | 60 | struct icst_vco vco; |
| 61 | 61 | ||
| 62 | cpufreq_verify_within_limits(policy, | 62 | cpufreq_verify_within_cpu_limits(policy); |
| 63 | policy->cpuinfo.min_freq, | ||
| 64 | policy->cpuinfo.max_freq); | ||
| 65 | 63 | ||
| 66 | vco = icst_hz_to_vco(&cclk_params, policy->max * 1000); | 64 | vco = icst_hz_to_vco(&cclk_params, policy->max * 1000); |
| 67 | policy->max = icst_hz(&cclk_params, vco) / 1000; | 65 | policy->max = icst_hz(&cclk_params, vco) / 1000; |
| @@ -69,10 +67,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy) | |||
| 69 | vco = icst_hz_to_vco(&cclk_params, policy->min * 1000); | 67 | vco = icst_hz_to_vco(&cclk_params, policy->min * 1000); |
| 70 | policy->min = icst_hz(&cclk_params, vco) / 1000; | 68 | policy->min = icst_hz(&cclk_params, vco) / 1000; |
| 71 | 69 | ||
| 72 | cpufreq_verify_within_limits(policy, | 70 | cpufreq_verify_within_cpu_limits(policy); |
| 73 | policy->cpuinfo.min_freq, | ||
| 74 | policy->cpuinfo.max_freq); | ||
| 75 | |||
| 76 | return 0; | 71 | return 0; |
| 77 | } | 72 | } |
| 78 | 73 | ||
| @@ -186,10 +181,9 @@ static int integrator_cpufreq_init(struct cpufreq_policy *policy) | |||
| 186 | { | 181 | { |
| 187 | 182 | ||
| 188 | /* set default policy and cpuinfo */ | 183 | /* set default policy and cpuinfo */ |
| 189 | policy->cpuinfo.max_freq = 160000; | 184 | policy->max = policy->cpuinfo.max_freq = 160000; |
| 190 | policy->cpuinfo.min_freq = 12000; | 185 | policy->min = policy->cpuinfo.min_freq = 12000; |
| 191 | policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */ | 186 | policy->cpuinfo.transition_latency = 1000000; /* 1 ms, assumed */ |
| 192 | policy->cur = policy->min = policy->max = integrator_get(policy->cpu); | ||
| 193 | 187 | ||
| 194 | return 0; | 188 | return 0; |
| 195 | } | 189 | } |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index badf6206b2b2..d57648989c0b 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
| @@ -615,9 +615,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) | |||
| 615 | 615 | ||
| 616 | static int intel_pstate_verify_policy(struct cpufreq_policy *policy) | 616 | static int intel_pstate_verify_policy(struct cpufreq_policy *policy) |
| 617 | { | 617 | { |
| 618 | cpufreq_verify_within_limits(policy, | 618 | cpufreq_verify_within_cpu_limits(policy); |
| 619 | policy->cpuinfo.min_freq, | ||
| 620 | policy->cpuinfo.max_freq); | ||
| 621 | 619 | ||
| 622 | if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && | 620 | if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && |
| 623 | (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) | 621 | (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) |
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c index ba10658a9394..fff8653c8e9b 100644 --- a/drivers/cpufreq/kirkwood-cpufreq.c +++ b/drivers/cpufreq/kirkwood-cpufreq.c | |||
| @@ -102,11 +102,6 @@ static void kirkwood_cpufreq_set_cpu_state(struct cpufreq_policy *policy, | |||
| 102 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 102 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 103 | }; | 103 | }; |
| 104 | 104 | ||
| 105 | static int kirkwood_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 106 | { | ||
| 107 | return cpufreq_frequency_table_verify(policy, kirkwood_freq_table); | ||
| 108 | } | ||
| 109 | |||
| 110 | static int kirkwood_cpufreq_target(struct cpufreq_policy *policy, | 105 | static int kirkwood_cpufreq_target(struct cpufreq_policy *policy, |
| 111 | unsigned int target_freq, | 106 | unsigned int target_freq, |
| 112 | unsigned int relation) | 107 | unsigned int relation) |
| @@ -125,40 +120,17 @@ static int kirkwood_cpufreq_target(struct cpufreq_policy *policy, | |||
| 125 | /* Module init and exit code */ | 120 | /* Module init and exit code */ |
| 126 | static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy) | 121 | static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy) |
| 127 | { | 122 | { |
| 128 | int result; | 123 | return cpufreq_generic_init(policy, kirkwood_freq_table, 5000); |
| 129 | |||
| 130 | /* cpuinfo and default policy values */ | ||
| 131 | policy->cpuinfo.transition_latency = 5000; /* 5uS */ | ||
| 132 | policy->cur = kirkwood_cpufreq_get_cpu_frequency(0); | ||
| 133 | |||
| 134 | result = cpufreq_frequency_table_cpuinfo(policy, kirkwood_freq_table); | ||
| 135 | if (result) | ||
| 136 | return result; | ||
| 137 | |||
| 138 | cpufreq_frequency_table_get_attr(kirkwood_freq_table, policy->cpu); | ||
| 139 | |||
| 140 | return 0; | ||
| 141 | } | ||
| 142 | |||
| 143 | static int kirkwood_cpufreq_cpu_exit(struct cpufreq_policy *policy) | ||
| 144 | { | ||
| 145 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 146 | return 0; | ||
| 147 | } | 124 | } |
| 148 | 125 | ||
| 149 | static struct freq_attr *kirkwood_cpufreq_attr[] = { | ||
| 150 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 151 | NULL, | ||
| 152 | }; | ||
| 153 | |||
| 154 | static struct cpufreq_driver kirkwood_cpufreq_driver = { | 126 | static struct cpufreq_driver kirkwood_cpufreq_driver = { |
| 155 | .get = kirkwood_cpufreq_get_cpu_frequency, | 127 | .get = kirkwood_cpufreq_get_cpu_frequency, |
| 156 | .verify = kirkwood_cpufreq_verify, | 128 | .verify = cpufreq_generic_frequency_table_verify, |
| 157 | .target = kirkwood_cpufreq_target, | 129 | .target = kirkwood_cpufreq_target, |
| 158 | .init = kirkwood_cpufreq_cpu_init, | 130 | .init = kirkwood_cpufreq_cpu_init, |
| 159 | .exit = kirkwood_cpufreq_cpu_exit, | 131 | .exit = cpufreq_generic_exit, |
| 160 | .name = "kirkwood-cpufreq", | 132 | .name = "kirkwood-cpufreq", |
| 161 | .attr = kirkwood_cpufreq_attr, | 133 | .attr = cpufreq_generic_attr, |
| 162 | }; | 134 | }; |
| 163 | 135 | ||
| 164 | static int kirkwood_cpufreq_probe(struct platform_device *pdev) | 136 | static int kirkwood_cpufreq_probe(struct platform_device *pdev) |
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index 4ada1cccb052..14df4974fb45 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
| @@ -625,12 +625,6 @@ static void longhaul_setup_voltagescaling(void) | |||
| 625 | } | 625 | } |
| 626 | 626 | ||
| 627 | 627 | ||
| 628 | static int longhaul_verify(struct cpufreq_policy *policy) | ||
| 629 | { | ||
| 630 | return cpufreq_frequency_table_verify(policy, longhaul_table); | ||
| 631 | } | ||
| 632 | |||
| 633 | |||
| 634 | static int longhaul_target(struct cpufreq_policy *policy, | 628 | static int longhaul_target(struct cpufreq_policy *policy, |
| 635 | unsigned int target_freq, unsigned int relation) | 629 | unsigned int target_freq, unsigned int relation) |
| 636 | { | 630 | { |
| @@ -919,36 +913,18 @@ static int longhaul_cpu_init(struct cpufreq_policy *policy) | |||
| 919 | longhaul_setup_voltagescaling(); | 913 | longhaul_setup_voltagescaling(); |
| 920 | 914 | ||
| 921 | policy->cpuinfo.transition_latency = 200000; /* nsec */ | 915 | policy->cpuinfo.transition_latency = 200000; /* nsec */ |
| 922 | policy->cur = calc_speed(longhaul_get_cpu_mult()); | ||
| 923 | |||
| 924 | ret = cpufreq_frequency_table_cpuinfo(policy, longhaul_table); | ||
| 925 | if (ret) | ||
| 926 | return ret; | ||
| 927 | |||
| 928 | cpufreq_frequency_table_get_attr(longhaul_table, policy->cpu); | ||
| 929 | 916 | ||
| 930 | return 0; | 917 | return cpufreq_table_validate_and_show(policy, longhaul_table); |
| 931 | } | 918 | } |
| 932 | 919 | ||
| 933 | static int longhaul_cpu_exit(struct cpufreq_policy *policy) | ||
| 934 | { | ||
| 935 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 936 | return 0; | ||
| 937 | } | ||
| 938 | |||
| 939 | static struct freq_attr *longhaul_attr[] = { | ||
| 940 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 941 | NULL, | ||
| 942 | }; | ||
| 943 | |||
| 944 | static struct cpufreq_driver longhaul_driver = { | 920 | static struct cpufreq_driver longhaul_driver = { |
| 945 | .verify = longhaul_verify, | 921 | .verify = cpufreq_generic_frequency_table_verify, |
| 946 | .target = longhaul_target, | 922 | .target = longhaul_target, |
| 947 | .get = longhaul_get, | 923 | .get = longhaul_get, |
| 948 | .init = longhaul_cpu_init, | 924 | .init = longhaul_cpu_init, |
| 949 | .exit = longhaul_cpu_exit, | 925 | .exit = cpufreq_generic_exit, |
| 950 | .name = "longhaul", | 926 | .name = "longhaul", |
| 951 | .attr = longhaul_attr, | 927 | .attr = cpufreq_generic_attr, |
| 952 | }; | 928 | }; |
| 953 | 929 | ||
| 954 | static const struct x86_cpu_id longhaul_id[] = { | 930 | static const struct x86_cpu_id longhaul_id[] = { |
diff --git a/drivers/cpufreq/longrun.c b/drivers/cpufreq/longrun.c index 5aa031612d53..074971b12635 100644 --- a/drivers/cpufreq/longrun.c +++ b/drivers/cpufreq/longrun.c | |||
| @@ -129,9 +129,7 @@ static int longrun_verify_policy(struct cpufreq_policy *policy) | |||
| 129 | return -EINVAL; | 129 | return -EINVAL; |
| 130 | 130 | ||
| 131 | policy->cpu = 0; | 131 | policy->cpu = 0; |
| 132 | cpufreq_verify_within_limits(policy, | 132 | cpufreq_verify_within_cpu_limits(policy); |
| 133 | policy->cpuinfo.min_freq, | ||
| 134 | policy->cpuinfo.max_freq); | ||
| 135 | 133 | ||
| 136 | if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && | 134 | if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && |
| 137 | (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) | 135 | (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) |
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c index 7bc3c44d34e2..2c8ec8e06449 100644 --- a/drivers/cpufreq/loongson2_cpufreq.c +++ b/drivers/cpufreq/loongson2_cpufreq.c | |||
| @@ -131,40 +131,24 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 131 | return ret; | 131 | return ret; |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | policy->cur = loongson2_cpufreq_get(policy->cpu); | 134 | return cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0); |
| 135 | |||
| 136 | cpufreq_frequency_table_get_attr(&loongson2_clockmod_table[0], | ||
| 137 | policy->cpu); | ||
| 138 | |||
| 139 | return cpufreq_frequency_table_cpuinfo(policy, | ||
| 140 | &loongson2_clockmod_table[0]); | ||
| 141 | } | ||
| 142 | |||
| 143 | static int loongson2_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 144 | { | ||
| 145 | return cpufreq_frequency_table_verify(policy, | ||
| 146 | &loongson2_clockmod_table[0]); | ||
| 147 | } | 135 | } |
| 148 | 136 | ||
| 149 | static int loongson2_cpufreq_exit(struct cpufreq_policy *policy) | 137 | static int loongson2_cpufreq_exit(struct cpufreq_policy *policy) |
| 150 | { | 138 | { |
| 139 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 151 | clk_put(cpuclk); | 140 | clk_put(cpuclk); |
| 152 | return 0; | 141 | return 0; |
| 153 | } | 142 | } |
| 154 | 143 | ||
| 155 | static struct freq_attr *loongson2_table_attr[] = { | ||
| 156 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 157 | NULL, | ||
| 158 | }; | ||
| 159 | |||
| 160 | static struct cpufreq_driver loongson2_cpufreq_driver = { | 144 | static struct cpufreq_driver loongson2_cpufreq_driver = { |
| 161 | .name = "loongson2", | 145 | .name = "loongson2", |
| 162 | .init = loongson2_cpufreq_cpu_init, | 146 | .init = loongson2_cpufreq_cpu_init, |
| 163 | .verify = loongson2_cpufreq_verify, | 147 | .verify = cpufreq_generic_frequency_table_verify, |
| 164 | .target = loongson2_cpufreq_target, | 148 | .target = loongson2_cpufreq_target, |
| 165 | .get = loongson2_cpufreq_get, | 149 | .get = loongson2_cpufreq_get, |
| 166 | .exit = loongson2_cpufreq_exit, | 150 | .exit = loongson2_cpufreq_exit, |
| 167 | .attr = loongson2_table_attr, | 151 | .attr = cpufreq_generic_attr, |
| 168 | }; | 152 | }; |
| 169 | 153 | ||
| 170 | static struct platform_device_id platform_device_ids[] = { | 154 | static struct platform_device_id platform_device_ids[] = { |
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c index 6168d77b296d..eb1e1766baed 100644 --- a/drivers/cpufreq/maple-cpufreq.c +++ b/drivers/cpufreq/maple-cpufreq.c | |||
| @@ -64,11 +64,6 @@ static struct cpufreq_frequency_table maple_cpu_freqs[] = { | |||
| 64 | {0, CPUFREQ_TABLE_END}, | 64 | {0, CPUFREQ_TABLE_END}, |
| 65 | }; | 65 | }; |
| 66 | 66 | ||
| 67 | static struct freq_attr *maple_cpu_freqs_attr[] = { | ||
| 68 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 69 | NULL, | ||
| 70 | }; | ||
| 71 | |||
| 72 | /* Power mode data is an array of the 32 bits PCR values to use for | 67 | /* Power mode data is an array of the 32 bits PCR values to use for |
| 73 | * the various frequencies, retrieved from the device-tree | 68 | * the various frequencies, retrieved from the device-tree |
| 74 | */ | 69 | */ |
| @@ -135,11 +130,6 @@ static int maple_scom_query_freq(void) | |||
| 135 | * Common interface to the cpufreq core | 130 | * Common interface to the cpufreq core |
| 136 | */ | 131 | */ |
| 137 | 132 | ||
| 138 | static int maple_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 139 | { | ||
| 140 | return cpufreq_frequency_table_verify(policy, maple_cpu_freqs); | ||
| 141 | } | ||
| 142 | |||
| 143 | static int maple_cpufreq_target(struct cpufreq_policy *policy, | 133 | static int maple_cpufreq_target(struct cpufreq_policy *policy, |
| 144 | unsigned int target_freq, unsigned int relation) | 134 | unsigned int target_freq, unsigned int relation) |
| 145 | { | 135 | { |
| @@ -175,27 +165,17 @@ static unsigned int maple_cpufreq_get_speed(unsigned int cpu) | |||
| 175 | 165 | ||
| 176 | static int maple_cpufreq_cpu_init(struct cpufreq_policy *policy) | 166 | static int maple_cpufreq_cpu_init(struct cpufreq_policy *policy) |
| 177 | { | 167 | { |
| 178 | policy->cpuinfo.transition_latency = 12000; | 168 | return cpufreq_generic_init(policy, maple_cpu_freqs, 12000); |
| 179 | policy->cur = maple_cpu_freqs[maple_scom_query_freq()].frequency; | ||
| 180 | /* secondary CPUs are tied to the primary one by the | ||
| 181 | * cpufreq core if in the secondary policy we tell it that | ||
| 182 | * it actually must be one policy together with all others. */ | ||
| 183 | cpumask_setall(policy->cpus); | ||
| 184 | cpufreq_frequency_table_get_attr(maple_cpu_freqs, policy->cpu); | ||
| 185 | |||
| 186 | return cpufreq_frequency_table_cpuinfo(policy, | ||
| 187 | maple_cpu_freqs); | ||
| 188 | } | 169 | } |
| 189 | 170 | ||
| 190 | |||
| 191 | static struct cpufreq_driver maple_cpufreq_driver = { | 171 | static struct cpufreq_driver maple_cpufreq_driver = { |
| 192 | .name = "maple", | 172 | .name = "maple", |
| 193 | .flags = CPUFREQ_CONST_LOOPS, | 173 | .flags = CPUFREQ_CONST_LOOPS, |
| 194 | .init = maple_cpufreq_cpu_init, | 174 | .init = maple_cpufreq_cpu_init, |
| 195 | .verify = maple_cpufreq_verify, | 175 | .verify = cpufreq_generic_frequency_table_verify, |
| 196 | .target = maple_cpufreq_target, | 176 | .target = maple_cpufreq_target, |
| 197 | .get = maple_cpufreq_get_speed, | 177 | .get = maple_cpufreq_get_speed, |
| 198 | .attr = maple_cpu_freqs_attr, | 178 | .attr = cpufreq_generic_attr, |
| 199 | }; | 179 | }; |
| 200 | 180 | ||
| 201 | static int __init maple_cpufreq_init(void) | 181 | static int __init maple_cpufreq_init(void) |
diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index 20190f56594f..ac552d090463 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c | |||
| @@ -40,13 +40,6 @@ static struct clk *mpu_clk; | |||
| 40 | static struct device *mpu_dev; | 40 | static struct device *mpu_dev; |
| 41 | static struct regulator *mpu_reg; | 41 | static struct regulator *mpu_reg; |
| 42 | 42 | ||
| 43 | static int omap_verify_speed(struct cpufreq_policy *policy) | ||
| 44 | { | ||
| 45 | if (!freq_table) | ||
| 46 | return -EINVAL; | ||
| 47 | return cpufreq_frequency_table_verify(policy, freq_table); | ||
| 48 | } | ||
| 49 | |||
| 50 | static unsigned int omap_getspeed(unsigned int cpu) | 43 | static unsigned int omap_getspeed(unsigned int cpu) |
| 51 | { | 44 | { |
| 52 | unsigned long rate; | 45 | unsigned long rate; |
| @@ -167,81 +160,52 @@ static inline void freq_table_free(void) | |||
| 167 | 160 | ||
| 168 | static int omap_cpu_init(struct cpufreq_policy *policy) | 161 | static int omap_cpu_init(struct cpufreq_policy *policy) |
| 169 | { | 162 | { |
| 170 | int result = 0; | 163 | int result; |
| 171 | 164 | ||
| 172 | mpu_clk = clk_get(NULL, "cpufreq_ck"); | 165 | mpu_clk = clk_get(NULL, "cpufreq_ck"); |
| 173 | if (IS_ERR(mpu_clk)) | 166 | if (IS_ERR(mpu_clk)) |
| 174 | return PTR_ERR(mpu_clk); | 167 | return PTR_ERR(mpu_clk); |
| 175 | 168 | ||
| 176 | if (policy->cpu >= NR_CPUS) { | 169 | if (!freq_table) { |
| 177 | result = -EINVAL; | ||
| 178 | goto fail_ck; | ||
| 179 | } | ||
| 180 | |||
| 181 | policy->cur = omap_getspeed(policy->cpu); | ||
| 182 | |||
| 183 | if (!freq_table) | ||
| 184 | result = dev_pm_opp_init_cpufreq_table(mpu_dev, &freq_table); | 170 | result = dev_pm_opp_init_cpufreq_table(mpu_dev, &freq_table); |
| 185 | 171 | if (result) { | |
| 186 | if (result) { | 172 | dev_err(mpu_dev, |
| 187 | dev_err(mpu_dev, "%s: cpu%d: failed creating freq table[%d]\n", | 173 | "%s: cpu%d: failed creating freq table[%d]\n", |
| 188 | __func__, policy->cpu, result); | 174 | __func__, policy->cpu, result); |
| 189 | goto fail_ck; | 175 | goto fail; |
| 176 | } | ||
| 190 | } | 177 | } |
| 191 | 178 | ||
| 192 | atomic_inc_return(&freq_table_users); | 179 | atomic_inc_return(&freq_table_users); |
| 193 | 180 | ||
| 194 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
| 195 | if (result) | ||
| 196 | goto fail_table; | ||
| 197 | |||
| 198 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | ||
| 199 | |||
| 200 | policy->cur = omap_getspeed(policy->cpu); | ||
| 201 | |||
| 202 | /* | ||
| 203 | * On OMAP SMP configuartion, both processors share the voltage | ||
| 204 | * and clock. So both CPUs needs to be scaled together and hence | ||
| 205 | * needs software co-ordination. Use cpufreq affected_cpus | ||
| 206 | * interface to handle this scenario. Additional is_smp() check | ||
| 207 | * is to keep SMP_ON_UP build working. | ||
| 208 | */ | ||
| 209 | if (is_smp()) | ||
| 210 | cpumask_setall(policy->cpus); | ||
| 211 | |||
| 212 | /* FIXME: what's the actual transition time? */ | 181 | /* FIXME: what's the actual transition time? */ |
| 213 | policy->cpuinfo.transition_latency = 300 * 1000; | 182 | result = cpufreq_generic_init(policy, freq_table, 300 * 1000); |
| 214 | 183 | if (!result) | |
| 215 | return 0; | 184 | return 0; |
| 216 | 185 | ||
| 217 | fail_table: | ||
| 218 | freq_table_free(); | 186 | freq_table_free(); |
| 219 | fail_ck: | 187 | fail: |
| 220 | clk_put(mpu_clk); | 188 | clk_put(mpu_clk); |
| 221 | return result; | 189 | return result; |
| 222 | } | 190 | } |
| 223 | 191 | ||
| 224 | static int omap_cpu_exit(struct cpufreq_policy *policy) | 192 | static int omap_cpu_exit(struct cpufreq_policy *policy) |
| 225 | { | 193 | { |
| 194 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 226 | freq_table_free(); | 195 | freq_table_free(); |
| 227 | clk_put(mpu_clk); | 196 | clk_put(mpu_clk); |
| 228 | return 0; | 197 | return 0; |
| 229 | } | 198 | } |
| 230 | 199 | ||
| 231 | static struct freq_attr *omap_cpufreq_attr[] = { | ||
| 232 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 233 | NULL, | ||
| 234 | }; | ||
| 235 | |||
| 236 | static struct cpufreq_driver omap_driver = { | 200 | static struct cpufreq_driver omap_driver = { |
| 237 | .flags = CPUFREQ_STICKY, | 201 | .flags = CPUFREQ_STICKY, |
| 238 | .verify = omap_verify_speed, | 202 | .verify = cpufreq_generic_frequency_table_verify, |
| 239 | .target = omap_target, | 203 | .target = omap_target, |
| 240 | .get = omap_getspeed, | 204 | .get = omap_getspeed, |
| 241 | .init = omap_cpu_init, | 205 | .init = omap_cpu_init, |
| 242 | .exit = omap_cpu_exit, | 206 | .exit = omap_cpu_exit, |
| 243 | .name = "omap", | 207 | .name = "omap", |
| 244 | .attr = omap_cpufreq_attr, | 208 | .attr = cpufreq_generic_attr, |
| 245 | }; | 209 | }; |
| 246 | 210 | ||
| 247 | static int omap_cpufreq_probe(struct platform_device *pdev) | 211 | static int omap_cpufreq_probe(struct platform_device *pdev) |
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c index 2f0a2a65c37f..6164c1cca504 100644 --- a/drivers/cpufreq/p4-clockmod.c +++ b/drivers/cpufreq/p4-clockmod.c | |||
| @@ -140,12 +140,6 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | 142 | ||
| 143 | static int cpufreq_p4_verify(struct cpufreq_policy *policy) | ||
| 144 | { | ||
| 145 | return cpufreq_frequency_table_verify(policy, &p4clockmod_table[0]); | ||
| 146 | } | ||
| 147 | |||
| 148 | |||
| 149 | static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c) | 143 | static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c) |
| 150 | { | 144 | { |
| 151 | if (c->x86 == 0x06) { | 145 | if (c->x86 == 0x06) { |
| @@ -230,25 +224,17 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy) | |||
| 230 | else | 224 | else |
| 231 | p4clockmod_table[i].frequency = (stock_freq * i)/8; | 225 | p4clockmod_table[i].frequency = (stock_freq * i)/8; |
| 232 | } | 226 | } |
| 233 | cpufreq_frequency_table_get_attr(p4clockmod_table, policy->cpu); | ||
| 234 | 227 | ||
| 235 | /* cpuinfo and default policy values */ | 228 | /* cpuinfo and default policy values */ |
| 236 | 229 | ||
| 237 | /* the transition latency is set to be 1 higher than the maximum | 230 | /* the transition latency is set to be 1 higher than the maximum |
| 238 | * transition latency of the ondemand governor */ | 231 | * transition latency of the ondemand governor */ |
| 239 | policy->cpuinfo.transition_latency = 10000001; | 232 | policy->cpuinfo.transition_latency = 10000001; |
| 240 | policy->cur = stock_freq; | ||
| 241 | 233 | ||
| 242 | return cpufreq_frequency_table_cpuinfo(policy, &p4clockmod_table[0]); | 234 | return cpufreq_table_validate_and_show(policy, &p4clockmod_table[0]); |
| 243 | } | 235 | } |
| 244 | 236 | ||
| 245 | 237 | ||
| 246 | static int cpufreq_p4_cpu_exit(struct cpufreq_policy *policy) | ||
| 247 | { | ||
| 248 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 249 | return 0; | ||
| 250 | } | ||
| 251 | |||
| 252 | static unsigned int cpufreq_p4_get(unsigned int cpu) | 238 | static unsigned int cpufreq_p4_get(unsigned int cpu) |
| 253 | { | 239 | { |
| 254 | u32 l, h; | 240 | u32 l, h; |
| @@ -267,19 +253,14 @@ static unsigned int cpufreq_p4_get(unsigned int cpu) | |||
| 267 | return stock_freq; | 253 | return stock_freq; |
| 268 | } | 254 | } |
| 269 | 255 | ||
| 270 | static struct freq_attr *p4clockmod_attr[] = { | ||
| 271 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 272 | NULL, | ||
| 273 | }; | ||
| 274 | |||
| 275 | static struct cpufreq_driver p4clockmod_driver = { | 256 | static struct cpufreq_driver p4clockmod_driver = { |
| 276 | .verify = cpufreq_p4_verify, | 257 | .verify = cpufreq_generic_frequency_table_verify, |
| 277 | .target = cpufreq_p4_target, | 258 | .target = cpufreq_p4_target, |
| 278 | .init = cpufreq_p4_cpu_init, | 259 | .init = cpufreq_p4_cpu_init, |
| 279 | .exit = cpufreq_p4_cpu_exit, | 260 | .exit = cpufreq_generic_exit, |
| 280 | .get = cpufreq_p4_get, | 261 | .get = cpufreq_p4_get, |
| 281 | .name = "p4-clockmod", | 262 | .name = "p4-clockmod", |
| 282 | .attr = p4clockmod_attr, | 263 | .attr = cpufreq_generic_attr, |
| 283 | }; | 264 | }; |
| 284 | 265 | ||
| 285 | static const struct x86_cpu_id cpufreq_p4_id[] = { | 266 | static const struct x86_cpu_id cpufreq_p4_id[] = { |
diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c index 534e43a60d1f..1cca332728c3 100644 --- a/drivers/cpufreq/pasemi-cpufreq.c +++ b/drivers/cpufreq/pasemi-cpufreq.c | |||
| @@ -69,11 +69,6 @@ static struct cpufreq_frequency_table pas_freqs[] = { | |||
| 69 | {0, CPUFREQ_TABLE_END}, | 69 | {0, CPUFREQ_TABLE_END}, |
| 70 | }; | 70 | }; |
| 71 | 71 | ||
| 72 | static struct freq_attr *pas_cpu_freqs_attr[] = { | ||
| 73 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 74 | NULL, | ||
| 75 | }; | ||
| 76 | |||
| 77 | /* | 72 | /* |
| 78 | * hardware specific functions | 73 | * hardware specific functions |
| 79 | */ | 74 | */ |
| @@ -209,22 +204,13 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 209 | pr_debug("%d: %d\n", i, pas_freqs[i].frequency); | 204 | pr_debug("%d: %d\n", i, pas_freqs[i].frequency); |
| 210 | } | 205 | } |
| 211 | 206 | ||
| 212 | policy->cpuinfo.transition_latency = get_gizmo_latency(); | ||
| 213 | |||
| 214 | cur_astate = get_cur_astate(policy->cpu); | 207 | cur_astate = get_cur_astate(policy->cpu); |
| 215 | pr_debug("current astate is at %d\n",cur_astate); | 208 | pr_debug("current astate is at %d\n",cur_astate); |
| 216 | 209 | ||
| 217 | policy->cur = pas_freqs[cur_astate].frequency; | 210 | policy->cur = pas_freqs[cur_astate].frequency; |
| 218 | cpumask_copy(policy->cpus, cpu_online_mask); | ||
| 219 | |||
| 220 | ppc_proc_freq = policy->cur * 1000ul; | 211 | ppc_proc_freq = policy->cur * 1000ul; |
| 221 | 212 | ||
| 222 | cpufreq_frequency_table_get_attr(pas_freqs, policy->cpu); | 213 | return cpufreq_generic_init(policy, pas_freqs, get_gizmo_latency()); |
| 223 | |||
| 224 | /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max | ||
| 225 | * are set correctly | ||
| 226 | */ | ||
| 227 | return cpufreq_frequency_table_cpuinfo(policy, pas_freqs); | ||
| 228 | 214 | ||
| 229 | out_unmap_sdcpwr: | 215 | out_unmap_sdcpwr: |
| 230 | iounmap(sdcpwr_mapbase); | 216 | iounmap(sdcpwr_mapbase); |
| @@ -253,11 +239,6 @@ static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy) | |||
| 253 | return 0; | 239 | return 0; |
| 254 | } | 240 | } |
| 255 | 241 | ||
| 256 | static int pas_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 257 | { | ||
| 258 | return cpufreq_frequency_table_verify(policy, pas_freqs); | ||
| 259 | } | ||
| 260 | |||
| 261 | static int pas_cpufreq_target(struct cpufreq_policy *policy, | 242 | static int pas_cpufreq_target(struct cpufreq_policy *policy, |
| 262 | unsigned int target_freq, | 243 | unsigned int target_freq, |
| 263 | unsigned int relation) | 244 | unsigned int relation) |
| @@ -300,9 +281,9 @@ static struct cpufreq_driver pas_cpufreq_driver = { | |||
| 300 | .flags = CPUFREQ_CONST_LOOPS, | 281 | .flags = CPUFREQ_CONST_LOOPS, |
| 301 | .init = pas_cpufreq_cpu_init, | 282 | .init = pas_cpufreq_cpu_init, |
| 302 | .exit = pas_cpufreq_cpu_exit, | 283 | .exit = pas_cpufreq_cpu_exit, |
| 303 | .verify = pas_cpufreq_verify, | 284 | .verify = cpufreq_generic_frequency_table_verify, |
| 304 | .target = pas_cpufreq_target, | 285 | .target = pas_cpufreq_target, |
| 305 | .attr = pas_cpu_freqs_attr, | 286 | .attr = cpufreq_generic_attr, |
| 306 | }; | 287 | }; |
| 307 | 288 | ||
| 308 | /* | 289 | /* |
diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c index d81c4e5ea0ad..ef663474a643 100644 --- a/drivers/cpufreq/pcc-cpufreq.c +++ b/drivers/cpufreq/pcc-cpufreq.c | |||
| @@ -111,8 +111,7 @@ static struct pcc_cpu __percpu *pcc_cpu_info; | |||
| 111 | 111 | ||
| 112 | static int pcc_cpufreq_verify(struct cpufreq_policy *policy) | 112 | static int pcc_cpufreq_verify(struct cpufreq_policy *policy) |
| 113 | { | 113 | { |
| 114 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 114 | cpufreq_verify_within_cpu_limits(policy); |
| 115 | policy->cpuinfo.max_freq); | ||
| 116 | return 0; | 115 | return 0; |
| 117 | } | 116 | } |
| 118 | 117 | ||
| @@ -560,13 +559,6 @@ static int pcc_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 560 | ioread32(&pcch_hdr->nominal) * 1000; | 559 | ioread32(&pcch_hdr->nominal) * 1000; |
| 561 | policy->min = policy->cpuinfo.min_freq = | 560 | policy->min = policy->cpuinfo.min_freq = |
| 562 | ioread32(&pcch_hdr->minimum_frequency) * 1000; | 561 | ioread32(&pcch_hdr->minimum_frequency) * 1000; |
| 563 | policy->cur = pcc_get_freq(cpu); | ||
| 564 | |||
| 565 | if (!policy->cur) { | ||
| 566 | pr_debug("init: Unable to get current CPU frequency\n"); | ||
| 567 | result = -EINVAL; | ||
| 568 | goto out; | ||
| 569 | } | ||
| 570 | 562 | ||
| 571 | pr_debug("init: policy->max is %d, policy->min is %d\n", | 563 | pr_debug("init: policy->max is %d, policy->min is %d\n", |
| 572 | policy->max, policy->min); | 564 | policy->max, policy->min); |
diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c index a096cd3fa23d..6eac1e230078 100644 --- a/drivers/cpufreq/pmac32-cpufreq.c +++ b/drivers/cpufreq/pmac32-cpufreq.c | |||
| @@ -86,11 +86,6 @@ static struct cpufreq_frequency_table pmac_cpu_freqs[] = { | |||
| 86 | {0, CPUFREQ_TABLE_END}, | 86 | {0, CPUFREQ_TABLE_END}, |
| 87 | }; | 87 | }; |
| 88 | 88 | ||
| 89 | static struct freq_attr* pmac_cpu_freqs_attr[] = { | ||
| 90 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 91 | NULL, | ||
| 92 | }; | ||
| 93 | |||
| 94 | static inline void local_delay(unsigned long ms) | 89 | static inline void local_delay(unsigned long ms) |
| 95 | { | 90 | { |
| 96 | if (no_schedule) | 91 | if (no_schedule) |
| @@ -378,11 +373,6 @@ static unsigned int pmac_cpufreq_get_speed(unsigned int cpu) | |||
| 378 | return cur_freq; | 373 | return cur_freq; |
| 379 | } | 374 | } |
| 380 | 375 | ||
| 381 | static int pmac_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 382 | { | ||
| 383 | return cpufreq_frequency_table_verify(policy, pmac_cpu_freqs); | ||
| 384 | } | ||
| 385 | |||
| 386 | static int pmac_cpufreq_target( struct cpufreq_policy *policy, | 376 | static int pmac_cpufreq_target( struct cpufreq_policy *policy, |
| 387 | unsigned int target_freq, | 377 | unsigned int target_freq, |
| 388 | unsigned int relation) | 378 | unsigned int relation) |
| @@ -402,14 +392,7 @@ static int pmac_cpufreq_target( struct cpufreq_policy *policy, | |||
| 402 | 392 | ||
| 403 | static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy) | 393 | static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy) |
| 404 | { | 394 | { |
| 405 | if (policy->cpu != 0) | 395 | return cpufreq_generic_init(policy, pmac_cpu_freqs, transition_latency); |
| 406 | return -ENODEV; | ||
| 407 | |||
| 408 | policy->cpuinfo.transition_latency = transition_latency; | ||
| 409 | policy->cur = cur_freq; | ||
| 410 | |||
| 411 | cpufreq_frequency_table_get_attr(pmac_cpu_freqs, policy->cpu); | ||
| 412 | return cpufreq_frequency_table_cpuinfo(policy, pmac_cpu_freqs); | ||
| 413 | } | 396 | } |
| 414 | 397 | ||
| 415 | static u32 read_gpio(struct device_node *np) | 398 | static u32 read_gpio(struct device_node *np) |
| @@ -469,14 +452,14 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy) | |||
| 469 | } | 452 | } |
| 470 | 453 | ||
| 471 | static struct cpufreq_driver pmac_cpufreq_driver = { | 454 | static struct cpufreq_driver pmac_cpufreq_driver = { |
| 472 | .verify = pmac_cpufreq_verify, | 455 | .verify = cpufreq_generic_frequency_table_verify, |
| 473 | .target = pmac_cpufreq_target, | 456 | .target = pmac_cpufreq_target, |
| 474 | .get = pmac_cpufreq_get_speed, | 457 | .get = pmac_cpufreq_get_speed, |
| 475 | .init = pmac_cpufreq_cpu_init, | 458 | .init = pmac_cpufreq_cpu_init, |
| 476 | .suspend = pmac_cpufreq_suspend, | 459 | .suspend = pmac_cpufreq_suspend, |
| 477 | .resume = pmac_cpufreq_resume, | 460 | .resume = pmac_cpufreq_resume, |
| 478 | .flags = CPUFREQ_PM_NO_WARN, | 461 | .flags = CPUFREQ_PM_NO_WARN, |
| 479 | .attr = pmac_cpu_freqs_attr, | 462 | .attr = cpufreq_generic_attr, |
| 480 | .name = "powermac", | 463 | .name = "powermac", |
| 481 | }; | 464 | }; |
| 482 | 465 | ||
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c index 3a51ad7e47c8..5261b92d768b 100644 --- a/drivers/cpufreq/pmac64-cpufreq.c +++ b/drivers/cpufreq/pmac64-cpufreq.c | |||
| @@ -70,11 +70,6 @@ static struct cpufreq_frequency_table g5_cpu_freqs[] = { | |||
| 70 | {0, CPUFREQ_TABLE_END}, | 70 | {0, CPUFREQ_TABLE_END}, |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| 73 | static struct freq_attr* g5_cpu_freqs_attr[] = { | ||
| 74 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 75 | NULL, | ||
| 76 | }; | ||
| 77 | |||
| 78 | /* Power mode data is an array of the 32 bits PCR values to use for | 73 | /* Power mode data is an array of the 32 bits PCR values to use for |
| 79 | * the various frequencies, retrieved from the device-tree | 74 | * the various frequencies, retrieved from the device-tree |
| 80 | */ | 75 | */ |
| @@ -142,7 +137,7 @@ static void g5_vdnap_switch_volt(int speed_mode) | |||
| 142 | pmf_call_one(pfunc_vdnap0_complete, &args); | 137 | pmf_call_one(pfunc_vdnap0_complete, &args); |
| 143 | if (done) | 138 | if (done) |
| 144 | break; | 139 | break; |
| 145 | msleep(1); | 140 | usleep_range(1000, 1000); |
| 146 | } | 141 | } |
| 147 | if (done == 0) | 142 | if (done == 0) |
| 148 | printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n"); | 143 | printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n"); |
| @@ -241,7 +236,7 @@ static void g5_pfunc_switch_volt(int speed_mode) | |||
| 241 | if (pfunc_cpu1_volt_low) | 236 | if (pfunc_cpu1_volt_low) |
| 242 | pmf_call_one(pfunc_cpu1_volt_low, NULL); | 237 | pmf_call_one(pfunc_cpu1_volt_low, NULL); |
| 243 | } | 238 | } |
| 244 | msleep(10); /* should be faster , to fix */ | 239 | usleep_range(10000, 10000); /* should be faster , to fix */ |
| 245 | } | 240 | } |
| 246 | 241 | ||
| 247 | /* | 242 | /* |
| @@ -286,7 +281,7 @@ static int g5_pfunc_switch_freq(int speed_mode) | |||
| 286 | pmf_call_one(pfunc_slewing_done, &args); | 281 | pmf_call_one(pfunc_slewing_done, &args); |
| 287 | if (done) | 282 | if (done) |
| 288 | break; | 283 | break; |
| 289 | msleep(1); | 284 | usleep_range(500, 500); |
| 290 | } | 285 | } |
| 291 | if (done == 0) | 286 | if (done == 0) |
| 292 | printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n"); | 287 | printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n"); |
| @@ -317,11 +312,6 @@ static int g5_pfunc_query_freq(void) | |||
| 317 | * Common interface to the cpufreq core | 312 | * Common interface to the cpufreq core |
| 318 | */ | 313 | */ |
| 319 | 314 | ||
| 320 | static int g5_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 321 | { | ||
| 322 | return cpufreq_frequency_table_verify(policy, g5_cpu_freqs); | ||
| 323 | } | ||
| 324 | |||
| 325 | static int g5_cpufreq_target(struct cpufreq_policy *policy, | 315 | static int g5_cpufreq_target(struct cpufreq_policy *policy, |
| 326 | unsigned int target_freq, unsigned int relation) | 316 | unsigned int target_freq, unsigned int relation) |
| 327 | { | 317 | { |
| @@ -357,27 +347,17 @@ static unsigned int g5_cpufreq_get_speed(unsigned int cpu) | |||
| 357 | 347 | ||
| 358 | static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy) | 348 | static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy) |
| 359 | { | 349 | { |
| 360 | policy->cpuinfo.transition_latency = transition_latency; | 350 | return cpufreq_generic_init(policy, g5_cpu_freqs, transition_latency); |
| 361 | policy->cur = g5_cpu_freqs[g5_query_freq()].frequency; | ||
| 362 | /* secondary CPUs are tied to the primary one by the | ||
| 363 | * cpufreq core if in the secondary policy we tell it that | ||
| 364 | * it actually must be one policy together with all others. */ | ||
| 365 | cpumask_copy(policy->cpus, cpu_online_mask); | ||
| 366 | cpufreq_frequency_table_get_attr(g5_cpu_freqs, policy->cpu); | ||
| 367 | |||
| 368 | return cpufreq_frequency_table_cpuinfo(policy, | ||
| 369 | g5_cpu_freqs); | ||
| 370 | } | 351 | } |
| 371 | 352 | ||
| 372 | |||
| 373 | static struct cpufreq_driver g5_cpufreq_driver = { | 353 | static struct cpufreq_driver g5_cpufreq_driver = { |
| 374 | .name = "powermac", | 354 | .name = "powermac", |
| 375 | .flags = CPUFREQ_CONST_LOOPS, | 355 | .flags = CPUFREQ_CONST_LOOPS, |
| 376 | .init = g5_cpufreq_cpu_init, | 356 | .init = g5_cpufreq_cpu_init, |
| 377 | .verify = g5_cpufreq_verify, | 357 | .verify = cpufreq_generic_frequency_table_verify, |
| 378 | .target = g5_cpufreq_target, | 358 | .target = g5_cpufreq_target, |
| 379 | .get = g5_cpufreq_get_speed, | 359 | .get = g5_cpufreq_get_speed, |
| 380 | .attr = g5_cpu_freqs_attr, | 360 | .attr = cpufreq_generic_attr, |
| 381 | }; | 361 | }; |
| 382 | 362 | ||
| 383 | 363 | ||
| @@ -397,7 +377,8 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpunode) | |||
| 397 | /* Check supported platforms */ | 377 | /* Check supported platforms */ |
| 398 | if (of_machine_is_compatible("PowerMac8,1") || | 378 | if (of_machine_is_compatible("PowerMac8,1") || |
| 399 | of_machine_is_compatible("PowerMac8,2") || | 379 | of_machine_is_compatible("PowerMac8,2") || |
| 400 | of_machine_is_compatible("PowerMac9,1")) | 380 | of_machine_is_compatible("PowerMac9,1") || |
| 381 | of_machine_is_compatible("PowerMac12,1")) | ||
| 401 | use_volts_smu = 1; | 382 | use_volts_smu = 1; |
| 402 | else if (of_machine_is_compatible("PowerMac11,2")) | 383 | else if (of_machine_is_compatible("PowerMac11,2")) |
| 403 | use_volts_vdnap = 1; | 384 | use_volts_vdnap = 1; |
| @@ -647,8 +628,10 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpunode) | |||
| 647 | g5_cpu_freqs[0].frequency = max_freq; | 628 | g5_cpu_freqs[0].frequency = max_freq; |
| 648 | g5_cpu_freqs[1].frequency = min_freq; | 629 | g5_cpu_freqs[1].frequency = min_freq; |
| 649 | 630 | ||
| 631 | /* Based on a measurement on Xserve G5, rounded up. */ | ||
| 632 | transition_latency = 10 * NSEC_PER_MSEC; | ||
| 633 | |||
| 650 | /* Set callbacks */ | 634 | /* Set callbacks */ |
| 651 | transition_latency = CPUFREQ_ETERNAL; | ||
| 652 | g5_switch_volt = g5_pfunc_switch_volt; | 635 | g5_switch_volt = g5_pfunc_switch_volt; |
| 653 | g5_switch_freq = g5_pfunc_switch_freq; | 636 | g5_switch_freq = g5_pfunc_switch_freq; |
| 654 | g5_query_freq = g5_pfunc_query_freq; | 637 | g5_query_freq = g5_pfunc_query_freq; |
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c index 85f1c8c25ddc..eda17024a34a 100644 --- a/drivers/cpufreq/powernow-k6.c +++ b/drivers/cpufreq/powernow-k6.c | |||
| @@ -105,19 +105,6 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy, | |||
| 105 | 105 | ||
| 106 | 106 | ||
| 107 | /** | 107 | /** |
| 108 | * powernow_k6_verify - verifies a new CPUfreq policy | ||
| 109 | * @policy: new policy | ||
| 110 | * | ||
| 111 | * Policy must be within lowest and highest possible CPU Frequency, | ||
| 112 | * and at least one possible state must be within min and max. | ||
| 113 | */ | ||
| 114 | static int powernow_k6_verify(struct cpufreq_policy *policy) | ||
| 115 | { | ||
| 116 | return cpufreq_frequency_table_verify(policy, &clock_ratio[0]); | ||
| 117 | } | ||
| 118 | |||
| 119 | |||
| 120 | /** | ||
| 121 | * powernow_k6_setpolicy - sets a new CPUFreq policy | 108 | * powernow_k6_setpolicy - sets a new CPUFreq policy |
| 122 | * @policy: new policy | 109 | * @policy: new policy |
| 123 | * @target_freq: the target frequency | 110 | * @target_freq: the target frequency |
| @@ -145,7 +132,6 @@ static int powernow_k6_target(struct cpufreq_policy *policy, | |||
| 145 | static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | 132 | static int powernow_k6_cpu_init(struct cpufreq_policy *policy) |
| 146 | { | 133 | { |
| 147 | unsigned int i, f; | 134 | unsigned int i, f; |
| 148 | int result; | ||
| 149 | 135 | ||
| 150 | if (policy->cpu != 0) | 136 | if (policy->cpu != 0) |
| 151 | return -ENODEV; | 137 | return -ENODEV; |
| @@ -165,15 +151,8 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | |||
| 165 | 151 | ||
| 166 | /* cpuinfo and default policy values */ | 152 | /* cpuinfo and default policy values */ |
| 167 | policy->cpuinfo.transition_latency = 200000; | 153 | policy->cpuinfo.transition_latency = 200000; |
| 168 | policy->cur = busfreq * max_multiplier; | ||
| 169 | |||
| 170 | result = cpufreq_frequency_table_cpuinfo(policy, clock_ratio); | ||
| 171 | if (result) | ||
| 172 | return result; | ||
| 173 | |||
| 174 | cpufreq_frequency_table_get_attr(clock_ratio, policy->cpu); | ||
| 175 | 154 | ||
| 176 | return 0; | 155 | return cpufreq_table_validate_and_show(policy, clock_ratio); |
| 177 | } | 156 | } |
| 178 | 157 | ||
| 179 | 158 | ||
| @@ -195,19 +174,14 @@ static unsigned int powernow_k6_get(unsigned int cpu) | |||
| 195 | return ret; | 174 | return ret; |
| 196 | } | 175 | } |
| 197 | 176 | ||
| 198 | static struct freq_attr *powernow_k6_attr[] = { | ||
| 199 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 200 | NULL, | ||
| 201 | }; | ||
| 202 | |||
| 203 | static struct cpufreq_driver powernow_k6_driver = { | 177 | static struct cpufreq_driver powernow_k6_driver = { |
| 204 | .verify = powernow_k6_verify, | 178 | .verify = cpufreq_generic_frequency_table_verify, |
| 205 | .target = powernow_k6_target, | 179 | .target = powernow_k6_target, |
| 206 | .init = powernow_k6_cpu_init, | 180 | .init = powernow_k6_cpu_init, |
| 207 | .exit = powernow_k6_cpu_exit, | 181 | .exit = powernow_k6_cpu_exit, |
| 208 | .get = powernow_k6_get, | 182 | .get = powernow_k6_get, |
| 209 | .name = "powernow-k6", | 183 | .name = "powernow-k6", |
| 210 | .attr = powernow_k6_attr, | 184 | .attr = cpufreq_generic_attr, |
| 211 | }; | 185 | }; |
| 212 | 186 | ||
| 213 | static const struct x86_cpu_id powernow_k6_ids[] = { | 187 | static const struct x86_cpu_id powernow_k6_ids[] = { |
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c index 14ce480be8ab..44d345bad6fb 100644 --- a/drivers/cpufreq/powernow-k7.c +++ b/drivers/cpufreq/powernow-k7.c | |||
| @@ -549,11 +549,6 @@ static int powernow_target(struct cpufreq_policy *policy, | |||
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | 551 | ||
| 552 | static int powernow_verify(struct cpufreq_policy *policy) | ||
| 553 | { | ||
| 554 | return cpufreq_frequency_table_verify(policy, powernow_table); | ||
| 555 | } | ||
| 556 | |||
| 557 | /* | 552 | /* |
| 558 | * We use the fact that the bus frequency is somehow | 553 | * We use the fact that the bus frequency is somehow |
| 559 | * a multiple of 100000/3 khz, then we compute sgtc according | 554 | * a multiple of 100000/3 khz, then we compute sgtc according |
| @@ -678,11 +673,7 @@ static int powernow_cpu_init(struct cpufreq_policy *policy) | |||
| 678 | policy->cpuinfo.transition_latency = | 673 | policy->cpuinfo.transition_latency = |
| 679 | cpufreq_scale(2000000UL, fsb, latency); | 674 | cpufreq_scale(2000000UL, fsb, latency); |
| 680 | 675 | ||
| 681 | policy->cur = powernow_get(0); | 676 | return cpufreq_table_validate_and_show(policy, powernow_table); |
| 682 | |||
| 683 | cpufreq_frequency_table_get_attr(powernow_table, policy->cpu); | ||
| 684 | |||
| 685 | return cpufreq_frequency_table_cpuinfo(policy, powernow_table); | ||
| 686 | } | 677 | } |
| 687 | 678 | ||
| 688 | static int powernow_cpu_exit(struct cpufreq_policy *policy) | 679 | static int powernow_cpu_exit(struct cpufreq_policy *policy) |
| @@ -701,13 +692,8 @@ static int powernow_cpu_exit(struct cpufreq_policy *policy) | |||
| 701 | return 0; | 692 | return 0; |
| 702 | } | 693 | } |
| 703 | 694 | ||
| 704 | static struct freq_attr *powernow_table_attr[] = { | ||
| 705 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 706 | NULL, | ||
| 707 | }; | ||
| 708 | |||
| 709 | static struct cpufreq_driver powernow_driver = { | 695 | static struct cpufreq_driver powernow_driver = { |
| 710 | .verify = powernow_verify, | 696 | .verify = cpufreq_generic_frequency_table_verify, |
| 711 | .target = powernow_target, | 697 | .target = powernow_target, |
| 712 | .get = powernow_get, | 698 | .get = powernow_get, |
| 713 | #ifdef CONFIG_X86_POWERNOW_K7_ACPI | 699 | #ifdef CONFIG_X86_POWERNOW_K7_ACPI |
| @@ -716,7 +702,7 @@ static struct cpufreq_driver powernow_driver = { | |||
| 716 | .init = powernow_cpu_init, | 702 | .init = powernow_cpu_init, |
| 717 | .exit = powernow_cpu_exit, | 703 | .exit = powernow_cpu_exit, |
| 718 | .name = "powernow-k7", | 704 | .name = "powernow-k7", |
| 719 | .attr = powernow_table_attr, | 705 | .attr = cpufreq_generic_attr, |
| 720 | }; | 706 | }; |
| 721 | 707 | ||
| 722 | static int __init powernow_init(void) | 708 | static int __init powernow_init(void) |
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c index 2344a9ed17f3..298beb742ebb 100644 --- a/drivers/cpufreq/powernow-k8.c +++ b/drivers/cpufreq/powernow-k8.c | |||
| @@ -1053,17 +1053,6 @@ static int powernowk8_target(struct cpufreq_policy *pol, | |||
| 1053 | return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta); | 1053 | return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta); |
| 1054 | } | 1054 | } |
| 1055 | 1055 | ||
| 1056 | /* Driver entry point to verify the policy and range of frequencies */ | ||
| 1057 | static int powernowk8_verify(struct cpufreq_policy *pol) | ||
| 1058 | { | ||
| 1059 | struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); | ||
| 1060 | |||
| 1061 | if (!data) | ||
| 1062 | return -EINVAL; | ||
| 1063 | |||
| 1064 | return cpufreq_frequency_table_verify(pol, data->powernow_table); | ||
| 1065 | } | ||
| 1066 | |||
| 1067 | struct init_on_cpu { | 1056 | struct init_on_cpu { |
| 1068 | struct powernow_k8_data *data; | 1057 | struct powernow_k8_data *data; |
| 1069 | int rc; | 1058 | int rc; |
| @@ -1152,11 +1141,8 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
| 1152 | cpumask_copy(pol->cpus, cpu_core_mask(pol->cpu)); | 1141 | cpumask_copy(pol->cpus, cpu_core_mask(pol->cpu)); |
| 1153 | data->available_cores = pol->cpus; | 1142 | data->available_cores = pol->cpus; |
| 1154 | 1143 | ||
| 1155 | pol->cur = find_khz_freq_from_fid(data->currfid); | ||
| 1156 | pr_debug("policy current frequency %d kHz\n", pol->cur); | ||
| 1157 | |||
| 1158 | /* min/max the cpu is capable of */ | 1144 | /* min/max the cpu is capable of */ |
| 1159 | if (cpufreq_frequency_table_cpuinfo(pol, data->powernow_table)) { | 1145 | if (cpufreq_table_validate_and_show(pol, data->powernow_table)) { |
| 1160 | printk(KERN_ERR FW_BUG PFX "invalid powernow_table\n"); | 1146 | printk(KERN_ERR FW_BUG PFX "invalid powernow_table\n"); |
| 1161 | powernow_k8_cpu_exit_acpi(data); | 1147 | powernow_k8_cpu_exit_acpi(data); |
| 1162 | kfree(data->powernow_table); | 1148 | kfree(data->powernow_table); |
| @@ -1164,8 +1150,6 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol) | |||
| 1164 | return -EINVAL; | 1150 | return -EINVAL; |
| 1165 | } | 1151 | } |
| 1166 | 1152 | ||
| 1167 | cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu); | ||
| 1168 | |||
| 1169 | pr_debug("cpu_init done, current fid 0x%x, vid 0x%x\n", | 1153 | pr_debug("cpu_init done, current fid 0x%x, vid 0x%x\n", |
| 1170 | data->currfid, data->currvid); | 1154 | data->currfid, data->currvid); |
| 1171 | 1155 | ||
| @@ -1227,20 +1211,15 @@ out: | |||
| 1227 | return khz; | 1211 | return khz; |
| 1228 | } | 1212 | } |
| 1229 | 1213 | ||
| 1230 | static struct freq_attr *powernow_k8_attr[] = { | ||
| 1231 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 1232 | NULL, | ||
| 1233 | }; | ||
| 1234 | |||
| 1235 | static struct cpufreq_driver cpufreq_amd64_driver = { | 1214 | static struct cpufreq_driver cpufreq_amd64_driver = { |
| 1236 | .verify = powernowk8_verify, | 1215 | .verify = cpufreq_generic_frequency_table_verify, |
| 1237 | .target = powernowk8_target, | 1216 | .target = powernowk8_target, |
| 1238 | .bios_limit = acpi_processor_get_bios_limit, | 1217 | .bios_limit = acpi_processor_get_bios_limit, |
| 1239 | .init = powernowk8_cpu_init, | 1218 | .init = powernowk8_cpu_init, |
| 1240 | .exit = powernowk8_cpu_exit, | 1219 | .exit = powernowk8_cpu_exit, |
| 1241 | .get = powernowk8_get, | 1220 | .get = powernowk8_get, |
| 1242 | .name = "powernow-k8", | 1221 | .name = "powernow-k8", |
| 1243 | .attr = powernow_k8_attr, | 1222 | .attr = cpufreq_generic_attr, |
| 1244 | }; | 1223 | }; |
| 1245 | 1224 | ||
| 1246 | static void __request_acpi_cpufreq(void) | 1225 | static void __request_acpi_cpufreq(void) |
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c index 60e81d524ea8..a0f562ca292d 100644 --- a/drivers/cpufreq/ppc-corenet-cpufreq.c +++ b/drivers/cpufreq/ppc-corenet-cpufreq.c | |||
| @@ -202,7 +202,7 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 202 | table[i].frequency = CPUFREQ_TABLE_END; | 202 | table[i].frequency = CPUFREQ_TABLE_END; |
| 203 | 203 | ||
| 204 | /* set the min and max frequency properly */ | 204 | /* set the min and max frequency properly */ |
| 205 | ret = cpufreq_frequency_table_cpuinfo(policy, table); | 205 | ret = cpufreq_table_validate_and_show(policy, table); |
| 206 | if (ret) { | 206 | if (ret) { |
| 207 | pr_err("invalid frequency table: %d\n", ret); | 207 | pr_err("invalid frequency table: %d\n", ret); |
| 208 | goto err_nomem1; | 208 | goto err_nomem1; |
| @@ -217,9 +217,6 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 217 | per_cpu(cpu_data, i) = data; | 217 | per_cpu(cpu_data, i) = data; |
| 218 | 218 | ||
| 219 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 219 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
| 220 | policy->cur = corenet_cpufreq_get_speed(policy->cpu); | ||
| 221 | |||
| 222 | cpufreq_frequency_table_get_attr(table, cpu); | ||
| 223 | of_node_put(np); | 220 | of_node_put(np); |
| 224 | 221 | ||
| 225 | return 0; | 222 | return 0; |
| @@ -253,14 +250,6 @@ static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy) | |||
| 253 | return 0; | 250 | return 0; |
| 254 | } | 251 | } |
| 255 | 252 | ||
| 256 | static int corenet_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 257 | { | ||
| 258 | struct cpufreq_frequency_table *table = | ||
| 259 | per_cpu(cpu_data, policy->cpu)->table; | ||
| 260 | |||
| 261 | return cpufreq_frequency_table_verify(policy, table); | ||
| 262 | } | ||
| 263 | |||
| 264 | static int corenet_cpufreq_target(struct cpufreq_policy *policy, | 253 | static int corenet_cpufreq_target(struct cpufreq_policy *policy, |
| 265 | unsigned int target_freq, unsigned int relation) | 254 | unsigned int target_freq, unsigned int relation) |
| 266 | { | 255 | { |
| @@ -293,20 +282,15 @@ static int corenet_cpufreq_target(struct cpufreq_policy *policy, | |||
| 293 | return ret; | 282 | return ret; |
| 294 | } | 283 | } |
| 295 | 284 | ||
| 296 | static struct freq_attr *corenet_cpufreq_attr[] = { | ||
| 297 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 298 | NULL, | ||
| 299 | }; | ||
| 300 | |||
| 301 | static struct cpufreq_driver ppc_corenet_cpufreq_driver = { | 285 | static struct cpufreq_driver ppc_corenet_cpufreq_driver = { |
| 302 | .name = "ppc_cpufreq", | 286 | .name = "ppc_cpufreq", |
| 303 | .flags = CPUFREQ_CONST_LOOPS, | 287 | .flags = CPUFREQ_CONST_LOOPS, |
| 304 | .init = corenet_cpufreq_cpu_init, | 288 | .init = corenet_cpufreq_cpu_init, |
| 305 | .exit = __exit_p(corenet_cpufreq_cpu_exit), | 289 | .exit = __exit_p(corenet_cpufreq_cpu_exit), |
| 306 | .verify = corenet_cpufreq_verify, | 290 | .verify = cpufreq_generic_frequency_table_verify, |
| 307 | .target = corenet_cpufreq_target, | 291 | .target = corenet_cpufreq_target, |
| 308 | .get = corenet_cpufreq_get_speed, | 292 | .get = corenet_cpufreq_get_speed, |
| 309 | .attr = corenet_cpufreq_attr, | 293 | .attr = cpufreq_generic_attr, |
| 310 | }; | 294 | }; |
| 311 | 295 | ||
| 312 | static const struct of_device_id node_matches[] __initdata = { | 296 | static const struct of_device_id node_matches[] __initdata = { |
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c index 2e448f0bbdc5..38540d1f5939 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq.c | |||
| @@ -123,22 +123,9 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 123 | cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu)); | 123 | cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu)); |
| 124 | #endif | 124 | #endif |
| 125 | 125 | ||
| 126 | cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu); | ||
| 127 | |||
| 128 | /* this ensures that policy->cpuinfo_min | 126 | /* this ensures that policy->cpuinfo_min |
| 129 | * and policy->cpuinfo_max are set correctly */ | 127 | * and policy->cpuinfo_max are set correctly */ |
| 130 | return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs); | 128 | return cpufreq_table_validate_and_show(policy, cbe_freqs); |
| 131 | } | ||
| 132 | |||
| 133 | static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy) | ||
| 134 | { | ||
| 135 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 136 | return 0; | ||
| 137 | } | ||
| 138 | |||
| 139 | static int cbe_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 140 | { | ||
| 141 | return cpufreq_frequency_table_verify(policy, cbe_freqs); | ||
| 142 | } | 129 | } |
| 143 | 130 | ||
| 144 | static int cbe_cpufreq_target(struct cpufreq_policy *policy, | 131 | static int cbe_cpufreq_target(struct cpufreq_policy *policy, |
| @@ -176,10 +163,10 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy, | |||
| 176 | } | 163 | } |
| 177 | 164 | ||
| 178 | static struct cpufreq_driver cbe_cpufreq_driver = { | 165 | static struct cpufreq_driver cbe_cpufreq_driver = { |
| 179 | .verify = cbe_cpufreq_verify, | 166 | .verify = cpufreq_generic_frequency_table_verify, |
| 180 | .target = cbe_cpufreq_target, | 167 | .target = cbe_cpufreq_target, |
| 181 | .init = cbe_cpufreq_cpu_init, | 168 | .init = cbe_cpufreq_cpu_init, |
| 182 | .exit = cbe_cpufreq_cpu_exit, | 169 | .exit = cpufreq_generic_exit, |
| 183 | .name = "cbe-cpufreq", | 170 | .name = "cbe-cpufreq", |
| 184 | .flags = CPUFREQ_CONST_LOOPS, | 171 | .flags = CPUFREQ_CONST_LOOPS, |
| 185 | }; | 172 | }; |
diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c index 8749eaf18793..29aca574317b 100644 --- a/drivers/cpufreq/pxa2xx-cpufreq.c +++ b/drivers/cpufreq/pxa2xx-cpufreq.c | |||
| @@ -262,23 +262,6 @@ static u32 mdrefr_dri(unsigned int freq) | |||
| 262 | return (interval - (cpu_is_pxa27x() ? 31 : 0)) / 32; | 262 | return (interval - (cpu_is_pxa27x() ? 31 : 0)) / 32; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | /* find a valid frequency point */ | ||
| 266 | static int pxa_verify_policy(struct cpufreq_policy *policy) | ||
| 267 | { | ||
| 268 | struct cpufreq_frequency_table *pxa_freqs_table; | ||
| 269 | pxa_freqs_t *pxa_freqs; | ||
| 270 | int ret; | ||
| 271 | |||
| 272 | find_freq_tables(&pxa_freqs_table, &pxa_freqs); | ||
| 273 | ret = cpufreq_frequency_table_verify(policy, pxa_freqs_table); | ||
| 274 | |||
| 275 | if (freq_debug) | ||
| 276 | pr_debug("Verified CPU policy: %dKhz min to %dKhz max\n", | ||
| 277 | policy->min, policy->max); | ||
| 278 | |||
| 279 | return ret; | ||
| 280 | } | ||
| 281 | |||
| 282 | static unsigned int pxa_cpufreq_get(unsigned int cpu) | 265 | static unsigned int pxa_cpufreq_get(unsigned int cpu) |
| 283 | { | 266 | { |
| 284 | return get_clk_frequency_khz(0); | 267 | return get_clk_frequency_khz(0); |
| @@ -414,8 +397,6 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
| 414 | 397 | ||
| 415 | /* set default policy and cpuinfo */ | 398 | /* set default policy and cpuinfo */ |
| 416 | policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ | 399 | policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ |
| 417 | policy->cur = get_clk_frequency_khz(0); /* current freq */ | ||
| 418 | policy->min = policy->max = policy->cur; | ||
| 419 | 400 | ||
| 420 | /* Generate pxa25x the run cpufreq_frequency_table struct */ | 401 | /* Generate pxa25x the run cpufreq_frequency_table struct */ |
| 421 | for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) { | 402 | for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) { |
| @@ -453,10 +434,12 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
| 453 | find_freq_tables(&pxa255_freq_table, &pxa255_freqs); | 434 | find_freq_tables(&pxa255_freq_table, &pxa255_freqs); |
| 454 | pr_info("PXA255 cpufreq using %s frequency table\n", | 435 | pr_info("PXA255 cpufreq using %s frequency table\n", |
| 455 | pxa255_turbo_table ? "turbo" : "run"); | 436 | pxa255_turbo_table ? "turbo" : "run"); |
| 456 | cpufreq_frequency_table_cpuinfo(policy, pxa255_freq_table); | 437 | |
| 438 | cpufreq_table_validate_and_show(policy, pxa255_freq_table); | ||
| 439 | } | ||
| 440 | else if (cpu_is_pxa27x()) { | ||
| 441 | cpufreq_table_validate_and_show(policy, pxa27x_freq_table); | ||
| 457 | } | 442 | } |
| 458 | else if (cpu_is_pxa27x()) | ||
| 459 | cpufreq_frequency_table_cpuinfo(policy, pxa27x_freq_table); | ||
| 460 | 443 | ||
| 461 | printk(KERN_INFO "PXA CPU frequency change support initialized\n"); | 444 | printk(KERN_INFO "PXA CPU frequency change support initialized\n"); |
| 462 | 445 | ||
| @@ -464,9 +447,10 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
| 464 | } | 447 | } |
| 465 | 448 | ||
| 466 | static struct cpufreq_driver pxa_cpufreq_driver = { | 449 | static struct cpufreq_driver pxa_cpufreq_driver = { |
| 467 | .verify = pxa_verify_policy, | 450 | .verify = cpufreq_generic_frequency_table_verify, |
| 468 | .target = pxa_set_target, | 451 | .target = pxa_set_target, |
| 469 | .init = pxa_cpufreq_init, | 452 | .init = pxa_cpufreq_init, |
| 453 | .exit = cpufreq_generic_exit, | ||
| 470 | .get = pxa_cpufreq_get, | 454 | .get = pxa_cpufreq_get, |
| 471 | .name = "PXA2xx", | 455 | .name = "PXA2xx", |
| 472 | }; | 456 | }; |
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c index d26306fb00d2..47fbee49d6e5 100644 --- a/drivers/cpufreq/pxa3xx-cpufreq.c +++ b/drivers/cpufreq/pxa3xx-cpufreq.c | |||
| @@ -108,7 +108,7 @@ static int setup_freqs_table(struct cpufreq_policy *policy, | |||
| 108 | pxa3xx_freqs_num = num; | 108 | pxa3xx_freqs_num = num; |
| 109 | pxa3xx_freqs_table = table; | 109 | pxa3xx_freqs_table = table; |
| 110 | 110 | ||
| 111 | return cpufreq_frequency_table_cpuinfo(policy, table); | 111 | return cpufreq_table_validate_and_show(policy, table); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | static void __update_core_freq(struct pxa3xx_freq_info *info) | 114 | static void __update_core_freq(struct pxa3xx_freq_info *info) |
| @@ -150,11 +150,6 @@ static void __update_bus_freq(struct pxa3xx_freq_info *info) | |||
| 150 | cpu_relax(); | 150 | cpu_relax(); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | static int pxa3xx_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 154 | { | ||
| 155 | return cpufreq_frequency_table_verify(policy, pxa3xx_freqs_table); | ||
| 156 | } | ||
| 157 | |||
| 158 | static unsigned int pxa3xx_cpufreq_get(unsigned int cpu) | 153 | static unsigned int pxa3xx_cpufreq_get(unsigned int cpu) |
| 159 | { | 154 | { |
| 160 | return pxa3xx_get_clk_frequency_khz(0); | 155 | return pxa3xx_get_clk_frequency_khz(0); |
| @@ -206,11 +201,10 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy) | |||
| 206 | int ret = -EINVAL; | 201 | int ret = -EINVAL; |
| 207 | 202 | ||
| 208 | /* set default policy and cpuinfo */ | 203 | /* set default policy and cpuinfo */ |
| 209 | policy->cpuinfo.min_freq = 104000; | 204 | policy->min = policy->cpuinfo.min_freq = 104000; |
| 210 | policy->cpuinfo.max_freq = (cpu_is_pxa320()) ? 806000 : 624000; | 205 | policy->max = policy->cpuinfo.max_freq = |
| 206 | (cpu_is_pxa320()) ? 806000 : 624000; | ||
| 211 | policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ | 207 | policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ |
| 212 | policy->max = pxa3xx_get_clk_frequency_khz(0); | ||
| 213 | policy->cur = policy->min = policy->max; | ||
| 214 | 208 | ||
| 215 | if (cpu_is_pxa300() || cpu_is_pxa310()) | 209 | if (cpu_is_pxa300() || cpu_is_pxa310()) |
| 216 | ret = setup_freqs_table(policy, pxa300_freqs, | 210 | ret = setup_freqs_table(policy, pxa300_freqs, |
| @@ -230,9 +224,10 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy) | |||
| 230 | } | 224 | } |
| 231 | 225 | ||
| 232 | static struct cpufreq_driver pxa3xx_cpufreq_driver = { | 226 | static struct cpufreq_driver pxa3xx_cpufreq_driver = { |
| 233 | .verify = pxa3xx_cpufreq_verify, | 227 | .verify = cpufreq_generic_frequency_table_verify, |
| 234 | .target = pxa3xx_cpufreq_set, | 228 | .target = pxa3xx_cpufreq_set, |
| 235 | .init = pxa3xx_cpufreq_init, | 229 | .init = pxa3xx_cpufreq_init, |
| 230 | .exit = cpufreq_generic_exit, | ||
| 236 | .get = pxa3xx_cpufreq_get, | 231 | .get = pxa3xx_cpufreq_get, |
| 237 | .name = "pxa3xx-cpufreq", | 232 | .name = "pxa3xx-cpufreq", |
| 238 | }; | 233 | }; |
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c index 22dcb81ef9d0..26a35d137157 100644 --- a/drivers/cpufreq/s3c2416-cpufreq.c +++ b/drivers/cpufreq/s3c2416-cpufreq.c | |||
| @@ -87,16 +87,6 @@ static struct cpufreq_frequency_table s3c2450_freq_table[] = { | |||
| 87 | { 0, CPUFREQ_TABLE_END }, | 87 | { 0, CPUFREQ_TABLE_END }, |
| 88 | }; | 88 | }; |
| 89 | 89 | ||
| 90 | static int s3c2416_cpufreq_verify_speed(struct cpufreq_policy *policy) | ||
| 91 | { | ||
| 92 | struct s3c2416_data *s3c_freq = &s3c2416_cpufreq; | ||
| 93 | |||
| 94 | if (policy->cpu != 0) | ||
| 95 | return -EINVAL; | ||
| 96 | |||
| 97 | return cpufreq_frequency_table_verify(policy, s3c_freq->freq_table); | ||
| 98 | } | ||
| 99 | |||
| 100 | static unsigned int s3c2416_cpufreq_get_speed(unsigned int cpu) | 90 | static unsigned int s3c2416_cpufreq_get_speed(unsigned int cpu) |
| 101 | { | 91 | { |
| 102 | struct s3c2416_data *s3c_freq = &s3c2416_cpufreq; | 92 | struct s3c2416_data *s3c_freq = &s3c2416_cpufreq; |
| @@ -486,20 +476,14 @@ static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
| 486 | freq++; | 476 | freq++; |
| 487 | } | 477 | } |
| 488 | 478 | ||
| 489 | policy->cur = clk_get_rate(s3c_freq->armclk) / 1000; | ||
| 490 | |||
| 491 | /* Datasheet says PLL stabalisation time must be at least 300us, | 479 | /* Datasheet says PLL stabalisation time must be at least 300us, |
| 492 | * so but add some fudge. (reference in LOCKCON0 register description) | 480 | * so but add some fudge. (reference in LOCKCON0 register description) |
| 493 | */ | 481 | */ |
| 494 | policy->cpuinfo.transition_latency = (500 * 1000) + | 482 | ret = cpufreq_generic_init(policy, s3c_freq->freq_table, |
| 495 | s3c_freq->regulator_latency; | 483 | (500 * 1000) + s3c_freq->regulator_latency); |
| 496 | |||
| 497 | ret = cpufreq_frequency_table_cpuinfo(policy, s3c_freq->freq_table); | ||
| 498 | if (ret) | 484 | if (ret) |
| 499 | goto err_freq_table; | 485 | goto err_freq_table; |
| 500 | 486 | ||
| 501 | cpufreq_frequency_table_get_attr(s3c_freq->freq_table, 0); | ||
| 502 | |||
| 503 | register_reboot_notifier(&s3c2416_cpufreq_reboot_notifier); | 487 | register_reboot_notifier(&s3c2416_cpufreq_reboot_notifier); |
| 504 | 488 | ||
| 505 | return 0; | 489 | return 0; |
| @@ -518,19 +502,14 @@ err_hclk: | |||
| 518 | return ret; | 502 | return ret; |
| 519 | } | 503 | } |
| 520 | 504 | ||
| 521 | static struct freq_attr *s3c2416_cpufreq_attr[] = { | ||
| 522 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 523 | NULL, | ||
| 524 | }; | ||
| 525 | |||
| 526 | static struct cpufreq_driver s3c2416_cpufreq_driver = { | 505 | static struct cpufreq_driver s3c2416_cpufreq_driver = { |
| 527 | .flags = 0, | 506 | .flags = 0, |
| 528 | .verify = s3c2416_cpufreq_verify_speed, | 507 | .verify = cpufreq_generic_frequency_table_verify, |
| 529 | .target = s3c2416_cpufreq_set_target, | 508 | .target = s3c2416_cpufreq_set_target, |
| 530 | .get = s3c2416_cpufreq_get_speed, | 509 | .get = s3c2416_cpufreq_get_speed, |
| 531 | .init = s3c2416_cpufreq_driver_init, | 510 | .init = s3c2416_cpufreq_driver_init, |
| 532 | .name = "s3c2416", | 511 | .name = "s3c2416", |
| 533 | .attr = s3c2416_cpufreq_attr, | 512 | .attr = cpufreq_generic_attr, |
| 534 | }; | 513 | }; |
| 535 | 514 | ||
| 536 | static int __init s3c2416_cpufreq_init(void) | 515 | static int __init s3c2416_cpufreq_init(void) |
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c index b0f343fcb7ee..485088253358 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq.c +++ b/drivers/cpufreq/s3c24xx-cpufreq.c | |||
| @@ -373,23 +373,7 @@ struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name) | |||
| 373 | 373 | ||
| 374 | static int s3c_cpufreq_init(struct cpufreq_policy *policy) | 374 | static int s3c_cpufreq_init(struct cpufreq_policy *policy) |
| 375 | { | 375 | { |
| 376 | printk(KERN_INFO "%s: initialising policy %p\n", __func__, policy); | 376 | return cpufreq_generic_init(policy, ftab, cpu_cur.info->latency); |
| 377 | |||
| 378 | if (policy->cpu != 0) | ||
| 379 | return -EINVAL; | ||
| 380 | |||
| 381 | policy->cur = s3c_cpufreq_get(0); | ||
| 382 | policy->min = policy->cpuinfo.min_freq = 0; | ||
| 383 | policy->max = policy->cpuinfo.max_freq = cpu_cur.info->max.fclk / 1000; | ||
| 384 | policy->governor = CPUFREQ_DEFAULT_GOVERNOR; | ||
| 385 | |||
| 386 | /* feed the latency information from the cpu driver */ | ||
| 387 | policy->cpuinfo.transition_latency = cpu_cur.info->latency; | ||
| 388 | |||
| 389 | if (ftab) | ||
| 390 | cpufreq_frequency_table_cpuinfo(policy, ftab); | ||
| 391 | |||
| 392 | return 0; | ||
| 393 | } | 377 | } |
| 394 | 378 | ||
| 395 | static int __init s3c_cpufreq_initclks(void) | 379 | static int __init s3c_cpufreq_initclks(void) |
| @@ -416,14 +400,6 @@ static int __init s3c_cpufreq_initclks(void) | |||
| 416 | return 0; | 400 | return 0; |
| 417 | } | 401 | } |
| 418 | 402 | ||
| 419 | static int s3c_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 420 | { | ||
| 421 | if (policy->cpu != 0) | ||
| 422 | return -EINVAL; | ||
| 423 | |||
| 424 | return 0; | ||
| 425 | } | ||
| 426 | |||
| 427 | #ifdef CONFIG_PM | 403 | #ifdef CONFIG_PM |
| 428 | static struct cpufreq_frequency_table suspend_pll; | 404 | static struct cpufreq_frequency_table suspend_pll; |
| 429 | static unsigned int suspend_freq; | 405 | static unsigned int suspend_freq; |
| @@ -473,7 +449,6 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy) | |||
| 473 | 449 | ||
| 474 | static struct cpufreq_driver s3c24xx_driver = { | 450 | static struct cpufreq_driver s3c24xx_driver = { |
| 475 | .flags = CPUFREQ_STICKY, | 451 | .flags = CPUFREQ_STICKY, |
| 476 | .verify = s3c_cpufreq_verify, | ||
| 477 | .target = s3c_cpufreq_target, | 452 | .target = s3c_cpufreq_target, |
| 478 | .get = s3c_cpufreq_get, | 453 | .get = s3c_cpufreq_get, |
| 479 | .init = s3c_cpufreq_init, | 454 | .init = s3c_cpufreq_init, |
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index 15631f92ab7d..461617332033 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c | |||
| @@ -54,14 +54,6 @@ static struct cpufreq_frequency_table s3c64xx_freq_table[] = { | |||
| 54 | }; | 54 | }; |
| 55 | #endif | 55 | #endif |
| 56 | 56 | ||
| 57 | static int s3c64xx_cpufreq_verify_speed(struct cpufreq_policy *policy) | ||
| 58 | { | ||
| 59 | if (policy->cpu != 0) | ||
| 60 | return -EINVAL; | ||
| 61 | |||
| 62 | return cpufreq_frequency_table_verify(policy, s3c64xx_freq_table); | ||
| 63 | } | ||
| 64 | |||
| 65 | static unsigned int s3c64xx_cpufreq_get_speed(unsigned int cpu) | 57 | static unsigned int s3c64xx_cpufreq_get_speed(unsigned int cpu) |
| 66 | { | 58 | { |
| 67 | if (cpu != 0) | 59 | if (cpu != 0) |
| @@ -243,15 +235,12 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
| 243 | freq++; | 235 | freq++; |
| 244 | } | 236 | } |
| 245 | 237 | ||
| 246 | policy->cur = clk_get_rate(armclk) / 1000; | ||
| 247 | |||
| 248 | /* Datasheet says PLL stabalisation time (if we were to use | 238 | /* Datasheet says PLL stabalisation time (if we were to use |
| 249 | * the PLLs, which we don't currently) is ~300us worst case, | 239 | * the PLLs, which we don't currently) is ~300us worst case, |
| 250 | * but add some fudge. | 240 | * but add some fudge. |
| 251 | */ | 241 | */ |
| 252 | policy->cpuinfo.transition_latency = (500 * 1000) + regulator_latency; | 242 | ret = cpufreq_generic_init(policy, s3c64xx_freq_table, |
| 253 | 243 | (500 * 1000) + regulator_latency); | |
| 254 | ret = cpufreq_frequency_table_cpuinfo(policy, s3c64xx_freq_table); | ||
| 255 | if (ret != 0) { | 244 | if (ret != 0) { |
| 256 | pr_err("Failed to configure frequency table: %d\n", | 245 | pr_err("Failed to configure frequency table: %d\n", |
| 257 | ret); | 246 | ret); |
| @@ -264,7 +253,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
| 264 | 253 | ||
| 265 | static struct cpufreq_driver s3c64xx_cpufreq_driver = { | 254 | static struct cpufreq_driver s3c64xx_cpufreq_driver = { |
| 266 | .flags = 0, | 255 | .flags = 0, |
| 267 | .verify = s3c64xx_cpufreq_verify_speed, | 256 | .verify = cpufreq_generic_frequency_table_verify, |
| 268 | .target = s3c64xx_cpufreq_set_target, | 257 | .target = s3c64xx_cpufreq_set_target, |
| 269 | .get = s3c64xx_cpufreq_get_speed, | 258 | .get = s3c64xx_cpufreq_get_speed, |
| 270 | .init = s3c64xx_cpufreq_driver_init, | 259 | .init = s3c64xx_cpufreq_driver_init, |
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c index 5c7757073793..600b4f472e28 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c | |||
| @@ -174,14 +174,6 @@ static void s5pv210_set_refresh(enum s5pv210_dmc_port ch, unsigned long freq) | |||
| 174 | __raw_writel(tmp1, reg); | 174 | __raw_writel(tmp1, reg); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | static int s5pv210_verify_speed(struct cpufreq_policy *policy) | ||
| 178 | { | ||
| 179 | if (policy->cpu) | ||
| 180 | return -EINVAL; | ||
| 181 | |||
| 182 | return cpufreq_frequency_table_verify(policy, s5pv210_freq_table); | ||
| 183 | } | ||
| 184 | |||
| 185 | static unsigned int s5pv210_getspeed(unsigned int cpu) | 177 | static unsigned int s5pv210_getspeed(unsigned int cpu) |
| 186 | { | 178 | { |
| 187 | if (cpu) | 179 | if (cpu) |
| @@ -551,13 +543,7 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) | |||
| 551 | s5pv210_dram_conf[1].refresh = (__raw_readl(S5P_VA_DMC1 + 0x30) * 1000); | 543 | s5pv210_dram_conf[1].refresh = (__raw_readl(S5P_VA_DMC1 + 0x30) * 1000); |
| 552 | s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk); | 544 | s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk); |
| 553 | 545 | ||
| 554 | policy->cur = policy->min = policy->max = s5pv210_getspeed(0); | 546 | return cpufreq_generic_init(policy, s5pv210_freq_table, 40000); |
| 555 | |||
| 556 | cpufreq_frequency_table_get_attr(s5pv210_freq_table, policy->cpu); | ||
| 557 | |||
| 558 | policy->cpuinfo.transition_latency = 40000; | ||
| 559 | |||
| 560 | return cpufreq_frequency_table_cpuinfo(policy, s5pv210_freq_table); | ||
| 561 | 547 | ||
| 562 | out_dmc1: | 548 | out_dmc1: |
| 563 | clk_put(dmc0_clk); | 549 | clk_put(dmc0_clk); |
| @@ -605,7 +591,7 @@ static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this, | |||
| 605 | 591 | ||
| 606 | static struct cpufreq_driver s5pv210_driver = { | 592 | static struct cpufreq_driver s5pv210_driver = { |
| 607 | .flags = CPUFREQ_STICKY, | 593 | .flags = CPUFREQ_STICKY, |
| 608 | .verify = s5pv210_verify_speed, | 594 | .verify = cpufreq_generic_frequency_table_verify, |
| 609 | .target = s5pv210_target, | 595 | .target = s5pv210_target, |
| 610 | .get = s5pv210_getspeed, | 596 | .get = s5pv210_getspeed, |
| 611 | .init = s5pv210_cpu_init, | 597 | .init = s5pv210_cpu_init, |
diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c index cff18e87ca58..b282cea47e62 100644 --- a/drivers/cpufreq/sa1100-cpufreq.c +++ b/drivers/cpufreq/sa1100-cpufreq.c | |||
| @@ -218,18 +218,12 @@ static int sa1100_target(struct cpufreq_policy *policy, | |||
| 218 | 218 | ||
| 219 | static int __init sa1100_cpu_init(struct cpufreq_policy *policy) | 219 | static int __init sa1100_cpu_init(struct cpufreq_policy *policy) |
| 220 | { | 220 | { |
| 221 | if (policy->cpu != 0) | 221 | return cpufreq_generic_init(policy, sa11x0_freq_table, CPUFREQ_ETERNAL); |
| 222 | return -EINVAL; | ||
| 223 | policy->cur = policy->min = policy->max = sa11x0_getspeed(0); | ||
| 224 | policy->cpuinfo.min_freq = 59000; | ||
| 225 | policy->cpuinfo.max_freq = 287000; | ||
| 226 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | ||
| 227 | return 0; | ||
| 228 | } | 222 | } |
| 229 | 223 | ||
| 230 | static struct cpufreq_driver sa1100_driver __refdata = { | 224 | static struct cpufreq_driver sa1100_driver __refdata = { |
| 231 | .flags = CPUFREQ_STICKY, | 225 | .flags = CPUFREQ_STICKY, |
| 232 | .verify = sa11x0_verify_speed, | 226 | .verify = cpufreq_generic_frequency_table_verify, |
| 233 | .target = sa1100_target, | 227 | .target = sa1100_target, |
| 234 | .get = sa11x0_getspeed, | 228 | .get = sa11x0_getspeed, |
| 235 | .init = sa1100_cpu_init, | 229 | .init = sa1100_cpu_init, |
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c index 39c90b6f4286..bca04c0b4a73 100644 --- a/drivers/cpufreq/sa1110-cpufreq.c +++ b/drivers/cpufreq/sa1110-cpufreq.c | |||
| @@ -332,20 +332,14 @@ static int sa1110_target(struct cpufreq_policy *policy, | |||
| 332 | 332 | ||
| 333 | static int __init sa1110_cpu_init(struct cpufreq_policy *policy) | 333 | static int __init sa1110_cpu_init(struct cpufreq_policy *policy) |
| 334 | { | 334 | { |
| 335 | if (policy->cpu != 0) | 335 | return cpufreq_generic_init(policy, sa11x0_freq_table, CPUFREQ_ETERNAL); |
| 336 | return -EINVAL; | ||
| 337 | policy->cur = policy->min = policy->max = sa11x0_getspeed(0); | ||
| 338 | policy->cpuinfo.min_freq = 59000; | ||
| 339 | policy->cpuinfo.max_freq = 287000; | ||
| 340 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | ||
| 341 | return 0; | ||
| 342 | } | 336 | } |
| 343 | 337 | ||
| 344 | /* sa1110_driver needs __refdata because it must remain after init registers | 338 | /* sa1110_driver needs __refdata because it must remain after init registers |
| 345 | * it with cpufreq_register_driver() */ | 339 | * it with cpufreq_register_driver() */ |
| 346 | static struct cpufreq_driver sa1110_driver __refdata = { | 340 | static struct cpufreq_driver sa1110_driver __refdata = { |
| 347 | .flags = CPUFREQ_STICKY, | 341 | .flags = CPUFREQ_STICKY, |
| 348 | .verify = sa11x0_verify_speed, | 342 | .verify = cpufreq_generic_frequency_table_verify, |
| 349 | .target = sa1110_target, | 343 | .target = sa1110_target, |
| 350 | .get = sa11x0_getspeed, | 344 | .get = sa11x0_getspeed, |
| 351 | .init = sa1110_cpu_init, | 345 | .init = sa1110_cpu_init, |
diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c index d6f6c6f4efa7..9047ab1ca014 100644 --- a/drivers/cpufreq/sc520_freq.c +++ b/drivers/cpufreq/sc520_freq.c | |||
| @@ -78,11 +78,6 @@ static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy, | |||
| 78 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 78 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | static int sc520_freq_verify(struct cpufreq_policy *policy) | ||
| 82 | { | ||
| 83 | return cpufreq_frequency_table_verify(policy, &sc520_freq_table[0]); | ||
| 84 | } | ||
| 85 | |||
| 86 | static int sc520_freq_target(struct cpufreq_policy *policy, | 81 | static int sc520_freq_target(struct cpufreq_policy *policy, |
| 87 | unsigned int target_freq, | 82 | unsigned int target_freq, |
| 88 | unsigned int relation) | 83 | unsigned int relation) |
| @@ -106,7 +101,6 @@ static int sc520_freq_target(struct cpufreq_policy *policy, | |||
| 106 | static int sc520_freq_cpu_init(struct cpufreq_policy *policy) | 101 | static int sc520_freq_cpu_init(struct cpufreq_policy *policy) |
| 107 | { | 102 | { |
| 108 | struct cpuinfo_x86 *c = &cpu_data(0); | 103 | struct cpuinfo_x86 *c = &cpu_data(0); |
| 109 | int result; | ||
| 110 | 104 | ||
| 111 | /* capability check */ | 105 | /* capability check */ |
| 112 | if (c->x86_vendor != X86_VENDOR_AMD || | 106 | if (c->x86_vendor != X86_VENDOR_AMD || |
| @@ -115,39 +109,19 @@ static int sc520_freq_cpu_init(struct cpufreq_policy *policy) | |||
| 115 | 109 | ||
| 116 | /* cpuinfo and default policy values */ | 110 | /* cpuinfo and default policy values */ |
| 117 | policy->cpuinfo.transition_latency = 1000000; /* 1ms */ | 111 | policy->cpuinfo.transition_latency = 1000000; /* 1ms */ |
| 118 | policy->cur = sc520_freq_get_cpu_frequency(0); | ||
| 119 | |||
| 120 | result = cpufreq_frequency_table_cpuinfo(policy, sc520_freq_table); | ||
| 121 | if (result) | ||
| 122 | return result; | ||
| 123 | |||
| 124 | cpufreq_frequency_table_get_attr(sc520_freq_table, policy->cpu); | ||
| 125 | |||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | |||
| 129 | 112 | ||
| 130 | static int sc520_freq_cpu_exit(struct cpufreq_policy *policy) | 113 | return cpufreq_table_validate_and_show(policy, sc520_freq_table); |
| 131 | { | ||
| 132 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 133 | return 0; | ||
| 134 | } | 114 | } |
| 135 | 115 | ||
| 136 | 116 | ||
| 137 | static struct freq_attr *sc520_freq_attr[] = { | ||
| 138 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 139 | NULL, | ||
| 140 | }; | ||
| 141 | |||
| 142 | |||
| 143 | static struct cpufreq_driver sc520_freq_driver = { | 117 | static struct cpufreq_driver sc520_freq_driver = { |
| 144 | .get = sc520_freq_get_cpu_frequency, | 118 | .get = sc520_freq_get_cpu_frequency, |
| 145 | .verify = sc520_freq_verify, | 119 | .verify = cpufreq_generic_frequency_table_verify, |
| 146 | .target = sc520_freq_target, | 120 | .target = sc520_freq_target, |
| 147 | .init = sc520_freq_cpu_init, | 121 | .init = sc520_freq_cpu_init, |
| 148 | .exit = sc520_freq_cpu_exit, | 122 | .exit = cpufreq_generic_exit, |
| 149 | .name = "sc520_freq", | 123 | .name = "sc520_freq", |
| 150 | .attr = sc520_freq_attr, | 124 | .attr = cpufreq_generic_attr, |
| 151 | }; | 125 | }; |
| 152 | 126 | ||
| 153 | static const struct x86_cpu_id sc520_ids[] = { | 127 | static const struct x86_cpu_id sc520_ids[] = { |
diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c index ffc6d24b0cfb..387af12503a6 100644 --- a/drivers/cpufreq/sh-cpufreq.c +++ b/drivers/cpufreq/sh-cpufreq.c | |||
| @@ -87,15 +87,12 @@ static int sh_cpufreq_verify(struct cpufreq_policy *policy) | |||
| 87 | if (freq_table) | 87 | if (freq_table) |
| 88 | return cpufreq_frequency_table_verify(policy, freq_table); | 88 | return cpufreq_frequency_table_verify(policy, freq_table); |
| 89 | 89 | ||
| 90 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 90 | cpufreq_verify_within_cpu_limits(policy); |
| 91 | policy->cpuinfo.max_freq); | ||
| 92 | 91 | ||
| 93 | policy->min = (clk_round_rate(cpuclk, 1) + 500) / 1000; | 92 | policy->min = (clk_round_rate(cpuclk, 1) + 500) / 1000; |
| 94 | policy->max = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; | 93 | policy->max = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; |
| 95 | 94 | ||
| 96 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, | 95 | cpufreq_verify_within_cpu_limits(policy); |
| 97 | policy->cpuinfo.max_freq); | ||
| 98 | |||
| 99 | return 0; | 96 | return 0; |
| 100 | } | 97 | } |
| 101 | 98 | ||
| @@ -114,15 +111,13 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 114 | return PTR_ERR(cpuclk); | 111 | return PTR_ERR(cpuclk); |
| 115 | } | 112 | } |
| 116 | 113 | ||
| 117 | policy->cur = sh_cpufreq_get(cpu); | ||
| 118 | |||
| 119 | freq_table = cpuclk->nr_freqs ? cpuclk->freq_table : NULL; | 114 | freq_table = cpuclk->nr_freqs ? cpuclk->freq_table : NULL; |
| 120 | if (freq_table) { | 115 | if (freq_table) { |
| 121 | int result; | 116 | int result; |
| 122 | 117 | ||
| 123 | result = cpufreq_frequency_table_cpuinfo(policy, freq_table); | 118 | result = cpufreq_table_validate_and_show(policy, freq_table); |
| 124 | if (!result) | 119 | if (result) |
| 125 | cpufreq_frequency_table_get_attr(freq_table, cpu); | 120 | return result; |
| 126 | } else { | 121 | } else { |
| 127 | dev_notice(dev, "no frequency table found, falling back " | 122 | dev_notice(dev, "no frequency table found, falling back " |
| 128 | "to rate rounding.\n"); | 123 | "to rate rounding.\n"); |
| @@ -154,11 +149,6 @@ static int sh_cpufreq_cpu_exit(struct cpufreq_policy *policy) | |||
| 154 | return 0; | 149 | return 0; |
| 155 | } | 150 | } |
| 156 | 151 | ||
| 157 | static struct freq_attr *sh_freq_attr[] = { | ||
| 158 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 159 | NULL, | ||
| 160 | }; | ||
| 161 | |||
| 162 | static struct cpufreq_driver sh_cpufreq_driver = { | 152 | static struct cpufreq_driver sh_cpufreq_driver = { |
| 163 | .name = "sh", | 153 | .name = "sh", |
| 164 | .get = sh_cpufreq_get, | 154 | .get = sh_cpufreq_get, |
| @@ -166,7 +156,7 @@ static struct cpufreq_driver sh_cpufreq_driver = { | |||
| 166 | .verify = sh_cpufreq_verify, | 156 | .verify = sh_cpufreq_verify, |
| 167 | .init = sh_cpufreq_cpu_init, | 157 | .init = sh_cpufreq_cpu_init, |
| 168 | .exit = sh_cpufreq_cpu_exit, | 158 | .exit = sh_cpufreq_cpu_exit, |
| 169 | .attr = sh_freq_attr, | 159 | .attr = cpufreq_generic_attr, |
| 170 | }; | 160 | }; |
| 171 | 161 | ||
| 172 | static int __init sh_cpufreq_module_init(void) | 162 | static int __init sh_cpufreq_module_init(void) |
diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c index cf5bc2ca16fa..291688c1da9a 100644 --- a/drivers/cpufreq/sparc-us2e-cpufreq.c +++ b/drivers/cpufreq/sparc-us2e-cpufreq.c | |||
| @@ -295,12 +295,6 @@ static int us2e_freq_target(struct cpufreq_policy *policy, | |||
| 295 | return 0; | 295 | return 0; |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | static int us2e_freq_verify(struct cpufreq_policy *policy) | ||
| 299 | { | ||
| 300 | return cpufreq_frequency_table_verify(policy, | ||
| 301 | &us2e_freq_table[policy->cpu].table[0]); | ||
| 302 | } | ||
| 303 | |||
| 304 | static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) | 298 | static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) |
| 305 | { | 299 | { |
| 306 | unsigned int cpu = policy->cpu; | 300 | unsigned int cpu = policy->cpu; |
| @@ -324,13 +318,15 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) | |||
| 324 | policy->cpuinfo.transition_latency = 0; | 318 | policy->cpuinfo.transition_latency = 0; |
| 325 | policy->cur = clock_tick; | 319 | policy->cur = clock_tick; |
| 326 | 320 | ||
| 327 | return cpufreq_frequency_table_cpuinfo(policy, table); | 321 | return cpufreq_table_validate_and_show(policy, table); |
| 328 | } | 322 | } |
| 329 | 323 | ||
| 330 | static int us2e_freq_cpu_exit(struct cpufreq_policy *policy) | 324 | static int us2e_freq_cpu_exit(struct cpufreq_policy *policy) |
| 331 | { | 325 | { |
| 332 | if (cpufreq_us2e_driver) | 326 | if (cpufreq_us2e_driver) { |
| 327 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 333 | us2e_set_cpu_divider_index(policy, 0); | 328 | us2e_set_cpu_divider_index(policy, 0); |
| 329 | } | ||
| 334 | 330 | ||
| 335 | return 0; | 331 | return 0; |
| 336 | } | 332 | } |
| @@ -361,7 +357,7 @@ static int __init us2e_freq_init(void) | |||
| 361 | goto err_out; | 357 | goto err_out; |
| 362 | 358 | ||
| 363 | driver->init = us2e_freq_cpu_init; | 359 | driver->init = us2e_freq_cpu_init; |
| 364 | driver->verify = us2e_freq_verify; | 360 | driver->verify = cpufreq_generic_frequency_table_verify; |
| 365 | driver->target = us2e_freq_target; | 361 | driver->target = us2e_freq_target; |
| 366 | driver->get = us2e_freq_get; | 362 | driver->get = us2e_freq_get; |
| 367 | driver->exit = us2e_freq_cpu_exit; | 363 | driver->exit = us2e_freq_cpu_exit; |
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c index ac76b489979d..9b3dbd31362e 100644 --- a/drivers/cpufreq/sparc-us3-cpufreq.c +++ b/drivers/cpufreq/sparc-us3-cpufreq.c | |||
| @@ -156,12 +156,6 @@ static int us3_freq_target(struct cpufreq_policy *policy, | |||
| 156 | return 0; | 156 | return 0; |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | static int us3_freq_verify(struct cpufreq_policy *policy) | ||
| 160 | { | ||
| 161 | return cpufreq_frequency_table_verify(policy, | ||
| 162 | &us3_freq_table[policy->cpu].table[0]); | ||
| 163 | } | ||
| 164 | |||
| 165 | static int __init us3_freq_cpu_init(struct cpufreq_policy *policy) | 159 | static int __init us3_freq_cpu_init(struct cpufreq_policy *policy) |
| 166 | { | 160 | { |
| 167 | unsigned int cpu = policy->cpu; | 161 | unsigned int cpu = policy->cpu; |
| @@ -181,13 +175,15 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy) | |||
| 181 | policy->cpuinfo.transition_latency = 0; | 175 | policy->cpuinfo.transition_latency = 0; |
| 182 | policy->cur = clock_tick; | 176 | policy->cur = clock_tick; |
| 183 | 177 | ||
| 184 | return cpufreq_frequency_table_cpuinfo(policy, table); | 178 | return cpufreq_table_validate_and_show(policy, table); |
| 185 | } | 179 | } |
| 186 | 180 | ||
| 187 | static int us3_freq_cpu_exit(struct cpufreq_policy *policy) | 181 | static int us3_freq_cpu_exit(struct cpufreq_policy *policy) |
| 188 | { | 182 | { |
| 189 | if (cpufreq_us3_driver) | 183 | if (cpufreq_us3_driver) { |
| 184 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 190 | us3_set_cpu_divider_index(policy, 0); | 185 | us3_set_cpu_divider_index(policy, 0); |
| 186 | } | ||
| 191 | 187 | ||
| 192 | return 0; | 188 | return 0; |
| 193 | } | 189 | } |
| @@ -222,7 +218,7 @@ static int __init us3_freq_init(void) | |||
| 222 | goto err_out; | 218 | goto err_out; |
| 223 | 219 | ||
| 224 | driver->init = us3_freq_cpu_init; | 220 | driver->init = us3_freq_cpu_init; |
| 225 | driver->verify = us3_freq_verify; | 221 | driver->verify = cpufreq_generic_frequency_table_verify; |
| 226 | driver->target = us3_freq_target; | 222 | driver->target = us3_freq_target; |
| 227 | driver->get = us3_freq_get; | 223 | driver->get = us3_freq_get; |
| 228 | driver->exit = us3_freq_cpu_exit; | 224 | driver->exit = us3_freq_cpu_exit; |
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c index 3f418166ce02..8841366a2068 100644 --- a/drivers/cpufreq/spear-cpufreq.c +++ b/drivers/cpufreq/spear-cpufreq.c | |||
| @@ -30,11 +30,6 @@ static struct { | |||
| 30 | u32 cnt; | 30 | u32 cnt; |
| 31 | } spear_cpufreq; | 31 | } spear_cpufreq; |
| 32 | 32 | ||
| 33 | static int spear_cpufreq_verify(struct cpufreq_policy *policy) | ||
| 34 | { | ||
| 35 | return cpufreq_frequency_table_verify(policy, spear_cpufreq.freq_tbl); | ||
| 36 | } | ||
| 37 | |||
| 38 | static unsigned int spear_cpufreq_get(unsigned int cpu) | 33 | static unsigned int spear_cpufreq_get(unsigned int cpu) |
| 39 | { | 34 | { |
| 40 | return clk_get_rate(spear_cpufreq.clk) / 1000; | 35 | return clk_get_rate(spear_cpufreq.clk) / 1000; |
| @@ -176,43 +171,19 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy, | |||
| 176 | 171 | ||
| 177 | static int spear_cpufreq_init(struct cpufreq_policy *policy) | 172 | static int spear_cpufreq_init(struct cpufreq_policy *policy) |
| 178 | { | 173 | { |
| 179 | int ret; | 174 | return cpufreq_generic_init(policy, spear_cpufreq.freq_tbl, |
| 180 | 175 | spear_cpufreq.transition_latency); | |
| 181 | ret = cpufreq_frequency_table_cpuinfo(policy, spear_cpufreq.freq_tbl); | ||
| 182 | if (ret) { | ||
| 183 | pr_err("cpufreq_frequency_table_cpuinfo() failed"); | ||
| 184 | return ret; | ||
| 185 | } | ||
| 186 | |||
| 187 | cpufreq_frequency_table_get_attr(spear_cpufreq.freq_tbl, policy->cpu); | ||
| 188 | policy->cpuinfo.transition_latency = spear_cpufreq.transition_latency; | ||
| 189 | policy->cur = spear_cpufreq_get(0); | ||
| 190 | |||
| 191 | cpumask_setall(policy->cpus); | ||
| 192 | |||
| 193 | return 0; | ||
| 194 | } | ||
| 195 | |||
| 196 | static int spear_cpufreq_exit(struct cpufreq_policy *policy) | ||
| 197 | { | ||
| 198 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 199 | return 0; | ||
| 200 | } | 176 | } |
| 201 | 177 | ||
| 202 | static struct freq_attr *spear_cpufreq_attr[] = { | ||
| 203 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 204 | NULL, | ||
| 205 | }; | ||
| 206 | |||
| 207 | static struct cpufreq_driver spear_cpufreq_driver = { | 178 | static struct cpufreq_driver spear_cpufreq_driver = { |
| 208 | .name = "cpufreq-spear", | 179 | .name = "cpufreq-spear", |
| 209 | .flags = CPUFREQ_STICKY, | 180 | .flags = CPUFREQ_STICKY, |
| 210 | .verify = spear_cpufreq_verify, | 181 | .verify = cpufreq_generic_frequency_table_verify, |
| 211 | .target = spear_cpufreq_target, | 182 | .target = spear_cpufreq_target, |
| 212 | .get = spear_cpufreq_get, | 183 | .get = spear_cpufreq_get, |
| 213 | .init = spear_cpufreq_init, | 184 | .init = spear_cpufreq_init, |
| 214 | .exit = spear_cpufreq_exit, | 185 | .exit = cpufreq_generic_exit, |
| 215 | .attr = spear_cpufreq_attr, | 186 | .attr = cpufreq_generic_attr, |
| 216 | }; | 187 | }; |
| 217 | 188 | ||
| 218 | static int spear_cpufreq_driver_init(void) | 189 | static int spear_cpufreq_driver_init(void) |
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index f897d5105842..25e45f89acac 100644 --- a/drivers/cpufreq/speedstep-centrino.c +++ b/drivers/cpufreq/speedstep-centrino.c | |||
| @@ -343,9 +343,7 @@ static unsigned int get_cur_freq(unsigned int cpu) | |||
| 343 | static int centrino_cpu_init(struct cpufreq_policy *policy) | 343 | static int centrino_cpu_init(struct cpufreq_policy *policy) |
| 344 | { | 344 | { |
| 345 | struct cpuinfo_x86 *cpu = &cpu_data(policy->cpu); | 345 | struct cpuinfo_x86 *cpu = &cpu_data(policy->cpu); |
| 346 | unsigned freq; | ||
| 347 | unsigned l, h; | 346 | unsigned l, h; |
| 348 | int ret; | ||
| 349 | int i; | 347 | int i; |
| 350 | 348 | ||
| 351 | /* Only Intel makes Enhanced Speedstep-capable CPUs */ | 349 | /* Only Intel makes Enhanced Speedstep-capable CPUs */ |
| @@ -373,9 +371,8 @@ static int centrino_cpu_init(struct cpufreq_policy *policy) | |||
| 373 | return -ENODEV; | 371 | return -ENODEV; |
| 374 | } | 372 | } |
| 375 | 373 | ||
| 376 | if (centrino_cpu_init_table(policy)) { | 374 | if (centrino_cpu_init_table(policy)) |
| 377 | return -ENODEV; | 375 | return -ENODEV; |
| 378 | } | ||
| 379 | 376 | ||
| 380 | /* Check to see if Enhanced SpeedStep is enabled, and try to | 377 | /* Check to see if Enhanced SpeedStep is enabled, and try to |
| 381 | enable it if not. */ | 378 | enable it if not. */ |
| @@ -395,22 +392,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy) | |||
| 395 | } | 392 | } |
| 396 | } | 393 | } |
| 397 | 394 | ||
| 398 | freq = get_cur_freq(policy->cpu); | ||
| 399 | policy->cpuinfo.transition_latency = 10000; | 395 | policy->cpuinfo.transition_latency = 10000; |
| 400 | /* 10uS transition latency */ | 396 | /* 10uS transition latency */ |
| 401 | policy->cur = freq; | ||
| 402 | |||
| 403 | pr_debug("centrino_cpu_init: cur=%dkHz\n", policy->cur); | ||
| 404 | 397 | ||
| 405 | ret = cpufreq_frequency_table_cpuinfo(policy, | 398 | return cpufreq_table_validate_and_show(policy, |
| 406 | per_cpu(centrino_model, policy->cpu)->op_points); | 399 | per_cpu(centrino_model, policy->cpu)->op_points); |
| 407 | if (ret) | ||
| 408 | return (ret); | ||
| 409 | |||
| 410 | cpufreq_frequency_table_get_attr( | ||
| 411 | per_cpu(centrino_model, policy->cpu)->op_points, policy->cpu); | ||
| 412 | |||
| 413 | return 0; | ||
| 414 | } | 400 | } |
| 415 | 401 | ||
| 416 | static int centrino_cpu_exit(struct cpufreq_policy *policy) | 402 | static int centrino_cpu_exit(struct cpufreq_policy *policy) |
| @@ -428,19 +414,6 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy) | |||
| 428 | } | 414 | } |
| 429 | 415 | ||
| 430 | /** | 416 | /** |
| 431 | * centrino_verify - verifies a new CPUFreq policy | ||
| 432 | * @policy: new policy | ||
| 433 | * | ||
| 434 | * Limit must be within this model's frequency range at least one | ||
| 435 | * border included. | ||
| 436 | */ | ||
| 437 | static int centrino_verify (struct cpufreq_policy *policy) | ||
| 438 | { | ||
| 439 | return cpufreq_frequency_table_verify(policy, | ||
| 440 | per_cpu(centrino_model, policy->cpu)->op_points); | ||
| 441 | } | ||
| 442 | |||
| 443 | /** | ||
| 444 | * centrino_setpolicy - set a new CPUFreq policy | 417 | * centrino_setpolicy - set a new CPUFreq policy |
| 445 | * @policy: new policy | 418 | * @policy: new policy |
| 446 | * @target_freq: the target frequency | 419 | * @target_freq: the target frequency |
| @@ -561,20 +534,15 @@ out: | |||
| 561 | return retval; | 534 | return retval; |
| 562 | } | 535 | } |
| 563 | 536 | ||
| 564 | static struct freq_attr* centrino_attr[] = { | ||
| 565 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 566 | NULL, | ||
| 567 | }; | ||
| 568 | |||
| 569 | static struct cpufreq_driver centrino_driver = { | 537 | static struct cpufreq_driver centrino_driver = { |
| 570 | .name = "centrino", /* should be speedstep-centrino, | 538 | .name = "centrino", /* should be speedstep-centrino, |
| 571 | but there's a 16 char limit */ | 539 | but there's a 16 char limit */ |
| 572 | .init = centrino_cpu_init, | 540 | .init = centrino_cpu_init, |
| 573 | .exit = centrino_cpu_exit, | 541 | .exit = centrino_cpu_exit, |
| 574 | .verify = centrino_verify, | 542 | .verify = cpufreq_generic_frequency_table_verify, |
| 575 | .target = centrino_target, | 543 | .target = centrino_target, |
| 576 | .get = get_cur_freq, | 544 | .get = get_cur_freq, |
| 577 | .attr = centrino_attr, | 545 | .attr = cpufreq_generic_attr, |
| 578 | }; | 546 | }; |
| 579 | 547 | ||
| 580 | /* | 548 | /* |
diff --git a/drivers/cpufreq/speedstep-ich.c b/drivers/cpufreq/speedstep-ich.c index 5355abb69afc..1a8b01bd0fec 100644 --- a/drivers/cpufreq/speedstep-ich.c +++ b/drivers/cpufreq/speedstep-ich.c | |||
| @@ -289,18 +289,6 @@ static int speedstep_target(struct cpufreq_policy *policy, | |||
| 289 | } | 289 | } |
| 290 | 290 | ||
| 291 | 291 | ||
| 292 | /** | ||
| 293 | * speedstep_verify - verifies a new CPUFreq policy | ||
| 294 | * @policy: new policy | ||
| 295 | * | ||
| 296 | * Limit must be within speedstep_low_freq and speedstep_high_freq, with | ||
| 297 | * at least one border included. | ||
| 298 | */ | ||
| 299 | static int speedstep_verify(struct cpufreq_policy *policy) | ||
| 300 | { | ||
| 301 | return cpufreq_frequency_table_verify(policy, &speedstep_freqs[0]); | ||
| 302 | } | ||
| 303 | |||
| 304 | struct get_freqs { | 292 | struct get_freqs { |
| 305 | struct cpufreq_policy *policy; | 293 | struct cpufreq_policy *policy; |
| 306 | int ret; | 294 | int ret; |
| @@ -320,8 +308,7 @@ static void get_freqs_on_cpu(void *_get_freqs) | |||
| 320 | 308 | ||
| 321 | static int speedstep_cpu_init(struct cpufreq_policy *policy) | 309 | static int speedstep_cpu_init(struct cpufreq_policy *policy) |
| 322 | { | 310 | { |
| 323 | int result; | 311 | unsigned int policy_cpu; |
| 324 | unsigned int policy_cpu, speed; | ||
| 325 | struct get_freqs gf; | 312 | struct get_freqs gf; |
| 326 | 313 | ||
| 327 | /* only run on CPU to be set, or on its sibling */ | 314 | /* only run on CPU to be set, or on its sibling */ |
| @@ -336,49 +323,18 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) | |||
| 336 | if (gf.ret) | 323 | if (gf.ret) |
| 337 | return gf.ret; | 324 | return gf.ret; |
| 338 | 325 | ||
| 339 | /* get current speed setting */ | 326 | return cpufreq_table_validate_and_show(policy, speedstep_freqs); |
| 340 | speed = speedstep_get(policy_cpu); | ||
| 341 | if (!speed) | ||
| 342 | return -EIO; | ||
| 343 | |||
| 344 | pr_debug("currently at %s speed setting - %i MHz\n", | ||
| 345 | (speed == speedstep_freqs[SPEEDSTEP_LOW].frequency) | ||
| 346 | ? "low" : "high", | ||
| 347 | (speed / 1000)); | ||
| 348 | |||
| 349 | /* cpuinfo and default policy values */ | ||
| 350 | policy->cur = speed; | ||
| 351 | |||
| 352 | result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs); | ||
| 353 | if (result) | ||
| 354 | return result; | ||
| 355 | |||
| 356 | cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu); | ||
| 357 | |||
| 358 | return 0; | ||
| 359 | } | ||
| 360 | |||
| 361 | |||
| 362 | static int speedstep_cpu_exit(struct cpufreq_policy *policy) | ||
| 363 | { | ||
| 364 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 365 | return 0; | ||
| 366 | } | 327 | } |
| 367 | 328 | ||
| 368 | static struct freq_attr *speedstep_attr[] = { | ||
| 369 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 370 | NULL, | ||
| 371 | }; | ||
| 372 | |||
| 373 | 329 | ||
| 374 | static struct cpufreq_driver speedstep_driver = { | 330 | static struct cpufreq_driver speedstep_driver = { |
| 375 | .name = "speedstep-ich", | 331 | .name = "speedstep-ich", |
| 376 | .verify = speedstep_verify, | 332 | .verify = cpufreq_generic_frequency_table_verify, |
| 377 | .target = speedstep_target, | 333 | .target = speedstep_target, |
| 378 | .init = speedstep_cpu_init, | 334 | .init = speedstep_cpu_init, |
| 379 | .exit = speedstep_cpu_exit, | 335 | .exit = cpufreq_generic_exit, |
| 380 | .get = speedstep_get, | 336 | .get = speedstep_get, |
| 381 | .attr = speedstep_attr, | 337 | .attr = cpufreq_generic_attr, |
| 382 | }; | 338 | }; |
| 383 | 339 | ||
| 384 | static const struct x86_cpu_id ss_smi_ids[] = { | 340 | static const struct x86_cpu_id ss_smi_ids[] = { |
diff --git a/drivers/cpufreq/speedstep-smi.c b/drivers/cpufreq/speedstep-smi.c index abfba4f731eb..a02b649c9647 100644 --- a/drivers/cpufreq/speedstep-smi.c +++ b/drivers/cpufreq/speedstep-smi.c | |||
| @@ -264,23 +264,9 @@ static int speedstep_target(struct cpufreq_policy *policy, | |||
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | 266 | ||
| 267 | /** | ||
| 268 | * speedstep_verify - verifies a new CPUFreq policy | ||
| 269 | * @policy: new policy | ||
| 270 | * | ||
| 271 | * Limit must be within speedstep_low_freq and speedstep_high_freq, with | ||
| 272 | * at least one border included. | ||
| 273 | */ | ||
| 274 | static int speedstep_verify(struct cpufreq_policy *policy) | ||
| 275 | { | ||
| 276 | return cpufreq_frequency_table_verify(policy, &speedstep_freqs[0]); | ||
| 277 | } | ||
| 278 | |||
| 279 | |||
| 280 | static int speedstep_cpu_init(struct cpufreq_policy *policy) | 267 | static int speedstep_cpu_init(struct cpufreq_policy *policy) |
| 281 | { | 268 | { |
| 282 | int result; | 269 | int result; |
| 283 | unsigned int speed, state; | ||
| 284 | unsigned int *low, *high; | 270 | unsigned int *low, *high; |
| 285 | 271 | ||
| 286 | /* capability check */ | 272 | /* capability check */ |
| @@ -316,32 +302,8 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) | |||
| 316 | pr_debug("workaround worked.\n"); | 302 | pr_debug("workaround worked.\n"); |
| 317 | } | 303 | } |
| 318 | 304 | ||
| 319 | /* get current speed setting */ | ||
| 320 | state = speedstep_get_state(); | ||
| 321 | speed = speedstep_freqs[state].frequency; | ||
| 322 | |||
| 323 | pr_debug("currently at %s speed setting - %i MHz\n", | ||
| 324 | (speed == speedstep_freqs[SPEEDSTEP_LOW].frequency) | ||
| 325 | ? "low" : "high", | ||
| 326 | (speed / 1000)); | ||
| 327 | |||
| 328 | /* cpuinfo and default policy values */ | ||
| 329 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 305 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
| 330 | policy->cur = speed; | 306 | return cpufreq_table_validate_and_show(policy, speedstep_freqs); |
| 331 | |||
| 332 | result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs); | ||
| 333 | if (result) | ||
| 334 | return result; | ||
| 335 | |||
| 336 | cpufreq_frequency_table_get_attr(speedstep_freqs, policy->cpu); | ||
| 337 | |||
| 338 | return 0; | ||
| 339 | } | ||
| 340 | |||
| 341 | static int speedstep_cpu_exit(struct cpufreq_policy *policy) | ||
| 342 | { | ||
| 343 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
| 344 | return 0; | ||
| 345 | } | 307 | } |
| 346 | 308 | ||
| 347 | static unsigned int speedstep_get(unsigned int cpu) | 309 | static unsigned int speedstep_get(unsigned int cpu) |
| @@ -362,20 +324,15 @@ static int speedstep_resume(struct cpufreq_policy *policy) | |||
| 362 | return result; | 324 | return result; |
| 363 | } | 325 | } |
| 364 | 326 | ||
| 365 | static struct freq_attr *speedstep_attr[] = { | ||
| 366 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 367 | NULL, | ||
| 368 | }; | ||
| 369 | |||
| 370 | static struct cpufreq_driver speedstep_driver = { | 327 | static struct cpufreq_driver speedstep_driver = { |
| 371 | .name = "speedstep-smi", | 328 | .name = "speedstep-smi", |
| 372 | .verify = speedstep_verify, | 329 | .verify = cpufreq_generic_frequency_table_verify, |
| 373 | .target = speedstep_target, | 330 | .target = speedstep_target, |
| 374 | .init = speedstep_cpu_init, | 331 | .init = speedstep_cpu_init, |
| 375 | .exit = speedstep_cpu_exit, | 332 | .exit = cpufreq_generic_exit, |
| 376 | .get = speedstep_get, | 333 | .get = speedstep_get, |
| 377 | .resume = speedstep_resume, | 334 | .resume = speedstep_resume, |
| 378 | .attr = speedstep_attr, | 335 | .attr = cpufreq_generic_attr, |
| 379 | }; | 336 | }; |
| 380 | 337 | ||
| 381 | static const struct x86_cpu_id ss_smi_ids[] = { | 338 | static const struct x86_cpu_id ss_smi_ids[] = { |
diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c index a7b876fdc1d8..32483ef63d53 100644 --- a/drivers/cpufreq/tegra-cpufreq.c +++ b/drivers/cpufreq/tegra-cpufreq.c | |||
| @@ -51,11 +51,6 @@ static unsigned long target_cpu_speed[NUM_CPUS]; | |||
| 51 | static DEFINE_MUTEX(tegra_cpu_lock); | 51 | static DEFINE_MUTEX(tegra_cpu_lock); |
| 52 | static bool is_suspended; | 52 | static bool is_suspended; |
| 53 | 53 | ||
| 54 | static int tegra_verify_speed(struct cpufreq_policy *policy) | ||
| 55 | { | ||
| 56 | return cpufreq_frequency_table_verify(policy, freq_table); | ||
| 57 | } | ||
| 58 | |||
| 59 | static unsigned int tegra_getspeed(unsigned int cpu) | 54 | static unsigned int tegra_getspeed(unsigned int cpu) |
| 60 | { | 55 | { |
| 61 | unsigned long rate; | 56 | unsigned long rate; |
| @@ -209,21 +204,23 @@ static struct notifier_block tegra_cpu_pm_notifier = { | |||
| 209 | 204 | ||
| 210 | static int tegra_cpu_init(struct cpufreq_policy *policy) | 205 | static int tegra_cpu_init(struct cpufreq_policy *policy) |
| 211 | { | 206 | { |
| 207 | int ret; | ||
| 208 | |||
| 212 | if (policy->cpu >= NUM_CPUS) | 209 | if (policy->cpu >= NUM_CPUS) |
| 213 | return -EINVAL; | 210 | return -EINVAL; |
| 214 | 211 | ||
| 215 | clk_prepare_enable(emc_clk); | 212 | clk_prepare_enable(emc_clk); |
| 216 | clk_prepare_enable(cpu_clk); | 213 | clk_prepare_enable(cpu_clk); |
| 217 | 214 | ||
| 218 | cpufreq_frequency_table_cpuinfo(policy, freq_table); | 215 | target_cpu_speed[policy->cpu] = tegra_getspeed(policy->cpu); |
| 219 | cpufreq_frequency_table_get_attr(freq_table, policy->cpu); | ||
| 220 | policy->cur = tegra_getspeed(policy->cpu); | ||
| 221 | target_cpu_speed[policy->cpu] = policy->cur; | ||
| 222 | 216 | ||
| 223 | /* FIXME: what's the actual transition time? */ | 217 | /* FIXME: what's the actual transition time? */ |
| 224 | policy->cpuinfo.transition_latency = 300 * 1000; | 218 | ret = cpufreq_generic_init(policy, freq_table, 300 * 1000); |
| 225 | 219 | if (ret) { | |
| 226 | cpumask_copy(policy->cpus, cpu_possible_mask); | 220 | clk_disable_unprepare(cpu_clk); |
| 221 | clk_disable_unprepare(emc_clk); | ||
| 222 | return ret; | ||
| 223 | } | ||
| 227 | 224 | ||
| 228 | if (policy->cpu == 0) | 225 | if (policy->cpu == 0) |
| 229 | register_pm_notifier(&tegra_cpu_pm_notifier); | 226 | register_pm_notifier(&tegra_cpu_pm_notifier); |
| @@ -233,24 +230,20 @@ static int tegra_cpu_init(struct cpufreq_policy *policy) | |||
| 233 | 230 | ||
| 234 | static int tegra_cpu_exit(struct cpufreq_policy *policy) | 231 | static int tegra_cpu_exit(struct cpufreq_policy *policy) |
| 235 | { | 232 | { |
| 236 | cpufreq_frequency_table_cpuinfo(policy, freq_table); | 233 | cpufreq_frequency_table_put_attr(policy->cpu); |
| 234 | clk_disable_unprepare(cpu_clk); | ||
| 237 | clk_disable_unprepare(emc_clk); | 235 | clk_disable_unprepare(emc_clk); |
| 238 | return 0; | 236 | return 0; |
| 239 | } | 237 | } |
| 240 | 238 | ||
| 241 | static struct freq_attr *tegra_cpufreq_attr[] = { | ||
| 242 | &cpufreq_freq_attr_scaling_available_freqs, | ||
| 243 | NULL, | ||
| 244 | }; | ||
| 245 | |||
| 246 | static struct cpufreq_driver tegra_cpufreq_driver = { | 239 | static struct cpufreq_driver tegra_cpufreq_driver = { |
| 247 | .verify = tegra_verify_speed, | 240 | .verify = cpufreq_generic_frequency_table_verify, |
| 248 | .target = tegra_target, | 241 | .target = tegra_target, |
| 249 | .get = tegra_getspeed, | 242 | .get = tegra_getspeed, |
| 250 | .init = tegra_cpu_init, | 243 | .init = tegra_cpu_init, |
| 251 | .exit = tegra_cpu_exit, | 244 | .exit = tegra_cpu_exit, |
| 252 | .name = "tegra", | 245 | .name = "tegra", |
| 253 | .attr = tegra_cpufreq_attr, | 246 | .attr = cpufreq_generic_attr, |
| 254 | }; | 247 | }; |
| 255 | 248 | ||
| 256 | static int __init tegra_cpufreq_init(void) | 249 | static int __init tegra_cpufreq_init(void) |
diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c index b225f04d8ae5..653ae2955b55 100644 --- a/drivers/cpufreq/unicore2-cpufreq.c +++ b/drivers/cpufreq/unicore2-cpufreq.c | |||
| @@ -29,9 +29,7 @@ static int ucv2_verify_speed(struct cpufreq_policy *policy) | |||
| 29 | if (policy->cpu) | 29 | if (policy->cpu) |
| 30 | return -EINVAL; | 30 | return -EINVAL; |
| 31 | 31 | ||
| 32 | cpufreq_verify_within_limits(policy, | 32 | cpufreq_verify_within_cpu_limits(policy); |
| 33 | policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); | ||
| 34 | |||
| 35 | return 0; | 33 | return 0; |
| 36 | } | 34 | } |
| 37 | 35 | ||
| @@ -68,7 +66,6 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy) | |||
| 68 | { | 66 | { |
| 69 | if (policy->cpu != 0) | 67 | if (policy->cpu != 0) |
| 70 | return -EINVAL; | 68 | return -EINVAL; |
| 71 | policy->cur = ucv2_getspeed(0); | ||
| 72 | policy->min = policy->cpuinfo.min_freq = 250000; | 69 | policy->min = policy->cpuinfo.min_freq = 250000; |
| 73 | policy->max = policy->cpuinfo.max_freq = 1000000; | 70 | policy->max = policy->cpuinfo.max_freq = 1000000; |
| 74 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 71 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
