drivers/clk/tegra/clk-pll.c
Source file repositories/reference/linux-study-clean/drivers/clk/tegra/clk-pll.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/tegra/clk-pll.c- Extension
.c- Size
- 71683 bytes
- Lines
- 2741
- Domain
- Driver Families
- Bucket
- drivers/clk
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/slab.hlinux/io.hlinux/delay.hlinux/err.hlinux/clk.hlinux/clk-provider.hclk.h
Detected Declarations
struct utmi_clk_paramfunction clk_pll_enable_lockfunction clk_pll_wait_for_lockfunction tegra_pll_wait_for_lockfunction pllm_clk_is_gated_by_pmcfunction clk_pll_is_enabledfunction _clk_pll_enablefunction _clk_pll_disablefunction pll_clk_start_ssfunction pll_clk_stop_ssfunction clk_pll_enablefunction clk_pll_disablefunction _p_div_to_hwfunction tegra_pll_p_div_to_hwfunction _hw_to_p_divfunction _get_table_ratefunction _calc_ratefunction SDMfunction _update_pll_mnpfunction _get_pll_mnpfunction _update_pll_cpconfunction _program_pllfunction clk_pll_set_ratefunction clk_pll_determine_ratefunction clk_pll_recalc_ratefunction clk_plle_trainingfunction clk_plle_enablefunction clk_plle_recalc_ratefunction tegra_clk_pll_restore_contextfunction clk_pllu_enablefunction _pll_fixed_mdivfunction _calc_dynamic_ramp_ratefunction tegra_pll_get_fixed_mdivfunction _clip_vco_minfunction _setup_dynamic_rampfunction _pll_ramp_calc_pllfunction clk_pllxc_set_ratefunction clk_pll_ramp_determine_ratefunction _pllcx_strobefunction clk_pllc_enablefunction _clk_pllc_disablefunction clk_pllc_disablefunction _pllcx_update_dynamic_coeffunction clk_pllc_set_ratefunction _pllre_calc_ratefunction clk_pllre_set_ratefunction clk_pllre_recalc_ratefunction clk_pllre_determine_rate
Annotated Snippet
struct utmi_clk_param {
/* Oscillator Frequency in Hz */
u32 osc_frequency;
/* UTMIP PLL Enable Delay Count */
u8 enable_delay_count;
/* UTMIP PLL Stable count */
u8 stable_count;
/* UTMIP PLL Active delay count */
u8 active_delay_count;
/* UTMIP PLL Xtal frequency count */
u8 xtal_freq_count;
};
static const struct utmi_clk_param utmi_parameters[] = {
{
.osc_frequency = 13000000, .enable_delay_count = 0x02,
.stable_count = 0x33, .active_delay_count = 0x05,
.xtal_freq_count = 0x7f
}, {
.osc_frequency = 19200000, .enable_delay_count = 0x03,
.stable_count = 0x4b, .active_delay_count = 0x06,
.xtal_freq_count = 0xbb
}, {
.osc_frequency = 12000000, .enable_delay_count = 0x02,
.stable_count = 0x2f, .active_delay_count = 0x04,
.xtal_freq_count = 0x76
}, {
.osc_frequency = 26000000, .enable_delay_count = 0x04,
.stable_count = 0x66, .active_delay_count = 0x09,
.xtal_freq_count = 0xfe
}, {
.osc_frequency = 16800000, .enable_delay_count = 0x03,
.stable_count = 0x41, .active_delay_count = 0x0a,
.xtal_freq_count = 0xa4
}, {
.osc_frequency = 38400000, .enable_delay_count = 0x0,
.stable_count = 0x0, .active_delay_count = 0x6,
.xtal_freq_count = 0x80
},
};
static int clk_pllu_enable(struct clk_hw *hw)
{
struct tegra_clk_pll *pll = to_clk_pll(hw);
struct clk_hw *pll_ref = clk_hw_get_parent(hw);
struct clk_hw *osc = clk_hw_get_parent(pll_ref);
const struct utmi_clk_param *params = NULL;
unsigned long flags = 0, input_rate;
unsigned int i;
int ret = 0;
u32 value;
if (!osc) {
pr_err("%s: failed to get OSC clock\n", __func__);
return -EINVAL;
}
input_rate = clk_hw_get_rate(osc);
if (pll->lock)
spin_lock_irqsave(pll->lock, flags);
if (!clk_pll_is_enabled(hw))
_clk_pll_enable(hw);
ret = clk_pll_wait_for_lock(pll);
if (ret < 0)
goto out;
for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) {
if (input_rate == utmi_parameters[i].osc_frequency) {
params = &utmi_parameters[i];
break;
}
}
if (!params) {
pr_err("%s: unexpected input rate %lu Hz\n", __func__,
input_rate);
ret = -EINVAL;
goto out;
}
value = pll_readl_base(pll);
value &= ~PLLU_BASE_OVERRIDE;
pll_writel_base(value, pll);
value = readl_relaxed(pll->clk_base + UTMIP_PLL_CFG2);
/* Program UTMIP PLL stable and active counts */
value &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0);
Annotation
- Immediate include surface: `linux/slab.h`, `linux/io.h`, `linux/delay.h`, `linux/err.h`, `linux/clk.h`, `linux/clk-provider.h`, `clk.h`.
- Detected declarations: `struct utmi_clk_param`, `function clk_pll_enable_lock`, `function clk_pll_wait_for_lock`, `function tegra_pll_wait_for_lock`, `function pllm_clk_is_gated_by_pmc`, `function clk_pll_is_enabled`, `function _clk_pll_enable`, `function _clk_pll_disable`, `function pll_clk_start_ss`, `function pll_clk_stop_ss`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.