drivers/cpufreq/tegra186-cpufreq.c
Source file repositories/reference/linux-study-clean/drivers/cpufreq/tegra186-cpufreq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cpufreq/tegra186-cpufreq.c- Extension
.c- Size
- 11289 bytes
- Lines
- 445
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/cpufreq.hlinux/dma-mapping.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/units.hsoc/tegra/bpmp.hsoc/tegra/bpmp-abi.h
Detected Declarations
struct tegra186_cpufreq_cpustruct tegra186_cpufreq_clusterstruct tegra186_cpufreq_datafunction tegra_cpufreq_set_bwfunction tegra_cpufreq_init_cpufreq_tablefunction tegra186_cpufreq_initfunction tegra186_cpufreq_set_targetfunction for_each_cpufunction tegra186_cpufreq_getfunction tegra186_cpufreq_probefunction tegra186_cpufreq_remove
Annotated Snippet
struct tegra186_cpufreq_cpu {
unsigned int bpmp_cluster_id;
unsigned int edvd_offset;
};
static const struct tegra186_cpufreq_cpu tegra186_cpus[] = {
/* CPU0 - A57 Cluster */
{
.bpmp_cluster_id = 1,
.edvd_offset = EDVD_OFFSET_A57(0)
},
/* CPU1 - Denver Cluster */
{
.bpmp_cluster_id = 0,
.edvd_offset = EDVD_OFFSET_DENVER(0)
},
/* CPU2 - Denver Cluster */
{
.bpmp_cluster_id = 0,
.edvd_offset = EDVD_OFFSET_DENVER(1)
},
/* CPU3 - A57 Cluster */
{
.bpmp_cluster_id = 1,
.edvd_offset = EDVD_OFFSET_A57(1)
},
/* CPU4 - A57 Cluster */
{
.bpmp_cluster_id = 1,
.edvd_offset = EDVD_OFFSET_A57(2)
},
/* CPU5 - A57 Cluster */
{
.bpmp_cluster_id = 1,
.edvd_offset = EDVD_OFFSET_A57(3)
},
};
struct tegra186_cpufreq_cluster {
struct cpufreq_frequency_table *bpmp_lut;
u32 ref_clk_khz;
u32 div;
};
struct tegra186_cpufreq_data {
void __iomem *regs;
const struct tegra186_cpufreq_cpu *cpus;
bool icc_dram_bw_scaling;
struct tegra186_cpufreq_cluster clusters[];
};
static int tegra_cpufreq_set_bw(struct cpufreq_policy *policy, unsigned long freq_khz)
{
struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
struct device *dev;
int ret;
dev = get_cpu_device(policy->cpu);
if (!dev)
return -ENODEV;
struct dev_pm_opp *opp __free(put_opp) =
dev_pm_opp_find_freq_exact(dev, freq_khz * HZ_PER_KHZ, true);
if (IS_ERR(opp))
return PTR_ERR(opp);
ret = dev_pm_opp_set_opp(dev, opp);
if (ret)
data->icc_dram_bw_scaling = false;
return ret;
}
static int tegra_cpufreq_init_cpufreq_table(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *bpmp_lut,
struct cpufreq_frequency_table **opp_table)
{
struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
struct cpufreq_frequency_table *freq_table = NULL;
struct cpufreq_frequency_table *pos;
struct device *cpu_dev;
unsigned long rate;
int ret, max_opps;
int j = 0;
cpu_dev = get_cpu_device(policy->cpu);
if (!cpu_dev) {
pr_err("%s: failed to get cpu%d device\n", __func__, policy->cpu);
return -ENODEV;
}
Annotation
- Immediate include surface: `linux/cpufreq.h`, `linux/dma-mapping.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/units.h`, `soc/tegra/bpmp.h`, `soc/tegra/bpmp-abi.h`.
- Detected declarations: `struct tegra186_cpufreq_cpu`, `struct tegra186_cpufreq_cluster`, `struct tegra186_cpufreq_data`, `function tegra_cpufreq_set_bw`, `function tegra_cpufreq_init_cpufreq_table`, `function tegra186_cpufreq_init`, `function tegra186_cpufreq_set_target`, `function for_each_cpu`, `function tegra186_cpufreq_get`, `function tegra186_cpufreq_probe`.
- Atlas domain: Driver Families / drivers/cpufreq.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.