drivers/clk/imx/clk-pllv3.c
Source file repositories/reference/linux-study-clean/drivers/clk/imx/clk-pllv3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/imx/clk-pllv3.c- Extension
.c- Size
- 12338 bytes
- Lines
- 499
- Domain
- Driver Families
- Bucket
- drivers/clk
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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-provider.hlinux/delay.hlinux/export.hlinux/io.hlinux/iopoll.hlinux/slab.hlinux/jiffies.hlinux/err.hclk.h
Detected Declarations
struct clk_pllv3struct clk_pllv3_vf610_mffunction clk_pllv3_wait_lockfunction clk_pllv3_preparefunction clk_pllv3_unpreparefunction clk_pllv3_is_preparedfunction clk_pllv3_recalc_ratefunction clk_pllv3_determine_ratefunction clk_pllv3_set_ratefunction clk_pllv3_sys_recalc_ratefunction clk_pllv3_sys_determine_ratefunction clk_pllv3_sys_set_ratefunction clk_pllv3_av_recalc_ratefunction clk_pllv3_av_determine_ratefunction clk_pllv3_av_set_ratefunction clk_pllv3_vf610_mf_to_ratefunction clk_pllv3_vf610_rate_to_mffunction clk_pllv3_vf610_recalc_ratefunction clk_pllv3_vf610_determine_ratefunction clk_pllv3_vf610_set_ratefunction clk_pllv3_enet_recalc_rateexport imx_clk_hw_pllv3
Annotated Snippet
struct clk_pllv3 {
struct clk_hw hw;
void __iomem *base;
u32 power_bit;
bool powerup_set;
u32 div_mask;
u32 div_shift;
unsigned long ref_clock;
u32 num_offset;
u32 denom_offset;
};
#define to_clk_pllv3(_hw) container_of(_hw, struct clk_pllv3, hw)
static int clk_pllv3_wait_lock(struct clk_pllv3 *pll)
{
u32 val = readl_relaxed(pll->base) & pll->power_bit;
/* No need to wait for lock when pll is not powered up */
if ((pll->powerup_set && !val) || (!pll->powerup_set && val))
return 0;
return readl_relaxed_poll_timeout(pll->base, val, val & BM_PLL_LOCK,
500, PLL_LOCK_TIMEOUT);
}
static int clk_pllv3_prepare(struct clk_hw *hw)
{
struct clk_pllv3 *pll = to_clk_pllv3(hw);
u32 val;
val = readl_relaxed(pll->base);
if (pll->powerup_set)
val |= pll->power_bit;
else
val &= ~pll->power_bit;
writel_relaxed(val, pll->base);
return clk_pllv3_wait_lock(pll);
}
static void clk_pllv3_unprepare(struct clk_hw *hw)
{
struct clk_pllv3 *pll = to_clk_pllv3(hw);
u32 val;
val = readl_relaxed(pll->base);
if (pll->powerup_set)
val &= ~pll->power_bit;
else
val |= pll->power_bit;
writel_relaxed(val, pll->base);
}
static int clk_pllv3_is_prepared(struct clk_hw *hw)
{
struct clk_pllv3 *pll = to_clk_pllv3(hw);
if (readl_relaxed(pll->base) & BM_PLL_LOCK)
return 1;
return 0;
}
static unsigned long clk_pllv3_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct clk_pllv3 *pll = to_clk_pllv3(hw);
u32 div = (readl_relaxed(pll->base) >> pll->div_shift) & pll->div_mask;
return (div == 1) ? parent_rate * 22 : parent_rate * 20;
}
static int clk_pllv3_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
unsigned long parent_rate = req->best_parent_rate;
req->rate = (req->rate >= parent_rate * 22) ? parent_rate * 22 : parent_rate * 20;
return 0;
}
static int clk_pllv3_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct clk_pllv3 *pll = to_clk_pllv3(hw);
u32 val, div;
if (rate == parent_rate * 22)
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/delay.h`, `linux/export.h`, `linux/io.h`, `linux/iopoll.h`, `linux/slab.h`, `linux/jiffies.h`, `linux/err.h`.
- Detected declarations: `struct clk_pllv3`, `struct clk_pllv3_vf610_mf`, `function clk_pllv3_wait_lock`, `function clk_pllv3_prepare`, `function clk_pllv3_unprepare`, `function clk_pllv3_is_prepared`, `function clk_pllv3_recalc_rate`, `function clk_pllv3_determine_rate`, `function clk_pllv3_set_rate`, `function clk_pllv3_sys_recalc_rate`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: integration 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.