drivers/clk/clk-axi-clkgen.c
Source file repositories/reference/linux-study-clean/drivers/clk/clk-axi-clkgen.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/clk-axi-clkgen.c- Extension
.c- Size
- 17354 bytes
- Lines
- 670
- 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/adi-axi-common.hlinux/bits.hlinux/clk.hlinux/clk-provider.hlinux/err.hlinux/io.hlinux/module.hlinux/mod_devicetable.hlinux/of.hlinux/platform_device.hlinux/slab.h
Detected Declarations
struct axi_clkgen_limitsstruct axi_clkgenstruct axi_clkgen_div_paramsfunction axi_clkgen_lookup_filterfunction axi_clkgen_lookup_lockfunction axi_clkgen_calc_paramsfunction axi_clkgen_calc_clk_paramsfunction axi_clkgen_writefunction axi_clkgen_readfunction axi_clkgen_wait_non_busyfunction axi_clkgen_mmcm_readfunction axi_clkgen_mmcm_writefunction axi_clkgen_mmcm_enablefunction axi_clkgen_set_divfunction axi_clkgen_set_ratefunction axi_clkgen_determine_ratefunction axi_clkgen_get_divfunction axi_clkgen_recalc_ratefunction axi_clkgen_enablefunction axi_clkgen_disablefunction axi_clkgen_set_parentfunction axi_clkgen_get_parentfunction axi_clkgen_setup_limitsfunction axi_clkgen_probe
Annotated Snippet
struct axi_clkgen_limits {
unsigned int fpfd_min;
unsigned int fpfd_max;
unsigned int fvco_min;
unsigned int fvco_max;
};
struct axi_clkgen {
void __iomem *base;
struct clk_hw clk_hw;
struct axi_clkgen_limits limits;
};
static uint32_t axi_clkgen_lookup_filter(unsigned int m)
{
switch (m) {
case 0:
return 0x01001990;
case 1:
return 0x01001190;
case 2:
return 0x01009890;
case 3:
return 0x01001890;
case 4:
return 0x01008890;
case 5 ... 8:
return 0x01009090;
case 9 ... 11:
return 0x01000890;
case 12:
return 0x08009090;
case 13 ... 22:
return 0x01001090;
case 23 ... 36:
return 0x01008090;
case 37 ... 46:
return 0x08001090;
default:
return 0x08008090;
}
}
static const u32 axi_clkgen_lock_table[] = {
0x060603e8, 0x060603e8, 0x080803e8, 0x0b0b03e8,
0x0e0e03e8, 0x111103e8, 0x131303e8, 0x161603e8,
0x191903e8, 0x1c1c03e8, 0x1f1f0384, 0x1f1f0339,
0x1f1f02ee, 0x1f1f02bc, 0x1f1f028a, 0x1f1f0271,
0x1f1f023f, 0x1f1f0226, 0x1f1f020d, 0x1f1f01f4,
0x1f1f01db, 0x1f1f01c2, 0x1f1f01a9, 0x1f1f0190,
0x1f1f0190, 0x1f1f0177, 0x1f1f015e, 0x1f1f015e,
0x1f1f0145, 0x1f1f0145, 0x1f1f012c, 0x1f1f012c,
0x1f1f012c, 0x1f1f0113, 0x1f1f0113, 0x1f1f0113,
};
static u32 axi_clkgen_lookup_lock(unsigned int m)
{
if (m < ARRAY_SIZE(axi_clkgen_lock_table))
return axi_clkgen_lock_table[m];
return 0x1f1f00fa;
}
static const struct axi_clkgen_limits axi_clkgen_zynqmp_default_limits = {
.fpfd_min = 10000,
.fpfd_max = 450000,
.fvco_min = 800000,
.fvco_max = 1600000,
};
static const struct axi_clkgen_limits axi_clkgen_zynq_default_limits = {
.fpfd_min = 10000,
.fpfd_max = 450000,
.fvco_min = 600000,
.fvco_max = 1200000,
};
static void axi_clkgen_calc_params(const struct axi_clkgen_limits *limits,
unsigned long fin, unsigned long fout,
unsigned int *best_d, unsigned int *best_m,
unsigned int *best_dout)
{
unsigned long d, d_min, d_max, _d_min, _d_max;
unsigned long m, m_min, m_max;
unsigned long f, dout, best_f, fvco;
unsigned long fract_shift = 0;
unsigned long fvco_min_fract, fvco_max_fract;
fin /= 1000;
fout /= 1000;
Annotation
- Immediate include surface: `linux/adi-axi-common.h`, `linux/bits.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/err.h`, `linux/io.h`, `linux/module.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct axi_clkgen_limits`, `struct axi_clkgen`, `struct axi_clkgen_div_params`, `function axi_clkgen_lookup_filter`, `function axi_clkgen_lookup_lock`, `function axi_clkgen_calc_params`, `function axi_clkgen_calc_clk_params`, `function axi_clkgen_write`, `function axi_clkgen_read`, `function axi_clkgen_wait_non_busy`.
- 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.