drivers/cpufreq/qoriq-cpufreq.c
Source file repositories/reference/linux-study-clean/drivers/cpufreq/qoriq-cpufreq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cpufreq/qoriq-cpufreq.c- Extension
.c- Size
- 6957 bytes
- Lines
- 306
- Domain
- Driver Families
- Bucket
- drivers/cpufreq
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/clk-provider.hlinux/cpufreq.hlinux/errno.hlinux/init.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/of.hlinux/slab.hlinux/smp.hlinux/platform_device.h
Detected Declarations
struct cpu_datastruct soc_datafunction get_bus_freqfunction set_affected_cpusfunction for_each_present_cpufunction freq_table_redupfunction freq_table_sortfunction qoriq_cpufreq_cpu_initfunction qoriq_cpufreq_cpu_exitfunction qoriq_cpufreq_targetfunction qoriq_cpufreq_probefunction qoriq_cpufreq_remove
Annotated Snippet
struct cpu_data {
struct clk **pclk;
struct cpufreq_frequency_table *table;
};
/**
* struct soc_data - SoC specific data
* @flags: SOC_xxx
*/
struct soc_data {
u32 flags;
};
static u32 get_bus_freq(void)
{
struct device_node *soc;
u32 sysfreq;
struct clk *pltclk;
int ret;
/* get platform freq by searching bus-frequency property */
soc = of_find_node_by_type(NULL, "soc");
if (soc) {
ret = of_property_read_u32(soc, "bus-frequency", &sysfreq);
of_node_put(soc);
if (!ret)
return sysfreq;
}
/* get platform freq by its clock name */
pltclk = clk_get(NULL, "cg-pll0-div1");
if (IS_ERR(pltclk)) {
pr_err("%s: can't get bus frequency %ld\n",
__func__, PTR_ERR(pltclk));
return PTR_ERR(pltclk);
}
return clk_get_rate(pltclk);
}
static struct clk *cpu_to_clk(int cpu)
{
struct device_node *np;
struct clk *clk;
if (!cpu_present(cpu))
return NULL;
np = of_get_cpu_node(cpu, NULL);
if (!np)
return NULL;
clk = of_clk_get(np, 0);
of_node_put(np);
return clk;
}
/* traverse cpu nodes to get cpu mask of sharing clock wire */
static void set_affected_cpus(struct cpufreq_policy *policy)
{
struct cpumask *dstp = policy->cpus;
struct clk *clk;
int i;
for_each_present_cpu(i) {
clk = cpu_to_clk(i);
if (IS_ERR(clk)) {
pr_err("%s: no clock for cpu %d\n", __func__, i);
continue;
}
if (clk_is_match(policy->clk, clk))
cpumask_set_cpu(i, dstp);
}
}
/* 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;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/cpufreq.h`, `linux/errno.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`.
- Detected declarations: `struct cpu_data`, `struct soc_data`, `function get_bus_freq`, `function set_affected_cpus`, `function for_each_present_cpu`, `function freq_table_redup`, `function freq_table_sort`, `function qoriq_cpufreq_cpu_init`, `function qoriq_cpufreq_cpu_exit`, `function qoriq_cpufreq_target`.
- Atlas domain: Driver Families / drivers/cpufreq.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.