drivers/clk/socfpga/clk-gate-s10.c
Source file repositories/reference/linux-study-clean/drivers/clk/socfpga/clk-gate-s10.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/socfpga/clk-gate-s10.c- Extension
.c- Size
- 7675 bytes
- Lines
- 295
- 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/clk-provider.hlinux/io.hlinux/slab.hstratix10-clk.hclk.h
Detected Declarations
function Copyrightfunction socfpga_dbg_clk_recalc_ratefunction socfpga_gate_get_parentfunction socfpga_agilex_gate_get_parent
Annotated Snippet
streq(name, SOCFPGA_EMAC2_CLK)) {
second_bypass = readl(socfpgaclk->bypass_reg -
STRATIX10_BYPASS_OFFSET);
/* EMACA bypass to bootclk @0xB0 offset */
if (second_bypass & 0x1)
if (parent == 0) /* only applicable if parent is maca */
parent = BOOTCLK_BYPASS;
if (second_bypass & 0x2)
if (parent == 1) /* only applicable if parent is macb */
parent = BOOTCLK_BYPASS;
}
return parent;
}
static u8 socfpga_agilex_gate_get_parent(struct clk_hw *hwclk)
{
struct socfpga_gate_clk *socfpgaclk = to_socfpga_gate_clk(hwclk);
u32 mask, second_bypass;
u8 parent = 0;
const char *name = clk_hw_get_name(hwclk);
if (socfpgaclk->bypass_reg) {
mask = (0x1 << socfpgaclk->bypass_shift);
parent = ((readl(socfpgaclk->bypass_reg) & mask) >>
socfpgaclk->bypass_shift);
}
if (streq(name, SOCFPGA_EMAC0_CLK) ||
streq(name, SOCFPGA_EMAC1_CLK) ||
streq(name, SOCFPGA_EMAC2_CLK)) {
second_bypass = readl(socfpgaclk->bypass_reg -
AGILEX_BYPASS_OFFSET);
/* EMACA bypass to bootclk @0x88 offset */
if (second_bypass & 0x1)
if (parent == 0) /* only applicable if parent is maca */
parent = BOOTCLK_BYPASS;
if (second_bypass & 0x2)
if (parent == 1) /* only applicable if parent is macb */
parent = BOOTCLK_BYPASS;
}
return parent;
}
static struct clk_ops gateclk_ops = {
.recalc_rate = socfpga_gate_clk_recalc_rate,
.get_parent = socfpga_gate_get_parent,
};
static const struct clk_ops agilex_gateclk_ops = {
.recalc_rate = socfpga_gate_clk_recalc_rate,
.get_parent = socfpga_agilex_gate_get_parent,
};
static const struct clk_ops dbgclk_ops = {
.recalc_rate = socfpga_dbg_clk_recalc_rate,
.get_parent = socfpga_gate_get_parent,
};
struct clk_hw *s10_register_gate(const struct stratix10_gate_clock *clks, void __iomem *regbase)
{
struct clk_hw *hw_clk;
struct socfpga_gate_clk *socfpga_clk;
struct clk_init_data init;
const char *parent_name = clks->parent_name;
int ret;
socfpga_clk = kzalloc_obj(*socfpga_clk);
if (!socfpga_clk)
return NULL;
socfpga_clk->hw.reg = regbase + clks->gate_reg;
socfpga_clk->hw.bit_idx = clks->gate_idx;
gateclk_ops.enable = clk_gate_ops.enable;
gateclk_ops.disable = clk_gate_ops.disable;
socfpga_clk->fixed_div = clks->fixed_div;
if (clks->div_reg)
socfpga_clk->div_reg = regbase + clks->div_reg;
else
socfpga_clk->div_reg = NULL;
socfpga_clk->width = clks->div_width;
socfpga_clk->shift = clks->div_offset;
if (clks->bypass_reg)
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/io.h`, `linux/slab.h`, `stratix10-clk.h`, `clk.h`.
- Detected declarations: `function Copyright`, `function socfpga_dbg_clk_recalc_rate`, `function socfpga_gate_get_parent`, `function socfpga_agilex_gate_get_parent`.
- 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.