drivers/clk/spear/clk-vco-pll.c
Source file repositories/reference/linux-study-clean/drivers/clk/spear/clk-vco-pll.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/spear/clk-vco-pll.c- Extension
.c- Size
- 8846 bytes
- Lines
- 364
- 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/clk-provider.hlinux/slab.hlinux/io.hlinux/err.hclk.h
Detected Declarations
function Copyrightfunction clk_pll_round_rate_indexfunction clk_pll_determine_ratefunction clk_pll_recalc_ratefunction clk_pll_set_ratefunction vco_calc_ratefunction clk_vco_determine_ratefunction clk_vco_recalc_ratefunction clk_vco_set_rate
Annotated Snippet
if (drate < rate) {
/* previous clock was best */
if (*index) {
rate = prev_rate;
*prate = vco_prev_rate;
(*index)--;
}
break;
}
}
return rate;
}
static int clk_pll_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
int unused;
req->rate = clk_pll_round_rate_index(hw, req->rate,
&req->best_parent_rate, &unused);
return 0;
}
static unsigned long clk_pll_recalc_rate(struct clk_hw *hw, unsigned long
parent_rate)
{
struct clk_pll *pll = to_clk_pll(hw);
unsigned long flags = 0;
unsigned int p;
if (pll->vco->lock)
spin_lock_irqsave(pll->vco->lock, flags);
p = readl_relaxed(pll->vco->cfg_reg);
if (pll->vco->lock)
spin_unlock_irqrestore(pll->vco->lock, flags);
p = (p >> PLL_DIV_P_SHIFT) & PLL_DIV_P_MASK;
return parent_rate / (1 << p);
}
static int clk_pll_set_rate(struct clk_hw *hw, unsigned long drate,
unsigned long prate)
{
struct clk_pll *pll = to_clk_pll(hw);
struct pll_rate_tbl *rtbl = pll->vco->rtbl;
unsigned long flags = 0, val;
int i = 0;
clk_pll_round_rate_index(hw, drate, NULL, &i);
if (pll->vco->lock)
spin_lock_irqsave(pll->vco->lock, flags);
val = readl_relaxed(pll->vco->cfg_reg);
val &= ~(PLL_DIV_P_MASK << PLL_DIV_P_SHIFT);
val |= (rtbl[i].p & PLL_DIV_P_MASK) << PLL_DIV_P_SHIFT;
writel_relaxed(val, pll->vco->cfg_reg);
if (pll->vco->lock)
spin_unlock_irqrestore(pll->vco->lock, flags);
return 0;
}
static const struct clk_ops clk_pll_ops = {
.recalc_rate = clk_pll_recalc_rate,
.determine_rate = clk_pll_determine_rate,
.set_rate = clk_pll_set_rate,
};
static inline unsigned long vco_calc_rate(struct clk_hw *hw,
unsigned long prate, int index)
{
struct clk_vco *vco = to_clk_vco(hw);
return pll_calc_rate(vco->rtbl, prate, index, NULL);
}
static int clk_vco_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
struct clk_vco *vco = to_clk_vco(hw);
int unused;
req->rate = clk_round_rate_index(hw, req->rate, req->best_parent_rate,
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/slab.h`, `linux/io.h`, `linux/err.h`, `clk.h`.
- Detected declarations: `function Copyright`, `function clk_pll_round_rate_index`, `function clk_pll_determine_rate`, `function clk_pll_recalc_rate`, `function clk_pll_set_rate`, `function vco_calc_rate`, `function clk_vco_determine_rate`, `function clk_vco_recalc_rate`, `function clk_vco_set_rate`.
- 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.