Skip to content

Commit 2668cae

Browse files
Mani-Sadhasivamvinodkoul
authored andcommitted
phy: qcom-qmp-ufs: Switch to devm_clk_bulk_get_all() API
Device drivers should just rely on the clocks provided by the devicetree and enable/disable them based on the requirement. There is no need to validate the clocks provided by devicetree in the driver. That's the job of DT schema. So let's switch to devm_clk_bulk_get_all() API that just gets the clocks provided by devicetree and remove hardcoded clocks info. Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Link: https://lore.kernel.org/r/20240131-ufs-phy-clock-v3-2-58a49d2f4605@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent b0bcec8 commit 2668cae

1 file changed

Lines changed: 7 additions & 56 deletions

File tree

drivers/phy/qualcomm/phy-qcom-qmp-ufs.c

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -923,9 +923,6 @@ struct qmp_phy_cfg {
923923
/* Additional sequence for different HS Gears */
924924
const struct qmp_phy_cfg_tbls tbls_hs_overlay[NUM_OVERLAY];
925925

926-
/* clock ids to be requested */
927-
const char * const *clk_list;
928-
int num_clks;
929926
/* regulators to be requested */
930927
const char * const *vreg_list;
931928
int num_vregs;
@@ -951,6 +948,7 @@ struct qmp_ufs {
951948
void __iomem *rx2;
952949

953950
struct clk_bulk_data *clks;
951+
int num_clks;
954952
struct regulator_bulk_data *vregs;
955953
struct reset_control *ufs_reset;
956954

@@ -983,20 +981,6 @@ static inline void qphy_clrbits(void __iomem *base, u32 offset, u32 val)
983981
readl(base + offset);
984982
}
985983

986-
/* list of clocks required by phy */
987-
static const char * const msm8996_ufs_phy_clk_l[] = {
988-
"ref",
989-
};
990-
991-
/* the primary usb3 phy on sm8250 doesn't have a ref clock */
992-
static const char * const sm8450_ufs_phy_clk_l[] = {
993-
"qref", "ref", "ref_aux",
994-
};
995-
996-
static const char * const sdm845_ufs_phy_clk_l[] = {
997-
"ref", "ref_aux",
998-
};
999-
1000984
/* list of regulators */
1001985
static const char * const qmp_phy_vreg_l[] = {
1002986
"vdda-phy", "vdda-pll",
@@ -1035,9 +1019,6 @@ static const struct qmp_phy_cfg msm8996_ufsphy_cfg = {
10351019
.rx_num = ARRAY_SIZE(msm8996_ufsphy_rx),
10361020
},
10371021

1038-
.clk_list = msm8996_ufs_phy_clk_l,
1039-
.num_clks = ARRAY_SIZE(msm8996_ufs_phy_clk_l),
1040-
10411022
.vreg_list = qmp_phy_vreg_l,
10421023
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
10431024

@@ -1075,8 +1056,6 @@ static const struct qmp_phy_cfg sa8775p_ufsphy_cfg = {
10751056
.pcs_num = ARRAY_SIZE(sm8350_ufsphy_g4_pcs),
10761057
.max_gear = UFS_HS_G4,
10771058
},
1078-
.clk_list = sm8450_ufs_phy_clk_l,
1079-
.num_clks = ARRAY_SIZE(sm8450_ufs_phy_clk_l),
10801059
.vreg_list = qmp_phy_vreg_l,
10811060
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
10821061
.regs = ufsphy_v5_regs_layout,
@@ -1111,8 +1090,6 @@ static const struct qmp_phy_cfg sc7280_ufsphy_cfg = {
11111090
.pcs_num = ARRAY_SIZE(sm8150_ufsphy_hs_g4_pcs),
11121091
.max_gear = UFS_HS_G4,
11131092
},
1114-
.clk_list = sm8450_ufs_phy_clk_l,
1115-
.num_clks = ARRAY_SIZE(sm8450_ufs_phy_clk_l),
11161093
.vreg_list = qmp_phy_vreg_l,
11171094
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
11181095
.regs = ufsphy_v4_regs_layout,
@@ -1147,8 +1124,6 @@ static const struct qmp_phy_cfg sc8280xp_ufsphy_cfg = {
11471124
.pcs_num = ARRAY_SIZE(sm8350_ufsphy_g4_pcs),
11481125
.max_gear = UFS_HS_G4,
11491126
},
1150-
.clk_list = sdm845_ufs_phy_clk_l,
1151-
.num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l),
11521127
.vreg_list = qmp_phy_vreg_l,
11531128
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
11541129
.regs = ufsphy_v5_regs_layout,
@@ -1174,8 +1149,6 @@ static const struct qmp_phy_cfg sdm845_ufsphy_cfg = {
11741149
.serdes = sdm845_ufsphy_hs_b_serdes,
11751150
.serdes_num = ARRAY_SIZE(sdm845_ufsphy_hs_b_serdes),
11761151
},
1177-
.clk_list = sdm845_ufs_phy_clk_l,
1178-
.num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l),
11791152
.vreg_list = qmp_phy_vreg_l,
11801153
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
11811154
.regs = ufsphy_v3_regs_layout,
@@ -1203,8 +1176,6 @@ static const struct qmp_phy_cfg sm6115_ufsphy_cfg = {
12031176
.serdes = sm6115_ufsphy_hs_b_serdes,
12041177
.serdes_num = ARRAY_SIZE(sm6115_ufsphy_hs_b_serdes),
12051178
},
1206-
.clk_list = sdm845_ufs_phy_clk_l,
1207-
.num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l),
12081179
.vreg_list = qmp_phy_vreg_l,
12091180
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
12101181
.regs = ufsphy_v2_regs_layout,
@@ -1232,8 +1203,6 @@ static const struct qmp_phy_cfg sm7150_ufsphy_cfg = {
12321203
.serdes = sdm845_ufsphy_hs_b_serdes,
12331204
.serdes_num = ARRAY_SIZE(sdm845_ufsphy_hs_b_serdes),
12341205
},
1235-
.clk_list = sdm845_ufs_phy_clk_l,
1236-
.num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l),
12371206
.vreg_list = qmp_phy_vreg_l,
12381207
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
12391208
.regs = ufsphy_v3_regs_layout,
@@ -1270,8 +1239,6 @@ static const struct qmp_phy_cfg sm8150_ufsphy_cfg = {
12701239
.pcs_num = ARRAY_SIZE(sm8150_ufsphy_hs_g4_pcs),
12711240
.max_gear = UFS_HS_G4,
12721241
},
1273-
.clk_list = sdm845_ufs_phy_clk_l,
1274-
.num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l),
12751242
.vreg_list = qmp_phy_vreg_l,
12761243
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
12771244
.regs = ufsphy_v4_regs_layout,
@@ -1306,8 +1273,6 @@ static const struct qmp_phy_cfg sm8250_ufsphy_cfg = {
13061273
.pcs_num = ARRAY_SIZE(sm8150_ufsphy_hs_g4_pcs),
13071274
.max_gear = UFS_HS_G4,
13081275
},
1309-
.clk_list = sdm845_ufs_phy_clk_l,
1310-
.num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l),
13111276
.vreg_list = qmp_phy_vreg_l,
13121277
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
13131278
.regs = ufsphy_v4_regs_layout,
@@ -1342,8 +1307,6 @@ static const struct qmp_phy_cfg sm8350_ufsphy_cfg = {
13421307
.pcs_num = ARRAY_SIZE(sm8350_ufsphy_g4_pcs),
13431308
.max_gear = UFS_HS_G4,
13441309
},
1345-
.clk_list = sdm845_ufs_phy_clk_l,
1346-
.num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l),
13471310
.vreg_list = qmp_phy_vreg_l,
13481311
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
13491312
.regs = ufsphy_v5_regs_layout,
@@ -1378,8 +1341,6 @@ static const struct qmp_phy_cfg sm8450_ufsphy_cfg = {
13781341
.pcs_num = ARRAY_SIZE(sm8350_ufsphy_g4_pcs),
13791342
.max_gear = UFS_HS_G4,
13801343
},
1381-
.clk_list = sm8450_ufs_phy_clk_l,
1382-
.num_clks = ARRAY_SIZE(sm8450_ufs_phy_clk_l),
13831344
.vreg_list = qmp_phy_vreg_l,
13841345
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
13851346
.regs = ufsphy_v5_regs_layout,
@@ -1425,8 +1386,6 @@ static const struct qmp_phy_cfg sm8550_ufsphy_cfg = {
14251386
.pcs_num = ARRAY_SIZE(sm8550_ufsphy_g5_pcs),
14261387
.max_gear = UFS_HS_G5,
14271388
},
1428-
.clk_list = sdm845_ufs_phy_clk_l,
1429-
.num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l),
14301389
.vreg_list = qmp_phy_vreg_l,
14311390
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
14321391
.regs = ufsphy_v6_regs_layout,
@@ -1448,8 +1407,6 @@ static const struct qmp_phy_cfg sm8650_ufsphy_cfg = {
14481407
.pcs = sm8650_ufsphy_pcs,
14491408
.pcs_num = ARRAY_SIZE(sm8650_ufsphy_pcs),
14501409
},
1451-
.clk_list = sdm845_ufs_phy_clk_l,
1452-
.num_clks = ARRAY_SIZE(sdm845_ufs_phy_clk_l),
14531410
.vreg_list = qmp_phy_vreg_l,
14541411
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
14551412
.regs = ufsphy_v6_regs_layout,
@@ -1541,7 +1498,7 @@ static int qmp_ufs_com_init(struct qmp_ufs *qmp)
15411498
return ret;
15421499
}
15431500

