Commit 39a95f48 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

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
  ...
parents 7ae9b27b 7f77a563
...@@ -186,7 +186,7 @@ As most cpufreq processors only allow for being set to a few specific ...@@ -186,7 +186,7 @@ As most cpufreq processors only allow for being set to a few specific
frequencies, a "frequency table" with some functions might assist in frequencies, a "frequency table" with some functions might assist in
some work of the processor driver. Such a "frequency table" consists some work of the processor driver. Such a "frequency table" consists
of an array of struct cpufreq_frequency_table entries, with any value in of an array of struct cpufreq_frequency_table entries, with any value in
"index" you want to use, and the corresponding frequency in "driver_data" you want to use, and the corresponding frequency in
"frequency". At the end of the table, you need to add a "frequency". At the end of the table, you need to add a
cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And
if you want to skip one entry in the table, set the frequency to 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,10 +214,4 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
is the corresponding frequency table helper for the ->target is the corresponding frequency table helper for the ->target
stage. Just pass the values to this function, and the unsigned int stage. Just pass the values to this function, and the unsigned int
index returns the number of the frequency table entry which contains index returns the number of the frequency table entry which contains
the frequency the CPU shall be set to. PLEASE NOTE: This is not the the frequency the CPU shall be set to.
"index" which is in this cpufreq_table_entry.index, but instead
cpufreq_table[index]. So, the new frequency is
cpufreq_table[index].frequency, and the value you stored into the
frequency table "index" field is
cpufreq_table[index].index.
...@@ -2215,7 +2215,8 @@ M: Viresh Kumar <viresh.kumar@linaro.org> ...@@ -2215,7 +2215,8 @@ M: Viresh Kumar <viresh.kumar@linaro.org>
L: cpufreq@vger.kernel.org L: cpufreq@vger.kernel.org
L: linux-pm@vger.kernel.org L: linux-pm@vger.kernel.org
S: Maintained S: Maintained
T: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
T: git git://git.linaro.org/people/vireshk/linux.git (For ARM Updates)
F: drivers/cpufreq/ F: drivers/cpufreq/
F: include/linux/cpufreq.h F: include/linux/cpufreq.h
......
...@@ -1004,7 +1004,7 @@ static const struct da850_opp da850_opp_96 = { ...@@ -1004,7 +1004,7 @@ static const struct da850_opp da850_opp_96 = {
#define OPP(freq) \ #define OPP(freq) \
{ \ { \
.index = (unsigned int) &da850_opp_##freq, \ .driver_data = (unsigned int) &da850_opp_##freq, \
.frequency = freq * 1000, \ .frequency = freq * 1000, \
} }
...@@ -1016,7 +1016,7 @@ static struct cpufreq_frequency_table da850_freq_table[] = { ...@@ -1016,7 +1016,7 @@ static struct cpufreq_frequency_table da850_freq_table[] = {
OPP(200), OPP(200),
OPP(96), OPP(96),
{ {
.index = 0, .driver_data = 0,
.frequency = CPUFREQ_TABLE_END, .frequency = CPUFREQ_TABLE_END,
}, },
}; };
...@@ -1044,7 +1044,7 @@ static int da850_set_voltage(unsigned int index) ...@@ -1044,7 +1044,7 @@ static int da850_set_voltage(unsigned int index)
if (!cvdd) if (!cvdd)
return -ENODEV; return -ENODEV;
opp = (struct da850_opp *) cpufreq_info.freq_table[index].index; opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data;
return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max); return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max);
} }
...@@ -1125,7 +1125,7 @@ static int da850_set_pll0rate(struct clk *clk, unsigned long index) ...@@ -1125,7 +1125,7 @@ static int da850_set_pll0rate(struct clk *clk, unsigned long index)
struct pll_data *pll = clk->pll_data; struct pll_data *pll = clk->pll_data;
int ret; int ret;
opp = (struct da850_opp *) cpufreq_info.freq_table[index].index; opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data;
prediv = opp->prediv; prediv = opp->prediv;
mult = opp->mult; mult = opp->mult;
postdiv = opp->postdiv; postdiv = opp->postdiv;
......
...@@ -60,5 +60,5 @@ void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg) ...@@ -60,5 +60,5 @@ void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg)
*/ */
void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg) void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg)
{ {
__raw_writel(cfg->pll.index, S3C2410_MPLLCON); __raw_writel(cfg->pll.driver_data, S3C2410_MPLLCON);
} }
...@@ -70,7 +70,7 @@ static void s3c_cpufreq_getcur(struct s3c_cpufreq_config *cfg) ...@@ -70,7 +70,7 @@ static void s3c_cpufreq_getcur(struct s3c_cpufreq_config *cfg)
cfg->freq.pclk = pclk = clk_get_rate(clk_pclk); cfg->freq.pclk = pclk = clk_get_rate(clk_pclk);
cfg->freq.armclk = armclk = clk_get_rate(clk_arm); cfg->freq.armclk = armclk = clk_get_rate(clk_arm);
cfg->pll.index = __raw_readl(S3C2410_MPLLCON); cfg->pll.driver_data = __raw_readl(S3C2410_MPLLCON);
cfg->pll.frequency = fclk; cfg->pll.frequency = fclk;
cfg->freq.hclk_tns = 1000000000 / (cfg->freq.hclk / 10); cfg->freq.hclk_tns = 1000000000 / (cfg->freq.hclk / 10);
...@@ -431,7 +431,7 @@ static unsigned int suspend_freq; ...@@ -431,7 +431,7 @@ static unsigned int suspend_freq;
static int s3c_cpufreq_suspend(struct cpufreq_policy *policy) static int s3c_cpufreq_suspend(struct cpufreq_policy *policy)
{ {
suspend_pll.frequency = clk_get_rate(_clk_mpll); suspend_pll.frequency = clk_get_rate(_clk_mpll);
suspend_pll.index = __raw_readl(S3C2410_MPLLCON); suspend_pll.driver_data = __raw_readl(S3C2410_MPLLCON);
suspend_freq = s3c_cpufreq_get(0) * 1000; suspend_freq = s3c_cpufreq_get(0) * 1000;
return 0; return 0;
......
...@@ -33,36 +33,36 @@ ...@@ -33,36 +33,36 @@
#include <plat/cpu-freq-core.h> #include <plat/cpu-freq-core.h>
static struct cpufreq_frequency_table pll_vals_12MHz[] = { static struct cpufreq_frequency_table pll_vals_12MHz[] = {
{ .frequency = 34000000, .index = PLLVAL(82, 2, 3), }, { .frequency = 34000000, .driver_data = PLLVAL(82, 2, 3), },
{ .frequency = 45000000, .index = PLLVAL(82, 1, 3), }, { .frequency = 45000000, .driver_data = PLLVAL(82, 1, 3), },
{ .frequency = 51000000, .index = PLLVAL(161, 3, 3), }, { .frequency = 51000000, .driver_data = PLLVAL(161, 3, 3), },
{ .frequency = 48000000, .index = PLLVAL(120, 2, 3), }, { .frequency = 48000000, .driver_data = PLLVAL(120, 2, 3), },
{ .frequency = 56000000, .index = PLLVAL(142, 2, 3), }, { .frequency = 56000000, .driver_data = PLLVAL(142, 2, 3), },
{ .frequency = 68000000, .index = PLLVAL(82, 2, 2), }, { .frequency = 68000000, .driver_data = PLLVAL(82, 2, 2), },
{ .frequency = 79000000, .index = PLLVAL(71, 1, 2), }, { .frequency = 79000000, .driver_data = PLLVAL(71, 1, 2), },
{ .frequency = 85000000, .index = PLLVAL(105, 2, 2), }, { .frequency = 85000000, .driver_data = PLLVAL(105, 2, 2), },
{ .frequency = 90000000, .index = PLLVAL(112, 2, 2), }, { .frequency = 90000000, .driver_data = PLLVAL(112, 2, 2), },
{ .frequency = 101000000, .index = PLLVAL(127, 2, 2), }, { .frequency = 101000000, .driver_data = PLLVAL(127, 2, 2), },
{ .frequency = 113000000, .index = PLLVAL(105, 1, 2), }, { .frequency = 113000000, .driver_data = PLLVAL(105, 1, 2), },
{ .frequency = 118000000, .index = PLLVAL(150, 2, 2), }, { .frequency = 118000000, .driver_data = PLLVAL(150, 2, 2), },
{ .frequency = 124000000, .index = PLLVAL(116, 1, 2), }, { .frequency = 124000000, .driver_data = PLLVAL(116, 1, 2), },
{ .frequency = 135000000, .index = PLLVAL(82, 2, 1), }, { .frequency = 135000000, .driver_data = PLLVAL(82, 2, 1), },
{ .frequency = 147000000, .index = PLLVAL(90, 2, 1), }, { .frequency = 147000000, .driver_data = PLLVAL(90, 2, 1), },
{ .frequency = 152000000, .index = PLLVAL(68, 1, 1), }, { .frequency = 152000000, .driver_data = PLLVAL(68, 1, 1), },
{ .frequency = 158000000, .index = PLLVAL(71, 1, 1), }, { .frequency = 158000000, .driver_data = PLLVAL(71, 1, 1), },
{ .frequency = 170000000, .index = PLLVAL(77, 1, 1), }, { .frequency = 170000000, .driver_data = PLLVAL(77, 1, 1), },
{ .frequency = 180000000, .index = PLLVAL(82, 1, 1), }, { .frequency = 180000000, .driver_data = PLLVAL(82, 1, 1), },
{ .frequency = 186000000, .index = PLLVAL(85, 1, 1), }, { .frequency = 186000000, .driver_data = PLLVAL(85, 1, 1), },
{ .frequency = 192000000, .index = PLLVAL(88, 1, 1), }, { .frequency = 192000000, .driver_data = PLLVAL(88, 1, 1), },
{ .frequency = 203000000, .index = PLLVAL(161, 3, 1), }, { .frequency = 203000000, .driver_data = PLLVAL(161, 3, 1), },
/* 2410A extras */ /* 2410A extras */
{ .frequency = 210000000, .index = PLLVAL(132, 2, 1), }, { .frequency = 210000000, .driver_data = PLLVAL(132, 2, 1), },
{ .frequency = 226000000, .index = PLLVAL(105, 1, 1), }, { .frequency = 226000000, .driver_data = PLLVAL(105, 1, 1), },
{ .frequency = 266000000, .index = PLLVAL(125, 1, 1), }, { .frequency = 266000000, .driver_data = PLLVAL(125, 1, 1), },
{ .frequency = 268000000, .index = PLLVAL(126, 1, 1), }, { .frequency = 268000000, .driver_data = PLLVAL(126, 1, 1), },
{ .frequency = 270000000, .index = PLLVAL(127, 1, 1), }, { .frequency = 270000000, .driver_data = PLLVAL(127, 1, 1), },
}; };
static int s3c2410_plls_add(struct device *dev, struct subsys_interface *sif) static int s3c2410_plls_add(struct device *dev, struct subsys_interface *sif)
......
...@@ -21,33 +21,33 @@ ...@@ -21,33 +21,33 @@
#include <plat/cpu-freq-core.h> #include <plat/cpu-freq-core.h>
static struct cpufreq_frequency_table s3c2440_plls_12[] __initdata = { static struct cpufreq_frequency_table s3c2440_plls_12[] __initdata = {
{ .frequency = 75000000, .index = PLLVAL(0x75, 3, 3), }, /* FVco 600.000000 */ { .frequency = 75000000, .driver_data = PLLVAL(0x75, 3, 3), }, /* FVco 600.000000 */
{ .frequency = 80000000, .index = PLLVAL(0x98, 4, 3), }, /* FVco 640.000000 */ { .frequency = 80000000, .driver_data = PLLVAL(0x98, 4, 3), }, /* FVco 640.000000 */
{ .frequency = 90000000, .index = PLLVAL(0x70, 2, 3), }, /* FVco 720.000000 */ { .frequency = 90000000, .driver_data = PLLVAL(0x70, 2, 3), }, /* FVco 720.000000 */
{ .frequency = 100000000, .index = PLLVAL(0x5c, 1, 3), }, /* FVco 800.000000 */ { .frequency = 100000000, .driver_data = PLLVAL(0x5c, 1, 3), }, /* FVco 800.000000 */
{ .frequency = 110000000, .index = PLLVAL(0x66, 1, 3), }, /* FVco 880.000000 */ { .frequency = 110000000, .driver_data = PLLVAL(0x66, 1, 3), }, /* FVco 880.000000 */
{ .frequency = 120000000, .index = PLLVAL(0x70, 1, 3), }, /* FVco 960.000000 */ { .frequency = 120000000, .driver_data = PLLVAL(0x70, 1, 3), }, /* FVco 960.000000 */
{ .frequency = 150000000, .index = PLLVAL(0x75, 3, 2), }, /* FVco 600.000000 */ { .frequency = 150000000, .driver_data = PLLVAL(0x75, 3, 2), }, /* FVco 600.000000 */
{ .frequency = 160000000, .index = PLLVAL(0x98, 4, 2), }, /* FVco 640.000000 */ { .frequency = 160000000, .driver_data = PLLVAL(0x98, 4, 2), }, /* FVco 640.000000 */
{ .frequency = 170000000, .index = PLLVAL(0x4d, 1, 2), }, /* FVco 680.000000 */ { .frequency = 170000000, .driver_data = PLLVAL(0x4d, 1, 2), }, /* FVco 680.000000 */
{ .frequency = 180000000, .index = PLLVAL(0x70, 2, 2), }, /* FVco 720.000000 */ { .frequency = 180000000, .driver_data = PLLVAL(0x70, 2, 2), }, /* FVco 720.000000 */
{ .frequency = 190000000, .index = PLLVAL(0x57, 1, 2), }, /* FVco 760.000000 */ { .frequency = 190000000, .driver_data = PLLVAL(0x57, 1, 2), }, /* FVco 760.000000 */
{ .frequency = 200000000, .index = PLLVAL(0x5c, 1, 2), }, /* FVco 800.000000 */ { .frequency = 200000000, .driver_data = PLLVAL(0x5c, 1, 2), }, /* FVco 800.000000 */
{ .frequency = 210000000, .index = PLLVAL(0x84, 2, 2), }, /* FVco 840.000000 */ { .frequency = 210000000, .driver_data = PLLVAL(0x84, 2, 2), }, /* FVco 840.000000 */
{ .frequency = 220000000, .index = PLLVAL(0x66, 1, 2), }, /* FVco 880.000000 */ { .frequency = 220000000, .driver_data = PLLVAL(0x66, 1, 2), }, /* FVco 880.000000 */
{ .frequency = 230000000, .index = PLLVAL(0x6b, 1, 2), }, /* FVco 920.000000 */ { .frequency = 230000000, .driver_data = PLLVAL(0x6b, 1, 2), }, /* FVco 920.000000 */
{ .frequency = 240000000, .index = PLLVAL(0x70, 1, 2), }, /* FVco 960.000000 */ { .frequency = 240000000, .driver_data = PLLVAL(0x70, 1, 2), }, /* FVco 960.000000 */
{ .frequency = 300000000, .index = PLLVAL(0x75, 3, 1), }, /* FVco 600.000000 */ { .frequency = 300000000, .driver_data = PLLVAL(0x75, 3, 1), }, /* FVco 600.000000 */
{ .frequency = 310000000, .index = PLLVAL(0x93, 4, 1), }, /* FVco 620.000000 */ { .frequency = 310000000, .driver_data = PLLVAL(0x93, 4, 1), }, /* FVco 620.000000 */
{ .frequency = 320000000, .index = PLLVAL(0x98, 4, 1), }, /* FVco 640.000000 */ { .frequency = 320000000, .driver_data = PLLVAL(0x98, 4, 1), }, /* FVco 640.000000 */
{ .frequency = 330000000, .index = PLLVAL(0x66, 2, 1), }, /* FVco 660.000000 */ { .frequency = 330000000, .driver_data = PLLVAL(0x66, 2, 1), }, /* FVco 660.000000 */
{ .frequency = 340000000, .index = PLLVAL(0x4d, 1, 1), }, /* FVco 680.000000 */ { .frequency = 340000000, .driver_data = PLLVAL(0x4d, 1, 1), }, /* FVco 680.000000 */
{ .frequency = 350000000, .index = PLLVAL(0xa7, 4, 1), }, /* FVco 700.000000 */ { .frequency = 350000000, .driver_data = PLLVAL(0xa7, 4, 1), }, /* FVco 700.000000 */
{ .frequency = 360000000, .index = PLLVAL(0x70, 2, 1), }, /* FVco 720.000000 */ { .frequency = 360000000, .driver_data = PLLVAL(0x70, 2, 1), }, /* FVco 720.000000 */
{ .frequency = 370000000, .index = PLLVAL(0xb1, 4, 1), }, /* FVco 740.000000 */ { .frequency = 370000000, .driver_data = PLLVAL(0xb1, 4, 1), }, /* FVco 740.000000 */
{ .frequency = 380000000, .index = PLLVAL(0x57, 1, 1), }, /* FVco 760.000000 */ { .frequency = 380000000, .driver_data = PLLVAL(0x57, 1, 1), }, /* FVco 760.000000 */
{ .frequency = 390000000, .index = PLLVAL(0x7a, 2, 1), }, /* FVco 780.000000 */ { .frequency = 390000000, .driver_data = PLLVAL(0x7a, 2, 1), }, /* FVco 780.000000 */
{ .frequency = 400000000, .index = PLLVAL(0x5c, 1, 1), }, /* FVco 800.000000 */ { .frequency = 400000000, .driver_data = PLLVAL(0x5c, 1, 1), }, /* FVco 800.000000 */
}; };
static int s3c2440_plls12_add(struct device *dev, struct subsys_interface *sif) static int s3c2440_plls12_add(struct device *dev, struct subsys_interface *sif)
......
...@@ -21,61 +21,61 @@ ...@@ -21,61 +21,61 @@
#include <plat/cpu-freq-core.h> #include <plat/cpu-freq-core.h>
static struct cpufreq_frequency_table s3c2440_plls_169344[] __initdata = { static struct cpufreq_frequency_table s3c2440_plls_169344[] __initdata = {
{ .frequency = 78019200, .index = PLLVAL(121, 5, 3), }, /* FVco 624.153600 */ { .frequency = 78019200, .driver_data = PLLVAL(121, 5, 3), }, /* FVco 624.153600 */
{ .frequency = 84067200, .index = PLLVAL(131, 5, 3), }, /* FVco 672.537600 */ { .frequency = 84067200, .driver_data = PLLVAL(131, 5, 3), }, /* FVco 672.537600 */
{ .frequency = 90115200, .index = PLLVAL(141, 5, 3), }, /* FVco 720.921600 */ { .frequency = 90115200, .driver_data = PLLVAL(141, 5, 3), }, /* FVco 720.921600 */
{ .frequency = 96163200, .index = PLLVAL(151, 5, 3), }, /* FVco 769.305600 */ { .frequency = 96163200, .driver_data = PLLVAL(151, 5, 3), }, /* FVco 769.305600 */
{ .frequency = 102135600, .index = PLLVAL(185, 6, 3), }, /* FVco 817.084800 */ { .frequency = 102135600, .driver_data = PLLVAL(185, 6, 3), }, /* FVco 817.084800 */
{ .frequency = 108259200, .index = PLLVAL(171, 5, 3), }, /* FVco 866.073600 */ { .frequency = 108259200, .driver_data = PLLVAL(171, 5, 3), }, /* FVco 866.073600 */
{ .frequency = 114307200, .index = PLLVAL(127, 3, 3), }, /* FVco 914.457600 */ { .frequency = 114307200, .driver_data = PLLVAL(127, 3, 3), }, /* FVco 914.457600 */
{ .frequency = 120234240, .index = PLLVAL(134, 3, 3), }, /* FVco 961.873920 */ { .frequency = 120234240, .driver_data = PLLVAL(134, 3, 3), }, /* FVco 961.873920 */
{ .frequency = 126161280, .index = PLLVAL(141, 3, 3), }, /* FVco 1009.290240 */ { .frequency = 126161280, .driver_data = PLLVAL(141, 3, 3), }, /* FVco 1009.290240 */
{ .frequency = 132088320, .index = PLLVAL(148, 3, 3), }, /* FVco 1056.706560 */ { .frequency = 132088320, .driver_data = PLLVAL(148, 3, 3), }, /* FVco 1056.706560 */
{ .frequency = 138015360, .index = PLLVAL(155, 3, 3), }, /* FVco 1104.122880 */ { .frequency = 138015360, .driver_data = PLLVAL(155, 3, 3), }, /* FVco 1104.122880 */
{ .frequency = 144789120, .index = PLLVAL(163, 3, 3), }, /* FVco 1158.312960 */ { .frequency = 144789120, .driver_data = PLLVAL(163, 3, 3), }, /* FVco 1158.312960 */
{ .frequency = 150100363, .index = PLLVAL(187, 9, 2), }, /* FVco 600.401454 */ { .frequency = 150100363, .driver_data = PLLVAL(187, 9, 2), }, /* FVco 600.401454 */
{ .frequency = 156038400, .index = PLLVAL(121, 5, 2), }, /* FVco 624.153600 */ { .frequency = 156038400, .driver_data = PLLVAL(121, 5, 2), }, /* FVco 624.153600 */
{ .frequency = 162086400, .index = PLLVAL(126, 5, 2), }, /* FVco 648.345600 */ { .frequency = 162086400, .driver_data = PLLVAL(126, 5, 2), }, /* FVco 648.345600 */
{ .frequency = 168134400, .index = PLLVAL(131, 5, 2), }, /* FVco 672.537600 */ { .frequency = 168134400, .driver_data = PLLVAL(131, 5, 2), }, /* FVco 672.537600 */
{ .frequency = 174048000, .index = PLLVAL(177, 7, 2), }, /* FVco 696.192000 */ { .frequency = 174048000, .driver_data = PLLVAL(177, 7, 2), }, /* FVco 696.192000 */
{ .frequency = 180230400, .index = PLLVAL(141, 5, 2), }, /* FVco 720.921600 */ { .frequency = 180230400, .driver_data = PLLVAL(141, 5, 2), }, /* FVco 720.921600 */
{ .frequency = 186278400, .index = PLLVAL(124, 4, 2), }, /* FVco 745.113600 */ { .frequency = 186278400, .driver_data = PLLVAL(124, 4, 2), }, /* FVco 745.113600 */
{ .frequency = 192326400, .index = PLLVAL(151, 5, 2), }, /* FVco 769.305600 */ { .frequency = 192326400, .driver_data = PLLVAL(151, 5, 2), }, /* FVco 769.305600 */
{ .frequency = 198132480, .index = PLLVAL(109, 3, 2), }, /* FVco 792.529920 */ { .frequency = 198132480, .driver_data = PLLVAL(109, 3, 2), }, /* FVco 792.529920 */
{ .frequency = 204271200, .index = PLLVAL(185, 6, 2), }, /* FVco 817.084800 */ { .frequency = 204271200, .driver_data = PLLVAL(185, 6, 2), }, /* FVco 817.084800 */
{ .frequency = 210268800, .index = PLLVAL(141, 4, 2), }, /* FVco 841.075200 */ { .frequency = 210268800, .driver_data = PLLVAL(141, 4, 2), }, /* FVco 841.075200 */
{ .frequency = 216518400, .index = PLLVAL(171, 5, 2), }, /* FVco 866.073600 */ { .frequency = 216518400, .driver_data = PLLVAL(171, 5, 2), }, /* FVco 866.073600 */
{ .frequency = 222264000, .index = PLLVAL(97, 2, 2), }, /* FVco 889.056000 */ { .frequency = 222264000, .driver_data = PLLVAL(97, 2, 2), }, /* FVco 889.056000 */
{ .frequency = 228614400, .index = PLLVAL(127, 3, 2), }, /* FVco 914.457600 */ { .frequency = 228614400, .driver_data = PLLVAL(127, 3, 2), }, /* FVco 914.457600 */
{ .frequency = 234259200, .index = PLLVAL(158, 4, 2), }, /* FVco 937.036800 */ { .frequency = 234259200, .driver_data = PLLVAL(158, 4, 2), }, /* FVco 937.036800 */
{ .frequency = 240468480, .index = PLLVAL(134, 3, 2), }, /* FVco 961.873920 */ { .frequency = 240468480, .driver_data = PLLVAL(134, 3, 2), }, /* FVco 961.873920 */
{ .frequency = 246960000, .index = PLLVAL(167, 4, 2), }, /* FVco 987.840000 */ { .frequency = 246960000, .driver_data = PLLVAL(167, 4, 2), }, /* FVco 987.840000 */
{ .frequency = 252322560, .index = PLLVAL(141, 3, 2), }, /* FVco 1009.290240 */ { .frequency = 252322560, .driver_data = PLLVAL(141, 3, 2), }, /* FVco 1009.290240 */
{ .frequency = 258249600, .index = PLLVAL(114, 2, 2), }, /* FVco 1032.998400 */ { .frequency = 258249600, .driver_data = PLLVAL(114, 2, 2), }, /* FVco 1032.998400 */
{ .frequency = 264176640, .index = PLLVAL(148, 3, 2), }, /* FVco 1056.706560 */ { .frequency = 264176640, .driver_data = PLLVAL(148, 3, 2), }, /* FVco 1056.706560 */
{ .frequency = 270950400, .index = PLLVAL(120, 2, 2), }, /* FVco 1083.801600 */ { .frequency = 270950400, .driver_data = PLLVAL(120, 2, 2), }, /* FVco 1083.801600 */
{ .frequency = 276030720, .index = PLLVAL(155, 3, 2), }, /* FVco 1104.122880 */ { .frequency = 276030720, .driver_data = PLLVAL(155, 3, 2), }, /* FVco 1104.122880 */
{ .frequency = 282240000, .index = PLLVAL(92, 1, 2), }, /* FVco 1128.960000 */ { .frequency = 282240000, .driver_data = PLLVAL(92, 1, 2), }, /* FVco 1128.960000 */
{ .frequency = 289578240, .index = PLLVAL(163, 3, 2), }, /* FVco 1158.312960 */ { .frequency = 289578240, .driver_data = PLLVAL(163, 3, 2), }, /* FVco 1158.312960 */
{ .frequency = 294235200, .index = PLLVAL(131, 2, 2), }, /* FVco 1176.940800 */ { .frequency = 294235200, .driver_data = PLLVAL(131, 2, 2), }, /* FVco 1176.940800 */
{ .frequency = 300200727, .index = PLLVAL(187, 9, 1), }, /* FVco 600.401454 */ { .frequency = 300200727, .driver_data = PLLVAL(187, 9, 1), }, /* FVco 600.401454 */
{ .frequency = 306358690, .index = PLLVAL(191, 9, 1), }, /* FVco 612.717380 */ { .frequency = 306358690, .driver_data = PLLVAL(191, 9, 1), }, /* FVco 612.717380 */
{ .frequency = 312076800, .index = PLLVAL(121, 5, 1), }, /* FVco 624.153600 */ { .frequency = 312076800, .driver_data = PLLVAL(121, 5, 1), }, /* FVco 624.153600 */
{ .frequency = 318366720, .index = PLLVAL(86, 3, 1), }, /* FVco 636.733440 */ { .frequency = 318366720, .driver_data = PLLVAL(86, 3, 1), }, /* FVco 636.733440 */
{ .frequency = 324172800, .index = PLLVAL(126, 5, 1), }, /* FVco 648.345600 */ { .frequency = 324172800, .driver_data = PLLVAL(126, 5, 1), }, /* FVco 648.345600 */
{ .frequency = 330220800, .index = PLLVAL(109, 4, 1), }, /* FVco 660.441600 */ { .frequency = 330220800, .driver_data = PLLVAL(109, 4, 1), }, /* FVco 660.441600 */
{ .frequency = 336268800, .index = PLLVAL(131, 5, 1), }, /* FVco 672.537600 */ { .frequency = 336268800, .driver_data = PLLVAL(131, 5, 1), }, /* FVco 672.537600 */
{ .frequency = 342074880, .index = PLLVAL(93, 3, 1), }, /* FVco 684.149760 */ { .frequency = 342074880, .driver_data = PLLVAL(93, 3, 1), }, /* FVco 684.149760 */
{ .frequency = 348096000, .index = PLLVAL(177, 7, 1), }, /* FVco 696.192000 */ { .frequency = 348096000, .driver_data = PLLVAL(177, 7, 1), }, /* FVco 696.192000 */
{ .frequency = 355622400, .index = PLLVAL(118, 4, 1), }, /* FVco 711.244800 */ { .frequency = 355622400, .driver_data = PLLVAL(118, 4, 1), }, /* FVco 711.244800 */
{ .frequency = 360460800, .index = PLLVAL(141, 5, 1), }, /* FVco 720.921600 */ { .frequency = 360460800, .driver_data = PLLVAL(141, 5, 1), }, /* FVco 720.921600 */
{ .frequency = 366206400, .index = PLLVAL(165, 6, 1), }, /* FVco 732.412800 */ { .frequency = 366206400, .driver_data = PLLVAL(165, 6, 1), }, /* FVco 732.412800 */
{ .frequency = 372556800, .index = PLLVAL(124, 4, 1), }, /* FVco 745.113600 */ { .frequency = 372556800, .driver_data = PLLVAL(124, 4, 1), }, /* FVco 745.113600 */
{ .frequency = 378201600, .index = PLLVAL(126, 4, 1), }, /* FVco 756.403200 */ { .frequency = 378201600, .driver_data = PLLVAL(126, 4, 1), }, /* FVco 756.403200 */
{ .frequency = 384652800, .index = PLLVAL(151, 5, 1), }, /* FVco 769.305600 */ { .frequency = 384652800, .driver_data = PLLVAL(151, 5, 1), }, /* FVco 769.305600 */
{ .frequency = 391608000, .index = PLLVAL(177, 6, 1), }, /* FVco 783.216000 */ { .frequency = 391608000, .driver_data = PLLVAL(177, 6, 1), }, /* FVco 783.216000 */
{ .frequency = 396264960, .index = PLLVAL(109, 3, 1), }, /* FVco 792.529920 */ { .frequency = 396264960, .driver_data = PLLVAL(109, 3, 1), }, /* FVco 792.529920 */
{ .frequency = 402192000, .index = PLLVAL(87, 2, 1), }, /* FVco 804.384000 */ { .frequency = 402192000, .driver_data = PLLVAL(87, 2, 1), }, /* FVco 804.384000 */
}; };
static int s3c2440_plls169344_add(struct device *dev, static int s3c2440_plls169344_add(struct device *dev,
......
...@@ -142,15 +142,15 @@ static void pllc2_table_rebuild(struct clk *clk) ...@@ -142,15 +142,15 @@ static void pllc2_table_rebuild(struct clk *clk)
/* Initialise PLLC2 frequency table */ /* Initialise PLLC2 frequency table */
for (i = 0; i < ARRAY_SIZE(pllc2_freq_table) - 2; i++) { for (i = 0; i < ARRAY_SIZE(pllc2_freq_table) - 2; i++) {
pllc2_freq_table[i].frequency = clk->parent->rate * (i + 20) * 2; pllc2_freq_table[i].frequency = clk->parent->rate * (i + 20) * 2;
pllc2_freq_table[i].index = i; pllc2_freq_table[i].driver_data = i;
} }
/* This is a special entry - switching PLL off makes it a repeater */ /* This is a special entry - switching PLL off makes it a repeater */
pllc2_freq_table[i].frequency = clk->parent->rate; pllc2_freq_table[i].frequency = clk->parent->rate;
pllc2_freq_table[i].index = i; pllc2_freq_table[i].driver_data = i;
pllc2_freq_table[++i].frequency = CPUFREQ_TABLE_END; pllc2_freq_table[++i].frequency = CPUFREQ_TABLE_END;
pllc2_freq_table[i].index = i; pllc2_freq_table[i].driver_data = i;
} }
static unsigned long pllc2_recalc(struct clk *clk) static unsigned long pllc2_recalc(struct clk *clk)
......
...@@ -285,7 +285,7 @@ static inline int s3c_cpufreq_addfreq(struct cpufreq_frequency_table *table, ...@@ -285,7 +285,7 @@ static inline int s3c_cpufreq_addfreq(struct cpufreq_frequency_table *table,
s3c_freq_dbg("%s: { %d = %u kHz }\n", s3c_freq_dbg("%s: { %d = %u kHz }\n",
__func__, index, freq); __func__, index, freq);
table[index].index = index; table[index].driver_data = index;
table[index].frequency = freq; table[index].frequency = freq;
} }
......
...@@ -121,7 +121,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate) ...@@ -121,7 +121,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
clk->rate = rate; clk->rate = rate;
regval = LOONGSON_CHIPCFG0; regval = LOONGSON_CHIPCFG0;
regval = (regval & ~0x7) | (loongson2_clockmod_table[i].index - 1); regval = (regval & ~0x7) |
(loongson2_clockmod_table[i].driver_data - 1);
LOONGSON_CHIPCFG0 = regval; LOONGSON_CHIPCFG0 = regval;
return ret; return ret;
......
...@@ -193,37 +193,6 @@ config PPC_IO_WORKAROUNDS ...@@ -193,37 +193,6 @@ config PPC_IO_WORKAROUNDS
source "drivers/cpufreq/Kconfig" source "drivers/cpufreq/Kconfig"
menu "CPU Frequency drivers"
depends on CPU_FREQ
config CPU_FREQ_PMAC
bool "Support for Apple PowerBooks"
depends on ADB_PMU && PPC32
select CPU_FREQ_TABLE
help
This adds support for frequency switching on Apple PowerBooks,
this currently includes some models of iBook & Titanium
PowerBook.
config CPU_FREQ_PMAC64
bool "Support for some Apple G5s"
depends on PPC_PMAC && PPC64
select CPU_FREQ_TABLE
help
This adds support for frequency switching on Apple iMac G5,
and some of the more recent desktop G5 machines as well.
config PPC_PASEMI_CPUFREQ
bool "Support for PA Semi PWRficient"
depends on PPC_PASEMI
default y
select CPU_FREQ_TABLE
help
This adds the support for frequency switching on PA Semi
PWRficient processors.
endmenu
menu "CPUIdle driver" menu "CPUIdle driver"
source "drivers/cpuidle/Kconfig" source "drivers/cpuidle/Kconfig"
......
obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o dma_lib.o misc.o obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o dma_lib.o misc.o
obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o
obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += cpufreq.o
...@@ -9,8 +9,6 @@ obj-y += pic.o setup.o time.o feature.o pci.o \ ...@@ -9,8 +9,6 @@ obj-y += pic.o setup.o time.o feature.o pci.o \
sleep.o low_i2c.o cache.o pfunc_core.o \ sleep.o low_i2c.o cache.o pfunc_core.o \
pfunc_base.o udbg_scc.o udbg_adb.o pfunc_base.o udbg_scc.o udbg_adb.o
obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o
obj-$(CONFIG_CPU_FREQ_PMAC) += cpufreq_32.o
obj-$(CONFIG_CPU_FREQ_PMAC64) += cpufreq_64.o
# CONFIG_NVRAM is an arch. independent tristate symbol, for pmac32 we really # CONFIG_NVRAM is an arch. independent tristate symbol, for pmac32 we really
# need this to be a bool. Cheat here and pretend CONFIG_NVRAM=m is really # need this to be a bool. Cheat here and pretend CONFIG_NVRAM=m is really
# CONFIG_NVRAM=y # CONFIG_NVRAM=y
......
...@@ -648,14 +648,14 @@ int opp_init_cpufreq_table(struct device *dev, ...@@ -648,14 +648,14 @@ int opp_init_cpufreq_table(struct device *dev,
list_for_each_entry(opp, &dev_opp->opp_list, node) { list_for_each_entry(opp, &dev_opp->opp_list, node) {
if (opp->available) { if (opp->available) {
freq_table[i].index = i; freq_table[i].driver_data = i;
freq_table[i].frequency = opp->rate / 1000; freq_table[i].frequency = opp->rate / 1000;
i++; i++;
} }
} }
mutex_unlock(&dev_opp_list_lock); mutex_unlock(&dev_opp_list_lock);
freq_table[i].index = i; freq_table[i].driver_data = i;
freq_table[i].frequency = CPUFREQ_TABLE_END; freq_table[i].frequency = CPUFREQ_TABLE_END;
*table = &freq_table[0]; *table = &freq_table[0];
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
config ARM_BIG_LITTLE_CPUFREQ config ARM_BIG_LITTLE_CPUFREQ
tristate "Generic ARM big LITTLE CPUfreq driver" tristate "Generic ARM big LITTLE CPUfreq driver"
depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK depends on ARM_CPU_TOPOLOGY && PM_OPP && HAVE_CLK
select CPU_FREQ_TABLE
help help
This enables the Generic CPUfreq driver for ARM big.LITTLE platforms. This enables the Generic CPUfreq driver for ARM big.LITTLE platforms.
...@@ -88,6 +89,7 @@ config ARM_INTEGRATOR ...@@ -88,6 +89,7 @@ config ARM_INTEGRATOR
config ARM_KIRKWOOD_CPUFREQ config ARM_KIRKWOOD_CPUFREQ
def_bool ARCH_KIRKWOOD && OF def_bool ARCH_KIRKWOOD && OF
select CPU_FREQ_TABLE
help help
This adds the CPUFreq driver for Marvell Kirkwood This adds the CPUFreq driver for Marvell Kirkwood
SoCs. SoCs.
...@@ -151,6 +153,7 @@ config ARM_SA1110_CPUFREQ ...@@ -151,6 +153,7 @@ config ARM_SA1110_CPUFREQ
config ARM_SPEAR_CPUFREQ config ARM_SPEAR_CPUFREQ
bool "SPEAr CPUFreq support" bool "SPEAr CPUFreq support"
depends on PLAT_SPEAR depends on PLAT_SPEAR
select CPU_FREQ_TABLE
default y default y
help help
This adds the CPUFreq driver support for SPEAr SOCs. This adds the CPUFreq driver support for SPEAr SOCs.
......
...@@ -24,3 +24,39 @@ config CPU_FREQ_MAPLE ...@@ -24,3 +24,39 @@ config CPU_FREQ_MAPLE
help help
This adds support for frequency switching on Maple 970FX This adds support for frequency switching on Maple 970FX
Evaluation Board and compatible boards (IBM JS2x blades). Evaluation Board and compatible boards (IBM JS2x blades).
config PPC_CORENET_CPUFREQ
tristate "CPU frequency scaling driver for Freescale E500MC SoCs"
depends on PPC_E500MC && OF && COMMON_CLK
select CPU_FREQ_TABLE
select CLK_PPC_CORENET
help
This adds the CPUFreq driver support for Freescale e500mc,
e5500 and e6500 series SoCs which are capable of changing
the CPU's frequency dynamically.
config CPU_FREQ_PMAC
bool "Support for Apple PowerBooks"
depends on ADB_PMU && PPC32
select CPU_FREQ_TABLE
help
This adds support for frequency switching on Apple PowerBooks,
this currently includes some models of iBook & Titanium
PowerBook.
config CPU_FREQ_PMAC64
bool "Support for some Apple G5s"
depends on PPC_PMAC && PPC64
select CPU_FREQ_TABLE
help
This adds support for frequency switching on Apple iMac G5,
and some of the more recent desktop G5 machines as well.
config PPC_PASEMI_CPUFREQ
bool "Support for PA Semi PWRficient"
depends on PPC_PASEMI
select CPU_FREQ_TABLE
default y
help
This adds the support for frequency switching on PA Semi
PWRficient processors.
...@@ -79,6 +79,10 @@ obj-$(CONFIG_CPU_FREQ_CBE) += ppc-cbe-cpufreq.o ...@@ -79,6 +79,10 @@ obj-$(CONFIG_CPU_FREQ_CBE) += ppc-cbe-cpufreq.o
ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o
obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o
obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o
obj-$(CONFIG_PPC_CORENET_CPUFREQ) += ppc-corenet-cpufreq.o
obj-$(CONFIG_CPU_FREQ_PMAC) += pmac32-cpufreq.o
obj-$(CONFIG_CPU_FREQ_PMAC64) += pmac64-cpufreq.o
obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += pasemi-cpufreq.o
################################################################################## ##################################################################################
# Other platform drivers # Other platform drivers
......
...@@ -232,7 +232,7 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data) ...@@ -232,7 +232,7 @@ static unsigned extract_msr(u32 msr, struct acpi_cpufreq_data *data)
perf = data->acpi_data; perf = data->acpi_data;
for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { for (i = 0; data->freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
if (msr == perf->states[data->freq_table[i].index].status) if (msr == perf->states[data->freq_table[i].driver_data].status)
return data->freq_table[i].frequency; return data->freq_table[i].frequency;
} }
return data->freq_table[0].frequency; return data->freq_table[0].frequency;
...@@ -442,7 +442,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -442,7 +442,7 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
goto out; goto out;
} }
next_perf_state = data->freq_table[next_state].index; next_perf_state = data->freq_table[next_state].driver_data;
if (perf->state == next_perf_state) { if (perf->state == next_perf_state) {
if (unlikely(data->resume)) { if (unlikely(data->resume)) {
pr_debug("Called after resume, resetting to P%d\n", pr_debug("Called after resume, resetting to P%d\n",
...@@ -494,12 +494,14 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, ...@@ -494,12 +494,14 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
pr_debug("acpi_cpufreq_target failed (%d)\n", pr_debug("acpi_cpufreq_target failed (%d)\n",
policy->cpu); policy->cpu);
result = -EAGAIN; result = -EAGAIN;
goto out; freqs.new = freqs.old;
} }
} }
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
perf->state = next_perf_state;
if (!result)
perf->state = next_perf_state;
out: out:
return result; return result;
...@@ -811,7 +813,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) ...@@ -811,7 +813,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
data->freq_table[valid_states-1].frequency / 1000) data->freq_table[valid_states-1].frequency / 1000)
continue; continue;
data->freq_table[valid_states].index = i; data->freq_table[valid_states].driver_data = i;
data->freq_table[valid_states].frequency = data->freq_table[valid_states].frequency =
perf->states[i].core_frequency * 1000; perf->states[i].core_frequency * 1000;
valid_states++; valid_states++;
...@@ -947,7 +949,7 @@ static void __init acpi_cpufreq_boost_init(void) ...@@ -947,7 +949,7 @@ static void __init acpi_cpufreq_boost_init(void)
/* We create the boost file in any case, though for systems without /* We create the boost file in any case, though for systems without
* hardware support it will be read-only and hardwired to return 0. * hardware support it will be read-only and hardwired to return 0.
*/ */
if (sysfs_create_file(cpufreq_global_kobject, &(global_boost.attr))) if (cpufreq_sysfs_create_file(&(global_boost.attr)))
pr_warn(PFX "could not register global boost sysfs file\n"); pr_warn(PFX "could not register global boost sysfs file\n");
else else
pr_debug("registered global boost sysfs file\n"); pr_debug("registered global boost sysfs file\n");
...@@ -955,7 +957,7 @@ static void __init acpi_cpufreq_boost_init(void) ...@@ -955,7 +957,7 @@ static void __init acpi_cpufreq_boost_init(void)
static void __exit acpi_cpufreq_boost_exit(void) static void __exit acpi_cpufreq_boost_exit(void)
{ {
sysfs_remove_file(cpufreq_global_kobject, &(global_boost.attr)); cpufreq_sysfs_remove_file(&(global_boost.attr));
if (msrs) { if (msrs) {
unregister_cpu_notifier(&boost_nb); unregister_cpu_notifier(&boost_nb);
......
...@@ -20,23 +20,23 @@ ...@@ -20,23 +20,23 @@
/* this is the table of CCLK frequencies, in Hz */ /* this is the table of CCLK frequencies, in Hz */
/* .index is the entry in the auxiliary dpm_state_table[] */ /* .driver_data is the entry in the auxiliary dpm_state_table[] */
static struct cpufreq_frequency_table bfin_freq_table[] = { static struct cpufreq_frequency_table bfin_freq_table[] = {
{ {
.frequency = CPUFREQ_TABLE_END, .frequency = CPUFREQ_TABLE_END,
.index = 0, .driver_data = 0,
}, },
{ {
.frequency = CPUFREQ_TABLE_END, .frequency = CPUFREQ_TABLE_END,
.index = 1, .driver_data = 1,
}, },
{ {
.frequency = CPUFREQ_TABLE_END, .frequency = CPUFREQ_TABLE_END,
.index = 2, .driver_data = 2,
}, },
{ {
.frequency = CPUFREQ_TABLE_END, .frequency = CPUFREQ_TABLE_END,
.index = 0, .driver_data = 0,
}, },
}; };
......
This diff is collapsed.
...@@ -23,21 +23,12 @@ ...@@ -23,21 +23,12 @@
#include <linux/kernel_stat.h> #include <linux/kernel_stat.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/tick.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include "cpufreq_governor.h" #include "cpufreq_governor.h"
static struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy)
{
if (have_governor_per_policy())
return &policy->kobj;
else
return cpufreq_global_kobject;
}
static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data)
{ {
if (have_governor_per_policy()) if (have_governor_per_policy())
...@@ -46,41 +37,6 @@ static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) ...@@ -46,41 +37,6 @@ static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data)
return dbs_data->cdata->attr_group_gov_sys; return dbs_data->cdata->attr_group_gov_sys;
} }
static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall)
{
u64 idle_time;
u64 cur_wall_time;
u64 busy_time;
cur_wall_time = jiffies64_to_cputime64(get_jiffies_64());
busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER];
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM];
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ];
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ];
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL];
busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE];
idle_time = cur_wall_time - busy_time;
if (wall)
*wall = cputime_to_usecs(cur_wall_time);
return cputime_to_usecs(idle_time);
}
u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy)
{
u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL);
if (idle_time == -1ULL)
return get_cpu_idle_time_jiffy(cpu, wall);
else if (!io_busy)
idle_time += get_cpu_iowait_time_us(cpu, wall);
return idle_time;
}
EXPORT_SYMBOL_GPL(get_cpu_idle_time);
void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
{ {
struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); 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,6 +234,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
return rc; return rc;
} }
if (!have_governor_per_policy())
WARN_ON(cpufreq_get_global_kobject());
rc = sysfs_create_group(get_governor_parent_kobj(policy), rc = sysfs_create_group(get_governor_parent_kobj(policy),
get_sysfs_attr(dbs_data)); get_sysfs_attr(dbs_data));
if (rc) { if (rc) {
...@@ -316,6 +275,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, ...@@ -316,6 +275,9 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
sysfs_remove_group(get_governor_parent_kobj(policy), sysfs_remove_group(get_governor_parent_kobj(policy),
get_sysfs_attr(dbs_data)); get_sysfs_attr(dbs_data));
if (!have_governor_per_policy())
cpufreq_put_global_kobject();
if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) && if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
(policy->governor->initialized == 1)) { (policy->governor->initialized == 1)) {
struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
......
...@@ -81,7 +81,7 @@ static ssize_t show_##file_name##_gov_sys \ ...@@ -81,7 +81,7 @@ static ssize_t show_##file_name##_gov_sys \
return sprintf(buf, "%u\n", tuners->file_name); \ return sprintf(buf, "%u\n", tuners->file_name); \
} \ } \
\ \
static ssize_t show_##file_name##_gov_pol \ static ssize_t show_##file_name##_gov_pol \
(struct cpufreq_policy *policy, char *buf) \ (struct cpufreq_policy *policy, char *buf) \
{ \ { \
struct dbs_data *dbs_data = policy->governor_data; \ struct dbs_data *dbs_data = policy->governor_data; \
...@@ -91,7 +91,7 @@ static ssize_t show_##file_name##_gov_pol \ ...@@ -91,7 +91,7 @@ static ssize_t show_##file_name##_gov_pol \
#define store_one(_gov, file_name) \ #define store_one(_gov, file_name) \
static ssize_t store_##file_name##_gov_sys \ static ssize_t store_##file_name##_gov_sys \
(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \ (struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) \
{ \ { \
struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \ struct dbs_data *dbs_data = _gov##_dbs_cdata.gdbs_data; \
return store_##file_name(dbs_data, buf, count); \ return store_##file_name(dbs_data, buf, count); \
...@@ -256,7 +256,6 @@ static ssize_t show_sampling_rate_min_gov_pol \ ...@@ -256,7 +256,6 @@ static ssize_t show_sampling_rate_min_gov_pol \
return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \ return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \
} }
u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy);
void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); void dbs_check_cpu(struct dbs_data *dbs_data, int cpu);
bool need_load_eval(struct cpu_dbs_common_info *cdbs, bool need_load_eval(struct cpu_dbs_common_info *cdbs,
unsigned int sampling_rate); unsigned int sampling_rate);
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <linux/init.h> #include <linux/init.h>
static int cpufreq_governor_performance(struct cpufreq_policy *policy, static int cpufreq_governor_performance(struct cpufreq_policy *policy,
unsigned int event) unsigned int event)
{ {
...@@ -44,19 +43,16 @@ struct cpufreq_governor cpufreq_gov_performance = { ...@@ -44,19 +43,16 @@ struct cpufreq_governor cpufreq_gov_performance = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int __init cpufreq_gov_performance_init(void) static int __init cpufreq_gov_performance_init(void)
{ {
return cpufreq_register_governor(&cpufreq_gov_performance); return cpufreq_register_governor(&cpufreq_gov_performance);
} }
static void __exit cpufreq_gov_performance_exit(void) static void __exit cpufreq_gov_performance_exit(void)
{ {
cpufreq_unregister_governor(&cpufreq_gov_performance); cpufreq_unregister_governor(&cpufreq_gov_performance);
} }
MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>");
MODULE_DESCRIPTION("CPUfreq policy governor 'performance'"); MODULE_DESCRIPTION("CPUfreq policy governor 'performance'");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
/* /*
* linux/drivers/cpufreq/cpufreq_powersave.c * linux/drivers/cpufreq/cpufreq_powersave.c
* *
* Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> * Copyright (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
* *
* *
* This program is free software; you can redistribute it and/or modify * 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,13 +48,11 @@ static int __init cpufreq_gov_powersave_init(void)
return cpufreq_register_governor(&cpufreq_gov_powersave); return cpufreq_register_governor(&cpufreq_gov_powersave);
} }
static void __exit cpufreq_gov_powersave_exit(void) static void __exit cpufreq_gov_powersave_exit(void)
{ {
cpufreq_unregister_governor(&cpufreq_gov_powersave); cpufreq_unregister_governor(&cpufreq_gov_powersave);
} }
MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>"); MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>");
MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'"); MODULE_DESCRIPTION("CPUfreq policy governor 'powersave'");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
...@@ -27,7 +27,7 @@ static spinlock_t cpufreq_stats_lock; ...@@ -27,7 +27,7 @@ static spinlock_t cpufreq_stats_lock;
struct cpufreq_stats { struct cpufreq_stats {
unsigned int cpu; unsigned int cpu;
unsigned int total_trans; unsigned int total_trans;
unsigned long long last_time; unsigned long long last_time;
unsigned int max_state; unsigned int max_state;
unsigned int state_num; unsigned int state_num;
unsigned int last_index; unsigned int last_index;
...@@ -116,7 +116,7 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) ...@@ -116,7 +116,7 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ", len += snprintf(buf + len, PAGE_SIZE - len, "%9u: ",
stat->freq_table[i]); stat->freq_table[i]);
for (j = 0; j < stat->state_num; j++) { for (j = 0; j < stat->state_num; j++) {
if (len >= PAGE_SIZE) if (len >= PAGE_SIZE)
break; break;
len += snprintf(buf + len, PAGE_SIZE - len, "%9u ", len += snprintf(buf + len, PAGE_SIZE - len, "%9u ",
......
...@@ -13,55 +13,13 @@ ...@@ -13,55 +13,13 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/smp.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/cpufreq.h> #include <linux/cpufreq.h>
#include <linux/cpu.h> #include <linux/init.h>
#include <linux/types.h> #include <linux/module.h>
#include <linux/fs.h>
#include <linux/sysfs.h>
#include <linux/mutex.h> #include <linux/mutex.h>
/**
* A few values needed by the userspace governor
*/
static DEFINE_PER_CPU(unsigned int, cpu_max_freq);
static DEFINE_PER_CPU(unsigned int, cpu_min_freq);
static DEFINE_PER_CPU(unsigned int, cpu_cur_freq); /* current CPU freq */
static DEFINE_PER_CPU(unsigned int, cpu_set_freq); /* CPU freq desired by
userspace */
static DEFINE_PER_CPU(unsigned int, cpu_is_managed); static DEFINE_PER_CPU(unsigned int, cpu_is_managed);
static DEFINE_MUTEX(userspace_mutex); static DEFINE_MUTEX(userspace_mutex);
static int cpus_using_userspace_governor;
/* keep track of frequency transitions */
static int
userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
void *data)
{
struct cpufreq_freqs *freq = data;
if (!per_cpu(cpu_is_managed, freq->cpu))
return 0;
if (val == CPUFREQ_POSTCHANGE) {
pr_debug("saving cpu_cur_freq of cpu %u to be %u kHz\n",
freq->cpu, freq->new);
per_cpu(cpu_cur_freq, freq->cpu) = freq->new;
}
return 0;
}
static struct notifier_block userspace_cpufreq_notifier_block = {
.notifier_call = userspace_cpufreq_notifier
};
/** /**
* cpufreq_set - set the CPU frequency * cpufreq_set - set the CPU frequency
...@@ -80,13 +38,6 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq) ...@@ -80,13 +38,6 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq)
if (!per_cpu(cpu_is_managed, policy->cpu)) if (!per_cpu(cpu_is_managed, policy->cpu))
goto err; goto err;
per_cpu(cpu_set_freq, policy->cpu) = freq;
if (freq < per_cpu(cpu_min_freq, policy->cpu))
freq = per_cpu(cpu_min_freq, policy->cpu);
if (freq > per_cpu(cpu_max_freq, policy->cpu))
freq = per_cpu(cpu_max_freq, policy->cpu);
/* /*
* We're safe from concurrent calls to ->target() here * We're safe from concurrent calls to ->target() here
* as we hold the userspace_mutex lock. If we were calling * 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,10 +55,9 @@ static int cpufreq_set(struct cpufreq_policy *policy, unsigned int freq)
return ret; return ret;
} }
static ssize_t show_speed(struct cpufreq_policy *policy, char *buf) static ssize_t show_speed(struct cpufreq_policy *policy, char *buf)
{ {
return sprintf(buf, "%u\n", per_cpu(cpu_cur_freq, policy->cpu)); return sprintf(buf, "%u\n", policy->cur);
} }
static int cpufreq_governor_userspace(struct cpufreq_policy *policy, static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
...@@ -119,73 +69,37 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy, ...@@ -119,73 +69,37 @@ static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
switch (event) { switch (event) {
case CPUFREQ_GOV_START: case CPUFREQ_GOV_START:
BUG_ON(!policy->cur); BUG_ON(!policy->cur);
mutex_lock(&userspace_mutex); pr_debug("started managing cpu %u\n", cpu);
if (cpus_using_userspace_governor == 0) {
cpufreq_register_notifier(
&userspace_cpufreq_notifier_block,
CPUFREQ_TRANSITION_NOTIFIER);
}
cpus_using_userspace_governor++;
mutex_lock(&userspace_mutex);
per_cpu(cpu_is_managed, cpu) = 1; per_cpu(cpu_is_managed, cpu) = 1;
per_cpu(cpu_min_freq, cpu) = policy->min;
per_cpu(cpu_max_freq, cpu) = policy->max;
per_cpu(cpu_cur_freq, cpu) = policy->cur;
per_cpu(cpu_set_freq, cpu) = policy->cur;
pr_debug("managing cpu %u started "
"(%u - %u kHz, currently %u kHz)\n",
cpu,
per_cpu(cpu_min_freq, cpu),
per_cpu(cpu_max_freq, cpu),
per_cpu(cpu_cur_freq, cpu));
mutex_unlock(&userspace_mutex); mutex_unlock(&userspace_mutex);
break; break;
case CPUFREQ_GOV_STOP: case CPUFREQ_GOV_STOP:
mutex_lock(&userspace_mutex); pr_debug("managing cpu %u stopped\n", cpu);
cpus_using_userspace_governor--;
if (cpus_using_userspace_governor == 0) {
cpufreq_unregister_notifier(
&userspace_cpufreq_notifier_block,
CPUFREQ_TRANSITION_NOTIFIER);
}
mutex_lock(&userspace_mutex);
per_cpu(cpu_is_managed, cpu) = 0; per_cpu(cpu_is_managed, cpu) = 0;
per_cpu(cpu_min_freq, cpu) = 0;
per_cpu(cpu_max_freq, cpu) = 0;
per_cpu(cpu_set_freq, cpu) = 0;
pr_debug("managing cpu %u stopped\n", cpu);
mutex_unlock(&userspace_mutex); mutex_unlock(&userspace_mutex);
break; break;
case CPUFREQ_GOV_LIMITS: case CPUFREQ_GOV_LIMITS:
mutex_lock(&userspace_mutex); mutex_lock(&userspace_mutex);
pr_debug("limit event for cpu %u: %u - %u kHz, " pr_debug("limit event for cpu %u: %u - %u kHz, currently %u kHz\n",
"currently %u kHz, last set to %u kHz\n",
cpu, policy->min, policy->max, cpu, policy->min, policy->max,
per_cpu(cpu_cur_freq, cpu), policy->cur);
per_cpu(cpu_set_freq, cpu));
if (policy->max < per_cpu(cpu_set_freq, cpu)) { if (policy->max < policy->cur)
__cpufreq_driver_target(policy, policy->max, __cpufreq_driver_target(policy, policy->max,
CPUFREQ_RELATION_H); CPUFREQ_RELATION_H);
} else if (policy->min > per_cpu(cpu_set_freq, cpu)) { else if (policy->min > policy->cur)
__cpufreq_driver_target(policy, policy->min, __cpufreq_driver_target(policy, policy->min,
CPUFREQ_RELATION_L); CPUFREQ_RELATION_L);
} else {
__cpufreq_driver_target(policy,
per_cpu(cpu_set_freq, cpu),
CPUFREQ_RELATION_L);
}
per_cpu(cpu_min_freq, cpu) = policy->min;
per_cpu(cpu_max_freq, cpu) = policy->max;
per_cpu(cpu_cur_freq, cpu) = policy->cur;
mutex_unlock(&userspace_mutex); mutex_unlock(&userspace_mutex);
break; break;
} }
return rc; return rc;
} }
#ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE
static static
#endif #endif
...@@ -202,13 +116,11 @@ static int __init cpufreq_gov_userspace_init(void) ...@@ -202,13 +116,11 @@ static int __init cpufreq_gov_userspace_init(void)
return cpufreq_register_governor(&cpufreq_gov_userspace); return cpufreq_register_governor(&cpufreq_gov_userspace);
} }
static void __exit cpufreq_gov_userspace_exit(void) static void __exit cpufreq_gov_userspace_exit(void)
{ {
cpufreq_unregister_governor(&cpufreq_gov_userspace); cpufreq_unregister_governor(&cpufreq_gov_userspace);
} }
MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, " MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>, "
"Russell King <rmk@arm.linux.org.uk>"); "Russell King <rmk@arm.linux.org.uk>");
MODULE_DESCRIPTION("CPUfreq policy governor 'userspace'"); MODULE_DESCRIPTION("CPUfreq policy governor 'userspace'");
......
...@@ -161,6 +161,9 @@ static int eps_set_state(struct eps_cpu_data *centaur, ...@@ -161,6 +161,9 @@ static int eps_set_state(struct eps_cpu_data *centaur,
current_multiplier); current_multiplier);
} }
#endif #endif
if (err)
freqs.new = freqs.old;
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
return err; return err;
} }
...@@ -188,7 +191,7 @@ static int eps_target(struct cpufreq_policy *policy, ...@@ -188,7 +191,7 @@ static int eps_target(struct cpufreq_policy *policy,
} }
/* Make frequency transition */ /* Make frequency transition */
dest_state = centaur->freq_table[newstate].index & 0xffff; dest_state = centaur->freq_table[newstate].driver_data & 0xffff;
ret = eps_set_state(centaur, policy, dest_state); ret = eps_set_state(centaur, policy, dest_state);
if (ret) if (ret)
printk(KERN_ERR "eps: Timeout!\n"); printk(KERN_ERR "eps: Timeout!\n");
...@@ -380,9 +383,9 @@ static int eps_cpu_init(struct cpufreq_policy *policy) ...@@ -380,9 +383,9 @@ static int eps_cpu_init(struct cpufreq_policy *policy)
f_table = &centaur->freq_table[0]; f_table = &centaur->freq_table[0];
if (brand != EPS_BRAND_C7M) { if (brand != EPS_BRAND_C7M) {
f_table[0].frequency = fsb * min_multiplier; f_table[0].frequency = fsb * min_multiplier;
f_table[0].index = (min_multiplier << 8) | min_voltage; f_table[0].driver_data = (min_multiplier << 8) | min_voltage;
f_table[1].frequency = fsb * max_multiplier; f_table[1].frequency = fsb * max_multiplier;
f_table[1].index = (max_multiplier << 8) | max_voltage; f_table[1].driver_data = (max_multiplier << 8) | max_voltage;
f_table[2].frequency = CPUFREQ_TABLE_END; f_table[2].frequency = CPUFREQ_TABLE_END;
} else { } else {
k = 0; k = 0;
...@@ -391,7 +394,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy) ...@@ -391,7 +394,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy)
for (i = min_multiplier; i <= max_multiplier; i++) { for (i = min_multiplier; i <= max_multiplier; i++) {
voltage = (k * step) / 256 + min_voltage; voltage = (k * step) / 256 + min_voltage;
f_table[k].frequency = fsb * i; f_table[k].frequency = fsb * i;
f_table[k].index = (i << 8) | voltage; f_table[k].driver_data = (i << 8) | voltage;
k++; k++;
} }
f_table[k].frequency = CPUFREQ_TABLE_END; f_table[k].frequency = CPUFREQ_TABLE_END;
......
...@@ -34,8 +34,8 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, ...@@ -34,8 +34,8 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
continue; continue;
} }
pr_debug("table entry %u: %u kHz, %u index\n", pr_debug("table entry %u: %u kHz, %u driver_data\n",
i, freq, table[i].index); i, freq, table[i].driver_data);
if (freq < min_freq) if (freq < min_freq)
min_freq = freq; min_freq = freq;
if (freq > max_freq) if (freq > max_freq)
...@@ -97,11 +97,11 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, ...@@ -97,11 +97,11 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
unsigned int *index) unsigned int *index)
{ {
struct cpufreq_frequency_table optimal = { struct cpufreq_frequency_table optimal = {
.index = ~0, .driver_data = ~0,
.frequency = 0, .frequency = 0,
}; };
struct cpufreq_frequency_table suboptimal = { struct cpufreq_frequency_table suboptimal = {
.index = ~0, .driver_data = ~0,
.frequency = 0, .frequency = 0,
}; };
unsigned int i; unsigned int i;
...@@ -129,12 +129,12 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, ...@@ -129,12 +129,12 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
if (freq <= target_freq) { if (freq <= target_freq) {
if (freq >= optimal.frequency) { if (freq >= optimal.frequency) {
optimal.frequency = freq; optimal.frequency = freq;
optimal.index = i; optimal.driver_data = i;
} }
} else { } else {
if (freq <= suboptimal.frequency) { if (freq <= suboptimal.frequency) {
suboptimal.frequency = freq; suboptimal.frequency = freq;
suboptimal.index = i; suboptimal.driver_data = i;
} }
} }
break; break;
...@@ -142,26 +142,26 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, ...@@ -142,26 +142,26 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
if (freq >= target_freq) { if (freq >= target_freq) {
if (freq <= optimal.frequency) { if (freq <= optimal.frequency) {
optimal.frequency = freq; optimal.frequency = freq;
optimal.index = i; optimal.driver_data = i;
} }
} else { } else {
if (freq >= suboptimal.frequency) { if (freq >= suboptimal.frequency) {
suboptimal.frequency = freq; suboptimal.frequency = freq;
suboptimal.index = i; suboptimal.driver_data = i;
} }
} }
break; break;
} }
} }
if (optimal.index > i) { if (optimal.driver_data > i) {
if (suboptimal.index > i) if (suboptimal.driver_data > i)
return -EINVAL; return -EINVAL;
*index = suboptimal.index; *index = suboptimal.driver_data;
} else } else
*index = optimal.index; *index = optimal.driver_data;
pr_debug("target is %u (%u kHz, %u)\n", *index, table[*index].frequency, pr_debug("target is %u (%u kHz, %u)\n", *index, table[*index].frequency,
table[*index].index); table[*index].driver_data);
return 0; return 0;
} }
......
...@@ -326,7 +326,7 @@ acpi_cpufreq_cpu_init ( ...@@ -326,7 +326,7 @@ acpi_cpufreq_cpu_init (
/* table init */ /* table init */
for (i = 0; i <= data->acpi_data.state_count; i++) for (i = 0; i <= data->acpi_data.state_count; i++)
{ {
data->freq_table[i].index = i; data->freq_table[i].driver_data = i;
if (i < data->acpi_data.state_count) { if (i < data->acpi_data.state_count) {
data->freq_table[i].frequency = data->freq_table[i].frequency =
data->acpi_data.states[i].core_frequency * 1000; data->acpi_data.states[i].core_frequency * 1000;
......
...@@ -59,7 +59,7 @@ static void kirkwood_cpufreq_set_cpu_state(struct cpufreq_policy *policy, ...@@ -59,7 +59,7 @@ static void kirkwood_cpufreq_set_cpu_state(struct cpufreq_policy *policy,
unsigned int index) unsigned int index)
{ {
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
unsigned int state = kirkwood_freq_table[index].index; unsigned int state = kirkwood_freq_table[index].driver_data;
unsigned long reg; unsigned long reg;
freqs.old = kirkwood_cpufreq_get_cpu_frequency(0); freqs.old = kirkwood_cpufreq_get_cpu_frequency(0);
......
...@@ -254,7 +254,7 @@ static void longhaul_setstate(struct cpufreq_policy *policy, ...@@ -254,7 +254,7 @@ static void longhaul_setstate(struct cpufreq_policy *policy,
u32 bm_timeout = 1000; u32 bm_timeout = 1000;
unsigned int dir = 0; unsigned int dir = 0;
mults_index = longhaul_table[table_index].index; mults_index = longhaul_table[table_index].driver_data;
/* Safety precautions */ /* Safety precautions */
mult = mults[mults_index & 0x1f]; mult = mults[mults_index & 0x1f];
if (mult == -1) if (mult == -1)
...@@ -487,7 +487,7 @@ static int __cpuinit longhaul_get_ranges(void) ...@@ -487,7 +487,7 @@ static int __cpuinit longhaul_get_ranges(void)
if (ratio > maxmult || ratio < minmult) if (ratio > maxmult || ratio < minmult)
continue; continue;
longhaul_table[k].frequency = calc_speed(ratio); longhaul_table[k].frequency = calc_speed(ratio);
longhaul_table[k].index = j; longhaul_table[k].driver_data = j;
k++; k++;
} }
if (k <= 1) { if (k <= 1) {
...@@ -508,8 +508,8 @@ static int __cpuinit longhaul_get_ranges(void) ...@@ -508,8 +508,8 @@ static int __cpuinit longhaul_get_ranges(void)
if (min_i != j) { if (min_i != j) {
swap(longhaul_table[j].frequency, swap(longhaul_table[j].frequency,
longhaul_table[min_i].frequency); longhaul_table[min_i].frequency);
swap(longhaul_table[j].index, swap(longhaul_table[j].driver_data,
longhaul_table[min_i].index); longhaul_table[min_i].driver_data);
} }
} }
...@@ -517,7 +517,7 @@ static int __cpuinit longhaul_get_ranges(void) ...@@ -517,7 +517,7 @@ static int __cpuinit longhaul_get_ranges(void)
/* Find index we are running on */ /* Find index we are running on */
for (j = 0; j < k; j++) { for (j = 0; j < k; j++) {
if (mults[longhaul_table[j].index & 0x1f] == mult) { if (mults[longhaul_table[j].driver_data & 0x1f] == mult) {
longhaul_index = j; longhaul_index = j;
break; break;
} }
...@@ -613,7 +613,7 @@ static void __cpuinit longhaul_setup_voltagescaling(void) ...@@ -613,7 +613,7 @@ static void __cpuinit longhaul_setup_voltagescaling(void)
pos = (speed - min_vid_speed) / kHz_step + minvid.pos; pos = (speed - min_vid_speed) / kHz_step + minvid.pos;
else else
pos = minvid.pos; pos = minvid.pos;
longhaul_table[j].index |= mV_vrm_table[pos] << 8; longhaul_table[j].driver_data |= mV_vrm_table[pos] << 8;
vid = vrm_mV_table[mV_vrm_table[pos]]; vid = vrm_mV_table[mV_vrm_table[pos]];
printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n", printk(KERN_INFO PFX "f: %d kHz, index: %d, vid: %d mV\n",
speed, j, vid.mV); speed, j, vid.mV);
...@@ -656,12 +656,12 @@ static int longhaul_target(struct cpufreq_policy *policy, ...@@ -656,12 +656,12 @@ static int longhaul_target(struct cpufreq_policy *policy,
* this in hardware, C3 is old and we need to do this * this in hardware, C3 is old and we need to do this
* in software. */ * in software. */
i = longhaul_index; i = longhaul_index;
current_vid = (longhaul_table[longhaul_index].index >> 8); current_vid = (longhaul_table[longhaul_index].driver_data >> 8);
current_vid &= 0x1f; current_vid &= 0x1f;
if (table_index > longhaul_index) if (table_index > longhaul_index)
dir = 1; dir = 1;
while (i != table_index) { while (i != table_index) {
vid = (longhaul_table[i].index >> 8) & 0x1f; vid = (longhaul_table[i].driver_data >> 8) & 0x1f;
if (vid != current_vid) { if (vid != current_vid) {
longhaul_setstate(policy, i); longhaul_setstate(policy, i);
current_vid = vid; current_vid = vid;
......
...@@ -72,7 +72,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy, ...@@ -72,7 +72,7 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
freq = freq =
((cpu_clock_freq / 1000) * ((cpu_clock_freq / 1000) *
loongson2_clockmod_table[newstate].index) / 8; loongson2_clockmod_table[newstate].driver_data) / 8;
if (freq < policy->min || freq > policy->max) if (freq < policy->min || freq > policy->max)
return -EINVAL; return -EINVAL;
......
...@@ -118,7 +118,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, ...@@ -118,7 +118,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
return -EINVAL; return -EINVAL;
freqs.old = cpufreq_p4_get(policy->cpu); freqs.old = cpufreq_p4_get(policy->cpu);
freqs.new = stock_freq * p4clockmod_table[newstate].index / 8; freqs.new = stock_freq * p4clockmod_table[newstate].driver_data / 8;
if (freqs.new == freqs.old) if (freqs.new == freqs.old)
return 0; return 0;
...@@ -131,7 +131,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, ...@@ -131,7 +131,7 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
* Developer's Manual, Volume 3 * Developer's Manual, Volume 3
*/ */
for_each_cpu(i, policy->cpus) for_each_cpu(i, policy->cpus)
cpufreq_p4_setdc(i, p4clockmod_table[newstate].index); cpufreq_p4_setdc(i, p4clockmod_table[newstate].driver_data);
/* notifiers */ /* notifiers */
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
......
...@@ -204,7 +204,8 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) ...@@ -204,7 +204,8 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
/* initialize frequency table */ /* initialize frequency table */
for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {
pas_freqs[i].frequency = get_astate_freq(pas_freqs[i].index) * 100000; pas_freqs[i].frequency =
get_astate_freq(pas_freqs[i].driver_data) * 100000;
pr_debug("%d: %d\n", i, pas_freqs[i].frequency); pr_debug("%d: %d\n", i, pas_freqs[i].frequency);
} }
...@@ -280,7 +281,7 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy, ...@@ -280,7 +281,7 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy,
pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n",
policy->cpu, policy->cpu,
pas_freqs[pas_astate_new].frequency, pas_freqs[pas_astate_new].frequency,
pas_freqs[pas_astate_new].index); pas_freqs[pas_astate_new].driver_data);
current_astate = pas_astate_new; current_astate = pas_astate_new;
......
...@@ -243,6 +243,8 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy, ...@@ -243,6 +243,8 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy,
return 0; return 0;
cmd_incomplete: cmd_incomplete:
freqs.new = freqs.old;
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
iowrite16(0, &pcch_hdr->status); iowrite16(0, &pcch_hdr->status);
spin_unlock(&pcc_lock); spin_unlock(&pcc_lock);
return -EINVAL; return -EINVAL;
......
...@@ -58,7 +58,7 @@ static int powernow_k6_get_cpu_multiplier(void) ...@@ -58,7 +58,7 @@ static int powernow_k6_get_cpu_multiplier(void)
msrval = POWERNOW_IOPORT + 0x0; msrval = POWERNOW_IOPORT + 0x0;
wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */ wrmsr(MSR_K6_EPMR, msrval, 0); /* disable it again */
return clock_ratio[(invalue >> 5)&7].index; return clock_ratio[(invalue >> 5)&7].driver_data;
} }
...@@ -75,13 +75,13 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy, ...@@ -75,13 +75,13 @@ static void powernow_k6_set_state(struct cpufreq_policy *policy,
unsigned long msrval; unsigned long msrval;
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
if (clock_ratio[best_i].index > max_multiplier) { if (clock_ratio[best_i].driver_data > max_multiplier) {
printk(KERN_ERR PFX "invalid target frequency\n"); printk(KERN_ERR PFX "invalid target frequency\n");
return; return;
} }
freqs.old = busfreq * powernow_k6_get_cpu_multiplier(); freqs.old = busfreq * powernow_k6_get_cpu_multiplier();
freqs.new = busfreq * clock_ratio[best_i].index; freqs.new = busfreq * clock_ratio[best_i].driver_data;
cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
...@@ -156,7 +156,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) ...@@ -156,7 +156,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
/* table init */ /* table init */
for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) { for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
f = clock_ratio[i].index; f = clock_ratio[i].driver_data;
if (f > max_multiplier) if (f > max_multiplier)
clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID; clock_ratio[i].frequency = CPUFREQ_ENTRY_INVALID;
else else
......
...@@ -186,7 +186,7 @@ static int get_ranges(unsigned char *pst) ...@@ -186,7 +186,7 @@ static int get_ranges(unsigned char *pst)
fid = *pst++; fid = *pst++;
powernow_table[j].frequency = (fsb * fid_codes[fid]) / 10; powernow_table[j].frequency = (fsb * fid_codes[fid]) / 10;
powernow_table[j].index = fid; /* lower 8 bits */ powernow_table[j].driver_data = fid; /* lower 8 bits */
speed = powernow_table[j].frequency; speed = powernow_table[j].frequency;
...@@ -203,7 +203,7 @@ static int get_ranges(unsigned char *pst) ...@@ -203,7 +203,7 @@ static int get_ranges(unsigned char *pst)
maximum_speed = speed; maximum_speed = speed;
vid = *pst++; vid = *pst++;
powernow_table[j].index |= (vid << 8); /* upper 8 bits */ powernow_table[j].driver_data |= (vid << 8); /* upper 8 bits */
pr_debug(" FID: 0x%x (%d.%dx [%dMHz]) " pr_debug(" FID: 0x%x (%d.%dx [%dMHz]) "
"VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10, "VID: 0x%x (%d.%03dV)\n", fid, fid_codes[fid] / 10,
...@@ -212,7 +212,7 @@ static int get_ranges(unsigned char *pst) ...@@ -212,7 +212,7 @@ static int get_ranges(unsigned char *pst)
mobile_vid_table[vid]%1000); mobile_vid_table[vid]%1000);
} }
powernow_table[number_scales].frequency = CPUFREQ_TABLE_END; powernow_table[number_scales].frequency = CPUFREQ_TABLE_END;
powernow_table[number_scales].index = 0; powernow_table[number_scales].driver_data = 0;
return 0; return 0;
} }
...@@ -260,8 +260,8 @@ static void change_speed(struct cpufreq_policy *policy, unsigned int index) ...@@ -260,8 +260,8 @@ static void change_speed(struct cpufreq_policy *policy, unsigned int index)
* vid are the upper 8 bits. * vid are the upper 8 bits.
*/ */
fid = powernow_table[index].index & 0xFF; fid = powernow_table[index].driver_data & 0xFF;
vid = (powernow_table[index].index & 0xFF00) >> 8; vid = (powernow_table[index].driver_data & 0xFF00) >> 8;
rdmsrl(MSR_K7_FID_VID_STATUS, fidvidstatus.val); rdmsrl(MSR_K7_FID_VID_STATUS, fidvidstatus.val);
cfid = fidvidstatus.bits.CFID; cfid = fidvidstatus.bits.CFID;
...@@ -373,8 +373,8 @@ static int powernow_acpi_init(void) ...@@ -373,8 +373,8 @@ static int powernow_acpi_init(void)
fid = pc.bits.fid; fid = pc.bits.fid;
powernow_table[i].frequency = fsb * fid_codes[fid] / 10; powernow_table[i].frequency = fsb * fid_codes[fid] / 10;
powernow_table[i].index = fid; /* lower 8 bits */ powernow_table[i].driver_data = fid; /* lower 8 bits */
powernow_table[i].index |= (vid << 8); /* upper 8 bits */ powernow_table[i].driver_data |= (vid << 8); /* upper 8 bits */
speed = powernow_table[i].frequency; speed = powernow_table[i].frequency;
speed_mhz = speed / 1000; speed_mhz = speed / 1000;
...@@ -417,7 +417,7 @@ static int powernow_acpi_init(void) ...@@ -417,7 +417,7 @@ static int powernow_acpi_init(void)
} }
powernow_table[i].frequency = CPUFREQ_TABLE_END; powernow_table[i].frequency = CPUFREQ_TABLE_END;
powernow_table[i].index = 0; powernow_table[i].driver_data = 0;
/* notify BIOS that we exist */ /* notify BIOS that we exist */
acpi_processor_notify_smm(THIS_MODULE); acpi_processor_notify_smm(THIS_MODULE);
......
...@@ -584,9 +584,9 @@ static void print_basics(struct powernow_k8_data *data) ...@@ -584,9 +584,9 @@ static void print_basics(struct powernow_k8_data *data)
CPUFREQ_ENTRY_INVALID) { CPUFREQ_ENTRY_INVALID) {
printk(KERN_INFO PFX printk(KERN_INFO PFX
"fid 0x%x (%d MHz), vid 0x%x\n", "fid 0x%x (%d MHz), vid 0x%x\n",
data->powernow_table[j].index & 0xff, data->powernow_table[j].driver_data & 0xff,
data->powernow_table[j].frequency/1000, data->powernow_table[j].frequency/1000,
data->powernow_table[j].index >> 8); data->powernow_table[j].driver_data >> 8);
} }
} }
if (data->batps) if (data->batps)
...@@ -632,13 +632,13 @@ static int fill_powernow_table(struct powernow_k8_data *data, ...@@ -632,13 +632,13 @@ static int fill_powernow_table(struct powernow_k8_data *data,
for (j = 0; j < data->numps; j++) { for (j = 0; j < data->numps; j++) {
int freq; int freq;
powernow_table[j].index = pst[j].fid; /* lower 8 bits */ powernow_table[j].driver_data = pst[j].fid; /* lower 8 bits */
powernow_table[j].index |= (pst[j].vid << 8); /* upper 8 bits */ powernow_table[j].driver_data |= (pst[j].vid << 8); /* upper 8 bits */
freq = find_khz_freq_from_fid(pst[j].fid); freq = find_khz_freq_from_fid(pst[j].fid);
powernow_table[j].frequency = freq; powernow_table[j].frequency = freq;
} }
powernow_table[data->numps].frequency = CPUFREQ_TABLE_END; powernow_table[data->numps].frequency = CPUFREQ_TABLE_END;
powernow_table[data->numps].index = 0; powernow_table[data->numps].driver_data = 0;
if (query_current_values_with_pending_wait(data)) { if (query_current_values_with_pending_wait(data)) {
kfree(powernow_table); kfree(powernow_table);
...@@ -810,7 +810,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) ...@@ -810,7 +810,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
powernow_table[data->acpi_data.state_count].frequency = powernow_table[data->acpi_data.state_count].frequency =
CPUFREQ_TABLE_END; CPUFREQ_TABLE_END;
powernow_table[data->acpi_data.state_count].index = 0; powernow_table[data->acpi_data.state_count].driver_data = 0;
data->powernow_table = powernow_table; data->powernow_table = powernow_table;
if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu) 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,7 +865,7 @@ static int fill_powernow_table_fidvid(struct powernow_k8_data *data,
pr_debug(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid); pr_debug(" %d : fid 0x%x, vid 0x%x\n", i, fid, vid);
index = fid | (vid<<8); index = fid | (vid<<8);
powernow_table[i].index = index; powernow_table[i].driver_data = index;
freq = find_khz_freq_from_fid(fid); freq = find_khz_freq_from_fid(fid);
powernow_table[i].frequency = freq; powernow_table[i].frequency = freq;
...@@ -941,8 +941,8 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, ...@@ -941,8 +941,8 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data,
* the cpufreq frequency table in find_psb_table, vid * the cpufreq frequency table in find_psb_table, vid
* are the upper 8 bits. * are the upper 8 bits.
*/ */
fid = data->powernow_table[index].index & 0xFF; fid = data->powernow_table[index].driver_data & 0xFF;
vid = (data->powernow_table[index].index & 0xFF00) >> 8; vid = (data->powernow_table[index].driver_data & 0xFF00) >> 8;
pr_debug("table matched fid 0x%x, giving vid 0x%x\n", fid, vid); pr_debug("table matched fid 0x%x, giving vid 0x%x\n", fid, vid);
...@@ -967,9 +967,9 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, ...@@ -967,9 +967,9 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data,
res = transition_fid_vid(data, fid, vid); res = transition_fid_vid(data, fid, vid);
if (res) if (res)
return res; freqs.new = freqs.old;
else
freqs.new = find_khz_freq_from_fid(data->currfid); freqs.new = find_khz_freq_from_fid(data->currfid);
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
return res; return res;
......
/*
* Copyright 2013 Freescale Semiconductor, Inc.
*
* CPU Frequency Scaling driver for Freescale PowerPC corenet SoCs.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/clk.h>
#include <linux/cpufreq.h>
#include <linux/errno.h>
#include <sysdev/fsl_soc.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/smp.h>
/**
* struct cpu_data - per CPU data struct
* @clk: the clk of CPU
* @parent: the parent node of cpu clock
* @table: frequency table
*/
struct cpu_data {
struct clk *clk;
struct device_node *parent;
struct cpufreq_frequency_table *table;
};
/**
* struct soc_data - SoC specific data
* @freq_mask: mask the disallowed frequencies
* @flag: unique flags
*/
struct soc_data {
u32 freq_mask[4];
u32 flag;
};
#define FREQ_MASK 1
/* see hardware specification for the allowed frqeuencies */
static const struct soc_data sdata[] = {
{ /* used by p2041 and p3041 */
.freq_mask = {0x8, 0x8, 0x2, 0x2},
.flag = FREQ_MASK,
},
{ /* used by p5020 */
.freq_mask = {0x8, 0x2},
.flag = FREQ_MASK,
},
{ /* used by p4080, p5040 */
.freq_mask = {0},
.flag = 0,
},
};
/*
* the minimum allowed core frequency, in Hz
* for chassis v1.0, >= platform frequency
* for chassis v2.0, >= platform frequency / 2
*/
static u32 min_cpufreq;
static const u32 *fmask;
/* serialize frequency changes */
static DEFINE_MUTEX(cpufreq_lock);
static DEFINE_PER_CPU(struct cpu_data *, cpu_data);
/* cpumask in a cluster */
static DEFINE_PER_CPU(cpumask_var_t, cpu_mask);
#ifndef CONFIG_SMP
static inline const struct cpumask *cpu_core_mask(int cpu)
{
return cpumask_of(0);
}
#endif
static unsigned int corenet_cpufreq_get_speed(unsigned int cpu)
{
struct cpu_data *data = per_cpu(cpu_data, cpu);
return clk_get_rate(data->clk) / 1000;
}
/* reduce the duplicated frequencies in frequency table */
static void freq_table_redup(struct cpufreq_frequency_table *freq_table,
int count)
{
int i, j;
for (i = 1; i < count; i++) {
for (j = 0; j < i; j++) {
if (freq_table[j].frequency == CPUFREQ_ENTRY_INVALID ||
freq_table[j].frequency !=
freq_table[i].frequency)
continue;
freq_table[i].frequency = CPUFREQ_ENTRY_INVALID;
break;
}
}
}
/* sort the frequencies in frequency table in descenting order */
static void freq_table_sort(struct cpufreq_frequency_table *freq_table,
int count)
{
int i, j, ind;
unsigned int freq, max_freq;
struct cpufreq_frequency_table table;
for (i = 0; i < count - 1; i++) {
max_freq = freq_table[i].frequency;
ind = i;
for (j = i + 1; j < count; j++) {
freq = freq_table[j].frequency;
if (freq == CPUFREQ_ENTRY_INVALID ||
freq <= max_freq)
continue;
ind = j;
max_freq = freq;
}
if (ind != i) {
/* exchange the frequencies */
table.driver_data = freq_table[i].driver_data;
table.frequency = freq_table[i].frequency;
freq_table[i].driver_data = freq_table[ind].driver_data;
freq_table[i].frequency = freq_table[ind].frequency;
freq_table[ind].driver_data = table.driver_data;
freq_table[ind].frequency = table.frequency;
}
}
}
static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
struct device_node *np;
int i, count, ret;
u32 freq, mask;
struct clk *clk;
struct cpufreq_frequency_table *table;
struct cpu_data *data;
unsigned int cpu = policy->cpu;
np = of_get_cpu_node(cpu, NULL);
if (!np)
return -ENODEV;
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) {
pr_err("%s: no memory\n", __func__);
goto err_np;
}
data->clk = of_clk_get(np, 0);
if (IS_ERR(data->clk)) {
pr_err("%s: no clock information\n", __func__);
goto err_nomem2;
}
data->parent = of_parse_phandle(np, "clocks", 0);
if (!data->parent) {
pr_err("%s: could not get clock information\n", __func__);
goto err_nomem2;
}
count = of_property_count_strings(data->parent, "clock-names");
table = kcalloc(count + 1, sizeof(*table), GFP_KERNEL);
if (!table) {
pr_err("%s: no memory\n", __func__);
goto err_node;
}
if (fmask)
mask = fmask[get_hard_smp_processor_id(cpu)];
else
mask = 0x0;
for (i = 0; i < count; i++) {
clk = of_clk_get(data->parent, i);
freq = clk_get_rate(clk);
/*
* the clock is valid if its frequency is not masked
* and large than minimum allowed frequency.
*/
if (freq < min_cpufreq || (mask & (1 << i)))
table[i].frequency = CPUFREQ_ENTRY_INVALID;
else
table[i].frequency = freq / 1000;
table[i].driver_data = i;
}
freq_table_redup(table, count);
freq_table_sort(table, count);
table[i].frequency = CPUFREQ_TABLE_END;
/* set the min and max frequency properly */
ret = cpufreq_frequency_table_cpuinfo(policy, table);
if (ret) {
pr_err("invalid frequency table: %d\n", ret);
goto err_nomem1;
}
data->table = table;
per_cpu(cpu_data, cpu) = data;
/* update ->cpus if we have cluster, no harm if not */
cpumask_copy(policy->cpus, per_cpu(cpu_mask, cpu));
for_each_cpu(i, per_cpu(cpu_mask, cpu))
per_cpu(cpu_data, i) = data;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = corenet_cpufreq_get_speed(policy->cpu);
cpufreq_frequency_table_get_attr(table, cpu);
of_node_put(np);
return 0;
err_nomem1:
kfree(table);
err_node:
of_node_put(data->parent);
err_nomem2:
per_cpu(cpu_data, cpu) = NULL;
kfree(data);
err_np:
of_node_put(np);
return -ENODEV;
}
static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy)
{
struct cpu_data *data = per_cpu(cpu_data, policy->cpu);
unsigned int cpu;
cpufreq_frequency_table_put_attr(policy->cpu);
of_node_put(data->parent);
kfree(data->table);
kfree(data);
for_each_cpu(cpu, per_cpu(cpu_mask, policy->cpu))
per_cpu(cpu_data, cpu) = NULL;
return 0;
}
static int corenet_cpufreq_verify(struct cpufreq_policy *policy)
{
struct cpufreq_frequency_table *table =
per_cpu(cpu_data, policy->cpu)->table;
return cpufreq_frequency_table_verify(policy, table);
}
static int corenet_cpufreq_target(struct cpufreq_policy *policy,
unsigned int target_freq, unsigned int relation)
{
struct cpufreq_freqs freqs;
unsigned int new;
struct clk *parent;
int ret;
struct cpu_data *data = per_cpu(cpu_data, policy->cpu);
cpufreq_frequency_table_target(policy, data->table,
target_freq, relation, &new);
if (policy->cur == data->table[new].frequency)
return 0;
freqs.old = policy->cur;
freqs.new = data->table[new].frequency;
mutex_lock(&cpufreq_lock);
cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE);
parent = of_clk_get(data->parent, data->table[new].driver_data);
ret = clk_set_parent(data->clk, parent);
if (ret)
freqs.new = freqs.old;
cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
mutex_unlock(&cpufreq_lock);
return ret;
}
static struct freq_attr *corenet_cpufreq_attr[] = {
&cpufreq_freq_attr_scaling_available_freqs,
NULL,
};
static struct cpufreq_driver ppc_corenet_cpufreq_driver = {
.name = "ppc_cpufreq",
.owner = THIS_MODULE,
.flags = CPUFREQ_CONST_LOOPS,
.init = corenet_cpufreq_cpu_init,
.exit = __exit_p(corenet_cpufreq_cpu_exit),
.verify = corenet_cpufreq_verify,
.target = corenet_cpufreq_target,
.get = corenet_cpufreq_get_speed,
.attr = corenet_cpufreq_attr,
};
static const struct of_device_id node_matches[] __initdata = {
{ .compatible = "fsl,p2041-clockgen", .data = &sdata[0], },
{ .compatible = "fsl,p3041-clockgen", .data = &sdata[0], },
{ .compatible = "fsl,p5020-clockgen", .data = &sdata[1], },
{ .compatible = "fsl,p4080-clockgen", .data = &sdata[2], },
{ .compatible = "fsl,p5040-clockgen", .data = &sdata[2], },
{ .compatible = "fsl,qoriq-clockgen-2.0", },
{}
};
static int __init ppc_corenet_cpufreq_init(void)
{
int ret;
struct device_node *np;
const struct of_device_id *match;
const struct soc_data *data;
unsigned int cpu;
np = of_find_matching_node(NULL, node_matches);
if (!np)
return -ENODEV;
for_each_possible_cpu(cpu) {
if (!alloc_cpumask_var(&per_cpu(cpu_mask, cpu), GFP_KERNEL))
goto err_mask;
cpumask_copy(per_cpu(cpu_mask, cpu), cpu_core_mask(cpu));
}
match = of_match_node(node_matches, np);
data = match->data;
if (data) {
if (data->flag)
fmask = data->freq_mask;
min_cpufreq = fsl_get_sys_freq();
} else {
min_cpufreq = fsl_get_sys_freq() / 2;
}
of_node_put(np);
ret = cpufreq_register_driver(&ppc_corenet_cpufreq_driver);
if (!ret)
pr_info("Freescale PowerPC corenet CPU frequency scaling driver\n");
return ret;
err_mask:
for_each_possible_cpu(cpu)
free_cpumask_var(per_cpu(cpu_mask, cpu));
return -ENOMEM;
}
module_init(ppc_corenet_cpufreq_init);
static void __exit ppc_corenet_cpufreq_exit(void)
{
unsigned int cpu;
for_each_possible_cpu(cpu)
free_cpumask_var(per_cpu(cpu_mask, cpu));
cpufreq_unregister_driver(&ppc_corenet_cpufreq_driver);
}
module_exit(ppc_corenet_cpufreq_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Tang Yuantian <Yuantian.Tang@freescale.com>");
MODULE_DESCRIPTION("cpufreq driver for Freescale e500mc series SoCs");
...@@ -106,7 +106,7 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) ...@@ -106,7 +106,7 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
/* initialize frequency table */ /* initialize frequency table */
for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {
cbe_freqs[i].frequency = max_freq / cbe_freqs[i].index; cbe_freqs[i].frequency = max_freq / cbe_freqs[i].driver_data;
pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); pr_debug("%d: %d\n", i, cbe_freqs[i].frequency);
} }
...@@ -165,7 +165,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy, ...@@ -165,7 +165,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy,
"1/%d of max frequency\n", "1/%d of max frequency\n",
policy->cpu, policy->cpu,
cbe_freqs[cbe_pmode_new].frequency, cbe_freqs[cbe_pmode_new].frequency,
cbe_freqs[cbe_pmode_new].index); cbe_freqs[cbe_pmode_new].driver_data);
rc = set_pmode(policy->cpu, cbe_pmode_new); rc = set_pmode(policy->cpu, cbe_pmode_new);
......
...@@ -420,7 +420,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) ...@@ -420,7 +420,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
/* Generate pxa25x the run cpufreq_frequency_table struct */ /* Generate pxa25x the run cpufreq_frequency_table struct */
for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) { for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) {
pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz; pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz;
pxa255_run_freq_table[i].index = i; pxa255_run_freq_table[i].driver_data = i;
} }
pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END; pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END;
...@@ -428,7 +428,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) ...@@ -428,7 +428,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
for (i = 0; i < NUM_PXA25x_TURBO_FREQS; i++) { for (i = 0; i < NUM_PXA25x_TURBO_FREQS; i++) {
pxa255_turbo_freq_table[i].frequency = pxa255_turbo_freq_table[i].frequency =
pxa255_turbo_freqs[i].khz; pxa255_turbo_freqs[i].khz;
pxa255_turbo_freq_table[i].index = i; pxa255_turbo_freq_table[i].driver_data = i;
} }
pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END; pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END;
...@@ -440,9 +440,9 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy) ...@@ -440,9 +440,9 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)
if (freq > pxa27x_maxfreq) if (freq > pxa27x_maxfreq)
break; break;
pxa27x_freq_table[i].frequency = freq; pxa27x_freq_table[i].frequency = freq;
pxa27x_freq_table[i].index = i; pxa27x_freq_table[i].driver_data = i;
} }
pxa27x_freq_table[i].index = i; pxa27x_freq_table[i].driver_data = i;
pxa27x_freq_table[i].frequency = CPUFREQ_TABLE_END; pxa27x_freq_table[i].frequency = CPUFREQ_TABLE_END;
/* /*
......
...@@ -98,10 +98,10 @@ static int setup_freqs_table(struct cpufreq_policy *policy, ...@@ -98,10 +98,10 @@ static int setup_freqs_table(struct cpufreq_policy *policy,
return -ENOMEM; return -ENOMEM;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
table[i].index = i; table[i].driver_data = i;
table[i].frequency = freqs[i].cpufreq_mhz * 1000; table[i].frequency = freqs[i].cpufreq_mhz * 1000;
} }
table[num].index = i; table[num].driver_data = i;
table[num].frequency = CPUFREQ_TABLE_END; table[num].frequency = CPUFREQ_TABLE_END;
pxa3xx_freqs = freqs; pxa3xx_freqs = freqs;
......
...@@ -244,7 +244,7 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy, ...@@ -244,7 +244,7 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy,
if (ret != 0) if (ret != 0)
goto out; goto out;
idx = s3c_freq->freq_table[i].index; idx = s3c_freq->freq_table[i].driver_data;
if (idx == SOURCE_HCLK) if (idx == SOURCE_HCLK)
to_dvs = 1; to_dvs = 1;
......
...@@ -87,7 +87,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, ...@@ -87,7 +87,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,
freqs.old = clk_get_rate(armclk) / 1000; freqs.old = clk_get_rate(armclk) / 1000;
freqs.new = s3c64xx_freq_table[i].frequency; freqs.new = s3c64xx_freq_table[i].frequency;
freqs.flags = 0; freqs.flags = 0;
dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[i].index]; dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[i].driver_data];
if (freqs.old == freqs.new) if (freqs.old == freqs.new)
return 0; return 0;
......
...@@ -71,7 +71,7 @@ static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy, ...@@ -71,7 +71,7 @@ static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy,
local_irq_disable(); local_irq_disable();
clockspeed_reg = *cpuctl & ~0x03; clockspeed_reg = *cpuctl & ~0x03;
*cpuctl = clockspeed_reg | sc520_freq_table[state].index; *cpuctl = clockspeed_reg | sc520_freq_table[state].driver_data;
local_irq_enable(); local_irq_enable();
......
...@@ -308,17 +308,17 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) ...@@ -308,17 +308,17 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
struct cpufreq_frequency_table *table = struct cpufreq_frequency_table *table =
&us2e_freq_table[cpu].table[0]; &us2e_freq_table[cpu].table[0];
table[0].index = 0; table[0].driver_data = 0;
table[0].frequency = clock_tick / 1; table[0].frequency = clock_tick / 1;
table[1].index = 1; table[1].driver_data = 1;
table[1].frequency = clock_tick / 2; table[1].frequency = clock_tick / 2;
table[2].index = 2; table[2].driver_data = 2;
table[2].frequency = clock_tick / 4; table[2].frequency = clock_tick / 4;
table[2].index = 3; table[2].driver_data = 3;
table[2].frequency = clock_tick / 6; table[2].frequency = clock_tick / 6;
table[2].index = 4; table[2].driver_data = 4;
table[2].frequency = clock_tick / 8; table[2].frequency = clock_tick / 8;
table[2].index = 5; table[2].driver_data = 5;
table[3].frequency = CPUFREQ_TABLE_END; table[3].frequency = CPUFREQ_TABLE_END;
policy->cpuinfo.transition_latency = 0; policy->cpuinfo.transition_latency = 0;
......
...@@ -169,13 +169,13 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy) ...@@ -169,13 +169,13 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
struct cpufreq_frequency_table *table = struct cpufreq_frequency_table *table =
&us3_freq_table[cpu].table[0]; &us3_freq_table[cpu].table[0];
table[0].index = 0; table[0].driver_data = 0;
table[0].frequency = clock_tick / 1; table[0].frequency = clock_tick / 1;
table[1].index = 1; table[1].driver_data = 1;
table[1].frequency = clock_tick / 2; table[1].frequency = clock_tick / 2;
table[2].index = 2; table[2].driver_data = 2;
table[2].frequency = clock_tick / 32; table[2].frequency = clock_tick / 32;
table[3].index = 0; table[3].driver_data = 0;
table[3].frequency = CPUFREQ_TABLE_END; table[3].frequency = CPUFREQ_TABLE_END;
policy->cpuinfo.transition_latency = 0; policy->cpuinfo.transition_latency = 0;
......
...@@ -250,11 +250,11 @@ static int spear_cpufreq_driver_init(void) ...@@ -250,11 +250,11 @@ static int spear_cpufreq_driver_init(void)
} }
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
freq_tbl[i].index = i; freq_tbl[i].driver_data = i;
freq_tbl[i].frequency = be32_to_cpup(val++); freq_tbl[i].frequency = be32_to_cpup(val++);
} }
freq_tbl[i].index = i; freq_tbl[i].driver_data = i;
freq_tbl[i].frequency = CPUFREQ_TABLE_END; freq_tbl[i].frequency = CPUFREQ_TABLE_END;
spear_cpufreq.freq_tbl = freq_tbl; spear_cpufreq.freq_tbl = freq_tbl;
......
...@@ -79,11 +79,11 @@ static struct cpufreq_driver centrino_driver; ...@@ -79,11 +79,11 @@ static struct cpufreq_driver centrino_driver;
/* Computes the correct form for IA32_PERF_CTL MSR for a particular /* Computes the correct form for IA32_PERF_CTL MSR for a particular
frequency/voltage operating point; frequency in MHz, volts in mV. frequency/voltage operating point; frequency in MHz, volts in mV.
This is stored as "index" in the structure. */ This is stored as "driver_data" in the structure. */
#define OP(mhz, mv) \ #define OP(mhz, mv) \
{ \ { \
.frequency = (mhz) * 1000, \ .frequency = (mhz) * 1000, \
.index = (((mhz)/100) << 8) | ((mv - 700) / 16) \ .driver_data = (((mhz)/100) << 8) | ((mv - 700) / 16) \
} }
/* /*
...@@ -307,7 +307,7 @@ static unsigned extract_clock(unsigned msr, unsigned int cpu, int failsafe) ...@@ -307,7 +307,7 @@ static unsigned extract_clock(unsigned msr, unsigned int cpu, int failsafe)
per_cpu(centrino_model, cpu)->op_points[i].frequency per_cpu(centrino_model, cpu)->op_points[i].frequency
!= CPUFREQ_TABLE_END; != CPUFREQ_TABLE_END;
i++) { i++) {
if (msr == per_cpu(centrino_model, cpu)->op_points[i].index) if (msr == per_cpu(centrino_model, cpu)->op_points[i].driver_data)
return per_cpu(centrino_model, cpu)-> return per_cpu(centrino_model, cpu)->
op_points[i].frequency; op_points[i].frequency;
} }
...@@ -501,7 +501,7 @@ static int centrino_target (struct cpufreq_policy *policy, ...@@ -501,7 +501,7 @@ static int centrino_target (struct cpufreq_policy *policy,
break; break;
} }
msr = per_cpu(centrino_model, cpu)->op_points[newstate].index; msr = per_cpu(centrino_model, cpu)->op_points[newstate].driver_data;
if (first_cpu) { if (first_cpu) {
rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h); rdmsr_on_cpu(good_cpu, MSR_IA32_PERF_CTL, &oldmsr, &h);
......
...@@ -28,17 +28,16 @@ ...@@ -28,17 +28,16 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/suspend.h> #include <linux/suspend.h>
/* Frequency table index must be sequential starting at 0 */
static struct cpufreq_frequency_table freq_table[] = { static struct cpufreq_frequency_table freq_table[] = {
{ 0, 216000 }, { .frequency = 216000 },
{ 1, 312000 }, { .frequency = 312000 },
{ 2, 456000 }, { .frequency = 456000 },
{ 3, 608000 }, { .frequency = 608000 },
{ 4, 760000 }, { .frequency = 760000 },
{ 5, 816000 }, { .frequency = 816000 },
{ 6, 912000 }, { .frequency = 912000 },
{ 7, 1000000 }, { .frequency = 1000000 },
{ 8, CPUFREQ_TABLE_END }, { .frequency = CPUFREQ_TABLE_END },
}; };
#define NUM_CPUS 2 #define NUM_CPUS 2
......
...@@ -1724,9 +1724,9 @@ static long round_clock_rate(u8 clock, unsigned long rate) ...@@ -1724,9 +1724,9 @@ static long round_clock_rate(u8 clock, unsigned long rate)
/* CPU FREQ table, may be changed due to if MAX_OPP is supported. */ /* CPU FREQ table, may be changed due to if MAX_OPP is supported. */
static struct cpufreq_frequency_table db8500_cpufreq_table[] = { static struct cpufreq_frequency_table db8500_cpufreq_table[] = {
{ .frequency = 200000, .index = ARM_EXTCLK,}, { .frequency = 200000, .driver_data = ARM_EXTCLK,},
{ .frequency = 400000, .index = ARM_50_OPP,}, { .frequency = 400000, .driver_data = ARM_50_OPP,},
{ .frequency = 800000, .index = ARM_100_OPP,}, { .frequency = 800000, .driver_data = ARM_100_OPP,},
{ .frequency = CPUFREQ_TABLE_END,}, /* To be used for MAX_OPP. */ { .frequency = CPUFREQ_TABLE_END,}, /* To be used for MAX_OPP. */
{ .frequency = CPUFREQ_TABLE_END,}, { .frequency = CPUFREQ_TABLE_END,},
}; };
...@@ -1901,7 +1901,7 @@ static int set_armss_rate(unsigned long rate) ...@@ -1901,7 +1901,7 @@ static int set_armss_rate(unsigned long rate)
return -EINVAL; return -EINVAL;
/* Set the new arm opp. */ /* Set the new arm opp. */
return db8500_prcmu_set_arm_opp(db8500_cpufreq_table[i].index); return db8500_prcmu_set_arm_opp(db8500_cpufreq_table[i].driver_data);
} }
static int set_plldsi_rate(unsigned long rate) static int set_plldsi_rate(unsigned long rate)
...@@ -3105,7 +3105,7 @@ static void db8500_prcmu_update_cpufreq(void) ...@@ -3105,7 +3105,7 @@ static void db8500_prcmu_update_cpufreq(void)
{ {
if (prcmu_has_arm_maxopp()) { if (prcmu_has_arm_maxopp()) {
db8500_cpufreq_table[3].frequency = 1000000; db8500_cpufreq_table[3].frequency = 1000000;
db8500_cpufreq_table[3].index = ARM_MAX_OPP; db8500_cpufreq_table[3].driver_data = ARM_MAX_OPP;
} }
} }
......
...@@ -63,12 +63,12 @@ void clk_rate_table_build(struct clk *clk, ...@@ -63,12 +63,12 @@ void clk_rate_table_build(struct clk *clk,
else else
freq = clk->parent->rate * mult / div; freq = clk->parent->rate * mult / div;
freq_table[i].index = i; freq_table[i].driver_data = i;
freq_table[i].frequency = freq; freq_table[i].frequency = freq;
} }
/* Termination entry */ /* Termination entry */
freq_table[i].index = i; freq_table[i].driver_data = i;
freq_table[i].frequency = CPUFREQ_TABLE_END; freq_table[i].frequency = CPUFREQ_TABLE_END;
} }
......
/* /*
* linux/include/linux/cpufreq.h * linux/include/linux/cpufreq.h
* *
* Copyright (C) 2001 Russell King * Copyright (C) 2001 Russell King
* (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de> * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
/* Print length for names. Extra 1 space for accomodating '\n' in prints */ /* Print length for names. Extra 1 space for accomodating '\n' in prints */
#define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1) #define CPUFREQ_NAME_PLEN (CPUFREQ_NAME_LEN + 1)
/********************************************************************* /*********************************************************************
* CPUFREQ NOTIFIER INTERFACE * * CPUFREQ NOTIFIER INTERFACE *
*********************************************************************/ *********************************************************************/
...@@ -71,6 +70,10 @@ struct cpufreq_governor; ...@@ -71,6 +70,10 @@ struct cpufreq_governor;
/* /sys/devices/system/cpu/cpufreq: entry point for global variables */ /* /sys/devices/system/cpu/cpufreq: entry point for global variables */
extern struct kobject *cpufreq_global_kobject; extern struct kobject *cpufreq_global_kobject;
int cpufreq_get_global_kobject(void);
void cpufreq_put_global_kobject(void);
int cpufreq_sysfs_create_file(const struct attribute *attr);
void cpufreq_sysfs_remove_file(const struct attribute *attr);
#define CPUFREQ_ETERNAL (-1) #define CPUFREQ_ETERNAL (-1)
struct cpufreq_cpuinfo { struct cpufreq_cpuinfo {
...@@ -107,6 +110,7 @@ struct cpufreq_policy { ...@@ -107,6 +110,7 @@ struct cpufreq_policy {
unsigned int policy; /* see above */ unsigned int policy; /* see above */
struct cpufreq_governor *governor; /* see below */ struct cpufreq_governor *governor; /* see below */
void *governor_data; void *governor_data;
bool governor_enabled; /* governor start/stop flag */
struct work_struct update; /* if update_policy() needs to be struct work_struct update; /* if update_policy() needs to be
* called, but you're in IRQ context */ * called, but you're in IRQ context */
...@@ -148,17 +152,18 @@ struct cpufreq_freqs { ...@@ -148,17 +152,18 @@ struct cpufreq_freqs {
u8 flags; /* flags of cpufreq_driver, see below. */ u8 flags; /* flags of cpufreq_driver, see below. */
}; };
/** /**
* cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch safe) * cpufreq_scale - "old * mult / div" calculation for large values (32-bit-arch
* safe)
* @old: old value * @old: old value
* @div: divisor * @div: divisor
* @mult: multiplier * @mult: multiplier
* *
* *
* new = old * mult / div * new = old * mult / div
*/ */
static inline unsigned long cpufreq_scale(unsigned long old, u_int div, u_int mult) static inline unsigned long cpufreq_scale(unsigned long old, u_int div,
u_int mult)
{ {
#if BITS_PER_LONG == 32 #if BITS_PER_LONG == 32
...@@ -211,14 +216,12 @@ extern int __cpufreq_driver_target(struct cpufreq_policy *policy, ...@@ -211,14 +216,12 @@ extern int __cpufreq_driver_target(struct cpufreq_policy *policy,
unsigned int target_freq, unsigned int target_freq,
unsigned int relation); unsigned int relation);
extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy, extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy,
unsigned int cpu); unsigned int cpu);
int cpufreq_register_governor(struct cpufreq_governor *governor); int cpufreq_register_governor(struct cpufreq_governor *governor);
void cpufreq_unregister_governor(struct cpufreq_governor *governor); void cpufreq_unregister_governor(struct cpufreq_governor *governor);
/********************************************************************* /*********************************************************************
* CPUFREQ DRIVER INTERFACE * * CPUFREQ DRIVER INTERFACE *
*********************************************************************/ *********************************************************************/
...@@ -229,7 +232,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor); ...@@ -229,7 +232,7 @@ void cpufreq_unregister_governor(struct cpufreq_governor *governor);
struct freq_attr; struct freq_attr;
struct cpufreq_driver { struct cpufreq_driver {
struct module *owner; struct module *owner;
char name[CPUFREQ_NAME_LEN]; char name[CPUFREQ_NAME_LEN];
u8 flags; u8 flags;
/* /*
...@@ -277,11 +280,11 @@ struct cpufreq_driver { ...@@ -277,11 +280,11 @@ struct cpufreq_driver {
int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_register_driver(struct cpufreq_driver *driver_data);
int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
void cpufreq_notify_transition(struct cpufreq_policy *policy, void cpufreq_notify_transition(struct cpufreq_policy *policy,
struct cpufreq_freqs *freqs, unsigned int state); struct cpufreq_freqs *freqs, unsigned int state);
static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned int min, unsigned int max) static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy,
unsigned int min, unsigned int max)
{ {
if (policy->min < min) if (policy->min < min)
policy->min = min; policy->min = min;
...@@ -337,12 +340,16 @@ const char *cpufreq_get_current_driver(void); ...@@ -337,12 +340,16 @@ const char *cpufreq_get_current_driver(void);
/********************************************************************* /*********************************************************************
* CPUFREQ 2.6. INTERFACE * * CPUFREQ 2.6. INTERFACE *
*********************************************************************/ *********************************************************************/
u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy);
int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
int cpufreq_update_policy(unsigned int cpu); int cpufreq_update_policy(unsigned int cpu);
bool have_governor_per_policy(void); bool have_governor_per_policy(void);
struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
/* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */ /*
* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it
*/
unsigned int cpufreq_get(unsigned int cpu); unsigned int cpufreq_get(unsigned int cpu);
#else #else
static inline unsigned int cpufreq_get(unsigned int cpu) static inline unsigned int cpufreq_get(unsigned int cpu)
...@@ -351,7 +358,9 @@ static inline unsigned int cpufreq_get(unsigned int cpu) ...@@ -351,7 +358,9 @@ static inline unsigned int cpufreq_get(unsigned int cpu)
} }
#endif #endif
/* query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it */ /*
* query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it
*/
#ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_FREQ
unsigned int cpufreq_quick_get(unsigned int cpu); unsigned int cpufreq_quick_get(unsigned int cpu);
unsigned int cpufreq_quick_get_max(unsigned int cpu); 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,16 +375,14 @@ static inline unsigned int cpufreq_quick_get_max(unsigned int cpu)
} }
#endif #endif
/********************************************************************* /*********************************************************************
* CPUFREQ DEFAULT GOVERNOR * * CPUFREQ DEFAULT GOVERNOR *
*********************************************************************/ *********************************************************************/
/* /*
Performance governor is fallback governor if any other gov failed to * Performance governor is fallback governor if any other gov failed to auto
auto load due latency restrictions * load due latency restrictions
*/ */
#ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE #ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE
extern struct cpufreq_governor cpufreq_gov_performance; extern struct cpufreq_governor cpufreq_gov_performance;
#endif #endif
...@@ -395,7 +402,6 @@ extern struct cpufreq_governor cpufreq_gov_conservative; ...@@ -395,7 +402,6 @@ extern struct cpufreq_governor cpufreq_gov_conservative;
#define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_conservative) #define CPUFREQ_DEFAULT_GOVERNOR (&cpufreq_gov_conservative)
#endif #endif
/********************************************************************* /*********************************************************************
* FREQUENCY TABLE HELPERS * * FREQUENCY TABLE HELPERS *
*********************************************************************/ *********************************************************************/
...@@ -404,7 +410,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative; ...@@ -404,7 +410,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative;
#define CPUFREQ_TABLE_END ~1 #define CPUFREQ_TABLE_END ~1
struct cpufreq_frequency_table { struct cpufreq_frequency_table {
unsigned int index; /* any */ unsigned int driver_data; /* driver specific data, not used by core */
unsigned int frequency; /* kHz - doesn't need to be in ascending unsigned int frequency; /* kHz - doesn't need to be in ascending
* order */ * order */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment