aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/clk/clk.c8
-rw-r--r--drivers/clk/mediatek/clk-mt2712.c69
-rw-r--r--drivers/clk/mvebu/armada-38x.c14
-rw-r--r--drivers/clk/mvebu/cp110-system-controller.c94
-rw-r--r--drivers/clk/nxp/clk-lpc32xx.c1
-rw-r--r--drivers/clk/qcom/clk-rpm.c79
-rw-r--r--include/dt-bindings/clock/mt2712-clk.h12
-rw-r--r--include/dt-bindings/clock/qcom,rpmcc.h5
8 files changed, 202 insertions, 80 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 037035a46b33..ea67ac81c6f9 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2311,8 +2311,11 @@ static int clk_core_set_phase_nolock(struct clk_core *core, int degrees)
2311 2311
2312 trace_clk_set_phase(core, degrees); 2312 trace_clk_set_phase(core, degrees);
2313 2313
2314 if (core->ops->set_phase) 2314 if (core->ops->set_phase) {
2315 ret = core->ops->set_phase(core->hw, degrees); 2315 ret = core->ops->set_phase(core->hw, degrees);
2316 if (!ret)
2317 core->phase = degrees;
2318 }
2316 2319
2317 trace_clk_set_phase_complete(core, degrees); 2320 trace_clk_set_phase_complete(core, degrees);
2318 2321
@@ -2372,6 +2375,9 @@ static int clk_core_get_phase(struct clk_core *core)
2372 int ret; 2375 int ret;
2373 2376
2374 clk_prepare_lock(); 2377 clk_prepare_lock();
2378 /* Always try to update cached phase if possible */
2379 if (core->ops->get_phase)
2380 core->phase = core->ops->get_phase(core->hw);
2375 ret = core->phase; 2381 ret = core->phase;
2376 clk_prepare_unlock(); 2382 clk_prepare_unlock();
2377 2383
diff --git a/drivers/clk/mediatek/clk-mt2712.c b/drivers/clk/mediatek/clk-mt2712.c
index 498d13799388..991d4093726e 100644
--- a/drivers/clk/mediatek/clk-mt2712.c
+++ b/drivers/clk/mediatek/clk-mt2712.c
@@ -221,6 +221,8 @@ static const struct mtk_fixed_factor top_divs[] = {
221 4), 221 4),
222 FACTOR(CLK_TOP_D2A_ULCLK_6P5M, "d2a_ulclk_6p5m", "clk26m", 1, 222 FACTOR(CLK_TOP_D2A_ULCLK_6P5M, "d2a_ulclk_6p5m", "clk26m", 1,
223 4), 223 4),
224 FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1_ck", 1,
225 3),
224}; 226};
225 227
226static const char * const axi_parents[] = { 228static const char * const axi_parents[] = {
@@ -625,7 +627,7 @@ static const char * const ether_125m_parents[] = {
625static const char * const ether_50m_parents[] = { 627static const char * const ether_50m_parents[] = {
626 "clk26m", 628 "clk26m",
627 "etherpll_50m", 629 "etherpll_50m",
628 "univpll_d26", 630 "apll1_d3",
629 "univpll3_d4" 631 "univpll3_d4"
630}; 632};
631 633
@@ -686,7 +688,7 @@ static const char * const i2c_parents[] = {
686 688
687static const char * const msdc0p_aes_parents[] = { 689static const char * const msdc0p_aes_parents[] = {
688 "clk26m", 690 "clk26m",
689 "msdcpll_ck", 691 "syspll_d2",
690 "univpll_d3", 692 "univpll_d3",
691 "vcodecpll_ck" 693 "vcodecpll_ck"
692}; 694};
@@ -719,6 +721,17 @@ static const char * const aud_apll2_parents[] = {
719 "clkaud_ext_i_2" 721 "clkaud_ext_i_2"
720}; 722};
721 723
724static const char * const apll1_ref_parents[] = {
725 "clkaud_ext_i_2",
726 "clkaud_ext_i_1",
727 "clki2si0_mck_i",
728 "clki2si1_mck_i",
729 "clki2si2_mck_i",
730 "clktdmin_mclk_i",
731 "clki2si2_mck_i",
732 "clktdmin_mclk_i"
733};
734
722static const char * const audull_vtx_parents[] = { 735static const char * const audull_vtx_parents[] = {
723 "d2a_ulclk_6p5m", 736 "d2a_ulclk_6p5m",
724 "clkaud_ext_i_0" 737 "clkaud_ext_i_0"
@@ -886,6 +899,10 @@ static struct mtk_composite top_muxes[] = {
886 aud_apll2_parents, 0x134, 1, 1), 899 aud_apll2_parents, 0x134, 1, 1),
887 MUX(CLK_TOP_DA_AUDULL_VTX_6P5M_SEL, "audull_vtx_sel", 900 MUX(CLK_TOP_DA_AUDULL_VTX_6P5M_SEL, "audull_vtx_sel",
888 audull_vtx_parents, 0x134, 31, 1), 901 audull_vtx_parents, 0x134, 31, 1),
902 MUX(CLK_TOP_APLL1_REF_SEL, "apll1_ref_sel",
903 apll1_ref_parents, 0x134, 4, 3),
904 MUX(CLK_TOP_APLL2_REF_SEL, "apll2_ref_sel",
905 apll1_ref_parents, 0x134, 7, 3),
889}; 906};
890 907
891static const char * const mcu_mp0_parents[] = { 908static const char * const mcu_mp0_parents[] = {
@@ -932,36 +949,56 @@ static const struct mtk_clk_divider top_adj_divs[] = {
932 DIV_ADJ(CLK_TOP_APLL_DIV7, "apll_div7", "i2si3_sel", 0x128, 24, 8), 949 DIV_ADJ(CLK_TOP_APLL_DIV7, "apll_div7", "i2si3_sel", 0x128, 24, 8),
933}; 950};
934 951
935static const struct mtk_gate_regs top_cg_regs = { 952static const struct mtk_gate_regs top0_cg_regs = {
936 .set_ofs = 0x120, 953 .set_ofs = 0x120,
937 .clr_ofs = 0x120, 954 .clr_ofs = 0x120,
938 .sta_ofs = 0x120, 955 .sta_ofs = 0x120,
939}; 956};
940 957
941#define GATE_TOP(_id, _name, _parent, _shift) { \ 958static const struct mtk_gate_regs top1_cg_regs = {
959 .set_ofs = 0x424,
960 .clr_ofs = 0x424,
961 .sta_ofs = 0x424,
962};
963
964#define GATE_TOP0(_id, _name, _parent, _shift) { \
942 .id = _id, \ 965 .id = _id, \
943 .name = _name, \ 966 .name = _name, \
944 .parent_name = _parent, \ 967 .parent_name = _parent, \
945 .regs = &top_cg_regs, \ 968 .regs = &top0_cg_regs, \
946 .shift = _shift, \ 969 .shift = _shift, \
947 .ops = &mtk_clk_gate_ops_no_setclr, \ 970 .ops = &mtk_clk_gate_ops_no_setclr, \
948 } 971 }
949 972
973#define GATE_TOP1(_id, _name, _parent, _shift) { \
974 .id = _id, \
975 .name = _name, \
976 .parent_name = _parent, \
977 .regs = &top1_cg_regs, \
978 .shift = _shift, \
979 .ops = &mtk_clk_gate_ops_no_setclr_inv, \
980 }
981
950static const struct mtk_gate top_clks[] = { 982static const struct mtk_gate top_clks[] = {
951 GATE_TOP(CLK_TOP_APLL_DIV_PDN0, "apll_div_pdn0", "i2so1_sel", 0), 983 /* TOP0 */
952 GATE_TOP(CLK_TOP_APLL_DIV_PDN1, "apll_div_pdn1", "i2so2_sel", 1), 984 GATE_TOP0(CLK_TOP_APLL_DIV_PDN0, "apll_div_pdn0", "i2so1_sel", 0),
953 GATE_TOP(CLK_TOP_APLL_DIV_PDN2, "apll_div_pdn2", "i2so3_sel", 2), 985 GATE_TOP0(CLK_TOP_APLL_DIV_PDN1, "apll_div_pdn1", "i2so2_sel", 1),
954 GATE_TOP(CLK_TOP_APLL_DIV_PDN3, "apll_div_pdn3", "tdmo0_sel", 3), 986 GATE_TOP0(CLK_TOP_APLL_DIV_PDN2, "apll_div_pdn2", "i2so3_sel", 2),
955 GATE_TOP(CLK_TOP_APLL_DIV_PDN4, "apll_div_pdn4", "tdmo1_sel", 4), 987 GATE_TOP0(CLK_TOP_APLL_DIV_PDN3, "apll_div_pdn3", "tdmo0_sel", 3),
956 GATE_TOP(CLK_TOP_APLL_DIV_PDN5, "apll_div_pdn5", "i2si1_sel", 5), 988 GATE_TOP0(CLK_TOP_APLL_DIV_PDN4, "apll_div_pdn4", "tdmo1_sel", 4),
957 GATE_TOP(CLK_TOP_APLL_DIV_PDN6, "apll_div_pdn6", "i2si2_sel", 6), 989 GATE_TOP0(CLK_TOP_APLL_DIV_PDN5, "apll_div_pdn5", "i2si1_sel", 5),
958 GATE_TOP(CLK_TOP_APLL_DIV_PDN7, "apll_div_pdn7", "i2si3_sel", 7), 990 GATE_TOP0(CLK_TOP_APLL_DIV_PDN6, "apll_div_pdn6", "i2si2_sel", 6),
991 GATE_TOP0(CLK_TOP_APLL_DIV_PDN7, "apll_div_pdn7", "i2si3_sel", 7),
992 /* TOP1 */
993 GATE_TOP1(CLK_TOP_NFI2X_EN, "nfi2x_en", "nfi2x_sel", 0),
994 GATE_TOP1(CLK_TOP_NFIECC_EN, "nfiecc_en", "nfiecc_sel", 1),
995 GATE_TOP1(CLK_TOP_NFI1X_CK_EN, "nfi1x_ck_en", "nfi2x_sel", 2),
959}; 996};
960 997
961static const struct mtk_gate_regs infra_cg_regs = { 998static const struct mtk_gate_regs infra_cg_regs = {
962 .set_ofs = 0x40, 999 .set_ofs = 0x40,
963 .clr_ofs = 0x44, 1000 .clr_ofs = 0x44,
964 .sta_ofs = 0x40, 1001 .sta_ofs = 0x48,
965}; 1002};
966 1003
967#define GATE_INFRA(_id, _name, _parent, _shift) { \ 1004#define GATE_INFRA(_id, _name, _parent, _shift) { \
@@ -1120,6 +1157,10 @@ static const struct mtk_gate peri_clks[] = {
1120 "msdc50_0_h_sel", 4), 1157 "msdc50_0_h_sel", 4),
1121 GATE_PERI2(CLK_PERI_MSDC50_3_HCLK_EN, "per_msdc50_3_h", 1158 GATE_PERI2(CLK_PERI_MSDC50_3_HCLK_EN, "per_msdc50_3_h",
1122 "msdc50_3_h_sel", 5), 1159 "msdc50_3_h_sel", 5),
1160 GATE_PERI2(CLK_PERI_MSDC30_0_QTR_EN, "per_msdc30_0_q",
1161 "axi_sel", 6),
1162 GATE_PERI2(CLK_PERI_MSDC30_3_QTR_EN, "per_msdc30_3_q",
1163 "mem_sel", 7),
1123}; 1164};
1124 1165
1125#define MT2712_PLL_FMAX (3000UL * MHZ) 1166#define MT2712_PLL_FMAX (3000UL * MHZ)
diff --git a/drivers/clk/mvebu/armada-38x.c b/drivers/clk/mvebu/armada-38x.c
index 394aa6f03f01..9ff4ea63932d 100644
--- a/drivers/clk/mvebu/armada-38x.c
+++ b/drivers/clk/mvebu/armada-38x.c
@@ -46,11 +46,11 @@ static u32 __init armada_38x_get_tclk_freq(void __iomem *sar)
46} 46}
47 47
48static const u32 armada_38x_cpu_frequencies[] __initconst = { 48static const u32 armada_38x_cpu_frequencies[] __initconst = {
49 0, 0, 0, 0, 49 666 * 1000 * 1000, 0, 800 * 1000 * 1000, 0,
50 1066 * 1000 * 1000, 0, 0, 0, 50 1066 * 1000 * 1000, 0, 1200 * 1000 * 1000, 0,
51 1332 * 1000 * 1000, 0, 0, 0, 51 1332 * 1000 * 1000, 0, 0, 0,
52 1600 * 1000 * 1000, 0, 0, 0, 52 1600 * 1000 * 1000, 0, 0, 0,
53 1866 * 1000 * 1000, 53 1866 * 1000 * 1000, 0, 0, 2000 * 1000 * 1000,
54}; 54};
55 55
56static u32 __init armada_38x_get_cpu_freq(void __iomem *sar) 56static u32 __init armada_38x_get_cpu_freq(void __iomem *sar)
@@ -76,11 +76,11 @@ static const struct coreclk_ratio armada_38x_coreclk_ratios[] __initconst = {
76}; 76};
77 77
78static const int armada_38x_cpu_l2_ratios[32][2] __initconst = { 78static const int armada_38x_cpu_l2_ratios[32][2] __initconst = {
79 {0, 1}, {0, 1}, {0, 1}, {0, 1}, 79 {1, 2}, {0, 1}, {1, 2}, {0, 1},
80 {1, 2}, {0, 1}, {0, 1}, {0, 1}, 80 {1, 2}, {0, 1}, {1, 2}, {0, 1},
81 {1, 2}, {0, 1}, {0, 1}, {0, 1},
82 {1, 2}, {0, 1}, {0, 1}, {0, 1}, 81 {1, 2}, {0, 1}, {0, 1}, {0, 1},
83 {1, 2}, {0, 1}, {0, 1}, {0, 1}, 82 {1, 2}, {0, 1}, {0, 1}, {0, 1},
83 {1, 2}, {0, 1}, {0, 1}, {1, 2},
84 {0, 1}, {0, 1}, {0, 1}, {0, 1}, 84 {0, 1}, {0, 1}, {0, 1}, {0, 1},
85 {0, 1}, {0, 1}, {0, 1}, {0, 1}, 85 {0, 1}, {0, 1}, {0, 1}, {0, 1},
86 {0, 1}, {0, 1}, {0, 1}, {0, 1}, 86 {0, 1}, {0, 1}, {0, 1}, {0, 1},
@@ -91,7 +91,7 @@ static const int armada_38x_cpu_ddr_ratios[32][2] __initconst = {
91 {1, 2}, {0, 1}, {0, 1}, {0, 1}, 91 {1, 2}, {0, 1}, {0, 1}, {0, 1},
92 {1, 2}, {0, 1}, {0, 1}, {0, 1}, 92 {1, 2}, {0, 1}, {0, 1}, {0, 1},
93 {1, 2}, {0, 1}, {0, 1}, {0, 1}, 93 {1, 2}, {0, 1}, {0, 1}, {0, 1},
94 {1, 2}, {0, 1}, {0, 1}, {0, 1}, 94 {1, 2}, {0, 1}, {0, 1}, {7, 15},
95 {0, 1}, {0, 1}, {0, 1}, {0, 1}, 95 {0, 1}, {0, 1}, {0, 1}, {0, 1},
96 {0, 1}, {0, 1}, {0, 1}, {0, 1}, 96 {0, 1}, {0, 1}, {0, 1}, {0, 1},
97 {0, 1}, {0, 1}, {0, 1}, {0, 1}, 97 {0, 1}, {0, 1}, {0, 1}, {0, 1},
diff --git a/drivers/clk/mvebu/cp110-system-controller.c b/drivers/clk/mvebu/cp110-system-controller.c
index ca9a0a536174..75bf7b8f282f 100644
--- a/drivers/clk/mvebu/cp110-system-controller.c
+++ b/drivers/clk/mvebu/cp110-system-controller.c
@@ -13,18 +13,17 @@
13/* 13/*
14 * CP110 has 6 core clocks: 14 * CP110 has 6 core clocks:
15 * 15 *
16 * - APLL (1 Ghz) 16 * - PLL0 (1 Ghz)
17 * - PPv2 core (1/3 APLL) 17 * - PPv2 core (1/3 PLL0)
18 * - EIP (1/2 APLL) 18 * - x2 Core (1/2 PLL0)
19 * - Core (1/2 EIP) 19 * - Core (1/2 x2 Core)
20 * - SDIO (2/5 APLL) 20 * - SDIO (2/5 PLL0)
21 * 21 *
22 * - NAND clock, which is either: 22 * - NAND clock, which is either:
23 * - Equal to SDIO clock 23 * - Equal to SDIO clock
24 * - 2/5 APLL 24 * - 2/5 PLL0
25 * 25 *
26 * CP110 has 32 gatable clocks, for the various peripherals in the 26 * CP110 has 32 gatable clocks, for the various peripherals in the IP.
27 * IP. They have fairly complicated parent/child relationships.
28 */ 27 */
29 28
30#define pr_fmt(fmt) "cp110-system-controller: " fmt 29#define pr_fmt(fmt) "cp110-system-controller: " fmt
@@ -53,9 +52,9 @@ enum {
53#define CP110_CLK_NUM \ 52#define CP110_CLK_NUM \
54 (CP110_MAX_CORE_CLOCKS + CP110_MAX_GATABLE_CLOCKS) 53 (CP110_MAX_CORE_CLOCKS + CP110_MAX_GATABLE_CLOCKS)
55 54
56#define CP110_CORE_APLL 0 55#define CP110_CORE_PLL0 0
57#define CP110_CORE_PPV2 1 56#define CP110_CORE_PPV2 1
58#define CP110_CORE_EIP 2 57#define CP110_CORE_X2CORE 2
59#define CP110_CORE_CORE 3 58#define CP110_CORE_CORE 3
60#define CP110_CORE_NAND 4 59#define CP110_CORE_NAND 4
61#define CP110_CORE_SDIO 5 60#define CP110_CORE_SDIO 5
@@ -237,7 +236,7 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
237 struct regmap *regmap; 236 struct regmap *regmap;
238 struct device *dev = &pdev->dev; 237 struct device *dev = &pdev->dev;
239 struct device_node *np = dev->of_node; 238 struct device_node *np = dev->of_node;
240 const char *ppv2_name, *apll_name, *core_name, *eip_name, *nand_name, 239 const char *ppv2_name, *pll0_name, *core_name, *x2core_name, *nand_name,
241 *sdio_name; 240 *sdio_name;
242 struct clk_hw_onecell_data *cp110_clk_data; 241 struct clk_hw_onecell_data *cp110_clk_data;
243 struct clk_hw *hw, **cp110_clks; 242 struct clk_hw *hw, **cp110_clks;
@@ -263,20 +262,20 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
263 cp110_clks = cp110_clk_data->hws; 262 cp110_clks = cp110_clk_data->hws;
264 cp110_clk_data->num = CP110_CLK_NUM; 263 cp110_clk_data->num = CP110_CLK_NUM;
265 264
266 /* Register the APLL which is the root of the hw tree */ 265 /* Register the PLL0 which is the root of the hw tree */
267 apll_name = cp110_unique_name(dev, syscon_node, "apll"); 266 pll0_name = cp110_unique_name(dev, syscon_node, "pll0");
268 hw = clk_hw_register_fixed_rate(NULL, apll_name, NULL, 0, 267 hw = clk_hw_register_fixed_rate(NULL, pll0_name, NULL, 0,
269 1000 * 1000 * 1000); 268 1000 * 1000 * 1000);
270 if (IS_ERR(hw)) { 269 if (IS_ERR(hw)) {
271 ret = PTR_ERR(hw); 270 ret = PTR_ERR(hw);
272 goto fail_apll; 271 goto fail_pll0;
273 } 272 }
274 273
275 cp110_clks[CP110_CORE_APLL] = hw; 274 cp110_clks[CP110_CORE_PLL0] = hw;
276 275
277 /* PPv2 is APLL/3 */ 276 /* PPv2 is PLL0/3 */
278 ppv2_name = cp110_unique_name(dev, syscon_node, "ppv2-core"); 277 ppv2_name = cp110_unique_name(dev, syscon_node, "ppv2-core");
279 hw = clk_hw_register_fixed_factor(NULL, ppv2_name, apll_name, 0, 1, 3); 278 hw = clk_hw_register_fixed_factor(NULL, ppv2_name, pll0_name, 0, 1, 3);
280 if (IS_ERR(hw)) { 279 if (IS_ERR(hw)) {
281 ret = PTR_ERR(hw); 280 ret = PTR_ERR(hw);
282 goto fail_ppv2; 281 goto fail_ppv2;
@@ -284,30 +283,32 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
284 283
285 cp110_clks[CP110_CORE_PPV2] = hw; 284 cp110_clks[CP110_CORE_PPV2] = hw;
286 285
287 /* EIP clock is APLL/2 */ 286 /* X2CORE clock is PLL0/2 */
288 eip_name = cp110_unique_name(dev, syscon_node, "eip"); 287 x2core_name = cp110_unique_name(dev, syscon_node, "x2core");
289 hw = clk_hw_register_fixed_factor(NULL, eip_name, apll_name, 0, 1, 2); 288 hw = clk_hw_register_fixed_factor(NULL, x2core_name, pll0_name,
289 0, 1, 2);
290 if (IS_ERR(hw)) { 290 if (IS_ERR(hw)) {
291 ret = PTR_ERR(hw); 291 ret = PTR_ERR(hw);
292 goto fail_eip; 292 goto fail_eip;
293 } 293 }
294 294
295 cp110_clks[CP110_CORE_EIP] = hw; 295 cp110_clks[CP110_CORE_X2CORE] = hw;
296 296
297 /* Core clock is EIP/2 */ 297 /* Core clock is X2CORE/2 */
298 core_name = cp110_unique_name(dev, syscon_node, "core"); 298 core_name = cp110_unique_name(dev, syscon_node, "core");
299 hw = clk_hw_register_fixed_factor(NULL, core_name, eip_name, 0, 1, 2); 299 hw = clk_hw_register_fixed_factor(NULL, core_name, x2core_name,
300 0, 1, 2);
300 if (IS_ERR(hw)) { 301 if (IS_ERR(hw)) {
301 ret = PTR_ERR(hw); 302 ret = PTR_ERR(hw);
302 goto fail_core; 303 goto fail_core;
303 } 304 }
304 305
305 cp110_clks[CP110_CORE_CORE] = hw; 306 cp110_clks[CP110_CORE_CORE] = hw;
306 /* NAND can be either APLL/2.5 or core clock */ 307 /* NAND can be either PLL0/2.5 or core clock */
307 nand_name = cp110_unique_name(dev, syscon_node, "nand-core"); 308 nand_name = cp110_unique_name(dev, syscon_node, "nand-core");
308 if (nand_clk_ctrl & NF_CLOCK_SEL_400_MASK) 309 if (nand_clk_ctrl & NF_CLOCK_SEL_400_MASK)
309 hw = clk_hw_register_fixed_factor(NULL, nand_name, 310 hw = clk_hw_register_fixed_factor(NULL, nand_name,
310 apll_name, 0, 2, 5); 311 pll0_name, 0, 2, 5);
311 else 312 else
312 hw = clk_hw_register_fixed_factor(NULL, nand_name, 313 hw = clk_hw_register_fixed_factor(NULL, nand_name,
313 core_name, 0, 1, 1); 314 core_name, 0, 1, 1);
@@ -318,10 +319,10 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
318 319
319 cp110_clks[CP110_CORE_NAND] = hw; 320 cp110_clks[CP110_CORE_NAND] = hw;
320 321
321 /* SDIO clock is APLL/2.5 */ 322 /* SDIO clock is PLL0/2.5 */
322 sdio_name = cp110_unique_name(dev, syscon_node, "sdio-core"); 323 sdio_name = cp110_unique_name(dev, syscon_node, "sdio-core");
323 hw = clk_hw_register_fixed_factor(NULL, sdio_name, 324 hw = clk_hw_register_fixed_factor(NULL, sdio_name,
324 apll_name, 0, 2, 5); 325 pll0_name, 0, 2, 5);
325 if (IS_ERR(hw)) { 326 if (IS_ERR(hw)) {
326 ret = PTR_ERR(hw); 327 ret = PTR_ERR(hw);
327 goto fail_sdio; 328 goto fail_sdio;
@@ -341,40 +342,23 @@ static int cp110_syscon_common_probe(struct platform_device *pdev,
341 continue; 342 continue;
342 343
343 switch (i) { 344 switch (i) {
344 case CP110_GATE_AUDIO:
345 case CP110_GATE_COMM_UNIT:
346 case CP110_GATE_EIP150:
347 case CP110_GATE_EIP197:
348 case CP110_GATE_SLOW_IO:
349 parent = gate_name[CP110_GATE_MAIN];
350 break;
351 case CP110_GATE_MG:
352 parent = gate_name[CP110_GATE_MG_CORE];
353 break;
354 case CP110_GATE_NAND: 345 case CP110_GATE_NAND:
355 parent = nand_name; 346 parent = nand_name;
356 break; 347 break;
348 case CP110_GATE_MG:
349 case CP110_GATE_GOP_DP:
357 case CP110_GATE_PPV2: 350 case CP110_GATE_PPV2:
358 parent = ppv2_name; 351 parent = ppv2_name;
359 break; 352 break;
360 case CP110_GATE_SDIO: 353 case CP110_GATE_SDIO:
361 parent = sdio_name; 354 parent = sdio_name;
362 break; 355 break;
363 case CP110_GATE_GOP_DP: 356 case CP110_GATE_MAIN:
364 parent = gate_name[CP110_GATE_SDMMC_GOP]; 357 case CP110_GATE_PCIE_XOR:
365 break;
366 case CP110_GATE_XOR1:
367 case CP110_GATE_XOR0:
368 case CP110_GATE_PCIE_X1_0:
369 case CP110_GATE_PCIE_X1_1:
370 case CP110_GATE_PCIE_X4: 358 case CP110_GATE_PCIE_X4:
371 parent = gate_name[CP110_GATE_PCIE_XOR]; 359 case CP110_GATE_EIP150:
372 break; 360 case CP110_GATE_EIP197:
373 case CP110_GATE_SATA: 361 parent = x2core_name;
374 case CP110_GATE_USB3H0:
375 case CP110_GATE_USB3H1:
376 case CP110_GATE_USB3DEV:
377 parent = gate_name[CP110_GATE_SATA_USB];
378 break; 362 break;
379 default: 363 default:
380 parent = core_name; 364 parent = core_name;
@@ -413,12 +397,12 @@ fail_sdio:
413fail_nand: 397fail_nand:
414 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_CORE]); 398 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_CORE]);
415fail_core: 399fail_core:
416 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_EIP]); 400 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_X2CORE]);
417fail_eip: 401fail_eip:
418 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_PPV2]); 402 clk_hw_unregister_fixed_factor(cp110_clks[CP110_CORE_PPV2]);
419fail_ppv2: 403fail_ppv2:
420 clk_hw_unregister_fixed_rate(cp110_clks[CP110_CORE_APLL]); 404 clk_hw_unregister_fixed_rate(cp110_clks[CP110_CORE_PLL0]);
421fail_apll: 405fail_pll0:
422 return ret; 406 return ret;
423} 407}
424 408
diff --git a/drivers/clk/nxp/clk-lpc32xx.c b/drivers/clk/nxp/clk-lpc32xx.c
index f5d815f577e0..5eeecee17b69 100644
--- a/drivers/clk/nxp/clk-lpc32xx.c
+++ b/drivers/clk/nxp/clk-lpc32xx.c
@@ -67,6 +67,7 @@
67#define LPC32XX_USB_CLK_STS 0xF8 67#define LPC32XX_USB_CLK_STS 0xF8
68 68
69static struct regmap_config lpc32xx_scb_regmap_config = { 69static struct regmap_config lpc32xx_scb_regmap_config = {
70 .name = "scb",
70 .reg_bits = 32, 71 .reg_bits = 32,
71 .val_bits = 32, 72 .val_bits = 32,
72 .reg_stride = 4, 73 .reg_stride = 4,
diff --git a/drivers/clk/qcom/clk-rpm.c b/drivers/clk/qcom/clk-rpm.c
index c60f61b10c7f..b94981447664 100644
--- a/drivers/clk/qcom/clk-rpm.c
+++ b/drivers/clk/qcom/clk-rpm.c
@@ -29,6 +29,7 @@
29 29
30#define QCOM_RPM_MISC_CLK_TYPE 0x306b6c63 30#define QCOM_RPM_MISC_CLK_TYPE 0x306b6c63
31#define QCOM_RPM_SCALING_ENABLE_ID 0x2 31#define QCOM_RPM_SCALING_ENABLE_ID 0x2
32#define QCOM_RPM_XO_MODE_ON 0x2
32 33
33#define DEFINE_CLK_RPM(_platform, _name, _active, r_id) \ 34#define DEFINE_CLK_RPM(_platform, _name, _active, r_id) \
34 static struct clk_rpm _platform##_##_active; \ 35 static struct clk_rpm _platform##_##_active; \
@@ -56,6 +57,18 @@
56 }, \ 57 }, \
57 } 58 }
58 59
60#define DEFINE_CLK_RPM_XO_BUFFER(_platform, _name, _active, offset) \
61 static struct clk_rpm _platform##_##_name = { \
62 .rpm_clk_id = QCOM_RPM_CXO_BUFFERS, \
63 .xo_offset = (offset), \
64 .hw.init = &(struct clk_init_data){ \
65 .ops = &clk_rpm_xo_ops, \
66 .name = #_name, \
67 .parent_names = (const char *[]){ "cxo_board" }, \
68 .num_parents = 1, \
69 }, \
70 }
71
59#define DEFINE_CLK_RPM_FIXED(_platform, _name, _active, r_id, r) \ 72#define DEFINE_CLK_RPM_FIXED(_platform, _name, _active, r_id, r) \
60 static struct clk_rpm _platform##_##_name = { \ 73 static struct clk_rpm _platform##_##_name = { \
61 .rpm_clk_id = (r_id), \ 74 .rpm_clk_id = (r_id), \
@@ -126,8 +139,11 @@
126 139
127#define to_clk_rpm(_hw) container_of(_hw, struct clk_rpm, hw) 140#define to_clk_rpm(_hw) container_of(_hw, struct clk_rpm, hw)
128 141
142struct rpm_cc;
143
129struct clk_rpm { 144struct clk_rpm {
130 const int rpm_clk_id; 145 const int rpm_clk_id;
146 const int xo_offset;
131 const bool active_only; 147 const bool active_only;
132 unsigned long rate; 148 unsigned long rate;
133 bool enabled; 149 bool enabled;
@@ -135,12 +151,15 @@ struct clk_rpm {
135 struct clk_rpm *peer; 151 struct clk_rpm *peer;
136 struct clk_hw hw; 152 struct clk_hw hw;
137 struct qcom_rpm *rpm; 153 struct qcom_rpm *rpm;
154 struct rpm_cc *rpm_cc;
138}; 155};
139 156
140struct rpm_cc { 157struct rpm_cc {
141 struct qcom_rpm *rpm; 158 struct qcom_rpm *rpm;
142 struct clk_rpm **clks; 159 struct clk_rpm **clks;
143 size_t num_clks; 160 size_t num_clks;
161 u32 xo_buffer_value;
162 struct mutex xo_lock;
144}; 163};
145 164
146struct rpm_clk_desc { 165struct rpm_clk_desc {
@@ -159,7 +178,8 @@ static int clk_rpm_handoff(struct clk_rpm *r)
159 * The vendor tree simply reads the status for this 178 * The vendor tree simply reads the status for this
160 * RPM clock. 179 * RPM clock.
161 */ 180 */
162 if (r->rpm_clk_id == QCOM_RPM_PLL_4) 181 if (r->rpm_clk_id == QCOM_RPM_PLL_4 ||
182 r->rpm_clk_id == QCOM_RPM_CXO_BUFFERS)
163 return 0; 183 return 0;
164 184
165 ret = qcom_rpm_write(r->rpm, QCOM_RPM_ACTIVE_STATE, 185 ret = qcom_rpm_write(r->rpm, QCOM_RPM_ACTIVE_STATE,
@@ -288,6 +308,46 @@ out:
288 mutex_unlock(&rpm_clk_lock); 308 mutex_unlock(&rpm_clk_lock);
289} 309}
290 310
311static int clk_rpm_xo_prepare(struct clk_hw *hw)
312{
313 struct clk_rpm *r = to_clk_rpm(hw);
314 struct rpm_cc *rcc = r->rpm_cc;
315 int ret, clk_id = r->rpm_clk_id;
316 u32 value;
317
318 mutex_lock(&rcc->xo_lock);
319
320 value = rcc->xo_buffer_value | (QCOM_RPM_XO_MODE_ON << r->xo_offset);
321 ret = qcom_rpm_write(r->rpm, QCOM_RPM_ACTIVE_STATE, clk_id, &value, 1);
322 if (!ret) {
323 r->enabled = true;
324 rcc->xo_buffer_value = value;
325 }
326
327 mutex_unlock(&rcc->xo_lock);
328
329 return ret;
330}
331
332static void clk_rpm_xo_unprepare(struct clk_hw *hw)
333{
334 struct clk_rpm *r = to_clk_rpm(hw);
335 struct rpm_cc *rcc = r->rpm_cc;
336 int ret, clk_id = r->rpm_clk_id;
337 u32 value;
338
339 mutex_lock(&rcc->xo_lock);
340
341 value = rcc->xo_buffer_value & ~(QCOM_RPM_XO_MODE_ON << r->xo_offset);
342 ret = qcom_rpm_write(r->rpm, QCOM_RPM_ACTIVE_STATE, clk_id, &value, 1);
343 if (!ret) {
344 r->enabled = false;
345 rcc->xo_buffer_value = value;
346 }
347
348 mutex_unlock(&rcc->xo_lock);
349}
350
291static int clk_rpm_fixed_prepare(struct clk_hw *hw) 351static int clk_rpm_fixed_prepare(struct clk_hw *hw)
292{ 352{
293 struct clk_rpm *r = to_clk_rpm(hw); 353 struct clk_rpm *r = to_clk_rpm(hw);
@@ -378,6 +438,11 @@ static unsigned long clk_rpm_recalc_rate(struct clk_hw *hw,
378 return r->rate; 438 return r->rate;
379} 439}
380 440
441static const struct clk_ops clk_rpm_xo_ops = {
442 .prepare = clk_rpm_xo_prepare,
443 .unprepare = clk_rpm_xo_unprepare,
444};
445
381static const struct clk_ops clk_rpm_fixed_ops = { 446static const struct clk_ops clk_rpm_fixed_ops = {
382 .prepare = clk_rpm_fixed_prepare, 447 .prepare = clk_rpm_fixed_prepare,
383 .unprepare = clk_rpm_fixed_unprepare, 448 .unprepare = clk_rpm_fixed_unprepare,
@@ -449,6 +514,11 @@ DEFINE_CLK_RPM(apq8064, mmfpb_clk, mmfpb_a_clk, QCOM_RPM_MMFPB_CLK);
449DEFINE_CLK_RPM(apq8064, sfab_clk, sfab_a_clk, QCOM_RPM_SYS_FABRIC_CLK); 514DEFINE_CLK_RPM(apq8064, sfab_clk, sfab_a_clk, QCOM_RPM_SYS_FABRIC_CLK);
450DEFINE_CLK_RPM(apq8064, sfpb_clk, sfpb_a_clk, QCOM_RPM_SFPB_CLK); 515DEFINE_CLK_RPM(apq8064, sfpb_clk, sfpb_a_clk, QCOM_RPM_SFPB_CLK);
451DEFINE_CLK_RPM(apq8064, qdss_clk, qdss_a_clk, QCOM_RPM_QDSS_CLK); 516DEFINE_CLK_RPM(apq8064, qdss_clk, qdss_a_clk, QCOM_RPM_QDSS_CLK);
517DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_d0_clk, xo_d0_a_clk, 0);
518DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_d1_clk, xo_d1_a_clk, 8);
519DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_a0_clk, xo_a0_a_clk, 16);
520DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_a1_clk, xo_a1_a_clk, 24);
521DEFINE_CLK_RPM_XO_BUFFER(apq8064, xo_a2_clk, xo_a2_a_clk, 28);
452 522
453static struct clk_rpm *apq8064_clks[] = { 523static struct clk_rpm *apq8064_clks[] = {
454 [RPM_APPS_FABRIC_CLK] = &apq8064_afab_clk, 524 [RPM_APPS_FABRIC_CLK] = &apq8064_afab_clk,
@@ -469,6 +539,11 @@ static struct clk_rpm *apq8064_clks[] = {
469 [RPM_SFPB_A_CLK] = &apq8064_sfpb_a_clk, 539 [RPM_SFPB_A_CLK] = &apq8064_sfpb_a_clk,
470 [RPM_QDSS_CLK] = &apq8064_qdss_clk, 540 [RPM_QDSS_CLK] = &apq8064_qdss_clk,
471 [RPM_QDSS_A_CLK] = &apq8064_qdss_a_clk, 541 [RPM_QDSS_A_CLK] = &apq8064_qdss_a_clk,
542 [RPM_XO_D0] = &apq8064_xo_d0_clk,
543 [RPM_XO_D1] = &apq8064_xo_d1_clk,
544 [RPM_XO_A0] = &apq8064_xo_a0_clk,
545 [RPM_XO_A1] = &apq8064_xo_a1_clk,
546 [RPM_XO_A2] = &apq8064_xo_a2_clk,
472}; 547};
473 548
474static const struct rpm_clk_desc rpm_clk_apq8064 = { 549static const struct rpm_clk_desc rpm_clk_apq8064 = {
@@ -526,12 +601,14 @@ static int rpm_clk_probe(struct platform_device *pdev)
526 601
527 rcc->clks = rpm_clks; 602 rcc->clks = rpm_clks;
528 rcc->num_clks = num_clks; 603 rcc->num_clks = num_clks;
604 mutex_init(&rcc->xo_lock);
529 605
530 for (i = 0; i < num_clks; i++) { 606 for (i = 0; i < num_clks; i++) {
531 if (!rpm_clks[i]) 607 if (!rpm_clks[i])
532 continue; 608 continue;
533 609
534 rpm_clks[i]->rpm = rpm; 610 rpm_clks[i]->rpm = rpm;
611 rpm_clks[i]->rpm_cc = rcc;
535 612
536 ret = clk_rpm_handoff(rpm_clks[i]); 613 ret = clk_rpm_handoff(rpm_clks[i]);
537 if (ret) 614 if (ret)
diff --git a/include/dt-bindings/clock/mt2712-clk.h b/include/dt-bindings/clock/mt2712-clk.h
index 48a8e797a617..76265836a1e1 100644
--- a/include/dt-bindings/clock/mt2712-clk.h
+++ b/include/dt-bindings/clock/mt2712-clk.h
@@ -222,7 +222,13 @@
222#define CLK_TOP_APLL_DIV_PDN5 183 222#define CLK_TOP_APLL_DIV_PDN5 183
223#define CLK_TOP_APLL_DIV_PDN6 184 223#define CLK_TOP_APLL_DIV_PDN6 184
224#define CLK_TOP_APLL_DIV_PDN7 185 224#define CLK_TOP_APLL_DIV_PDN7 185
225#define CLK_TOP_NR_CLK 186 225#define CLK_TOP_APLL1_D3 186
226#define CLK_TOP_APLL1_REF_SEL 187
227#define CLK_TOP_APLL2_REF_SEL 188
228#define CLK_TOP_NFI2X_EN 189
229#define CLK_TOP_NFIECC_EN 190
230#define CLK_TOP_NFI1X_CK_EN 191
231#define CLK_TOP_NR_CLK 192
226 232
227/* INFRACFG */ 233/* INFRACFG */
228 234
@@ -281,7 +287,9 @@
281#define CLK_PERI_MSDC30_3_EN 41 287#define CLK_PERI_MSDC30_3_EN 41
282#define CLK_PERI_MSDC50_0_HCLK_EN 42 288#define CLK_PERI_MSDC50_0_HCLK_EN 42
283#define CLK_PERI_MSDC50_3_HCLK_EN 43 289#define CLK_PERI_MSDC50_3_HCLK_EN 43
284#define CLK_PERI_NR_CLK 44 290#define CLK_PERI_MSDC30_0_QTR_EN 44
291#define CLK_PERI_MSDC30_3_QTR_EN 45
292#define CLK_PERI_NR_CLK 46
285 293
286/* MCUCFG */ 294/* MCUCFG */
287 295
diff --git a/include/dt-bindings/clock/qcom,rpmcc.h b/include/dt-bindings/clock/qcom,rpmcc.h
index b8337a5fa347..c585b82b9c05 100644
--- a/include/dt-bindings/clock/qcom,rpmcc.h
+++ b/include/dt-bindings/clock/qcom,rpmcc.h
@@ -40,6 +40,11 @@
40#define RPM_SMI_CLK 22 40#define RPM_SMI_CLK 22
41#define RPM_SMI_A_CLK 23 41#define RPM_SMI_A_CLK 23
42#define RPM_PLL4_CLK 24 42#define RPM_PLL4_CLK 24
43#define RPM_XO_D0 25
44#define RPM_XO_D1 26
45#define RPM_XO_A0 27
46#define RPM_XO_A1 28
47#define RPM_XO_A2 29
43 48
44/* SMD RPM clocks */ 49/* SMD RPM clocks */
45#define RPM_SMD_XO_CLK_SRC 0 50#define RPM_SMD_XO_CLK_SRC 0