drivers/clk/samsung/clk-cpu.c
Source file repositories/reference/linux-study-clean/drivers/clk/samsung/clk-cpu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/samsung/clk-cpu.c- Extension
.c- Size
- 23392 bytes
- Lines
- 728
- 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/delay.hlinux/errno.hlinux/io.hlinux/slab.hlinux/clk.hlinux/clk-provider.hclk.hclk-cpu.h
Detected Declarations
struct exynos_cpuclkstruct exynos_cpuclk_regsstruct exynos_cpuclk_chipstruct exynos_cpuclkfunction dividerfunction wait_until_mux_stablefunction exynos_set_safe_divfunction exynos_cpuclk_pre_rate_changefunction exynos_cpuclk_post_rate_changefunction exynos5433_cpuclk_pre_rate_changefunction exynos5433_cpuclk_post_rate_changefunction exynos850_alt_parent_set_max_ratefunction exynos850_cpuclk_pre_rate_changefunction exynos850_cpuclk_post_rate_changefunction exynos_cpuclk_determine_ratefunction exynos_cpuclk_recalc_ratefunction exynos_cpuclk_notifier_cbfunction exynos_register_cpu_clockfunction samsung_clk_register_cpu
Annotated Snippet
struct exynos_cpuclk_regs {
u32 mux_sel;
u32 mux_stat;
u32 div_cpu0;
u32 div_cpu1;
u32 div_stat_cpu0;
u32 div_stat_cpu1;
u32 mux;
u32 divs[4];
};
/**
* struct exynos_cpuclk_chip - Chip specific data for CPU clock
* @regs: register offsets for CPU related clocks
* @pre_rate_cb: callback to run before CPU clock rate change
* @post_rate_cb: callback to run after CPU clock rate change
*/
struct exynos_cpuclk_chip {
const struct exynos_cpuclk_regs *regs;
exynos_rate_change_fn_t pre_rate_cb;
exynos_rate_change_fn_t post_rate_cb;
};
/**
* struct exynos_cpuclk - information about clock supplied to a CPU core
* @hw: handle between CCF and CPU clock
* @alt_parent: alternate parent clock to use when switching the speed
* of the primary parent clock
* @base: start address of the CPU clock registers block
* @lock: cpu clock domain register access lock
* @cfg: cpu clock rate configuration data
* @num_cfgs: number of array elements in @cfg array
* @clk_nb: clock notifier registered for changes in clock speed of the
* primary parent clock
* @flags: configuration flags for the CPU clock
* @chip: chip-specific data for the CPU clock
*
* This structure holds information required for programming the CPU clock for
* various clock speeds.
*/
struct exynos_cpuclk {
struct clk_hw hw;
const struct clk_hw *alt_parent;
void __iomem *base;
spinlock_t *lock;
const struct exynos_cpuclk_cfg_data *cfg;
const unsigned long num_cfgs;
struct notifier_block clk_nb;
unsigned long flags;
const struct exynos_cpuclk_chip *chip;
};
/* ---- Common code --------------------------------------------------------- */
/* Divider stabilization time, msec */
#define MAX_STAB_TIME 10
#define MAX_DIV 8
#define DIV_MASK GENMASK(2, 0)
#define DIV_MASK_ALL GENMASK(31, 0)
#define MUX_MASK GENMASK(2, 0)
/*
* Helper function to wait until divider(s) have stabilized after the divider
* value has changed.
*/
static void wait_until_divider_stable(void __iomem *div_reg, unsigned long mask)
{
unsigned long timeout = jiffies + msecs_to_jiffies(MAX_STAB_TIME);
do {
if (!(readl(div_reg) & mask))
return;
} while (time_before(jiffies, timeout));
if (!(readl(div_reg) & mask))
return;
pr_err("%s: timeout in divider stabilization\n", __func__);
}
/*
* Helper function to wait until mux has stabilized after the mux selection
* value was changed.
*/
static void wait_until_mux_stable(void __iomem *mux_reg, u32 mux_pos,
unsigned long mask, unsigned long mux_value)
{
unsigned long timeout = jiffies + msecs_to_jiffies(MAX_STAB_TIME);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/errno.h`, `linux/io.h`, `linux/slab.h`, `linux/clk.h`, `linux/clk-provider.h`, `clk.h`, `clk-cpu.h`.
- Detected declarations: `struct exynos_cpuclk`, `struct exynos_cpuclk_regs`, `struct exynos_cpuclk_chip`, `struct exynos_cpuclk`, `function divider`, `function wait_until_mux_stable`, `function exynos_set_safe_div`, `function exynos_cpuclk_pre_rate_change`, `function exynos_cpuclk_post_rate_change`, `function exynos5433_cpuclk_pre_rate_change`.
- 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.