diff options
39 files changed, 418 insertions, 391 deletions
diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu index d5a0d33c571f..acb9bfc89b48 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu | |||
@@ -128,7 +128,7 @@ Description: Discover cpuidle policy and mechanism | |||
128 | 128 | ||
129 | What: /sys/devices/system/cpu/cpu#/cpufreq/* | 129 | What: /sys/devices/system/cpu/cpu#/cpufreq/* |
130 | Date: pre-git history | 130 | Date: pre-git history |
131 | Contact: cpufreq@vger.kernel.org | 131 | Contact: linux-pm@vger.kernel.org |
132 | Description: Discover and change clock speed of CPUs | 132 | Description: Discover and change clock speed of CPUs |
133 | 133 | ||
134 | Clock scaling allows you to change the clock speed of the | 134 | Clock scaling allows you to change the clock speed of the |
@@ -146,7 +146,7 @@ Description: Discover and change clock speed of CPUs | |||
146 | 146 | ||
147 | What: /sys/devices/system/cpu/cpu#/cpufreq/freqdomain_cpus | 147 | What: /sys/devices/system/cpu/cpu#/cpufreq/freqdomain_cpus |
148 | Date: June 2013 | 148 | Date: June 2013 |
149 | Contact: cpufreq@vger.kernel.org | 149 | Contact: linux-pm@vger.kernel.org |
150 | Description: Discover CPUs in the same CPU frequency coordination domain | 150 | Description: Discover CPUs in the same CPU frequency coordination domain |
151 | 151 | ||
152 | freqdomain_cpus is the list of CPUs (online+offline) that share | 152 | freqdomain_cpus is the list of CPUs (online+offline) that share |
diff --git a/Documentation/cpu-freq/core.txt b/Documentation/cpu-freq/core.txt index 0060d76b445f..70933eadc308 100644 --- a/Documentation/cpu-freq/core.txt +++ b/Documentation/cpu-freq/core.txt | |||
@@ -20,6 +20,7 @@ Contents: | |||
20 | --------- | 20 | --------- |
21 | 1. CPUFreq core and interfaces | 21 | 1. CPUFreq core and interfaces |
22 | 2. CPUFreq notifiers | 22 | 2. CPUFreq notifiers |
23 | 3. CPUFreq Table Generation with Operating Performance Point (OPP) | ||
23 | 24 | ||
24 | 1. General Information | 25 | 1. General Information |
25 | ======================= | 26 | ======================= |
@@ -92,3 +93,31 @@ values: | |||
92 | cpu - number of the affected CPU | 93 | cpu - number of the affected CPU |
93 | old - old frequency | 94 | old - old frequency |
94 | new - new frequency | 95 | new - new frequency |
96 | |||
97 | 3. CPUFreq Table Generation with Operating Performance Point (OPP) | ||
98 | ================================================================== | ||
99 | For details about OPP, see Documentation/power/opp.txt | ||
100 | |||
101 | dev_pm_opp_init_cpufreq_table - cpufreq framework typically is initialized with | ||
102 | cpufreq_frequency_table_cpuinfo which is provided with the list of | ||
103 | frequencies that are available for operation. This function provides | ||
104 | a ready to use conversion routine to translate the OPP layer's internal | ||
105 | information about the available frequencies into a format readily | ||
106 | providable to cpufreq. | ||
107 | |||
108 | WARNING: Do not use this function in interrupt context. | ||
109 | |||
110 | Example: | ||
111 | soc_pm_init() | ||
112 | { | ||
113 | /* Do things */ | ||
114 | r = dev_pm_opp_init_cpufreq_table(dev, &freq_table); | ||
115 | if (!r) | ||
116 | cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
117 | /* Do other things */ | ||
118 | } | ||
119 | |||
120 | NOTE: This function is available only if CONFIG_CPU_FREQ is enabled in | ||
121 | addition to CONFIG_PM_OPP. | ||
122 | |||
123 | dev_pm_opp_free_cpufreq_table - Free up the table allocated by dev_pm_opp_init_cpufreq_table | ||
diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt index 48da5fdcb9f1..b045fe54986a 100644 --- a/Documentation/cpu-freq/cpu-drivers.txt +++ b/Documentation/cpu-freq/cpu-drivers.txt | |||
@@ -228,3 +228,22 @@ is the corresponding frequency table helper for the ->target | |||
228 | stage. Just pass the values to this function, and the unsigned int | 228 | stage. Just pass the values to this function, and the unsigned int |
229 | index returns the number of the frequency table entry which contains | 229 | index returns the number of the frequency table entry which contains |
230 | the frequency the CPU shall be set to. | 230 | the frequency the CPU shall be set to. |
231 | |||
232 | The following macros can be used as iterators over cpufreq_frequency_table: | ||
233 | |||
234 | cpufreq_for_each_entry(pos, table) - iterates over all entries of frequency | ||
235 | table. | ||
236 | |||
237 | cpufreq-for_each_valid_entry(pos, table) - iterates over all entries, | ||
238 | excluding CPUFREQ_ENTRY_INVALID frequencies. | ||
239 | Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and | ||
240 | "table" - the cpufreq_frequency_table * you want to iterate over. | ||
241 | |||
242 | For example: | ||
243 | |||
244 | struct cpufreq_frequency_table *pos, *driver_freq_table; | ||
245 | |||
246 | cpufreq_for_each_entry(pos, driver_freq_table) { | ||
247 | /* Do something with pos */ | ||
248 | pos->frequency = ... | ||
249 | } | ||
diff --git a/Documentation/cpu-freq/index.txt b/Documentation/cpu-freq/index.txt index 3d0b915035b9..dc024ab4054f 100644 --- a/Documentation/cpu-freq/index.txt +++ b/Documentation/cpu-freq/index.txt | |||
@@ -35,8 +35,8 @@ Mailing List | |||
35 | ------------ | 35 | ------------ |
36 | There is a CPU frequency changing CVS commit and general list where | 36 | There is a CPU frequency changing CVS commit and general list where |
37 | you can report bugs, problems or submit patches. To post a message, | 37 | you can report bugs, problems or submit patches. To post a message, |
38 | send an email to cpufreq@vger.kernel.org, to subscribe go to | 38 | send an email to linux-pm@vger.kernel.org, to subscribe go to |
39 | http://vger.kernel.org/vger-lists.html#cpufreq and follow the | 39 | http://vger.kernel.org/vger-lists.html#linux-pm and follow the |
40 | instructions there. | 40 | instructions there. |
41 | 41 | ||
42 | Links | 42 | Links |
diff --git a/Documentation/power/opp.txt b/Documentation/power/opp.txt index b8a907dc0169..a9adad828cdc 100644 --- a/Documentation/power/opp.txt +++ b/Documentation/power/opp.txt | |||
@@ -10,8 +10,7 @@ Contents | |||
10 | 3. OPP Search Functions | 10 | 3. OPP Search Functions |
11 | 4. OPP Availability Control Functions | 11 | 4. OPP Availability Control Functions |
12 | 5. OPP Data Retrieval Functions | 12 | 5. OPP Data Retrieval Functions |
13 | 6. Cpufreq Table Generation | 13 | 6. Data Structures |
14 | 7. Data Structures | ||
15 | 14 | ||
16 | 1. Introduction | 15 | 1. Introduction |
17 | =============== | 16 | =============== |
@@ -72,7 +71,6 @@ operations until that OPP could be re-enabled if possible. | |||
72 | OPP library facilitates this concept in it's implementation. The following | 71 | OPP library facilitates this concept in it's implementation. The following |
73 | operational functions operate only on available opps: | 72 | operational functions operate only on available opps: |
74 | opp_find_freq_{ceil, floor}, dev_pm_opp_get_voltage, dev_pm_opp_get_freq, dev_pm_opp_get_opp_count | 73 | opp_find_freq_{ceil, floor}, dev_pm_opp_get_voltage, dev_pm_opp_get_freq, dev_pm_opp_get_opp_count |
75 | and dev_pm_opp_init_cpufreq_table | ||
76 | 74 | ||
77 | dev_pm_opp_find_freq_exact is meant to be used to find the opp pointer which can then | 75 | dev_pm_opp_find_freq_exact is meant to be used to find the opp pointer which can then |
78 | be used for dev_pm_opp_enable/disable functions to make an opp available as required. | 76 | be used for dev_pm_opp_enable/disable functions to make an opp available as required. |
@@ -96,10 +94,9 @@ using RCU read locks. The opp_find_freq_{exact,ceil,floor}, | |||
96 | opp_get_{voltage, freq, opp_count} fall into this category. | 94 | opp_get_{voltage, freq, opp_count} fall into this category. |
97 | 95 | ||
98 | opp_{add,enable,disable} are updaters which use mutex and implement it's own | 96 | opp_{add,enable,disable} are updaters which use mutex and implement it's own |
99 | RCU locking mechanisms. dev_pm_opp_init_cpufreq_table acts as an updater and uses | 97 | RCU locking mechanisms. These functions should *NOT* be called under RCU locks |
100 | mutex to implment RCU updater strategy. These functions should *NOT* be called | 98 | and other contexts that prevent blocking functions in RCU or mutex operations |
101 | under RCU locks and other contexts that prevent blocking functions in RCU or | 99 | from working. |
102 | mutex operations from working. | ||
103 | 100 | ||
104 | 2. Initial OPP List Registration | 101 | 2. Initial OPP List Registration |
105 | ================================ | 102 | ================================ |
@@ -311,34 +308,7 @@ dev_pm_opp_get_opp_count - Retrieve the number of available opps for a device | |||
311 | /* Do other things */ | 308 | /* Do other things */ |
312 | } | 309 | } |
313 | 310 | ||
314 | 6. Cpufreq Table Generation | 311 | 6. Data Structures |
315 | =========================== | ||
316 | dev_pm_opp_init_cpufreq_table - cpufreq framework typically is initialized with | ||
317 | cpufreq_frequency_table_cpuinfo which is provided with the list of | ||
318 | frequencies that are available for operation. This function provides | ||
319 | a ready to use conversion routine to translate the OPP layer's internal | ||
320 | information about the available frequencies into a format readily | ||
321 | providable to cpufreq. | ||
322 | |||
323 | WARNING: Do not use this function in interrupt context. | ||
324 | |||
325 | Example: | ||
326 | soc_pm_init() | ||
327 | { | ||
328 | /* Do things */ | ||
329 | r = dev_pm_opp_init_cpufreq_table(dev, &freq_table); | ||
330 | if (!r) | ||
331 | cpufreq_frequency_table_cpuinfo(policy, freq_table); | ||
332 | /* Do other things */ | ||
333 | } | ||
334 | |||
335 | NOTE: This function is available only if CONFIG_CPU_FREQ is enabled in | ||
336 | addition to CONFIG_PM as power management feature is required to | ||
337 | dynamically scale voltage and frequency in a system. | ||
338 | |||
339 | dev_pm_opp_free_cpufreq_table - Free up the table allocated by dev_pm_opp_init_cpufreq_table | ||
340 | |||
341 | 7. Data Structures | ||
342 | ================== | 312 | ================== |
343 | Typically an SoC contains multiple voltage domains which are variable. Each | 313 | Typically an SoC contains multiple voltage domains which are variable. Each |
344 | domain is represented by a device pointer. The relationship to OPP can be | 314 | domain is represented by a device pointer. The relationship to OPP can be |
diff --git a/MAINTAINERS b/MAINTAINERS index 106626442124..06d2506a8d2d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -2415,7 +2415,6 @@ F: drivers/net/ethernet/ti/cpmac.c | |||
2415 | CPU FREQUENCY DRIVERS | 2415 | CPU FREQUENCY DRIVERS |
2416 | M: Rafael J. Wysocki <rjw@rjwysocki.net> | 2416 | M: Rafael J. Wysocki <rjw@rjwysocki.net> |
2417 | M: Viresh Kumar <viresh.kumar@linaro.org> | 2417 | M: Viresh Kumar <viresh.kumar@linaro.org> |
2418 | L: cpufreq@vger.kernel.org | ||
2419 | L: linux-pm@vger.kernel.org | 2418 | L: linux-pm@vger.kernel.org |
2420 | S: Maintained | 2419 | S: Maintained |
2421 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git | 2420 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git |
@@ -2426,7 +2425,6 @@ F: include/linux/cpufreq.h | |||
2426 | CPU FREQUENCY DRIVERS - ARM BIG LITTLE | 2425 | CPU FREQUENCY DRIVERS - ARM BIG LITTLE |
2427 | M: Viresh Kumar <viresh.kumar@linaro.org> | 2426 | M: Viresh Kumar <viresh.kumar@linaro.org> |
2428 | M: Sudeep Holla <sudeep.holla@arm.com> | 2427 | M: Sudeep Holla <sudeep.holla@arm.com> |
2429 | L: cpufreq@vger.kernel.org | ||
2430 | L: linux-pm@vger.kernel.org | 2428 | L: linux-pm@vger.kernel.org |
2431 | W: http://www.arm.com/products/processors/technologies/biglittleprocessing.php | 2429 | W: http://www.arm.com/products/processors/technologies/biglittleprocessing.php |
2432 | S: Maintained | 2430 | S: Maintained |
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index 85399c98f84a..45ce065e7170 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c | |||
@@ -1092,20 +1092,21 @@ int da850_register_cpufreq(char *async_clk) | |||
1092 | 1092 | ||
1093 | static int da850_round_armrate(struct clk *clk, unsigned long rate) | 1093 | static int da850_round_armrate(struct clk *clk, unsigned long rate) |
1094 | { | 1094 | { |
1095 | int i, ret = 0, diff; | 1095 | int ret = 0, diff; |
1096 | unsigned int best = (unsigned int) -1; | 1096 | unsigned int best = (unsigned int) -1; |
1097 | struct cpufreq_frequency_table *table = cpufreq_info.freq_table; | 1097 | struct cpufreq_frequency_table *table = cpufreq_info.freq_table; |
1098 | struct cpufreq_frequency_table *pos; | ||
1098 | 1099 | ||
1099 | rate /= 1000; /* convert to kHz */ | 1100 | rate /= 1000; /* convert to kHz */ |
1100 | 1101 | ||
1101 | for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 1102 | cpufreq_for_each_entry(pos, table) { |
1102 | diff = table[i].frequency - rate; | 1103 | diff = pos->frequency - rate; |
1103 | if (diff < 0) | 1104 | if (diff < 0) |
1104 | diff = -diff; | 1105 | diff = -diff; |
1105 | 1106 | ||
1106 | if (diff < best) { | 1107 | if (diff < best) { |
1107 | best = diff; | 1108 | best = diff; |
1108 | ret = table[i].frequency; | 1109 | ret = pos->frequency; |
1109 | } | 1110 | } |
1110 | } | 1111 | } |
1111 | 1112 | ||
diff --git a/arch/mips/loongson/lemote-2f/clock.c b/arch/mips/loongson/lemote-2f/clock.c index e1f427f4f5f3..1eed38e28b1e 100644 --- a/arch/mips/loongson/lemote-2f/clock.c +++ b/arch/mips/loongson/lemote-2f/clock.c | |||
@@ -91,9 +91,9 @@ EXPORT_SYMBOL(clk_put); | |||
91 | 91 | ||
92 | int clk_set_rate(struct clk *clk, unsigned long rate) | 92 | int clk_set_rate(struct clk *clk, unsigned long rate) |
93 | { | 93 | { |
94 | struct cpufreq_frequency_table *pos; | ||
94 | int ret = 0; | 95 | int ret = 0; |
95 | int regval; | 96 | int regval; |
96 | int i; | ||
97 | 97 | ||
98 | if (likely(clk->ops && clk->ops->set_rate)) { | 98 | if (likely(clk->ops && clk->ops->set_rate)) { |
99 | unsigned long flags; | 99 | unsigned long flags; |
@@ -106,22 +106,16 @@ int clk_set_rate(struct clk *clk, unsigned long rate) | |||
106 | if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) | 106 | if (unlikely(clk->flags & CLK_RATE_PROPAGATES)) |
107 | propagate_rate(clk); | 107 | propagate_rate(clk); |
108 | 108 | ||
109 | for (i = 0; loongson2_clockmod_table[i].frequency != CPUFREQ_TABLE_END; | 109 | cpufreq_for_each_valid_entry(pos, loongson2_clockmod_table) |
110 | i++) { | 110 | if (rate == pos->frequency) |
111 | if (loongson2_clockmod_table[i].frequency == | ||
112 | CPUFREQ_ENTRY_INVALID) | ||
113 | continue; | ||
114 | if (rate == loongson2_clockmod_table[i].frequency) | ||
115 | break; | 111 | break; |
116 | } | 112 | if (rate != pos->frequency) |
117 | if (rate != loongson2_clockmod_table[i].frequency) | ||
118 | return -ENOTSUPP; | 113 | return -ENOTSUPP; |
119 | 114 | ||
120 | clk->rate = rate; | 115 | clk->rate = rate; |
121 | 116 | ||
122 | regval = LOONGSON_CHIPCFG0; | 117 | regval = LOONGSON_CHIPCFG0; |
123 | regval = (regval & ~0x7) | | 118 | regval = (regval & ~0x7) | (pos->driver_data - 1); |
124 | (loongson2_clockmod_table[i].driver_data - 1); | ||
125 | LOONGSON_CHIPCFG0 = regval; | 119 | LOONGSON_CHIPCFG0 = regval; |
126 | 120 | ||
127 | return ret; | 121 | return ret; |
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 25538675d59e..d9e376a6d19d 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/errno.h> | 15 | #include <linux/errno.h> |
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/cpufreq.h> | ||
19 | #include <linux/device.h> | 18 | #include <linux/device.h> |
20 | #include <linux/list.h> | 19 | #include <linux/list.h> |
21 | #include <linux/rculist.h> | 20 | #include <linux/rculist.h> |
@@ -596,96 +595,6 @@ int dev_pm_opp_disable(struct device *dev, unsigned long freq) | |||
596 | } | 595 | } |
597 | EXPORT_SYMBOL_GPL(dev_pm_opp_disable); | 596 | EXPORT_SYMBOL_GPL(dev_pm_opp_disable); |
598 | 597 | ||
599 | #ifdef CONFIG_CPU_FREQ | ||
600 | /** | ||
601 | * dev_pm_opp_init_cpufreq_table() - create a cpufreq table for a device | ||
602 | * @dev: device for which we do this operation | ||
603 | * @table: Cpufreq table returned back to caller | ||
604 | * | ||
605 | * Generate a cpufreq table for a provided device- this assumes that the | ||
606 | * opp list is already initialized and ready for usage. | ||
607 | * | ||
608 | * This function allocates required memory for the cpufreq table. It is | ||
609 | * expected that the caller does the required maintenance such as freeing | ||
610 | * the table as required. | ||
611 | * | ||
612 | * Returns -EINVAL for bad pointers, -ENODEV if the device is not found, -ENOMEM | ||
613 | * if no memory available for the operation (table is not populated), returns 0 | ||
614 | * if successful and table is populated. | ||
615 | * | ||
616 | * WARNING: It is important for the callers to ensure refreshing their copy of | ||
617 | * the table if any of the mentioned functions have been invoked in the interim. | ||
618 | * | ||
619 | * Locking: The internal device_opp and opp structures are RCU protected. | ||
620 | * To simplify the logic, we pretend we are updater and hold relevant mutex here | ||
621 | * Callers should ensure that this function is *NOT* called under RCU protection | ||
622 | * or in contexts where mutex locking cannot be used. | ||
623 | */ | ||
624 | int dev_pm_opp_init_cpufreq_table(struct device *dev, | ||
625 | struct cpufreq_frequency_table **table) | ||
626 | { | ||
627 | struct device_opp *dev_opp; | ||
628 | struct dev_pm_opp *opp; | ||
629 | struct cpufreq_frequency_table *freq_table; | ||
630 | int i = 0; | ||
631 | |||
632 | /* Pretend as if I am an updater */ | ||
633 | mutex_lock(&dev_opp_list_lock); | ||
634 | |||
635 | dev_opp = find_device_opp(dev); | ||
636 | if (IS_ERR(dev_opp)) { | ||
637 | int r = PTR_ERR(dev_opp); | ||
638 | mutex_unlock(&dev_opp_list_lock); | ||
639 | dev_err(dev, "%s: Device OPP not found (%d)\n", __func__, r); | ||
640 | return r; | ||
641 | } | ||
642 | |||
643 | freq_table = kzalloc(sizeof(struct cpufreq_frequency_table) * | ||
644 | (dev_pm_opp_get_opp_count(dev) + 1), GFP_KERNEL); | ||
645 | if (!freq_table) { | ||
646 | mutex_unlock(&dev_opp_list_lock); | ||
647 | dev_warn(dev, "%s: Unable to allocate frequency table\n", | ||
648 | __func__); | ||
649 | return -ENOMEM; | ||
650 | } | ||
651 | |||
652 | list_for_each_entry(opp, &dev_opp->opp_list, node) { | ||
653 | if (opp->available) { | ||
654 | freq_table[i].driver_data = i; | ||
655 | freq_table[i].frequency = opp->rate / 1000; | ||
656 | i++; | ||
657 | } | ||
658 | } | ||
659 | mutex_unlock(&dev_opp_list_lock); | ||
660 | |||
661 | freq_table[i].driver_data = i; | ||
662 | freq_table[i].frequency = CPUFREQ_TABLE_END; | ||
663 | |||
664 | *table = &freq_table[0]; | ||
665 | |||
666 | return 0; | ||
667 | } | ||
668 | EXPORT_SYMBOL_GPL(dev_pm_opp_init_cpufreq_table); | ||
669 | |||
670 | /** | ||
671 | * dev_pm_opp_free_cpufreq_table() - free the cpufreq table | ||
672 | * @dev: device for which we do this operation | ||
673 | * @table: table to free | ||
674 | * | ||
675 | * Free up the table allocated by dev_pm_opp_init_cpufreq_table | ||
676 | */ | ||
677 | void dev_pm_opp_free_cpufreq_table(struct device *dev, | ||
678 | struct cpufreq_frequency_table **table) | ||
679 | { | ||
680 | if (!table) | ||
681 | return; | ||
682 | |||
683 | kfree(*table); | ||
684 | *table = NULL; | ||
685 | } | ||
686 | EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); | ||
687 | #endif /* CONFIG_CPU_FREQ */ | ||
688 | |||
689 | /** | 598 | /** |
690 | * dev_pm_opp_get_notifier() - find notifier_head of the device with opp | 599 | * dev_pm_opp_get_notifier() - find notifier_head of the device with opp |
691 | * @dev: device pointer used to lookup device OPPs. | 600 | * @dev: device pointer used to lookup device OPPs. |
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index 580503513f0f..6e05a1e18e52 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm | |||
@@ -85,7 +85,7 @@ config ARM_EXYNOS_CPU_FREQ_BOOST_SW | |||
85 | It allows usage of special frequencies for Samsung Exynos | 85 | It allows usage of special frequencies for Samsung Exynos |
86 | processors if thermal conditions are appropriate. | 86 | processors if thermal conditions are appropriate. |
87 | 87 | ||
88 | It reguires, for safe operation, thermal framework with properly | 88 | It requires, for safe operation, thermal framework with properly |
89 | defined trip points. | 89 | defined trip points. |
90 | 90 | ||
91 | If in doubt, say N. | 91 | If in doubt, say N. |
@@ -186,7 +186,7 @@ config ARM_S3C2416_CPUFREQ | |||
186 | S3C2450 SoC. The S3C2416 supports changing the rate of the | 186 | S3C2450 SoC. The S3C2416 supports changing the rate of the |
187 | armdiv clock source and also entering a so called dynamic | 187 | armdiv clock source and also entering a so called dynamic |
188 | voltage scaling mode in which it is possible to reduce the | 188 | voltage scaling mode in which it is possible to reduce the |
189 | core voltage of the cpu. | 189 | core voltage of the CPU. |
190 | 190 | ||
191 | If in doubt, say N. | 191 | If in doubt, say N. |
192 | 192 | ||
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86 index d369349eeaab..89ae88f91895 100644 --- a/drivers/cpufreq/Kconfig.x86 +++ b/drivers/cpufreq/Kconfig.x86 | |||
@@ -10,7 +10,7 @@ config X86_INTEL_PSTATE | |||
10 | The driver implements an internal governor and will become | 10 | The driver implements an internal governor and will become |
11 | the scaling driver and governor for Sandy bridge processors. | 11 | the scaling driver and governor for Sandy bridge processors. |
12 | 12 | ||
13 | When this driver is enabled it will become the perferred | 13 | When this driver is enabled it will become the preferred |
14 | scaling driver for Sandy bridge processors. | 14 | scaling driver for Sandy bridge processors. |
15 | 15 | ||
16 | If in doubt, say N. | 16 | If in doubt, say N. |
@@ -52,7 +52,7 @@ config X86_ACPI_CPUFREQ_CPB | |||
52 | help | 52 | help |
53 | The powernow-k8 driver used to provide a sysfs knob called "cpb" | 53 | The powernow-k8 driver used to provide a sysfs knob called "cpb" |
54 | to disable the Core Performance Boosting feature of AMD CPUs. This | 54 | to disable the Core Performance Boosting feature of AMD CPUs. This |
55 | file has now been superseeded by the more generic "boost" entry. | 55 | file has now been superseded by the more generic "boost" entry. |
56 | 56 | ||
57 | By enabling this option the acpi_cpufreq driver provides the old | 57 | By enabling this option the acpi_cpufreq driver provides the old |
58 | entry in addition to the new boost ones, for compatibility reasons. | 58 | entry in addition to the new boost ones, for compatibility reasons. |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 0dbb963c1aef..738c8b7b17dc 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
@@ -1,5 +1,7 @@ | |||
1 | # CPUfreq core | 1 | # CPUfreq core |
2 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o | 2 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o freq_table.o |
3 | obj-$(CONFIG_PM_OPP) += cpufreq_opp.o | ||
4 | |||
3 | # CPUfreq stats | 5 | # CPUfreq stats |
4 | obj-$(CONFIG_CPU_FREQ_STAT) += cpufreq_stats.o | 6 | obj-$(CONFIG_CPU_FREQ_STAT) += cpufreq_stats.o |
5 | 7 | ||
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 000e4e0afd7e..b0c18ed8d83f 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
@@ -213,7 +213,7 @@ static unsigned extract_io(u32 value, struct acpi_cpufreq_data *data) | |||
213 | 213 | ||
214 | static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) | 214 | static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) |
215 | { | 215 | { |
216 | int i; | 216 | struct cpufreq_frequency_table *pos; |
217 | struct acpi_processor_performance *perf; | 217 | struct acpi_processor_performance *perf; |
218 | 218 | ||
219 | if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) | 219 | if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) |
@@ -223,10 +223,9 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) | |||
223 | 223 | ||
224 | perf = data->acpi_data; | 224 | perf = data->acpi_data; |
225 | 225 | ||
226 | for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { | 226 | cpufreq_for_each_entry(pos, data->freq_table) |
227 | if (msr == perf->states[data->freq_table[i].driver_data].status) | 227 | if (msr == perf->states[pos->driver_data].status) |
228 | return data->freq_table[i].frequency; | 228 | return pos->frequency; |
229 | } | ||
230 | return data->freq_table[0].frequency; | 229 | return data->freq_table[0].frequency; |
231 | } | 230 | } |
232 | 231 | ||
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index bad2ed317ba2..1f4d4e315057 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c | |||
@@ -226,22 +226,22 @@ static inline u32 get_table_count(struct cpufreq_frequency_table *table) | |||
226 | /* get the minimum frequency in the cpufreq_frequency_table */ | 226 | /* get the minimum frequency in the cpufreq_frequency_table */ |
227 | static inline u32 get_table_min(struct cpufreq_frequency_table *table) | 227 | static inline u32 get_table_min(struct cpufreq_frequency_table *table) |
228 | { | 228 | { |
229 | int i; | 229 | struct cpufreq_frequency_table *pos; |
230 | uint32_t min_freq = ~0; | 230 | uint32_t min_freq = ~0; |
231 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) | 231 | cpufreq_for_each_entry(pos, table) |
232 | if (table[i].frequency < min_freq) | 232 | if (pos->frequency < min_freq) |
233 | min_freq = table[i].frequency; | 233 | min_freq = pos->frequency; |
234 | return min_freq; | 234 | return min_freq; |
235 | } | 235 | } |
236 | 236 | ||
237 | /* get the maximum frequency in the cpufreq_frequency_table */ | 237 | /* get the maximum frequency in the cpufreq_frequency_table */ |
238 | static inline u32 get_table_max(struct cpufreq_frequency_table *table) | 238 | static inline u32 get_table_max(struct cpufreq_frequency_table *table) |
239 | { | 239 | { |
240 | int i; | 240 | struct cpufreq_frequency_table *pos; |
241 | uint32_t max_freq = 0; | 241 | uint32_t max_freq = 0; |
242 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) | 242 | cpufreq_for_each_entry(pos, table) |
243 | if (table[i].frequency > max_freq) | 243 | if (pos->frequency > max_freq) |
244 | max_freq = table[i].frequency; | 244 | max_freq = pos->frequency; |
245 | return max_freq; | 245 | return max_freq; |
246 | } | 246 | } |
247 | 247 | ||
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index abda6609d3e7..bfe82b63875f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -237,6 +237,17 @@ void cpufreq_cpu_put(struct cpufreq_policy *policy) | |||
237 | } | 237 | } |
238 | EXPORT_SYMBOL_GPL(cpufreq_cpu_put); | 238 | EXPORT_SYMBOL_GPL(cpufreq_cpu_put); |
239 | 239 | ||
240 | bool cpufreq_next_valid(struct cpufreq_frequency_table **pos) | ||
241 | { | ||
242 | while ((*pos)->frequency != CPUFREQ_TABLE_END) | ||
243 | if ((*pos)->frequency != CPUFREQ_ENTRY_INVALID) | ||
244 | return true; | ||
245 | else | ||
246 | (*pos)++; | ||
247 | return false; | ||
248 | } | ||
249 | EXPORT_SYMBOL_GPL(cpufreq_next_valid); | ||
250 | |||
240 | /********************************************************************* | 251 | /********************************************************************* |
241 | * EXTERNALLY AFFECTING FREQUENCY CHANGES * | 252 | * EXTERNALLY AFFECTING FREQUENCY CHANGES * |
242 | *********************************************************************/ | 253 | *********************************************************************/ |
@@ -354,6 +365,18 @@ static void cpufreq_notify_post_transition(struct cpufreq_policy *policy, | |||
354 | void cpufreq_freq_transition_begin(struct cpufreq_policy *policy, | 365 | void cpufreq_freq_transition_begin(struct cpufreq_policy *policy, |
355 | struct cpufreq_freqs *freqs) | 366 | struct cpufreq_freqs *freqs) |
356 | { | 367 | { |
368 | |||
369 | /* | ||
370 | * Catch double invocations of _begin() which lead to self-deadlock. | ||
371 | * ASYNC_NOTIFICATION drivers are left out because the cpufreq core | ||
372 | * doesn't invoke _begin() on their behalf, and hence the chances of | ||
373 | * double invocations are very low. Moreover, there are scenarios | ||
374 | * where these checks can emit false-positive warnings in these | ||
375 | * drivers; so we avoid that by skipping them altogether. | ||
376 | */ | ||
377 | WARN_ON(!(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION) | ||
378 | && current == policy->transition_task); | ||
379 | |||
357 | wait: | 380 | wait: |
358 | wait_event(policy->transition_wait, !policy->transition_ongoing); | 381 | wait_event(policy->transition_wait, !policy->transition_ongoing); |
359 | 382 | ||
@@ -365,6 +388,7 @@ wait: | |||
365 | } | 388 | } |
366 | 389 | ||
367 | policy->transition_ongoing = true; | 390 | policy->transition_ongoing = true; |
391 | policy->transition_task = current; | ||
368 | 392 | ||
369 | spin_unlock(&policy->transition_lock); | 393 | spin_unlock(&policy->transition_lock); |
370 | 394 | ||
@@ -381,6 +405,7 @@ void cpufreq_freq_transition_end(struct cpufreq_policy *policy, | |||
381 | cpufreq_notify_post_transition(policy, freqs, transition_failed); | 405 | cpufreq_notify_post_transition(policy, freqs, transition_failed); |
382 | 406 | ||
383 | policy->transition_ongoing = false; | 407 | policy->transition_ongoing = false; |
408 | policy->transition_task = NULL; | ||
384 | 409 | ||
385 | wake_up(&policy->transition_wait); | 410 | wake_up(&policy->transition_wait); |
386 | } | 411 | } |
diff --git a/drivers/cpufreq/cpufreq_opp.c b/drivers/cpufreq/cpufreq_opp.c new file mode 100644 index 000000000000..c0c6f4a4eccf --- /dev/null +++ b/drivers/cpufreq/cpufreq_opp.c | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | * Generic OPP helper interface for CPUFreq drivers | ||
3 | * | ||
4 | * Copyright (C) 2009-2014 Texas Instruments Incorporated. | ||
5 | * Nishanth Menon | ||
6 | * Romit Dasgupta | ||
7 | * Kevin Hilman | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | #include <linux/cpufreq.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/export.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/pm_opp.h> | ||
20 | #include <linux/rcupdate.h> | ||
21 | #include <linux/slab.h> | ||
22 | |||
23 | /** | ||
24 | * dev_pm_opp_init_cpufreq_table() - create a cpufreq table for a device | ||
25 | * @dev: device for which we do this operation | ||
26 | * @table: Cpufreq table returned back to caller | ||
27 | * | ||
28 | * Generate a cpufreq table for a provided device- this assumes that the | ||
29 | * opp list is already initialized and ready for usage. | ||
30 | * | ||
31 | * This function allocates required memory for the cpufreq table. It is | ||
32 | * expected that the caller does the required maintenance such as freeing | ||
33 | * the table as required. | ||
34 | * | ||
35 | * Returns -EINVAL for bad pointers, -ENODEV if the device is not found, -ENOMEM | ||
36 | * if no memory available for the operation (table is not populated), returns 0 | ||
37 | * if successful and table is populated. | ||
38 | * | ||
39 | * WARNING: It is important for the callers to ensure refreshing their copy of | ||
40 | * the table if any of the mentioned functions have been invoked in the interim. | ||
41 | * | ||
42 | * Locking: The internal device_opp and opp structures are RCU protected. | ||
43 | * Since we just use the regular accessor functions to access the internal data | ||
44 | * structures, we use RCU read lock inside this function. As a result, users of | ||
45 | * this function DONOT need to use explicit locks for invoking. | ||
46 | */ | ||
47 | int dev_pm_opp_init_cpufreq_table(struct device *dev, | ||
48 | struct cpufreq_frequency_table **table) | ||
49 | { | ||
50 | struct dev_pm_opp *opp; | ||
51 | struct cpufreq_frequency_table *freq_table = NULL; | ||
52 | int i, max_opps, ret = 0; | ||
53 | unsigned long rate; | ||
54 | |||
55 | rcu_read_lock(); | ||
56 | |||
57 | max_opps = dev_pm_opp_get_opp_count(dev); | ||
58 | if (max_opps <= 0) { | ||
59 | ret = max_opps ? max_opps : -ENODATA; | ||
60 | goto out; | ||
61 | } | ||
62 | |||
63 | freq_table = kzalloc(sizeof(*freq_table) * (max_opps + 1), GFP_KERNEL); | ||
64 | if (!freq_table) { | ||
65 | ret = -ENOMEM; | ||
66 | goto out; | ||
67 | } | ||
68 | |||
69 | for (i = 0, rate = 0; i < max_opps; i++, rate++) { | ||
70 | /* find next rate */ | ||
71 | opp = dev_pm_opp_find_freq_ceil(dev, &rate); | ||
72 | if (IS_ERR(opp)) { | ||
73 | ret = PTR_ERR(opp); | ||
74 | goto out; | ||
75 | } | ||
76 | freq_table[i].driver_data = i; | ||
77 | freq_table[i].frequency = rate / 1000; | ||
78 | } | ||
79 | |||
80 | freq_table[i].driver_data = i; | ||
81 | freq_table[i].frequency = CPUFREQ_TABLE_END; | ||
82 | |||
83 | *table = &freq_table[0]; | ||
84 | |||
85 | out: | ||
86 | rcu_read_unlock(); | ||
87 | if (ret) | ||
88 | kfree(freq_table); | ||
89 | |||
90 | return ret; | ||
91 | } | ||
92 | EXPORT_SYMBOL_GPL(dev_pm_opp_init_cpufreq_table); | ||
93 | |||
94 | /** | ||
95 | * dev_pm_opp_free_cpufreq_table() - free the cpufreq table | ||
96 | * @dev: device for which we do this operation | ||
97 | * @table: table to free | ||
98 | * | ||
99 | * Free up the table allocated by dev_pm_opp_init_cpufreq_table | ||
100 | */ | ||
101 | void dev_pm_opp_free_cpufreq_table(struct device *dev, | ||
102 | struct cpufreq_frequency_table **table) | ||
103 | { | ||
104 | if (!table) | ||
105 | return; | ||
106 | |||
107 | kfree(*table); | ||
108 | *table = NULL; | ||
109 | } | ||
110 | EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); | ||
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index ecaaebf969fc..0cd9b4dcef99 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -182,11 +182,11 @@ static void cpufreq_stats_free_table(unsigned int cpu) | |||
182 | 182 | ||
183 | static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) | 183 | static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) |
184 | { | 184 | { |
185 | unsigned int i, j, count = 0, ret = 0; | 185 | unsigned int i, count = 0, ret = 0; |
186 | struct cpufreq_stats *stat; | 186 | struct cpufreq_stats *stat; |
187 | unsigned int alloc_size; | 187 | unsigned int alloc_size; |
188 | unsigned int cpu = policy->cpu; | 188 | unsigned int cpu = policy->cpu; |
189 | struct cpufreq_frequency_table *table; | 189 | struct cpufreq_frequency_table *pos, *table; |
190 | 190 | ||
191 | table = cpufreq_frequency_get_table(cpu); | 191 | table = cpufreq_frequency_get_table(cpu); |
192 | if (unlikely(!table)) | 192 | if (unlikely(!table)) |
@@ -205,12 +205,8 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) | |||
205 | stat->cpu = cpu; | 205 | stat->cpu = cpu; |
206 | per_cpu(cpufreq_stats_table, cpu) = stat; | 206 | per_cpu(cpufreq_stats_table, cpu) = stat; |
207 | 207 | ||
208 | for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 208 | cpufreq_for_each_valid_entry(pos, table) |
209 | unsigned int freq = table[i].frequency; | ||
210 | if (freq == CPUFREQ_ENTRY_INVALID) | ||
211 | continue; | ||
212 | count++; | 209 | count++; |
213 | } | ||
214 | 210 | ||
215 | alloc_size = count * sizeof(int) + count * sizeof(u64); | 211 | alloc_size = count * sizeof(int) + count * sizeof(u64); |
216 | 212 | ||
@@ -228,15 +224,11 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy) | |||
228 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS | 224 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS |
229 | stat->trans_table = stat->freq_table + count; | 225 | stat->trans_table = stat->freq_table + count; |
230 | #endif | 226 | #endif |
231 | j = 0; | 227 | i = 0; |
232 | for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 228 | cpufreq_for_each_valid_entry(pos, table) |
233 | unsigned int freq = table[i].frequency; | 229 | if (freq_table_get_index(stat, pos->frequency) == -1) |
234 | if (freq == CPUFREQ_ENTRY_INVALID) | 230 | stat->freq_table[i++] = pos->frequency; |
235 | continue; | 231 | stat->state_num = i; |
236 | if (freq_table_get_index(stat, freq) == -1) | ||
237 | stat->freq_table[j++] = freq; | ||
238 | } | ||
239 | stat->state_num = j; | ||
240 | spin_lock(&cpufreq_stats_lock); | 232 | spin_lock(&cpufreq_stats_lock); |
241 | stat->last_time = get_jiffies_64(); | 233 | stat->last_time = get_jiffies_64(); |
242 | stat->last_index = freq_table_get_index(stat, policy->cur); | 234 | stat->last_index = freq_table_get_index(stat, policy->cur); |
diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c index 412a78bb0c94..4bebc1b5db48 100644 --- a/drivers/cpufreq/dbx500-cpufreq.c +++ b/drivers/cpufreq/dbx500-cpufreq.c | |||
@@ -45,7 +45,7 @@ static struct cpufreq_driver dbx500_cpufreq_driver = { | |||
45 | 45 | ||
46 | static int dbx500_cpufreq_probe(struct platform_device *pdev) | 46 | static int dbx500_cpufreq_probe(struct platform_device *pdev) |
47 | { | 47 | { |
48 | int i = 0; | 48 | struct cpufreq_frequency_table *pos; |
49 | 49 | ||
50 | freq_table = dev_get_platdata(&pdev->dev); | 50 | freq_table = dev_get_platdata(&pdev->dev); |
51 | if (!freq_table) { | 51 | if (!freq_table) { |
@@ -60,10 +60,8 @@ static int dbx500_cpufreq_probe(struct platform_device *pdev) | |||
60 | } | 60 | } |
61 | 61 | ||
62 | pr_info("dbx500-cpufreq: Available frequencies:\n"); | 62 | pr_info("dbx500-cpufreq: Available frequencies:\n"); |
63 | while (freq_table[i].frequency != CPUFREQ_TABLE_END) { | 63 | cpufreq_for_each_entry(pos, freq_table) |
64 | pr_info(" %d Mhz\n", freq_table[i].frequency/1000); | 64 | pr_info(" %d Mhz\n", pos->frequency / 1000); |
65 | i++; | ||
66 | } | ||
67 | 65 | ||
68 | return cpufreq_register_driver(&dbx500_cpufreq_driver); | 66 | return cpufreq_register_driver(&dbx500_cpufreq_driver); |
69 | } | 67 | } |
diff --git a/drivers/cpufreq/elanfreq.c b/drivers/cpufreq/elanfreq.c index 7f5d2a68c353..1c06e786c9ba 100644 --- a/drivers/cpufreq/elanfreq.c +++ b/drivers/cpufreq/elanfreq.c | |||
@@ -147,7 +147,7 @@ static int elanfreq_target(struct cpufreq_policy *policy, | |||
147 | static int elanfreq_cpu_init(struct cpufreq_policy *policy) | 147 | static int elanfreq_cpu_init(struct cpufreq_policy *policy) |
148 | { | 148 | { |
149 | struct cpuinfo_x86 *c = &cpu_data(0); | 149 | struct cpuinfo_x86 *c = &cpu_data(0); |
150 | unsigned int i; | 150 | struct cpufreq_frequency_table *pos; |
151 | 151 | ||
152 | /* capability check */ | 152 | /* capability check */ |
153 | if ((c->x86_vendor != X86_VENDOR_AMD) || | 153 | if ((c->x86_vendor != X86_VENDOR_AMD) || |
@@ -159,10 +159,9 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy) | |||
159 | max_freq = elanfreq_get_cpu_frequency(0); | 159 | max_freq = elanfreq_get_cpu_frequency(0); |
160 | 160 | ||
161 | /* table init */ | 161 | /* table init */ |
162 | for (i = 0; (elanfreq_table[i].frequency != CPUFREQ_TABLE_END); i++) { | 162 | cpufreq_for_each_entry(pos, elanfreq_table) |
163 | if (elanfreq_table[i].frequency > max_freq) | 163 | if (pos->frequency > max_freq) |
164 | elanfreq_table[i].frequency = CPUFREQ_ENTRY_INVALID; | 164 | pos->frequency = CPUFREQ_ENTRY_INVALID; |
165 | } | ||
166 | 165 | ||
167 | /* cpuinfo and default policy values */ | 166 | /* cpuinfo and default policy values */ |
168 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | 167 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; |
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c index f99cfe24e7bc..c3e55aa28cf8 100644 --- a/drivers/cpufreq/exynos-cpufreq.c +++ b/drivers/cpufreq/exynos-cpufreq.c | |||
@@ -29,17 +29,16 @@ static unsigned int locking_frequency; | |||
29 | static int exynos_cpufreq_get_index(unsigned int freq) | 29 | static int exynos_cpufreq_get_index(unsigned int freq) |
30 | { | 30 | { |
31 | struct cpufreq_frequency_table *freq_table = exynos_info->freq_table; | 31 | struct cpufreq_frequency_table *freq_table = exynos_info->freq_table; |
32 | int index; | 32 | struct cpufreq_frequency_table *pos; |
33 | 33 | ||
34 | for (index = 0; | 34 | cpufreq_for_each_entry(pos, freq_table) |
35 | freq_table[index].frequency != CPUFREQ_TABLE_END; index++) | 35 | if (pos->frequency == freq) |
36 | if (freq_table[index].frequency == freq) | ||
37 | break; | 36 | break; |
38 | 37 | ||
39 | if (freq_table[index].frequency == CPUFREQ_TABLE_END) | 38 | if (pos->frequency == CPUFREQ_TABLE_END) |
40 | return -EINVAL; | 39 | return -EINVAL; |
41 | 40 | ||
42 | return index; | 41 | return pos - freq_table; |
43 | } | 42 | } |
44 | 43 | ||
45 | static int exynos_cpufreq_scale(unsigned int target_freq) | 44 | static int exynos_cpufreq_scale(unsigned int target_freq) |
@@ -49,6 +48,7 @@ static int exynos_cpufreq_scale(unsigned int target_freq) | |||
49 | struct cpufreq_policy *policy = cpufreq_cpu_get(0); | 48 | struct cpufreq_policy *policy = cpufreq_cpu_get(0); |
50 | unsigned int arm_volt, safe_arm_volt = 0; | 49 | unsigned int arm_volt, safe_arm_volt = 0; |
51 | unsigned int mpll_freq_khz = exynos_info->mpll_freq_khz; | 50 | unsigned int mpll_freq_khz = exynos_info->mpll_freq_khz; |
51 | struct device *dev = exynos_info->dev; | ||
52 | unsigned int old_freq; | 52 | unsigned int old_freq; |
53 | int index, old_index; | 53 | int index, old_index; |
54 | int ret = 0; | 54 | int ret = 0; |
@@ -90,8 +90,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq) | |||
90 | /* Firstly, voltage up to increase frequency */ | 90 | /* Firstly, voltage up to increase frequency */ |
91 | ret = regulator_set_voltage(arm_regulator, arm_volt, arm_volt); | 91 | ret = regulator_set_voltage(arm_regulator, arm_volt, arm_volt); |
92 | if (ret) { | 92 | if (ret) { |
93 | pr_err("%s: failed to set cpu voltage to %d\n", | 93 | dev_err(dev, "failed to set cpu voltage to %d\n", |
94 | __func__, arm_volt); | 94 | arm_volt); |
95 | return ret; | 95 | return ret; |
96 | } | 96 | } |
97 | } | 97 | } |
@@ -100,8 +100,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq) | |||
100 | ret = regulator_set_voltage(arm_regulator, safe_arm_volt, | 100 | ret = regulator_set_voltage(arm_regulator, safe_arm_volt, |
101 | safe_arm_volt); | 101 | safe_arm_volt); |
102 | if (ret) { | 102 | if (ret) { |
103 | pr_err("%s: failed to set cpu voltage to %d\n", | 103 | dev_err(dev, "failed to set cpu voltage to %d\n", |
104 | __func__, safe_arm_volt); | 104 | safe_arm_volt); |
105 | return ret; | 105 | return ret; |
106 | } | 106 | } |
107 | } | 107 | } |
@@ -115,8 +115,8 @@ static int exynos_cpufreq_scale(unsigned int target_freq) | |||
115 | ret = regulator_set_voltage(arm_regulator, arm_volt, | 115 | ret = regulator_set_voltage(arm_regulator, arm_volt, |
116 | arm_volt); | 116 | arm_volt); |
117 | if (ret) { | 117 | if (ret) { |
118 | pr_err("%s: failed to set cpu voltage to %d\n", | 118 | dev_err(dev, "failed to set cpu voltage to %d\n", |
119 | __func__, arm_volt); | 119 | arm_volt); |
120 | goto out; | 120 | goto out; |
121 | } | 121 | } |
122 | } | 122 | } |
@@ -163,6 +163,8 @@ static int exynos_cpufreq_probe(struct platform_device *pdev) | |||
163 | if (!exynos_info) | 163 | if (!exynos_info) |
164 | return -ENOMEM; | 164 | return -ENOMEM; |
165 | 165 | ||
166 | exynos_info->dev = &pdev->dev; | ||
167 | |||
166 | if (soc_is_exynos4210()) | 168 | if (soc_is_exynos4210()) |
167 | ret = exynos4210_cpufreq_init(exynos_info); | 169 | ret = exynos4210_cpufreq_init(exynos_info); |
168 | else if (soc_is_exynos4212() || soc_is_exynos4412()) | 170 | else if (soc_is_exynos4212() || soc_is_exynos4412()) |
@@ -176,13 +178,13 @@ static int exynos_cpufreq_probe(struct platform_device *pdev) | |||
176 | goto err_vdd_arm; | 178 | goto err_vdd_arm; |
177 | 179 | ||
178 | if (exynos_info->set_freq == NULL) { | 180 | if (exynos_info->set_freq == NULL) { |
179 | pr_err("%s: No set_freq function (ERR)\n", __func__); | 181 | dev_err(&pdev->dev, "No set_freq function (ERR)\n"); |
180 | goto err_vdd_arm; | 182 | goto err_vdd_arm; |
181 | } | 183 | } |
182 | 184 | ||
183 | arm_regulator = regulator_get(NULL, "vdd_arm"); | 185 | arm_regulator = regulator_get(NULL, "vdd_arm"); |
184 | if (IS_ERR(arm_regulator)) { | 186 | if (IS_ERR(arm_regulator)) { |
185 | pr_err("%s: failed to get resource vdd_arm\n", __func__); | 187 | dev_err(&pdev->dev, "failed to get resource vdd_arm\n"); |
186 | goto err_vdd_arm; | 188 | goto err_vdd_arm; |
187 | } | 189 | } |
188 | 190 | ||
@@ -192,7 +194,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev) | |||
192 | if (!cpufreq_register_driver(&exynos_driver)) | 194 | if (!cpufreq_register_driver(&exynos_driver)) |
193 | return 0; | 195 | return 0; |
194 | 196 | ||
195 | pr_err("%s: failed to register cpufreq driver\n", __func__); | 197 | dev_err(&pdev->dev, "failed to register cpufreq driver\n"); |
196 | regulator_put(arm_regulator); | 198 | regulator_put(arm_regulator); |
197 | err_vdd_arm: | 199 | err_vdd_arm: |
198 | kfree(exynos_info); | 200 | kfree(exynos_info); |
diff --git a/drivers/cpufreq/exynos-cpufreq.h b/drivers/cpufreq/exynos-cpufreq.h index 3ddade8a5125..b72ff10a040e 100644 --- a/drivers/cpufreq/exynos-cpufreq.h +++ b/drivers/cpufreq/exynos-cpufreq.h | |||
@@ -34,6 +34,7 @@ struct apll_freq { | |||
34 | }; | 34 | }; |
35 | 35 | ||
36 | struct exynos_dvfs_info { | 36 | struct exynos_dvfs_info { |
37 | struct device *dev; | ||
37 | unsigned long mpll_freq_khz; | 38 | unsigned long mpll_freq_khz; |
38 | unsigned int pll_safe_idx; | 39 | unsigned int pll_safe_idx; |
39 | struct clk *cpu_clk; | 40 | struct clk *cpu_clk; |
diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c index a6b8214d7b77..f33f25b483ca 100644 --- a/drivers/cpufreq/exynos5440-cpufreq.c +++ b/drivers/cpufreq/exynos5440-cpufreq.c | |||
@@ -114,25 +114,23 @@ static struct cpufreq_freqs freqs; | |||
114 | 114 | ||
115 | static int init_div_table(void) | 115 | static int init_div_table(void) |
116 | { | 116 | { |
117 | struct cpufreq_frequency_table *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; |
119 | int i = 0; | ||
120 | struct dev_pm_opp *opp; | 119 | struct dev_pm_opp *opp; |
121 | 120 | ||
122 | rcu_read_lock(); | 121 | rcu_read_lock(); |
123 | for (i = 0; freq_tbl[i].frequency != CPUFREQ_TABLE_END; i++) { | 122 | cpufreq_for_each_entry(pos, freq_tbl) { |
124 | |||
125 | opp = dev_pm_opp_find_freq_exact(dvfs_info->dev, | 123 | opp = dev_pm_opp_find_freq_exact(dvfs_info->dev, |
126 | freq_tbl[i].frequency * 1000, true); | 124 | pos->frequency * 1000, true); |
127 | if (IS_ERR(opp)) { | 125 | if (IS_ERR(opp)) { |
128 | rcu_read_unlock(); | 126 | rcu_read_unlock(); |
129 | dev_err(dvfs_info->dev, | 127 | dev_err(dvfs_info->dev, |
130 | "failed to find valid OPP for %u KHZ\n", | 128 | "failed to find valid OPP for %u KHZ\n", |
131 | freq_tbl[i].frequency); | 129 | pos->frequency); |
132 | return PTR_ERR(opp); | 130 | return PTR_ERR(opp); |
133 | } | 131 | } |
134 | 132 | ||
135 | freq = freq_tbl[i].frequency / 1000; /* In MHZ */ | 133 | freq = pos->frequency / 1000; /* In MHZ */ |
136 | clk_div = ((freq / CPU_DIV_FREQ_MAX) & P0_7_CPUCLKDEV_MASK) | 134 | clk_div = ((freq / CPU_DIV_FREQ_MAX) & P0_7_CPUCLKDEV_MASK) |
137 | << P0_7_CPUCLKDEV_SHIFT; | 135 | << P0_7_CPUCLKDEV_SHIFT; |
138 | clk_div |= ((freq / CPU_ATB_FREQ_MAX) & P0_7_ATBCLKDEV_MASK) | 136 | clk_div |= ((freq / CPU_ATB_FREQ_MAX) & P0_7_ATBCLKDEV_MASK) |
@@ -157,7 +155,8 @@ static int init_div_table(void) | |||
157 | tmp = (clk_div | ema_div | (volt_id << P0_7_VDD_SHIFT) | 155 | tmp = (clk_div | ema_div | (volt_id << P0_7_VDD_SHIFT) |
158 | | ((freq / FREQ_UNIT) << P0_7_FREQ_SHIFT)); | 156 | | ((freq / FREQ_UNIT) << P0_7_FREQ_SHIFT)); |
159 | 157 | ||
160 | __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * i); | 158 | __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * |
159 | (pos - freq_tbl)); | ||
161 | } | 160 | } |
162 | 161 | ||
163 | rcu_read_unlock(); | 162 | rcu_read_unlock(); |
@@ -166,8 +165,9 @@ static int init_div_table(void) | |||
166 | 165 | ||
167 | static void exynos_enable_dvfs(unsigned int cur_frequency) | 166 | static void exynos_enable_dvfs(unsigned int cur_frequency) |
168 | { | 167 | { |
169 | unsigned int tmp, i, cpu; | 168 | unsigned int tmp, cpu; |
170 | struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table; | 169 | struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table; |
170 | struct cpufreq_frequency_table *pos; | ||
171 | /* Disable DVFS */ | 171 | /* Disable DVFS */ |
172 | __raw_writel(0, dvfs_info->base + XMU_DVFS_CTRL); | 172 | __raw_writel(0, dvfs_info->base + XMU_DVFS_CTRL); |
173 | 173 | ||
@@ -182,15 +182,15 @@ static void exynos_enable_dvfs(unsigned int cur_frequency) | |||
182 | __raw_writel(tmp, dvfs_info->base + XMU_PMUIRQEN); | 182 | __raw_writel(tmp, dvfs_info->base + XMU_PMUIRQEN); |
183 | 183 | ||
184 | /* Set initial performance index */ | 184 | /* Set initial performance index */ |
185 | for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) | 185 | cpufreq_for_each_entry(pos, freq_table) |
186 | if (freq_table[i].frequency == cur_frequency) | 186 | if (pos->frequency == cur_frequency) |
187 | break; | 187 | break; |
188 | 188 | ||
189 | if (freq_table[i].frequency == CPUFREQ_TABLE_END) { | 189 | if (pos->frequency == CPUFREQ_TABLE_END) { |
190 | dev_crit(dvfs_info->dev, "Boot up frequency not supported\n"); | 190 | dev_crit(dvfs_info->dev, "Boot up frequency not supported\n"); |
191 | /* Assign the highest frequency */ | 191 | /* Assign the highest frequency */ |
192 | i = 0; | 192 | pos = freq_table; |
193 | cur_frequency = freq_table[i].frequency; | 193 | cur_frequency = pos->frequency; |
194 | } | 194 | } |
195 | 195 | ||
196 | dev_info(dvfs_info->dev, "Setting dvfs initial frequency = %uKHZ", | 196 | dev_info(dvfs_info->dev, "Setting dvfs initial frequency = %uKHZ", |
@@ -199,7 +199,7 @@ static void exynos_enable_dvfs(unsigned int cur_frequency) | |||
199 | for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++) { | 199 | for (cpu = 0; cpu < CONFIG_NR_CPUS; cpu++) { |
200 | tmp = __raw_readl(dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4); | 200 | tmp = __raw_readl(dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4); |
201 | tmp &= ~(P_VALUE_MASK << C0_3_PSTATE_NEW_SHIFT); | 201 | tmp &= ~(P_VALUE_MASK << C0_3_PSTATE_NEW_SHIFT); |
202 | tmp |= (i << C0_3_PSTATE_NEW_SHIFT); | 202 | tmp |= ((pos - freq_table) << C0_3_PSTATE_NEW_SHIFT); |
203 | __raw_writel(tmp, dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4); | 203 | __raw_writel(tmp, dvfs_info->base + XMU_C0_3_PSTATE + cpu * 4); |
204 | } | 204 | } |
205 | 205 | ||
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 08e7bbcf6d73..8e518c689393 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -21,22 +21,19 @@ | |||
21 | int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, | 21 | int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, |
22 | struct cpufreq_frequency_table *table) | 22 | struct cpufreq_frequency_table *table) |
23 | { | 23 | { |
24 | struct cpufreq_frequency_table *pos; | ||
24 | unsigned int min_freq = ~0; | 25 | unsigned int min_freq = ~0; |
25 | unsigned int max_freq = 0; | 26 | unsigned int max_freq = 0; |
26 | unsigned int i; | 27 | unsigned int freq; |
27 | 28 | ||
28 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { | 29 | cpufreq_for_each_valid_entry(pos, table) { |
29 | unsigned int freq = table[i].frequency; | 30 | freq = pos->frequency; |
30 | if (freq == CPUFREQ_ENTRY_INVALID) { | ||
31 | pr_debug("table entry %u is invalid, skipping\n", i); | ||
32 | 31 | ||
33 | continue; | ||
34 | } | ||
35 | if (!cpufreq_boost_enabled() | 32 | if (!cpufreq_boost_enabled() |
36 | && (table[i].flags & CPUFREQ_BOOST_FREQ)) | 33 | && (pos->flags & CPUFREQ_BOOST_FREQ)) |
37 | continue; | 34 | continue; |
38 | 35 | ||
39 | pr_debug("table entry %u: %u kHz\n", i, freq); | 36 | pr_debug("table entry %u: %u kHz\n", (int)(pos - table), freq); |
40 | if (freq < min_freq) | 37 | if (freq < min_freq) |
41 | min_freq = freq; | 38 | min_freq = freq; |
42 | if (freq > max_freq) | 39 | if (freq > max_freq) |
@@ -57,7 +54,8 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_cpuinfo); | |||
57 | int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | 54 | int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, |
58 | struct cpufreq_frequency_table *table) | 55 | struct cpufreq_frequency_table *table) |
59 | { | 56 | { |
60 | unsigned int next_larger = ~0, freq, i = 0; | 57 | struct cpufreq_frequency_table *pos; |
58 | unsigned int freq, next_larger = ~0; | ||
61 | bool found = false; | 59 | bool found = false; |
62 | 60 | ||
63 | pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", | 61 | pr_debug("request for verification of policy (%u - %u kHz) for cpu %u\n", |
@@ -65,9 +63,9 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, | |||
65 | 63 | ||
66 | cpufreq_verify_within_cpu_limits(policy); | 64 | cpufreq_verify_within_cpu_limits(policy); |
67 | 65 | ||
68 | for (; freq = table[i].frequency, freq != CPUFREQ_TABLE_END; i++) { | 66 | cpufreq_for_each_valid_entry(pos, table) { |
69 | if (freq == CPUFREQ_ENTRY_INVALID) | 67 | freq = pos->frequency; |
70 | continue; | 68 | |
71 | if ((freq >= policy->min) && (freq <= policy->max)) { | 69 | if ((freq >= policy->min) && (freq <= policy->max)) { |
72 | found = true; | 70 | found = true; |
73 | break; | 71 | break; |
@@ -118,7 +116,8 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
118 | .driver_data = ~0, | 116 | .driver_data = ~0, |
119 | .frequency = 0, | 117 | .frequency = 0, |
120 | }; | 118 | }; |
121 | unsigned int i; | 119 | struct cpufreq_frequency_table *pos; |
120 | unsigned int freq, i = 0; | ||
122 | 121 | ||
123 | pr_debug("request for target %u kHz (relation: %u) for cpu %u\n", | 122 | pr_debug("request for target %u kHz (relation: %u) for cpu %u\n", |
124 | target_freq, relation, policy->cpu); | 123 | target_freq, relation, policy->cpu); |
@@ -132,10 +131,10 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
132 | break; | 131 | break; |
133 | } | 132 | } |
134 | 133 | ||
135 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { | 134 | cpufreq_for_each_valid_entry(pos, table) { |
136 | unsigned int freq = table[i].frequency; | 135 | freq = pos->frequency; |
137 | if (freq == CPUFREQ_ENTRY_INVALID) | 136 | |
138 | continue; | 137 | i = pos - table; |
139 | if ((freq < policy->min) || (freq > policy->max)) | 138 | if ((freq < policy->min) || (freq > policy->max)) |
140 | continue; | 139 | continue; |
141 | switch (relation) { | 140 | switch (relation) { |
@@ -184,8 +183,7 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target); | |||
184 | int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, | 183 | int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, |
185 | unsigned int freq) | 184 | unsigned int freq) |
186 | { | 185 | { |
187 | struct cpufreq_frequency_table *table; | 186 | struct cpufreq_frequency_table *pos, *table; |
188 | int i; | ||
189 | 187 | ||
190 | table = cpufreq_frequency_get_table(policy->cpu); | 188 | table = cpufreq_frequency_get_table(policy->cpu); |
191 | if (unlikely(!table)) { | 189 | if (unlikely(!table)) { |
@@ -193,10 +191,9 @@ int cpufreq_frequency_table_get_index(struct cpufreq_policy *policy, | |||
193 | return -ENOENT; | 191 | return -ENOENT; |
194 | } | 192 | } |
195 | 193 | ||
196 | for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 194 | cpufreq_for_each_valid_entry(pos, table) |
197 | if (table[i].frequency == freq) | 195 | if (pos->frequency == freq) |
198 | return i; | 196 | return pos - table; |
199 | } | ||
200 | 197 | ||
201 | return -EINVAL; | 198 | return -EINVAL; |
202 | } | 199 | } |
@@ -208,16 +205,13 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_index); | |||
208 | static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf, | 205 | static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf, |
209 | bool show_boost) | 206 | bool show_boost) |
210 | { | 207 | { |
211 | unsigned int i = 0; | ||
212 | ssize_t count = 0; | 208 | ssize_t count = 0; |
213 | struct cpufreq_frequency_table *table = policy->freq_table; | 209 | struct cpufreq_frequency_table *pos, *table = policy->freq_table; |
214 | 210 | ||
215 | if (!table) | 211 | if (!table) |
216 | return -ENODEV; | 212 | return -ENODEV; |
217 | 213 | ||
218 | for (i = 0; (table[i].frequency != CPUFREQ_TABLE_END); i++) { | 214 | cpufreq_for_each_valid_entry(pos, table) { |
219 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) | ||
220 | continue; | ||
221 | /* | 215 | /* |
222 | * show_boost = true and driver_data = BOOST freq | 216 | * show_boost = true and driver_data = BOOST freq |
223 | * display BOOST freqs | 217 | * display BOOST freqs |
@@ -229,10 +223,10 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf, | |||
229 | * show_boost = false and driver_data != BOOST freq | 223 | * show_boost = false and driver_data != BOOST freq |
230 | * display NON BOOST freqs | 224 | * display NON BOOST freqs |
231 | */ | 225 | */ |
232 | if (show_boost ^ (table[i].flags & CPUFREQ_BOOST_FREQ)) | 226 | if (show_boost ^ (pos->flags & CPUFREQ_BOOST_FREQ)) |
233 | continue; | 227 | continue; |
234 | 228 | ||
235 | count += sprintf(&buf[count], "%d ", table[i].frequency); | 229 | count += sprintf(&buf[count], "%d ", pos->frequency); |
236 | } | 230 | } |
237 | count += sprintf(&buf[count], "\n"); | 231 | count += sprintf(&buf[count], "\n"); |
238 | 232 | ||
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 099967302bf2..6658bef99352 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -32,8 +32,6 @@ | |||
32 | #include <asm/msr.h> | 32 | #include <asm/msr.h> |
33 | #include <asm/cpu_device_id.h> | 33 | #include <asm/cpu_device_id.h> |
34 | 34 | ||
35 | #define SAMPLE_COUNT 3 | ||
36 | |||
37 | #define BYT_RATIOS 0x66a | 35 | #define BYT_RATIOS 0x66a |
38 | #define BYT_VIDS 0x66b | 36 | #define BYT_VIDS 0x66b |
39 | #define BYT_TURBO_RATIOS 0x66c | 37 | #define BYT_TURBO_RATIOS 0x66c |
@@ -553,14 +551,13 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) | |||
553 | intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate); | 551 | intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate); |
554 | } | 552 | } |
555 | 553 | ||
556 | static inline void intel_pstate_calc_busy(struct cpudata *cpu, | 554 | static inline void intel_pstate_calc_busy(struct cpudata *cpu) |
557 | struct sample *sample) | ||
558 | { | 555 | { |
556 | struct sample *sample = &cpu->sample; | ||
559 | int32_t core_pct; | 557 | int32_t core_pct; |
560 | int32_t c0_pct; | 558 | int32_t c0_pct; |
561 | 559 | ||
562 | core_pct = div_fp(int_tofp((sample->aperf)), | 560 | core_pct = div_fp(int_tofp(sample->aperf), int_tofp(sample->mperf)); |
563 | int_tofp((sample->mperf))); | ||
564 | core_pct = mul_fp(core_pct, int_tofp(100)); | 561 | core_pct = mul_fp(core_pct, int_tofp(100)); |
565 | FP_ROUNDUP(core_pct); | 562 | FP_ROUNDUP(core_pct); |
566 | 563 | ||
@@ -592,7 +589,7 @@ static inline void intel_pstate_sample(struct cpudata *cpu) | |||
592 | cpu->sample.mperf -= cpu->prev_mperf; | 589 | cpu->sample.mperf -= cpu->prev_mperf; |
593 | cpu->sample.tsc -= cpu->prev_tsc; | 590 | cpu->sample.tsc -= cpu->prev_tsc; |
594 | 591 | ||
595 | intel_pstate_calc_busy(cpu, &cpu->sample); | 592 | intel_pstate_calc_busy(cpu); |
596 | 593 | ||
597 | cpu->prev_aperf = aperf; | 594 | cpu->prev_aperf = aperf; |
598 | cpu->prev_mperf = mperf; | 595 | cpu->prev_mperf = mperf; |
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index 5c4369b5d834..c913906a719e 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
@@ -530,6 +530,7 @@ static int longhaul_get_ranges(void) | |||
530 | 530 | ||
531 | static void longhaul_setup_voltagescaling(void) | 531 | static void longhaul_setup_voltagescaling(void) |
532 | { | 532 | { |
533 | struct cpufreq_frequency_table *freq_pos; | ||
533 | union msr_longhaul longhaul; | 534 | union msr_longhaul longhaul; |
534 | struct mV_pos minvid, maxvid, vid; | 535 | struct mV_pos minvid, maxvid, vid; |
535 | unsigned int j, speed, pos, kHz_step, numvscales; | 536 | unsigned int j, speed, pos, kHz_step, numvscales; |
@@ -608,18 +609,16 @@ static void longhaul_setup_voltagescaling(void) | |||
608 | /* Calculate kHz for one voltage step */ | 609 | /* Calculate kHz for one voltage step */ |
609 | kHz_step = (highest_speed - min_vid_speed) / numvscales; | 610 | kHz_step = (highest_speed - min_vid_speed) / numvscales; |
610 | 611 | ||
611 | j = 0; | 612 | cpufreq_for_each_entry(freq_pos, longhaul_table) { |
612 | while (longhaul_table[j].frequency != CPUFREQ_TABLE_END) { | 613 | speed = freq_pos->frequency; |
613 | speed = longhaul_table[j].frequency; | ||
614 | if (speed > min_vid_speed) | 614 | if (speed > min_vid_speed) |
615 | pos = (speed - min_vid_speed) / kHz_step + minvid.pos; | 615 | pos = (speed - min_vid_speed) / kHz_step + minvid.pos; |
616 | else | 616 | else |
617 | pos = minvid.pos; | 617 | pos = minvid.pos; |
618 | longhaul_table[j].driver_data |= mV_vrm_table[pos] << 8; | 618 | freq_pos->driver_data |= mV_vrm_table[pos] << 8; |
619 | vid = vrm_mV_table[mV_vrm_table[pos]]; | 619 | vid = vrm_mV_table[mV_vrm_table[pos]]; |
620 | printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n", | 620 | printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n", |
621 | speed, j, vid.mV); | 621 | speed, (int)(freq_pos - longhaul_table), vid.mV); |
622 | j++; | ||
623 | } | 622 | } |
624 | 623 | ||
625 | can_scale_voltage = 1; | 624 | can_scale_voltage = 1; |
diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c index 84c84b5f0f3a..35dd4d7ffee0 100644 --- a/drivers/cpufreq/pasemi-cpufreq.c +++ b/drivers/cpufreq/pasemi-cpufreq.c | |||
@@ -136,9 +136,10 @@ void restore_astate(int cpu) | |||
136 | 136 | ||
137 | static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) | 137 | static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) |
138 | { | 138 | { |
139 | struct cpufreq_frequency_table *pos; | ||
139 | const u32 *max_freqp; | 140 | const u32 *max_freqp; |
140 | u32 max_freq; | 141 | u32 max_freq; |
141 | int i, cur_astate; | 142 | int cur_astate; |
142 | struct resource res; | 143 | struct resource res; |
143 | struct device_node *cpu, *dn; | 144 | struct device_node *cpu, *dn; |
144 | int err = -ENODEV; | 145 | int err = -ENODEV; |
@@ -197,10 +198,9 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
197 | pr_debug("initializing frequency table\n"); | 198 | pr_debug("initializing frequency table\n"); |
198 | 199 | ||
199 | /* initialize frequency table */ | 200 | /* initialize frequency table */ |
200 | for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { | 201 | cpufreq_for_each_entry(pos, pas_freqs) { |
201 | pas_freqs[i].frequency = | 202 | pos->frequency = get_astate_freq(pos->driver_data) * 100000; |
202 | get_astate_freq(pas_freqs[i].driver_data) * 100000; | 203 | pr_debug("%d: %d\n", (int)(pos - pas_freqs), pos->frequency); |
203 | pr_debug("%d: %d\n", i, pas_freqs[i].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/powernow-k6.c b/drivers/cpufreq/powernow-k6.c index 78904e6ca4a0..c8012bc86910 100644 --- a/drivers/cpufreq/powernow-k6.c +++ b/drivers/cpufreq/powernow-k6.c | |||
@@ -151,6 +151,7 @@ static int powernow_k6_target(struct cpufreq_policy *policy, | |||
151 | 151 | ||
152 | static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | 152 | static int powernow_k6_cpu_init(struct cpufreq_policy *policy) |
153 | { | 153 | { |
154 | struct cpufreq_frequency_table *pos; | ||
154 | unsigned int i, f; | 155 | unsigned int i, f; |
155 | unsigned khz; | 156 | unsigned khz; |
156 | 157 | ||
@@ -168,12 +169,11 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | |||
168 | } | 169 | } |
169 | } | 170 | } |
170 | if (param_max_multiplier) { | 171 | if (param_max_multiplier) { |
171 | for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { | 172 | cpufreq_for_each_entry(pos, clock_ratio) |
172 | if (clock_ratio[i].driver_data == param_max_multiplier) { | 173 | if (pos->driver_data == param_max_multiplier) { |
173 | max_multiplier = param_max_multiplier; | 174 | max_multiplier = param_max_multiplier; |
174 | goto have_max_multiplier; | 175 | goto have_max_multiplier; |
175 | } | 176 | } |
176 | } | ||
177 | printk(KERN_ERR "powernow-k6: invalid max_multiplier parameter, valid parameters 20, 30, 35, 40, 45, 50, 55, 60\n"); | 177 | printk(KERN_ERR "powernow-k6: invalid max_multiplier parameter, valid parameters 20, 30, 35, 40, 45, 50, 55, 60\n"); |
178 | return -EINVAL; | 178 | return -EINVAL; |
179 | } | 179 | } |
@@ -201,12 +201,12 @@ have_busfreq: | |||
201 | param_busfreq = busfreq * 10; | 201 | param_busfreq = busfreq * 10; |
202 | 202 | ||
203 | /* table init */ | 203 | /* table init */ |
204 | for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { | 204 | cpufreq_for_each_entry(pos, clock_ratio) { |
205 | f = clock_ratio[i].driver_data; | 205 | f = pos->driver_data; |
206 | if (f > max_multiplier) | 206 | if (f > max_multiplier) |
207 | clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; | 207 | pos->frequency = CPUFREQ_ENTRY_INVALID; |
208 | else | 208 | else |
209 | clock_ratio[i].frequency = busfreq * f; | 209 | pos->frequency = busfreq * f; |
210 | } | 210 | } |
211 | 211 | ||
212 | /* cpuinfo and default policy values */ | 212 | /* cpuinfo and default policy values */ |
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c index 5be8a48dba74..5a4c5a639f61 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq.c | |||
@@ -67,9 +67,10 @@ static int set_pmode(unsigned int cpu, unsigned int slow_mode) | |||
67 | 67 | ||
68 | static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) | 68 | static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) |
69 | { | 69 | { |
70 | struct cpufreq_frequency_table *pos; | ||
70 | const u32 *max_freqp; | 71 | const u32 *max_freqp; |
71 | u32 max_freq; | 72 | u32 max_freq; |
72 | int i, cur_pmode; | 73 | int cur_pmode; |
73 | struct device_node *cpu; | 74 | struct device_node *cpu; |
74 | 75 | ||
75 | cpu = of_get_cpu_node(policy->cpu, NULL); | 76 | cpu = of_get_cpu_node(policy->cpu, NULL); |
@@ -102,9 +103,9 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
102 | pr_debug("initializing frequency table\n"); | 103 | pr_debug("initializing frequency table\n"); |
103 | 104 | ||
104 | /* initialize frequency table */ | 105 | /* initialize frequency table */ |
105 | for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { | 106 | cpufreq_for_each_entry(pos, cbe_freqs) { |
106 | cbe_freqs[i].frequency = max_freq / cbe_freqs[i].driver_data; | 107 | pos->frequency = max_freq / pos->driver_data; |
107 | pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); | 108 | pr_debug("%d: %d\n", (int)(pos - cbe_freqs), pos->frequency); |
108 | } | 109 | } |
109 | 110 | ||
110 | /* if DEBUG is enabled set_pmode() measures the latency | 111 | /* if DEBUG is enabled set_pmode() measures the latency |
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c index 4626f90559b5..2fd53eaaec20 100644 --- a/drivers/cpufreq/s3c2416-cpufreq.c +++ b/drivers/cpufreq/s3c2416-cpufreq.c | |||
@@ -266,7 +266,7 @@ out: | |||
266 | static void __init s3c2416_cpufreq_cfg_regulator(struct s3c2416_data *s3c_freq) | 266 | static void __init s3c2416_cpufreq_cfg_regulator(struct s3c2416_data *s3c_freq) |
267 | { | 267 | { |
268 | int count, v, i, found; | 268 | int count, v, i, found; |
269 | struct cpufreq_frequency_table *freq; | 269 | struct cpufreq_frequency_table *pos; |
270 | struct s3c2416_dvfs *dvfs; | 270 | struct s3c2416_dvfs *dvfs; |
271 | 271 | ||
272 | count = regulator_count_voltages(s3c_freq->vddarm); | 272 | count = regulator_count_voltages(s3c_freq->vddarm); |
@@ -275,12 +275,11 @@ static void __init s3c2416_cpufreq_cfg_regulator(struct s3c2416_data *s3c_freq) | |||
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | 277 | ||
278 | freq = s3c_freq->freq_table; | 278 | if (!count) |
279 | while (count > 0 && freq->frequency != CPUFREQ_TABLE_END) { | 279 | goto out; |
280 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) | ||
281 | continue; | ||
282 | 280 | ||
283 | dvfs = &s3c2416_dvfs_table[freq->driver_data]; | 281 | cpufreq_for_each_valid_entry(pos, s3c_freq->freq_table) { |
282 | dvfs = &s3c2416_dvfs_table[pos->driver_data]; | ||
284 | found = 0; | 283 | found = 0; |
285 | 284 | ||
286 | /* Check only the min-voltage, more is always ok on S3C2416 */ | 285 | /* Check only the min-voltage, more is always ok on S3C2416 */ |
@@ -292,13 +291,12 @@ static void __init s3c2416_cpufreq_cfg_regulator(struct s3c2416_data *s3c_freq) | |||
292 | 291 | ||
293 | if (!found) { | 292 | if (!found) { |
294 | pr_debug("cpufreq: %dkHz unsupported by regulator\n", | 293 | pr_debug("cpufreq: %dkHz unsupported by regulator\n", |
295 | freq->frequency); | 294 | pos->frequency); |
296 | freq->frequency = CPUFREQ_ENTRY_INVALID; | 295 | pos->frequency = CPUFREQ_ENTRY_INVALID; |
297 | } | 296 | } |
298 | |||
299 | freq++; | ||
300 | } | 297 | } |
301 | 298 | ||
299 | out: | ||
302 | /* Guessed */ | 300 | /* Guessed */ |
303 | s3c_freq->regulator_latency = 1 * 1000 * 1000; | 301 | s3c_freq->regulator_latency = 1 * 1000 * 1000; |
304 | } | 302 | } |
@@ -338,7 +336,7 @@ static struct notifier_block s3c2416_cpufreq_reboot_notifier = { | |||
338 | static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy) | 336 | static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy) |
339 | { | 337 | { |
340 | struct s3c2416_data *s3c_freq = &s3c2416_cpufreq; | 338 | struct s3c2416_data *s3c_freq = &s3c2416_cpufreq; |
341 | struct cpufreq_frequency_table *freq; | 339 | struct cpufreq_frequency_table *pos; |
342 | struct clk *msysclk; | 340 | struct clk *msysclk; |
343 | unsigned long rate; | 341 | unsigned long rate; |
344 | int ret; | 342 | int ret; |
@@ -427,31 +425,27 @@ static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
427 | s3c_freq->regulator_latency = 0; | 425 | s3c_freq->regulator_latency = 0; |
428 | #endif | 426 | #endif |
429 | 427 | ||
430 | freq = s3c_freq->freq_table; | 428 | cpufreq_for_each_entry(pos, s3c_freq->freq_table) { |
431 | while (freq->frequency != CPUFREQ_TABLE_END) { | ||
432 | /* special handling for dvs mode */ | 429 | /* special handling for dvs mode */ |
433 | if (freq->driver_data == 0) { | 430 | if (pos->driver_data == 0) { |
434 | if (!s3c_freq->hclk) { | 431 | if (!s3c_freq->hclk) { |
435 | pr_debug("cpufreq: %dkHz unsupported as it would need unavailable dvs mode\n", | 432 | pr_debug("cpufreq: %dkHz unsupported as it would need unavailable dvs mode\n", |
436 | freq->frequency); | 433 | pos->frequency); |
437 | freq->frequency = CPUFREQ_ENTRY_INVALID; | 434 | pos->frequency = CPUFREQ_ENTRY_INVALID; |
438 | } else { | 435 | } else { |
439 | freq++; | ||
440 | continue; | 436 | continue; |
441 | } | 437 | } |
442 | } | 438 | } |
443 | 439 | ||
444 | /* Check for frequencies we can generate */ | 440 | /* Check for frequencies we can generate */ |
445 | rate = clk_round_rate(s3c_freq->armdiv, | 441 | rate = clk_round_rate(s3c_freq->armdiv, |
446 | freq->frequency * 1000); | 442 | pos->frequency * 1000); |
447 | rate /= 1000; | 443 | rate /= 1000; |
448 | if (rate != freq->frequency) { | 444 | if (rate != pos->frequency) { |
449 | pr_debug("cpufreq: %dkHz unsupported by clock (clk_round_rate return %lu)\n", | 445 | pr_debug("cpufreq: %dkHz unsupported by clock (clk_round_rate return %lu)\n", |
450 | freq->frequency, rate); | 446 | pos->frequency, rate); |
451 | freq->frequency = CPUFREQ_ENTRY_INVALID; | 447 | pos->frequency = CPUFREQ_ENTRY_INVALID; |
452 | } | 448 | } |
453 | |||
454 | freq++; | ||
455 | } | 449 | } |
456 | 450 | ||
457 | /* Datasheet says PLL stabalisation time must be at least 300us, | 451 | /* Datasheet says PLL stabalisation time must be at least 300us, |
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index ff7d3ecb85f0..176e84cc3991 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c | |||
@@ -118,11 +118,10 @@ static void __init s3c64xx_cpufreq_config_regulator(void) | |||
118 | pr_err("Unable to check supported voltages\n"); | 118 | pr_err("Unable to check supported voltages\n"); |
119 | } | 119 | } |
120 | 120 | ||
121 | freq = s3c64xx_freq_table; | 121 | if (!count) |
122 | while (count > 0 && freq->frequency != CPUFREQ_TABLE_END) { | 122 | goto out; |
123 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) | ||
124 | continue; | ||
125 | 123 | ||
124 | cpufreq_for_each_valid_entry(freq, s3c64xx_freq_table) { | ||
126 | dvfs = &s3c64xx_dvfs_table[freq->driver_data]; | 125 | dvfs = &s3c64xx_dvfs_table[freq->driver_data]; |
127 | found = 0; | 126 | found = 0; |
128 | 127 | ||
@@ -137,10 +136,9 @@ static void __init s3c64xx_cpufreq_config_regulator(void) | |||
137 | freq->frequency); | 136 | freq->frequency); |
138 | freq->frequency = CPUFREQ_ENTRY_INVALID; | 137 | freq->frequency = CPUFREQ_ENTRY_INVALID; |
139 | } | 138 | } |
140 | |||
141 | freq++; | ||
142 | } | 139 | } |
143 | 140 | ||
141 | out: | ||
144 | /* Guess based on having to do an I2C/SPI write; in future we | 142 | /* Guess based on having to do an I2C/SPI write; in future we |
145 | * will be able to query the regulator performance here. */ | 143 | * will be able to query the regulator performance here. */ |
146 | regulator_latency = 1 * 1000 * 1000; | 144 | regulator_latency = 1 * 1000 * 1000; |
@@ -179,8 +177,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
179 | } | 177 | } |
180 | #endif | 178 | #endif |
181 | 179 | ||
182 | freq = s3c64xx_freq_table; | 180 | cpufreq_for_each_entry(freq, s3c64xx_freq_table) { |
183 | while (freq->frequency != CPUFREQ_TABLE_END) { | ||
184 | unsigned long r; | 181 | unsigned long r; |
185 | 182 | ||
186 | /* Check for frequencies we can generate */ | 183 | /* Check for frequencies we can generate */ |
@@ -196,8 +193,6 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) | |||
196 | * frequency is the maximum we can support. */ | 193 | * frequency is the maximum we can support. */ |
197 | if (!vddarm && freq->frequency > clk_get_rate(policy->clk) / 1000) | 194 | if (!vddarm && freq->frequency > clk_get_rate(policy->clk) / 1000) |
198 | freq->frequency = CPUFREQ_ENTRY_INVALID; | 195 | freq->frequency = CPUFREQ_ENTRY_INVALID; |
199 | |||
200 | freq++; | ||
201 | } | 196 | } |
202 | 197 | ||
203 | /* Datasheet says PLL stabalisation time (if we were to use | 198 | /* Datasheet says PLL stabalisation time (if we were to use |
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index 6723f0390f20..7d4a31571608 100644 --- a/drivers/cpufreq/speedstep-centrino.c +++ b/drivers/cpufreq/speedstep-centrino.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <asm/cpu_device_id.h> | 28 | #include <asm/cpu_device_id.h> |
29 | 29 | ||
30 | #define PFX "speedstep-centrino: " | 30 | #define PFX "speedstep-centrino: " |
31 | #define MAINTAINER "cpufreq@vger.kernel.org" | 31 | #define MAINTAINER "linux-pm@vger.kernel.org" |
32 | 32 | ||
33 | #define INTEL_MSR_RANGE (0xffff) | 33 | #define INTEL_MSR_RANGE (0xffff) |
34 | 34 | ||
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index 7694e0700d34..b11fdd63eecd 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c | |||
@@ -1734,18 +1734,17 @@ static struct cpufreq_frequency_table db8500_cpufreq_table[] = { | |||
1734 | 1734 | ||
1735 | static long round_armss_rate(unsigned long rate) | 1735 | static long round_armss_rate(unsigned long rate) |
1736 | { | 1736 | { |
1737 | struct cpufreq_frequency_table *pos; | ||
1737 | long freq = 0; | 1738 | long freq = 0; |
1738 | int i = 0; | ||
1739 | 1739 | ||
1740 | /* cpufreq table frequencies is in KHz. */ | 1740 | /* cpufreq table frequencies is in KHz. */ |
1741 | rate = rate / 1000; | 1741 | rate = rate / 1000; |
1742 | 1742 | ||
1743 | /* Find the corresponding arm opp from the cpufreq table. */ | 1743 | /* Find the corresponding arm opp from the cpufreq table. */ |
1744 | while (db8500_cpufreq_table[i].frequency != CPUFREQ_TABLE_END) { | 1744 | cpufreq_for_each_entry(pos, db8500_cpufreq_table) { |
1745 | freq = db8500_cpufreq_table[i].frequency; | 1745 | freq = pos->frequency; |
1746 | if (freq == rate) | 1746 | if (freq == rate) |
1747 | break; | 1747 | break; |
1748 | i++; | ||
1749 | } | 1748 | } |
1750 | 1749 | ||
1751 | /* Return the last valid value, even if a match was not found. */ | 1750 | /* Return the last valid value, even if a match was not found. */ |
@@ -1886,23 +1885,21 @@ static void set_clock_rate(u8 clock, unsigned long rate) | |||
1886 | 1885 | ||
1887 | static int set_armss_rate(unsigned long rate) | 1886 | static int set_armss_rate(unsigned long rate) |
1888 | { | 1887 | { |
1889 | int i = 0; | 1888 | struct cpufreq_frequency_table *pos; |
1890 | 1889 | ||
1891 | /* cpufreq table frequencies is in KHz. */ | 1890 | /* cpufreq table frequencies is in KHz. */ |
1892 | rate = rate / 1000; | 1891 | rate = rate / 1000; |
1893 | 1892 | ||
1894 | /* Find the corresponding arm opp from the cpufreq table. */ | 1893 | /* Find the corresponding arm opp from the cpufreq table. */ |
1895 | while (db8500_cpufreq_table[i].frequency != CPUFREQ_TABLE_END) { | 1894 | cpufreq_for_each_entry(pos, db8500_cpufreq_table) |
1896 | if (db8500_cpufreq_table[i].frequency == rate) | 1895 | if (pos->frequency == rate) |
1897 | break; | 1896 | break; |
1898 | i++; | ||
1899 | } | ||
1900 | 1897 | ||
1901 | if (db8500_cpufreq_table[i].frequency != rate) | 1898 | if (pos->frequency != rate) |
1902 | return -EINVAL; | 1899 | return -EINVAL; |
1903 | 1900 | ||
1904 | /* Set the new arm opp. */ | 1901 | /* Set the new arm opp. */ |
1905 | return db8500_prcmu_set_arm_opp(db8500_cpufreq_table[i].driver_data); | 1902 | return db8500_prcmu_set_arm_opp(pos->driver_data); |
1906 | } | 1903 | } |
1907 | 1904 | ||
1908 | static int set_plldsi_rate(unsigned long rate) | 1905 | static int set_plldsi_rate(unsigned long rate) |
diff --git a/drivers/net/irda/sh_sir.c b/drivers/net/irda/sh_sir.c index cadf52e22464..e3fe9a286136 100644 --- a/drivers/net/irda/sh_sir.c +++ b/drivers/net/irda/sh_sir.c | |||
@@ -217,21 +217,17 @@ crc_init_out: | |||
217 | static u32 sh_sir_find_sclk(struct clk *irda_clk) | 217 | static u32 sh_sir_find_sclk(struct clk *irda_clk) |
218 | { | 218 | { |
219 | struct cpufreq_frequency_table *freq_table = irda_clk->freq_table; | 219 | struct cpufreq_frequency_table *freq_table = irda_clk->freq_table; |
220 | struct cpufreq_frequency_table *pos; | ||
220 | struct clk *pclk = clk_get(NULL, "peripheral_clk"); | 221 | struct clk *pclk = clk_get(NULL, "peripheral_clk"); |
221 | u32 limit, min = 0xffffffff, tmp; | 222 | u32 limit, min = 0xffffffff, tmp; |
222 | int i, index = 0; | 223 | int index = 0; |
223 | 224 | ||
224 | limit = clk_get_rate(pclk); | 225 | limit = clk_get_rate(pclk); |
225 | clk_put(pclk); | 226 | clk_put(pclk); |
226 | 227 | ||
227 | /* IrDA can not set over peripheral_clk */ | 228 | /* IrDA can not set over peripheral_clk */ |
228 | for (i = 0; | 229 | cpufreq_for_each_valid_entry(pos, freq_table) { |
229 | freq_table[i].frequency != CPUFREQ_TABLE_END; | 230 | u32 freq = pos->frequency; |
230 | i++) { | ||
231 | u32 freq = freq_table[i].frequency; | ||
232 | |||
233 | if (freq == CPUFREQ_ENTRY_INVALID) | ||
234 | continue; | ||
235 | 231 | ||
236 | /* IrDA should not over peripheral_clk */ | 232 | /* IrDA should not over peripheral_clk */ |
237 | if (freq > limit) | 233 | if (freq > limit) |
@@ -240,7 +236,7 @@ static u32 sh_sir_find_sclk(struct clk *irda_clk) | |||
240 | tmp = freq % SCLK_BASE; | 236 | tmp = freq % SCLK_BASE; |
241 | if (tmp < min) { | 237 | if (tmp < min) { |
242 | min = tmp; | 238 | min = tmp; |
243 | index = i; | 239 | index = pos - freq_table; |
244 | } | 240 | } |
245 | } | 241 | } |
246 | 242 | ||
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 74727851820d..be56b22ca941 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c | |||
@@ -196,17 +196,11 @@ int clk_rate_table_find(struct clk *clk, | |||
196 | struct cpufreq_frequency_table *freq_table, | 196 | struct cpufreq_frequency_table *freq_table, |
197 | unsigned long rate) | 197 | unsigned long rate) |
198 | { | 198 | { |
199 | int i; | 199 | struct cpufreq_frequency_table *pos; |
200 | |||
201 | for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { | ||
202 | unsigned long freq = freq_table[i].frequency; | ||
203 | 200 | ||
204 | if (freq == CPUFREQ_ENTRY_INVALID) | 201 | cpufreq_for_each_valid_entry(pos, freq_table) |
205 | continue; | 202 | if (pos->frequency == rate) |
206 | 203 | return pos - freq_table; | |
207 | if (freq == rate) | ||
208 | return i; | ||
209 | } | ||
210 | 204 | ||
211 | return -ENOENT; | 205 | return -ENOENT; |
212 | } | 206 | } |
@@ -575,11 +569,7 @@ long clk_round_parent(struct clk *clk, unsigned long target, | |||
575 | return abs(target - *best_freq); | 569 | return abs(target - *best_freq); |
576 | } | 570 | } |
577 | 571 | ||
578 | for (freq = parent->freq_table; freq->frequency != CPUFREQ_TABLE_END; | 572 | cpufreq_for_each_valid_entry(freq, parent->freq_table) { |
579 | freq++) { | ||
580 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) | ||
581 | continue; | ||
582 | |||
583 | if (unlikely(freq->frequency / target <= div_min - 1)) { | 573 | if (unlikely(freq->frequency / target <= div_min - 1)) { |
584 | unsigned long freq_max; | 574 | unsigned long freq_max; |
585 | 575 | ||
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 4246262c4bd2..84a75f89bf74 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c | |||
@@ -144,11 +144,11 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
144 | unsigned int *output, | 144 | unsigned int *output, |
145 | enum cpufreq_cooling_property property) | 145 | enum cpufreq_cooling_property property) |
146 | { | 146 | { |
147 | int i, j; | 147 | int i; |
148 | unsigned long max_level = 0, level = 0; | 148 | unsigned long max_level = 0, level = 0; |
149 | unsigned int freq = CPUFREQ_ENTRY_INVALID; | 149 | unsigned int freq = CPUFREQ_ENTRY_INVALID; |
150 | int descend = -1; | 150 | int descend = -1; |
151 | struct cpufreq_frequency_table *table = | 151 | struct cpufreq_frequency_table *pos, *table = |
152 | cpufreq_frequency_get_table(cpu); | 152 | cpufreq_frequency_get_table(cpu); |
153 | 153 | ||
154 | if (!output) | 154 | if (!output) |
@@ -157,20 +157,16 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
157 | if (!table) | 157 | if (!table) |
158 | return -EINVAL; | 158 | return -EINVAL; |
159 | 159 | ||
160 | for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 160 | cpufreq_for_each_valid_entry(pos, table) { |
161 | /* ignore invalid entries */ | ||
162 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) | ||
163 | continue; | ||
164 | |||
165 | /* ignore duplicate entry */ | 161 | /* ignore duplicate entry */ |
166 | if (freq == table[i].frequency) | 162 | if (freq == pos->frequency) |
167 | continue; | 163 | continue; |
168 | 164 | ||
169 | /* get the frequency order */ | 165 | /* get the frequency order */ |
170 | if (freq != CPUFREQ_ENTRY_INVALID && descend == -1) | 166 | if (freq != CPUFREQ_ENTRY_INVALID && descend == -1) |
171 | descend = !!(freq > table[i].frequency); | 167 | descend = freq > pos->frequency; |
172 | 168 | ||
173 | freq = table[i].frequency; | 169 | freq = pos->frequency; |
174 | max_level++; | 170 | max_level++; |
175 | } | 171 | } |
176 | 172 | ||
@@ -190,29 +186,26 @@ static int get_property(unsigned int cpu, unsigned long input, | |||
190 | if (property == GET_FREQ) | 186 | if (property == GET_FREQ) |
191 | level = descend ? input : (max_level - input); | 187 | level = descend ? input : (max_level - input); |
192 | 188 | ||
193 | for (i = 0, j = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { | 189 | i = 0; |
194 | /* ignore invalid entry */ | 190 | cpufreq_for_each_valid_entry(pos, table) { |
195 | if (table[i].frequency == CPUFREQ_ENTRY_INVALID) | ||
196 | continue; | ||
197 | |||
198 | /* ignore duplicate entry */ | 191 | /* ignore duplicate entry */ |
199 | if (freq == table[i].frequency) | 192 | if (freq == pos->frequency) |
200 | continue; | 193 | continue; |
201 | 194 | ||
202 | /* now we have a valid frequency entry */ | 195 | /* now we have a valid frequency entry */ |
203 | freq = table[i].frequency; | 196 | freq = pos->frequency; |
204 | 197 | ||
205 | if (property == GET_LEVEL && (unsigned int)input == freq) { | 198 | if (property == GET_LEVEL && (unsigned int)input == freq) { |
206 | /* get level by frequency */ | 199 | /* get level by frequency */ |
207 | *output = descend ? j : (max_level - j); | 200 | *output = descend ? i : (max_level - i); |
208 | return 0; | 201 | return 0; |
209 | } | 202 | } |
210 | if (property == GET_FREQ && level == j) { | 203 | if (property == GET_FREQ && level == i) { |
211 | /* get frequency by level */ | 204 | /* get frequency by level */ |
212 | *output = freq; | 205 | *output = freq; |
213 | return 0; | 206 | return 0; |
214 | } | 207 | } |
215 | j++; | 208 | i++; |
216 | } | 209 | } |
217 | 210 | ||
218 | return -EINVAL; | 211 | return -EINVAL; |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 5ae5100c1f24..9d803b529ac2 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -110,6 +110,7 @@ struct cpufreq_policy { | |||
110 | bool transition_ongoing; /* Tracks transition status */ | 110 | bool transition_ongoing; /* Tracks transition status */ |
111 | spinlock_t transition_lock; | 111 | spinlock_t transition_lock; |
112 | wait_queue_head_t transition_wait; | 112 | wait_queue_head_t transition_wait; |
113 | struct task_struct *transition_task; /* Task which is doing the transition */ | ||
113 | }; | 114 | }; |
114 | 115 | ||
115 | /* Only for ACPI */ | 116 | /* Only for ACPI */ |
@@ -468,6 +469,48 @@ struct cpufreq_frequency_table { | |||
468 | * order */ | 469 | * order */ |
469 | }; | 470 | }; |
470 | 471 | ||
472 | #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP) | ||
473 | int dev_pm_opp_init_cpufreq_table(struct device *dev, | ||
474 | struct cpufreq_frequency_table **table); | ||
475 | void dev_pm_opp_free_cpufreq_table(struct device *dev, | ||
476 | struct cpufreq_frequency_table **table); | ||
477 | #else | ||
478 | static inline int dev_pm_opp_init_cpufreq_table(struct device *dev, | ||
479 | struct cpufreq_frequency_table | ||
480 | **table) | ||
481 | { | ||
482 | return -EINVAL; | ||
483 | } | ||
484 | |||
485 | static inline void dev_pm_opp_free_cpufreq_table(struct device *dev, | ||
486 | struct cpufreq_frequency_table | ||
487 | **table) | ||
488 | { | ||
489 | } | ||
490 | #endif | ||
491 | |||
492 | |||
493 | bool cpufreq_next_valid(struct cpufreq_frequency_table **pos); | ||
494 | |||
495 | /* | ||
496 | * cpufreq_for_each_entry - iterate over a cpufreq_frequency_table | ||
497 | * @pos: the cpufreq_frequency_table * to use as a loop cursor. | ||
498 | * @table: the cpufreq_frequency_table * to iterate over. | ||
499 | */ | ||
500 | |||
501 | #define cpufreq_for_each_entry(pos, table) \ | ||
502 | for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++) | ||
503 | |||
504 | /* | ||
505 | * cpufreq_for_each_valid_entry - iterate over a cpufreq_frequency_table | ||
506 | * excluding CPUFREQ_ENTRY_INVALID frequencies. | ||
507 | * @pos: the cpufreq_frequency_table * to use as a loop cursor. | ||
508 | * @table: the cpufreq_frequency_table * to iterate over. | ||
509 | */ | ||
510 | |||
511 | #define cpufreq_for_each_valid_entry(pos, table) \ | ||
512 | for (pos = table; cpufreq_next_valid(&pos); pos++) | ||
513 | |||
471 | int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, | 514 | int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, |
472 | struct cpufreq_frequency_table *table); | 515 | struct cpufreq_frequency_table *table); |
473 | 516 | ||
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 5151b0059585..0330217abfad 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h | |||
@@ -15,7 +15,6 @@ | |||
15 | #define __LINUX_OPP_H__ | 15 | #define __LINUX_OPP_H__ |
16 | 16 | ||
17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
18 | #include <linux/cpufreq.h> | ||
19 | #include <linux/notifier.h> | 18 | #include <linux/notifier.h> |
20 | 19 | ||
21 | struct dev_pm_opp; | 20 | struct dev_pm_opp; |
@@ -117,23 +116,4 @@ static inline int of_init_opp_table(struct device *dev) | |||
117 | } | 116 | } |
118 | #endif | 117 | #endif |
119 | 118 | ||
120 | #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP) | ||
121 | int dev_pm_opp_init_cpufreq_table(struct device *dev, | ||
122 | struct cpufreq_frequency_table **table); | ||
123 | void dev_pm_opp_free_cpufreq_table(struct device *dev, | ||
124 | struct cpufreq_frequency_table **table); | ||
125 | #else | ||
126 | static inline int dev_pm_opp_init_cpufreq_table(struct device *dev, | ||
127 | struct cpufreq_frequency_table **table) | ||
128 | { | ||
129 | return -EINVAL; | ||
130 | } | ||
131 | |||
132 | static inline | ||
133 | void dev_pm_opp_free_cpufreq_table(struct device *dev, | ||
134 | struct cpufreq_frequency_table **table) | ||
135 | { | ||
136 | } | ||
137 | #endif /* CONFIG_CPU_FREQ */ | ||
138 | |||
139 | #endif /* __LINUX_OPP_H__ */ | 119 | #endif /* __LINUX_OPP_H__ */ |
diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile index cbfec92af327..3651db7eda23 100644 --- a/tools/power/cpupower/Makefile +++ b/tools/power/cpupower/Makefile | |||
@@ -62,7 +62,7 @@ LIB_MAJ= 0.0.0 | |||
62 | LIB_MIN= 0 | 62 | LIB_MIN= 0 |
63 | 63 | ||
64 | PACKAGE = cpupower | 64 | PACKAGE = cpupower |
65 | PACKAGE_BUGREPORT = cpufreq@vger.kernel.org | 65 | PACKAGE_BUGREPORT = linux-pm@vger.kernel.org |
66 | LANGUAGES = de fr it cs pt | 66 | LANGUAGES = de fr it cs pt |
67 | 67 | ||
68 | 68 | ||
diff --git a/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c b/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c index 0f10b81e3322..5224ee5b392d 100644 --- a/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c +++ b/tools/power/cpupower/debug/kernel/cpufreq-test_tsc.c | |||
@@ -18,7 +18,7 @@ | |||
18 | * 5.) if the third value, "diff_pmtmr", changes between 2. and 4., the | 18 | * 5.) if the third value, "diff_pmtmr", changes between 2. and 4., the |
19 | * TSC-based delay routine on the Linux kernel does not correctly | 19 | * TSC-based delay routine on the Linux kernel does not correctly |
20 | * handle the cpufreq transition. Please report this to | 20 | * handle the cpufreq transition. Please report this to |
21 | * cpufreq@vger.kernel.org | 21 | * linux-pm@vger.kernel.org |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |