drivers/clk/x86/clk-cgu.c
Source file repositories/reference/linux-study-clean/drivers/clk/x86/clk-cgu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/x86/clk-cgu.c- Extension
.c- Size
- 14221 bytes
- Lines
- 586
- 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-provider.hlinux/device.hlinux/of.hclk-cgu.h
Detected Declarations
function Copyrightfunction lgm_clk_mux_get_parentfunction lgm_clk_mux_set_parentfunction lgm_clk_mux_determine_ratefunction lgm_clk_register_muxfunction lgm_clk_divider_recalc_ratefunction lgm_clk_divider_determine_ratefunction lgm_clk_divider_set_ratefunction lgm_clk_divider_enable_disablefunction lgm_clk_divider_enablefunction lgm_clk_divider_disablefunction lgm_clk_register_dividerfunction lgm_clk_register_fixed_factorfunction lgm_clk_gate_enablefunction lgm_clk_gate_disablefunction lgm_clk_gate_is_enabledfunction lgm_clk_register_gatefunction lgm_clk_register_branchesfunction lgm_clk_ddiv_recalc_ratefunction lgm_clk_ddiv_enablefunction lgm_clk_ddiv_disablefunction lgm_clk_get_ddiv_valfunction lgm_clk_ddiv_set_ratefunction lgm_clk_ddiv_determine_ratefunction lgm_clk_register_ddiv
Annotated Snippet
switch (list->type) {
case CLK_TYPE_FIXED:
hw = lgm_clk_register_fixed(ctx, list);
break;
case CLK_TYPE_MUX:
hw = lgm_clk_register_mux(ctx, list);
break;
case CLK_TYPE_DIVIDER:
hw = lgm_clk_register_divider(ctx, list);
break;
case CLK_TYPE_FIXED_FACTOR:
hw = lgm_clk_register_fixed_factor(ctx, list);
break;
case CLK_TYPE_GATE:
if (list->gate_flags & GATE_CLK_HW) {
hw = lgm_clk_register_gate(ctx, list);
} else {
/*
* GATE_CLKs can be controlled either from
* CGU clk driver i.e. this driver or directly
* from power management driver/daemon. It is
* dependent on the power policy/profile requirements
* of the end product. To override control of gate
* clks from this driver, provide NULL for this index
* of gate clk provider.
*/
hw = NULL;
}
break;
default:
dev_err(ctx->dev, "invalid clk type\n");
return -EINVAL;
}
if (IS_ERR(hw)) {
dev_err(ctx->dev,
"register clk: %s, type: %u failed!\n",
list->name, list->type);
return -EIO;
}
ctx->clk_data.hws[list->id] = hw;
}
return 0;
}
static unsigned long
lgm_clk_ddiv_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
{
struct lgm_clk_ddiv *ddiv = to_lgm_clk_ddiv(hw);
unsigned int div0, div1, exdiv;
u64 prate;
div0 = lgm_get_clk_val(ddiv->membase, ddiv->reg,
ddiv->shift0, ddiv->width0) + 1;
div1 = lgm_get_clk_val(ddiv->membase, ddiv->reg,
ddiv->shift1, ddiv->width1) + 1;
exdiv = lgm_get_clk_val(ddiv->membase, ddiv->reg,
ddiv->shift2, ddiv->width2);
prate = (u64)parent_rate;
do_div(prate, div0);
do_div(prate, div1);
if (exdiv) {
do_div(prate, ddiv->div);
prate *= ddiv->mult;
}
return prate;
}
static int lgm_clk_ddiv_enable(struct clk_hw *hw)
{
struct lgm_clk_ddiv *ddiv = to_lgm_clk_ddiv(hw);
lgm_set_clk_val(ddiv->membase, ddiv->reg, ddiv->shift_gate,
ddiv->width_gate, 1);
return 0;
}
static void lgm_clk_ddiv_disable(struct clk_hw *hw)
{
struct lgm_clk_ddiv *ddiv = to_lgm_clk_ddiv(hw);
lgm_set_clk_val(ddiv->membase, ddiv->reg, ddiv->shift_gate,
ddiv->width_gate, 0);
}
static int
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/device.h`, `linux/of.h`, `clk-cgu.h`.
- Detected declarations: `function Copyright`, `function lgm_clk_mux_get_parent`, `function lgm_clk_mux_set_parent`, `function lgm_clk_mux_determine_rate`, `function lgm_clk_register_mux`, `function lgm_clk_divider_recalc_rate`, `function lgm_clk_divider_determine_rate`, `function lgm_clk_divider_set_rate`, `function lgm_clk_divider_enable_disable`, `function lgm_clk_divider_enable`.
- 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.