drivers/clk/sophgo/clk-cv18xx-ip.c
Source file repositories/reference/linux-study-clean/drivers/clk/sophgo/clk-cv18xx-ip.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/sophgo/clk-cv18xx-ip.c- Extension
.c- Size
- 21707 bytes
- Lines
- 906
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk-provider.hlinux/io.hlinux/gcd.hlinux/spinlock.hclk-cv18xx-ip.h
Detected Declarations
function Copyrightfunction gate_enablefunction gate_disablefunction gate_is_enabledfunction gate_recalc_ratefunction gate_determine_ratefunction gate_set_ratefunction div_enablefunction div_disablefunction div_is_enabledfunction div_helper_set_ratefunction div_helper_get_clockdivfunction div_helper_determine_ratefunction do_div_determine_ratefunction div_is_better_ratefunction mux_helper_determine_ratefunction div_determine_ratefunction div_recalc_ratefunction div_set_ratefunction hw_to_cv1800_clk_bypass_divfunction do_bypass_div_determine_ratefunction bypass_div_determine_ratefunction bypass_div_recalc_ratefunction bypass_div_set_ratefunction bypass_div_get_parentfunction bypass_div_set_parentfunction mux_enablefunction mux_disablefunction mux_is_enabledfunction do_mux_determine_ratefunction mux_determine_ratefunction mux_recalc_ratefunction mux_set_ratefunction mux_get_parentfunction _mux_set_parentfunction mux_set_parentfunction hw_to_cv1800_clk_bypass_muxfunction do_bypass_mux_determine_ratefunction bypass_mux_determine_ratefunction bypass_mux_recalc_ratefunction bypass_mux_set_ratefunction bypass_mux_get_parentfunction bypass_mux_set_parentfunction mmux_get_parent_idfunction mmux_enablefunction mmux_disablefunction mmux_is_enabledfunction do_mmux_determine_rate
Annotated Snippet
if (tmp_req.rate == req->rate) {
best_parent = parent;
best_parent_rate = tmp_req.best_parent_rate;
best_rate = tmp_req.rate;
goto find;
}
if (div_is_better_rate(common, req->rate,
tmp_req.rate, best_rate)) {
best_parent = parent;
best_parent_rate = tmp_req.best_parent_rate;
best_rate = tmp_req.rate;
}
}
if (best_rate == 0)
return -EINVAL;
find:
req->best_parent_hw = best_parent;
req->best_parent_rate = best_parent_rate;
req->rate = best_rate;
return 0;
}
static int div_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
struct cv1800_clk_div *div = hw_to_cv1800_clk_div(hw);
return mux_helper_determine_rate(&div->common, req,
do_div_determine_rate, div);
}
static unsigned long div_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct cv1800_clk_div *div = hw_to_cv1800_clk_div(hw);
unsigned long val;
val = div_helper_get_clockdiv(&div->common, &div->div);
if (val == 0)
return 0;
return divider_recalc_rate(hw, parent_rate, val, NULL,
div->div.flags, div->div.width);
}
static int div_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct cv1800_clk_div *div = hw_to_cv1800_clk_div(hw);
unsigned long val;
val = divider_get_val(rate, parent_rate, NULL,
div->div.width, div->div.flags);
return div_helper_set_rate(&div->common, &div->div, val);
}
const struct clk_ops cv1800_clk_div_ops = {
.disable = div_disable,
.enable = div_enable,
.is_enabled = div_is_enabled,
.determine_rate = div_determine_rate,
.recalc_rate = div_recalc_rate,
.set_rate = div_set_rate,
};
static inline struct cv1800_clk_bypass_div *
hw_to_cv1800_clk_bypass_div(struct clk_hw *hw)
{
struct cv1800_clk_div *div = hw_to_cv1800_clk_div(hw);
return container_of(div, struct cv1800_clk_bypass_div, div);
}
static int do_bypass_div_determine_rate(struct clk_rate_request *req, int id,
void *data)
{
struct cv1800_clk_bypass_div *div = data;
if (id == -1) {
if (cv1800_clk_checkbit(&div->div.common, &div->bypass)) {
req->rate = req->best_parent_rate;
return 0;
}
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/io.h`, `linux/gcd.h`, `linux/spinlock.h`, `clk-cv18xx-ip.h`.
- Detected declarations: `function Copyright`, `function gate_enable`, `function gate_disable`, `function gate_is_enabled`, `function gate_recalc_rate`, `function gate_determine_rate`, `function gate_set_rate`, `function div_enable`, `function div_disable`, `function div_is_enabled`.
- 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.