Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge back earlier 'pm-cpufreq' material.

Conflicts:
drivers/cpufreq/omap-cpufreq.c

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