1544-
ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks);
1501+
ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks);
15451502
if (ret)
15461503
goto err_disable_regulators;
15471504

@@ -1561,7 +1518,7 @@ static int qmp_ufs_com_exit(struct qmp_ufs *qmp)
15611518

15621519
reset_control_assert(qmp->ufs_reset);
15631520

1564-
clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
1521+
clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks);
15651522

15661523
regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
15671524

@@ -1737,19 +1694,13 @@ static int qmp_ufs_vreg_init(struct qmp_ufs *qmp)
17371694

17381695
static int qmp_ufs_clk_init(struct qmp_ufs *qmp)
17391696
{
1740-
const struct qmp_phy_cfg *cfg = qmp->cfg;
17411697
struct device *dev = qmp->dev;
1742-
int num = cfg->num_clks;
1743-
int i;
17441698

1745-
qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL);
1746-
if (!qmp->clks)
1747-
return -ENOMEM;
1699+
qmp->num_clks = devm_clk_bulk_get_all(dev, &qmp->clks);
1700+
if (qmp->num_clks < 0)
1701+
return qmp->num_clks;
17481702

1749-
for (i = 0; i < num; i++)
1750-
qmp->clks[i].id = cfg->clk_list[i];
1751-
1752-
return devm_clk_bulk_get(dev, num, qmp->clks);
1703+
return 0;
17531704
}
17541705

17551706
static void qmp_ufs_clk_release_provider(void *res)

0 commit comments

Comments
 (0)