Skip to content

Commit d06b104

Browse files
Ansuelandersson
authored andcommitted
clk: qcom: clk-rcg: introduce support for multiple conf for same freq
Some RCG frequency can be reached by multiple configuration. We currently declare multiple configuration for the same frequency but that is not supported and always the first configuration will be taken. These multiple configuration are needed as based on the current parent configuration, it may be needed to use a different configuration to reach the same frequency. To handle this introduce 3 new macro, C, FM and FMS: - C is used to declare a freq_conf where src, pre_div, m and n are provided. - FM is used to declare a freq_multi_tbl with the frequency and an array of confs to insert all the config for the provided frequency. - FMS is used to declare a freq_multi_tbl with the frequency and an array of a single conf with the provided src, pre_div, m and n. Struct clk_rcg2 is changed to add a union type to reference a simple freq_tbl or a complex freq_multi_tbl. Signed-off-by: Christian Marangi <[email protected]> Acked-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 3db0f3b commit d06b104

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

drivers/clk/qcom/clk-rcg.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ struct freq_tbl {
1717
u16 n;
1818
};
1919

20+
#define C(s, h, m, n) { (s), (2 * (h) - 1), (m), (n) }
21+
#define FM(f, confs) { (f), ARRAY_SIZE(confs), (confs) }
22+
#define FMS(f, s, h, m, n) { (f), 1, (const struct freq_conf []){ C(s, h, m, n) } }
23+
24+
struct freq_conf {
25+
u8 src;
26+
u8 pre_div;
27+
u16 m;
28+
u16 n;
29+
};
30+
31+
struct freq_multi_tbl {
32+
unsigned long freq;
33+
size_t num_confs;
34+
const struct freq_conf *confs;
35+
};
36+
2037
/**
2138
* struct mn - M/N:D counter
2239
* @mnctr_en_bit: bit to enable mn counter
@@ -138,6 +155,7 @@ extern const struct clk_ops clk_dyn_rcg_ops;
138155
* @safe_src_index: safe src index value
139156
* @parent_map: map from software's parent index to hardware's src_sel field
140157
* @freq_tbl: frequency table
158+
* @freq_multi_tbl: frequency table for clocks reachable with multiple RCGs conf
141159
* @clkr: regmap clock handle
142160
* @cfg_off: defines the cfg register offset from the CMD_RCGR + CFG_REG
143161
* @parked_cfg: cached value of the CFG register for parked RCGs
@@ -149,7 +167,10 @@ struct clk_rcg2 {
149167
u8 hid_width;
150168
u8 safe_src_index;
151169
const struct parent_map *parent_map;
152-
const struct freq_tbl *freq_tbl;
170+
union {
171+
const struct freq_tbl *freq_tbl;
172+
const struct freq_multi_tbl *freq_multi_tbl;
173+
};
153174
struct clk_regmap clkr;
154175
u8 cfg_off;
155176
u32 parked_cfg;

0 commit comments

Comments
 (0)