hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/clk/qcom/gcc-ipq8074.c
....@@ -1,14 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2017, The Linux Foundation. All rights reserved.
3
- *
4
- * This software is licensed under the terms of the GNU General Public
5
- * License version 2, as published by the Free Software Foundation, and
6
- * may be copied, distributed, and modified under those terms.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
124 */
135
146 #include <linux/kernel.h>
....@@ -66,11 +58,6 @@
6658 { P_XO, 0 },
6759 { P_GPLL0, 1 },
6860 { P_GPLL0_DIV2, 4 },
69
-};
70
-
71
-static const char * const gcc_xo_gpll0[] = {
72
- "xo",
73
- "gpll0",
7461 };
7562
7663 static const struct parent_map gcc_xo_gpll0_map[] = {
....@@ -675,6 +662,7 @@
675662 },
676663 .num_parents = 1,
677664 .ops = &clk_branch2_ops,
665
+ .flags = CLK_IS_CRITICAL,
678666 },
679667 },
680668 };
....@@ -964,6 +952,11 @@
964952 },
965953 };
966954
955
+static const struct clk_parent_data gcc_xo_gpll0[] = {
956
+ { .fw_name = "xo" },
957
+ { .hw = &gpll0.clkr.hw },
958
+};
959
+
967960 static const struct freq_tbl ftbl_pcie_axi_clk_src[] = {
968961 F(19200000, P_XO, 1, 0, 0),
969962 F(200000000, P_GPLL0, 4, 0, 0),
....@@ -977,7 +970,7 @@
977970 .parent_map = gcc_xo_gpll0_map,
978971 .clkr.hw.init = &(struct clk_init_data){
979972 .name = "pcie0_axi_clk_src",
980
- .parent_names = gcc_xo_gpll0,
973
+ .parent_data = gcc_xo_gpll0,
981974 .num_parents = 2,
982975 .ops = &clk_rcg2_ops,
983976 },
....@@ -1024,7 +1017,7 @@
10241017 .parent_map = gcc_xo_gpll0_map,
10251018 .clkr.hw.init = &(struct clk_init_data){
10261019 .name = "pcie1_axi_clk_src",
1027
- .parent_names = gcc_xo_gpll0,
1020
+ .parent_data = gcc_xo_gpll0,
10281021 .num_parents = 2,
10291022 .ops = &clk_rcg2_ops,
10301023 },
....@@ -1082,7 +1075,7 @@
10821075 .name = "sdcc1_apps_clk_src",
10831076 .parent_names = gcc_xo_gpll0_gpll2_gpll0_out_main_div2,
10841077 .num_parents = 4,
1085
- .ops = &clk_rcg2_ops,
1078
+ .ops = &clk_rcg2_floor_ops,
10861079 },
10871080 };
10881081
....@@ -1116,7 +1109,7 @@
11161109 .name = "sdcc2_apps_clk_src",
11171110 .parent_names = gcc_xo_gpll0_gpll2_gpll0_out_main_div2,
11181111 .num_parents = 4,
1119
- .ops = &clk_rcg2_ops,
1112
+ .ops = &clk_rcg2_floor_ops,
11201113 },
11211114 };
11221115
....@@ -1338,7 +1331,7 @@
13381331 .parent_map = gcc_xo_gpll0_map,
13391332 .clkr.hw.init = &(struct clk_init_data){
13401333 .name = "nss_ce_clk_src",
1341
- .parent_names = gcc_xo_gpll0,
1334
+ .parent_data = gcc_xo_gpll0,
13421335 .num_parents = 2,
13431336 .ops = &clk_rcg2_ops,
13441337 },
....@@ -1796,8 +1789,10 @@
17961789 static const struct freq_tbl ftbl_nss_port5_rx_clk_src[] = {
17971790 F(19200000, P_XO, 1, 0, 0),
17981791 F(25000000, P_UNIPHY1_RX, 12.5, 0, 0),
1792
+ F(25000000, P_UNIPHY0_RX, 5, 0, 0),
17991793 F(78125000, P_UNIPHY1_RX, 4, 0, 0),
18001794 F(125000000, P_UNIPHY1_RX, 2.5, 0, 0),
1795
+ F(125000000, P_UNIPHY0_RX, 1, 0, 0),
18011796 F(156250000, P_UNIPHY1_RX, 2, 0, 0),
18021797 F(312500000, P_UNIPHY1_RX, 1, 0, 0),
18031798 { }
....@@ -1836,8 +1831,10 @@
18361831 static const struct freq_tbl ftbl_nss_port5_tx_clk_src[] = {
18371832 F(19200000, P_XO, 1, 0, 0),
18381833 F(25000000, P_UNIPHY1_TX, 12.5, 0, 0),
1834
+ F(25000000, P_UNIPHY0_TX, 5, 0, 0),
18391835 F(78125000, P_UNIPHY1_TX, 4, 0, 0),
18401836 F(125000000, P_UNIPHY1_TX, 2.5, 0, 0),
1837
+ F(125000000, P_UNIPHY0_TX, 1, 0, 0),
18411838 F(156250000, P_UNIPHY1_TX, 2, 0, 0),
18421839 F(312500000, P_UNIPHY1_TX, 1, 0, 0),
18431840 { }
....@@ -1875,8 +1872,10 @@
18751872
18761873 static const struct freq_tbl ftbl_nss_port6_rx_clk_src[] = {
18771874 F(19200000, P_XO, 1, 0, 0),
1875
+ F(25000000, P_UNIPHY2_RX, 5, 0, 0),
18781876 F(25000000, P_UNIPHY2_RX, 12.5, 0, 0),
18791877 F(78125000, P_UNIPHY2_RX, 4, 0, 0),
1878
+ F(125000000, P_UNIPHY2_RX, 1, 0, 0),
18801879 F(125000000, P_UNIPHY2_RX, 2.5, 0, 0),
18811880 F(156250000, P_UNIPHY2_RX, 2, 0, 0),
18821881 F(312500000, P_UNIPHY2_RX, 1, 0, 0),
....@@ -1915,8 +1914,10 @@
19151914
19161915 static const struct freq_tbl ftbl_nss_port6_tx_clk_src[] = {
19171916 F(19200000, P_XO, 1, 0, 0),
1917
+ F(25000000, P_UNIPHY2_TX, 5, 0, 0),
19181918 F(25000000, P_UNIPHY2_TX, 12.5, 0, 0),
19191919 F(78125000, P_UNIPHY2_TX, 4, 0, 0),
1920
+ F(125000000, P_UNIPHY2_TX, 1, 0, 0),
19201921 F(125000000, P_UNIPHY2_TX, 2.5, 0, 0),
19211922 F(156250000, P_UNIPHY2_TX, 2, 0, 0),
19221923 F(312500000, P_UNIPHY2_TX, 1, 0, 0),
....@@ -3354,6 +3355,7 @@
33543355
33553356 static struct clk_branch gcc_ubi0_ahb_clk = {
33563357 .halt_reg = 0x6820c,
3358
+ .halt_check = BRANCH_HALT_DELAY,
33573359 .clkr = {
33583360 .enable_reg = 0x6820c,
33593361 .enable_mask = BIT(0),
....@@ -3371,6 +3373,7 @@
33713373
33723374 static struct clk_branch gcc_ubi0_axi_clk = {
33733375 .halt_reg = 0x68200,
3376
+ .halt_check = BRANCH_HALT_DELAY,
33743377 .clkr = {
33753378 .enable_reg = 0x68200,
33763379 .enable_mask = BIT(0),
....@@ -3388,6 +3391,7 @@
33883391
33893392 static struct clk_branch gcc_ubi0_nc_axi_clk = {
33903393 .halt_reg = 0x68204,
3394
+ .halt_check = BRANCH_HALT_DELAY,
33913395 .clkr = {
33923396 .enable_reg = 0x68204,
33933397 .enable_mask = BIT(0),
....@@ -3405,6 +3409,7 @@
34053409
34063410 static struct clk_branch gcc_ubi0_core_clk = {
34073411 .halt_reg = 0x68210,
3412
+ .halt_check = BRANCH_HALT_DELAY,
34083413 .clkr = {
34093414 .enable_reg = 0x68210,
34103415 .enable_mask = BIT(0),
....@@ -3422,6 +3427,7 @@
34223427
34233428 static struct clk_branch gcc_ubi0_mpt_clk = {
34243429 .halt_reg = 0x68208,
3430
+ .halt_check = BRANCH_HALT_DELAY,
34253431 .clkr = {
34263432 .enable_reg = 0x68208,
34273433 .enable_mask = BIT(0),
....@@ -3439,6 +3445,7 @@
34393445
34403446 static struct clk_branch gcc_ubi1_ahb_clk = {
34413447 .halt_reg = 0x6822c,
3448
+ .halt_check = BRANCH_HALT_DELAY,
34423449 .clkr = {
34433450 .enable_reg = 0x6822c,
34443451 .enable_mask = BIT(0),
....@@ -3456,6 +3463,7 @@
34563463
34573464 static struct clk_branch gcc_ubi1_axi_clk = {
34583465 .halt_reg = 0x68220,
3466
+ .halt_check = BRANCH_HALT_DELAY,
34593467 .clkr = {
34603468 .enable_reg = 0x68220,
34613469 .enable_mask = BIT(0),
....@@ -3473,6 +3481,7 @@
34733481
34743482 static struct clk_branch gcc_ubi1_nc_axi_clk = {
34753483 .halt_reg = 0x68224,
3484
+ .halt_check = BRANCH_HALT_DELAY,
34763485 .clkr = {
34773486 .enable_reg = 0x68224,
34783487 .enable_mask = BIT(0),
....@@ -3490,6 +3499,7 @@
34903499
34913500 static struct clk_branch gcc_ubi1_core_clk = {
34923501 .halt_reg = 0x68230,
3502
+ .halt_check = BRANCH_HALT_DELAY,
34933503 .clkr = {
34943504 .enable_reg = 0x68230,
34953505 .enable_mask = BIT(0),
....@@ -3507,6 +3517,7 @@
35073517
35083518 static struct clk_branch gcc_ubi1_mpt_clk = {
35093519 .halt_reg = 0x68228,
3520
+ .halt_check = BRANCH_HALT_DELAY,
35103521 .clkr = {
35113522 .enable_reg = 0x68228,
35123523 .enable_mask = BIT(0),
....@@ -4324,6 +4335,88 @@
43244335 },
43254336 };
43264337
4338
+static const struct freq_tbl ftbl_pcie_rchng_clk_src[] = {
4339
+ F(19200000, P_XO, 1, 0, 0),
4340
+ F(100000000, P_GPLL0, 8, 0, 0),
4341
+ { }
4342
+};
4343
+
4344
+static struct clk_rcg2 pcie0_rchng_clk_src = {
4345
+ .cmd_rcgr = 0x75070,
4346
+ .freq_tbl = ftbl_pcie_rchng_clk_src,
4347
+ .hid_width = 5,
4348
+ .parent_map = gcc_xo_gpll0_map,
4349
+ .clkr.hw.init = &(struct clk_init_data){
4350
+ .name = "pcie0_rchng_clk_src",
4351
+ .parent_data = gcc_xo_gpll0,
4352
+ .num_parents = 2,
4353
+ .ops = &clk_rcg2_ops,
4354
+ },
4355
+};
4356
+
4357
+static struct clk_branch gcc_pcie0_rchng_clk = {
4358
+ .halt_reg = 0x75070,
4359
+ .halt_bit = 31,
4360
+ .clkr = {
4361
+ .enable_reg = 0x75070,
4362
+ .enable_mask = BIT(1),
4363
+ .hw.init = &(struct clk_init_data){
4364
+ .name = "gcc_pcie0_rchng_clk",
4365
+ .parent_hws = (const struct clk_hw *[]){
4366
+ &pcie0_rchng_clk_src.clkr.hw,
4367
+ },
4368
+ .num_parents = 1,
4369
+ .flags = CLK_SET_RATE_PARENT,
4370
+ .ops = &clk_branch2_ops,
4371
+ },
4372
+ },
4373
+};
4374
+
4375
+static struct clk_branch gcc_pcie0_axi_s_bridge_clk = {
4376
+ .halt_reg = 0x75048,
4377
+ .halt_bit = 31,
4378
+ .clkr = {
4379
+ .enable_reg = 0x75048,
4380
+ .enable_mask = BIT(0),
4381
+ .hw.init = &(struct clk_init_data){
4382
+ .name = "gcc_pcie0_axi_s_bridge_clk",
4383
+ .parent_hws = (const struct clk_hw *[]){
4384
+ &pcie0_axi_clk_src.clkr.hw,
4385
+ },
4386
+ .num_parents = 1,
4387
+ .flags = CLK_SET_RATE_PARENT,
4388
+ .ops = &clk_branch2_ops,
4389
+ },
4390
+ },
4391
+};
4392
+
4393
+static const struct alpha_pll_config ubi32_pll_config = {
4394
+ .l = 0x4e,
4395
+ .config_ctl_val = 0x200d4aa8,
4396
+ .config_ctl_hi_val = 0x3c2,
4397
+ .main_output_mask = BIT(0),
4398
+ .aux_output_mask = BIT(1),
4399
+ .pre_div_val = 0x0,
4400
+ .pre_div_mask = BIT(12),
4401
+ .post_div_val = 0x0,
4402
+ .post_div_mask = GENMASK(9, 8),
4403
+};
4404
+
4405
+static const struct alpha_pll_config nss_crypto_pll_config = {
4406
+ .l = 0x3e,
4407
+ .alpha = 0x0,
4408
+ .alpha_hi = 0x80,
4409
+ .config_ctl_val = 0x4001055b,
4410
+ .main_output_mask = BIT(0),
4411
+ .pre_div_val = 0x0,
4412
+ .pre_div_mask = GENMASK(14, 12),
4413
+ .post_div_val = 0x1 << 8,
4414
+ .post_div_mask = GENMASK(11, 8),
4415
+ .vco_mask = GENMASK(21, 20),
4416
+ .vco_val = 0x0,
4417
+ .alpha_en_mask = BIT(24),
4418
+};
4419
+
43274420 static struct clk_hw *gcc_ipq8074_hws[] = {
43284421 &gpll0_out_main_div2.hw,
43294422 &gpll6_out_main_div2.hw,
....@@ -4559,6 +4652,9 @@
45594652 [GCC_GP1_CLK] = &gcc_gp1_clk.clkr,
45604653 [GCC_GP2_CLK] = &gcc_gp2_clk.clkr,
45614654 [GCC_GP3_CLK] = &gcc_gp3_clk.clkr,
4655
+ [GCC_PCIE0_RCHNG_CLK_SRC] = &pcie0_rchng_clk_src.clkr,
4656
+ [GCC_PCIE0_RCHNG_CLK] = &gcc_pcie0_rchng_clk.clkr,
4657
+ [GCC_PCIE0_AXI_S_BRIDGE_CLK] = &gcc_pcie0_axi_s_bridge_clk.clkr,
45624658 };
45634659
45644660 static const struct qcom_reset_map gcc_ipq8074_resets[] = {
....@@ -4686,6 +4782,7 @@
46864782 [GCC_PCIE0_AXI_SLAVE_ARES] = { 0x75040, 4 },
46874783 [GCC_PCIE0_AHB_ARES] = { 0x75040, 5 },
46884784 [GCC_PCIE0_AXI_MASTER_STICKY_ARES] = { 0x75040, 6 },
4785
+ [GCC_PCIE0_AXI_SLAVE_STICKY_ARES] = { 0x75040, 7 },
46894786 [GCC_PCIE1_PIPE_ARES] = { 0x76040, 0 },
46904787 [GCC_PCIE1_SLEEP_ARES] = { 0x76040, 1 },
46914788 [GCC_PCIE1_CORE_STICKY_ARES] = { 0x76040, 2 },
....@@ -4715,19 +4812,26 @@
47154812 .num_clks = ARRAY_SIZE(gcc_ipq8074_clks),
47164813 .resets = gcc_ipq8074_resets,
47174814 .num_resets = ARRAY_SIZE(gcc_ipq8074_resets),
4815
+ .clk_hws = gcc_ipq8074_hws,
4816
+ .num_clk_hws = ARRAY_SIZE(gcc_ipq8074_hws),
47184817 };
47194818
47204819 static int gcc_ipq8074_probe(struct platform_device *pdev)
47214820 {
4722
- int ret, i;
4821
+ struct regmap *regmap;
47234822
4724
- for (i = 0; i < ARRAY_SIZE(gcc_ipq8074_hws); i++) {
4725
- ret = devm_clk_hw_register(&pdev->dev, gcc_ipq8074_hws[i]);
4726
- if (ret)
4727
- return ret;
4728
- }
4823
+ regmap = qcom_cc_map(pdev, &gcc_ipq8074_desc);
4824
+ if (IS_ERR(regmap))
4825
+ return PTR_ERR(regmap);
47294826
4730
- return qcom_cc_probe(pdev, &gcc_ipq8074_desc);
4827
+ /* SW Workaround for UBI32 Huayra PLL */
4828
+ regmap_update_bits(regmap, 0x2501c, BIT(26), BIT(26));
4829
+
4830
+ clk_alpha_pll_configure(&ubi32_pll_main, regmap, &ubi32_pll_config);
4831
+ clk_alpha_pll_configure(&nss_crypto_pll_main, regmap,
4832
+ &nss_crypto_pll_config);
4833
+
4834
+ return qcom_cc_really_probe(pdev, &gcc_ipq8074_desc, regmap);
47314835 }
47324836
47334837 static struct platform_driver gcc_ipq8074_driver = {