drivers/clk/mvebu/kirkwood.c
Source file repositories/reference/linux-study-clean/drivers/clk/mvebu/kirkwood.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/mvebu/kirkwood.c- Extension
.c- Size
- 8619 bytes
- Lines
- 359
- 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.
- 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/kernel.hlinux/slab.hlinux/clk-provider.hlinux/io.hlinux/of.hlinux/of_address.hcommon.h
Detected Declarations
struct clk_muxing_soc_descstruct clk_muxing_ctrlfunction kirkwood_get_tclk_freqfunction kirkwood_get_cpu_freqfunction kirkwood_get_clk_ratiofunction mv88f6180_get_cpu_freqfunction mv88f6180_get_clk_ratiofunction mv98dx1135_get_tclk_freqfunction kirkwood_clk_muxing_setupfunction kirkwood_clk_init
Annotated Snippet
struct clk_muxing_soc_desc {
const char *name;
const char **parents;
int num_parents;
int shift;
int width;
unsigned long flags;
};
struct clk_muxing_ctrl {
spinlock_t *lock;
struct clk **muxes;
int num_muxes;
};
static const char *powersave_parents[] = {
"cpuclk",
"ddrclk",
};
static const struct clk_muxing_soc_desc kirkwood_mux_desc[] __initconst = {
{ "powersave", powersave_parents, ARRAY_SIZE(powersave_parents),
11, 1, 0 },
{ }
};
static struct clk *clk_muxing_get_src(
struct of_phandle_args *clkspec, void *data)
{
struct clk_muxing_ctrl *ctrl = (struct clk_muxing_ctrl *)data;
int n;
if (clkspec->args_count < 1)
return ERR_PTR(-EINVAL);
for (n = 0; n < ctrl->num_muxes; n++) {
struct clk_mux *mux =
to_clk_mux(__clk_get_hw(ctrl->muxes[n]));
if (clkspec->args[0] == mux->shift)
return ctrl->muxes[n];
}
return ERR_PTR(-ENODEV);
}
static void __init kirkwood_clk_muxing_setup(struct device_node *np,
const struct clk_muxing_soc_desc *desc)
{
struct clk_muxing_ctrl *ctrl;
void __iomem *base;
int n;
base = of_iomap(np, 0);
if (WARN_ON(!base))
return;
ctrl = kzalloc_obj(*ctrl);
if (WARN_ON(!ctrl))
goto ctrl_out;
/* lock must already be initialized */
ctrl->lock = &ctrl_gating_lock;
/* Count, allocate, and register clock muxes */
for (n = 0; desc[n].name;)
n++;
ctrl->num_muxes = n;
ctrl->muxes = kzalloc_objs(struct clk *, ctrl->num_muxes);
if (WARN_ON(!ctrl->muxes))
goto muxes_out;
for (n = 0; n < ctrl->num_muxes; n++) {
ctrl->muxes[n] = clk_register_mux(NULL, desc[n].name,
desc[n].parents, desc[n].num_parents,
desc[n].flags, base, desc[n].shift,
desc[n].width, desc[n].flags, ctrl->lock);
WARN_ON(IS_ERR(ctrl->muxes[n]));
}
of_clk_add_provider(np, clk_muxing_get_src, ctrl);
return;
muxes_out:
kfree(ctrl);
ctrl_out:
iounmap(base);
}
static void __init kirkwood_clk_init(struct device_node *np)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/clk-provider.h`, `linux/io.h`, `linux/of.h`, `linux/of_address.h`, `common.h`.
- Detected declarations: `struct clk_muxing_soc_desc`, `struct clk_muxing_ctrl`, `function kirkwood_get_tclk_freq`, `function kirkwood_get_cpu_freq`, `function kirkwood_get_clk_ratio`, `function mv88f6180_get_cpu_freq`, `function mv88f6180_get_clk_ratio`, `function mv98dx1135_get_tclk_freq`, `function kirkwood_clk_muxing_setup`, `function kirkwood_clk_init`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source 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.