diff options
-rw-r--r-- | Documentation/cpu-freq/cpu-drivers.txt | 4 | ||||
-rw-r--r-- | arch/x86/kernel/apm_32.c | 1 | ||||
-rw-r--r-- | drivers/base/power/domain.c | 76 | ||||
-rw-r--r-- | drivers/cpufreq/Kconfig | 10 | ||||
-rw-r--r-- | drivers/cpufreq/Makefile | 1 | ||||
-rw-r--r-- | drivers/cpufreq/amd_freq_sensitivity.c | 11 | ||||
-rw-r--r-- | drivers/cpufreq/at32ap-cpufreq.c | 127 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 3 | ||||
-rw-r--r-- | drivers/cpufreq/exynos5440-cpufreq.c | 7 | ||||
-rw-r--r-- | drivers/cpufreq/freq_table.c | 8 | ||||
-rw-r--r-- | drivers/cpufreq/imx6q-cpufreq.c | 1 | ||||
-rw-r--r-- | drivers/cpufreq/intel_pstate.c | 5 | ||||
-rw-r--r-- | drivers/cpufreq/longhaul.c | 4 | ||||
-rw-r--r-- | drivers/cpufreq/pasemi-cpufreq.c | 6 | ||||
-rw-r--r-- | drivers/cpufreq/scpi-cpufreq.c | 6 | ||||
-rw-r--r-- | drivers/sh/clk/core.c | 5 | ||||
-rw-r--r-- | drivers/staging/irda/drivers/sh_sir.c | 4 | ||||
-rw-r--r-- | include/linux/cpufreq.h | 125 |
18 files changed, 166 insertions, 238 deletions
diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt index 434c49cc7330..61546ac578d6 100644 --- a/Documentation/cpu-freq/cpu-drivers.txt +++ b/Documentation/cpu-freq/cpu-drivers.txt | |||
@@ -291,3 +291,7 @@ For example: | |||
291 | /* Do something with pos */ | 291 | /* Do something with pos */ |
292 | pos->frequency = ... | 292 | pos->frequency = ... |
293 | } | 293 | } |
294 | |||
295 | If you need to work with the position of pos within driver_freq_table, | ||
296 | do not subtract the pointers, as it is quite costly. Instead, use the | ||
297 | macros cpufreq_for_each_entry_idx() and cpufreq_for_each_valid_entry_idx(). | ||
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index ab1865342002..dc0ca8e29c75 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c | |||
@@ -2389,6 +2389,7 @@ static int __init apm_init(void) | |||
2389 | if (HZ != 100) | 2389 | if (HZ != 100) |
2390 | idle_period = (idle_period * HZ) / 100; | 2390 | idle_period = (idle_period * HZ) / 100; |
2391 | if (idle_threshold < 100) { | 2391 | if (idle_threshold < 100) { |
2392 | cpuidle_poll_state_init(&apm_idle_driver); | ||
2392 | if (!cpuidle_register_driver(&apm_idle_driver)) | 2393 | if (!cpuidle_register_driver(&apm_idle_driver)) |
2393 | if (cpuidle_register_device(&apm_cpuidle_device)) | 2394 | if (cpuidle_register_device(&apm_cpuidle_device)) |
2394 | cpuidle_unregister_driver(&apm_idle_driver); | 2395 | cpuidle_unregister_driver(&apm_idle_driver); |
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 528b24149bc7..1ea0e2502e8e 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c | |||
@@ -2290,6 +2290,38 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state, | |||
2290 | return 0; | 2290 | return 0; |
2291 | } | 2291 | } |
2292 | 2292 | ||
2293 | static int genpd_iterate_idle_states(struct device_node *dn, | ||
2294 | struct genpd_power_state *states) | ||
2295 | { | ||
2296 | int ret; | ||
2297 | struct of_phandle_iterator it; | ||
2298 | struct device_node *np; | ||
2299 | int i = 0; | ||
2300 | |||
2301 | ret = of_count_phandle_with_args(dn, "domain-idle-states", NULL); | ||
2302 | if (ret <= 0) | ||
2303 | return ret; | ||
2304 | |||
2305 | /* Loop over the phandles until all the requested entry is found */ | ||
2306 | of_for_each_phandle(&it, ret, dn, "domain-idle-states", NULL, 0) { | ||
2307 | np = it.node; | ||
2308 | if (!of_match_node(idle_state_match, np)) | ||
2309 | continue; | ||
2310 | if (states) { | ||
2311 | ret = genpd_parse_state(&states[i], np); | ||
2312 | if (ret) { | ||
2313 | pr_err("Parsing idle state node %pOF failed with err %d\n", | ||
2314 | np, ret); | ||
2315 | of_node_put(np); | ||
2316 | return ret; | ||
2317 | } | ||
2318 | } | ||
2319 | i++; | ||
2320 | } | ||
2321 | |||
2322 | return i; | ||
2323 | } | ||
2324 | |||
2293 | /** | 2325 | /** |
2294 | * of_genpd_parse_idle_states: Return array of idle states for the genpd. | 2326 | * of_genpd_parse_idle_states: Return array of idle states for the genpd. |
2295 | * | 2327 | * |
@@ -2299,49 +2331,31 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state, | |||
2299 | * | 2331 | * |
2300 | * Returns the device states parsed from the OF node. The memory for the states | 2332 | * Returns the device states parsed from the OF node. The memory for the states |
2301 | * is allocated by this function and is the responsibility of the caller to | 2333 | * is allocated by this function and is the responsibility of the caller to |
2302 | * free the memory after use. | 2334 | * free the memory after use. If no domain idle states is found it returns |
2335 | * -EINVAL and in case of errors, a negative error code. | ||
2303 | */ | 2336 | */ |
2304 | int of_genpd_parse_idle_states(struct device_node *dn, | 2337 | int of_genpd_parse_idle_states(struct device_node *dn, |
2305 | struct genpd_power_state **states, int *n) | 2338 | struct genpd_power_state **states, int *n) |
2306 | { | 2339 | { |
2307 | struct genpd_power_state *st; | 2340 | struct genpd_power_state *st; |
2308 | struct device_node *np; | 2341 | int ret; |
2309 | int i = 0; | ||
2310 | int err, ret; | ||
2311 | int count; | ||
2312 | struct of_phandle_iterator it; | ||
2313 | const struct of_device_id *match_id; | ||
2314 | 2342 | ||
2315 | count = of_count_phandle_with_args(dn, "domain-idle-states", NULL); | 2343 | ret = genpd_iterate_idle_states(dn, NULL); |
2316 | if (count <= 0) | 2344 | if (ret <= 0) |
2317 | return -EINVAL; | 2345 | return ret < 0 ? ret : -EINVAL; |
2318 | 2346 | ||
2319 | st = kcalloc(count, sizeof(*st), GFP_KERNEL); | 2347 | st = kcalloc(ret, sizeof(*st), GFP_KERNEL); |
2320 | if (!st) | 2348 | if (!st) |
2321 | return -ENOMEM; | 2349 | return -ENOMEM; |
2322 | 2350 | ||
2323 | /* Loop over the phandles until all the requested entry is found */ | 2351 | ret = genpd_iterate_idle_states(dn, st); |
2324 | of_for_each_phandle(&it, err, dn, "domain-idle-states", NULL, 0) { | 2352 | if (ret <= 0) { |
2325 | np = it.node; | 2353 | kfree(st); |
2326 | match_id = of_match_node(idle_state_match, np); | 2354 | return ret < 0 ? ret : -EINVAL; |
2327 | if (!match_id) | ||
2328 | continue; | ||
2329 | ret = genpd_parse_state(&st[i++], np); | ||
2330 | if (ret) { | ||
2331 | pr_err | ||
2332 | ("Parsing idle state node %pOF failed with err %d\n", | ||
2333 | np, ret); | ||
2334 | of_node_put(np); | ||
2335 | kfree(st); | ||
2336 | return ret; | ||
2337 | } | ||
2338 | } | 2355 | } |
2339 | 2356 | ||
2340 | *n = i; | 2357 | *states = st; |
2341 | if (!i) | 2358 | *n = ret; |
2342 | kfree(st); | ||
2343 | else | ||
2344 | *states = st; | ||
2345 | 2359 | ||
2346 | return 0; | 2360 | return 0; |
2347 | } | 2361 | } |
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index d8addbce40bc..608af20a3494 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig | |||
@@ -239,16 +239,6 @@ if PPC32 || PPC64 | |||
239 | source "drivers/cpufreq/Kconfig.powerpc" | 239 | source "drivers/cpufreq/Kconfig.powerpc" |
240 | endif | 240 | endif |
241 | 241 | ||
242 | if AVR32 | ||
243 | config AVR32_AT32AP_CPUFREQ | ||
244 | bool "CPU frequency driver for AT32AP" | ||
245 | depends on PLATFORM_AT32AP | ||
246 | default n | ||
247 | help | ||
248 | This enables the CPU frequency driver for AT32AP processors. | ||
249 | If in doubt, say N. | ||
250 | endif | ||
251 | |||
252 | if IA64 | 242 | if IA64 |
253 | config IA64_ACPI_CPUFREQ | 243 | config IA64_ACPI_CPUFREQ |
254 | tristate "ACPI Processor P-States driver" | 244 | tristate "ACPI Processor P-States driver" |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index e07715ce8844..c60c1e141d9d 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
@@ -100,7 +100,6 @@ obj-$(CONFIG_POWERNV_CPUFREQ) += powernv-cpufreq.o | |||
100 | 100 | ||
101 | ################################################################################## | 101 | ################################################################################## |
102 | # Other platform drivers | 102 | # Other platform drivers |
103 | obj-$(CONFIG_AVR32_AT32AP_CPUFREQ) += at32ap-cpufreq.o | ||
104 | obj-$(CONFIG_BFIN_CPU_FREQ) += blackfin-cpufreq.o | 103 | obj-$(CONFIG_BFIN_CPU_FREQ) += blackfin-cpufreq.o |
105 | obj-$(CONFIG_BMIPS_CPUFREQ) += bmips-cpufreq.o | 104 | obj-$(CONFIG_BMIPS_CPUFREQ) += bmips-cpufreq.o |
106 | obj-$(CONFIG_CRIS_MACH_ARTPEC3) += cris-artpec3-cpufreq.o | 105 | obj-$(CONFIG_CRIS_MACH_ARTPEC3) += cris-artpec3-cpufreq.o |
diff --git a/drivers/cpufreq/amd_freq_sensitivity.c b/drivers/cpufreq/amd_freq_sensitivity.c index 042023bbbf62..be926d9a66e5 100644 --- a/drivers/cpufreq/amd_freq_sensitivity.c +++ b/drivers/cpufreq/amd_freq_sensitivity.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | #include <linux/pci.h> | ||
17 | #include <linux/percpu-defs.h> | 18 | #include <linux/percpu-defs.h> |
18 | #include <linux/init.h> | 19 | #include <linux/init.h> |
19 | #include <linux/mod_devicetable.h> | 20 | #include <linux/mod_devicetable.h> |
@@ -109,12 +110,18 @@ out: | |||
109 | static int __init amd_freq_sensitivity_init(void) | 110 | static int __init amd_freq_sensitivity_init(void) |
110 | { | 111 | { |
111 | u64 val; | 112 | u64 val; |
113 | struct pci_dev *pcidev; | ||
112 | 114 | ||
113 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) | 115 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) |
114 | return -ENODEV; | 116 | return -ENODEV; |
115 | 117 | ||
116 | if (!static_cpu_has(X86_FEATURE_PROC_FEEDBACK)) | 118 | pcidev = pci_get_device(PCI_VENDOR_ID_AMD, |
117 | return -ENODEV; | 119 | PCI_DEVICE_ID_AMD_KERNCZ_SMBUS, NULL); |
120 | |||
121 | if (!pcidev) { | ||
122 | if (!static_cpu_has(X86_FEATURE_PROC_FEEDBACK)) | ||
123 | return -ENODEV; | ||
124 | } | ||
118 | 125 | ||
119 | if (rdmsrl_safe(MSR_AMD64_FREQ_SENSITIVITY_ACTUAL, &val)) | 126 | if (rdmsrl_safe(MSR_AMD64_FREQ_SENSITIVITY_ACTUAL, &val)) |
120 | return -ENODEV; | 127 | return -ENODEV; |
diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c deleted file mode 100644 index 7b612c8bb09e..000000000000 --- a/drivers/cpufreq/at32ap-cpufreq.c +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004-2007 Atmel Corporation | ||
3 | * | ||
4 | * Based on MIPS implementation arch/mips/kernel/time.c | ||
5 | * Copyright 2001 MontaVista Software Inc. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | /*#define DEBUG*/ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/types.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/cpufreq.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <linux/clk.h> | ||
20 | #include <linux/err.h> | ||
21 | #include <linux/export.h> | ||
22 | #include <linux/slab.h> | ||
23 | |||
24 | static struct cpufreq_frequency_table *freq_table; | ||
25 | |||
26 | static unsigned int ref_freq; | ||
27 | static unsigned long loops_per_jiffy_ref; | ||
28 | |||
29 | static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) | ||
30 | { | ||
31 | unsigned int old_freq, new_freq; | ||
32 | |||
33 | old_freq = policy->cur; | ||
34 | new_freq = freq_table[index].frequency; | ||
35 | |||
36 | if (!ref_freq) { | ||
37 | ref_freq = old_freq; | ||
38 | loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy; | ||
39 | } | ||
40 | |||
41 | if (old_freq < new_freq) | ||
42 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( | ||
43 | loops_per_jiffy_ref, ref_freq, new_freq); | ||
44 | clk_set_rate(policy->clk, new_freq * 1000); | ||
45 | if (new_freq < old_freq) | ||
46 | boot_cpu_data.loops_per_jiffy = cpufreq_scale( | ||
47 | loops_per_jiffy_ref, ref_freq, new_freq); | ||
48 | |||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | static int at32_cpufreq_driver_init(struct cpufreq_policy *policy) | ||
53 | { | ||
54 | unsigned int frequency, rate, min_freq; | ||
55 | struct clk *cpuclk; | ||
56 | int retval, steps, i; | ||
57 | |||
58 | if (policy->cpu != 0) | ||
59 | return -EINVAL; | ||
60 | |||
61 | cpuclk = clk_get(NULL, "cpu"); | ||
62 | if (IS_ERR(cpuclk)) { | ||
63 | pr_debug("cpufreq: could not get CPU clk\n"); | ||
64 | retval = PTR_ERR(cpuclk); | ||
65 | goto out_err; | ||
66 | } | ||
67 | |||
68 | min_freq = (clk_round_rate(cpuclk, 1) + 500) / 1000; | ||
69 | frequency = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000; | ||
70 | policy->cpuinfo.transition_latency = 0; | ||
71 | |||
72 | /* | ||
73 | * AVR32 CPU frequency rate scales in power of two between maximum and | ||
74 | * minimum, also add space for the table end marker. | ||
75 | * | ||
76 | * Further validate that the frequency is usable, and append it to the | ||
77 | * frequency table. | ||
78 | */ | ||
79 | steps = fls(frequency / min_freq) + 1; | ||
80 | freq_table = kzalloc(steps * sizeof(struct cpufreq_frequency_table), | ||
81 | GFP_KERNEL); | ||
82 | if (!freq_table) { | ||
83 | retval = -ENOMEM; | ||
84 | goto out_err_put_clk; | ||
85 | } | ||
86 | |||
87 | for (i = 0; i < (steps - 1); i++) { | ||
88 | rate = clk_round_rate(cpuclk, frequency * 1000) / 1000; | ||
89 | |||
90 | if (rate != frequency) | ||
91 | freq_table[i].frequency = CPUFREQ_ENTRY_INVALID; | ||
92 | else | ||
93 | freq_table[i].frequency = frequency; | ||
94 | |||
95 | frequency /= 2; | ||
96 | } | ||
97 | |||
98 | policy->clk = cpuclk; | ||
99 | freq_table[steps - 1].frequency = CPUFREQ_TABLE_END; | ||
100 | |||
101 | retval = cpufreq_table_validate_and_show(policy, freq_table); | ||
102 | if (!retval) { | ||
103 | printk("cpufreq: AT32AP CPU frequency driver\n"); | ||
104 | return 0; | ||
105 | } | ||
106 | |||
107 | kfree(freq_table); | ||
108 | out_err_put_clk: | ||
109 | clk_put(cpuclk); | ||
110 | out_err: | ||
111 | return retval; | ||
112 | } | ||
113 | |||
114 | static struct cpufreq_driver at32_driver = { | ||
115 | .name = "at32ap", | ||
116 | .init = at32_cpufreq_driver_init, | ||
117 | .verify = cpufreq_generic_frequency_table_verify, | ||
118 | .target_index = at32_set_target, | ||
119 | .get = cpufreq_generic_get, | ||
120 | .flags = CPUFREQ_STICKY, | ||
121 | }; | ||
122 | |||
123 | static int __init at32_cpufreq_init(void) | ||
124 | { | ||
125 | return cpufreq_register_driver(&at32_driver); | ||
126 | } | ||
127 | late_initcall(at32_cpufreq_init); | ||
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 421f318c0e66..de33ebf008ad 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -1686,6 +1686,9 @@ void cpufreq_resume(void) | |||
1686 | if (!cpufreq_driver) | 1686 | if (!cpufreq_driver) |
1687 | return; | 1687 | return; |
1688 | 1688 | ||
1689 | if (unlikely(!cpufreq_suspended)) | ||
1690 | return; | ||
1691 | |||
1689 | cpufreq_suspended = false; | 1692 | cpufreq_suspended = false; |
1690 | 1693 | ||
1691 | if (!has_target() && !cpufreq_driver->resume) | 1694 | if (!has_target() && !cpufreq_driver->resume) |
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c index b6b369c22272..932caa386ece 100644 --- a/drivers/cpufreq/exynos5440-cpufreq.c +++ b/drivers/cpufreq/exynos5440-cpufreq.c | |||
@@ -115,10 +115,10 @@ static struct cpufreq_freqs freqs; | |||
115 | static int init_div_table(void) | 115 | static int init_div_table(void) |
116 | { | 116 | { |
117 | struct cpufreq_frequency_table *pos, *freq_tbl = dvfs_info->freq_table; | 117 | struct cpufreq_frequency_table *pos, *freq_tbl = dvfs_info->freq_table; |
118 | unsigned int tmp, clk_div, ema_div, freq, volt_id; | 118 | unsigned int tmp, clk_div, ema_div, freq, volt_id, idx; |
119 | struct dev_pm_opp *opp; | 119 | struct dev_pm_opp *opp; |
120 | 120 | ||
121 | cpufreq_for_each_entry(pos, freq_tbl) { | 121 | cpufreq_for_each_entry_idx(pos, freq_tbl, idx) { |
122 | opp = dev_pm_opp_find_freq_exact(dvfs_info->dev, | 122 | opp = dev_pm_opp_find_freq_exact(dvfs_info->dev, |
123 | pos->frequency * 1000, true); | 123 | pos->frequency * 1000, true); |
124 | if (IS_ERR(opp)) { | 124 | if (IS_ERR(opp)) { |
@@ -154,8 +154,7 @@ static int init_div_table(void) | |||
154 | tmp = (clk_div | ema_div | (volt_id << P0_7_VDD_SHIFT) | 154 | tmp = (clk_div | ema_div | (volt_id << P0_7_VDD_SHIFT) |
155 | | ((freq / FREQ_UNIT) << P0_7_FREQ_SHIFT)); | 155 | | ((freq / FREQ_UNIT) << P0_7_FREQ_SHIFT)); |
156 | 156 | ||
157 | __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * | 157 | __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * idx); |
158 | (pos - freq_tbl)); | ||
159 | dev_pm_opp_put(opp); | 158 | dev_pm_opp_put(opp); |
160 | } | 159 | } |
161 | 160 | ||
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 3bbbf9e6960c..6d007f824ca7 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -143,10 +143,9 @@ int cpufreq_table_index_unsorted(struct cpufreq_policy *policy, | |||
143 | break; | 143 | break; |
144 | } | 144 | } |
145 | 145 | ||
146 | cpufreq_for_each_valid_entry(pos, table) { | 146 | cpufreq_for_each_valid_entry_idx(pos, table, i) { |
147 | freq = pos->frequency; | 147 | freq = pos->frequency; |
148 | 148 | ||
149 | i = pos - table; | ||
150 | if ((freq < policy->min) || (freq > policy->max)) | 149 | if ((freq < policy->min) || (freq > policy->max)) |
151 | continue; | 150 | continue; |
152 | if (freq == target_freq) { | 151 | if (freq == target_freq) { |
@@ -211,15 +210,16 @@ int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, | |||
211 | unsigned int freq) | 210 | unsigned int freq) |
212 | { | 211 | { |
213 | struct cpufreq_frequency_table *pos, *table = policy->freq_table; | 212 | struct cpufreq_frequency_table *pos, *table = policy->freq_table; |
213 | int idx; | ||
214 | 214 | ||
215 | if (unlikely(!table)) { | 215 | if (unlikely(!table)) { |
216 | pr_debug("%s: Unable to find frequency table\n", __func__); | 216 | pr_debug("%s: Unable to find frequency table\n", __func__); |
217 | return -ENOENT; | 217 | return -ENOENT; |
218 | } | 218 | } |
219 | 219 | ||
220 | cpufreq_for_each_valid_entry(pos, table) | 220 | cpufreq_for_each_valid_entry_idx(pos, table, idx) |
221 | if (pos->frequency == freq) | 221 | if (pos->frequency == freq) |
222 | return pos - table; | 222 | return idx; |
223 | 223 | ||
224 | return -EINVAL; | 224 | return -EINVAL; |
225 | } | 225 | } |
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 741f22e5cee3..ff67859948b3 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c | |||
@@ -504,6 +504,7 @@ static struct platform_driver imx6q_cpufreq_platdrv = { | |||
504 | }; | 504 | }; |
505 | module_platform_driver(imx6q_cpufreq_platdrv); | 505 | module_platform_driver(imx6q_cpufreq_platdrv); |
506 | 506 | ||
507 | MODULE_ALIAS("platform:imx6q-cpufreq"); | ||
507 | MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>"); | 508 | MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>"); |
508 | MODULE_DESCRIPTION("Freescale i.MX6Q cpufreq driver"); | 509 | MODULE_DESCRIPTION("Freescale i.MX6Q cpufreq driver"); |
509 | MODULE_LICENSE("GPL"); | 510 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 7edf7a0e5a96..6d084c61ee25 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -779,6 +779,8 @@ static int intel_pstate_hwp_save_state(struct cpufreq_policy *policy) | |||
779 | return 0; | 779 | return 0; |
780 | } | 780 | } |
781 | 781 | ||
782 | static void intel_pstate_hwp_enable(struct cpudata *cpudata); | ||
783 | |||
782 | static int intel_pstate_resume(struct cpufreq_policy *policy) | 784 | static int intel_pstate_resume(struct cpufreq_policy *policy) |
783 | { | 785 | { |
784 | if (!hwp_active) | 786 | if (!hwp_active) |
@@ -786,6 +788,9 @@ static int intel_pstate_resume(struct cpufreq_policy *policy) | |||
786 | 788 | ||
787 | mutex_lock(&intel_pstate_limits_lock); | 789 | mutex_lock(&intel_pstate_limits_lock); |
788 | 790 | ||
791 | if (policy->cpu == 0) | ||
792 | intel_pstate_hwp_enable(all_cpu_data[policy->cpu]); | ||
793 | |||
789 | all_cpu_data[policy->cpu]->epp_policy = 0; | 794 | all_cpu_data[policy->cpu]->epp_policy = 0; |
790 | intel_pstate_hwp_set(policy->cpu); | 795 | intel_pstate_hwp_set(policy->cpu); |
791 | 796 | ||
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index 5faa37c5b091..942632a27b50 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
@@ -600,7 +600,7 @@ static void longhaul_setup_voltagescaling(void) | |||
600 | /* Calculate kHz for one voltage step */ | 600 | /* Calculate kHz for one voltage step */ |
601 | kHz_step = (highest_speed - min_vid_speed) / numvscales; | 601 | kHz_step = (highest_speed - min_vid_speed) / numvscales; |
602 | 602 | ||
603 | cpufreq_for_each_entry(freq_pos, longhaul_table) { | 603 | cpufreq_for_each_entry_idx(freq_pos, longhaul_table, j) { |
604 | speed = freq_pos->frequency; | 604 | speed = freq_pos->frequency; |
605 | if (speed > min_vid_speed) | 605 | if (speed > min_vid_speed) |
606 | pos = (speed - min_vid_speed) / kHz_step + minvid.pos; | 606 | pos = (speed - min_vid_speed) / kHz_step + minvid.pos; |
@@ -609,7 +609,7 @@ static void longhaul_setup_voltagescaling(void) | |||
609 | freq_pos->driver_data |= mV_vrm_table[pos] << 8; | 609 | freq_pos->driver_data |= mV_vrm_table[pos] << 8; |
610 | vid = vrm_mV_table[mV_vrm_table[pos]]; | 610 | vid = vrm_mV_table[mV_vrm_table[pos]]; |
611 | pr_info("f: %d kHz, index: %d, vid: %d mV\n", | 611 | pr_info("f: %d kHz, index: %d, vid: %d mV\n", |
612 | speed, (int)(freq_pos - longhaul_table), vid.mV); | 612 | speed, j, vid.mV); |
613 | } | 613 | } |
614 | 614 | ||
615 | can_scale_voltage = 1; | 615 | can_scale_voltage = 1; |
diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c index b257fc7d5204..75dfbd2a58ea 100644 --- a/drivers/cpufreq/pasemi-cpufreq.c +++ b/drivers/cpufreq/pasemi-cpufreq.c | |||
@@ -139,7 +139,7 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
139 | struct cpufreq_frequency_table *pos; | 139 | struct cpufreq_frequency_table *pos; |
140 | const u32 *max_freqp; | 140 | const u32 *max_freqp; |
141 | u32 max_freq; | 141 | u32 max_freq; |
142 | int cur_astate; | 142 | int cur_astate, idx; |
143 | struct resource res; | 143 | struct resource res; |
144 | struct device_node *cpu, *dn; | 144 | struct device_node *cpu, *dn; |
145 | int err = -ENODEV; | 145 | int err = -ENODEV; |
@@ -198,9 +198,9 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
198 | pr_debug("initializing frequency table\n"); | 198 | pr_debug("initializing frequency table\n"); |
199 | 199 | ||
200 | /* initialize frequency table */ | 200 | /* initialize frequency table */ |
201 | cpufreq_for_each_entry(pos, pas_freqs) { | 201 | cpufreq_for_each_entry_idx(pos, pas_freqs, idx) { |
202 | pos->frequency = get_astate_freq(pos->driver_data) * 100000; | 202 | pos->frequency = get_astate_freq(pos->driver_data) * 100000; |
203 | pr_debug("%d: %d\n", (int)(pos - pas_freqs), pos->frequency); | 203 | pr_debug("%d: %d\n", idx, pos->frequency); |
204 | } | 204 | } |
205 | 205 | ||
206 | cur_astate = get_cur_astate(policy->cpu); | 206 | cur_astate = get_cur_astate(policy->cpu); |
diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c index 247fcbfa4cb5..c32a833e1b00 100644 --- a/drivers/cpufreq/scpi-cpufreq.c +++ b/drivers/cpufreq/scpi-cpufreq.c | |||
@@ -145,6 +145,7 @@ static int scpi_cpufreq_init(struct cpufreq_policy *policy) | |||
145 | if (IS_ERR(priv->clk)) { | 145 | if (IS_ERR(priv->clk)) { |
146 | dev_err(cpu_dev, "%s: Failed to get clk for cpu: %d\n", | 146 | dev_err(cpu_dev, "%s: Failed to get clk for cpu: %d\n", |
147 | __func__, cpu_dev->id); | 147 | __func__, cpu_dev->id); |
148 | ret = PTR_ERR(priv->clk); | ||
148 | goto out_free_cpufreq_table; | 149 | goto out_free_cpufreq_table; |
149 | } | 150 | } |
150 | 151 | ||
@@ -197,11 +198,8 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy) | |||
197 | static void scpi_cpufreq_ready(struct cpufreq_policy *policy) | 198 | static void scpi_cpufreq_ready(struct cpufreq_policy *policy) |
198 | { | 199 | { |
199 | struct scpi_data *priv = policy->driver_data; | 200 | struct scpi_data *priv = policy->driver_data; |
200 | struct thermal_cooling_device *cdev; | ||
201 | 201 | ||
202 | cdev = of_cpufreq_cooling_register(policy); | 202 | priv->cdev = of_cpufreq_cooling_register(policy); |
203 | if (!IS_ERR(cdev)) | ||
204 | priv->cdev = cdev; | ||
205 | } | 203 | } |
206 | 204 | ||
207 | static struct cpufreq_driver scpi_cpufreq_driver = { | 205 | static struct cpufreq_driver scpi_cpufreq_driver = { |
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 92863e3818e5..9475353f49d6 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c | |||
@@ -197,10 +197,11 @@ int clk_rate_table_find(struct clk *clk, | |||
197 | unsigned long rate) | 197 | unsigned long rate) |
198 | { | 198 | { |
199 | struct cpufreq_frequency_table *pos; | 199 | struct cpufreq_frequency_table *pos; |
200 | int idx; | ||
200 | 201 | ||
201 | cpufreq_for_each_valid_entry(pos, freq_table) | 202 | cpufreq_for_each_valid_entry_idx(pos, freq_table, idx) |
202 | if (pos->frequency == rate) | 203 | if (pos->frequency == rate) |
203 | return pos - freq_table; | 204 | return idx; |
204 | 205 | ||
205 | return -ENOENT; | 206 | return -ENOENT; |
206 | } | 207 | } |
diff --git a/drivers/staging/irda/drivers/sh_sir.c b/drivers/staging/irda/drivers/sh_sir.c index fede6864c737..0d0687cc454a 100644 --- a/drivers/staging/irda/drivers/sh_sir.c +++ b/drivers/staging/irda/drivers/sh_sir.c | |||
@@ -226,7 +226,7 @@ static u32 sh_sir_find_sclk(struct clk *irda_clk) | |||
226 | clk_put(pclk); | 226 | clk_put(pclk); |
227 | 227 | ||
228 | /* IrDA can not set over peripheral_clk */ | 228 | /* IrDA can not set over peripheral_clk */ |
229 | cpufreq_for_each_valid_entry(pos, freq_table) { | 229 | cpufreq_for_each_valid_entry_idx(pos, freq_table, index) { |
230 | u32 freq = pos->frequency; | 230 | u32 freq = pos->frequency; |
231 | 231 | ||
232 | /* IrDA should not over peripheral_clk */ | 232 | /* IrDA should not over peripheral_clk */ |
@@ -236,7 +236,7 @@ static u32 sh_sir_find_sclk(struct clk *irda_clk) | |||
236 | tmp = freq % SCLK_BASE; | 236 | tmp = freq % SCLK_BASE; |
237 | if (tmp < min) { | 237 | if (tmp < min) { |
238 | min = tmp; | 238 | min = tmp; |
239 | index = pos - freq_table; | 239 | break; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 065f3a8eb486..21e8d248d956 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -629,6 +629,18 @@ static inline void dev_pm_opp_free_cpufreq_table(struct device *dev, | |||
629 | for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++) | 629 | for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++) |
630 | 630 | ||
631 | /* | 631 | /* |
632 | * cpufreq_for_each_entry_idx - iterate over a cpufreq_frequency_table | ||
633 | * with index | ||
634 | * @pos: the cpufreq_frequency_table * to use as a loop cursor. | ||
635 | * @table: the cpufreq_frequency_table * to iterate over. | ||
636 | * @idx: the table entry currently being processed | ||
637 | */ | ||
638 | |||
639 | #define cpufreq_for_each_entry_idx(pos, table, idx) \ | ||
640 | for (pos = table, idx = 0; pos->frequency != CPUFREQ_TABLE_END; \ | ||
641 | pos++, idx++) | ||
642 | |||
643 | /* | ||
632 | * cpufreq_for_each_valid_entry - iterate over a cpufreq_frequency_table | 644 | * cpufreq_for_each_valid_entry - iterate over a cpufreq_frequency_table |
633 | * excluding CPUFREQ_ENTRY_INVALID frequencies. | 645 | * excluding CPUFREQ_ENTRY_INVALID frequencies. |
634 | * @pos: the cpufreq_frequency_table * to use as a loop cursor. | 646 | * @pos: the cpufreq_frequency_table * to use as a loop cursor. |
@@ -641,6 +653,21 @@ static inline void dev_pm_opp_free_cpufreq_table(struct device *dev, | |||
641 | continue; \ | 653 | continue; \ |
642 | else | 654 | else |
643 | 655 | ||
656 | /* | ||
657 | * cpufreq_for_each_valid_entry_idx - iterate with index over a cpufreq | ||
658 | * frequency_table excluding CPUFREQ_ENTRY_INVALID frequencies. | ||
659 | * @pos: the cpufreq_frequency_table * to use as a loop cursor. | ||
660 | * @table: the cpufreq_frequency_table * to iterate over. | ||
661 | * @idx: the table entry currently being processed | ||
662 | */ | ||
663 | |||
664 | #define cpufreq_for_each_valid_entry_idx(pos, table, idx) \ | ||
665 | cpufreq_for_each_entry_idx(pos, table, idx) \ | ||
666 | if (pos->frequency == CPUFREQ_ENTRY_INVALID) \ | ||
667 | continue; \ | ||
668 | else | ||
669 | |||
670 | |||
644 | int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, | 671 | int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, |
645 | struct cpufreq_frequency_table *table); | 672 | struct cpufreq_frequency_table *table); |
646 | 673 | ||
@@ -667,19 +694,20 @@ static inline int cpufreq_table_find_index_al(struct cpufreq_policy *policy, | |||
667 | unsigned int target_freq) | 694 | unsigned int target_freq) |
668 | { | 695 | { |
669 | struct cpufreq_frequency_table *table = policy->freq_table; | 696 | struct cpufreq_frequency_table *table = policy->freq_table; |
670 | struct cpufreq_frequency_table *pos, *best = table - 1; | 697 | struct cpufreq_frequency_table *pos; |
671 | unsigned int freq; | 698 | unsigned int freq; |
699 | int idx, best = -1; | ||
672 | 700 | ||
673 | cpufreq_for_each_valid_entry(pos, table) { | 701 | cpufreq_for_each_valid_entry_idx(pos, table, idx) { |
674 | freq = pos->frequency; | 702 | freq = pos->frequency; |
675 | 703 | ||
676 | if (freq >= target_freq) | 704 | if (freq >= target_freq) |
677 | return pos - table; | 705 | return idx; |
678 | 706 | ||
679 | best = pos; | 707 | best = idx; |
680 | } | 708 | } |
681 | 709 | ||
682 | return best - table; | 710 | return best; |
683 | } | 711 | } |
684 | 712 | ||
685 | /* Find lowest freq at or above target in a table in descending order */ | 713 | /* Find lowest freq at or above target in a table in descending order */ |
@@ -687,28 +715,29 @@ static inline int cpufreq_table_find_index_dl(struct cpufreq_policy *policy, | |||
687 | unsigned int target_freq) | 715 | unsigned int target_freq) |
688 | { | 716 | { |
689 | struct cpufreq_frequency_table *table = policy->freq_table; | 717 | struct cpufreq_frequency_table *table = policy->freq_table; |
690 | struct cpufreq_frequency_table *pos, *best = table - 1; | 718 | struct cpufreq_frequency_table *pos; |
691 | unsigned int freq; | 719 | unsigned int freq; |
720 | int idx, best = -1; | ||
692 | 721 | ||
693 | cpufreq_for_each_valid_entry(pos, table) { | 722 | cpufreq_for_each_valid_entry_idx(pos, table, idx) { |
694 | freq = pos->frequency; | 723 | freq = pos->frequency; |
695 | 724 | ||
696 | if (freq == target_freq) | 725 | if (freq == target_freq) |
697 | return pos - table; | 726 | return idx; |
698 | 727 | ||
699 | if (freq > target_freq) { | 728 | if (freq > target_freq) { |
700 | best = pos; | 729 | best = idx; |
701 | continue; | 730 | continue; |
702 | } | 731 | } |
703 | 732 | ||
704 | /* No freq found above target_freq */ | 733 | /* No freq found above target_freq */ |
705 | if (best == table - 1) | 734 | if (best == -1) |
706 | return pos - table; | 735 | return idx; |
707 | 736 | ||
708 | return best - table; | 737 | return best; |
709 | } | 738 | } |
710 | 739 | ||
711 | return best - table; | 740 | return best; |
712 | } | 741 | } |
713 | 742 | ||
714 | /* Works only on sorted freq-tables */ | 743 | /* Works only on sorted freq-tables */ |
@@ -728,28 +757,29 @@ static inline int cpufreq_table_find_index_ah(struct cpufreq_policy *policy, | |||
728 | unsigned int target_freq) | 757 | unsigned int target_freq) |
729 | { | 758 | { |
730 | struct cpufreq_frequency_table *table = policy->freq_table; | 759 | struct cpufreq_frequency_table *table = policy->freq_table; |
731 | struct cpufreq_frequency_table *pos, *best = table - 1; | 760 | struct cpufreq_frequency_table *pos; |
732 | unsigned int freq; | 761 | unsigned int freq; |
762 | int idx, best = -1; | ||
733 | 763 | ||
734 | cpufreq_for_each_valid_entry(pos, table) { | 764 | cpufreq_for_each_valid_entry_idx(pos, table, idx) { |
735 | freq = pos->frequency; | 765 | freq = pos->frequency; |
736 | 766 | ||
737 | if (freq == target_freq) | 767 | if (freq == target_freq) |
738 | return pos - table; | 768 | return idx; |
739 | 769 | ||
740 | if (freq < target_freq) { | 770 | if (freq < target_freq) { |
741 | best = pos; | 771 | best = idx; |
742 | continue; | 772 | continue; |
743 | } | 773 | } |
744 | 774 | ||
745 | /* No freq found below target_freq */ | 775 | /* No freq found below target_freq */ |
746 | if (best == table - 1) | 776 | if (best == -1) |
747 | return pos - table; | 777 | return idx; |
748 | 778 | ||
749 | return best - table; | 779 | return best; |
750 | } | 780 | } |
751 | 781 | ||
752 | return best - table; | 782 | return best; |
753 | } | 783 | } |
754 | 784 | ||
755 | /* Find highest freq at or below target in a table in descending order */ | 785 | /* Find highest freq at or below target in a table in descending order */ |
@@ -757,19 +787,20 @@ static inline int cpufreq_table_find_index_dh(struct cpufreq_policy *policy, | |||
757 | unsigned int target_freq) | 787 | unsigned int target_freq) |
758 | { | 788 | { |
759 | struct cpufreq_frequency_table *table = policy->freq_table; | 789 | struct cpufreq_frequency_table *table = policy->freq_table; |
760 | struct cpufreq_frequency_table *pos, *best = table - 1; | 790 | struct cpufreq_frequency_table *pos; |
761 | unsigned int freq; | 791 | unsigned int freq; |
792 | int idx, best = -1; | ||
762 | 793 | ||
763 | cpufreq_for_each_valid_entry(pos, table) { | 794 | cpufreq_for_each_valid_entry_idx(pos, table, idx) { |
764 | freq = pos->frequency; | 795 | freq = pos->frequency; |
765 | 796 | ||
766 | if (freq <= target_freq) | 797 | if (freq <= target_freq) |
767 | return pos - table; | 798 | return idx; |
768 | 799 | ||
769 | best = pos; | 800 | best = idx; |
770 | } | 801 | } |
771 | 802 | ||
772 | return best - table; | 803 | return best; |
773 | } | 804 | } |
774 | 805 | ||
775 | /* Works only on sorted freq-tables */ | 806 | /* Works only on sorted freq-tables */ |
@@ -789,32 +820,33 @@ static inline int cpufreq_table_find_index_ac(struct cpufreq_policy *policy, | |||
789 | unsigned int target_freq) | 820 | unsigned int target_freq) |
790 | { | 821 | { |
791 | struct cpufreq_frequency_table *table = policy->freq_table; | 822 | struct cpufreq_frequency_table *table = policy->freq_table; |
792 | struct cpufreq_frequency_table *pos, *best = table - 1; | 823 | struct cpufreq_frequency_table *pos; |
793 | unsigned int freq; | 824 | unsigned int freq; |
825 | int idx, best = -1; | ||
794 | 826 | ||
795 | cpufreq_for_each_valid_entry(pos, table) { | 827 | cpufreq_for_each_valid_entry_idx(pos, table, idx) { |
796 | freq = pos->frequency; | 828 | freq = pos->frequency; |
797 | 829 | ||
798 | if (freq == target_freq) | 830 | if (freq == target_freq) |
799 | return pos - table; | 831 | return idx; |
800 | 832 | ||
801 | if (freq < target_freq) { | 833 | if (freq < target_freq) { |
802 | best = pos; | 834 | best = idx; |
803 | continue; | 835 | continue; |
804 | } | 836 | } |
805 | 837 | ||
806 | /* No freq found below target_freq */ | 838 | /* No freq found below target_freq */ |
807 | if (best == table - 1) | 839 | if (best == -1) |
808 | return pos - table; | 840 | return idx; |
809 | 841 | ||
810 | /* Choose the closest freq */ | 842 | /* Choose the closest freq */ |
811 | if (target_freq - best->frequency > freq - target_freq) | 843 | if (target_freq - table[best].frequency > freq - target_freq) |
812 | return pos - table; | 844 | return idx; |
813 | 845 | ||
814 | return best - table; | 846 | return best; |
815 | } | 847 | } |
816 | 848 | ||
817 | return best - table; | 849 | return best; |
818 | } | 850 | } |
819 | 851 | ||
820 | /* Find closest freq to target in a table in descending order */ | 852 | /* Find closest freq to target in a table in descending order */ |
@@ -822,32 +854,33 @@ static inline int cpufreq_table_find_index_dc(struct cpufreq_policy *policy, | |||
822 | unsigned int target_freq) | 854 | unsigned int target_freq) |
823 | { | 855 | { |
824 | struct cpufreq_frequency_table *table = policy->freq_table; | 856 | struct cpufreq_frequency_table *table = policy->freq_table; |
825 | struct cpufreq_frequency_table *pos, *best = table - 1; | 857 | struct cpufreq_frequency_table *pos; |
826 | unsigned int freq; | 858 | unsigned int freq; |
859 | int idx, best = -1; | ||
827 | 860 | ||
828 | cpufreq_for_each_valid_entry(pos, table) { | 861 | cpufreq_for_each_valid_entry_idx(pos, table, idx) { |
829 | freq = pos->frequency; | 862 | freq = pos->frequency; |
830 | 863 | ||
831 | if (freq == target_freq) | 864 | if (freq == target_freq) |
832 | return pos - table; | 865 | return idx; |
833 | 866 | ||
834 | if (freq > target_freq) { | 867 | if (freq > target_freq) { |
835 | best = pos; | 868 | best = idx; |
836 | continue; | 869 | continue; |
837 | } | 870 | } |
838 | 871 | ||
839 | /* No freq found above target_freq */ | 872 | /* No freq found above target_freq */ |
840 | if (best == table - 1) | 873 | if (best == -1) |
841 | return pos - table; | 874 | return idx; |
842 | 875 | ||
843 | /* Choose the closest freq */ | 876 | /* Choose the closest freq */ |
844 | if (best->frequency - target_freq > target_freq - freq) | 877 | if (table[best].frequency - target_freq > target_freq - freq) |
845 | return pos - table; | 878 | return idx; |
846 | 879 | ||
847 | return best - table; | 880 | return best; |
848 | } | 881 | } |
849 | 882 | ||
850 | return best - table; | 883 | return best; |
851 | } | 884 | } |
852 | 885 | ||
853 | /* Works only on sorted freq-tables */ | 886 | /* Works only on sorted freq-tables */ |