drivers/clk/sophgo/clk-sg2044-pll.c
Source file repositories/reference/linux-study-clean/drivers/clk/sophgo/clk-sg2044-pll.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/sophgo/clk-sg2044-pll.c- Extension
.c- Size
- 16269 bytes
- Lines
- 629
- 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-pll.h
Detected Declarations
struct sg2044_pll_limitstruct sg2044_pll_internalstruct sg2044_clk_commonstruct sg2044_pllstruct sg2044_pll_desc_datastruct sg2044_pll_ctrlfunction sg2044_clk_fit_limitfunction sg2044_pll_calc_vco_ratefunction sg2044_pll_calc_ratefunction sg2044_pll_recalc_ratefunction pll_is_better_ratefunction sg2042_pll_compute_postdivfunction for_each_pll_limit_rangefunction sg2044_compute_pll_settingfunction for_each_pll_limit_rangefunction sg2044_pll_determine_ratefunction sg2044_pll_poll_updatefunction sg2044_pll_enablefunction sg2044_pll_update_vcoselfunction sg2044_pll_set_ratefunction sg2044_pll_init_ctrlfunction sg2044_pll_probe
Annotated Snippet
struct sg2044_pll_limit {
u64 min;
u64 max;
};
struct sg2044_pll_internal {
u32 ctrl_offset;
u32 status_offset;
u32 enable_offset;
u8 status_lock_bit;
u8 status_updating_bit;
u8 enable_bit;
const struct sg2044_pll_limit *limits;
};
struct sg2044_clk_common {
struct clk_hw hw;
struct regmap *regmap;
spinlock_t *lock;
unsigned int id;
};
struct sg2044_pll {
struct sg2044_clk_common common;
struct sg2044_pll_internal pll;
unsigned int syscon_offset;
};
struct sg2044_pll_desc_data {
struct sg2044_clk_common * const *pll;
u16 num_pll;
};
#define SG2044_SYSCON_PLL_OFFSET 0x98
struct sg2044_pll_ctrl {
spinlock_t lock;
struct clk_hw_onecell_data data;
};
#define hw_to_sg2044_clk_common(_hw) \
container_of((_hw), struct sg2044_clk_common, hw)
static inline bool sg2044_clk_fit_limit(u64 value,
const struct sg2044_pll_limit *limit)
{
return value >= limit->min && value <= limit->max;
}
static inline struct sg2044_pll *hw_to_sg2044_pll(struct clk_hw *hw)
{
return container_of(hw_to_sg2044_clk_common(hw),
struct sg2044_pll, common);
}
static unsigned long sg2044_pll_calc_vco_rate(unsigned long parent_rate,
unsigned long refdiv,
unsigned long fbdiv)
{
u64 numerator = parent_rate * fbdiv;
return div64_ul(numerator, refdiv);
}
static unsigned long sg2044_pll_calc_rate(unsigned long parent_rate,
unsigned long refdiv,
unsigned long fbdiv,
unsigned long postdiv1,
unsigned long postdiv2)
{
u64 numerator, denominator;
numerator = parent_rate * fbdiv;
denominator = refdiv * (postdiv1 + 1) * (postdiv2 + 1);
return div64_u64(numerator, denominator);
}
static unsigned long sg2044_pll_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct sg2044_pll *pll = hw_to_sg2044_pll(hw);
u32 value;
int ret;
ret = regmap_read(pll->common.regmap,
pll->syscon_offset + pll->pll.ctrl_offset + PLL_HIGH_CTRL_OFFSET,
&value);
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_pll_limit`, `struct sg2044_pll_internal`, `struct sg2044_clk_common`, `struct sg2044_pll`, `struct sg2044_pll_desc_data`, `struct sg2044_pll_ctrl`, `function sg2044_clk_fit_limit`, `function sg2044_pll_calc_vco_rate`, `function sg2044_pll_calc_rate`, `function sg2044_pll_recalc_rate`.
- 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.