drivers/clk/qcom/clk-rcg2.c
Source file repositories/reference/linux-study-clean/drivers/clk/qcom/clk-rcg2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/qcom/clk-rcg2.c- Extension
.c- Size
- 46477 bytes
- Lines
- 1862
- Domain
- Driver Families
- Bucket
- drivers/clk
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/bitops.hlinux/err.hlinux/bug.hlinux/export.hlinux/clk.hlinux/clk-provider.hlinux/delay.hlinux/rational.hlinux/regmap.hlinux/math64.hlinux/gcd.hlinux/minmax.hlinux/slab.hasm/div64.hclk-rcg.hcommon.h
Detected Declarations
struct frac_entryenum freq_policyfunction clk_rcg2_is_enabledfunction __clk_rcg2_get_parentfunction clk_rcg2_get_parentfunction update_configfunction clk_rcg2_set_parentfunction convert_to_reg_valfunction calc_ratefunction __clk_rcg2_recalc_ratefunction clk_rcg2_recalc_ratefunction _freq_tbl_determine_ratefunction __clk_rcg2_select_conffunction _freq_tbl_fm_determine_ratefunction clk_rcg2_determine_ratefunction clk_rcg2_determine_floor_ratefunction clk_rcg2_fm_determine_ratefunction clk_rcg2_split_divfunction clk_rcg2_calc_mndfunction clk_rcg2_determine_gp_ratefunction __clk_rcg2_configure_parentfunction __clk_rcg2_configure_mndfunction __clk_rcg2_configurefunction clk_rcg2_configurefunction clk_rcg2_configure_gpfunction __clk_rcg2_set_ratefunction __clk_rcg2_fm_set_ratefunction clk_rcg2_set_ratefunction clk_rcg2_set_gp_ratefunction clk_rcg2_set_floor_ratefunction clk_rcg2_fm_set_ratefunction clk_rcg2_set_rate_and_parentfunction clk_rcg2_set_floor_rate_and_parentfunction clk_rcg2_fm_set_rate_and_parentfunction clk_rcg2_get_duty_cyclefunction clk_rcg2_set_duty_cyclefunction clk_edp_pixel_set_ratefunction clk_edp_pixel_set_rate_and_parentfunction clk_edp_pixel_determine_ratefunction clk_byte_determine_ratefunction clk_byte_set_ratefunction clk_byte_set_rate_and_parentfunction clk_byte2_determine_ratefunction clk_byte2_set_ratefunction clk_byte2_set_rate_and_parentfunction clk_pixel_determine_ratefunction clk_pixel_set_ratefunction clk_pixel_set_rate_and_parent
Annotated Snippet
struct frac_entry {
int num;
int den;
};
static const struct frac_entry frac_table_675m[] = { /* link rate of 270M */
{ 52, 295 }, /* 119 M */
{ 11, 57 }, /* 130.25 M */
{ 63, 307 }, /* 138.50 M */
{ 11, 50 }, /* 148.50 M */
{ 47, 206 }, /* 154 M */
{ 31, 100 }, /* 205.25 M */
{ 107, 269 }, /* 268.50 M */
{ },
};
static struct frac_entry frac_table_810m[] = { /* Link rate of 162M */
{ 31, 211 }, /* 119 M */
{ 32, 199 }, /* 130.25 M */
{ 63, 307 }, /* 138.50 M */
{ 11, 60 }, /* 148.50 M */
{ 50, 263 }, /* 154 M */
{ 31, 120 }, /* 205.25 M */
{ 119, 359 }, /* 268.50 M */
{ },
};
static int clk_edp_pixel_set_rate(struct clk_hw *hw, unsigned long rate,
unsigned long parent_rate)
{
struct clk_rcg2 *rcg = to_clk_rcg2(hw);
struct freq_tbl f = *rcg->freq_tbl;
const struct frac_entry *frac;
int delta = 100000;
s64 src_rate = parent_rate;
s64 request;
u32 mask = BIT(rcg->hid_width) - 1;
u32 hid_div;
if (src_rate == 810000000)
frac = frac_table_810m;
else
frac = frac_table_675m;
for (; frac->num; frac++) {
request = rate;
request *= frac->den;
request = div_s64(request, frac->num);
if ((src_rate < (request - delta)) ||
(src_rate > (request + delta)))
continue;
regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG,
&hid_div);
f.pre_div = hid_div;
f.pre_div >>= CFG_SRC_DIV_SHIFT;
f.pre_div &= mask;
f.m = frac->num;
f.n = frac->den;
return clk_rcg2_configure(rcg, &f);
}
return -EINVAL;
}
static int clk_edp_pixel_set_rate_and_parent(struct clk_hw *hw,
unsigned long rate, unsigned long parent_rate, u8 index)
{
/* Parent index is set statically in frequency table */
return clk_edp_pixel_set_rate(hw, rate, parent_rate);
}
static int clk_edp_pixel_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
struct clk_rcg2 *rcg = to_clk_rcg2(hw);
const struct freq_tbl *f = rcg->freq_tbl;
const struct frac_entry *frac;
int delta = 100000;
s64 request;
u32 mask = BIT(rcg->hid_width) - 1;
u32 hid_div;
int index = qcom_find_src_index(hw, rcg->parent_map, f->src);
/* Force the correct parent */
req->best_parent_hw = clk_hw_get_parent_by_index(hw, index);
req->best_parent_rate = clk_hw_get_rate(req->best_parent_hw);
if (req->best_parent_rate == 810000000)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/bitops.h`, `linux/err.h`, `linux/bug.h`, `linux/export.h`, `linux/clk.h`, `linux/clk-provider.h`, `linux/delay.h`.
- Detected declarations: `struct frac_entry`, `enum freq_policy`, `function clk_rcg2_is_enabled`, `function __clk_rcg2_get_parent`, `function clk_rcg2_get_parent`, `function update_config`, `function clk_rcg2_set_parent`, `function convert_to_reg_val`, `function calc_rate`, `function __clk_rcg2_recalc_rate`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: integration 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.