drivers/clk/sophgo/clk-sg2044.c
Source file repositories/reference/linux-study-clean/drivers/clk/sophgo/clk-sg2044.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/sophgo/clk-sg2044.c- Extension
.c- Size
- 50336 bytes
- Lines
- 1813
- 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/array_size.hlinux/bitfield.hlinux/bits.hlinux/cleanup.hlinux/clk.hlinux/clk-provider.hlinux/io.hlinux/iopoll.hlinux/math64.hlinux/mfd/syscon.hlinux/platform_device.hlinux/regmap.hlinux/spinlock.hdt-bindings/clock/sophgo,sg2044-clk.h
Detected Declarations
struct sg2044_div_internalstruct sg2044_mux_internalstruct sg2044_gate_internalstruct sg2044_clk_commonstruct sg2044_divstruct sg2044_muxstruct sg2044_gatestruct sg2044_clk_ctrlstruct sg2044_clk_desc_datafunction sg2044_div_get_reg_divfunction _sg2044_div_recalc_ratefunction sg2044_div_recalc_ratefunction _sg2044_div_determine_ratefunction sg2044_div_determine_ratefunction sg2044_div_set_reg_divfunction sg2044_div_set_ratefunction sg2044_div_enablefunction sg2044_div_disablefunction sg2044_div_is_enabledfunction sg2044_mux_notifier_cbfunction sg2044_clk_fix_init_parentfunction sg2044_clk_init_ctrlfunction sg2044_clk_probe
Annotated Snippet
struct sg2044_div_internal {
u32 offset;
u32 initval;
u8 shift;
u8 width;
u16 flags;
};
struct sg2044_mux_internal {
const u32 *table;
u32 offset;
u16 shift;
u16 flags;
};
struct sg2044_gate_internal {
u32 offset;
u16 shift;
u16 flags;
};
struct sg2044_clk_common {
struct clk_hw hw;
void __iomem *base;
spinlock_t *lock;
unsigned int id;
};
struct sg2044_div {
struct sg2044_clk_common common;
struct sg2044_div_internal div;
};
struct sg2044_mux {
struct sg2044_clk_common common;
struct sg2044_mux_internal mux;
struct notifier_block nb;
u8 saved_parent;
};
struct sg2044_gate {
struct sg2044_clk_common common;
struct sg2044_gate_internal gate;
};
struct sg2044_clk_ctrl {
spinlock_t lock;
struct clk_hw_onecell_data data;
};
struct sg2044_clk_desc_data {
struct sg2044_clk_common * const *pll;
struct sg2044_clk_common * const *div;
struct sg2044_clk_common * const *mux;
struct sg2044_clk_common * const *gate;
u16 num_pll;
u16 num_div;
u16 num_mux;
u16 num_gate;
};
#define hw_to_sg2044_clk_common(_hw) \
container_of((_hw), struct sg2044_clk_common, hw)
static inline struct sg2044_div *hw_to_sg2044_div(struct clk_hw *hw)
{
return container_of(hw_to_sg2044_clk_common(hw),
struct sg2044_div, common);
}
static u32 sg2044_div_get_reg_div(u32 reg, struct sg2044_div_internal *div)
{
if ((reg & DIV_FACTOR_REG_SOURCE))
return (reg >> div->shift) & clk_div_mask(div->width);
return div->initval == 0 ? 1 : div->initval;
}
static unsigned long _sg2044_div_recalc_rate(struct sg2044_clk_common *common,
struct sg2044_div_internal *div,
unsigned long parent_rate)
{
u32 reg = readl(common->base + div->offset);
u32 val = sg2044_div_get_reg_div(reg, div);
return divider_recalc_rate(&common->hw, parent_rate, val, NULL,
div->flags, div->width);
}
static unsigned long sg2044_div_recalc_rate(struct clk_hw *hw,
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/bitfield.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/io.h`, `linux/iopoll.h`.
- Detected declarations: `struct sg2044_div_internal`, `struct sg2044_mux_internal`, `struct sg2044_gate_internal`, `struct sg2044_clk_common`, `struct sg2044_div`, `struct sg2044_mux`, `struct sg2044_gate`, `struct sg2044_clk_ctrl`, `struct sg2044_clk_desc_data`, `function sg2044_div_get_reg_div`.
- 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.