diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-06-27 15:46:45 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-06-27 15:46:45 -0400 |
commit | 39a95f4861381a87167729be8f71c59ed4efc27d (patch) | |
tree | 5dc01d8d229d9f553a7d3502902b4acb2191a19f | |
parent | 7ae9b27b2af4bb79a105bcdea08400fd00f6de87 (diff) | |
parent | 7f77a563f0c110a633b4ab0fec9f49d41630039a (diff) |
Merge branch 'pm-cpufreq-assorted' into pm-cpufreq
* pm-cpufreq-assorted: (21 commits)
cpufreq: powernow-k8: call CPUFREQ_POSTCHANGE notfier in error cases
cpufreq: pcc: call CPUFREQ_POSTCHANGE notfier in error cases
cpufreq: e_powersaver: call CPUFREQ_POSTCHANGE notfier in error cases
cpufreq: ACPI: call CPUFREQ_POSTCHANGE notfier in error cases
cpufreq: make __cpufreq_notify_transition() static
cpufreq: Fix minor formatting issues
cpufreq: Fix governor start/stop race condition
cpufreq: Simplify userspace governor
cpufreq: powerpc: move cpufreq driver to drivers/cpufreq
cpufreq: kirkwood: Select CPU_FREQ_TABLE option
cpufreq: big.LITTLE needs cpufreq table
cpufreq: SPEAr needs cpufreq table
cpufreq: powerpc: Add cpufreq driver for Freescale e500mc SoCs
cpufreq: remove unnecessary cpufreq_cpu_{get|put}() calls
cpufreq: MAINTAINERS: Add git tree path for ARM specific updates
cpufreq: rename index as driver_data in cpufreq_frequency_table
cpufreq: Don't create empty /sys/devices/system/cpu/cpufreq directory
cpufreq: Move get_cpu_idle_time() to cpufreq.c
cpufreq: governors: Move get_governor_parent_kobj() to cpufreq.c
cpufreq: Add EXPORT_SYMBOL_GPL for have_governor_per_policy
...
56 files changed, 867 insertions, 514 deletions
diff --git a/Documentation/cpu-freq/cpu-drivers.txt b/Documentation/cpu-freq/cpu-drivers.txt index a3585eac83b6..19fa98e07bf7 100644 --- a/Documentation/cpu-freq/cpu-drivers.txt +++ b/Documentation/cpu-freq/cpu-drivers.txt | |||
@@ -186,7 +186,7 @@ As most cpufreq processors only allow for being set to a few specific | |||
186 | frequencies, a "frequency table" with some functions might assist in | 186 | frequencies, a "frequency table" with some functions might assist in |
187 | some work of the processor driver. Such a "frequency table" consists | 187 | some work of the processor driver. Such a "frequency table" consists |
188 | of an array of struct cpufreq_frequency_table entries, with any value in | 188 | of an array of struct cpufreq_frequency_table entries, with any value in |
189 | "index" you want to use, and the corresponding frequency in | 189 | "driver_data" you want to use, and the corresponding frequency in |
190 | "frequency". At the end of the table, you need to add a | 190 | "frequency". At the end of the table, you need to add a |
191 | cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And | 191 | cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And |
192 | if you want to skip one entry in the table, set the frequency to | 192 | if you want to skip one entry in the table, set the frequency to |
@@ -214,10 +214,4 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
214 | is the corresponding frequency table helper for the ->target | 214 | is the corresponding frequency table helper for the ->target |
215 | stage. Just pass the values to this function, and the unsigned int | 215 | stage. Just pass the values to this function, and the unsigned int |
216 | index returns the number of the frequency table entry which contains | 216 | index returns the number of the frequency table entry which contains |
217 | the frequency the CPU shall be set to. PLEASE NOTE: This is not the | 217 | the frequency the CPU shall be set to. |
218 | "index" which is in this cpufreq_table_entry.index, but instead | ||
219 | cpufreq_table[index]. So, the new frequency is | ||
220 | cpufreq_table[index].frequency, and the value you stored into the | ||
221 | frequency table "index" field is | ||
222 | cpufreq_table[index].index. | ||
223 | |||
diff --git a/MAINTAINERS b/MAINTAINERS index 5be702cc8449..041df42fc34d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -2215,7 +2215,8 @@ M: Viresh Kumar <viresh.kumar@linaro.org> | |||
2215 | L: cpufreq@vger.kernel.org | 2215 | L: cpufreq@vger.kernel.org |
2216 | L: linux-pm@vger.kernel.org | 2216 | L: linux-pm@vger.kernel.org |
2217 | S: Maintained | 2217 | S: Maintained |
2218 | T: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git | 2218 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git |
2219 | T: git git://git.linaro.org/people/vireshk/linux.git (For ARM Updates) | ||
2219 | F: drivers/cpufreq/ | 2220 | F: drivers/cpufreq/ |
2220 | F: include/linux/cpufreq.h | 2221 | F: include/linux/cpufreq.h |
2221 | 2222 | ||
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index 4d6933848abf..a0d4f6038b60 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c | |||
@@ -1004,7 +1004,7 @@ static const struct da850_opp da850_opp_96 = { | |||
1004 | 1004 | ||
1005 | #define OPP(freq) \ | 1005 | #define OPP(freq) \ |
1006 | { \ | 1006 | { \ |
1007 | .index = (unsigned int) &da850_opp_##freq, \ | 1007 | .driver_data = (unsigned int) &da850_opp_##freq, \ |
1008 | .frequency = freq * 1000, \ | 1008 | .frequency = freq * 1000, \ |
1009 | } | 1009 | } |
1010 | 1010 | ||
@@ -1016,7 +1016,7 @@ static struct cpufreq_frequency_table da850_freq_table[] = { | |||
1016 | OPP(200), | 1016 | OPP(200), |
1017 | OPP(96), | 1017 | OPP(96), |
1018 | { | 1018 | { |
1019 | .index = 0, | 1019 | .driver_data = 0, |
1020 | .frequency = CPUFREQ_TABLE_END, | 1020 | .frequency = CPUFREQ_TABLE_END, |
1021 | }, | 1021 | }, |
1022 | }; | 1022 | }; |
@@ -1044,7 +1044,7 @@ static int da850_set_voltage(unsigned int index) | |||
1044 | if (!cvdd) | 1044 | if (!cvdd) |
1045 | return -ENODEV; | 1045 | return -ENODEV; |
1046 | 1046 | ||
1047 | opp = (struct da850_opp *) cpufreq_info.freq_table[index].index; | 1047 | opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data; |
1048 | 1048 | ||
1049 | return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max); | 1049 | return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max); |
1050 | } | 1050 | } |
@@ -1125,7 +1125,7 @@ static int da850_set_pll0rate(struct clk *clk, unsigned long index) | |||
1125 | struct pll_data *pll = clk->pll_data; | 1125 | struct pll_data *pll = clk->pll_data; |
1126 | int ret; | 1126 | int ret; |
1127 | 1127 | ||
1128 | opp = (struct da850_opp *) cpufreq_info.freq_table[index].index; | 1128 | opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data; |
1129 | prediv = opp->prediv; | 1129 | prediv = opp->prediv; |
1130 | mult = opp->mult; | 1130 | mult = opp->mult; |
1131 | postdiv = opp->postdiv; | 1131 | postdiv = opp->postdiv; |
diff --git a/arch/arm/mach-s3c24xx/cpufreq-utils.c b/arch/arm/mach-s3c24xx/cpufreq-utils.c index ddd8280e3875..2a0aa5684e72 100644 --- a/arch/arm/mach-s3c24xx/cpufreq-utils.c +++ b/arch/arm/mach-s3c24xx/cpufreq-utils.c | |||
@@ -60,5 +60,5 @@ void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg) | |||
60 | */ | 60 | */ |
61 | void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg) | 61 | void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg) |
62 | { | 62 | { |
63 | __raw_writel(cfg->pll.index, S3C2410_MPLLCON); | 63 | __raw_writel(cfg->pll.driver_data, S3C2410_MPLLCON); |
64 | } | 64 | } |
diff --git a/arch/arm/mach-s3c24xx/cpufreq.c b/arch/arm/mach-s3c24xx/cpufreq.c index 3c0e78ede0da..3513e7477160 100644 --- a/arch/arm/mach-s3c24xx/cpufreq.c +++ b/arch/arm/mach-s3c24xx/cpufreq.c | |||
@@ -70,7 +70,7 @@ static void s3c_cpufreq_getcur(struct s3c_cpufreq_config *cfg) | |||
70 | cfg->freq.pclk = pclk = clk_get_rate(clk_pclk); | 70 | cfg->freq.pclk = pclk = clk_get_rate(clk_pclk); |
71 | cfg->freq.armclk = armclk = clk_get_rate(clk_arm); | 71 | cfg->freq.armclk = armclk = clk_get_rate(clk_arm); |
72 | 72 | ||
73 | cfg->pll.index = __raw_readl(S3C2410_MPLLCON); | 73 | cfg->pll.driver_data = __raw_readl(S3C2410_MPLLCON); |
74 | cfg->pll.frequency = fclk; | 74 | cfg->pll.frequency = fclk; |
75 | 75 | ||
76 | cfg->freq.hclk_tns = 1000000000 / (cfg->freq.hclk / 10); | 76 | cfg->freq.hclk_tns = 1000000000 / (cfg->freq.hclk / 10); |
@@ -431,7 +431,7 @@ static unsigned int suspend_freq; | |||
431 | static int s3c_cpufreq_suspend(struct cpufreq_policy *policy) | 431 | static int s3c_cpufreq_suspend(struct cpufreq_policy *policy) |
432 | { | 432 | { |
433 | suspend_pll.frequency = clk_get_rate(_clk_mpll); | 433 | suspend_pll.frequency = clk_get_rate(_clk_mpll); |
434 | suspend_pll.index = __raw_readl(S3C2410_MPLLCON); | 434 | suspend_pll.driver_data = __raw_readl(S3C2410_MPLLCON); |
435 | suspend_freq = s3c_cpufreq_get(0) * 1000; | 435 | suspend_freq = s3c_cpufreq_get(0) * 1000; |
436 | 436 | ||
437 | return 0; | 437 | return 0; |
diff --git a/arch/arm/mach-s3c24xx/pll-s3c2410.c b/arch/arm/mach-s3c24xx/pll-s3c2410.c index dcf3420a3271..5e37d368594b 100644 --- a/arch/arm/mach-s3c24xx/pll-s3c2410.c +++ b/arch/arm/mach-s3c24xx/pll-s3c2410.c | |||
@@ -33,36 +33,36 @@ | |||
33 | #include <plat/cpu-freq-core.h> | 33 | #include <plat/cpu-freq-core.h> |
34 | 34 | ||
35 | static struct cpufreq_frequency_table pll_vals_12MHz[] = { | 35 | static struct cpufreq_frequency_table pll_vals_12MHz[] = { |
36 | { .frequency = 34000000, .index = PLLVAL(82, 2, 3), }, | 36 | { .frequency = 34000000, .driver_data = PLLVAL(82, 2, 3), }, |
37 | { .frequency = 45000000, .index = PLLVAL(82, 1, 3), }, | 37 | { .frequency = 45000000, .driver_data = PLLVAL(82, 1, 3), }, |
38 | { .frequency = 51000000, .index = PLLVAL(161, 3, 3), }, | 38 | { .frequency = 51000000, .driver_data = PLLVAL(161, 3, 3), }, |
39 | { .frequency = 48000000, .index = PLLVAL(120, 2, 3), }, | 39 | { .frequency = 48000000, .driver_data = PLLVAL(120, 2, 3), }, |
40 | { .frequency = 56000000, .index = PLLVAL(142, 2, 3), }, | 40 | { .frequency = 56000000, .driver_data = PLLVAL(142, 2, 3), }, |
41 | { .frequency = 68000000, .index = PLLVAL(82, 2, 2), }, | 41 | { .frequency = 68000000, .driver_data = PLLVAL(82, 2, 2), }, |
42 | { .frequency = 79000000, .index = PLLVAL(71, 1, 2), }, | 42 | { .frequency = 79000000, .driver_data = PLLVAL(71, 1, 2), }, |
43 | { .frequency = 85000000, .index = PLLVAL(105, 2, 2), }, | 43 | { .frequency = 85000000, .driver_data = PLLVAL(105, 2, 2), }, |
44 | { .frequency = 90000000, .index = PLLVAL(112, 2, 2), }, | 44 | { .frequency = 90000000, .driver_data = PLLVAL(112, 2, 2), }, |
45 | { .frequency = 101000000, .index = PLLVAL(127, 2, 2), }, | 45 | { .frequency = 101000000, .driver_data = PLLVAL(127, 2, 2), }, |
46 | { .frequency = 113000000, .index = PLLVAL(105, 1, 2), }, | 46 | { .frequency = 113000000, .driver_data = PLLVAL(105, 1, 2), }, |
47 | { .frequency = 118000000, .index = PLLVAL(150, 2, 2), }, | 47 | { .frequency = 118000000, .driver_data = PLLVAL(150, 2, 2), }, |
48 | { .frequency = 124000000, .index = PLLVAL(116, 1, 2), }, | 48 | { .frequency = 124000000, .driver_data = PLLVAL(116, 1, 2), }, |
49 | { .frequency = 135000000, .index = PLLVAL(82, 2, 1), }, | 49 | { .frequency = 135000000, .driver_data = PLLVAL(82, 2, 1), }, |
50 | { .frequency = 147000000, .index = PLLVAL(90, 2, 1), }, | 50 | { .frequency = 147000000, .driver_data = PLLVAL(90, 2, 1), }, |
51 | { .frequency = 152000000, .index = PLLVAL(68, 1, 1), }, | 51 | { .frequency = 152000000, .driver_data = PLLVAL(68, 1, 1), }, |
52 | { .frequency = 158000000, .index = PLLVAL(71, 1, 1), }, | 52 | { .frequency = 158000000, .driver_data = PLLVAL(71, 1, 1), }, |
53 | { .frequency = 170000000, .index = PLLVAL(77, 1, 1), }, | 53 | { .frequency = 170000000, .driver_data = PLLVAL(77, 1, 1), }, |
54 | { .frequency = 180000000, .index = PLLVAL(82, 1, 1), }, | 54 | { .frequency = 180000000, .driver_data = PLLVAL(82, 1, 1), }, |
55 | { .frequency = 186000000, .index = PLLVAL(85, 1, 1), }, | 55 | { .frequency = 186000000, .driver_data = PLLVAL(85, 1, 1), }, |
56 | { .frequency = 192000000, .index = PLLVAL(88, 1, 1), }, | 56 | { .frequency = 192000000, .driver_data = PLLVAL(88, 1, 1), }, |
57 | { .frequency = 203000000, .index = PLLVAL(161, 3, 1), }, | 57 | { .frequency = 203000000, .driver_data = PLLVAL(161, 3, 1), }, |
58 | 58 | ||
59 | /* 2410A extras */ | 59 | /* 2410A extras */ |
60 | 60 | ||
61 | { .frequency = 210000000, .index = PLLVAL(132, 2, 1), }, | 61 | { .frequency = 210000000, .driver_data = PLLVAL(132, 2, 1), }, |
62 | { .frequency = 226000000, .index = PLLVAL(105, 1, 1), }, | 62 | { .frequency = 226000000, .driver_data = PLLVAL(105, 1, 1), }, |
63 | { .frequency = 266000000, .index = PLLVAL(125, 1, 1), }, | 63 | { .frequency = 266000000, .driver_data = PLLVAL(125, 1, 1), }, |
64 | { .frequency = 268000000, .index = PLLVAL(126, 1, 1), }, | 64 | { .frequency = 268000000, .driver_data = PLLVAL(126, 1, 1), }, |
65 | { .frequency = 270000000, .index = PLLVAL(127, 1, 1), }, | 65 | { .frequency = 270000000, .driver_data = PLLVAL(127, 1, 1), }, |
66 | }; | 66 | }; |
67 | 67 | ||
68 | static int s3c2410_plls_add(struct device *dev, struct subsys_interface *sif) | 68 | static int s3c2410_plls_add(struct device *dev, struct subsys_interface *sif) |
diff --git a/arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c b/arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c index 673781758319..a19460e6e7b0 100644 --- a/arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c +++ b/arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c | |||
@@ -21,33 +21,33 @@ | |||
21 | #include <plat/cpu-freq-core.h> | 21 | #include <plat/cpu-freq-core.h> |
22 | 22 | ||
23 | static struct cpufreq_frequency_table s3c2440_plls_12[] __initdata = { | 23 | static struct cpufreq_frequency_table s3c2440_plls_12[] __initdata = { |
24 | { .frequency = 75000000, .index = PLLVAL(0x75, 3, 3), }, /* FVco 600.000000 */ | 24 | { .frequency = 75000000, .driver_data = PLLVAL(0x75, 3, 3), }, /* FVco 600.000000 */ |
25 | { .frequency = 80000000, .index = PLLVAL(0x98, 4, 3), }, /* FVco 640.000000 */ | 25 | { .frequency = 80000000, .driver_data = PLLVAL(0x98, 4, 3), }, /* FVco 640.000000 */ |
26 | { .frequency = 90000000, .index = PLLVAL(0x70, 2, 3), }, /* FVco 720.000000 */ | 26 | { .frequency = 90000000, .driver_data = PLLVAL(0x70, 2, 3), }, /* FVco 720.000000 */ |
27 | { .frequency = 100000000, .index = PLLVAL(0x5c, 1, 3), }, /* FVco 800.000000 */ | 27 | { .frequency = 100000000, .driver_data = PLLVAL(0x5c, 1, 3), }, /* FVco 800.000000 */ |
28 | { .frequency = 110000000, .index = PLLVAL(0x66, 1, 3), }, /* FVco 880.000000 */ | 28 | { .frequency = 110000000, .driver_data = PLLVAL(0x66, 1, 3), }, /* FVco 880.000000 */ |
29 | { .frequency = 120000000, .index = PLLVAL(0x70, 1, 3), }, /* FVco 960.000000 */ | 29 | { .frequency = 120000000, .driver_data = PLLVAL(0x70, 1, 3), }, /* FVco 960.000000 */ |
30 | { .frequency = 150000000, .index = PLLVAL(0x75, 3, 2), }, /* FVco 600.000000 */ | 30 | { .frequency = 150000000, .driver_data = PLLVAL(0x75, 3, 2), }, /* FVco 600.000000 */ |
31 | { .frequency = 160000000, .index = PLLVAL(0x98, 4, 2), }, /* FVco 640.000000 */ | 31 | { .frequency = 160000000, .driver_data = PLLVAL(0x98, 4, 2), }, /* FVco 640.000000 */ |
32 | { .frequency = 170000000, .index = PLLVAL(0x4d, 1, 2), }, /* FVco 680.000000 */ | 32 | { .frequency = 170000000, .driver_data = PLLVAL(0x4d, 1, 2), }, /* FVco 680.000000 */ |
33 | { .frequency = 180000000, .index = PLLVAL(0x70, 2, 2), }, /* FVco 720.000000 */ | 33 | { .frequency = 180000000, .driver_data = PLLVAL(0x70, 2, 2), }, /* FVco 720.000000 */ |
34 | { .frequency = 190000000, .index = PLLVAL(0x57, 1, 2), }, /* FVco 760.000000 */ | 34 | { .frequency = 190000000, .driver_data = PLLVAL(0x57, 1, 2), }, /* FVco 760.000000 */ |
35 | { .frequency = 200000000, .index = PLLVAL(0x5c, 1, 2), }, /* FVco 800.000000 */ | 35 | { .frequency = 200000000, .driver_data = PLLVAL(0x5c, 1, 2), }, /* FVco 800.000000 */ |
36 | { .frequency = 210000000, .index = PLLVAL(0x84, 2, 2), }, /* FVco 840.000000 */ | 36 | { .frequency = 210000000, .driver_data = PLLVAL(0x84, 2, 2), }, /* FVco 840.000000 */ |
37 | { .frequency = 220000000, .index = PLLVAL(0x66, 1, 2), }, /* FVco 880.000000 */ | 37 | { .frequency = 220000000, .driver_data = PLLVAL(0x66, 1, 2), }, /* FVco 880.000000 */ |
38 | { .frequency = 230000000, .index = PLLVAL(0x6b, 1, 2), }, /* FVco 920.000000 */ | 38 | { .frequency = 230000000, .driver_data = PLLVAL(0x6b, 1, 2), }, /* FVco 920.000000 */ |
39 | { .frequency = 240000000, .index = PLLVAL(0x70, 1, 2), }, /* FVco 960.000000 */ | 39 | { .frequency = 240000000, .driver_data = PLLVAL(0x70, 1, 2), }, /* FVco 960.000000 */ |
40 | { .frequency = 300000000, .index = PLLVAL(0x75, 3, 1), }, /* FVco 600.000000 */ | 40 | { .frequency = 300000000, .driver_data = PLLVAL(0x75, 3, 1), }, /* FVco 600.000000 */ |
41 | { .frequency = 310000000, .index = PLLVAL(0x93, 4, 1), }, /* FVco 620.000000 */ | 41 | { .frequency = 310000000, .driver_data = PLLVAL(0x93, 4, 1), }, /* FVco 620.000000 */ |
42 | { .frequency = 320000000, .index = PLLVAL(0x98, 4, 1), }, /* FVco 640.000000 */ | 42 | { .frequency = 320000000, .driver_data = PLLVAL(0x98, 4, 1), }, /* FVco 640.000000 */ |
43 | { .frequency = 330000000, .index = PLLVAL(0x66, 2, 1), }, /* FVco 660.000000 */ | 43 | { .frequency = 330000000, .driver_data = PLLVAL(0x66, 2, 1), }, /* FVco 660.000000 */ |
44 | { .frequency = 340000000, .index = PLLVAL(0x4d, 1, 1), }, /* FVco 680.000000 */ | 44 | { .frequency = 340000000, .driver_data = PLLVAL(0x4d, 1, 1), }, /* FVco 680.000000 */ |
45 | { .frequency = 350000000, .index = PLLVAL(0xa7, 4, 1), }, /* FVco 700.000000 */ | 45 | { .frequency = 350000000, .driver_data = PLLVAL(0xa7, 4, 1), }, /* FVco 700.000000 */ |
46 | { .frequency = 360000000, .index = PLLVAL(0x70, 2, 1), }, /* FVco 720.000000 */ | 46 | { .frequency = 360000000, .driver_data = PLLVAL(0x70, 2, 1), }, /* FVco 720.000000 */ |
47 | { .frequency = 370000000, .index = PLLVAL(0xb1, 4, 1), }, /* FVco 740.000000 */ | 47 | { .frequency = 370000000, .driver_data = PLLVAL(0xb1, 4, 1), }, /* FVco 740.000000 */ |
48 | { .frequency = 380000000, .index = PLLVAL(0x57, 1, 1), }, /* FVco 760.000000 */ | 48 | { .frequency = 380000000, .driver_data = PLLVAL(0x57, 1, 1), }, /* FVco 760.000000 */ |
49 | { .frequency = 390000000, .index = PLLVAL(0x7a, 2, 1), }, /* FVco 780.000000 */ | 49 | { .frequency = 390000000, .driver_data = PLLVAL(0x7a, 2, 1), }, /* FVco 780.000000 */ |
50 | { .frequency = 400000000, .index = PLLVAL(0x5c, 1, 1), }, /* FVco 800.000000 */ | 50 | { .frequency = 400000000, .driver_data = PLLVAL(0x5c, 1, 1), }, /* FVco 800.000000 */ |
51 | }; | 51 | }; |
52 | 52 | ||
53 | static int s3c2440_plls12_add(struct device *dev, struct subsys_interface *sif) | 53 | static int s3c2440_plls12_add(struct device *dev, struct subsys_interface *sif) |
diff --git a/arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c b/arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c index debfa106289b..1191b2905625 100644 --- a/arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c +++ b/arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c | |||
@@ -21,61 +21,61 @@ | |||
21 | #include <plat/cpu-freq-core.h> | 21 | #include <plat/cpu-freq-core.h> |
22 | 22 | ||
23 | static struct cpufreq_frequency_table s3c2440_plls_169344[] __initdata = { | 23 | static struct cpufreq_frequency_table s3c2440_plls_169344[] __initdata = { |
24 | { .frequency = 78019200, .index = PLLVAL(121, 5, 3), }, /* FVco 624.153600 */ | 24 | { .frequency = 78019200, .driver_data = PLLVAL(121, 5, 3), }, /* FVco 624.153600 */ |
25 | { .frequency = 84067200, .index = PLLVAL(131, 5, 3), }, /* FVco 672.537600 */ | 25 | { .frequency = 84067200, .driver_data = PLLVAL(131, 5, 3), }, /* FVco 672.537600 */ |
26 | { .frequency = 90115200, .index = PLLVAL(141, 5, 3), }, /* FVco 720.921600 */ | 26 | { .frequency = 90115200, .driver_data = PLLVAL(141, 5, 3), }, /* FVco 720.921600 */ |
27 | { .frequency = 96163200, .index = PLLVAL(151, 5, 3), }, /* FVco 769.305600 */ | 27 | { .frequency = 96163200, .driver_data = PLLVAL(151, 5, 3), }, /* FVco 769.305600 */ |
28 | { .frequency = 102135600, .index = PLLVAL(185, 6, 3), }, /* FVco 817.084800 */ | 28 | { .frequency = 102135600, .driver_data = PLLVAL(185, 6, 3), }, /* FVco 817.084800 */ |
29 | { .frequency = 108259200, .index = PLLVAL(171, 5, 3), }, /* FVco 866.073600 */ | 29 | { .frequency = 108259200, .driver_data = PLLVAL(171, 5, 3), }, /* FVco 866.073600 */ |
30 | { .frequency = 114307200, .index = PLLVAL(127, 3, 3), }, /* FVco 914.457600 */ | 30 | { .frequency = 114307200, .driver_data = PLLVAL(127, 3, 3), }, /* FVco 914.457600 */ |
31 | { .frequency = 120234240, .index = PLLVAL(134, 3, 3), }, /* FVco 961.873920 */ | 31 | { .frequency = 120234240, .driver_data = PLLVAL(134, 3, 3), }, /* FVco 961.873920 */ |
32 | { .frequency = 126161280, .index = PLLVAL(141, 3, 3), }, /* FVco 1009.290240 */ | 32 | { .frequency = 126161280, .driver_data = PLLVAL(141, 3, 3), }, /* FVco 1009.290240 */ |
33 | { .frequency = 132088320, .index = PLLVAL(148, 3, 3), }, /* FVco 1056.706560 */ | 33 | { .frequency = 132088320, .driver_data = PLLVAL(148, 3, 3), }, /* FVco 1056.706560 */ |
34 | { .frequency = 138015360, .index = PLLVAL(155, 3, 3), }, /* FVco 1104.122880 */ | 34 | { .frequency = 138015360, .driver_data = PLLVAL(155, 3, 3), }, /* FVco 1104.122880 */ |
35 | { .frequency = 144789120, .index = PLLVAL(163, 3, 3), }, /* FVco 1158.312960 */ | 35 | { .frequency = 144789120, .driver_data = PLLVAL(163, 3, 3), }, /* FVco 1158.312960 */ |
36 | { .frequency = 150100363, .index = PLLVAL(187, 9, 2), }, /* FVco 600.401454 */ | 36 | { .frequency = 150100363, .driver_data = PLLVAL(187, 9, 2), }, /* FVco 600.401454 */ |
37 | { .frequency = 156038400, .index = PLLVAL(121, 5, 2), }, /* FVco 624.153600 */ | 37 | { .frequency = 156038400, .driver_data = PLLVAL(121, 5, 2), }, /* FVco 624.153600 */ |
38 | { .frequency = 162086400, .index = PLLVAL(126, 5, 2), }, /* FVco 648.345600 */ | 38 | { .frequency = 162086400, .driver_data = PLLVAL(126, 5, 2), }, /* FVco 648.345600 */ |
39 | { .frequency = 168134400, .index = PLLVAL(131, 5, 2), }, /* FVco 672.537600 */ | 39 | { .frequency = 168134400, .driver_data = PLLVAL(131, 5, 2), }, /* FVco 672.537600 */ |
40 | { .frequency = 174048000, .index = PLLVAL(177, 7, 2), }, /* FVco 696.192000 */ | 40 | { .frequency = 174048000, .driver_data = PLLVAL(177, 7, 2), }, /* FVco 696.192000 */ |
41 | { .frequency = 180230400, .index = PLLVAL(141, 5, 2), }, /* FVco 720.921600 */ | 41 | { .frequency = 180230400, .driver_data = PLLVAL(141, 5, 2), }, /* FVco 720.921600 */ |
42 | { .frequency = 186278400, .index = PLLVAL(124, 4, 2), }, /* FVco 745.113600 */ | 42 | { .frequency = 186278400, .driver_data = PLLVAL(124, 4, 2), }, /* FVco 745.113600 */ |
43 | { .frequency = 192326400, .index = PLLVAL(151, 5, 2), }, /* FVco 769.305600 */ | 43 | { .frequency = 192326400, .driver_data = PLLVAL(151, 5, 2), }, /* FVco 769.305600 */ |
44 | { .frequency = 198132480, .index = PLLVAL(109, 3, 2), }, /* FVco 792.529920 */ | 44 | { .frequency = 198132480, .driver_data = PLLVAL(109, 3, 2), }, /* FVco 792.529920 */ |
45 | { .frequency = 204271200, .index = PLLVAL(185, 6, 2), }, /* FVco 817.084800 */ | 45 | { .frequency = 204271200, .driver_data = PLLVAL(185, 6, 2), }, /* FVco 817.084800 */ |
46 | { .frequency = 210268800, .index = PLLVAL(141, 4, 2), }, /* FVco 841.075200 */ | 46 | { .frequency = 210268800, .driver_data = PLLVAL(141, 4, 2), }, /* FVco 841.075200 */ |
47 | { .frequency = 216518400, .index = PLLVAL(171, 5, 2), }, /* FVco 866.073600 */ | 47 | { .frequency = 216518400, .driver_data = PLLVAL(171, 5, 2), }, /* FVco 866.073600 */ |
48 | { .frequency = 222264000, .index = PLLVAL(97, 2, 2), }, /* FVco 889.056000 */ | 48 | { .frequency = 222264000, .driver_data = PLLVAL(97, 2, 2), }, /* FVco 889.056000 */ |
49 | { .frequency = 228614400, .index = PLLVAL(127, 3, 2), }, /* FVco 914.457600 */ | 49 | { .frequency = 228614400, .driver_data = PLLVAL(127, 3, 2), }, /* FVco 914.457600 */ |
50 | { .frequency = 234259200, .index = PLLVAL(158, 4, 2), }, /* FVco 937.036800 */ | 50 | { .frequency = 234259200, .driver_data = PLLVAL(158, 4, 2), }, /* FVco 937.036800 */ |
51 | { .frequency = 240468480, .index = PLLVAL(134, 3, 2), }, /* FVco 961.873920 */ | 51 | { .frequency = 240468480, .driver_data = PLLVAL(134, 3, 2), }, /* FVco 961.873920 */ |
52 | { .frequency = 246960000, .index = PLLVAL(167, 4, 2), }, /* FVco 987.840000 */ | 52 | { .frequency = 246960000, .driver_data = PLLVAL(167, 4, 2), }, /* FVco 987.840000 */ |
53 | { .frequency = 252322560, .index = PLLVAL(141, 3, 2), }, /* FVco 1009.290240 */ | 53 | { .frequency = 252322560, .driver_data = PLLVAL(141, 3, 2), }, /* FVco 1009.290240 */ |
54 | { .frequency = 258249600, .index = PLLVAL(114, 2, 2), }, /* FVco 1032.998400 */ | 54 | { .frequency = 258249600, .driver_data = PLLVAL(114, 2, 2), }, /* FVco 1032.998400 */ |
55 | { .frequency = 264176640, .index = PLLVAL(148, 3, 2), }, /* FVco 1056.706560 */ | 55 | { .frequency = 264176640, .driver_data = PLLVAL(148, 3, 2), }, /* FVco 1056.706560 */ |
56 | { .frequency = 270950400, .index = PLLVAL(120, 2, 2), }, /* FVco 1083.801600 */ | 56 | { .frequency = 270950400, .driver_data = PLLVAL(120, 2, 2), }, /* FVco 1083.801600 */ |
57 | { .frequency = 276030720, .index = PLLVAL(155, 3, 2), }, /* FVco 1104.122880 */ | 57 | { .frequency = 276030720, .driver_data = PLLVAL(155, 3, 2), }, /* FVco 1104.122880 */ |
58 | { .frequency = 282240000, .index = PLLVAL(92, 1, 2), }, /* FVco 1128.960000 */ | 58 | { .frequency = 282240000, .driver_data = PLLVAL(92, 1, 2), }, /* FVco 1128.960000 */ |
59 | { .frequency = 289578240, .index = PLLVAL(163, 3, 2), }, /* FVco 1158.312960 */ | 59 | { .frequency = 289578240, .driver_data = PLLVAL(163, 3, 2), }, /* FVco 1158.312960 */ |
60 | { .frequency = 294235200, .index = PLLVAL(131, 2, 2), }, /* FVco 1176.940800 */ | 60 | { .frequency = 294235200, .driver_data = PLLVAL(131, 2, 2), }, /* FVco 1176.940800 */ |
61 | { .frequency = 300200727, .index = PLLVAL(187, 9, 1), }, /* FVco 600.401454 */ | 61 | { .frequency = 300200727, .driver_data = PLLVAL(187, 9, 1), }, /* FVco 600.401454 */ |
62 | { .frequency = 306358690, .index = PLLVAL(191, 9, 1), }, /* FVco 612.717380 */ | 62 | { .frequency = 306358690, .driver_data = PLLVAL(191, 9, 1), }, /* FVco 612.717380 */ |
63 | { .frequency = 312076800, .index = PLLVAL(121, 5, 1), }, /* FVco 624.153600 */ | 63 | { .frequency = 312076800, .driver_data = PLLVAL(121, 5, 1), }, /* FVco 624.153600 */ |
64 | { .frequency = 318366720, .index = PLLVAL(86, 3, 1), }, /* FVco 636.733440 */ | 64 | { .frequency = 318366720, .driver_data = PLLVAL(86, 3, 1), }, /* FVco 636.733440 */ |
65 | { .frequency = 324172800, .index = PLLVAL(126, 5, 1), }, /* FVco 648.345600 */ | 65 | { .frequency = 324172800, .driver_data = PLLVAL(126, 5, 1), }, /* FVco 648.345600 */ |
66 | { .frequency = 330220800, .index = PLLVAL(109, 4, 1), }, /* FVco 660.441600 */ | 66 | { .frequency = 330220800, .driver_data = PLLVAL(109, 4, 1), }, /* FVco 660.441600 */ |
67 | { .frequency = 336268800, .index = PLLVAL(131, 5, 1), }, /* FVco 672.537600 */ | 67 | { .frequency = 336268800, .driver_data = PLLVAL(131, 5, 1), }, /* FVco 672.537600 */ |
68 | { .frequency = 342074880, .index = PLLVAL(93, 3, 1), }, /* FVco 684.149760 */ | 68 | { .frequency = 342074880, .driver_data = PLLVAL(93, 3, 1), }, /* FVco 684.149760 */ |
69 | { .frequency = 348096000, .index = PLLVAL(177, 7, 1), }, /* FVco 696.192000 */ | 69 | { .frequency = 348096000, .driver_data = PLLVAL(177, 7, 1), }, /* FVco 696.192000 */ |
70 | { .frequency = 355622400, .index = PLLVAL(118, 4, 1), }, /* FVco 711.244800 */ | 70 | { .frequency = 355622400, .driver_data = PLLVAL(118, 4, 1), }, /* FVco 711.244800 */ |
71 | { .frequency = 360460800, .index = PLLVAL(141, 5, 1), }, /* FVco 720.921600 */ | 71 | { .frequency = 360460800, .driver_data = PLLVAL(141, 5, 1), }, /* FVco 720.921600 */ |
72 | { .frequency = 366206400, .index = PLLVAL(165, 6, 1), }, /* FVco 732.412800 */ | 72 | { .frequency = 366206400, .driver_data = PLLVAL(165, 6, 1), }, /* FVco 732.412800 */ |
73 | { .frequency = 372556800, .index = PLLVAL(124, 4, 1), }, /* FVco 745.113600 */ | 73 | { .frequency = 372556800, .driver_data = PLLVAL(124, 4, 1), }, /* FVco 745.113600 */ |
74 | { .frequency = 378201600, .index = PLLVAL(126, 4, 1), }, /* FVco 756.403200 */ | 74 | { .frequency = 378201600, .driver_data = PLLVAL(126, 4, 1), }, /* FVco 756.403200 */ |
75 | { .frequency = 384652800, .index = PLLVAL(151, 5, 1), }, /* FVco 769.305600 */ | 75 | { .frequency = 384652800, .driver_data = PLLVAL(151, 5, 1), }, /* FVco 769.305600 */ |
76 | { .frequency = 391608000, .index = PLLVAL(177, 6, 1), }, /* FVco 783.216000 */ | 76 | { .frequency = 391608000, .driver_data = PLLVAL(177, 6, 1), }, /* FVco 783.216000 */ |
77 | { .frequency = 396264960, .index = PLLVAL(109, 3, 1), }, /* FVco 792.529920 */ | 77 | { .frequency = 396264960, .driver_data = PLLVAL(109, 3, 1), }, /* FVco 792.529920 */ |
78 | { .frequency = 402192000, .index = PLLVAL(87, 2, 1), }, /* FVco 804.384000 */ | 78 | { .frequency = 402192000, .driver_data = PLLVAL(87, 2, 1), }, /* FVco 804.384000 */ |
79 | }; | 79 | }; |
80 | 80 | ||
81 | static int s3c2440_plls169344_add(struct device *dev, | 81 | static int s3c2440_plls169344_add(struct device *dev, |
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c index 7e105932c09d..5390c6bbbc02 100644 --- a/arch/arm/mach-shmobile/clock-sh7372.c +++ b/arch/arm/mach-shmobile/clock-sh7372.c | |||
@@ -142,15 +142,15 @@ static void pllc2_table_rebuild(struct clk *clk) | |||
142 | /* Initialise PLLC2 frequency table */ | 142 | /* Initialise PLLC2 frequency table */ |
143 | for (i = 0; i < ARRAY_SIZE(pllc2_freq_table) - 2; i++) { | 143 | for (i = 0; i < ARRAY_SIZE(pllc2_freq_table) - 2; i++) { |
144 | pllc2_freq_table[i].frequency = clk->parent->rate * (i + 20) * 2; | 144 | pllc2_freq_table[i].frequency = clk->parent->rate * (i + 20) * 2; |
145 | pllc2_freq_table[i].index = i; | 145 | pllc2_freq_table[i].driver_data = i; |
146 | } | 146 | } |
147 | 147 | ||
148 | /* This is a special entry - switching PLL off makes it a repeater */ | 148 | /* This is a special entry - switching PLL off makes it a repeater */ |
149 | pllc2_freq_table[i].frequency = clk->parent->rate; | 149 | pllc2_freq_table[i].frequency = clk->parent->rate; |
150 | pllc2_freq_table[i].index = i; | 150 | pllc2_freq_table[i].driver_data = i; |
151 | 151 | ||
152 | pllc2_freq_table[++i].frequency = CPUFREQ_TABLE_END; | 152 | pllc2_freq_table[++i].frequency = CPUFREQ_TABLE_END; |
153 | pllc2_freq_table[i].index = i; | 153 | pllc2_freq_table[i].driver_data = i; |
154 | } | 154 | } |
155 | 155 | ||
156 | static unsigned long pllc2_recalc(struct clk *clk) | 156 | static unsigned long pllc2_recalc(struct clk *clk) |
diff --git a/arch/arm/plat-samsung/include/plat/cpu-freq-core.h b/arch/arm/plat-samsung/include/plat/cpu-freq-core.h index 95509d8eb140..a8a760ddfae1 100644 --- a/arch/arm/plat-samsung/include/plat/cpu-freq-core.h +++ b/arch/arm/plat-samsung/include/plat/cpu-freq-core.h | |||
@@ -285,7 +285,7 @@ static inline int s3c_cpufreq_addfreq(struct cpufreq_frequency_table *table, | |||
285 | s3c_freq_dbg("%s: { %d = %u kHz }\n", | 285 | s3c_freq_dbg("%s: { %d = %u kHz }\n", |
286 | __func__, index, freq); | 286 | __func__, index, freq); |
287 | 287 | ||
288 | table[index].index = index; | 288 | table[index].driver_data = index; |
289 | table[index].frequency = freq; | 289 | table[index].frequency = freq; |
290 | } | 290 | } |
291 | 291 | ||
diff --git a/arch/mips/loongson/lemote-2f/clock.c b/arch/mips/loongson/lemote-2f/clock.c index bc739d4bab2e..4dc2f5fa3f67 100644 --- a/arch/mips/loongson/lemote-2f/clock.c +++ b/arch/mips/loongson/lemote-2f/clock.c | |||
@@ -121,7 +121,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate) | |||
121 | clk->rate = rate; | 121 | clk->rate = rate; |
122 | 122 | ||
123 | regval = LOONGSON_CHIPCFG0; | 123 | regval = LOONGSON_CHIPCFG0; |
124 | regval = (regval & ~0x7) | (loongson2_clockmod_table[i].index - 1); | 124 | regval = (regval & ~0x7) | |
125 | (loongson2_clockmod_table[i].driver_data - 1); | ||
125 | LOONGSON_CHIPCFG0 = regval; | 126 | LOONGSON_CHIPCFG0 = regval; |
126 | 127 | ||
127 | return ret; | 128 | return ret; |
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig index b62aab3e22ec..e17cdfc5ba40 100644 --- a/arch/powerpc/platforms/Kconfig +++ b/arch/powerpc/platforms/Kconfig | |||
@@ -193,37 +193,6 @@ config PPC_IO_WORKAROUNDS | |||
193 | 193 | ||
194 | source "drivers/cpufreq/Kconfig" | 194 | source "drivers/cpufreq/Kconfig" |
195 | 195 | ||
196 | menu "CPU Frequency drivers" | ||
197 | depends on CPU_FREQ | ||
198 | |||
199 | config CPU_FREQ_PMAC | ||
200 | bool "Support for Apple PowerBooks" | ||
201 | depends on ADB_PMU && PPC32 | ||
202 | select CPU_FREQ_TABLE | ||
203 | help | ||
204 | This adds support for frequency switching on Apple PowerBooks, | ||
205 | this currently includes some models of iBook & Titanium | ||
206 | PowerBook. | ||
207 | |||
208 | config CPU_FREQ_PMAC64 | ||
209 | bool "Support for some Apple G5s" | ||
210 | depends on PPC_PMAC && PPC64 | ||
211 | select CPU_FREQ_TABLE | ||
212 | help | ||
213 | This adds support for frequency switching on Apple iMac G5, | ||
214 | and some of the more recent desktop G5 machines as well. | ||
215 | |||
216 | config PPC_PASEMI_CPUFREQ | ||
217 | bool "Support for PA Semi PWRficient" | ||
218 | depends on PPC_PASEMI | ||
219 | default y | ||
220 | select CPU_FREQ_TABLE | ||
221 | help | ||
222 | This adds the support for frequency switching on PA Semi | ||
223 | PWRficient processors. | ||
224 | |||
225 | endmenu | ||
226 | |||
227 | menu "CPUIdle driver" | 196 | menu "CPUIdle driver" |
228 | 197 | ||
229 | source "drivers/cpuidle/Kconfig" | 198 | source "drivers/cpuidle/Kconfig" |
diff --git a/arch/powerpc/platforms/pasemi/Makefile b/arch/powerpc/platforms/pasemi/Makefile index ce6d789e0741..8e8d4cae5ebe 100644 --- a/arch/powerpc/platforms/pasemi/Makefile +++ b/arch/powerpc/platforms/pasemi/Makefile | |||
@@ -1,3 +1,2 @@ | |||
1 | obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o dma_lib.o misc.o | 1 | obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o dma_lib.o misc.o |
2 | obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o | 2 | obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o |
3 | obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += cpufreq.o | ||
diff --git a/arch/powerpc/platforms/powermac/Makefile b/arch/powerpc/platforms/powermac/Makefile index ea47df66fee5..52c6ce1cc985 100644 --- a/arch/powerpc/platforms/powermac/Makefile +++ b/arch/powerpc/platforms/powermac/Makefile | |||
@@ -9,8 +9,6 @@ obj-y += pic.o setup.o time.o feature.o pci.o \ | |||
9 | sleep.o low_i2c.o cache.o pfunc_core.o \ | 9 | sleep.o low_i2c.o cache.o pfunc_core.o \ |
10 | pfunc_base.o udbg_scc.o udbg_adb.o | 10 | pfunc_base.o udbg_scc.o udbg_adb.o |
11 | obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o | 11 | obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o |
12 | obj-$(CONFIG_CPU_FREQ_PMAC) += cpufreq_32.o | ||
13 | obj-$(CONFIG_CPU_FREQ_PMAC64) += cpufreq_64.o | ||
14 | # CONFIG_NVRAM is an arch. independent tristate symbol, for pmac32 we really | 12 | # CONFIG_NVRAM is an arch. independent tristate symbol, for pmac32 we really |
15 | # need this to be a bool. Cheat here and pretend CONFIG_NVRAM=m is really | 13 | # need this to be a bool. Cheat here and pretend CONFIG_NVRAM=m is really |
16 | # CONFIG_NVRAM=y | 14 | # CONFIG_NVRAM=y |
diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index f0077cb8e249..c8ec186303db 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c | |||
@@ -648,14 +648,14 @@ int opp_init_cpufreq_table(struct device *dev, | |||
648 | 648 | ||
649 | list_for_each_entry(opp, &dev_opp->opp_list, node) { | 649 | list_for_each_entry(opp, &dev_opp->opp_list, node) { |
650 | if (opp->available) { | 650 | if (opp->available) { |
651 | freq_table[i].index = i; | 651 | freq_table[i].driver_data = i; |
652 | freq_table[i].frequency = opp->rate / 1000; | 652 | freq_table[i].frequency = opp->rate / 1000; |
653 | i++; | 653 | i++; |
654 | } | 654 | } |
655 | } | 655 | } |
656 | mutex_unlock(&dev_opp_list_lock); | 656 | mutex_unlock(&dev_opp_list_lock); |
657 | 657 | ||
658 | freq_table[i].index = i; | 658 | freq_table[i].driver_data = i; |
659 | freq_table[i].frequency = CPUFREQ_TABLE_END; | 659 | freq_table[i].frequency = CPUFREQ_TABLE_END; |
660 | 660 | ||
661 | *table = &freq_table[0]; | 661 | *table = &freq_table[0]; |
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index 5085427eb29d..fee9f489269a 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm | |||
@@ -5,6 +5,7 @@ | |||
5 | config ARM_BIG_LITTLE_CPUFREQ | 5 | config ARM_BIG_LITTLE_CPUFREQ |
6 | tristate "Generic ARM big LITTLE CPUfreq driver" | 6 | tristate "Generic ARM big LITTLE CPUfreq driver" |
7 | depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK | 7 | depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK |
8 | select CPU_FREQ_TABLE | ||
8 | help | 9 | help |
9 | This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. | 10 | This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. |
10 | 11 | ||
@@ -88,6 +89,7 @@ config ARM_INTEGRATOR | |||
88 | 89 | ||
89 | config ARM_KIRKWOOD_CPUFREQ | 90 | config ARM_KIRKWOOD_CPUFREQ |
90 | def_bool ARCH_KIRKWOOD && OF | 91 | def_bool ARCH_KIRKWOOD && OF |
92 | select CPU_FREQ_TABLE | ||
91 | help | 93 | help |
92 | This adds the CPUFreq driver for Marvell Kirkwood | 94 | This adds the CPUFreq driver for Marvell Kirkwood |
93 | SoCs. | 95 | SoCs. |
@@ -151,6 +153,7 @@ config ARM_SA1110_CPUFREQ | |||
151 | config ARM_SPEAR_CPUFREQ | 153 | config ARM_SPEAR_CPUFREQ |
152 | bool "SPEAr CPUFreq support" | 154 | bool "SPEAr CPUFreq support" |
153 | depends on PLAT_SPEAR | 155 | depends on PLAT_SPEAR |
156 | select CPU_FREQ_TABLE | ||
154 | default y | 157 | default y |
155 | help | 158 | help |
156 | This adds the CPUFreq driver support for SPEAr SOCs. | 159 | This adds the CPUFreq driver support for SPEAr SOCs. |
diff --git a/drivers/cpufreq/Kconfig.powerpc b/drivers/cpufreq/Kconfig.powerpc index 68c1abc401f6..25ca9db62e09 100644 --- a/drivers/cpufreq/Kconfig.powerpc +++ b/drivers/cpufreq/Kconfig.powerpc | |||
@@ -24,3 +24,39 @@ config CPU_FREQ_MAPLE | |||
24 | help | 24 | help |
25 | This adds support for frequency switching on Maple 970FX | 25 | This adds support for frequency switching on Maple 970FX |
26 | Evaluation Board and compatible boards (IBM JS2x blades). | 26 | Evaluation Board and compatible boards (IBM JS2x blades). |
27 | |||
28 | config PPC_CORENET_CPUFREQ | ||
29 | tristate "CPU frequency scaling driver for Freescale E500MC SoCs" | ||
30 | depends on PPC_E500MC && OF && COMMON_CLK | ||
31 | select CPU_FREQ_TABLE | ||
32 | select CLK_PPC_CORENET | ||
33 | help | ||
34 | This adds the CPUFreq driver support for Freescale e500mc, | ||
35 | e5500 and e6500 series SoCs which are capable of changing | ||
36 | the CPU's frequency dynamically. | ||
37 | |||
38 | config CPU_FREQ_PMAC | ||
39 | bool "Support for Apple PowerBooks" | ||
40 | depends on ADB_PMU && PPC32 | ||
41 | select CPU_FREQ_TABLE | ||
42 | help | ||
43 | This adds support for frequency switching on Apple PowerBooks, | ||
44 | this currently includes some models of iBook & Titanium | ||
45 | PowerBook. | ||
46 | |||
47 | config CPU_FREQ_PMAC64 | ||
48 | bool "Support for some Apple G5s" | ||
49 | depends on PPC_PMAC && PPC64 | ||
50 | select CPU_FREQ_TABLE | ||
51 | help | ||
52 | This adds support for frequency switching on Apple iMac G5, | ||
53 | and some of the more recent desktop G5 machines as well. | ||
54 | |||
55 | config PPC_PASEMI_CPUFREQ | ||
56 | bool "Support for PA Semi PWRficient" | ||
57 | depends on PPC_PASEMI | ||
58 | select CPU_FREQ_TABLE | ||
59 | default y | ||
60 | help | ||
61 | This adds the support for frequency switching on PA Semi | ||
62 | PWRficient processors. | ||
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 9c873e778ee0..0c8d0c69306d 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
@@ -79,6 +79,10 @@ obj-$(CONFIG_CPU_FREQ_CBE) += ppc-cbe-cpufreq.o | |||
79 | ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o | 79 | ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o |
80 | obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o | 80 | obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o |
81 | obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o | 81 | obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o |
82 | obj-$(CONFIG_PPC_CORENET_CPUFREQ) += ppc-corenet-cpufreq.o | ||
83 | obj-$(CONFIG_CPU_FREQ_PMAC) += pmac32-cpufreq.o | ||
84 | obj-$(CONFIG_CPU_FREQ_PMAC64) += pmac64-cpufreq.o | ||
85 | obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += pasemi-cpufreq.o | ||
82 | 86 | ||
83 | ################################################################################## | 87 | ################################################################################## |
84 | # Other platform drivers | 88 | # Other platform drivers |
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index edc089e9d0c4..2c5906d71397 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
@@ -232,7 +232,7 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) | |||
232 | perf = data->acpi_data; | 232 | perf = data->acpi_data; |
233 | 233 | ||
234 | for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { | 234 | for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { |
235 | if (msr == perf->states[data->freq_table[i].index].status) | 235 | if (msr == perf->states[data->freq_table[i].driver_data].status) |
236 | return data->freq_table[i].frequency; | 236 | return data->freq_table[i].frequency; |
237 | } | 237 | } |
238 | return data->freq_table[0].frequency; | 238 | return data->freq_table[0].frequency; |
@@ -442,7 +442,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
442 | goto out; | 442 | goto out; |
443 | } | 443 | } |
444 | 444 | ||
445 | next_perf_state = data->freq_table[next_state].index; | 445 | next_perf_state = data->freq_table[next_state].driver_data; |
446 | if (perf->state == next_perf_state) { | 446 | if (perf->state == next_perf_state) { |
447 | if (unlikely(data->resume)) { | 447 | if (unlikely(data->resume)) { |
448 | pr_debug("Called after resume, resetting to P%d\n", | 448 | pr_debug("Called after resume, resetting to P%d\n", |
@@ -494,12 +494,14 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, | |||
494 | pr_debug("acpi_cpufreq_target failed (%d)\n", | 494 | pr_debug("acpi_cpufreq_target failed (%d)\n", |
495 | policy->cpu); | 495 | policy->cpu); |
496 | result = -EAGAIN; | 496 | result = -EAGAIN; |
497 | goto out; | 497 | freqs.new = freqs.old; |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 501 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
502 | perf->state = next_perf_state; | 502 | |
503 | if (!result) | ||
504 | perf->state = next_perf_state; | ||
503 | 505 | ||
504 | out: | 506 | out: |
505 | return result; | 507 | return result; |
@@ -811,7 +813,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
811 | data->freq_table[valid_states-1].frequency / 1000) | 813 | data->freq_table[valid_states-1].frequency / 1000) |
812 | continue; | 814 | continue; |
813 | 815 | ||
814 | data->freq_table[valid_states].index = i; | 816 | data->freq_table[valid_states].driver_data = i; |
815 | data->freq_table[valid_states].frequency = | 817 | data->freq_table[valid_states].frequency = |
816 | perf->states[i].core_frequency * 1000; | 818 | perf->states[i].core_frequency * 1000; |
817 | valid_states++; | 819 | valid_states++; |
@@ -947,7 +949,7 @@ static void __init acpi_cpufreq_boost_init(void) | |||
947 | /* We create the boost file in any case, though for systems without | 949 | /* We create the boost file in any case, though for systems without |
948 | * hardware support it will be read-only and hardwired to return 0. | 950 | * hardware support it will be read-only and hardwired to return 0. |
949 | */ | 951 | */ |
950 | if (sysfs_create_file(cpufreq_global_kobject, &(global_boost.attr))) | 952 | if (cpufreq_sysfs_create_file(&(global_boost.attr))) |
951 | pr_warn(PFX "could not register global boost sysfs file\n"); | 953 | pr_warn(PFX "could not register global boost sysfs file\n"); |
952 | else | 954 | else |
953 | pr_debug("registered global boost sysfs file\n"); | 955 | pr_debug("registered global boost sysfs file\n"); |
@@ -955,7 +957,7 @@ static void __init acpi_cpufreq_boost_init(void) | |||
955 | 957 | ||
956 | static void __exit acpi_cpufreq_boost_exit(void) | 958 | static void __exit acpi_cpufreq_boost_exit(void) |
957 | { | 959 | { |
958 | sysfs_remove_file(cpufreq_global_kobject, &(global_boost.attr)); | 960 | cpufreq_sysfs_remove_file(&(global_boost.attr)); |
959 | 961 | ||
960 | if (msrs) { | 962 | if (msrs) { |
961 | unregister_cpu_notifier(&boost_nb); | 963 | unregister_cpu_notifier(&boost_nb); |
diff --git a/drivers/cpufreq/blackfin-cpufreq.c b/drivers/cpufreq/blackfin-cpufreq.c index 995511e80bef..9cdbbd278a80 100644 --- a/drivers/cpufreq/blackfin-cpufreq.c +++ b/drivers/cpufreq/blackfin-cpufreq.c | |||
@@ -20,23 +20,23 @@ | |||
20 | 20 | ||
21 | 21 | ||
22 | /* this is the table of CCLK frequencies, in Hz */ | 22 | /* this is the table of CCLK frequencies, in Hz */ |
23 | /* .index is the entry in the auxiliary dpm_state_table[] */ | 23 | /* .driver_data is the entry in the auxiliary dpm_state_table[] */ |
24 | static struct cpufreq_frequency_table bfin_freq_table[] = { | 24 | static struct cpufreq_frequency_table bfin_freq_table[] = { |
25 | { | 25 | { |
26 | .frequency = CPUFREQ_TABLE_END, | 26 | .frequency = CPUFREQ_TABLE_END, |
27 | .index = 0, | 27 | .driver_data = 0, |
28 | }, | 28 | }, |
29 | { | 29 | { |
30 | .frequency = CPUFREQ_TABLE_END, | 30 | .frequency = CPUFREQ_TABLE_END, |
31 | .index = 1, | 31 | .driver_data = 1, |
32 | }, | 32 | }, |
33 | { | 33 | { |
34 | .frequency = CPUFREQ_TABLE_END, | 34 | .frequency = CPUFREQ_TABLE_END, |
35 | .index = 2, | 35 | .driver_data = 2, |
36 | }, | 36 | }, |
37 | { | 37 | { |
38 | .frequency = CPUFREQ_TABLE_END, | 38 | .frequency = CPUFREQ_TABLE_END, |
39 | .index = 0, | 39 | .driver_data = 0, |
40 | }, | 40 | }, |
41 | }; | 41 | }; |
42 | 42 | ||
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 2d53f47d1747..d976e222f10f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2001 Russell King | 4 | * Copyright (C) 2001 Russell King |
5 | * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> | 5 | * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> |
6 | * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org> | ||
6 | * | 7 | * |
7 | * Oct 2005 - Ashok Raj <ashok.raj@intel.com> | 8 | * Oct 2005 - Ashok Raj <ashok.raj@intel.com> |
8 | * Added handling for CPU hotplug | 9 | * Added handling for CPU hotplug |
@@ -12,12 +13,13 @@ | |||
12 | * This program is free software; you can redistribute it and/or modify | 13 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License version 2 as | 14 | * it under the terms of the GNU General Public License version 2 as |
14 | * published by the Free Software Foundation. | 15 | * published by the Free Software Foundation. |
15 | * | ||
16 | */ | 16 | */ |
17 | 17 | ||
18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
19 | 19 | ||
20 | #include <asm/cputime.h> | ||
20 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/kernel_stat.h> | ||
21 | #include <linux/module.h> | 23 | #include <linux/module.h> |
22 | #include <linux/init.h> | 24 | #include <linux/init.h> |
23 | #include <linux/notifier.h> | 25 | #include <linux/notifier.h> |
@@ -25,6 +27,7 @@ | |||
25 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
26 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
27 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
30 | #include <linux/tick.h> | ||
28 | #include <linux/device.h> | 31 | #include <linux/device.h> |
29 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
30 | #include <linux/cpu.h> | 33 | #include <linux/cpu.h> |
@@ -41,11 +44,13 @@ | |||
41 | */ | 44 | */ |
42 | static struct cpufreq_driver *cpufreq_driver; | 45 | static struct cpufreq_driver *cpufreq_driver; |
43 | static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); | 46 | static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data); |
47 | static DEFINE_RWLOCK(cpufreq_driver_lock); | ||
48 | static DEFINE_MUTEX(cpufreq_governor_lock); | ||
49 | |||
44 | #ifdef CONFIG_HOTPLUG_CPU | 50 | #ifdef CONFIG_HOTPLUG_CPU |
45 | /* This one keeps track of the previously set governor of a removed CPU */ | 51 | /* This one keeps track of the previously set governor of a removed CPU */ |
46 | static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); | 52 | static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); |
47 | #endif | 53 | #endif |
48 | static DEFINE_RWLOCK(cpufreq_driver_lock); | ||
49 | 54 | ||
50 | /* | 55 | /* |
51 | * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure | 56 | * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure |
@@ -132,6 +137,51 @@ bool have_governor_per_policy(void) | |||
132 | { | 137 | { |
133 | return cpufreq_driver->have_governor_per_policy; | 138 | return cpufreq_driver->have_governor_per_policy; |
134 | } | 139 | } |
140 | EXPORT_SYMBOL_GPL(have_governor_per_policy); | ||
141 | |||
142 | struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) | ||
143 | { | ||
144 | if (have_governor_per_policy()) | ||
145 | return &policy->kobj; | ||
146 | else | ||
147 | return cpufreq_global_kobject; | ||
148 | } | ||
149 | EXPORT_SYMBOL_GPL(get_governor_parent_kobj); | ||
150 | |||
151 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | ||
152 | { | ||
153 | u64 idle_time; | ||
154 | u64 cur_wall_time; | ||
155 | u64 busy_time; | ||
156 | |||
157 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | ||
158 | |||
159 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; | ||
160 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; | ||
161 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; | ||
162 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; | ||
163 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
164 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
165 | |||
166 | idle_time = cur_wall_time - busy_time; | ||
167 | if (wall) | ||
168 | *wall = cputime_to_usecs(cur_wall_time); | ||
169 | |||
170 | return cputime_to_usecs(idle_time); | ||
171 | } | ||
172 | |||
173 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) | ||
174 | { | ||
175 | u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); | ||
176 | |||
177 | if (idle_time == -1ULL) | ||
178 | return get_cpu_idle_time_jiffy(cpu, wall); | ||
179 | else if (!io_busy) | ||
180 | idle_time += get_cpu_iowait_time_us(cpu, wall); | ||
181 | |||
182 | return idle_time; | ||
183 | } | ||
184 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); | ||
135 | 185 | ||
136 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | 186 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) |
137 | { | 187 | { |
@@ -150,7 +200,6 @@ static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | |||
150 | if (!try_module_get(cpufreq_driver->owner)) | 200 | if (!try_module_get(cpufreq_driver->owner)) |
151 | goto err_out_unlock; | 201 | goto err_out_unlock; |
152 | 202 | ||
153 | |||
154 | /* get the CPU */ | 203 | /* get the CPU */ |
155 | data = per_cpu(cpufreq_cpu_data, cpu); | 204 | data = per_cpu(cpufreq_cpu_data, cpu); |
156 | 205 | ||
@@ -220,7 +269,7 @@ static void cpufreq_cpu_put_sysfs(struct cpufreq_policy *data) | |||
220 | */ | 269 | */ |
221 | #ifndef CONFIG_SMP | 270 | #ifndef CONFIG_SMP |
222 | static unsigned long l_p_j_ref; | 271 | static unsigned long l_p_j_ref; |
223 | static unsigned int l_p_j_ref_freq; | 272 | static unsigned int l_p_j_ref_freq; |
224 | 273 | ||
225 | static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) | 274 | static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) |
226 | { | 275 | { |
@@ -233,7 +282,7 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) | |||
233 | pr_debug("saving %lu as reference value for loops_per_jiffy; " | 282 | pr_debug("saving %lu as reference value for loops_per_jiffy; " |
234 | "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); | 283 | "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq); |
235 | } | 284 | } |
236 | if ((val == CPUFREQ_POSTCHANGE && ci->old != ci->new) || | 285 | if ((val == CPUFREQ_POSTCHANGE && ci->old != ci->new) || |
237 | (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { | 286 | (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { |
238 | loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, | 287 | loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, |
239 | ci->new); | 288 | ci->new); |
@@ -248,8 +297,7 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci) | |||
248 | } | 297 | } |
249 | #endif | 298 | #endif |
250 | 299 | ||
251 | 300 | static void __cpufreq_notify_transition(struct cpufreq_policy *policy, | |
252 | void __cpufreq_notify_transition(struct cpufreq_policy *policy, | ||
253 | struct cpufreq_freqs *freqs, unsigned int state) | 301 | struct cpufreq_freqs *freqs, unsigned int state) |
254 | { | 302 | { |
255 | BUG_ON(irqs_disabled()); | 303 | BUG_ON(irqs_disabled()); |
@@ -294,6 +342,7 @@ void __cpufreq_notify_transition(struct cpufreq_policy *policy, | |||
294 | break; | 342 | break; |
295 | } | 343 | } |
296 | } | 344 | } |
345 | |||
297 | /** | 346 | /** |
298 | * cpufreq_notify_transition - call notifier chain and adjust_jiffies | 347 | * cpufreq_notify_transition - call notifier chain and adjust_jiffies |
299 | * on frequency transition. | 348 | * on frequency transition. |
@@ -311,7 +360,6 @@ void cpufreq_notify_transition(struct cpufreq_policy *policy, | |||
311 | EXPORT_SYMBOL_GPL(cpufreq_notify_transition); | 360 | EXPORT_SYMBOL_GPL(cpufreq_notify_transition); |
312 | 361 | ||
313 | 362 | ||
314 | |||
315 | /********************************************************************* | 363 | /********************************************************************* |
316 | * SYSFS INTERFACE * | 364 | * SYSFS INTERFACE * |
317 | *********************************************************************/ | 365 | *********************************************************************/ |
@@ -376,7 +424,6 @@ out: | |||
376 | return err; | 424 | return err; |
377 | } | 425 | } |
378 | 426 | ||
379 | |||
380 | /** | 427 | /** |
381 | * cpufreq_per_cpu_attr_read() / show_##file_name() - | 428 | * cpufreq_per_cpu_attr_read() / show_##file_name() - |
382 | * print out cpufreq information | 429 | * print out cpufreq information |
@@ -441,7 +488,6 @@ static ssize_t show_cpuinfo_cur_freq(struct cpufreq_policy *policy, | |||
441 | return sprintf(buf, "%u\n", cur_freq); | 488 | return sprintf(buf, "%u\n", cur_freq); |
442 | } | 489 | } |
443 | 490 | ||
444 | |||
445 | /** | 491 | /** |
446 | * show_scaling_governor - show the current policy for the specified CPU | 492 | * show_scaling_governor - show the current policy for the specified CPU |
447 | */ | 493 | */ |
@@ -457,7 +503,6 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf) | |||
457 | return -EINVAL; | 503 | return -EINVAL; |
458 | } | 504 | } |
459 | 505 | ||
460 | |||
461 | /** | 506 | /** |
462 | * store_scaling_governor - store policy for the specified CPU | 507 | * store_scaling_governor - store policy for the specified CPU |
463 | */ | 508 | */ |
@@ -480,8 +525,10 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy, | |||
480 | &new_policy.governor)) | 525 | &new_policy.governor)) |
481 | return -EINVAL; | 526 | return -EINVAL; |
482 | 527 | ||
483 | /* Do not use cpufreq_set_policy here or the user_policy.max | 528 | /* |
484 | will be wrongly overridden */ | 529 | * Do not use cpufreq_set_policy here or the user_policy.max |
530 | * will be wrongly overridden | ||
531 | */ | ||
485 | ret = __cpufreq_set_policy(policy, &new_policy); | 532 | ret = __cpufreq_set_policy(policy, &new_policy); |
486 | 533 | ||
487 | policy->user_policy.policy = policy->policy; | 534 | policy->user_policy.policy = policy->policy; |
@@ -630,9 +677,6 @@ static struct attribute *default_attrs[] = { | |||
630 | NULL | 677 | NULL |
631 | }; | 678 | }; |
632 | 679 | ||
633 | struct kobject *cpufreq_global_kobject; | ||
634 | EXPORT_SYMBOL(cpufreq_global_kobject); | ||
635 | |||
636 | #define to_policy(k) container_of(k, struct cpufreq_policy, kobj) | 680 | #define to_policy(k) container_of(k, struct cpufreq_policy, kobj) |
637 | #define to_attr(a) container_of(a, struct freq_attr, attr) | 681 | #define to_attr(a) container_of(a, struct freq_attr, attr) |
638 | 682 | ||
@@ -703,6 +747,49 @@ static struct kobj_type ktype_cpufreq = { | |||
703 | .release = cpufreq_sysfs_release, | 747 | .release = cpufreq_sysfs_release, |
704 | }; | 748 | }; |
705 | 749 | ||
750 | struct kobject *cpufreq_global_kobject; | ||
751 | EXPORT_SYMBOL(cpufreq_global_kobject); | ||
752 | |||
753 | static int cpufreq_global_kobject_usage; | ||
754 | |||
755 | int cpufreq_get_global_kobject(void) | ||
756 | { | ||
757 | if (!cpufreq_global_kobject_usage++) | ||
758 | return kobject_add(cpufreq_global_kobject, | ||
759 | &cpu_subsys.dev_root->kobj, "%s", "cpufreq"); | ||
760 | |||
761 | return 0; | ||
762 | } | ||
763 | EXPORT_SYMBOL(cpufreq_get_global_kobject); | ||
764 | |||
765 | void cpufreq_put_global_kobject(void) | ||
766 | { | ||
767 | if (!--cpufreq_global_kobject_usage) | ||
768 | kobject_del(cpufreq_global_kobject); | ||
769 | } | ||
770 | EXPORT_SYMBOL(cpufreq_put_global_kobject); | ||
771 | |||
772 | int cpufreq_sysfs_create_file(const struct attribute *attr) | ||
773 | { | ||
774 | int ret = cpufreq_get_global_kobject(); | ||
775 | |||
776 | if (!ret) { | ||
777 | ret = sysfs_create_file(cpufreq_global_kobject, attr); | ||
778 | if (ret) | ||
779 | cpufreq_put_global_kobject(); | ||
780 | } | ||
781 | |||
782 | return ret; | ||
783 | } | ||
784 | EXPORT_SYMBOL(cpufreq_sysfs_create_file); | ||
785 | |||
786 | void cpufreq_sysfs_remove_file(const struct attribute *attr) | ||
787 | { | ||
788 | sysfs_remove_file(cpufreq_global_kobject, attr); | ||
789 | cpufreq_put_global_kobject(); | ||
790 | } | ||
791 | EXPORT_SYMBOL(cpufreq_sysfs_remove_file); | ||
792 | |||
706 | /* symlink affected CPUs */ | 793 | /* symlink affected CPUs */ |
707 | static int cpufreq_add_dev_symlink(unsigned int cpu, | 794 | static int cpufreq_add_dev_symlink(unsigned int cpu, |
708 | struct cpufreq_policy *policy) | 795 | struct cpufreq_policy *policy) |
@@ -1005,7 +1092,8 @@ static void update_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) | |||
1005 | * Caller should already have policy_rwsem in write mode for this CPU. | 1092 | * Caller should already have policy_rwsem in write mode for this CPU. |
1006 | * This routine frees the rwsem before returning. | 1093 | * This routine frees the rwsem before returning. |
1007 | */ | 1094 | */ |
1008 | static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) | 1095 | static int __cpufreq_remove_dev(struct device *dev, |
1096 | struct subsys_interface *sif) | ||
1009 | { | 1097 | { |
1010 | unsigned int cpu = dev->id, ret, cpus; | 1098 | unsigned int cpu = dev->id, ret, cpus; |
1011 | unsigned long flags; | 1099 | unsigned long flags; |
@@ -1112,7 +1200,6 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif | |||
1112 | return 0; | 1200 | return 0; |
1113 | } | 1201 | } |
1114 | 1202 | ||
1115 | |||
1116 | static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) | 1203 | static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) |
1117 | { | 1204 | { |
1118 | unsigned int cpu = dev->id; | 1205 | unsigned int cpu = dev->id; |
@@ -1125,7 +1212,6 @@ static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) | |||
1125 | return retval; | 1212 | return retval; |
1126 | } | 1213 | } |
1127 | 1214 | ||
1128 | |||
1129 | static void handle_update(struct work_struct *work) | 1215 | static void handle_update(struct work_struct *work) |
1130 | { | 1216 | { |
1131 | struct cpufreq_policy *policy = | 1217 | struct cpufreq_policy *policy = |
@@ -1136,7 +1222,8 @@ static void handle_update(struct work_struct *work) | |||
1136 | } | 1222 | } |
1137 | 1223 | ||
1138 | /** | 1224 | /** |
1139 | * cpufreq_out_of_sync - If actual and saved CPU frequency differs, we're in deep trouble. | 1225 | * cpufreq_out_of_sync - If actual and saved CPU frequency differs, we're |
1226 | * in deep trouble. | ||
1140 | * @cpu: cpu number | 1227 | * @cpu: cpu number |
1141 | * @old_freq: CPU frequency the kernel thinks the CPU runs at | 1228 | * @old_freq: CPU frequency the kernel thinks the CPU runs at |
1142 | * @new_freq: CPU frequency the CPU actually runs at | 1229 | * @new_freq: CPU frequency the CPU actually runs at |
@@ -1151,7 +1238,6 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, | |||
1151 | struct cpufreq_freqs freqs; | 1238 | struct cpufreq_freqs freqs; |
1152 | unsigned long flags; | 1239 | unsigned long flags; |
1153 | 1240 | ||
1154 | |||
1155 | pr_debug("Warning: CPU frequency out of sync: cpufreq and timing " | 1241 | pr_debug("Warning: CPU frequency out of sync: cpufreq and timing " |
1156 | "core thinks of %u, is %u kHz.\n", old_freq, new_freq); | 1242 | "core thinks of %u, is %u kHz.\n", old_freq, new_freq); |
1157 | 1243 | ||
@@ -1166,7 +1252,6 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, | |||
1166 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 1252 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
1167 | } | 1253 | } |
1168 | 1254 | ||
1169 | |||
1170 | /** | 1255 | /** |
1171 | * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur | 1256 | * cpufreq_quick_get - get the CPU frequency (in kHz) from policy->cur |
1172 | * @cpu: CPU number | 1257 | * @cpu: CPU number |
@@ -1212,7 +1297,6 @@ unsigned int cpufreq_quick_get_max(unsigned int cpu) | |||
1212 | } | 1297 | } |
1213 | EXPORT_SYMBOL(cpufreq_quick_get_max); | 1298 | EXPORT_SYMBOL(cpufreq_quick_get_max); |
1214 | 1299 | ||
1215 | |||
1216 | static unsigned int __cpufreq_get(unsigned int cpu) | 1300 | static unsigned int __cpufreq_get(unsigned int cpu) |
1217 | { | 1301 | { |
1218 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); | 1302 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); |
@@ -1271,7 +1355,6 @@ static struct subsys_interface cpufreq_interface = { | |||
1271 | .remove_dev = cpufreq_remove_dev, | 1355 | .remove_dev = cpufreq_remove_dev, |
1272 | }; | 1356 | }; |
1273 | 1357 | ||
1274 | |||
1275 | /** | 1358 | /** |
1276 | * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. | 1359 | * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. |
1277 | * | 1360 | * |
@@ -1408,11 +1491,10 @@ int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list) | |||
1408 | } | 1491 | } |
1409 | EXPORT_SYMBOL(cpufreq_register_notifier); | 1492 | EXPORT_SYMBOL(cpufreq_register_notifier); |
1410 | 1493 | ||
1411 | |||
1412 | /** | 1494 | /** |
1413 | * cpufreq_unregister_notifier - unregister a driver with cpufreq | 1495 | * cpufreq_unregister_notifier - unregister a driver with cpufreq |
1414 | * @nb: notifier block to be unregistered | 1496 | * @nb: notifier block to be unregistered |
1415 | * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER | 1497 | * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER |
1416 | * | 1498 | * |
1417 | * Remove a driver from the CPU frequency notifier list. | 1499 | * Remove a driver from the CPU frequency notifier list. |
1418 | * | 1500 | * |
@@ -1448,7 +1530,6 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); | |||
1448 | * GOVERNORS * | 1530 | * GOVERNORS * |
1449 | *********************************************************************/ | 1531 | *********************************************************************/ |
1450 | 1532 | ||
1451 | |||
1452 | int __cpufreq_driver_target(struct cpufreq_policy *policy, | 1533 | int __cpufreq_driver_target(struct cpufreq_policy *policy, |
1453 | unsigned int target_freq, | 1534 | unsigned int target_freq, |
1454 | unsigned int relation) | 1535 | unsigned int relation) |
@@ -1484,10 +1565,6 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1484 | { | 1565 | { |
1485 | int ret = -EINVAL; | 1566 | int ret = -EINVAL; |
1486 | 1567 | ||
1487 | policy = cpufreq_cpu_get(policy->cpu); | ||
1488 | if (!policy) | ||
1489 | goto no_policy; | ||
1490 | |||
1491 | if (unlikely(lock_policy_rwsem_write(policy->cpu))) | 1568 | if (unlikely(lock_policy_rwsem_write(policy->cpu))) |
1492 | goto fail; | 1569 | goto fail; |
1493 | 1570 | ||
@@ -1496,30 +1573,19 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1496 | unlock_policy_rwsem_write(policy->cpu); | 1573 | unlock_policy_rwsem_write(policy->cpu); |
1497 | 1574 | ||
1498 | fail: | 1575 | fail: |
1499 | cpufreq_cpu_put(policy); | ||
1500 | no_policy: | ||
1501 | return ret; | 1576 | return ret; |
1502 | } | 1577 | } |
1503 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); | 1578 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); |
1504 | 1579 | ||
1505 | int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu) | 1580 | int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu) |
1506 | { | 1581 | { |
1507 | int ret = 0; | ||
1508 | |||
1509 | if (cpufreq_disabled()) | 1582 | if (cpufreq_disabled()) |
1510 | return ret; | 1583 | return 0; |
1511 | 1584 | ||
1512 | if (!cpufreq_driver->getavg) | 1585 | if (!cpufreq_driver->getavg) |
1513 | return 0; | 1586 | return 0; |
1514 | 1587 | ||
1515 | policy = cpufreq_cpu_get(policy->cpu); | 1588 | return cpufreq_driver->getavg(policy, cpu); |
1516 | if (!policy) | ||
1517 | return -EINVAL; | ||
1518 | |||
1519 | ret = cpufreq_driver->getavg(policy, cpu); | ||
1520 | |||
1521 | cpufreq_cpu_put(policy); | ||
1522 | return ret; | ||
1523 | } | 1589 | } |
1524 | EXPORT_SYMBOL_GPL(__cpufreq_driver_getavg); | 1590 | EXPORT_SYMBOL_GPL(__cpufreq_driver_getavg); |
1525 | 1591 | ||
@@ -1562,6 +1628,21 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1562 | 1628 | ||
1563 | pr_debug("__cpufreq_governor for CPU %u, event %u\n", | 1629 | pr_debug("__cpufreq_governor for CPU %u, event %u\n", |
1564 | policy->cpu, event); | 1630 | policy->cpu, event); |
1631 | |||
1632 | mutex_lock(&cpufreq_governor_lock); | ||
1633 | if ((!policy->governor_enabled && (event == CPUFREQ_GOV_STOP)) || | ||
1634 | (policy->governor_enabled && (event == CPUFREQ_GOV_START))) { | ||
1635 | mutex_unlock(&cpufreq_governor_lock); | ||
1636 | return -EBUSY; | ||
1637 | } | ||
1638 | |||
1639 | if (event == CPUFREQ_GOV_STOP) | ||
1640 | policy->governor_enabled = false; | ||
1641 | else if (event == CPUFREQ_GOV_START) | ||
1642 | policy->governor_enabled = true; | ||
1643 | |||
1644 | mutex_unlock(&cpufreq_governor_lock); | ||
1645 | |||
1565 | ret = policy->governor->governor(policy, event); | 1646 | ret = policy->governor->governor(policy, event); |
1566 | 1647 | ||
1567 | if (!ret) { | 1648 | if (!ret) { |
@@ -1569,6 +1650,14 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1569 | policy->governor->initialized++; | 1650 | policy->governor->initialized++; |
1570 | else if (event == CPUFREQ_GOV_POLICY_EXIT) | 1651 | else if (event == CPUFREQ_GOV_POLICY_EXIT) |
1571 | policy->governor->initialized--; | 1652 | policy->governor->initialized--; |
1653 | } else { | ||
1654 | /* Restore original values */ | ||
1655 | mutex_lock(&cpufreq_governor_lock); | ||
1656 | if (event == CPUFREQ_GOV_STOP) | ||
1657 | policy->governor_enabled = true; | ||
1658 | else if (event == CPUFREQ_GOV_START) | ||
1659 | policy->governor_enabled = false; | ||
1660 | mutex_unlock(&cpufreq_governor_lock); | ||
1572 | } | 1661 | } |
1573 | 1662 | ||
1574 | /* we keep one module reference alive for | 1663 | /* we keep one module reference alive for |
@@ -1581,7 +1670,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, | |||
1581 | return ret; | 1670 | return ret; |
1582 | } | 1671 | } |
1583 | 1672 | ||
1584 | |||
1585 | int cpufreq_register_governor(struct cpufreq_governor *governor) | 1673 | int cpufreq_register_governor(struct cpufreq_governor *governor) |
1586 | { | 1674 | { |
1587 | int err; | 1675 | int err; |
@@ -1606,7 +1694,6 @@ int cpufreq_register_governor(struct cpufreq_governor *governor) | |||
1606 | } | 1694 | } |
1607 | EXPORT_SYMBOL_GPL(cpufreq_register_governor); | 1695 | EXPORT_SYMBOL_GPL(cpufreq_register_governor); |
1608 | 1696 | ||
1609 | |||
1610 | void cpufreq_unregister_governor(struct cpufreq_governor *governor) | 1697 | void cpufreq_unregister_governor(struct cpufreq_governor *governor) |
1611 | { | 1698 | { |
1612 | #ifdef CONFIG_HOTPLUG_CPU | 1699 | #ifdef CONFIG_HOTPLUG_CPU |
@@ -1636,7 +1723,6 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor) | |||
1636 | EXPORT_SYMBOL_GPL(cpufreq_unregister_governor); | 1723 | EXPORT_SYMBOL_GPL(cpufreq_unregister_governor); |
1637 | 1724 | ||
1638 | 1725 | ||
1639 | |||
1640 | /********************************************************************* | 1726 | /********************************************************************* |
1641 | * POLICY INTERFACE * | 1727 | * POLICY INTERFACE * |
1642 | *********************************************************************/ | 1728 | *********************************************************************/ |
@@ -1665,7 +1751,6 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) | |||
1665 | } | 1751 | } |
1666 | EXPORT_SYMBOL(cpufreq_get_policy); | 1752 | EXPORT_SYMBOL(cpufreq_get_policy); |
1667 | 1753 | ||
1668 | |||
1669 | /* | 1754 | /* |
1670 | * data : current policy. | 1755 | * data : current policy. |
1671 | * policy : policy to be set. | 1756 | * policy : policy to be set. |
@@ -1699,8 +1784,10 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, | |||
1699 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 1784 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
1700 | CPUFREQ_INCOMPATIBLE, policy); | 1785 | CPUFREQ_INCOMPATIBLE, policy); |
1701 | 1786 | ||
1702 | /* verify the cpu speed can be set within this limit, | 1787 | /* |
1703 | which might be different to the first one */ | 1788 | * verify the cpu speed can be set within this limit, which might be |
1789 | * different to the first one | ||
1790 | */ | ||
1704 | ret = cpufreq_driver->verify(policy); | 1791 | ret = cpufreq_driver->verify(policy); |
1705 | if (ret) | 1792 | if (ret) |
1706 | goto error_out; | 1793 | goto error_out; |
@@ -1802,8 +1889,10 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1802 | policy.policy = data->user_policy.policy; | 1889 | policy.policy = data->user_policy.policy; |
1803 | policy.governor = data->user_policy.governor; | 1890 | policy.governor = data->user_policy.governor; |
1804 | 1891 | ||
1805 | /* BIOS might change freq behind our back | 1892 | /* |
1806 | -> ask driver for current freq and notify governors about a change */ | 1893 | * BIOS might change freq behind our back |
1894 | * -> ask driver for current freq and notify governors about a change | ||
1895 | */ | ||
1807 | if (cpufreq_driver->get) { | 1896 | if (cpufreq_driver->get) { |
1808 | policy.cur = cpufreq_driver->get(cpu); | 1897 | policy.cur = cpufreq_driver->get(cpu); |
1809 | if (!data->cur) { | 1898 | if (!data->cur) { |
@@ -1852,7 +1941,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, | |||
1852 | } | 1941 | } |
1853 | 1942 | ||
1854 | static struct notifier_block __refdata cpufreq_cpu_notifier = { | 1943 | static struct notifier_block __refdata cpufreq_cpu_notifier = { |
1855 | .notifier_call = cpufreq_cpu_callback, | 1944 | .notifier_call = cpufreq_cpu_callback, |
1856 | }; | 1945 | }; |
1857 | 1946 | ||
1858 | /********************************************************************* | 1947 | /********************************************************************* |
@@ -1864,7 +1953,7 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { | |||
1864 | * @driver_data: A struct cpufreq_driver containing the values# | 1953 | * @driver_data: A struct cpufreq_driver containing the values# |
1865 | * submitted by the CPU Frequency driver. | 1954 | * submitted by the CPU Frequency driver. |
1866 | * | 1955 | * |
1867 | * Registers a CPU Frequency driver to this core code. This code | 1956 | * Registers a CPU Frequency driver to this core code. This code |
1868 | * returns zero on success, -EBUSY when another driver got here first | 1957 | * returns zero on success, -EBUSY when another driver got here first |
1869 | * (and isn't unregistered in the meantime). | 1958 | * (and isn't unregistered in the meantime). |
1870 | * | 1959 | * |
@@ -1931,11 +2020,10 @@ err_null_driver: | |||
1931 | } | 2020 | } |
1932 | EXPORT_SYMBOL_GPL(cpufreq_register_driver); | 2021 | EXPORT_SYMBOL_GPL(cpufreq_register_driver); |
1933 | 2022 | ||
1934 | |||
1935 | /** | 2023 | /** |
1936 | * cpufreq_unregister_driver - unregister the current CPUFreq driver | 2024 | * cpufreq_unregister_driver - unregister the current CPUFreq driver |
1937 | * | 2025 | * |
1938 | * Unregister the current CPUFreq driver. Only call this if you have | 2026 | * Unregister the current CPUFreq driver. Only call this if you have |
1939 | * the right to do so, i.e. if you have succeeded in initialising before! | 2027 | * the right to do so, i.e. if you have succeeded in initialising before! |
1940 | * Returns zero if successful, and -EINVAL if the cpufreq_driver is | 2028 | * Returns zero if successful, and -EINVAL if the cpufreq_driver is |
1941 | * currently not initialised. | 2029 | * currently not initialised. |
@@ -1972,7 +2060,7 @@ static int __init cpufreq_core_init(void) | |||
1972 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); | 2060 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); |
1973 | } | 2061 | } |
1974 | 2062 | ||
1975 | cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj); | 2063 | cpufreq_global_kobject = kobject_create(); |
1976 | BUG_ON(!cpufreq_global_kobject); | 2064 | BUG_ON(!cpufreq_global_kobject); |
1977 | register_syscore_ops(&cpufreq_syscore_ops); | 2065 | register_syscore_ops(&cpufreq_syscore_ops); |
1978 | 2066 | ||
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index dc9b72e25c1a..a849b2d499fa 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c | |||
@@ -23,21 +23,12 @@ | |||
23 | #include <linux/kernel_stat.h> | 23 | #include <linux/kernel_stat.h> |
24 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/tick.h> | ||
27 | #include <linux/types.h> | 26 | #include <linux/types.h> |
28 | #include <linux/workqueue.h> | 27 | #include <linux/workqueue.h> |
29 | #include <linux/cpu.h> | 28 | #include <linux/cpu.h> |
30 | 29 | ||
31 | #include "cpufreq_governor.h" | 30 | #include "cpufreq_governor.h" |
32 | 31 | ||
33 | static struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) | ||
34 | { | ||
35 | if (have_governor_per_policy()) | ||
36 | return &policy->kobj; | ||
37 | else | ||
38 | return cpufreq_global_kobject; | ||
39 | } | ||
40 | |||
41 | static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) | 32 | static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) |
42 | { | 33 | { |
43 | if (have_governor_per_policy()) | 34 | if (have_governor_per_policy()) |
@@ -46,41 +37,6 @@ static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) | |||
46 | return dbs_data->cdata->attr_group_gov_sys; | 37 | return dbs_data->cdata->attr_group_gov_sys; |
47 | } | 38 | } |
48 | 39 | ||
49 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | ||
50 | { | ||
51 | u64 idle_time; | ||
52 | u64 cur_wall_time; | ||
53 | u64 busy_time; | ||
54 | |||
55 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | ||
56 | |||
57 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; | ||
58 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; | ||
59 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; | ||
60 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; | ||
61 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
62 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
63 | |||
64 | idle_time = cur_wall_time - busy_time; | ||
65 | if (wall) | ||
66 | *wall = cputime_to_usecs(cur_wall_time); | ||
67 | |||
68 | return cputime_to_usecs(idle_time); | ||
69 | } | ||
70 | |||
71 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) | ||
72 | { | ||
73 | u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); | ||
74 | |||
75 | if (idle_time == -1ULL) | ||
76 | return get_cpu_idle_time_jiffy(cpu, wall); | ||
77 | else if (!io_busy) | ||
78 | idle_time += get_cpu_iowait_time_us(cpu, wall); | ||
79 | |||
80 | return idle_time; | ||
81 | } | ||
82 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); | ||
83 | |||
84 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | 40 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) |
85 | { | 41 | { |
86 | struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); | 42 | struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); |
@@ -278,6 +234,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
278 | return rc; | 234 | return rc; |
279 | } | 235 | } |
280 | 236 | ||
237 | if (!have_governor_per_policy()) | ||
238 | WARN_ON(cpufreq_get_global_kobject()); | ||
239 | |||
281 | rc = sysfs_create_group(get_governor_parent_kobj(policy), | 240 | rc = sysfs_create_group(get_governor_parent_kobj(policy), |
282 | get_sysfs_attr(dbs_data)); | 241 | get_sysfs_attr(dbs_data)); |
283 | if (rc) { | 242 | if (rc) { |
@@ -316,6 +275,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
316 | sysfs_remove_group(get_governor_parent_kobj(policy), | 275 | sysfs_remove_group(get_governor_parent_kobj(policy), |
317 | get_sysfs_attr(dbs_data)); | 276 | get_sysfs_attr(dbs_data)); |
318 | 277 | ||
278 | if (!have_governor_per_policy()) | ||
279 | cpufreq_put_global_kobject(); | ||
280 | |||
319 | if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && | 281 | if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && |
320 | (policy->governor->initialized == 1)) { | 282 | (policy->governor->initialized == 1)) { |
321 | struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; | 283 | struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; |
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index e16a96130cb3..6663ec3b3056 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h | |||
@@ -81,7 +81,7 @@ static ssize_t show_##file_name##_gov_sys \ | |||
81 | return sprintf(buf, "%u\n", tuners->file_name); \ | 81 | return sprintf(buf, "%u\n", tuners->file_name); \ |
82 | } \ | 82 | } \ |
83 | \ | 83 | \ |
84 | static ssize_t show_##file_name##_gov_pol \ | 84 | static ssize_t show_##file_name##_gov_pol \ |
85 | (struct cpufreq_policy *policy, char *buf) \ | 85 | (struct cpufreq_policy *policy, char *buf) \ |
86 | { \ | 86 | { \ |
87 | struct dbs_data *dbs_data = policy->governor_data; \ | 87 | struct dbs_data *dbs_data = policy->governor_data; \ |
@@ -91,7 +91,7 @@ static ssize_t show_##file_name##_gov_pol \ | |||
91 | 91 | ||
92 | #define store_one(_gov, file_name) \ | 92 | #define store_one(_gov, file_name) \ |
93 | static ssize_t store_##file_name##_gov_sys \ | 93 | static ssize_t store_##file_name##_gov_sys \ |
94 | (struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \ | 94 | (struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \ |
95 | { \ | 95 | { \ |
96 | struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \ | 96 | struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \ |
97 | return store_##file_name(dbs_data, buf, count); \ | 97 | return store_##file_name(dbs_data, buf, count); \ |
@@ -256,7 +256,6 @@ static ssize_t show_sampling_rate_min_gov_pol \ | |||
256 | return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \ | 256 | return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \ |
257 | } | 257 | } |
258 | 258 | ||
259 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); | ||
260 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); | 259 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); |
261 | bool need_load_eval(struct cpu_dbs_common_info *cdbs, | 260 | bool need_load_eval(struct cpu_dbs_common_info *cdbs, |
262 | unsigned int sampling_rate); | 261 | unsigned int sampling_rate); |
diff --git a/drivers/cpufreq/cpufreq_performance.c b/drivers/cpufreq/cpufreq_performance.c index ceee06849b91..9fef7d6e4e6a 100644 --- a/drivers/cpufreq/cpufreq_performance.c +++ b/drivers/cpufreq/cpufreq_performance.c | |||
@@ -17,7 +17,6 @@ | |||
17 | #include <linux/cpufreq.h> | 17 | #include <linux/cpufreq.h> |
18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
19 | 19 | ||
20 | |||
21 | static int cpufreq_governor_performance(struct cpufreq_policy *policy, | 20 | static int cpufreq_governor_performance(struct cpufreq_policy *policy, |
22 | unsigned int event) | 21 | unsigned int event) |
23 | { | 22 | { |
@@ -44,19 +43,16 @@ struct cpufreq_governor cpufreq_gov_performance = { | |||
44 | .owner = THIS_MODULE, | 43 | .owner = THIS_MODULE, |
45 | }; | 44 | }; |
46 | 45 | ||
47 | |||
48 | static int __init cpufreq_gov_performance_init(void) | 46 | static int __init cpufreq_gov_performance_init(void) |
49 | { | 47 | { |
50 | return cpufreq_register_governor(&cpufreq_gov_performance); | 48 | return cpufreq_register_governor(&cpufreq_gov_performance); |
51 | } | 49 | } |
52 | 50 | ||
53 | |||
54 | static void __exit cpufreq_gov_performance_exit(void) | 51 | static void __exit cpufreq_gov_performance_exit(void) |
55 | { | 52 | { |
56 | cpufreq_unregister_governor(&cpufreq_gov_performance); | 53 | cpufreq_unregister_governor(&cpufreq_gov_performance); |
57 | } | 54 | } |
58 | 55 | ||
59 | |||
60 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); | 56 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); |
61 | MODULE_DESCRIPTION("CPUfreq policy governor 'performance'"); | 57 | MODULE_DESCRIPTION("CPUfreq policy governor 'performance'"); |
62 | MODULE_LICENSE("GPL"); | 58 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/cpufreq/cpufreq_powersave.c b/drivers/cpufreq/cpufreq_powersave.c index 2d948a171155..32109a14f5dc 100644 --- a/drivers/cpufreq/cpufreq_powersave.c +++ b/drivers/cpufreq/cpufreq_powersave.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/cpufreq/cpufreq_powersave.c | 2 | * linux/drivers/cpufreq/cpufreq_powersave.c |
3 | * | 3 | * |
4 | * Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> | 4 | * Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> |
5 | * | 5 | * |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -48,13 +48,11 @@ static int __init cpufreq_gov_powersave_init(void) | |||
48 | return cpufreq_register_governor(&cpufreq_gov_powersave); | 48 | return cpufreq_register_governor(&cpufreq_gov_powersave); |
49 | } | 49 | } |
50 | 50 | ||
51 | |||
52 | static void __exit cpufreq_gov_powersave_exit(void) | 51 | static void __exit cpufreq_gov_powersave_exit(void) |
53 | { | 52 | { |
54 | cpufreq_unregister_governor(&cpufreq_gov_powersave); | 53 | cpufreq_unregister_governor(&cpufreq_gov_powersave); |
55 | } | 54 | } |
56 | 55 | ||
57 | |||
58 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); | 56 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); |
59 | MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'"); | 57 | MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'"); |
60 | MODULE_LICENSE("GPL"); | 58 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index fb65decffa28..6d35caa91167 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -27,7 +27,7 @@ static spinlock_t cpufreq_stats_lock; | |||
27 | struct cpufreq_stats { | 27 | struct cpufreq_stats { |
28 | unsigned int cpu; | 28 | unsigned int cpu; |
29 | unsigned int total_trans; | 29 | unsigned int total_trans; |
30 | unsigned long long last_time; | 30 | unsigned long long last_time; |
31 | unsigned int max_state; | 31 | unsigned int max_state; |
32 | unsigned int state_num; | 32 | unsigned int state_num; |
33 | unsigned int last_index; | 33 | unsigned int last_index; |
@@ -116,7 +116,7 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) | |||
116 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ", | 116 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ", |
117 | stat->freq_table[i]); | 117 | stat->freq_table[i]); |
118 | 118 | ||
119 | for (j = 0; j < stat->state_num; j++) { | 119 | for (j = 0; j < stat->state_num; j++) { |
120 | if (len >= PAGE_SIZE) | 120 | if (len >= PAGE_SIZE) |
121 | break; | 121 | break; |
122 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", | 122 | len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", |
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index bbeb9c0720a6..03078090b5f7 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c | |||
@@ -13,55 +13,13 @@ | |||
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
15 | 15 | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/smp.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/spinlock.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/cpufreq.h> | 16 | #include <linux/cpufreq.h> |
23 | #include <linux/cpu.h> | 17 | #include <linux/init.h> |
24 | #include <linux/types.h> | 18 | #include <linux/module.h> |
25 | #include <linux/fs.h> | ||
26 | #include <linux/sysfs.h> | ||
27 | #include <linux/mutex.h> | 19 | #include <linux/mutex.h> |
28 | 20 | ||
29 | /** | ||
30 | * A few values needed by the userspace governor | ||
31 | */ | ||
32 | static DEFINE_PER_CPU(unsigned int, cpu_max_freq); | ||
33 | static DEFINE_PER_CPU(unsigned int, cpu_min_freq); | ||
34 | static DEFINE_PER_CPU(unsigned int, cpu_cur_freq); /* current CPU freq */ | ||
35 | static DEFINE_PER_CPU(unsigned int, cpu_set_freq); /* CPU freq desired by | ||
36 | userspace */ | ||
37 | static DEFINE_PER_CPU(unsigned int, cpu_is_managed); | 21 | static DEFINE_PER_CPU(unsigned int, cpu_is_managed); |
38 | |||
39 | static DEFINE_MUTEX(userspace_mutex); | 22 | static DEFINE_MUTEX(userspace_mutex); |
40 | static int cpus_using_userspace_governor; | ||
41 | |||
42 | /* keep track of frequency transitions */ | ||
43 | static int | ||
44 | userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val, | ||
45 | void *data) | ||
46 | { | ||
47 | struct cpufreq_freqs *freq = data; | ||
48 | |||
49 | if (!per_cpu(cpu_is_managed, freq->cpu)) | ||
50 | return 0; | ||
51 | |||
52 | if (val == CPUFREQ_POSTCHANGE) { | ||
53 | pr_debug("saving cpu_cur_freq of cpu %u to be %u kHz\n", | ||
54 | freq->cpu, freq->new); | ||
55 | per_cpu(cpu_cur_freq, freq->cpu) = freq->new; | ||
56 | } | ||
57 | |||
58 | return 0; | ||
59 | } | ||
60 | |||
61 | static struct notifier_block userspace_cpufreq_notifier_block = { | ||
62 | .notifier_call = userspace_cpufreq_notifier | ||
63 | }; | ||
64 | |||
65 | 23 | ||
66 | /** | 24 | /** |
67 | * cpufreq_set - set the CPU frequency | 25 | * cpufreq_set - set the CPU frequency |
@@ -80,13 +38,6 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) | |||
80 | if (!per_cpu(cpu_is_managed, policy->cpu)) | 38 | if (!per_cpu(cpu_is_managed, policy->cpu)) |
81 | goto err; | 39 | goto err; |
82 | 40 | ||
83 | per_cpu(cpu_set_freq, policy->cpu) = freq; | ||
84 | |||
85 | if (freq < per_cpu(cpu_min_freq, policy->cpu)) | ||
86 | freq = per_cpu(cpu_min_freq, policy->cpu); | ||
87 | if (freq > per_cpu(cpu_max_freq, policy->cpu)) | ||
88 | freq = per_cpu(cpu_max_freq, policy->cpu); | ||
89 | |||
90 | /* | 41 | /* |
91 | * We're safe from concurrent calls to ->target() here | 42 | * We're safe from concurrent calls to ->target() here |
92 | * as we hold the userspace_mutex lock. If we were calling | 43 | * as we hold the userspace_mutex lock. If we were calling |
@@ -104,10 +55,9 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) | |||
104 | return ret; | 55 | return ret; |
105 | } | 56 | } |
106 | 57 | ||
107 | |||
108 | static ssize_t show_speed(struct cpufreq_policy *policy, char *buf) | 58 | static ssize_t show_speed(struct cpufreq_policy *policy, char *buf) |
109 | { | 59 | { |
110 | return sprintf(buf, "%u\n", per_cpu(cpu_cur_freq, policy->cpu)); | 60 | return sprintf(buf, "%u\n", policy->cur); |
111 | } | 61 | } |
112 | 62 | ||
113 | static int cpufreq_governor_userspace(struct cpufreq_policy *policy, | 63 | static int cpufreq_governor_userspace(struct cpufreq_policy *policy, |
@@ -119,73 +69,37 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, | |||
119 | switch (event) { | 69 | switch (event) { |
120 | case CPUFREQ_GOV_START: | 70 | case CPUFREQ_GOV_START: |
121 | BUG_ON(!policy->cur); | 71 | BUG_ON(!policy->cur); |
122 | mutex_lock(&userspace_mutex); | 72 | pr_debug("started managing cpu %u\n", cpu); |
123 | |||
124 | if (cpus_using_userspace_governor == 0) { | ||
125 | cpufreq_register_notifier( | ||
126 | &userspace_cpufreq_notifier_block, | ||
127 | CPUFREQ_TRANSITION_NOTIFIER); | ||
128 | } | ||
129 | cpus_using_userspace_governor++; | ||
130 | 73 | ||
74 | mutex_lock(&userspace_mutex); | ||
131 | per_cpu(cpu_is_managed, cpu) = 1; | 75 | per_cpu(cpu_is_managed, cpu) = 1; |
132 | per_cpu(cpu_min_freq, cpu) = policy->min; | ||
133 | per_cpu(cpu_max_freq, cpu) = policy->max; | ||
134 | per_cpu(cpu_cur_freq, cpu) = policy->cur; | ||
135 | per_cpu(cpu_set_freq, cpu) = policy->cur; | ||
136 | pr_debug("managing cpu %u started " | ||
137 | "(%u - %u kHz, currently %u kHz)\n", | ||
138 | cpu, | ||
139 | per_cpu(cpu_min_freq, cpu), | ||
140 | per_cpu(cpu_max_freq, cpu), | ||
141 | per_cpu(cpu_cur_freq, cpu)); | ||
142 | |||
143 | mutex_unlock(&userspace_mutex); | 76 | mutex_unlock(&userspace_mutex); |
144 | break; | 77 | break; |
145 | case CPUFREQ_GOV_STOP: | 78 | case CPUFREQ_GOV_STOP: |
146 | mutex_lock(&userspace_mutex); | 79 | pr_debug("managing cpu %u stopped\n", cpu); |
147 | cpus_using_userspace_governor--; | ||
148 | if (cpus_using_userspace_governor == 0) { | ||
149 | cpufreq_unregister_notifier( | ||
150 | &userspace_cpufreq_notifier_block, | ||
151 | CPUFREQ_TRANSITION_NOTIFIER); | ||
152 | } | ||
153 | 80 | ||
81 | mutex_lock(&userspace_mutex); | ||
154 | per_cpu(cpu_is_managed, cpu) = 0; | 82 | per_cpu(cpu_is_managed, cpu) = 0; |
155 | per_cpu(cpu_min_freq, cpu) = 0; | ||
156 | per_cpu(cpu_max_freq, cpu) = 0; | ||
157 | per_cpu(cpu_set_freq, cpu) = 0; | ||
158 | pr_debug("managing cpu %u stopped\n", cpu); | ||
159 | mutex_unlock(&userspace_mutex); | 83 | mutex_unlock(&userspace_mutex); |
160 | break; | 84 | break; |
161 | case CPUFREQ_GOV_LIMITS: | 85 | case CPUFREQ_GOV_LIMITS: |
162 | mutex_lock(&userspace_mutex); | 86 | mutex_lock(&userspace_mutex); |
163 | pr_debug("limit event for cpu %u: %u - %u kHz, " | 87 | pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz\n", |
164 | "currently %u kHz, last set to %u kHz\n", | ||
165 | cpu, policy->min, policy->max, | 88 | cpu, policy->min, policy->max, |
166 | per_cpu(cpu_cur_freq, cpu), | 89 | policy->cur); |
167 | per_cpu(cpu_set_freq, cpu)); | 90 | |
168 | if (policy->max < per_cpu(cpu_set_freq, cpu)) { | 91 | if (policy->max < policy->cur) |
169 | __cpufreq_driver_target(policy, policy->max, | 92 | __cpufreq_driver_target(policy, policy->max, |
170 | CPUFREQ_RELATION_H); | 93 | CPUFREQ_RELATION_H); |
171 | } else if (policy->min > per_cpu(cpu_set_freq, cpu)) { | 94 | else if (policy->min > policy->cur) |
172 | __cpufreq_driver_target(policy, policy->min, | 95 | __cpufreq_driver_target(policy, policy->min, |
173 | CPUFREQ_RELATION_L); | 96 | CPUFREQ_RELATION_L); |
174 | } else { | ||
175 | __cpufreq_driver_target(policy, | ||
176 | per_cpu(cpu_set_freq, cpu), | ||
177 | CPUFREQ_RELATION_L); | ||
178 | } | ||
179 | per_cpu(cpu_min_freq, cpu) = policy->min; | ||
180 | per_cpu(cpu_max_freq, cpu) = policy->max; | ||
181 | per_cpu(cpu_cur_freq, cpu) = policy->cur; | ||
182 | mutex_unlock(&userspace_mutex); | 97 | mutex_unlock(&userspace_mutex); |
183 | break; | 98 | break; |
184 | } | 99 | } |
185 | return rc; | 100 | return rc; |
186 | } | 101 | } |
187 | 102 | ||
188 | |||
189 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE | 103 | #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE |
190 | static | 104 | static |
191 | #endif | 105 | #endif |
@@ -202,13 +116,11 @@ static int __init cpufreq_gov_userspace_init(void) | |||
202 | return cpufreq_register_governor(&cpufreq_gov_userspace); | 116 | return cpufreq_register_governor(&cpufreq_gov_userspace); |
203 | } | 117 | } |
204 | 118 | ||
205 | |||
206 | static void __exit cpufreq_gov_userspace_exit(void) | 119 | static void __exit cpufreq_gov_userspace_exit(void) |
207 | { | 120 | { |
208 | cpufreq_unregister_governor(&cpufreq_gov_userspace); | 121 | cpufreq_unregister_governor(&cpufreq_gov_userspace); |
209 | } | 122 | } |
210 | 123 | ||
211 | |||
212 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, " | 124 | MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, " |
213 | "Russell King <rmk@arm.linux.org.uk>"); | 125 | "Russell King <rmk@arm.linux.org.uk>"); |
214 | MODULE_DESCRIPTION("CPUfreq policy governor 'userspace'"); | 126 | MODULE_DESCRIPTION("CPUfreq policy governor 'userspace'"); |
diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index 37380fb92621..a60efaeb4cf8 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c | |||
@@ -161,6 +161,9 @@ postchange: | |||
161 | current_multiplier); | 161 | current_multiplier); |
162 | } | 162 | } |
163 | #endif | 163 | #endif |
164 | if (err) | ||
165 | freqs.new = freqs.old; | ||
166 | |||
164 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 167 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
165 | return err; | 168 | return err; |
166 | } | 169 | } |
@@ -188,7 +191,7 @@ static int eps_target(struct cpufreq_policy *policy, | |||
188 | } | 191 | } |
189 | 192 | ||
190 | /* Make frequency transition */ | 193 | /* Make frequency transition */ |
191 | dest_state = centaur->freq_table[newstate].index & 0xffff; | 194 | dest_state = centaur->freq_table[newstate].driver_data & 0xffff; |
192 | ret = eps_set_state(centaur, policy, dest_state); | 195 | ret = eps_set_state(centaur, policy, dest_state); |
193 | if (ret) | 196 | if (ret) |
194 | printk(KERN_ERR "eps: Timeout!\n"); | 197 | printk(KERN_ERR "eps: Timeout!\n"); |
@@ -380,9 +383,9 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
380 | f_table = ¢aur->freq_table[0]; | 383 | f_table = ¢aur->freq_table[0]; |
381 | if (brand != EPS_BRAND_C7M) { | 384 | if (brand != EPS_BRAND_C7M) { |
382 | f_table[0].frequency = fsb * min_multiplier; | 385 | f_table[0].frequency = fsb * min_multiplier; |
383 | f_table[0].index = (min_multiplier << 8) | min_voltage; | 386 | f_table[0].driver_data = (min_multiplier << 8) | min_voltage; |
384 | f_table[1].frequency = fsb * max_multiplier; | 387 | f_table[1].frequency = fsb * max_multiplier; |
385 | f_table[1].index = (max_multiplier << 8) | max_voltage; | 388 | f_table[1].driver_data = (max_multiplier << 8) | max_voltage; |
386 | f_table[2].frequency = CPUFREQ_TABLE_END; | 389 | f_table[2].frequency = CPUFREQ_TABLE_END; |
387 | } else { | 390 | } else { |
388 | k = 0; | 391 | k = 0; |
@@ -391,7 +394,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy) | |||
391 | for (i = min_multiplier; i <= max_multiplier; i++) { | 394 | for (i = min_multiplier; i <= max_multiplier; i++) { |
392 | voltage = (k * step) / 256 + min_voltage; | 395 | voltage = (k * step) / 256 + min_voltage; |
393 | f_table[k].frequency = fsb * i; | 396 | f_table[k].frequency = fsb * i; |
394 | f_table[k].index = (i << 8) | voltage; | 397 | f_table[k].driver_data = (i << 8) | voltage; |
395 | k++; | 398 | k++; |
396 | } | 399 | } |
397 | f_table[k].frequency = CPUFREQ_TABLE_END; | 400 | f_table[k].frequency = CPUFREQ_TABLE_END; |
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index d7a79662e24c..f0d87412cc91 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -34,8 +34,8 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, | |||
34 | 34 | ||
35 | continue; | 35 | continue; |
36 | } | 36 | } |
37 | pr_debug("table entry %u: %u kHz, %u index\n", | 37 | pr_debug("table entry %u: %u kHz, %u driver_data\n", |
38 | i, freq, table[i].index); | 38 | i, freq, table[i].driver_data); |
39 | if (freq < min_freq) | 39 | if (freq < min_freq) |
40 | min_freq = freq; | 40 | min_freq = freq; |
41 | if (freq > max_freq) | 41 | if (freq > max_freq) |
@@ -97,11 +97,11 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
97 | unsigned int *index) | 97 | unsigned int *index) |
98 | { | 98 | { |
99 | struct cpufreq_frequency_table optimal = { | 99 | struct cpufreq_frequency_table optimal = { |
100 | .index = ~0, | 100 | .driver_data = ~0, |
101 | .frequency = 0, | 101 | .frequency = 0, |
102 | }; | 102 | }; |
103 | struct cpufreq_frequency_table suboptimal = { | 103 | struct cpufreq_frequency_table suboptimal = { |
104 | .index = ~0, | 104 | .driver_data = ~0, |
105 | .frequency = 0, | 105 | .frequency = 0, |
106 | }; | 106 | }; |
107 | unsigned int i; | 107 | unsigned int i; |
@@ -129,12 +129,12 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
129 | if (freq <= target_freq) { | 129 | if (freq <= target_freq) { |
130 | if (freq >= optimal.frequency) { | 130 | if (freq >= optimal.frequency) { |
131 | optimal.frequency = freq; | 131 | optimal.frequency = freq; |
132 | optimal.index = i; | 132 | optimal.driver_data = i; |
133 | } | 133 | } |
134 | } else { | 134 | } else { |
135 | if (freq <= suboptimal.frequency) { | 135 | if (freq <= suboptimal.frequency) { |
136 | suboptimal.frequency = freq; | 136 | suboptimal.frequency = freq; |
137 | suboptimal.index = i; | 137 | suboptimal.driver_data = i; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | break; | 140 | break; |
@@ -142,26 +142,26 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
142 | if (freq >= target_freq) { | 142 | if (freq >= target_freq) { |
143 | if (freq <= optimal.frequency) { | 143 | if (freq <= optimal.frequency) { |
144 | optimal.frequency = freq; | 144 | optimal.frequency = freq; |
145 | optimal.index = i; | 145 | optimal.driver_data = i; |
146 | } | 146 | } |
147 | } else { | 147 | } else { |
148 | if (freq >= suboptimal.frequency) { | 148 | if (freq >= suboptimal.frequency) { |
149 | suboptimal.frequency = freq; | 149 | suboptimal.frequency = freq; |
150 | suboptimal.index = i; | 150 | suboptimal.driver_data = i; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | break; | 153 | break; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | if (optimal.index > i) { | 156 | if (optimal.driver_data > i) { |
157 | if (suboptimal.index > i) | 157 | if (suboptimal.driver_data > i) |
158 | return -EINVAL; | 158 | return -EINVAL; |
159 | *index = suboptimal.index; | 159 | *index = suboptimal.driver_data; |
160 | } else | 160 | } else |
161 | *index = optimal.index; | 161 | *index = optimal.driver_data; |
162 | 162 | ||
163 | pr_debug("target is %u (%u kHz, %u)\n", *index, table[*index].frequency, | 163 | pr_debug("target is %u (%u kHz, %u)\n", *index, table[*index].frequency, |
164 | table[*index].index); | 164 | table[*index].driver_data); |
165 | 165 | ||
166 | return 0; | 166 | return 0; |
167 | } | 167 | } |
diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c index c0075dbaa633..573c14ea802d 100644 --- a/drivers/cpufreq/ia64-acpi-cpufreq.c +++ b/drivers/cpufreq/ia64-acpi-cpufreq.c | |||
@@ -326,7 +326,7 @@ acpi_cpufreq_cpu_init ( | |||
326 | /* table init */ | 326 | /* table init */ |
327 | for (i = 0; i <= data->acpi_data.state_count; i++) | 327 | for (i = 0; i <= data->acpi_data.state_count; i++) |
328 | { | 328 | { |
329 | data->freq_table[i].index = i; | 329 | data->freq_table[i].driver_data = i; |
330 | if (i < data->acpi_data.state_count) { | 330 | if (i < data->acpi_data.state_count) { |
331 | data->freq_table[i].frequency = | 331 | data->freq_table[i].frequency = |
332 | data->acpi_data.states[i].core_frequency * 1000; | 332 | data->acpi_data.states[i].core_frequency * 1000; |
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c index b2644af985ec..c233ea617366 100644 --- a/drivers/cpufreq/kirkwood-cpufreq.c +++ b/drivers/cpufreq/kirkwood-cpufreq.c | |||
@@ -59,7 +59,7 @@ static void kirkwood_cpufreq_set_cpu_state(struct cpufreq_policy *policy, | |||
59 | unsigned int index) | 59 | unsigned int index) |
60 | { | 60 | { |
61 | struct cpufreq_freqs freqs; | 61 | struct cpufreq_freqs freqs; |
62 | unsigned int state = kirkwood_freq_table[index].index; | 62 | unsigned int state = kirkwood_freq_table[index].driver_data; |
63 | unsigned long reg; | 63 | unsigned long reg; |
64 | 64 | ||
65 | freqs.old = kirkwood_cpufreq_get_cpu_frequency(0); | 65 | freqs.old = kirkwood_cpufreq_get_cpu_frequency(0); |
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index b448638e34de..b6a0a7a406b0 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
@@ -254,7 +254,7 @@ static void longhaul_setstate(struct cpufreq_policy *policy, | |||
254 | u32 bm_timeout = 1000; | 254 | u32 bm_timeout = 1000; |
255 | unsigned int dir = 0; | 255 | unsigned int dir = 0; |
256 | 256 | ||
257 | mults_index = longhaul_table[table_index].index; | 257 | mults_index = longhaul_table[table_index].driver_data; |
258 | /* Safety precautions */ | 258 | /* Safety precautions */ |
259 | mult = mults[mults_index & 0x1f]; | 259 | mult = mults[mults_index & 0x1f]; |
260 | if (mult == -1) | 260 | if (mult == -1) |
@@ -487,7 +487,7 @@ static int __cpuinit longhaul_get_ranges(void) | |||
487 | if (ratio > maxmult || ratio < minmult) | 487 | if (ratio > maxmult || ratio < minmult) |
488 | continue; | 488 | continue; |
489 | longhaul_table[k].frequency = calc_speed(ratio); | 489 | longhaul_table[k].frequency = calc_speed(ratio); |
490 | longhaul_table[k].index = j; | 490 | longhaul_table[k].driver_data = j; |
491 | k++; | 491 | k++; |
492 | } | 492 | } |
493 | if (k <= 1) { | 493 | if (k <= 1) { |
@@ -508,8 +508,8 @@ static int __cpuinit longhaul_get_ranges(void) | |||
508 | if (min_i != j) { | 508 | if (min_i != j) { |
509 | swap(longhaul_table[j].frequency, | 509 | swap(longhaul_table[j].frequency, |
510 | longhaul_table[min_i].frequency); | 510 | longhaul_table[min_i].frequency); |
511 | swap(longhaul_table[j].index, | 511 | swap(longhaul_table[j].driver_data, |
512 | longhaul_table[min_i].index); | 512 | longhaul_table[min_i].driver_data); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
@@ -517,7 +517,7 @@ static int __cpuinit longhaul_get_ranges(void) | |||
517 | 517 | ||
518 | /* Find index we are running on */ | 518 | /* Find index we are running on */ |
519 | for (j = 0; j < k; j++) { | 519 | for (j = 0; j < k; j++) { |
520 | if (mults[longhaul_table[j].index & 0x1f] == mult) { | 520 | if (mults[longhaul_table[j].driver_data & 0x1f] == mult) { |
521 | longhaul_index = j; | 521 | longhaul_index = j; |
522 | break; | 522 | break; |
523 | } | 523 | } |
@@ -613,7 +613,7 @@ static void __cpuinit longhaul_setup_voltagescaling(void) | |||
613 | pos = (speed - min_vid_speed) / kHz_step + minvid.pos; | 613 | pos = (speed - min_vid_speed) / kHz_step + minvid.pos; |
614 | else | 614 | else |
615 | pos = minvid.pos; | 615 | pos = minvid.pos; |
616 | longhaul_table[j].index |= mV_vrm_table[pos] << 8; | 616 | longhaul_table[j].driver_data |= mV_vrm_table[pos] << 8; |
617 | vid = vrm_mV_table[mV_vrm_table[pos]]; | 617 | vid = vrm_mV_table[mV_vrm_table[pos]]; |
618 | printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n", | 618 | printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n", |
619 | speed, j, vid.mV); | 619 | speed, j, vid.mV); |
@@ -656,12 +656,12 @@ static int longhaul_target(struct cpufreq_policy *policy, | |||
656 | * this in hardware, C3 is old and we need to do this | 656 | * this in hardware, C3 is old and we need to do this |
657 | * in software. */ | 657 | * in software. */ |
658 | i = longhaul_index; | 658 | i = longhaul_index; |
659 | current_vid = (longhaul_table[longhaul_index].index >> 8); | 659 | current_vid = (longhaul_table[longhaul_index].driver_data >> 8); |
660 | current_vid &= 0x1f; | 660 | current_vid &= 0x1f; |
661 | if (table_index > longhaul_index) | 661 | if (table_index > longhaul_index) |
662 | dir = 1; | 662 | dir = 1; |
663 | while (i != table_index) { | 663 | while (i != table_index) { |
664 | vid = (longhaul_table[i].index >> 8) & 0x1f; | 664 | vid = (longhaul_table[i].driver_data >> 8) & 0x1f; |
665 | if (vid != current_vid) { | 665 | if (vid != current_vid) { |
666 | longhaul_setstate(policy, i); | 666 | longhaul_setstate(policy, i); |
667 | current_vid = vid; | 667 | current_vid = vid; |
diff --git a/drivers/cpufreq/loongson2_cpufreq.c b/drivers/cpufreq/loongson2_cpufreq.c index d53912768946..bb838b985077 100644 --- a/drivers/cpufreq/loongson2_cpufreq.c +++ b/drivers/cpufreq/loongson2_cpufreq.c | |||
@@ -72,7 +72,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy, | |||
72 | 72 | ||
73 | freq = | 73 | freq = |
74 | ((cpu_clock_freq / 1000) * | 74 | ((cpu_clock_freq / 1000) * |
75 | loongson2_clockmod_table[newstate].index) / 8; | 75 | loongson2_clockmod_table[newstate].driver_data) / 8; |
76 | if (freq < policy->min || freq > policy->max) | 76 | if (freq < policy->min || freq > policy->max) |
77 | return -EINVAL; | 77 | return -EINVAL; |
78 | 78 | ||
diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c index 421ef37d0bb3..9ee78170ff86 100644 --- a/drivers/cpufreq/p4-clockmod.c +++ b/drivers/cpufreq/p4-clockmod.c | |||
@@ -118,7 +118,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, | |||
118 | return -EINVAL; | 118 | return -EINVAL; |
119 | 119 | ||
120 | freqs.old = cpufreq_p4_get(policy->cpu); | 120 | freqs.old = cpufreq_p4_get(policy->cpu); |
121 | freqs.new = stock_freq * p4clockmod_table[newstate].index / 8; | 121 | freqs.new = stock_freq * p4clockmod_table[newstate].driver_data / 8; |
122 | 122 | ||
123 | if (freqs.new == freqs.old) | 123 | if (freqs.new == freqs.old) |
124 | return 0; | 124 | return 0; |
@@ -131,7 +131,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, | |||
131 | * Developer's Manual, Volume 3 | 131 | * Developer's Manual, Volume 3 |
132 | */ | 132 | */ |
133 | for_each_cpu(i, policy->cpus) | 133 | for_each_cpu(i, policy->cpus) |
134 | cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); | 134 | cpufreq_p4_setdc(i, p4clockmod_table[newstate].driver_data); |
135 | 135 | ||
136 | /* notifiers */ | 136 | /* notifiers */ |
137 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 137 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
diff --git a/arch/powerpc/platforms/pasemi/cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c index be1e7958909e..b704da404067 100644 --- a/arch/powerpc/platforms/pasemi/cpufreq.c +++ b/drivers/cpufreq/pasemi-cpufreq.c | |||
@@ -204,7 +204,8 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
204 | 204 | ||
205 | /* initialize frequency table */ | 205 | /* initialize frequency table */ |
206 | for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { | 206 | for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { |
207 | pas_freqs[i].frequency = get_astate_freq(pas_freqs[i].index) * 100000; | 207 | pas_freqs[i].frequency = |
208 | get_astate_freq(pas_freqs[i].driver_data) * 100000; | ||
208 | pr_debug("%d: %d\n", i, pas_freqs[i].frequency); | 209 | pr_debug("%d: %d\n", i, pas_freqs[i].frequency); |
209 | } | 210 | } |
210 | 211 | ||
@@ -280,7 +281,7 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy, | |||
280 | pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", | 281 | pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", |
281 | policy->cpu, | 282 | policy->cpu, |
282 | pas_freqs[pas_astate_new].frequency, | 283 | pas_freqs[pas_astate_new].frequency, |
283 | pas_freqs[pas_astate_new].index); | 284 | pas_freqs[pas_astate_new].driver_data); |
284 | 285 | ||
285 | current_astate = pas_astate_new; | 286 | current_astate = pas_astate_new; |
286 | 287 | ||
diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c index 0de00081a81e..1581fcc4cf4a 100644 --- a/drivers/cpufreq/pcc-cpufreq.c +++ b/drivers/cpufreq/pcc-cpufreq.c | |||
@@ -243,6 +243,8 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy, | |||
243 | return 0; | 243 | return 0; |
244 | 244 | ||
245 | cmd_incomplete: | 245 | cmd_incomplete: |
246 | freqs.new = freqs.old; | ||
247 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
246 | iowrite16(0, &pcch_hdr->status); | 248 | iowrite16(0, &pcch_hdr->status); |
247 | spin_unlock(&pcc_lock); | 249 | spin_unlock(&pcc_lock); |
248 | return -EINVAL; | 250 | return -EINVAL; |
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/drivers/cpufreq/pmac32-cpufreq.c index 3104fad82480..3104fad82480 100644 --- a/arch/powerpc/platforms/powermac/cpufreq_32.c +++ b/drivers/cpufreq/pmac32-cpufreq.c | |||
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/drivers/cpufreq/pmac64-cpufreq.c index 7ba423431cfe..7ba423431cfe 100644 --- a/arch/powerpc/platforms/powermac/cpufreq_64.c +++ b/drivers/cpufreq/pmac64-cpufreq.c | |||
diff --git a/drivers/cpufreq/powernow-k6.c b/drivers/cpufreq/powernow-k6.c index ea0222a45b7b..ea8e10382ec5 100644 --- a/drivers/cpufreq/powernow-k6.c +++ b/drivers/cpufreq/powernow-k6.c | |||
@@ -58,7 +58,7 @@ static int powernow_k6_get_cpu_multiplier(void) | |||
58 | msrval = POWERNOW_IOPORT + 0x0; | 58 | msrval = POWERNOW_IOPORT + 0x0; |
59 | wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ | 59 | wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ |
60 | 60 | ||
61 | return clock_ratio[(invalue >> 5)&7].index; | 61 | return clock_ratio[(invalue >> 5)&7].driver_data; |
62 | } | 62 | } |
63 | 63 | ||
64 | 64 | ||
@@ -75,13 +75,13 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy, | |||
75 | unsigned long msrval; | 75 | unsigned long msrval; |
76 | struct cpufreq_freqs freqs; | 76 | struct cpufreq_freqs freqs; |
77 | 77 | ||
78 | if (clock_ratio[best_i].index > max_multiplier) { | 78 | if (clock_ratio[best_i].driver_data > max_multiplier) { |
79 | printk(KERN_ERR PFX "invalid target frequency\n"); | 79 | printk(KERN_ERR PFX "invalid target frequency\n"); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); | 83 | freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); |
84 | freqs.new = busfreq * clock_ratio[best_i].index; | 84 | freqs.new = busfreq * clock_ratio[best_i].driver_data; |
85 | 85 | ||
86 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | 86 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); |
87 | 87 | ||
@@ -156,7 +156,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) | |||
156 | 156 | ||
157 | /* table init */ | 157 | /* table init */ |
158 | for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { | 158 | for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { |
159 | f = clock_ratio[i].index; | 159 | f = clock_ratio[i].driver_data; |
160 | if (f > max_multiplier) | 160 | if (f > max_multiplier) |
161 | clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; | 161 | clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; |
162 | else | 162 | else |
diff --git a/drivers/cpufreq/powernow-k7.c b/drivers/cpufreq/powernow-k7.c index 53888dacbe58..b9f80b713fda 100644 --- a/drivers/cpufreq/powernow-k7.c +++ b/drivers/cpufreq/powernow-k7.c | |||
@@ -186,7 +186,7 @@ static int get_ranges(unsigned char *pst) | |||
186 | fid = *pst++; | 186 | fid = *pst++; |
187 | 187 | ||
188 | powernow_table[j].frequency = (fsb * fid_codes[fid]) / 10; | 188 | powernow_table[j].frequency = (fsb * fid_codes[fid]) / 10; |
189 | powernow_table[j].index = fid; /* lower 8 bits */ | 189 | powernow_table[j].driver_data = fid; /* lower 8 bits */ |
190 | 190 | ||
191 | speed = powernow_table[j].frequency; | 191 | speed = powernow_table[j].frequency; |
192 | 192 | ||
@@ -203,7 +203,7 @@ static int get_ranges(unsigned char *pst) | |||
203 | maximum_speed = speed; | 203 | maximum_speed = speed; |
204 | 204 | ||
205 | vid = *pst++; | 205 | vid = *pst++; |
206 | powernow_table[j].index |= (vid << 8); /* upper 8 bits */ | 206 | powernow_table[j].driver_data |= (vid << 8); /* upper 8 bits */ |
207 | 207 | ||
208 | pr_debug(" FID: 0x%x (%d.%dx [%dMHz]) " | 208 | pr_debug(" FID: 0x%x (%d.%dx [%dMHz]) " |
209 | "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, | 209 | "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, |
@@ -212,7 +212,7 @@ static int get_ranges(unsigned char *pst) | |||
212 | mobile_vid_table[vid]%1000); | 212 | mobile_vid_table[vid]%1000); |
213 | } | 213 | } |
214 | powernow_table[number_scales].frequency = CPUFREQ_TABLE_END; | 214 | powernow_table[number_scales].frequency = CPUFREQ_TABLE_END; |
215 | powernow_table[number_scales].index = 0; | 215 | powernow_table[number_scales].driver_data = 0; |
216 | 216 | ||
217 | return 0; | 217 | return 0; |
218 | } | 218 | } |
@@ -260,8 +260,8 @@ static void change_speed(struct cpufreq_policy *policy, unsigned int index) | |||
260 | * vid are the upper 8 bits. | 260 | * vid are the upper 8 bits. |
261 | */ | 261 | */ |
262 | 262 | ||
263 | fid = powernow_table[index].index & 0xFF; | 263 | fid = powernow_table[index].driver_data & 0xFF; |
264 | vid = (powernow_table[index].index & 0xFF00) >> 8; | 264 | vid = (powernow_table[index].driver_data & 0xFF00) >> 8; |
265 | 265 | ||
266 | rdmsrl(MSR_K7_FID_VID_STATUS, fidvidstatus.val); | 266 | rdmsrl(MSR_K7_FID_VID_STATUS, fidvidstatus.val); |
267 | cfid = fidvidstatus.bits.CFID; | 267 | cfid = fidvidstatus.bits.CFID; |
@@ -373,8 +373,8 @@ static int powernow_acpi_init(void) | |||
373 | fid = pc.bits.fid; | 373 | fid = pc.bits.fid; |
374 | 374 | ||
375 | powernow_table[i].frequency = fsb * fid_codes[fid] / 10; | 375 | powernow_table[i].frequency = fsb * fid_codes[fid] / 10; |
376 | powernow_table[i].index = fid; /* lower 8 bits */ | 376 | powernow_table[i].driver_data = fid; /* lower 8 bits */ |
377 | powernow_table[i].index |= (vid << 8); /* upper 8 bits */ | 377 | powernow_table[i].driver_data |= (vid << 8); /* upper 8 bits */ |
378 | 378 | ||
379 | speed = powernow_table[i].frequency; | 379 | speed = powernow_table[i].frequency; |
380 | speed_mhz = speed / 1000; | 380 | speed_mhz = speed / 1000; |
@@ -417,7 +417,7 @@ static int powernow_acpi_init(void) | |||
417 | } | 417 | } |
418 | 418 | ||
419 | powernow_table[i].frequency = CPUFREQ_TABLE_END; | 419 | powernow_table[i].frequency = CPUFREQ_TABLE_END; |
420 | powernow_table[i].index = 0; | 420 | powernow_table[i].driver_data = 0; |
421 | 421 | ||
422 | /* notify BIOS that we exist */ | 422 | /* notify BIOS that we exist */ |
423 | acpi_processor_notify_smm(THIS_MODULE); | 423 | acpi_processor_notify_smm(THIS_MODULE); |
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c index b828efe4b2f8..78f018f2a5de 100644 --- a/drivers/cpufreq/powernow-k8.c +++ b/drivers/cpufreq/powernow-k8.c | |||
@@ -584,9 +584,9 @@ static void print_basics(struct powernow_k8_data *data) | |||
584 | CPUFREQ_ENTRY_INVALID) { | 584 | CPUFREQ_ENTRY_INVALID) { |
585 | printk(KERN_INFO PFX | 585 | printk(KERN_INFO PFX |
586 | "fid 0x%x (%d MHz), vid 0x%x\n", | 586 | "fid 0x%x (%d MHz), vid 0x%x\n", |
587 | data->powernow_table[j].index & 0xff, | 587 | data->powernow_table[j].driver_data & 0xff, |
588 | data->powernow_table[j].frequency/1000, | 588 | data->powernow_table[j].frequency/1000, |
589 | data->powernow_table[j].index >> 8); | 589 | data->powernow_table[j].driver_data >> 8); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | if (data->batps) | 592 | if (data->batps) |
@@ -632,13 +632,13 @@ static int fill_powernow_table(struct powernow_k8_data *data, | |||
632 | 632 | ||
633 | for (j = 0; j < data->numps; j++) { | 633 | for (j = 0; j < data->numps; j++) { |
634 | int freq; | 634 | int freq; |
635 | powernow_table[j].index = pst[j].fid; /* lower 8 bits */ | 635 | powernow_table[j].driver_data = pst[j].fid; /* lower 8 bits */ |
636 | powernow_table[j].index |= (pst[j].vid << 8); /* upper 8 bits */ | 636 | powernow_table[j].driver_data |= (pst[j].vid << 8); /* upper 8 bits */ |
637 | freq = find_khz_freq_from_fid(pst[j].fid); | 637 | freq = find_khz_freq_from_fid(pst[j].fid); |
638 | powernow_table[j].frequency = freq; | 638 | powernow_table[j].frequency = freq; |
639 | } | 639 | } |
640 | powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; | 640 | powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; |
641 | powernow_table[data->numps].index = 0; | 641 | powernow_table[data->numps].driver_data = 0; |
642 | 642 | ||
643 | if (query_current_values_with_pending_wait(data)) { | 643 | if (query_current_values_with_pending_wait(data)) { |
644 | kfree(powernow_table); | 644 | kfree(powernow_table); |
@@ -810,7 +810,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) | |||
810 | 810 | ||
811 | powernow_table[data->acpi_data.state_count].frequency = | 811 | powernow_table[data->acpi_data.state_count].frequency = |
812 | CPUFREQ_TABLE_END; | 812 | CPUFREQ_TABLE_END; |
813 | powernow_table[data->acpi_data.state_count].index = 0; | 813 | powernow_table[data->acpi_data.state_count].driver_data = 0; |
814 | data->powernow_table = powernow_table; | 814 | data->powernow_table = powernow_table; |
815 | 815 | ||
816 | if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu) | 816 | if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu) |
@@ -865,7 +865,7 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data, | |||
865 | pr_debug(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); | 865 | pr_debug(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); |
866 | 866 | ||
867 | index = fid | (vid<<8); | 867 | index = fid | (vid<<8); |
868 | powernow_table[i].index = index; | 868 | powernow_table[i].driver_data = index; |
869 | 869 | ||
870 | freq = find_khz_freq_from_fid(fid); | 870 | freq = find_khz_freq_from_fid(fid); |
871 | powernow_table[i].frequency = freq; | 871 | powernow_table[i].frequency = freq; |
@@ -941,8 +941,8 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, | |||
941 | * the cpufreq frequency table in find_psb_table, vid | 941 | * the cpufreq frequency table in find_psb_table, vid |
942 | * are the upper 8 bits. | 942 | * are the upper 8 bits. |
943 | */ | 943 | */ |
944 | fid = data->powernow_table[index].index & 0xFF; | 944 | fid = data->powernow_table[index].driver_data & 0xFF; |
945 | vid = (data->powernow_table[index].index & 0xFF00) >> 8; | 945 | vid = (data->powernow_table[index].driver_data & 0xFF00) >> 8; |
946 | 946 | ||
947 | pr_debug("table matched fid 0x%x, giving vid 0x%x\n", fid, vid); | 947 | pr_debug("table matched fid 0x%x, giving vid 0x%x\n", fid, vid); |
948 | 948 | ||
@@ -967,9 +967,9 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, | |||
967 | 967 | ||
968 | res = transition_fid_vid(data, fid, vid); | 968 | res = transition_fid_vid(data, fid, vid); |
969 | if (res) | 969 | if (res) |
970 | return res; | 970 | freqs.new = freqs.old; |
971 | 971 | else | |
972 | freqs.new = find_khz_freq_from_fid(data->currfid); | 972 | freqs.new = find_khz_freq_from_fid(data->currfid); |
973 | 973 | ||
974 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | 974 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); |
975 | return res; | 975 | return res; |
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/ppc-corenet-cpufreq.c new file mode 100644 index 000000000000..3cae4529f959 --- /dev/null +++ b/drivers/cpufreq/ppc-corenet-cpufreq.c | |||
@@ -0,0 +1,380 @@ | |||
1 | /* | ||
2 | * Copyright 2013 Freescale Semiconductor, Inc. | ||
3 | * | ||
4 | * CPU Frequency Scaling driver for Freescale PowerPC corenet SoCs. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
12 | |||
13 | #include <linux/clk.h> | ||
14 | #include <linux/cpufreq.h> | ||
15 | #include <linux/errno.h> | ||
16 | #include <sysdev/fsl_soc.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/mutex.h> | ||
21 | #include <linux/of.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/smp.h> | ||
24 | |||
25 | /** | ||
26 | * struct cpu_data - per CPU data struct | ||
27 | * @clk: the clk of CPU | ||
28 | * @parent: the parent node of cpu clock | ||
29 | * @table: frequency table | ||
30 | */ | ||
31 | struct cpu_data { | ||
32 | struct clk *clk; | ||
33 | struct device_node *parent; | ||
34 | struct cpufreq_frequency_table *table; | ||
35 | }; | ||
36 | |||
37 | /** | ||
38 | * struct soc_data - SoC specific data | ||
39 | * @freq_mask: mask the disallowed frequencies | ||
40 | * @flag: unique flags | ||
41 | */ | ||
42 | struct soc_data { | ||
43 | u32 freq_mask[4]; | ||
44 | u32 flag; | ||
45 | }; | ||
46 | |||
47 | #define FREQ_MASK 1 | ||
48 | /* see hardware specification for the allowed frqeuencies */ | ||
49 | static const struct soc_data sdata[] = { | ||
50 | { /* used by p2041 and p3041 */ | ||
51 | .freq_mask = {0x8, 0x8, 0x2, 0x2}, | ||
52 | .flag = FREQ_MASK, | ||
53 | }, | ||
54 | { /* used by p5020 */ | ||
55 | .freq_mask = {0x8, 0x2}, | ||
56 | .flag = FREQ_MASK, | ||
57 | }, | ||
58 | { /* used by p4080, p5040 */ | ||
59 | .freq_mask = {0}, | ||
60 | .flag = 0, | ||
61 | }, | ||
62 | }; | ||
63 | |||
64 | /* | ||
65 | * the minimum allowed core frequency, in Hz | ||
66 | * for chassis v1.0, >= platform frequency | ||
67 | * for chassis v2.0, >= platform frequency / 2 | ||
68 | */ | ||
69 | static u32 min_cpufreq; | ||
70 | static const u32 *fmask; | ||
71 | |||
72 | /* serialize frequency changes */ | ||
73 | static DEFINE_MUTEX(cpufreq_lock); | ||
74 | static DEFINE_PER_CPU(struct cpu_data *, cpu_data); | ||
75 | |||
76 | /* cpumask in a cluster */ | ||
77 | static DEFINE_PER_CPU(cpumask_var_t, cpu_mask); | ||
78 | |||
79 | #ifndef CONFIG_SMP | ||
80 | static inline const struct cpumask *cpu_core_mask(int cpu) | ||
81 | { | ||
82 | return cpumask_of(0); | ||
83 | } | ||
84 | #endif | ||
85 | |||
86 | static unsigned int corenet_cpufreq_get_speed(unsigned int cpu) | ||
87 | { | ||
88 | struct cpu_data *data = per_cpu(cpu_data, cpu); | ||
89 | |||
90 | return clk_get_rate(data->clk) / 1000; | ||
91 | } | ||
92 | |||
93 | /* reduce the duplicated frequencies in frequency table */ | ||
94 | static void freq_table_redup(struct cpufreq_frequency_table *freq_table, | ||
95 | int count) | ||
96 | { | ||
97 | int i, j; | ||
98 | |||
99 | for (i = 1; i < count; i++) { | ||
100 | for (j = 0; j < i; j++) { | ||
101 | if (freq_table[j].frequency == CPUFREQ_ENTRY_INVALID || | ||
102 | freq_table[j].frequency != | ||
103 | freq_table[i].frequency) | ||
104 | continue; | ||
105 | |||
106 | freq_table[i].frequency = CPUFREQ_ENTRY_INVALID; | ||
107 | break; | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | /* sort the frequencies in frequency table in descenting order */ | ||
113 | static void freq_table_sort(struct cpufreq_frequency_table *freq_table, | ||
114 | int count) | ||
115 | { | ||
116 | int i, j, ind; | ||
117 | unsigned int freq, max_freq; | ||
118 | struct cpufreq_frequency_table table; | ||
119 | for (i = 0; i < count - 1; i++) { | ||
120 | max_freq = freq_table[i].frequency; | ||
121 | ind = i; | ||
122 | for (j = i + 1; j < count; j++) { | ||
123 | freq = freq_table[j].frequency; | ||
124 | if (freq == CPUFREQ_ENTRY_INVALID || | ||
125 | freq <= max_freq) | ||
126 | continue; | ||
127 | ind = j; | ||
128 | max_freq = freq; | ||
129 | } | ||
130 | |||
131 | if (ind != i) { | ||
132 | /* exchange the frequencies */ | ||
133 | table.driver_data = freq_table[i].driver_data; | ||
134 | table.frequency = freq_table[i].frequency; | ||
135 | freq_table[i].driver_data = freq_table[ind].driver_data; | ||
136 | freq_table[i].frequency = freq_table[ind].frequency; | ||
137 | freq_table[ind].driver_data = table.driver_data; | ||
138 | freq_table[ind].frequency = table.frequency; | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | |||
143 | static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) | ||
144 | { | ||
145 | struct device_node *np; | ||
146 | int i, count, ret; | ||
147 | u32 freq, mask; | ||
148 | struct clk *clk; | ||
149 | struct cpufreq_frequency_table *table; | ||
150 | struct cpu_data *data; | ||
151 | unsigned int cpu = policy->cpu; | ||
152 | |||
153 | np = of_get_cpu_node(cpu, NULL); | ||
154 | if (!np) | ||
155 | return -ENODEV; | ||
156 | |||
157 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
158 | if (!data) { | ||
159 | pr_err("%s: no memory\n", __func__); | ||
160 | goto err_np; | ||
161 | } | ||
162 | |||
163 | data->clk = of_clk_get(np, 0); | ||
164 | if (IS_ERR(data->clk)) { | ||
165 | pr_err("%s: no clock information\n", __func__); | ||
166 | goto err_nomem2; | ||
167 | } | ||
168 | |||
169 | data->parent = of_parse_phandle(np, "clocks", 0); | ||
170 | if (!data->parent) { | ||
171 | pr_err("%s: could not get clock information\n", __func__); | ||
172 | goto err_nomem2; | ||
173 | } | ||
174 | |||
175 | count = of_property_count_strings(data->parent, "clock-names"); | ||
176 | table = kcalloc(count + 1, sizeof(*table), GFP_KERNEL); | ||
177 | if (!table) { | ||
178 | pr_err("%s: no memory\n", __func__); | ||
179 | goto err_node; | ||
180 | } | ||
181 | |||
182 | if (fmask) | ||
183 | mask = fmask[get_hard_smp_processor_id(cpu)]; | ||
184 | else | ||
185 | mask = 0x0; | ||
186 | |||
187 | for (i = 0; i < count; i++) { | ||
188 | clk = of_clk_get(data->parent, i); | ||
189 | freq = clk_get_rate(clk); | ||
190 | /* | ||
191 | * the clock is valid if its frequency is not masked | ||
192 | * and large than minimum allowed frequency. | ||
193 | */ | ||
194 | if (freq < min_cpufreq || (mask & (1 << i))) | ||
195 | table[i].frequency = CPUFREQ_ENTRY_INVALID; | ||
196 | else | ||
197 | table[i].frequency = freq / 1000; | ||
198 | table[i].driver_data = i; | ||
199 | } | ||
200 | freq_table_redup(table, count); | ||
201 | freq_table_sort(table, count); | ||
202 | table[i].frequency = CPUFREQ_TABLE_END; | ||
203 | |||
204 | /* set the min and max frequency properly */ | ||
205 | ret = cpufreq_frequency_table_cpuinfo(policy, table); | ||
206 | if (ret) { | ||
207 | pr_err("invalid frequency table: %d\n", ret); | ||
208 | goto err_nomem1; | ||
209 | } | ||
210 | |||
211 | data->table = table; | ||
212 | per_cpu(cpu_data, cpu) = data; | ||
213 | |||
214 | /* update ->cpus if we have cluster, no harm if not */ | ||
215 | cpumask_copy(policy->cpus, per_cpu(cpu_mask, cpu)); | ||
216 | for_each_cpu(i, per_cpu(cpu_mask, cpu)) | ||
217 | per_cpu(cpu_data, i) = data; | ||
218 | |||
219 | policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; | ||
220 | policy->cur = corenet_cpufreq_get_speed(policy->cpu); | ||
221 | |||
222 | cpufreq_frequency_table_get_attr(table, cpu); | ||
223 | of_node_put(np); | ||
224 | |||
225 | return 0; | ||
226 | |||
227 | err_nomem1: | ||
228 | kfree(table); | ||
229 | err_node: | ||
230 | of_node_put(data->parent); | ||
231 | err_nomem2: | ||
232 | per_cpu(cpu_data, cpu) = NULL; | ||
233 | kfree(data); | ||
234 | err_np: | ||
235 | of_node_put(np); | ||
236 | |||
237 | return -ENODEV; | ||
238 | } | ||
239 | |||
240 | static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy) | ||
241 | { | ||
242 | struct cpu_data *data = per_cpu(cpu_data, policy->cpu); | ||
243 | unsigned int cpu; | ||
244 | |||
245 | cpufreq_frequency_table_put_attr(policy->cpu); | ||
246 | of_node_put(data->parent); | ||
247 | kfree(data->table); | ||
248 | kfree(data); | ||
249 | |||
250 | for_each_cpu(cpu, per_cpu(cpu_mask, policy->cpu)) | ||
251 | per_cpu(cpu_data, cpu) = NULL; | ||
252 | |||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | static int corenet_cpufreq_verify(struct cpufreq_policy *policy) | ||
257 | { | ||
258 | struct cpufreq_frequency_table *table = | ||
259 | per_cpu(cpu_data, policy->cpu)->table; | ||
260 | |||
261 | return cpufreq_frequency_table_verify(policy, table); | ||
262 | } | ||
263 | |||
264 | static int corenet_cpufreq_target(struct cpufreq_policy *policy, | ||
265 | unsigned int target_freq, unsigned int relation) | ||
266 | { | ||
267 | struct cpufreq_freqs freqs; | ||
268 | unsigned int new; | ||
269 | struct clk *parent; | ||
270 | int ret; | ||
271 | struct cpu_data *data = per_cpu(cpu_data, policy->cpu); | ||
272 | |||
273 | cpufreq_frequency_table_target(policy, data->table, | ||
274 | target_freq, relation, &new); | ||
275 | |||
276 | if (policy->cur == data->table[new].frequency) | ||
277 | return 0; | ||
278 | |||
279 | freqs.old = policy->cur; | ||
280 | freqs.new = data->table[new].frequency; | ||
281 | |||
282 | mutex_lock(&cpufreq_lock); | ||
283 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); | ||
284 | |||
285 | parent = of_clk_get(data->parent, data->table[new].driver_data); | ||
286 | ret = clk_set_parent(data->clk, parent); | ||
287 | if (ret) | ||
288 | freqs.new = freqs.old; | ||
289 | |||
290 | cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); | ||
291 | mutex_unlock(&cpufreq_lock); | ||
292 | |||
293 | return ret; | ||
294 | } | ||
295 | |||
296 | static struct freq_attr *corenet_cpufreq_attr[] = { | ||
297 | &cpufreq_freq_attr_scaling_available_freqs, | ||
298 | NULL, | ||
299 | }; | ||
300 | |||
301 | static struct cpufreq_driver ppc_corenet_cpufreq_driver = { | ||
302 | .name = "ppc_cpufreq", | ||
303 | .owner = THIS_MODULE, | ||
304 | .flags = CPUFREQ_CONST_LOOPS, | ||
305 | .init = corenet_cpufreq_cpu_init, | ||
306 | .exit = __exit_p(corenet_cpufreq_cpu_exit), | ||
307 | .verify = corenet_cpufreq_verify, | ||
308 | .target = corenet_cpufreq_target, | ||
309 | .get = corenet_cpufreq_get_speed, | ||
310 | .attr = corenet_cpufreq_attr, | ||
311 | }; | ||
312 | |||
313 | static const struct of_device_id node_matches[] __initdata = { | ||
314 | { .compatible = "fsl,p2041-clockgen", .data = &sdata[0], }, | ||
315 | { .compatible = "fsl,p3041-clockgen", .data = &sdata[0], }, | ||
316 | { .compatible = "fsl,p5020-clockgen", .data = &sdata[1], }, | ||
317 | { .compatible = "fsl,p4080-clockgen", .data = &sdata[2], }, | ||
318 | { .compatible = "fsl,p5040-clockgen", .data = &sdata[2], }, | ||
319 | { .compatible = "fsl,qoriq-clockgen-2.0", }, | ||
320 | {} | ||
321 | }; | ||
322 | |||
323 | static int __init ppc_corenet_cpufreq_init(void) | ||
324 | { | ||
325 | int ret; | ||
326 | struct device_node *np; | ||
327 | const struct of_device_id *match; | ||
328 | const struct soc_data *data; | ||
329 | unsigned int cpu; | ||
330 | |||
331 | np = of_find_matching_node(NULL, node_matches); | ||
332 | if (!np) | ||
333 | return -ENODEV; | ||
334 | |||
335 | for_each_possible_cpu(cpu) { | ||
336 | if (!alloc_cpumask_var(&per_cpu(cpu_mask, cpu), GFP_KERNEL)) | ||
337 | goto err_mask; | ||
338 | cpumask_copy(per_cpu(cpu_mask, cpu), cpu_core_mask(cpu)); | ||
339 | } | ||
340 | |||
341 | match = of_match_node(node_matches, np); | ||
342 | data = match->data; | ||
343 | if (data) { | ||
344 | if (data->flag) | ||
345 | fmask = data->freq_mask; | ||
346 | min_cpufreq = fsl_get_sys_freq(); | ||
347 | } else { | ||
348 | min_cpufreq = fsl_get_sys_freq() / 2; | ||
349 | } | ||
350 | |||
351 | of_node_put(np); | ||
352 | |||
353 | ret = cpufreq_register_driver(&ppc_corenet_cpufreq_driver); | ||
354 | if (!ret) | ||
355 | pr_info("Freescale PowerPC corenet CPU frequency scaling driver\n"); | ||
356 | |||
357 | return ret; | ||
358 | |||
359 | err_mask: | ||
360 | for_each_possible_cpu(cpu) | ||
361 | free_cpumask_var(per_cpu(cpu_mask, cpu)); | ||
362 | |||
363 | return -ENOMEM; | ||
364 | } | ||
365 | module_init(ppc_corenet_cpufreq_init); | ||
366 | |||
367 | static void __exit ppc_corenet_cpufreq_exit(void) | ||
368 | { | ||
369 | unsigned int cpu; | ||
370 | |||
371 | for_each_possible_cpu(cpu) | ||
372 | free_cpumask_var(per_cpu(cpu_mask, cpu)); | ||
373 | |||
374 | cpufreq_unregister_driver(&ppc_corenet_cpufreq_driver); | ||
375 | } | ||
376 | module_exit(ppc_corenet_cpufreq_exit); | ||
377 | |||
378 | MODULE_LICENSE("GPL"); | ||
379 | MODULE_AUTHOR("Tang Yuantian <Yuantian.Tang@freescale.com>"); | ||
380 | MODULE_DESCRIPTION("cpufreq driver for Freescale e500mc series SoCs"); | ||
diff --git a/drivers/cpufreq/ppc_cbe_cpufreq.c b/drivers/cpufreq/ppc_cbe_cpufreq.c index e577a1dbbfcd..5936f8d6f2cc 100644 --- a/drivers/cpufreq/ppc_cbe_cpufreq.c +++ b/drivers/cpufreq/ppc_cbe_cpufreq.c | |||
@@ -106,7 +106,7 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
106 | 106 | ||
107 | /* initialize frequency table */ | 107 | /* initialize frequency table */ |
108 | for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { | 108 | for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { |
109 | cbe_freqs[i].frequency = max_freq / cbe_freqs[i].index; | 109 | cbe_freqs[i].frequency = max_freq / cbe_freqs[i].driver_data; |
110 | pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); | 110 | pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); |
111 | } | 111 | } |
112 | 112 | ||
@@ -165,7 +165,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy, | |||
165 | "1/%d of max frequency\n", | 165 | "1/%d of max frequency\n", |
166 | policy->cpu, | 166 | policy->cpu, |
167 | cbe_freqs[cbe_pmode_new].frequency, | 167 | cbe_freqs[cbe_pmode_new].frequency, |
168 | cbe_freqs[cbe_pmode_new].index); | 168 | cbe_freqs[cbe_pmode_new].driver_data); |
169 | 169 | ||
170 | rc = set_pmode(policy->cpu, cbe_pmode_new); | 170 | rc = set_pmode(policy->cpu, cbe_pmode_new); |
171 | 171 | ||
diff --git a/drivers/cpufreq/pxa2xx-cpufreq.c b/drivers/cpufreq/pxa2xx-cpufreq.c index 9e5bc8e388a0..fb3981ac829f 100644 --- a/drivers/cpufreq/pxa2xx-cpufreq.c +++ b/drivers/cpufreq/pxa2xx-cpufreq.c | |||
@@ -420,7 +420,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
420 | /* Generate pxa25x the run cpufreq_frequency_table struct */ | 420 | /* Generate pxa25x the run cpufreq_frequency_table struct */ |
421 | for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) { | 421 | for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) { |
422 | pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz; | 422 | pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz; |
423 | pxa255_run_freq_table[i].index = i; | 423 | pxa255_run_freq_table[i].driver_data = i; |
424 | } | 424 | } |
425 | pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END; | 425 | pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END; |
426 | 426 | ||
@@ -428,7 +428,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
428 | for (i = 0; i < NUM_PXA25x_TURBO_FREQS; i++) { | 428 | for (i = 0; i < NUM_PXA25x_TURBO_FREQS; i++) { |
429 | pxa255_turbo_freq_table[i].frequency = | 429 | pxa255_turbo_freq_table[i].frequency = |
430 | pxa255_turbo_freqs[i].khz; | 430 | pxa255_turbo_freqs[i].khz; |
431 | pxa255_turbo_freq_table[i].index = i; | 431 | pxa255_turbo_freq_table[i].driver_data = i; |
432 | } | 432 | } |
433 | pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END; | 433 | pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END; |
434 | 434 | ||
@@ -440,9 +440,9 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) | |||
440 | if (freq > pxa27x_maxfreq) | 440 | if (freq > pxa27x_maxfreq) |
441 | break; | 441 | break; |
442 | pxa27x_freq_table[i].frequency = freq; | 442 | pxa27x_freq_table[i].frequency = freq; |
443 | pxa27x_freq_table[i].index = i; | 443 | pxa27x_freq_table[i].driver_data = i; |
444 | } | 444 | } |
445 | pxa27x_freq_table[i].index = i; | 445 | pxa27x_freq_table[i].driver_data = i; |
446 | pxa27x_freq_table[i].frequency = CPUFREQ_TABLE_END; | 446 | pxa27x_freq_table[i].frequency = CPUFREQ_TABLE_END; |
447 | 447 | ||
448 | /* | 448 | /* |
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c index 15d60f857ad5..9c92ef032a9e 100644 --- a/drivers/cpufreq/pxa3xx-cpufreq.c +++ b/drivers/cpufreq/pxa3xx-cpufreq.c | |||
@@ -98,10 +98,10 @@ static int setup_freqs_table(struct cpufreq_policy *policy, | |||
98 | return -ENOMEM; | 98 | return -ENOMEM; |
99 | 99 | ||
100 | for (i = 0; i < num; i++) { | 100 | for (i = 0; i < num; i++) { |
101 | table[i].index = i; | 101 | table[i].driver_data = i; |
102 | table[i].frequency = freqs[i].cpufreq_mhz * 1000; | 102 | table[i].frequency = freqs[i].cpufreq_mhz * 1000; |
103 | } | 103 | } |
104 | table[num].index = i; | 104 | table[num].driver_data = i; |
105 | table[num].frequency = CPUFREQ_TABLE_END; | 105 | table[num].frequency = CPUFREQ_TABLE_END; |
106 | 106 | ||
107 | pxa3xx_freqs = freqs; | 107 | pxa3xx_freqs = freqs; |
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c index 4f1881eee3f1..69f2e55828dc 100644 --- a/drivers/cpufreq/s3c2416-cpufreq.c +++ b/drivers/cpufreq/s3c2416-cpufreq.c | |||
@@ -244,7 +244,7 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy, | |||
244 | if (ret != 0) | 244 | if (ret != 0) |
245 | goto out; | 245 | goto out; |
246 | 246 | ||
247 | idx = s3c_freq->freq_table[i].index; | 247 | idx = s3c_freq->freq_table[i].driver_data; |
248 | 248 | ||
249 | if (idx == SOURCE_HCLK) | 249 | if (idx == SOURCE_HCLK) |
250 | to_dvs = 1; | 250 | to_dvs = 1; |
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index 27cacb524796..306d395de990 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c | |||
@@ -87,7 +87,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, | |||
87 | freqs.old = clk_get_rate(armclk) / 1000; | 87 | freqs.old = clk_get_rate(armclk) / 1000; |
88 | freqs.new = s3c64xx_freq_table[i].frequency; | 88 | freqs.new = s3c64xx_freq_table[i].frequency; |
89 | freqs.flags = 0; | 89 | freqs.flags = 0; |
90 | dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[i].index]; | 90 | dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[i].driver_data]; |
91 | 91 | ||
92 | if (freqs.old == freqs.new) | 92 | if (freqs.old == freqs.new) |
93 | return 0; | 93 | return 0; |
diff --git a/drivers/cpufreq/sc520_freq.c b/drivers/cpufreq/sc520_freq.c index f740b134d27b..77a210975fc4 100644 --- a/drivers/cpufreq/sc520_freq.c +++ b/drivers/cpufreq/sc520_freq.c | |||
@@ -71,7 +71,7 @@ static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy, | |||
71 | local_irq_disable(); | 71 | local_irq_disable(); |
72 | 72 | ||
73 | clockspeed_reg = *cpuctl & ~0x03; | 73 | clockspeed_reg = *cpuctl & ~0x03; |
74 | *cpuctl = clockspeed_reg | sc520_freq_table[state].index; | 74 | *cpuctl = clockspeed_reg | sc520_freq_table[state].driver_data; |
75 | 75 | ||
76 | local_irq_enable(); | 76 | local_irq_enable(); |
77 | 77 | ||
diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c index 306ae462bba6..93061a408773 100644 --- a/drivers/cpufreq/sparc-us2e-cpufreq.c +++ b/drivers/cpufreq/sparc-us2e-cpufreq.c | |||
@@ -308,17 +308,17 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) | |||
308 | struct cpufreq_frequency_table *table = | 308 | struct cpufreq_frequency_table *table = |
309 | &us2e_freq_table[cpu].table[0]; | 309 | &us2e_freq_table[cpu].table[0]; |
310 | 310 | ||
311 | table[0].index = 0; | 311 | table[0].driver_data = 0; |
312 | table[0].frequency = clock_tick / 1; | 312 | table[0].frequency = clock_tick / 1; |
313 | table[1].index = 1; | 313 | table[1].driver_data = 1; |
314 | table[1].frequency = clock_tick / 2; | 314 | table[1].frequency = clock_tick / 2; |
315 | table[2].index = 2; | 315 | table[2].driver_data = 2; |
316 | table[2].frequency = clock_tick / 4; | 316 | table[2].frequency = clock_tick / 4; |
317 | table[2].index = 3; | 317 | table[2].driver_data = 3; |
318 | table[2].frequency = clock_tick / 6; | 318 | table[2].frequency = clock_tick / 6; |
319 | table[2].index = 4; | 319 | table[2].driver_data = 4; |
320 | table[2].frequency = clock_tick / 8; | 320 | table[2].frequency = clock_tick / 8; |
321 | table[2].index = 5; | 321 | table[2].driver_data = 5; |
322 | table[3].frequency = CPUFREQ_TABLE_END; | 322 | table[3].frequency = CPUFREQ_TABLE_END; |
323 | 323 | ||
324 | policy->cpuinfo.transition_latency = 0; | 324 | policy->cpuinfo.transition_latency = 0; |
diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c index c71ee142347a..880ee293d61e 100644 --- a/drivers/cpufreq/sparc-us3-cpufreq.c +++ b/drivers/cpufreq/sparc-us3-cpufreq.c | |||
@@ -169,13 +169,13 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy) | |||
169 | struct cpufreq_frequency_table *table = | 169 | struct cpufreq_frequency_table *table = |
170 | &us3_freq_table[cpu].table[0]; | 170 | &us3_freq_table[cpu].table[0]; |
171 | 171 | ||
172 | table[0].index = 0; | 172 | table[0].driver_data = 0; |
173 | table[0].frequency = clock_tick / 1; | 173 | table[0].frequency = clock_tick / 1; |
174 | table[1].index = 1; | 174 | table[1].driver_data = 1; |
175 | table[1].frequency = clock_tick / 2; | 175 | table[1].frequency = clock_tick / 2; |
176 | table[2].index = 2; | 176 | table[2].driver_data = 2; |
177 | table[2].frequency = clock_tick / 32; | 177 | table[2].frequency = clock_tick / 32; |
178 | table[3].index = 0; | 178 | table[3].driver_data = 0; |
179 | table[3].frequency = CPUFREQ_TABLE_END; | 179 | table[3].frequency = CPUFREQ_TABLE_END; |
180 | 180 | ||
181 | policy->cpuinfo.transition_latency = 0; | 181 | policy->cpuinfo.transition_latency = 0; |
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c index 156829f4576d..c3efa7f2a908 100644 --- a/drivers/cpufreq/spear-cpufreq.c +++ b/drivers/cpufreq/spear-cpufreq.c | |||
@@ -250,11 +250,11 @@ static int spear_cpufreq_driver_init(void) | |||
250 | } | 250 | } |
251 | 251 | ||
252 | for (i = 0; i < cnt; i++) { | 252 | for (i = 0; i < cnt; i++) { |
253 | freq_tbl[i].index = i; | 253 | freq_tbl[i].driver_data = i; |
254 | freq_tbl[i].frequency = be32_to_cpup(val++); | 254 | freq_tbl[i].frequency = be32_to_cpup(val++); |
255 | } | 255 | } |
256 | 256 | ||
257 | freq_tbl[i].index = i; | 257 | freq_tbl[i].driver_data = i; |
258 | freq_tbl[i].frequency = CPUFREQ_TABLE_END; | 258 | freq_tbl[i].frequency = CPUFREQ_TABLE_END; |
259 | 259 | ||
260 | spear_cpufreq.freq_tbl = freq_tbl; | 260 | spear_cpufreq.freq_tbl = freq_tbl; |
diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c index 618e6f417b1c..0915e712fbdc 100644 --- a/drivers/cpufreq/speedstep-centrino.c +++ b/drivers/cpufreq/speedstep-centrino.c | |||
@@ -79,11 +79,11 @@ static struct cpufreq_driver centrino_driver; | |||
79 | 79 | ||
80 | /* Computes the correct form for IA32_PERF_CTL MSR for a particular | 80 | /* Computes the correct form for IA32_PERF_CTL MSR for a particular |
81 | frequency/voltage operating point; frequency in MHz, volts in mV. | 81 | frequency/voltage operating point; frequency in MHz, volts in mV. |
82 | This is stored as "index" in the structure. */ | 82 | This is stored as "driver_data" in the structure. */ |
83 | #define OP(mhz, mv) \ | 83 | #define OP(mhz, mv) \ |
84 | { \ | 84 | { \ |
85 | .frequency = (mhz) * 1000, \ | 85 | .frequency = (mhz) * 1000, \ |
86 | .index = (((mhz)/100) << 8) | ((mv - 700) / 16) \ | 86 | .driver_data = (((mhz)/100) << 8) | ((mv - 700) / 16) \ |
87 | } | 87 | } |
88 | 88 | ||
89 | /* | 89 | /* |
@@ -307,7 +307,7 @@ static unsigned extract_clock(unsigned msr, unsigned int cpu, int failsafe) | |||
307 | per_cpu(centrino_model, cpu)->op_points[i].frequency | 307 | per_cpu(centrino_model, cpu)->op_points[i].frequency |
308 | != CPUFREQ_TABLE_END; | 308 | != CPUFREQ_TABLE_END; |
309 | i++) { | 309 | i++) { |
310 | if (msr == per_cpu(centrino_model, cpu)->op_points[i].index) | 310 | if (msr == per_cpu(centrino_model, cpu)->op_points[i].driver_data) |
311 | return per_cpu(centrino_model, cpu)-> | 311 | return per_cpu(centrino_model, cpu)-> |
312 | op_points[i].frequency; | 312 | op_points[i].frequency; |
313 | } | 313 | } |
@@ -501,7 +501,7 @@ static int centrino_target (struct cpufreq_policy *policy, | |||
501 | break; | 501 | break; |
502 | } | 502 | } |
503 | 503 | ||
504 | msr = per_cpu(centrino_model, cpu)->op_points[newstate].index; | 504 | msr = per_cpu(centrino_model, cpu)->op_points[newstate].driver_data; |
505 | 505 | ||
506 | if (first_cpu) { | 506 | if (first_cpu) { |
507 | rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h); | 507 | rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h); |
diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c index c74c0e130ef4..81561be17e8c 100644 --- a/drivers/cpufreq/tegra-cpufreq.c +++ b/drivers/cpufreq/tegra-cpufreq.c | |||
@@ -28,17 +28,16 @@ | |||
28 | #include <linux/io.h> | 28 | #include <linux/io.h> |
29 | #include <linux/suspend.h> | 29 | #include <linux/suspend.h> |
30 | 30 | ||
31 | /* Frequency table index must be sequential starting at 0 */ | ||
32 | static struct cpufreq_frequency_table freq_table[] = { | 31 | static struct cpufreq_frequency_table freq_table[] = { |
33 | { 0, 216000 }, | 32 | { .frequency = 216000 }, |
34 | { 1, 312000 }, | 33 | { .frequency = 312000 }, |
35 | { 2, 456000 }, | 34 | { .frequency = 456000 }, |
36 | { 3, 608000 }, | 35 | { .frequency = 608000 }, |
37 | { 4, 760000 }, | 36 | { .frequency = 760000 }, |
38 | { 5, 816000 }, | 37 | { .frequency = 816000 }, |
39 | { 6, 912000 }, | 38 | { .frequency = 912000 }, |
40 | { 7, 1000000 }, | 39 | { .frequency = 1000000 }, |
41 | { 8, CPUFREQ_TABLE_END }, | 40 | { .frequency = CPUFREQ_TABLE_END }, |
42 | }; | 41 | }; |
43 | 42 | ||
44 | #define NUM_CPUS 2 | 43 | #define NUM_CPUS 2 |
diff --git a/drivers/mfd/db8500-prcmu.c b/drivers/mfd/db8500-prcmu.c index 66f80973596b..ed79d7b78e7d 100644 --- a/drivers/mfd/db8500-prcmu.c +++ b/drivers/mfd/db8500-prcmu.c | |||
@@ -1724,9 +1724,9 @@ static long round_clock_rate(u8 clock, unsigned long rate) | |||
1724 | 1724 | ||
1725 | /* CPU FREQ table, may be changed due to if MAX_OPP is supported. */ | 1725 | /* CPU FREQ table, may be changed due to if MAX_OPP is supported. */ |
1726 | static struct cpufreq_frequency_table db8500_cpufreq_table[] = { | 1726 | static struct cpufreq_frequency_table db8500_cpufreq_table[] = { |
1727 | { .frequency = 200000, .index = ARM_EXTCLK,}, | 1727 | { .frequency = 200000, .driver_data = ARM_EXTCLK,}, |
1728 | { .frequency = 400000, .index = ARM_50_OPP,}, | 1728 | { .frequency = 400000, .driver_data = ARM_50_OPP,}, |
1729 | { .frequency = 800000, .index = ARM_100_OPP,}, | 1729 | { .frequency = 800000, .driver_data = ARM_100_OPP,}, |
1730 | { .frequency = CPUFREQ_TABLE_END,}, /* To be used for MAX_OPP. */ | 1730 | { .frequency = CPUFREQ_TABLE_END,}, /* To be used for MAX_OPP. */ |
1731 | { .frequency = CPUFREQ_TABLE_END,}, | 1731 | { .frequency = CPUFREQ_TABLE_END,}, |
1732 | }; | 1732 | }; |
@@ -1901,7 +1901,7 @@ static int set_armss_rate(unsigned long rate) | |||
1901 | return -EINVAL; | 1901 | return -EINVAL; |
1902 | 1902 | ||
1903 | /* Set the new arm opp. */ | 1903 | /* Set the new arm opp. */ |
1904 | return db8500_prcmu_set_arm_opp(db8500_cpufreq_table[i].index); | 1904 | return db8500_prcmu_set_arm_opp(db8500_cpufreq_table[i].driver_data); |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | static int set_plldsi_rate(unsigned long rate) | 1907 | static int set_plldsi_rate(unsigned long rate) |
@@ -3105,7 +3105,7 @@ static void db8500_prcmu_update_cpufreq(void) | |||
3105 | { | 3105 | { |
3106 | if (prcmu_has_arm_maxopp()) { | 3106 | if (prcmu_has_arm_maxopp()) { |
3107 | db8500_cpufreq_table[3].frequency = 1000000; | 3107 | db8500_cpufreq_table[3].frequency = 1000000; |
3108 | db8500_cpufreq_table[3].index = ARM_MAX_OPP; | 3108 | db8500_cpufreq_table[3].driver_data = ARM_MAX_OPP; |
3109 | } | 3109 | } |
3110 | } | 3110 | } |
3111 | 3111 | ||
diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 7715de2629c1..74727851820d 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c | |||
@@ -63,12 +63,12 @@ void clk_rate_table_build(struct clk *clk, | |||
63 | else | 63 | else |
64 | freq = clk->parent->rate * mult / div; | 64 | freq = clk->parent->rate * mult / div; |
65 | 65 | ||
66 | freq_table[i].index = i; | 66 | freq_table[i].driver_data = i; |
67 | freq_table[i].frequency = freq; | 67 | freq_table[i].frequency = freq; |
68 | } | 68 | } |
69 | 69 | ||
70 | /* Termination entry */ | 70 | /* Termination entry */ |
71 | freq_table[i].index = i; | 71 | freq_table[i].driver_data = i; |
72 | freq_table[i].frequency = CPUFREQ_TABLE_END; | 72 | freq_table[i].frequency = CPUFREQ_TABLE_END; |
73 | } | 73 | } |
74 | 74 | ||
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 037d36ae63e5..3c7ee2f90370 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * linux/include/linux/cpufreq.h | 2 | * linux/include/linux/cpufreq.h |
3 | * | 3 | * |
4 | * Copyright (C) 2001 Russell King | 4 | * Copyright (C) 2001 Russell King |
5 | * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> | 5 | * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License version 2 as | 8 | * it under the terms of the GNU General Public License version 2 as |
@@ -26,7 +26,6 @@ | |||
26 | /* Print length for names. Extra 1 space for accomodating '\n' in prints */ | 26 | /* Print length for names. Extra 1 space for accomodating '\n' in prints */ |
27 | #define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1) | 27 | #define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1) |
28 | 28 | ||
29 | |||
30 | /********************************************************************* | 29 | /********************************************************************* |
31 | * CPUFREQ NOTIFIER INTERFACE * | 30 | * CPUFREQ NOTIFIER INTERFACE * |
32 | *********************************************************************/ | 31 | *********************************************************************/ |
@@ -71,6 +70,10 @@ struct cpufreq_governor; | |||
71 | 70 | ||
72 | /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ | 71 | /* /sys/devices/system/cpu/cpufreq: entry point for global variables */ |
73 | extern struct kobject *cpufreq_global_kobject; | 72 | extern struct kobject *cpufreq_global_kobject; |
73 | int cpufreq_get_global_kobject(void); | ||
74 | void cpufreq_put_global_kobject(void); | ||
75 | int cpufreq_sysfs_create_file(const struct attribute *attr); | ||
76 | void cpufreq_sysfs_remove_file(const struct attribute *attr); | ||
74 | 77 | ||
75 | #define CPUFREQ_ETERNAL (-1) | 78 | #define CPUFREQ_ETERNAL (-1) |
76 | struct cpufreq_cpuinfo { | 79 | struct cpufreq_cpuinfo { |
@@ -107,6 +110,7 @@ struct cpufreq_policy { | |||
107 | unsigned int policy; /* see above */ | 110 | unsigned int policy; /* see above */ |
108 | struct cpufreq_governor *governor; /* see below */ | 111 | struct cpufreq_governor *governor; /* see below */ |
109 | void *governor_data; | 112 | void *governor_data; |
113 | bool governor_enabled; /* governor start/stop flag */ | ||
110 | 114 | ||
111 | struct work_struct update; /* if update_policy() needs to be | 115 | struct work_struct update; /* if update_policy() needs to be |
112 | * called, but you're in IRQ context */ | 116 | * called, but you're in IRQ context */ |
@@ -148,17 +152,18 @@ struct cpufreq_freqs { | |||
148 | u8 flags; /* flags of cpufreq_driver, see below. */ | 152 | u8 flags; /* flags of cpufreq_driver, see below. */ |
149 | }; | 153 | }; |
150 | 154 | ||
151 | |||
152 | /** | 155 | /** |
153 | * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch safe) | 156 | * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch |
157 | * safe) | ||
154 | * @old: old value | 158 | * @old: old value |
155 | * @div: divisor | 159 | * @div: divisor |
156 | * @mult: multiplier | 160 | * @mult: multiplier |
157 | * | 161 | * |
158 | * | 162 | * |
159 | * new = old * mult / div | 163 | * new = old * mult / div |
160 | */ | 164 | */ |
161 | static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult) | 165 | static inline unsigned long cpufreq_scale(unsigned long old, u_int div, |
166 | u_int mult) | ||
162 | { | 167 | { |
163 | #if BITS_PER_LONG == 32 | 168 | #if BITS_PER_LONG == 32 |
164 | 169 | ||
@@ -211,14 +216,12 @@ extern int __cpufreq_driver_target(struct cpufreq_policy *policy, | |||
211 | unsigned int target_freq, | 216 | unsigned int target_freq, |
212 | unsigned int relation); | 217 | unsigned int relation); |
213 | 218 | ||
214 | |||
215 | extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy, | 219 | extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy, |
216 | unsigned int cpu); | 220 | unsigned int cpu); |
217 | 221 | ||
218 | int cpufreq_register_governor(struct cpufreq_governor *governor); | 222 | int cpufreq_register_governor(struct cpufreq_governor *governor); |
219 | void cpufreq_unregister_governor(struct cpufreq_governor *governor); | 223 | void cpufreq_unregister_governor(struct cpufreq_governor *governor); |
220 | 224 | ||
221 | |||
222 | /********************************************************************* | 225 | /********************************************************************* |
223 | * CPUFREQ DRIVER INTERFACE * | 226 | * CPUFREQ DRIVER INTERFACE * |
224 | *********************************************************************/ | 227 | *********************************************************************/ |
@@ -229,7 +232,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor); | |||
229 | struct freq_attr; | 232 | struct freq_attr; |
230 | 233 | ||
231 | struct cpufreq_driver { | 234 | struct cpufreq_driver { |
232 | struct module *owner; | 235 | struct module *owner; |
233 | char name[CPUFREQ_NAME_LEN]; | 236 | char name[CPUFREQ_NAME_LEN]; |
234 | u8 flags; | 237 | u8 flags; |
235 | /* | 238 | /* |
@@ -277,11 +280,11 @@ struct cpufreq_driver { | |||
277 | int cpufreq_register_driver(struct cpufreq_driver *driver_data); | 280 | int cpufreq_register_driver(struct cpufreq_driver *driver_data); |
278 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); | 281 | int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); |
279 | 282 | ||
280 | |||
281 | void cpufreq_notify_transition(struct cpufreq_policy *policy, | 283 | void cpufreq_notify_transition(struct cpufreq_policy *policy, |
282 | struct cpufreq_freqs *freqs, unsigned int state); | 284 | struct cpufreq_freqs *freqs, unsigned int state); |
283 | 285 | ||
284 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) | 286 | static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, |
287 | unsigned int min, unsigned int max) | ||
285 | { | 288 | { |
286 | if (policy->min < min) | 289 | if (policy->min < min) |
287 | policy->min = min; | 290 | policy->min = min; |
@@ -337,12 +340,16 @@ const char *cpufreq_get_current_driver(void); | |||
337 | /********************************************************************* | 340 | /********************************************************************* |
338 | * CPUFREQ 2.6. INTERFACE * | 341 | * CPUFREQ 2.6. INTERFACE * |
339 | *********************************************************************/ | 342 | *********************************************************************/ |
343 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); | ||
340 | int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); | 344 | int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); |
341 | int cpufreq_update_policy(unsigned int cpu); | 345 | int cpufreq_update_policy(unsigned int cpu); |
342 | bool have_governor_per_policy(void); | 346 | bool have_governor_per_policy(void); |
347 | struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy); | ||
343 | 348 | ||
344 | #ifdef CONFIG_CPU_FREQ | 349 | #ifdef CONFIG_CPU_FREQ |
345 | /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */ | 350 | /* |
351 | * query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it | ||
352 | */ | ||
346 | unsigned int cpufreq_get(unsigned int cpu); | 353 | unsigned int cpufreq_get(unsigned int cpu); |
347 | #else | 354 | #else |
348 | static inline unsigned int cpufreq_get(unsigned int cpu) | 355 | static inline unsigned int cpufreq_get(unsigned int cpu) |
@@ -351,7 +358,9 @@ static inline unsigned int cpufreq_get(unsigned int cpu) | |||
351 | } | 358 | } |
352 | #endif | 359 | #endif |
353 | 360 | ||
354 | /* query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it */ | 361 | /* |
362 | * query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it | ||
363 | */ | ||
355 | #ifdef CONFIG_CPU_FREQ | 364 | #ifdef CONFIG_CPU_FREQ |
356 | unsigned int cpufreq_quick_get(unsigned int cpu); | 365 | unsigned int cpufreq_quick_get(unsigned int cpu); |
357 | unsigned int cpufreq_quick_get_max(unsigned int cpu); | 366 | unsigned int cpufreq_quick_get_max(unsigned int cpu); |
@@ -366,16 +375,14 @@ static inline unsigned int cpufreq_quick_get_max(unsigned int cpu) | |||
366 | } | 375 | } |
367 | #endif | 376 | #endif |
368 | 377 | ||
369 | |||
370 | /********************************************************************* | 378 | /********************************************************************* |
371 | * CPUFREQ DEFAULT GOVERNOR * | 379 | * CPUFREQ DEFAULT GOVERNOR * |
372 | *********************************************************************/ | 380 | *********************************************************************/ |
373 | 381 | ||
374 | |||
375 | /* | 382 | /* |
376 | Performance governor is fallback governor if any other gov failed to | 383 | * Performance governor is fallback governor if any other gov failed to auto |
377 | auto load due latency restrictions | 384 | * load due latency restrictions |
378 | */ | 385 | */ |
379 | #ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE | 386 | #ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE |
380 | extern struct cpufreq_governor cpufreq_gov_performance; | 387 | extern struct cpufreq_governor cpufreq_gov_performance; |
381 | #endif | 388 | #endif |
@@ -395,7 +402,6 @@ extern struct cpufreq_governor cpufreq_gov_conservative; | |||
395 | #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_conservative) | 402 | #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_conservative) |
396 | #endif | 403 | #endif |
397 | 404 | ||
398 | |||
399 | /********************************************************************* | 405 | /********************************************************************* |
400 | * FREQUENCY TABLE HELPERS * | 406 | * FREQUENCY TABLE HELPERS * |
401 | *********************************************************************/ | 407 | *********************************************************************/ |
@@ -404,7 +410,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative; | |||
404 | #define CPUFREQ_TABLE_END ~1 | 410 | #define CPUFREQ_TABLE_END ~1 |
405 | 411 | ||
406 | struct cpufreq_frequency_table { | 412 | struct cpufreq_frequency_table { |
407 | unsigned int index; /* any */ | 413 | unsigned int driver_data; /* driver specific data, not used by core */ |
408 | unsigned int frequency; /* kHz - doesn't need to be in ascending | 414 | unsigned int frequency; /* kHz - doesn't need to be in ascending |
409 | * order */ | 415 | * order */ |
410 | }; | 416 | }; |