drivers/clk/mvebu/common.c
Source file repositories/reference/linux-study-clean/drivers/clk/mvebu/common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/mvebu/common.c- Extension
.c- Size
- 7009 bytes
- Lines
- 297
- 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.hlinux/clk-provider.hlinux/io.hlinux/of.hlinux/of_address.hlinux/syscore_ops.hcommon.h
Detected Declarations
struct clk_gating_ctrlfunction kirkwood_fix_sscg_deviationfunction mvebu_coreclk_setupfunction mvebu_clk_gating_suspendfunction mvebu_clk_gating_resumefunction mvebu_clk_gating_setup
Annotated Snippet
struct clk_gating_ctrl {
spinlock_t *lock;
struct clk **gates;
int num_gates;
void __iomem *base;
u32 saved_reg;
};
static struct clk_gating_ctrl *ctrl;
static struct clk *clk_gating_get_src(
struct of_phandle_args *clkspec, void *data)
{
int n;
if (clkspec->args_count < 1)
return ERR_PTR(-EINVAL);
for (n = 0; n < ctrl->num_gates; n++) {
struct clk_gate *gate =
to_clk_gate(__clk_get_hw(ctrl->gates[n]));
if (clkspec->args[0] == gate->bit_idx)
return ctrl->gates[n];
}
return ERR_PTR(-ENODEV);
}
static int mvebu_clk_gating_suspend(void *data)
{
ctrl->saved_reg = readl(ctrl->base);
return 0;
}
static void mvebu_clk_gating_resume(void *data)
{
writel(ctrl->saved_reg, ctrl->base);
}
static const struct syscore_ops clk_gate_syscore_ops = {
.suspend = mvebu_clk_gating_suspend,
.resume = mvebu_clk_gating_resume,
};
static struct syscore clk_gate_syscore = {
.ops = &clk_gate_syscore_ops,
};
void __init mvebu_clk_gating_setup(struct device_node *np,
const struct clk_gating_soc_desc *desc)
{
struct clk *clk;
void __iomem *base;
const char *default_parent = NULL;
int n;
if (ctrl) {
pr_err("mvebu-clk-gating: cannot instantiate more than one gateable clock device\n");
return;
}
base = of_iomap(np, 0);
if (WARN_ON(!base))
return;
clk = of_clk_get(np, 0);
if (!IS_ERR(clk)) {
default_parent = __clk_get_name(clk);
clk_put(clk);
}
ctrl = kzalloc_obj(*ctrl);
if (WARN_ON(!ctrl))
goto ctrl_out;
/* lock must already be initialized */
ctrl->lock = &ctrl_gating_lock;
ctrl->base = base;
/* Count, allocate, and register clock gates */
for (n = 0; desc[n].name;)
n++;
ctrl->num_gates = n;
ctrl->gates = kzalloc_objs(*ctrl->gates, ctrl->num_gates);
if (WARN_ON(!ctrl->gates))
goto gates_out;
for (n = 0; n < ctrl->num_gates; n++) {
const char *parent =
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/io.h`, `linux/of.h`, `linux/of_address.h`, `linux/syscore_ops.h`.
- Detected declarations: `struct clk_gating_ctrl`, `function kirkwood_fix_sscg_deviation`, `function mvebu_coreclk_setup`, `function mvebu_clk_gating_suspend`, `function mvebu_clk_gating_resume`, `function mvebu_clk_gating_setup`.
- 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.