drivers/clk/clk-k210.c
Source file repositories/reference/linux-study-clean/drivers/clk/clk-k210.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/clk-k210.c- Extension
.c- Size
- 25520 bytes
- Lines
- 1011
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/io.hlinux/slab.hlinux/spinlock.hlinux/platform_device.hlinux/of.hlinux/of_clk.hlinux/of_address.hlinux/clk-provider.hlinux/bitfield.hlinux/delay.hsoc/canaan/k210-sysctl.hdt-bindings/clock/k210-clk.h
Detected Declarations
struct k210_sysclkstruct k210_clkstruct k210_clk_cfgstruct k210_pllstruct k210_pll_cfgstruct k210_sysclkenum k210_clk_div_typeenum k210_pll_idfunction k210_aclk_set_selectorfunction k210_init_pllfunction k210_pll_wait_for_lockfunction k210_pll_hw_is_enabledfunction k210_pll_enable_hwfunction k210_pll_enablefunction k210_pll_disablefunction k210_pll_is_enabledfunction k210_pll_get_ratefunction k210_pll2_set_parentfunction k210_pll2_get_parentfunction k210_register_pllfunction k210_register_pllsfunction k210_aclk_set_parentfunction k210_aclk_get_parentfunction k210_aclk_get_ratefunction k210_register_aclkfunction k210_clk_enablefunction k210_clk_disablefunction k210_clk_set_parentfunction k210_clk_get_parentfunction k210_clk_get_ratefunction k210_register_clkfunction k210_register_mux_clkfunction k210_register_in0_childfunction k210_register_pll_childfunction k210_register_aclk_childfunction k210_register_clk_childfunction k210_clk_initfunction k210_clk_early_init
Annotated Snippet
struct k210_clk {
int id;
struct k210_sysclk *ksc;
struct clk_hw hw;
};
struct k210_clk_cfg {
const char *name;
u8 gate_reg;
u8 gate_bit;
u8 div_reg;
u8 div_shift;
u8 div_width;
u8 div_type;
u8 mux_reg;
u8 mux_bit;
};
enum k210_clk_div_type {
K210_DIV_NONE,
K210_DIV_ONE_BASED,
K210_DIV_DOUBLE_ONE_BASED,
K210_DIV_POWER_OF_TWO,
};
#define K210_GATE(_reg, _bit) \
.gate_reg = (_reg), \
.gate_bit = (_bit)
#define K210_DIV(_reg, _shift, _width, _type) \
.div_reg = (_reg), \
.div_shift = (_shift), \
.div_width = (_width), \
.div_type = (_type)
#define K210_MUX(_reg, _bit) \
.mux_reg = (_reg), \
.mux_bit = (_bit)
static struct k210_clk_cfg k210_clk_cfgs[K210_NUM_CLKS] = {
/* Gated clocks, no mux, no divider */
[K210_CLK_CPU] = {
.name = "cpu",
K210_GATE(K210_SYSCTL_EN_CENT, 0)
},
[K210_CLK_DMA] = {
.name = "dma",
K210_GATE(K210_SYSCTL_EN_PERI, 1)
},
[K210_CLK_FFT] = {
.name = "fft",
K210_GATE(K210_SYSCTL_EN_PERI, 4)
},
[K210_CLK_GPIO] = {
.name = "gpio",
K210_GATE(K210_SYSCTL_EN_PERI, 5)
},
[K210_CLK_UART1] = {
.name = "uart1",
K210_GATE(K210_SYSCTL_EN_PERI, 16)
},
[K210_CLK_UART2] = {
.name = "uart2",
K210_GATE(K210_SYSCTL_EN_PERI, 17)
},
[K210_CLK_UART3] = {
.name = "uart3",
K210_GATE(K210_SYSCTL_EN_PERI, 18)
},
[K210_CLK_FPIOA] = {
.name = "fpioa",
K210_GATE(K210_SYSCTL_EN_PERI, 20)
},
[K210_CLK_SHA] = {
.name = "sha",
K210_GATE(K210_SYSCTL_EN_PERI, 26)
},
[K210_CLK_AES] = {
.name = "aes",
K210_GATE(K210_SYSCTL_EN_PERI, 19)
},
[K210_CLK_OTP] = {
.name = "otp",
K210_GATE(K210_SYSCTL_EN_PERI, 27)
},
[K210_CLK_RTC] = {
.name = "rtc",
K210_GATE(K210_SYSCTL_EN_PERI, 29)
},
Annotation
- Immediate include surface: `linux/io.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/platform_device.h`, `linux/of.h`, `linux/of_clk.h`, `linux/of_address.h`, `linux/clk-provider.h`.
- Detected declarations: `struct k210_sysclk`, `struct k210_clk`, `struct k210_clk_cfg`, `struct k210_pll`, `struct k210_pll_cfg`, `struct k210_sysclk`, `enum k210_clk_div_type`, `enum k210_pll_id`, `function k210_aclk_set_selector`, `function k210_init_pll`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.