···615615config PXA25x616616 bool617617 select CPU_XSCALE618618- select CPU_FREQ_TABLE if CPU_FREQ619618 help620619 Select code specific to PXA21x/25x/26x variants621620622621config PXA27x623622 bool624623 select CPU_XSCALE625625- select CPU_FREQ_TABLE if CPU_FREQ626624 help627625 Select code specific to PXA27x variants628626···633635config PXA3xx634636 bool635637 select CPU_XSC3636636- select CPU_FREQ_TABLE if CPU_FREQ637638 help638639 Select code specific to PXA3xx variants639640
+21-44
arch/arm/mach-sa1100/generic.c
···4242/*4343 * This table is setup for a 3.6864MHz Crystal.4444 */4545-static const unsigned short cclk_frequency_100khz[NR_FREQS] = {4646- 590, /* 59.0 MHz */4747- 737, /* 73.7 MHz */4848- 885, /* 88.5 MHz */4949- 1032, /* 103.2 MHz */5050- 1180, /* 118.0 MHz */5151- 1327, /* 132.7 MHz */5252- 1475, /* 147.5 MHz */5353- 1622, /* 162.2 MHz */5454- 1769, /* 176.9 MHz */5555- 1917, /* 191.7 MHz */5656- 2064, /* 206.4 MHz */5757- 2212, /* 221.2 MHz */5858- 2359, /* 235.9 MHz */5959- 2507, /* 250.7 MHz */6060- 2654, /* 265.4 MHz */6161- 2802 /* 280.2 MHz */4545+struct cpufreq_frequency_table sa11x0_freq_table[NR_FREQS+1] = {4646+ { .frequency = 59000, /* 59.0 MHz */},4747+ { .frequency = 73700, /* 73.7 MHz */},4848+ { .frequency = 88500, /* 88.5 MHz */},4949+ { .frequency = 103200, /* 103.2 MHz */},5050+ { .frequency = 118000, /* 118.0 MHz */},5151+ { .frequency = 132700, /* 132.7 MHz */},5252+ { .frequency = 147500, /* 147.5 MHz */},5353+ { .frequency = 162200, /* 162.2 MHz */},5454+ { .frequency = 176900, /* 176.9 MHz */},5555+ { .frequency = 191700, /* 191.7 MHz */},5656+ { .frequency = 206400, /* 206.4 MHz */},5757+ { .frequency = 221200, /* 221.2 MHz */},5858+ { .frequency = 235900, /* 235.9 MHz */},5959+ { .frequency = 250700, /* 250.7 MHz */},6060+ { .frequency = 265400, /* 265.4 MHz */},6161+ { .frequency = 280200, /* 280.2 MHz */},6262+ { .frequency = CPUFREQ_TABLE_END, },6263};63646465/* rounds up(!) */···6766{6867 int i;69687070- khz /= 100;7171-7269 for (i = 0; i < NR_FREQS; i++)7373- if (cclk_frequency_100khz[i] >= khz)7070+ if (sa11x0_freq_table[i].frequency >= khz)7471 break;75727673 return i;···7879{7980 unsigned int freq = 0;8081 if (idx < NR_FREQS)8181- freq = cclk_frequency_100khz[idx] * 100;8282+ freq = sa11x0_freq_table[idx].frequency;8283 return freq;8383-}8484-8585-8686-/* make sure that only the "userspace" governor is run -- anything else wouldn't make sense on8787- * this platform, anyway.8888- */8989-int sa11x0_verify_speed(struct cpufreq_policy *policy)9090-{9191- unsigned int tmp;9292- if (policy->cpu)9393- return -EINVAL;9494-9595- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);9696-9797- /* make sure that at least one frequency is within the policy */9898- tmp = cclk_frequency_100khz[sa11x0_freq_to_ppcr(policy->min)] * 100;9999- if (tmp > policy->max)100100- policy->max = tmp;101101-102102- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);103103-104104- return 0;10584}1068510786unsigned int sa11x0_getspeed(unsigned int cpu)10887{10988 if (cpu)11089 return 0;111111- return cclk_frequency_100khz[PPCR & 0xf] * 100;9090+ return sa11x0_freq_table[PPCR & 0xf].frequency;11291}1139211493/*
+2-3
arch/arm/mach-sa1100/generic.h
···33 *44 * Author: Nicolas Pitre55 */66+#include <linux/cpufreq.h>67#include <linux/reboot.h>7889extern void sa1100_timer_init(void);···2019extern void sa1110_mb_enable(void);2120extern void sa1110_mb_disable(void);22212323-struct cpufreq_policy;2424-2222+extern struct cpufreq_frequency_table sa11x0_freq_table[];2523extern unsigned int sa11x0_freq_to_ppcr(unsigned int khz);2626-extern int sa11x0_verify_speed(struct cpufreq_policy *policy);2724extern unsigned int sa11x0_getspeed(unsigned int cpu);2825extern unsigned int sa11x0_ppcr_to_freq(unsigned int idx);2926
···17171818if CPU_FREQ19192020-config CPU_FREQ_TABLE2121- tristate2222-2320config CPU_FREQ_GOV_COMMON2421 bool25222623config CPU_FREQ_STAT2724 tristate "CPU frequency translation statistics"2828- select CPU_FREQ_TABLE2925 default y3026 help3127 This driver exports CPU frequency statistics information through sysfs···139143140144config CPU_FREQ_GOV_ONDEMAND141145 tristate "'ondemand' cpufreq policy governor"142142- select CPU_FREQ_TABLE143146 select CPU_FREQ_GOV_COMMON144147 help145148 'ondemand' - This driver adds a dynamic cpufreq policy governor.···182187config GENERIC_CPUFREQ_CPU0183188 tristate "Generic CPU0 cpufreq driver"184189 depends on HAVE_CLK && REGULATOR && PM_OPP && OF185185- select CPU_FREQ_TABLE186190 help187191 This adds a generic cpufreq driver for CPU0 frequency management.188192 It supports both uniprocessor (UP) and symmetric multiprocessor (SMP)···217223218224config IA64_ACPI_CPUFREQ219225 tristate "ACPI Processor P-States driver"220220- select CPU_FREQ_TABLE221226 depends on ACPI_PROCESSOR222227 help223228 This driver adds a CPUFreq driver which utilizes the ACPI···233240234241config LOONGSON2_CPUFREQ235242 tristate "Loongson2 CPUFreq Driver"236236- select CPU_FREQ_TABLE237243 help238244 This option adds a CPUFreq driver for loongson processors which239245 support software configurable cpu frequency.···254262depends on SPARC64255263config SPARC_US3_CPUFREQ256264 tristate "UltraSPARC-III CPU Frequency driver"257257- select CPU_FREQ_TABLE258265 help259266 This adds the CPUFreq driver for UltraSPARC-III processors.260267···263272264273config SPARC_US2E_CPUFREQ265274 tristate "UltraSPARC-IIe CPU Frequency driver"266266- select CPU_FREQ_TABLE267275 help268276 This adds the CPUFreq driver for UltraSPARC-IIe processors.269277···275285depends on SUPERH276286config SH_CPU_FREQ277287 tristate "SuperH CPU Frequency driver"278278- select CPU_FREQ_TABLE279288 help280289 This adds the cpufreq driver for SuperH. Any CPU that supports281290 clock rate rounding through the clock framework can use this
-11
drivers/cpufreq/Kconfig.arm
···55config ARM_BIG_LITTLE_CPUFREQ66 tristate "Generic ARM big LITTLE CPUfreq driver"77 depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK88- select CPU_FREQ_TABLE98 help109 This enables the Generic CPUfreq driver for ARM big.LITTLE platforms.1110···17181819config ARM_EXYNOS_CPUFREQ1920 bool2020- select CPU_FREQ_TABLE21212222config ARM_EXYNOS4210_CPUFREQ2323 bool "SAMSUNG EXYNOS4210"···5658 depends on SOC_EXYNOS54405759 depends on HAVE_CLK && PM_OPP && OF5860 default y5959- select CPU_FREQ_TABLE6061 help6162 This adds the CPUFreq driver for Samsung EXYNOS54406263 SoC. The nature of exynos5440 clock controller is···8285 tristate "Freescale i.MX6Q cpufreq support"8386 depends on SOC_IMX6Q8487 depends on REGULATOR_ANATOP8585- select CPU_FREQ_TABLE8688 help8789 This adds cpufreq driver support for Freescale i.MX6Q SOC.8890···9710198102config ARM_KIRKWOOD_CPUFREQ99103 def_bool ARCH_KIRKWOOD && OF100100- select CPU_FREQ_TABLE101104 help102105 This adds the CPUFreq driver for Marvell Kirkwood103106 SoCs.···105110 bool "TI OMAP2+"106111 depends on ARCH_OMAP2PLUS107112 default ARCH_OMAP2PLUS108108- select CPU_FREQ_TABLE109113110114config ARM_S3C_CPUFREQ111115 bool···159165config ARM_S3C2416_CPUFREQ160166 bool "S3C2416 CPU Frequency scaling support"161167 depends on CPU_S3C2416162162- select CPU_FREQ_TABLE163168 help164169 This adds the CPUFreq driver for the Samsung S3C2416 and165170 S3C2450 SoC. The S3C2416 supports changing the rate of the···189196config ARM_S3C64XX_CPUFREQ190197 bool "Samsung S3C64XX"191198 depends on CPU_S3C6410192192- select CPU_FREQ_TABLE193199 default y194200 help195201 This adds the CPUFreq driver for Samsung S3C6410 SoC.···198206config ARM_S5PV210_CPUFREQ199207 bool "Samsung S5PV210 and S5PC110"200208 depends on CPU_S5PV210201201- select CPU_FREQ_TABLE202209 default y203210 help204211 This adds the CPUFreq driver for Samsung S5PV210 and···214223config ARM_SPEAR_CPUFREQ215224 bool "SPEAr CPUFreq support"216225 depends on PLAT_SPEAR217217- select CPU_FREQ_TABLE218226 default y219227 help220228 This adds the CPUFreq driver support for SPEAr SOCs.···221231config ARM_TEGRA_CPUFREQ222232 bool "TEGRA CPUFreq support"223233 depends on ARCH_TEGRA224224- select CPU_FREQ_TABLE225234 default y226235 help227236 This adds the CPUFreq driver support for TEGRA SOCs.
-6
drivers/cpufreq/Kconfig.powerpc
···11config CPU_FREQ_CBE22 tristate "CBE frequency scaling"33 depends on CBE_RAS && PPC_CELL44- select CPU_FREQ_TABLE54 default m65 help76 This adds the cpufreq driver for Cell BE processors.···1920config CPU_FREQ_MAPLE2021 bool "Support for Maple 970FX Evaluation Board"2122 depends on PPC_MAPLE2222- select CPU_FREQ_TABLE2323 help2424 This adds support for frequency switching on Maple 970FX2525 Evaluation Board and compatible boards (IBM JS2x blades).···2628config PPC_CORENET_CPUFREQ2729 tristate "CPU frequency scaling driver for Freescale E500MC SoCs"2830 depends on PPC_E500MC && OF && COMMON_CLK2929- select CPU_FREQ_TABLE3031 select CLK_PPC_CORENET3132 help3233 This adds the CPUFreq driver support for Freescale e500mc,···3538config CPU_FREQ_PMAC3639 bool "Support for Apple PowerBooks"3740 depends on ADB_PMU && PPC323838- select CPU_FREQ_TABLE3941 help4042 This adds support for frequency switching on Apple PowerBooks,4143 this currently includes some models of iBook & Titanium···4347config CPU_FREQ_PMAC644448 bool "Support for some Apple G5s"4549 depends on PPC_PMAC && PPC644646- select CPU_FREQ_TABLE4750 help4851 This adds support for frequency switching on Apple iMac G5,4952 and some of the more recent desktop G5 machines as well.···5055config PPC_PASEMI_CPUFREQ5156 bool "Support for PA Semi PWRficient"5257 depends on PPC_PASEMI5353- select CPU_FREQ_TABLE5458 default y5559 help5660 This adds the support for frequency switching on PA Semi
-13
drivers/cpufreq/Kconfig.x86
···31313232config X86_ACPI_CPUFREQ3333 tristate "ACPI Processor P-States driver"3434- select CPU_FREQ_TABLE3534 depends on ACPI_PROCESSOR3635 help3736 This driver adds a CPUFreq driver which utilizes the ACPI···59606061config ELAN_CPUFREQ6162 tristate "AMD Elan SC400 and SC410"6262- select CPU_FREQ_TABLE6363 depends on MELAN6464 ---help---6565 This adds the CPUFreq driver for AMD Elan SC400 and SC410···74767577config SC520_CPUFREQ7678 tristate "AMD Elan SC520"7777- select CPU_FREQ_TABLE7879 depends on MELAN7980 ---help---8081 This adds the CPUFreq driver for AMD Elan SC520 processor.···85888689config X86_POWERNOW_K68790 tristate "AMD Mobile K6-2/K6-3 PowerNow!"8888- select CPU_FREQ_TABLE8991 depends on X86_329092 help9193 This adds the CPUFreq driver for mobile AMD K6-2+ and mobile···9610097101config X86_POWERNOW_K798102 tristate "AMD Mobile Athlon/Duron PowerNow!"9999- select CPU_FREQ_TABLE100103 depends on X86_32101104 help102105 This adds the CPUFreq driver for mobile AMD K7 mobile processors.···113118114119config X86_POWERNOW_K8115120 tristate "AMD Opteron/Athlon64 PowerNow!"116116- select CPU_FREQ_TABLE117121 depends on ACPI && ACPI_PROCESSOR && X86_ACPI_CPUFREQ118122 help119123 This adds the CPUFreq driver for K8/early Opteron/Athlon64 processors.···126132config X86_AMD_FREQ_SENSITIVITY127133 tristate "AMD frequency sensitivity feedback powersave bias"128134 depends on CPU_FREQ_GOV_ONDEMAND && X86_ACPI_CPUFREQ && CPU_SUP_AMD129129- select CPU_FREQ_TABLE130135 help131136 This adds AMD-specific powersave bias function to the ondemand132137 governor, which allows it to make more power-conscious frequency···153160154161config X86_SPEEDSTEP_CENTRINO155162 tristate "Intel Enhanced SpeedStep (deprecated)"156156- select CPU_FREQ_TABLE157163 select X86_SPEEDSTEP_CENTRINO_TABLE if X86_32158164 depends on X86_32 || (X86_64 && ACPI_PROCESSOR)159165 help···182190183191config X86_SPEEDSTEP_ICH184192 tristate "Intel Speedstep on ICH-M chipsets (ioport interface)"185185- select CPU_FREQ_TABLE186193 depends on X86_32187194 help188195 This adds the CPUFreq driver for certain mobile Intel Pentium III···195204196205config X86_SPEEDSTEP_SMI197206 tristate "Intel SpeedStep on 440BX/ZX/MX chipsets (SMI interface)"198198- select CPU_FREQ_TABLE199207 depends on X86_32200208 help201209 This adds the CPUFreq driver for certain mobile Intel Pentium III···207217208218config X86_P4_CLOCKMOD209219 tristate "Intel Pentium 4 clock modulation"210210- select CPU_FREQ_TABLE211220 help212221 This adds the CPUFreq driver for Intel Pentium 4 / XEON213222 processors. When enabled it will lower CPU temperature by skipping···248259249260config X86_LONGHAUL250261 tristate "VIA Cyrix III Longhaul"251251- select CPU_FREQ_TABLE252262 depends on X86_32 && ACPI_PROCESSOR253263 help254264 This adds the CPUFreq driver for VIA Samuel/CyrixIII,···260272261273config X86_E_POWERSAVER262274 tristate "VIA C7 Enhanced PowerSaver (DANGEROUS)"263263- select CPU_FREQ_TABLE264275 depends on X86_32 && ACPI_PROCESSOR265276 help266277 This adds the CPUFreq driver for VIA C7 processors. However, this driver
···516516 return result;517517}518518519519-static int acpi_cpufreq_verify(struct cpufreq_policy *policy)520520-{521521- struct acpi_cpufreq_data *data = per_cpu(acfreq_data, policy->cpu);522522-523523- pr_debug("acpi_cpufreq_verify\n");524524-525525- return cpufreq_frequency_table_verify(policy, data->freq_table);526526-}527527-528519static unsigned long529520acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)530521{···828837 data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END;829838 perf->state = 0;830839831831- result = cpufreq_frequency_table_cpuinfo(policy, data->freq_table);840840+ result = cpufreq_table_validate_and_show(policy, data->freq_table);832841 if (result)833842 goto err_freqfree;834843···837846838847 switch (perf->control_register.space_id) {839848 case ACPI_ADR_SPACE_SYSTEM_IO:840840- /* Current speed is unknown and not detectable by IO port */849849+ /*850850+ * The core will not set policy->cur, because851851+ * cpufreq_driver->get is NULL, so we need to set it here.852852+ * However, we have to guess it, because the current speed is853853+ * unknown and not detectable via IO ports.854854+ */841855 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);842856 break;843857 case ACPI_ADR_SPACE_FIXED_HARDWARE:844858 acpi_cpufreq_driver.get = get_cur_freq_on_cpu;845845- policy->cur = get_cur_freq_on_cpu(cpu);846859 break;847860 default:848861 break;···862867 (u32) perf->states[i].core_frequency,863868 (u32) perf->states[i].power,864869 (u32) perf->states[i].transition_latency);865865-866866- cpufreq_frequency_table_get_attr(data->freq_table, policy->cpu);867870868871 /*869872 * the first call to ->target() should result in us actually···922929};923930924931static struct cpufreq_driver acpi_cpufreq_driver = {925925- .verify = acpi_cpufreq_verify,932932+ .verify = cpufreq_generic_frequency_table_verify,926933 .target = acpi_cpufreq_target,927934 .bios_limit = acpi_processor_get_bios_limit,928935 .init = acpi_cpufreq_cpu_init,
···6767static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem);68686969#define lock_policy_rwsem(mode, cpu) \7070-static int lock_policy_rwsem_##mode(int cpu) \7070+static void lock_policy_rwsem_##mode(int cpu) \7171{ \7272 struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); \7373 BUG_ON(!policy); \7474 down_##mode(&per_cpu(cpu_policy_rwsem, policy->cpu)); \7575- \7676- return 0; \7775}78767977lock_policy_rwsem(read, cpu);···133135134136bool have_governor_per_policy(void)135137{136136- return cpufreq_driver->have_governor_per_policy;138138+ return !!(cpufreq_driver->flags & CPUFREQ_HAVE_GOVERNOR_PER_POLICY);137139}138140EXPORT_SYMBOL_GPL(have_governor_per_policy);139141···180182 return idle_time;181183}182184EXPORT_SYMBOL_GPL(get_cpu_idle_time);185185+186186+/*187187+ * This is a generic cpufreq init() routine which can be used by cpufreq188188+ * drivers of SMP systems. It will do following:189189+ * - validate & show freq table passed190190+ * - set policies transition latency191191+ * - policy->cpus with all possible CPUs192192+ */193193+int cpufreq_generic_init(struct cpufreq_policy *policy,194194+ struct cpufreq_frequency_table *table,195195+ unsigned int transition_latency)196196+{197197+ int ret;198198+199199+ ret = cpufreq_table_validate_and_show(policy, table);200200+ if (ret) {201201+ pr_err("%s: invalid frequency table: %d\n", __func__, ret);202202+ return ret;203203+ }204204+205205+ policy->cpuinfo.transition_latency = transition_latency;206206+207207+ /*208208+ * The driver only supports the SMP configuartion where all processors209209+ * share the clock and voltage and clock.210210+ */211211+ cpumask_setall(policy->cpus);212212+213213+ return 0;214214+}215215+EXPORT_SYMBOL_GPL(cpufreq_generic_init);183216184217struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)185218{···443414show_one(scaling_max_freq, max);444415show_one(scaling_cur_freq, cur);445416446446-static int __cpufreq_set_policy(struct cpufreq_policy *policy,417417+static int cpufreq_set_policy(struct cpufreq_policy *policy,447418 struct cpufreq_policy *new_policy);448419449420/**···464435 if (ret != 1) \465436 return -EINVAL; \466437 \467467- ret = __cpufreq_set_policy(policy, &new_policy); \438438+ ret = cpufreq_set_policy(policy, &new_policy); \468439 policy->user_policy.object = policy->object; \469440 \470441 return ret ? ret : count; \···522493 &new_policy.governor))523494 return -EINVAL;524495525525- /*526526- * Do not use cpufreq_set_policy here or the user_policy.max527527- * will be wrongly overridden528528- */529529- ret = __cpufreq_set_policy(policy, &new_policy);496496+ ret = cpufreq_set_policy(policy, &new_policy);530497531498 policy->user_policy.policy = policy->policy;532499 policy->user_policy.governor = policy->governor;···678653{679654 struct cpufreq_policy *policy = to_policy(kobj);680655 struct freq_attr *fattr = to_attr(attr);681681- ssize_t ret = -EINVAL;656656+ ssize_t ret;682657683658 if (!down_read_trylock(&cpufreq_rwsem))684684- goto exit;659659+ return -EINVAL;685660686686- if (lock_policy_rwsem_read(policy->cpu) < 0)687687- goto up_read;661661+ lock_policy_rwsem_read(policy->cpu);688662689663 if (fattr->show)690664 ret = fattr->show(policy, buf);···691667 ret = -EIO;692668693669 unlock_policy_rwsem_read(policy->cpu);694694-695695-up_read:696670 up_read(&cpufreq_rwsem);697697-exit:671671+698672 return ret;699673}700674···711689 if (!down_read_trylock(&cpufreq_rwsem))712690 goto unlock;713691714714- if (lock_policy_rwsem_write(policy->cpu) < 0)715715- goto up_read;692692+ lock_policy_rwsem_write(policy->cpu);716693717694 if (fattr->store)718695 ret = fattr->store(policy, buf, count);···720699721700 unlock_policy_rwsem_write(policy->cpu);722701723723-up_read:724702 up_read(&cpufreq_rwsem);725703unlock:726704 put_online_cpus();···864844 int ret = 0;865845866846 memcpy(&new_policy, policy, sizeof(*policy));867867- /* assure that the starting sequence is run in __cpufreq_set_policy */847847+ /* assure that the starting sequence is run in cpufreq_set_policy */868848 policy->governor = NULL;869849870850 /* set default policy */871871- ret = __cpufreq_set_policy(policy, &new_policy);851851+ ret = cpufreq_set_policy(policy, &new_policy);872852 policy->user_policy.policy = policy->policy;873853 policy->user_policy.governor = policy->governor;874854···969949970950static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu)971951{972972- if (cpu == policy->cpu)952952+ if (WARN_ON(cpu == policy->cpu))973953 return;974954975955 /*···986966987967 up_write(&per_cpu(cpu_policy_rwsem, policy->last_cpu));988968989989-#ifdef CONFIG_CPU_FREQ_TABLE990969 cpufreq_frequency_table_update_policy_cpu(policy);991991-#endif992970 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,993971 CPUFREQ_UPDATE_POLICY_CPU, policy);994972}···10711053 goto err_set_policy_cpu;10721054 }1073105510561056+ if (cpufreq_driver->get) {10571057+ policy->cur = cpufreq_driver->get(policy->cpu);10581058+ if (!policy->cur) {10591059+ pr_err("%s: ->get() failed\n", __func__);10601060+ goto err_get_freq;10611061+ }10621062+ }10631063+10741064 /* related cpus should atleast have policy->cpus */10751065 cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);10761066···11331107 per_cpu(cpufreq_cpu_data, j) = NULL;11341108 write_unlock_irqrestore(&cpufreq_driver_lock, flags);1135110911101110+err_get_freq:11111111+ if (cpufreq_driver->exit)11121112+ cpufreq_driver->exit(policy);11361113err_set_policy_cpu:11371114 cpufreq_policy_free(policy);11381115nomem_out:···11761147 if (ret) {11771148 pr_err("%s: Failed to move kobj: %d", __func__, ret);1178114911791179- WARN_ON(lock_policy_rwsem_write(old_cpu));11501150+ lock_policy_rwsem_write(old_cpu);11801151 cpumask_set_cpu(old_cpu, policy->cpus);11811152 unlock_policy_rwsem_write(old_cpu);11821153···12371208 if (!frozen)12381209 sysfs_remove_link(&dev->kobj, "cpufreq");12391210 } else if (cpus > 1) {12401240-12411211 new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu, frozen);12421212 if (new_cpu >= 0) {12431213 update_policy_cpu(policy, new_cpu);1244121412451215 if (!frozen) {12461246- pr_debug("%s: policy Kobject moved to cpu: %d "12471247- "from: %d\n",__func__, new_cpu, cpu);12161216+ pr_debug("%s: policy Kobject moved to cpu: %d from: %d\n",12171217+ __func__, new_cpu, cpu);12481218 }12491219 }12501220 }···12711243 return -EINVAL;12721244 }1273124512741274- WARN_ON(lock_policy_rwsem_write(cpu));12461246+ lock_policy_rwsem_write(cpu);12751247 cpus = cpumask_weight(policy->cpus);1276124812771249 if (cpus > 1)···13381310}1339131113401312/**13411341- * __cpufreq_remove_dev - remove a CPU device13131313+ * cpufreq_remove_dev - remove a CPU device13421314 *13431315 * Removes the cpufreq interface for a CPU device.13441344- * Caller should already have policy_rwsem in write mode for this CPU.13451345- * This routine frees the rwsem before returning.13461316 */13471347-static inline int __cpufreq_remove_dev(struct device *dev,13481348- struct subsys_interface *sif,13491349- bool frozen)13501350-{13511351- int ret;13521352-13531353- ret = __cpufreq_remove_dev_prepare(dev, sif, frozen);13541354-13551355- if (!ret)13561356- ret = __cpufreq_remove_dev_finish(dev, sif, frozen);13571357-13581358- return ret;13591359-}13601360-13611317static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)13621318{13631319 unsigned int cpu = dev->id;13641364- int retval;13201320+ int ret;1365132113661322 if (cpu_is_offline(cpu))13671323 return 0;1368132413691369- retval = __cpufreq_remove_dev(dev, sif, false);13701370- return retval;13251325+ ret = __cpufreq_remove_dev_prepare(dev, sif, false);13261326+13271327+ if (!ret)13281328+ ret = __cpufreq_remove_dev_finish(dev, sif, false);13291329+13301330+ return ret;13711331}1372133213731333static void handle_update(struct work_struct *work)···14821466 if (!down_read_trylock(&cpufreq_rwsem))14831467 return 0;1484146814851485- if (unlikely(lock_policy_rwsem_read(cpu)))14861486- goto out_policy;14691469+ lock_policy_rwsem_read(cpu);1487147014881471 ret_freq = __cpufreq_get(cpu);1489147214901473 unlock_policy_rwsem_read(cpu);14911491-14921492-out_policy:14931474 up_read(&cpufreq_rwsem);1494147514951476 return ret_freq;···17101697{17111698 int ret = -EINVAL;1712169917131713- if (unlikely(lock_policy_rwsem_write(policy->cpu)))17141714- goto fail;17001700+ lock_policy_rwsem_write(policy->cpu);1715170117161702 ret = __cpufreq_driver_target(policy, target_freq, relation);1717170317181704 unlock_policy_rwsem_write(policy->cpu);1719170517201720-fail:17211706 return ret;17221707}17231708EXPORT_SYMBOL_GPL(cpufreq_driver_target);···18821871EXPORT_SYMBOL(cpufreq_get_policy);1883187218841873/*18851885- * data : current policy.18861886- * policy : policy to be set.18741874+ * policy : current policy.18751875+ * new_policy: policy to be set.18871876 */18881888-static int __cpufreq_set_policy(struct cpufreq_policy *policy,18771877+static int cpufreq_set_policy(struct cpufreq_policy *policy,18891878 struct cpufreq_policy *new_policy)18901879{18911880 int ret = 0, failed = 1;···20061995 goto no_policy;20071996 }2008199720092009- if (unlikely(lock_policy_rwsem_write(cpu))) {20102010- ret = -EINVAL;20112011- goto fail;20122012- }19981998+ lock_policy_rwsem_write(cpu);2013199920142000 pr_debug("updating policy for CPU %u\n", cpu);20152001 memcpy(&new_policy, policy, sizeof(*policy));···20312023 }20322024 }2033202520342034- ret = __cpufreq_set_policy(policy, &new_policy);20262026+ ret = cpufreq_set_policy(policy, &new_policy);2035202720362028 unlock_policy_rwsem_write(cpu);2037202920382038-fail:20392030 cpufreq_cpu_put(policy);20402031no_policy:20412032 return ret;
+4-1
drivers/cpufreq/cpufreq_governor.h
···191191 struct attribute_group *attr_group_gov_sys; /* one governor - system */192192 struct attribute_group *attr_group_gov_pol; /* one governor - policy */193193194194- /* Common data for platforms that don't set have_governor_per_policy */194194+ /*195195+ * Common data for platforms that don't set196196+ * CPUFREQ_HAVE_GOVERNOR_PER_POLICY197197+ */195198 struct dbs_data *gdbs_data;196199197200 struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu);
-11
drivers/cpufreq/cpufreq_userspace.c
···3838 if (!per_cpu(cpu_is_managed, policy->cpu))3939 goto err;40404141- /*4242- * We're safe from concurrent calls to ->target() here4343- * as we hold the userspace_mutex lock. If we were calling4444- * cpufreq_driver_target, a deadlock situation might occur:4545- * A: cpufreq_set (lock userspace_mutex) ->4646- * cpufreq_driver_target(lock policy->lock)4747- * B: cpufreq_set_policy(lock policy->lock) ->4848- * __cpufreq_governor ->4949- * cpufreq_governor_userspace (lock userspace_mutex)5050- */5141 ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);5252-5342 err:5443 mutex_unlock(&userspace_mutex);5544 return ret;
···6464 {0, CPUFREQ_TABLE_END},6565};66666767-static struct freq_attr *maple_cpu_freqs_attr[] = {6868- &cpufreq_freq_attr_scaling_available_freqs,6969- NULL,7070-};7171-7267/* Power mode data is an array of the 32 bits PCR values to use for7368 * the various frequencies, retrieved from the device-tree7469 */···130135 * Common interface to the cpufreq core131136 */132137133133-static int maple_cpufreq_verify(struct cpufreq_policy *policy)134134-{135135- return cpufreq_frequency_table_verify(policy, maple_cpu_freqs);136136-}137137-138138static int maple_cpufreq_target(struct cpufreq_policy *policy,139139 unsigned int target_freq, unsigned int relation)140140{···165175166176static int maple_cpufreq_cpu_init(struct cpufreq_policy *policy)167177{168168- policy->cpuinfo.transition_latency = 12000;169169- policy->cur = maple_cpu_freqs[maple_scom_query_freq()].frequency;170170- /* secondary CPUs are tied to the primary one by the171171- * cpufreq core if in the secondary policy we tell it that172172- * it actually must be one policy together with all others. */173173- cpumask_setall(policy->cpus);174174- cpufreq_frequency_table_get_attr(maple_cpu_freqs, policy->cpu);175175-176176- return cpufreq_frequency_table_cpuinfo(policy,177177- maple_cpu_freqs);178178+ return cpufreq_generic_init(policy, maple_cpu_freqs, 12000);178179}179179-180180181181static struct cpufreq_driver maple_cpufreq_driver = {182182 .name = "maple",183183 .flags = CPUFREQ_CONST_LOOPS,184184 .init = maple_cpufreq_cpu_init,185185- .verify = maple_cpufreq_verify,185185+ .verify = cpufreq_generic_frequency_table_verify,186186 .target = maple_cpufreq_target,187187 .get = maple_cpufreq_get_speed,188188- .attr = maple_cpu_freqs_attr,188188+ .attr = cpufreq_generic_attr,189189};190190191191static int __init maple_cpufreq_init(void)
+14-50
drivers/cpufreq/omap-cpufreq.c
···4040static struct device *mpu_dev;4141static struct regulator *mpu_reg;42424343-static int omap_verify_speed(struct cpufreq_policy *policy)4444-{4545- if (!freq_table)4646- return -EINVAL;4747- return cpufreq_frequency_table_verify(policy, freq_table);4848-}4949-5043static unsigned int omap_getspeed(unsigned int cpu)5144{5245 unsigned long rate;···160167161168static int omap_cpu_init(struct cpufreq_policy *policy)162169{163163- int result = 0;170170+ int result;164171165172 mpu_clk = clk_get(NULL, "cpufreq_ck");166173 if (IS_ERR(mpu_clk))167174 return PTR_ERR(mpu_clk);168175169169- if (policy->cpu >= NR_CPUS) {170170- result = -EINVAL;171171- goto fail_ck;172172- }173173-174174- policy->cur = omap_getspeed(policy->cpu);175175-176176- if (!freq_table)176176+ if (!freq_table) {177177 result = dev_pm_opp_init_cpufreq_table(mpu_dev, &freq_table);178178-179179- if (result) {180180- dev_err(mpu_dev, "%s: cpu%d: failed creating freq table[%d]\n",178178+ if (result) {179179+ dev_err(mpu_dev,180180+ "%s: cpu%d: failed creating freq table[%d]\n",181181 __func__, policy->cpu, result);182182- goto fail_ck;182182+ goto fail;183183+ }183184 }184185185186 atomic_inc_return(&freq_table_users);186187187187- result = cpufreq_frequency_table_cpuinfo(policy, freq_table);188188- if (result)189189- goto fail_table;190190-191191- cpufreq_frequency_table_get_attr(freq_table, policy->cpu);192192-193193- policy->cur = omap_getspeed(policy->cpu);194194-195195- /*196196- * On OMAP SMP configuartion, both processors share the voltage197197- * and clock. So both CPUs needs to be scaled together and hence198198- * needs software co-ordination. Use cpufreq affected_cpus199199- * interface to handle this scenario. Additional is_smp() check200200- * is to keep SMP_ON_UP build working.201201- */202202- if (is_smp())203203- cpumask_setall(policy->cpus);204204-205188 /* FIXME: what's the actual transition time? */206206- policy->cpuinfo.transition_latency = 300 * 1000;189189+ result = cpufreq_generic_init(policy, freq_table, 300 * 1000);190190+ if (!result)191191+ return 0;207192208208- return 0;209209-210210-fail_table:211193 freq_table_free();212212-fail_ck:194194+fail:213195 clk_put(mpu_clk);214196 return result;215197}216198217199static int omap_cpu_exit(struct cpufreq_policy *policy)218200{201201+ cpufreq_frequency_table_put_attr(policy->cpu);219202 freq_table_free();220203 clk_put(mpu_clk);221204 return 0;222205}223206224224-static struct freq_attr *omap_cpufreq_attr[] = {225225- &cpufreq_freq_attr_scaling_available_freqs,226226- NULL,227227-};228228-229207static struct cpufreq_driver omap_driver = {230208 .flags = CPUFREQ_STICKY,231231- .verify = omap_verify_speed,209209+ .verify = cpufreq_generic_frequency_table_verify,232210 .target = omap_target,233211 .get = omap_getspeed,234212 .init = omap_cpu_init,235213 .exit = omap_cpu_exit,236214 .name = "omap",237237- .attr = omap_cpufreq_attr,215215+ .attr = cpufreq_generic_attr,238216};239217240218static int omap_cpufreq_probe(struct platform_device *pdev)
+4-23
drivers/cpufreq/p4-clockmod.c
···140140}141141142142143143-static int cpufreq_p4_verify(struct cpufreq_policy *policy)144144-{145145- return cpufreq_frequency_table_verify(policy, &p4clockmod_table[0]);146146-}147147-148148-149143static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)150144{151145 if (c->x86 == 0x06) {···224230 else225231 p4clockmod_table[i].frequency = (stock_freq * i)/8;226232 }227227- cpufreq_frequency_table_get_attr(p4clockmod_table, policy->cpu);228233229234 /* cpuinfo and default policy values */230235231236 /* the transition latency is set to be 1 higher than the maximum232237 * transition latency of the ondemand governor */233238 policy->cpuinfo.transition_latency = 10000001;234234- policy->cur = stock_freq;235239236236- return cpufreq_frequency_table_cpuinfo(policy, &p4clockmod_table[0]);240240+ return cpufreq_table_validate_and_show(policy, &p4clockmod_table[0]);237241}238242239239-240240-static int cpufreq_p4_cpu_exit(struct cpufreq_policy *policy)241241-{242242- cpufreq_frequency_table_put_attr(policy->cpu);243243- return 0;244244-}245243246244static unsigned int cpufreq_p4_get(unsigned int cpu)247245{···253267 return stock_freq;254268}255269256256-static struct freq_attr *p4clockmod_attr[] = {257257- &cpufreq_freq_attr_scaling_available_freqs,258258- NULL,259259-};260260-261270static struct cpufreq_driver p4clockmod_driver = {262262- .verify = cpufreq_p4_verify,271271+ .verify = cpufreq_generic_frequency_table_verify,263272 .target = cpufreq_p4_target,264273 .init = cpufreq_p4_cpu_init,265265- .exit = cpufreq_p4_cpu_exit,274274+ .exit = cpufreq_generic_exit,266275 .get = cpufreq_p4_get,267276 .name = "p4-clockmod",268268- .attr = p4clockmod_attr,277277+ .attr = cpufreq_generic_attr,269278};270279271280static const struct x86_cpu_id cpufreq_p4_id[] = {
+3-22
drivers/cpufreq/pasemi-cpufreq.c
···6969 {0, CPUFREQ_TABLE_END},7070};71717272-static struct freq_attr *pas_cpu_freqs_attr[] = {7373- &cpufreq_freq_attr_scaling_available_freqs,7474- NULL,7575-};7676-7772/*7873 * hardware specific functions7974 */···204209 pr_debug("%d: %d\n", i, pas_freqs[i].frequency);205210 }206211207207- policy->cpuinfo.transition_latency = get_gizmo_latency();208208-209212 cur_astate = get_cur_astate(policy->cpu);210213 pr_debug("current astate is at %d\n",cur_astate);211214212215 policy->cur = pas_freqs[cur_astate].frequency;213213- cpumask_copy(policy->cpus, cpu_online_mask);214214-215216 ppc_proc_freq = policy->cur * 1000ul;216217217217- cpufreq_frequency_table_get_attr(pas_freqs, policy->cpu);218218-219219- /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max220220- * are set correctly221221- */222222- return cpufreq_frequency_table_cpuinfo(policy, pas_freqs);218218+ return cpufreq_generic_init(policy, pas_freqs, get_gizmo_latency());223219224220out_unmap_sdcpwr:225221 iounmap(sdcpwr_mapbase);···237251238252 cpufreq_frequency_table_put_attr(policy->cpu);239253 return 0;240240-}241241-242242-static int pas_cpufreq_verify(struct cpufreq_policy *policy)243243-{244244- return cpufreq_frequency_table_verify(policy, pas_freqs);245254}246255247256static int pas_cpufreq_target(struct cpufreq_policy *policy,···281300 .flags = CPUFREQ_CONST_LOOPS,282301 .init = pas_cpufreq_cpu_init,283302 .exit = pas_cpufreq_cpu_exit,284284- .verify = pas_cpufreq_verify,303303+ .verify = cpufreq_generic_frequency_table_verify,285304 .target = pas_cpufreq_target,286286- .attr = pas_cpu_freqs_attr,305305+ .attr = cpufreq_generic_attr,287306};288307289308/*
+1-9
drivers/cpufreq/pcc-cpufreq.c
···111111112112static int pcc_cpufreq_verify(struct cpufreq_policy *policy)113113{114114- cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,115115- policy->cpuinfo.max_freq);114114+ cpufreq_verify_within_cpu_limits(policy);116115 return 0;117116}118117···559560 ioread32(&pcch_hdr->nominal) * 1000;560561 policy->min = policy->cpuinfo.min_freq =561562 ioread32(&pcch_hdr->minimum_frequency) * 1000;562562- policy->cur = pcc_get_freq(cpu);563563-564564- if (!policy->cur) {565565- pr_debug("init: Unable to get current CPU frequency\n");566566- result = -EINVAL;567567- goto out;568568- }569563570564 pr_debug("init: policy->max is %d, policy->min is %d\n",571565 policy->max, policy->min);
···7070 {0, CPUFREQ_TABLE_END},7171};72727373-static struct freq_attr* g5_cpu_freqs_attr[] = {7474- &cpufreq_freq_attr_scaling_available_freqs,7575- NULL,7676-};7777-7873/* Power mode data is an array of the 32 bits PCR values to use for7974 * the various frequencies, retrieved from the device-tree8075 */···137142 pmf_call_one(pfunc_vdnap0_complete, &args);138143 if (done)139144 break;140140- msleep(1);145145+ usleep_range(1000, 1000);141146 }142147 if (done == 0)143148 printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n");···236241 if (pfunc_cpu1_volt_low)237242 pmf_call_one(pfunc_cpu1_volt_low, NULL);238243 }239239- msleep(10); /* should be faster , to fix */244244+ usleep_range(10000, 10000); /* should be faster , to fix */240245}241246242247/*···281286 pmf_call_one(pfunc_slewing_done, &args);282287 if (done)283288 break;284284- msleep(1);289289+ usleep_range(500, 500);285290 }286291 if (done == 0)287292 printk(KERN_WARNING "cpufreq: Timeout in clock slewing !\n");···311316/*312317 * Common interface to the cpufreq core313318 */314314-315315-static int g5_cpufreq_verify(struct cpufreq_policy *policy)316316-{317317- return cpufreq_frequency_table_verify(policy, g5_cpu_freqs);318318-}319319320320static int g5_cpufreq_target(struct cpufreq_policy *policy,321321 unsigned int target_freq, unsigned int relation)···347357348358static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy)349359{350350- policy->cpuinfo.transition_latency = transition_latency;351351- policy->cur = g5_cpu_freqs[g5_query_freq()].frequency;352352- /* secondary CPUs are tied to the primary one by the353353- * cpufreq core if in the secondary policy we tell it that354354- * it actually must be one policy together with all others. */355355- cpumask_copy(policy->cpus, cpu_online_mask);356356- cpufreq_frequency_table_get_attr(g5_cpu_freqs, policy->cpu);357357-358358- return cpufreq_frequency_table_cpuinfo(policy,359359- g5_cpu_freqs);360360+ return cpufreq_generic_init(policy, g5_cpu_freqs, transition_latency);360361}361361-362362363363static struct cpufreq_driver g5_cpufreq_driver = {364364 .name = "powermac",365365 .flags = CPUFREQ_CONST_LOOPS,366366 .init = g5_cpufreq_cpu_init,367367- .verify = g5_cpufreq_verify,367367+ .verify = cpufreq_generic_frequency_table_verify,368368 .target = g5_cpufreq_target,369369 .get = g5_cpufreq_get_speed,370370- .attr = g5_cpu_freqs_attr,370370+ .attr = cpufreq_generic_attr,371371};372372373373···377397 /* Check supported platforms */378398 if (of_machine_is_compatible("PowerMac8,1") ||379399 of_machine_is_compatible("PowerMac8,2") ||380380- of_machine_is_compatible("PowerMac9,1"))400400+ of_machine_is_compatible("PowerMac9,1") ||401401+ of_machine_is_compatible("PowerMac12,1"))381402 use_volts_smu = 1;382403 else if (of_machine_is_compatible("PowerMac11,2"))383404 use_volts_vdnap = 1;···628647 g5_cpu_freqs[0].frequency = max_freq;629648 g5_cpu_freqs[1].frequency = min_freq;630649650650+ /* Based on a measurement on Xserve G5, rounded up. */651651+ transition_latency = 10 * NSEC_PER_MSEC;652652+631653 /* Set callbacks */632632- transition_latency = CPUFREQ_ETERNAL;633654 g5_switch_volt = g5_pfunc_switch_volt;634655 g5_switch_freq = g5_pfunc_switch_freq;635656 g5_query_freq = g5_pfunc_query_freq;
+3-29
drivers/cpufreq/powernow-k6.c
···105105106106107107/**108108- * powernow_k6_verify - verifies a new CPUfreq policy109109- * @policy: new policy110110- *111111- * Policy must be within lowest and highest possible CPU Frequency,112112- * and at least one possible state must be within min and max.113113- */114114-static int powernow_k6_verify(struct cpufreq_policy *policy)115115-{116116- return cpufreq_frequency_table_verify(policy, &clock_ratio[0]);117117-}118118-119119-120120-/**121108 * powernow_k6_setpolicy - sets a new CPUFreq policy122109 * @policy: new policy123110 * @target_freq: the target frequency···132145static int powernow_k6_cpu_init(struct cpufreq_policy *policy)133146{134147 unsigned int i, f;135135- int result;136148137149 if (policy->cpu != 0)138150 return -ENODEV;···151165152166 /* cpuinfo and default policy values */153167 policy->cpuinfo.transition_latency = 200000;154154- policy->cur = busfreq * max_multiplier;155168156156- result = cpufreq_frequency_table_cpuinfo(policy, clock_ratio);157157- if (result)158158- return result;159159-160160- cpufreq_frequency_table_get_attr(clock_ratio, policy->cpu);161161-162162- return 0;169169+ return cpufreq_table_validate_and_show(policy, clock_ratio);163170}164171165172···174195 return ret;175196}176197177177-static struct freq_attr *powernow_k6_attr[] = {178178- &cpufreq_freq_attr_scaling_available_freqs,179179- NULL,180180-};181181-182198static struct cpufreq_driver powernow_k6_driver = {183183- .verify = powernow_k6_verify,199199+ .verify = cpufreq_generic_frequency_table_verify,184200 .target = powernow_k6_target,185201 .init = powernow_k6_cpu_init,186202 .exit = powernow_k6_cpu_exit,187203 .get = powernow_k6_get,188204 .name = "powernow-k6",189189- .attr = powernow_k6_attr,205205+ .attr = cpufreq_generic_attr,190206};191207192208static const struct x86_cpu_id powernow_k6_ids[] = {
+3-17
drivers/cpufreq/powernow-k7.c
···549549}550550551551552552-static int powernow_verify(struct cpufreq_policy *policy)553553-{554554- return cpufreq_frequency_table_verify(policy, powernow_table);555555-}556556-557552/*558553 * We use the fact that the bus frequency is somehow559554 * a multiple of 100000/3 khz, then we compute sgtc according···673678 policy->cpuinfo.transition_latency =674679 cpufreq_scale(2000000UL, fsb, latency);675680676676- policy->cur = powernow_get(0);677677-678678- cpufreq_frequency_table_get_attr(powernow_table, policy->cpu);679679-680680- return cpufreq_frequency_table_cpuinfo(policy, powernow_table);681681+ return cpufreq_table_validate_and_show(policy, powernow_table);681682}682683683684static int powernow_cpu_exit(struct cpufreq_policy *policy)···692701 return 0;693702}694703695695-static struct freq_attr *powernow_table_attr[] = {696696- &cpufreq_freq_attr_scaling_available_freqs,697697- NULL,698698-};699699-700704static struct cpufreq_driver powernow_driver = {701701- .verify = powernow_verify,705705+ .verify = cpufreq_generic_frequency_table_verify,702706 .target = powernow_target,703707 .get = powernow_get,704708#ifdef CONFIG_X86_POWERNOW_K7_ACPI···702716 .init = powernow_cpu_init,703717 .exit = powernow_cpu_exit,704718 .name = "powernow-k7",705705- .attr = powernow_table_attr,719719+ .attr = cpufreq_generic_attr,706720};707721708722static int __init powernow_init(void)
+3-24
drivers/cpufreq/powernow-k8.c
···10531053 return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);10541054}1055105510561056-/* Driver entry point to verify the policy and range of frequencies */10571057-static int powernowk8_verify(struct cpufreq_policy *pol)10581058-{10591059- struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);10601060-10611061- if (!data)10621062- return -EINVAL;10631063-10641064- return cpufreq_frequency_table_verify(pol, data->powernow_table);10651065-}10661066-10671056struct init_on_cpu {10681057 struct powernow_k8_data *data;10691058 int rc;···11411152 cpumask_copy(pol->cpus, cpu_core_mask(pol->cpu));11421153 data->available_cores = pol->cpus;1143115411441144- pol->cur = find_khz_freq_from_fid(data->currfid);11451145- pr_debug("policy current frequency %d kHz\n", pol->cur);11461146-11471155 /* min/max the cpu is capable of */11481148- if (cpufreq_frequency_table_cpuinfo(pol, data->powernow_table)) {11561156+ if (cpufreq_table_validate_and_show(pol, data->powernow_table)) {11491157 printk(KERN_ERR FW_BUG PFX "invalid powernow_table\n");11501158 powernow_k8_cpu_exit_acpi(data);11511159 kfree(data->powernow_table);11521160 kfree(data);11531161 return -EINVAL;11541162 }11551155-11561156- cpufreq_frequency_table_get_attr(data->powernow_table, pol->cpu);1157116311581164 pr_debug("cpu_init done, current fid 0x%x, vid 0x%x\n",11591165 data->currfid, data->currvid);···12111227 return khz;12121228}1213122912141214-static struct freq_attr *powernow_k8_attr[] = {12151215- &cpufreq_freq_attr_scaling_available_freqs,12161216- NULL,12171217-};12181218-12191230static struct cpufreq_driver cpufreq_amd64_driver = {12201220- .verify = powernowk8_verify,12311231+ .verify = cpufreq_generic_frequency_table_verify,12211232 .target = powernowk8_target,12221233 .bios_limit = acpi_processor_get_bios_limit,12231234 .init = powernowk8_cpu_init,12241235 .exit = powernowk8_cpu_exit,12251236 .get = powernowk8_get,12261237 .name = "powernow-k8",12271227- .attr = powernow_k8_attr,12381238+ .attr = cpufreq_generic_attr,12281239};1229124012301241static void __request_acpi_cpufreq(void)
+3-19
drivers/cpufreq/ppc-corenet-cpufreq.c
···202202 table[i].frequency = CPUFREQ_TABLE_END;203203204204 /* set the min and max frequency properly */205205- ret = cpufreq_frequency_table_cpuinfo(policy, table);205205+ ret = cpufreq_table_validate_and_show(policy, table);206206 if (ret) {207207 pr_err("invalid frequency table: %d\n", ret);208208 goto err_nomem1;···217217 per_cpu(cpu_data, i) = data;218218219219 policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;220220- policy->cur = corenet_cpufreq_get_speed(policy->cpu);221221-222222- cpufreq_frequency_table_get_attr(table, cpu);223220 of_node_put(np);224221225222 return 0;···248251 per_cpu(cpu_data, cpu) = NULL;249252250253 return 0;251251-}252252-253253-static int corenet_cpufreq_verify(struct cpufreq_policy *policy)254254-{255255- struct cpufreq_frequency_table *table =256256- per_cpu(cpu_data, policy->cpu)->table;257257-258258- return cpufreq_frequency_table_verify(policy, table);259254}260255261256static int corenet_cpufreq_target(struct cpufreq_policy *policy,···282293 return ret;283294}284295285285-static struct freq_attr *corenet_cpufreq_attr[] = {286286- &cpufreq_freq_attr_scaling_available_freqs,287287- NULL,288288-};289289-290296static struct cpufreq_driver ppc_corenet_cpufreq_driver = {291297 .name = "ppc_cpufreq",292298 .flags = CPUFREQ_CONST_LOOPS,293299 .init = corenet_cpufreq_cpu_init,294300 .exit = __exit_p(corenet_cpufreq_cpu_exit),295295- .verify = corenet_cpufreq_verify,301301+ .verify = cpufreq_generic_frequency_table_verify,296302 .target = corenet_cpufreq_target,297303 .get = corenet_cpufreq_get_speed,298298- .attr = corenet_cpufreq_attr,304304+ .attr = cpufreq_generic_attr,299305};300306301307static const struct of_device_id node_matches[] __initdata = {
+3-16
drivers/cpufreq/ppc_cbe_cpufreq.c
···123123 cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu));124124#endif125125126126- cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);127127-128126 /* this ensures that policy->cpuinfo_min129127 * and policy->cpuinfo_max are set correctly */130130- return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs);131131-}132132-133133-static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy)134134-{135135- cpufreq_frequency_table_put_attr(policy->cpu);136136- return 0;137137-}138138-139139-static int cbe_cpufreq_verify(struct cpufreq_policy *policy)140140-{141141- return cpufreq_frequency_table_verify(policy, cbe_freqs);128128+ return cpufreq_table_validate_and_show(policy, cbe_freqs);142129}143130144131static int cbe_cpufreq_target(struct cpufreq_policy *policy,···163176}164177165178static struct cpufreq_driver cbe_cpufreq_driver = {166166- .verify = cbe_cpufreq_verify,179179+ .verify = cpufreq_generic_frequency_table_verify,167180 .target = cbe_cpufreq_target,168181 .init = cbe_cpufreq_cpu_init,169169- .exit = cbe_cpufreq_cpu_exit,182182+ .exit = cpufreq_generic_exit,170183 .name = "cbe-cpufreq",171184 .flags = CPUFREQ_CONST_LOOPS,172185};
+7-23
drivers/cpufreq/pxa2xx-cpufreq.c
···262262 return (interval - (cpu_is_pxa27x() ? 31 : 0)) / 32;263263}264264265265-/* find a valid frequency point */266266-static int pxa_verify_policy(struct cpufreq_policy *policy)267267-{268268- struct cpufreq_frequency_table *pxa_freqs_table;269269- pxa_freqs_t *pxa_freqs;270270- int ret;271271-272272- find_freq_tables(&pxa_freqs_table, &pxa_freqs);273273- ret = cpufreq_frequency_table_verify(policy, pxa_freqs_table);274274-275275- if (freq_debug)276276- pr_debug("Verified CPU policy: %dKhz min to %dKhz max\n",277277- policy->min, policy->max);278278-279279- return ret;280280-}281281-282265static unsigned int pxa_cpufreq_get(unsigned int cpu)283266{284267 return get_clk_frequency_khz(0);···397414398415 /* set default policy and cpuinfo */399416 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */400400- policy->cur = get_clk_frequency_khz(0); /* current freq */401401- policy->min = policy->max = policy->cur;402417403418 /* Generate pxa25x the run cpufreq_frequency_table struct */404419 for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) {···434453 find_freq_tables(&pxa255_freq_table, &pxa255_freqs);435454 pr_info("PXA255 cpufreq using %s frequency table\n",436455 pxa255_turbo_table ? "turbo" : "run");437437- cpufreq_frequency_table_cpuinfo(policy, pxa255_freq_table);456456+457457+ cpufreq_table_validate_and_show(policy, pxa255_freq_table);438458 }439439- else if (cpu_is_pxa27x())440440- cpufreq_frequency_table_cpuinfo(policy, pxa27x_freq_table);459459+ else if (cpu_is_pxa27x()) {460460+ cpufreq_table_validate_and_show(policy, pxa27x_freq_table);461461+ }441462442463 printk(KERN_INFO "PXA CPU frequency change support initialized\n");443464···447464}448465449466static struct cpufreq_driver pxa_cpufreq_driver = {450450- .verify = pxa_verify_policy,467467+ .verify = cpufreq_generic_frequency_table_verify,451468 .target = pxa_set_target,452469 .init = pxa_cpufreq_init,470470+ .exit = cpufreq_generic_exit,453471 .get = pxa_cpufreq_get,454472 .name = "PXA2xx",455473};
···7878config CPU_THERMAL7979 bool "generic cpu cooling support"8080 depends on CPU_FREQ8181- select CPU_FREQ_TABLE8281 help8382 This implements the generic cpu cooling mechanism through frequency8483 reduction. An ACPI version of this already exists
+36-14
include/linux/cpufreq.h
···180180struct cpufreq_driver {181181 char name[CPUFREQ_NAME_LEN];182182 u8 flags;183183- /*184184- * This should be set by platforms having multiple clock-domains, i.e.185185- * supporting multiple policies. With this sysfs directories of governor186186- * would be created in cpu/cpu<num>/cpufreq/ directory and so they can187187- * use the same governor with different tunables for different clusters.188188- */189189- bool have_governor_per_policy;190183191184 /* needed by all drivers */192185 int (*init) (struct cpufreq_policy *policy);···204211};205212206213/* flags */207207-#define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if208208- * all ->init() calls failed */209209-#define CPUFREQ_CONST_LOOPS 0x02 /* loops_per_jiffy or other kernel210210- * "constants" aren't affected by211211- * frequency transitions */212212-#define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed213213- * mismatches */214214+#define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if215215+ all ->init() calls failed */216216+#define CPUFREQ_CONST_LOOPS (1 << 1) /* loops_per_jiffy or other217217+ kernel "constants" aren't218218+ affected by frequency219219+ transitions */220220+#define CPUFREQ_PM_NO_WARN (1 << 2) /* don't warn on suspend/resume221221+ speed mismatches */222222+223223+/*224224+ * This should be set by platforms having multiple clock-domains, i.e.225225+ * supporting multiple policies. With this sysfs directories of governor would226226+ * be created in cpu/cpu<num>/cpufreq/ directory and so they can use the same227227+ * governor with different tunables for different clusters.228228+ */229229+#define CPUFREQ_HAVE_GOVERNOR_PER_POLICY (1 << 3)214230215231int cpufreq_register_driver(struct cpufreq_driver *driver_data);216232int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);···240238 if (policy->min > policy->max)241239 policy->min = policy->max;242240 return;241241+}242242+243243+static inline void244244+cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy)245245+{246246+ cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,247247+ policy->cpuinfo.max_freq);243248}244249245250/*********************************************************************···401392402393int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,403394 struct cpufreq_frequency_table *table);395395+int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy);404396405397int cpufreq_frequency_table_target(struct cpufreq_policy *policy,406398 struct cpufreq_frequency_table *table,···417407418408/* the following are really really optional */419409extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs;410410+extern struct freq_attr *cpufreq_generic_attr[];420411void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,421412 unsigned int cpu);422413void cpufreq_frequency_table_put_attr(unsigned int cpu);414414+int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,415415+ struct cpufreq_frequency_table *table);416416+417417+int cpufreq_generic_init(struct cpufreq_policy *policy,418418+ struct cpufreq_frequency_table *table,419419+ unsigned int transition_latency);420420+static inline int cpufreq_generic_exit(struct cpufreq_policy *policy)421421+{422422+ cpufreq_frequency_table_put_attr(policy->cpu);423423+ return 0;424424+}423425424426#endif /* _LINUX_CPUFREQ_H */