c75cd16d6bdcbcdfab0108ecbb611305dddc8917
[openwrt/staging/stintel.git] /
1 From d06b1043644a1831ab141bbee2669002bba15b0f Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Wed, 20 Dec 2023 23:17:22 +0100
4 Subject: [PATCH 1/2] clk: qcom: clk-rcg: introduce support for multiple conf
5 for same freq
6
7 Some RCG frequency can be reached by multiple configuration.
8
9 We currently declare multiple configuration for the same frequency but
10 that is not supported and always the first configuration will be taken.
11
12 These multiple configuration are needed as based on the current parent
13 configuration, it may be needed to use a different configuration to
14 reach the same frequency.
15
16 To handle this introduce 3 new macro, C, FM and FMS:
17
18 - C is used to declare a freq_conf where src, pre_div, m and n are
19 provided.
20
21 - FM is used to declare a freq_multi_tbl with the frequency and an
22 array of confs to insert all the config for the provided frequency.
23
24 - FMS is used to declare a freq_multi_tbl with the frequency and an
25 array of a single conf with the provided src, pre_div, m and n.
26
27 Struct clk_rcg2 is changed to add a union type to reference a simple
28 freq_tbl or a complex freq_multi_tbl.
29
30 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
31 Acked-by: Stephen Boyd <sboyd@kernel.org>
32 Link: https://lore.kernel.org/r/20231220221724.3822-2-ansuelsmth@gmail.com
33 Signed-off-by: Bjorn Andersson <andersson@kernel.org>
34 ---
35 drivers/clk/qcom/clk-rcg.h | 23 ++++++++++++++++++++++-
36 1 file changed, 22 insertions(+), 1 deletion(-)
37
38 diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h
39 index e6d84c8c7989..c50e6616d02c 100644
40 --- a/drivers/clk/qcom/clk-rcg.h
41 +++ b/drivers/clk/qcom/clk-rcg.h
42 @@ -17,6 +17,23 @@ struct freq_tbl {
43 u16 n;
44 };
45
46 +#define C(s, h, m, n) { (s), (2 * (h) - 1), (m), (n) }
47 +#define FM(f, confs) { (f), ARRAY_SIZE(confs), (confs) }
48 +#define FMS(f, s, h, m, n) { (f), 1, (const struct freq_conf []){ C(s, h, m, n) } }
49 +
50 +struct freq_conf {
51 + u8 src;
52 + u8 pre_div;
53 + u16 m;
54 + u16 n;
55 +};
56 +
57 +struct freq_multi_tbl {
58 + unsigned long freq;
59 + size_t num_confs;
60 + const struct freq_conf *confs;
61 +};
62 +
63 /**
64 * struct mn - M/N:D counter
65 * @mnctr_en_bit: bit to enable mn counter
66 @@ -138,6 +155,7 @@ extern const struct clk_ops clk_dyn_rcg_ops;
67 * @safe_src_index: safe src index value
68 * @parent_map: map from software's parent index to hardware's src_sel field
69 * @freq_tbl: frequency table
70 + * @freq_multi_tbl: frequency table for clocks reachable with multiple RCGs conf
71 * @clkr: regmap clock handle
72 * @cfg_off: defines the cfg register offset from the CMD_RCGR + CFG_REG
73 * @parked_cfg: cached value of the CFG register for parked RCGs
74 @@ -149,7 +167,10 @@ struct clk_rcg2 {
75 u8 hid_width;
76 u8 safe_src_index;
77 const struct parent_map *parent_map;
78 - const struct freq_tbl *freq_tbl;
79 + union {
80 + const struct freq_tbl *freq_tbl;
81 + const struct freq_multi_tbl *freq_multi_tbl;
82 + };
83 struct clk_regmap clkr;
84 u8 cfg_off;
85 u32 parked_cfg;
86 --
87 2.45.2
88