/* * Setup the opps list with the divider for the max frequency, that * will be filled at runtime.
*/ staticconstint opps_div[] __initconst = {1, 2, 3, 4};
/* If the CPUs share the same clock, then they are in the same cluster. */ staticvoid __init armada_8k_get_sharing_cpus(struct clk *cur_clk, struct cpumask *cpumask)
{ int cpu;
cpu_dev = get_cpu_device(cpu); if (!cpu_dev) {
pr_warn("Failed to get cpu%d device\n", cpu); continue;
}
clk = clk_get(cpu_dev, NULL); if (IS_ERR(clk)) {
pr_warn("Cannot get clock for CPU %d\n", cpu);
} else { if (clk_is_match(clk, cur_clk))
cpumask_set_cpu(cpu, cpumask);
clk_put(clk);
}
}
}
staticint __init armada_8k_add_opp(struct clk *clk, struct device *cpu_dev, struct freq_table *freq_tables, int opps_index)
{ unsignedint cur_frequency; unsignedint freq; int i, ret;
/* Get nominal (current) CPU frequency. */
cur_frequency = clk_get_rate(clk); if (!cur_frequency) {
dev_err(cpu_dev, "Failed to get clock rate for this CPU\n"); return -EINVAL;
}
freq_tables[opps_index].cpu_dev = cpu_dev;
for (i = 0; i < ARRAY_SIZE(opps_div); i++) {
freq = cur_frequency / opps_div[i];
ret = dev_pm_opp_add(cpu_dev, freq, 0); if (ret) return ret;
freq_tables[opps_index].freq[i] = freq;
}
return 0;
}
staticvoid armada_8k_cpufreq_free_table(struct freq_table *freq_tables)
{ int opps_index, nb_cpus = num_possible_cpus();
for (opps_index = 0 ; opps_index < nb_cpus; opps_index++) { int i;
/* If cpu_dev is NULL then we reached the end of the array */ if (!freq_tables[opps_index].cpu_dev) break;
for (i = 0; i < ARRAY_SIZE(opps_div); i++) { /* * A 0Hz frequency is not valid, this meant * that it was not yet initialized so there is * no more opp to free
*/ if (freq_tables[opps_index].freq[i] == 0) break;
/* * For each CPU, this loop registers the operating points * supported (which are the nominal CPU frequency and full integer * divisions of it).
*/
for_each_cpu(cpu, &cpus) { struct device *cpu_dev; struct clk *clk;
cpu_dev = get_cpu_device(cpu);
if (!cpu_dev) {
pr_err("Cannot get CPU %d\n", cpu); continue;
}
clk = clk_get(cpu_dev, NULL);
if (IS_ERR(clk)) {
pr_err("Cannot get clock for CPU %d\n", cpu);
ret = PTR_ERR(clk); goto remove_opp;
}
ret = armada_8k_add_opp(clk, cpu_dev, freq_tables, opps_index); if (ret) {
clk_put(clk); goto remove_opp;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.