drivers/clk/sunxi/clk-sunxi.c
Source file repositories/reference/linux-study-clean/drivers/clk/sunxi/clk-sunxi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/sunxi/clk-sunxi.c- Extension
.c- Size
- 27493 bytes
- Lines
- 1157
- 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.hlinux/clk-provider.hlinux/clkdev.hlinux/io.hlinux/of.hlinux/of_address.hlinux/reset-controller.hlinux/slab.hlinux/spinlock.hlinux/log2.hclk-factors.h
Detected Declarations
struct mux_datastruct div_datastruct divs_datafunction sun4i_get_pll1_factorsfunction sun6i_a31_get_pll1_factorsfunction sun8i_a23_get_pll1_factorsfunction sun4i_get_pll5_factorsfunction sun6i_a31_get_pll6_factorsfunction sun5i_a13_get_ahb_factorsfunction sun6i_a31_get_ahb_factorsfunction sun6i_ahb1_recalcfunction sun4i_get_apb1_factorsfunction sun7i_a20_get_out_factorsfunction sunxi_factors_clk_setupfunction sun4i_pll1_clk_setupfunction sun6i_pll1_clk_setupfunction sun8i_pll1_clk_setupfunction sun7i_pll4_clk_setupfunction sun5i_ahb_clk_setupfunction sun6i_ahb1_clk_setupfunction sun4i_apb1_clk_setupfunction sun7i_out_clk_setupfunction sunxi_mux_clk_setupfunction sun4i_cpu_clk_setupfunction sun6i_ahb1_mux_clk_setupfunction sun8i_ahb2_clk_setupfunction sunxi_divider_clk_setupfunction sun4i_ahb_clk_setupfunction sun4i_apb0_clk_setupfunction sun4i_axi_clk_setupfunction sun8i_axi_clk_setupfunction sunxi_divs_clk_setupfunction sun4i_pll5_clk_setupfunction sun4i_pll6_clk_setupfunction sun6i_pll6_clk_setupfunction sun6i_display_factorsfunction sun6i_display_setup
Annotated Snippet
struct mux_data {
u8 shift;
};
static const struct mux_data sun4i_cpu_mux_data __initconst = {
.shift = 16,
};
static const struct mux_data sun6i_a31_ahb1_mux_data __initconst = {
.shift = 12,
};
static const struct mux_data sun8i_h3_ahb2_mux_data __initconst = {
.shift = 0,
};
static struct clk * __init sunxi_mux_clk_setup(struct device_node *node,
const struct mux_data *data,
unsigned long flags)
{
struct clk *clk;
const char *clk_name = node->name;
const char *parents[SUNXI_MAX_PARENTS];
void __iomem *reg;
int i;
reg = of_iomap(node, 0);
if (!reg) {
pr_err("Could not map registers for mux-clk: %pOF\n", node);
return NULL;
}
i = of_clk_parent_fill(node, parents, SUNXI_MAX_PARENTS);
if (of_property_read_string(node, "clock-output-names", &clk_name)) {
pr_err("%s: could not read clock-output-names from \"%pOF\"\n",
__func__, node);
goto out_unmap;
}
clk = clk_register_mux(NULL, clk_name, parents, i,
CLK_SET_RATE_PARENT | flags, reg,
data->shift, SUNXI_MUX_GATE_WIDTH,
0, &clk_lock);
if (IS_ERR(clk)) {
pr_err("%s: failed to register mux clock %s: %ld\n", __func__,
clk_name, PTR_ERR(clk));
goto out_unmap;
}
if (of_clk_add_provider(node, of_clk_src_simple_get, clk)) {
pr_err("%s: failed to add clock provider for %s\n",
__func__, clk_name);
clk_unregister_divider(clk);
goto out_unmap;
}
return clk;
out_unmap:
iounmap(reg);
return NULL;
}
static void __init sun4i_cpu_clk_setup(struct device_node *node)
{
/* Protect CPU clock */
sunxi_mux_clk_setup(node, &sun4i_cpu_mux_data, CLK_IS_CRITICAL);
}
CLK_OF_DECLARE(sun4i_cpu, "allwinner,sun4i-a10-cpu-clk",
sun4i_cpu_clk_setup);
static void __init sun6i_ahb1_mux_clk_setup(struct device_node *node)
{
sunxi_mux_clk_setup(node, &sun6i_a31_ahb1_mux_data, 0);
}
CLK_OF_DECLARE(sun6i_ahb1_mux, "allwinner,sun6i-a31-ahb1-mux-clk",
sun6i_ahb1_mux_clk_setup);
static void __init sun8i_ahb2_clk_setup(struct device_node *node)
{
sunxi_mux_clk_setup(node, &sun8i_h3_ahb2_mux_data, 0);
}
CLK_OF_DECLARE(sun8i_ahb2, "allwinner,sun8i-h3-ahb2-clk",
sun8i_ahb2_clk_setup);
/*
* sunxi_divider_clk_setup() - Setup function for simple divider clocks
*/
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/clkdev.h`, `linux/io.h`, `linux/of.h`, `linux/of_address.h`, `linux/reset-controller.h`, `linux/slab.h`.
- Detected declarations: `struct mux_data`, `struct div_data`, `struct divs_data`, `function sun4i_get_pll1_factors`, `function sun6i_a31_get_pll1_factors`, `function sun8i_a23_get_pll1_factors`, `function sun4i_get_pll5_factors`, `function sun6i_a31_get_pll6_factors`, `function sun5i_a13_get_ahb_factors`, `function sun6i_a31_get_ahb_factors`.
- 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.