drivers/clk/clk-xgene.c
Source file repositories/reference/linux-study-clean/drivers/clk/clk-xgene.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/clk-xgene.c- Extension
.c- Size
- 19292 bytes
- Lines
- 756
- 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/module.hlinux/spinlock.hlinux/string_choices.hlinux/io.hlinux/of.hlinux/clkdev.hlinux/clk-provider.hlinux/of_address.h
Detected Declarations
struct xgene_clk_pllstruct xgene_clk_pmdstruct xgene_dev_parametersstruct xgene_clkenum xgene_pll_typefunction xgene_clk_readfunction xgene_clk_writefunction xgene_clk_pll_is_enabledfunction xgene_clk_pll_recalc_ratefunction xgene_pllclk_versionfunction xgene_pllclk_initfunction xgene_socpllclk_initfunction xgene_pcppllclk_initfunction xgene_clk_pmd_recalc_ratefunction xgene_clk_pmd_determine_ratefunction xgene_clk_pmd_set_ratefunction xgene_register_clk_pmdfunction xgene_pmdclk_initfunction xgene_clk_enablefunction xgene_clk_disablefunction xgene_clk_is_enabledfunction xgene_clk_recalc_ratefunction xgene_clk_set_ratefunction xgene_clk_determine_ratefunction xgene_devclk_init
Annotated Snippet
struct xgene_clk_pll {
struct clk_hw hw;
void __iomem *reg;
spinlock_t *lock;
u32 pll_offset;
enum xgene_pll_type type;
int version;
};
#define to_xgene_clk_pll(_hw) container_of(_hw, struct xgene_clk_pll, hw)
static int xgene_clk_pll_is_enabled(struct clk_hw *hw)
{
struct xgene_clk_pll *pllclk = to_xgene_clk_pll(hw);
u32 data;
data = xgene_clk_read(pllclk->reg + pllclk->pll_offset);
pr_debug("%s pll %s\n", clk_hw_get_name(hw),
data & REGSPEC_RESET_F1_MASK ? "disabled" : "enabled");
return data & REGSPEC_RESET_F1_MASK ? 0 : 1;
}
static unsigned long xgene_clk_pll_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct xgene_clk_pll *pllclk = to_xgene_clk_pll(hw);
unsigned long fref;
unsigned long fvco;
u32 pll;
u32 nref;
u32 nout;
u32 nfb;
pll = xgene_clk_read(pllclk->reg + pllclk->pll_offset);
if (pllclk->version <= 1) {
if (pllclk->type == PLL_TYPE_PCP) {
/*
* PLL VCO = Reference clock * NF
* PCP PLL = PLL_VCO / 2
*/
nout = 2;
fvco = parent_rate * (N_DIV_RD(pll) + 4);
} else {
/*
* Fref = Reference Clock / NREF;
* Fvco = Fref * NFB;
* Fout = Fvco / NOUT;
*/
nref = CLKR_RD(pll) + 1;
nout = CLKOD_RD(pll) + 1;
nfb = CLKF_RD(pll);
fref = parent_rate / nref;
fvco = fref * nfb;
}
} else {
/*
* fvco = Reference clock * FBDIVC
* PLL freq = fvco / NOUT
*/
nout = SC_OUTDIV2(pll) ? 2 : 3;
fvco = parent_rate * SC_N_DIV_RD(pll);
}
pr_debug("%s pll recalc rate %ld parent %ld version %d\n",
clk_hw_get_name(hw), fvco / nout, parent_rate,
pllclk->version);
return fvco / nout;
}
static const struct clk_ops xgene_clk_pll_ops = {
.is_enabled = xgene_clk_pll_is_enabled,
.recalc_rate = xgene_clk_pll_recalc_rate,
};
static struct clk *xgene_register_clk_pll(struct device *dev,
const char *name, const char *parent_name,
unsigned long flags, void __iomem *reg, u32 pll_offset,
u32 type, spinlock_t *lock, int version)
{
struct xgene_clk_pll *apmclk;
struct clk *clk;
struct clk_init_data init;
/* allocate the APM clock structure */
apmclk = kzalloc_obj(*apmclk);
if (!apmclk)
return ERR_PTR(-ENOMEM);
Annotation
- Immediate include surface: `linux/module.h`, `linux/spinlock.h`, `linux/string_choices.h`, `linux/io.h`, `linux/of.h`, `linux/clkdev.h`, `linux/clk-provider.h`, `linux/of_address.h`.
- Detected declarations: `struct xgene_clk_pll`, `struct xgene_clk_pmd`, `struct xgene_dev_parameters`, `struct xgene_clk`, `enum xgene_pll_type`, `function xgene_clk_read`, `function xgene_clk_write`, `function xgene_clk_pll_is_enabled`, `function xgene_clk_pll_recalc_rate`, `function xgene_pllclk_version`.
- 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.