Skip to content

Commit fcf6348

Browse files
lumagvinodkoul
authored andcommitted
phy: qcom-qmp-usb: rework reset handling
All legacy bindings of USB PHYs use "phy", "common" resets, while newer style bindings use "phy", "phy_phy" resets. In preparation for converting existing legacy PHY bindings to use newer scheme, drop reset lists from configuration struture and reference reset lists directly. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20230824211952.1397699-4-dmitry.baryshkov@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 7233090 commit fcf6348

1 file changed

Lines changed: 26 additions & 45 deletions

File tree

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

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,9 +1172,6 @@ struct qmp_phy_cfg {
11721172
const struct qmp_phy_init_tbl *pcs_usb_tbl;
11731173
int pcs_usb_tbl_num;
11741174

1175-
/* resets to be requested */
1176-
const char * const *reset_list;
1177-
int num_resets;
11781175
/* regulators to be requested */
11791176
const char * const *vreg_list;
11801177
int num_vregs;
@@ -1206,6 +1203,7 @@ struct qmp_usb {
12061203
struct clk *pipe_clk;
12071204
struct clk_bulk_data *clks;
12081205
int num_clks;
1206+
int num_resets;
12091207
struct reset_control_bulk_data *resets;
12101208
struct regulator_bulk_data *vregs;
12111209

@@ -1246,11 +1244,11 @@ static const char * const qmp_usb_phy_clk_l[] = {
12461244
};
12471245

12481246
/* list of resets */
1249-
static const char * const msm8996_usb3phy_reset_l[] = {
1247+
static const char * const usb3phy_legacy_reset_l[] = {
12501248
"phy", "common",
12511249
};
12521250

1253-
static const char * const qcm2290_usb3phy_reset_l[] = {
1251+
static const char * const usb3phy_reset_l[] = {
12541252
"phy_phy", "phy",
12551253
};
12561254

@@ -1296,8 +1294,6 @@ static const struct qmp_phy_cfg ipq8074_usb3phy_cfg = {
12961294
.rx_tbl_num = ARRAY_SIZE(ipq8074_usb3_rx_tbl),
12971295
.pcs_tbl = ipq8074_usb3_pcs_tbl,
12981296
.pcs_tbl_num = ARRAY_SIZE(ipq8074_usb3_pcs_tbl),
1299-
.reset_list = msm8996_usb3phy_reset_l,
1300-
.num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
13011297
.vreg_list = qmp_phy_vreg_l,
13021298
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
13031299
.regs = qmp_v3_usb3phy_regs_layout,
@@ -1316,8 +1312,6 @@ static const struct qmp_phy_cfg ipq9574_usb3phy_cfg = {
13161312
.rx_tbl_num = ARRAY_SIZE(ipq9574_usb3_rx_tbl),
13171313
.pcs_tbl = ipq9574_usb3_pcs_tbl,
13181314
.pcs_tbl_num = ARRAY_SIZE(ipq9574_usb3_pcs_tbl),
1319-
.reset_list = qcm2290_usb3phy_reset_l,
1320-
.num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l),
13211315
.vreg_list = qmp_phy_vreg_l,
13221316
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
13231317
.regs = qmp_v3_usb3phy_regs_layout,
@@ -1334,8 +1328,6 @@ static const struct qmp_phy_cfg msm8996_usb3phy_cfg = {
13341328
.rx_tbl_num = ARRAY_SIZE(msm8996_usb3_rx_tbl),
13351329
.pcs_tbl = msm8996_usb3_pcs_tbl,
13361330
.pcs_tbl_num = ARRAY_SIZE(msm8996_usb3_pcs_tbl),
1337-
.reset_list = msm8996_usb3phy_reset_l,
1338-
.num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
13391331
.vreg_list = qmp_phy_vreg_l,
13401332
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
13411333
.regs = qmp_v2_usb3phy_regs_layout,
@@ -1354,8 +1346,6 @@ static const struct qmp_phy_cfg sa8775p_usb3_uniphy_cfg = {
13541346
.rx_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_rx_tbl),
13551347
.pcs_tbl = sa8775p_usb3_uniphy_pcs_tbl,
13561348
.pcs_tbl_num = ARRAY_SIZE(sa8775p_usb3_uniphy_pcs_tbl),
1357-
.reset_list = qcm2290_usb3phy_reset_l,
1358-
.num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l),
13591349
.vreg_list = qmp_phy_vreg_l,
13601350
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
13611351
.regs = qmp_v5_usb3phy_regs_layout,
@@ -1374,8 +1364,6 @@ static const struct qmp_phy_cfg sc8280xp_usb3_uniphy_cfg = {
13741364
.rx_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_rx_tbl),
13751365
.pcs_tbl = sc8280xp_usb3_uniphy_pcs_tbl,
13761366
.pcs_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_pcs_tbl),
1377-
.reset_list = qcm2290_usb3phy_reset_l,
1378-
.num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l),
13791367
.vreg_list = qmp_phy_vreg_l,
13801368
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
13811369
.regs = qmp_v5_usb3phy_regs_layout,
@@ -1392,8 +1380,6 @@ static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = {
13921380
.rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_rx_tbl),
13931381
.pcs_tbl = qmp_v3_usb3_uniphy_pcs_tbl,
13941382
.pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_pcs_tbl),
1395-
.reset_list = msm8996_usb3phy_reset_l,
1396-
.num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
13971383
.vreg_list = qmp_phy_vreg_l,
13981384
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
13991385
.regs = qmp_v3_usb3phy_regs_layout,
@@ -1412,8 +1398,6 @@ static const struct qmp_phy_cfg msm8998_usb3phy_cfg = {
14121398
.rx_tbl_num = ARRAY_SIZE(msm8998_usb3_rx_tbl),
14131399
.pcs_tbl = msm8998_usb3_pcs_tbl,
14141400
.pcs_tbl_num = ARRAY_SIZE(msm8998_usb3_pcs_tbl),
1415-
.reset_list = msm8996_usb3phy_reset_l,
1416-
.num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
14171401
.vreg_list = qmp_phy_vreg_l,
14181402
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
14191403
.regs = qmp_v3_usb3phy_regs_layout,
@@ -1432,8 +1416,6 @@ static const struct qmp_phy_cfg sm8150_usb3_uniphy_cfg = {
14321416
.pcs_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_pcs_tbl),
14331417
.pcs_usb_tbl = sm8150_usb3_uniphy_pcs_usb_tbl,
14341418
.pcs_usb_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_pcs_usb_tbl),
1435-
.reset_list = msm8996_usb3phy_reset_l,
1436-
.num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
14371419
.vreg_list = qmp_phy_vreg_l,
14381420
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
14391421
.regs = qmp_v4_usb3phy_regs_layout,
@@ -1455,8 +1437,6 @@ static const struct qmp_phy_cfg sm8250_usb3_uniphy_cfg = {
14551437
.pcs_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_tbl),
14561438
.pcs_usb_tbl = sm8250_usb3_uniphy_pcs_usb_tbl,
14571439
.pcs_usb_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_usb_tbl),
1458-
.reset_list = msm8996_usb3phy_reset_l,
1459-
.num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
14601440
.vreg_list = qmp_phy_vreg_l,
14611441
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
14621442
.regs = qmp_v4_usb3phy_regs_layout,
@@ -1478,8 +1458,6 @@ static const struct qmp_phy_cfg sdx55_usb3_uniphy_cfg = {
14781458
.pcs_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_tbl),
14791459
.pcs_usb_tbl = sm8250_usb3_uniphy_pcs_usb_tbl,
14801460
.pcs_usb_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_usb_tbl),
1481-
.reset_list = msm8996_usb3phy_reset_l,
1482-
.num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
14831461
.vreg_list = qmp_phy_vreg_l,
14841462
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
14851463
.regs = qmp_v4_usb3phy_regs_layout,
@@ -1501,8 +1479,6 @@ static const struct qmp_phy_cfg sdx65_usb3_uniphy_cfg = {
15011479
.pcs_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_tbl),
15021480
.pcs_usb_tbl = sm8350_usb3_uniphy_pcs_usb_tbl,
15031481
.pcs_usb_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_usb_tbl),
1504-
.reset_list = msm8996_usb3phy_reset_l,
1505-
.num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
15061482
.vreg_list = qmp_phy_vreg_l,
15071483
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
15081484
.regs = qmp_v5_usb3phy_regs_layout,
@@ -1524,8 +1500,6 @@ static const struct qmp_phy_cfg sm8350_usb3_uniphy_cfg = {
15241500
.pcs_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_tbl),
15251501
.pcs_usb_tbl = sm8350_usb3_uniphy_pcs_usb_tbl,
15261502
.pcs_usb_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_usb_tbl),
1527-
.reset_list = msm8996_usb3phy_reset_l,
1528-
.num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l),
15291503
.vreg_list = qmp_phy_vreg_l,
15301504
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
15311505
.regs = qmp_v5_usb3phy_regs_layout,
@@ -1547,8 +1521,6 @@ static const struct qmp_phy_cfg qcm2290_usb3phy_cfg = {
15471521
.rx_tbl_num = ARRAY_SIZE(qcm2290_usb3_rx_tbl),
15481522
.pcs_tbl = qcm2290_usb3_pcs_tbl,
15491523
.pcs_tbl_num = ARRAY_SIZE(qcm2290_usb3_pcs_tbl),
1550-
.reset_list = qcm2290_usb3phy_reset_l,
1551-
.num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l),
15521524
.vreg_list = qmp_phy_vreg_l,
15531525
.num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
15541526
.regs = qmp_v3_usb3phy_regs_layout,
@@ -1605,13 +1577,13 @@ static int qmp_usb_init(struct phy *phy)
16051577
return ret;
16061578
}
16071579

1608-
ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets);
1580+
ret = reset_control_bulk_assert(qmp->num_resets, qmp->resets);
16091581
if (ret) {
16101582
dev_err(qmp->dev, "reset assert failed\n");
16111583
goto err_disable_regulators;
16121584
}
16131585

1614-
ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets);
1586+
ret = reset_control_bulk_deassert(qmp->num_resets, qmp->resets);
16151587
if (ret) {
16161588
dev_err(qmp->dev, "reset deassert failed\n");
16171589
goto err_disable_regulators;
@@ -1626,7 +1598,7 @@ static int qmp_usb_init(struct phy *phy)
16261598
return 0;
16271599

16281600
err_assert_reset:
1629-
reset_control_bulk_assert(cfg->num_resets, qmp->resets);
1601+
reset_control_bulk_assert(qmp->num_resets, qmp->resets);
16301602
err_disable_regulators:
16311603
regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
16321604

@@ -1638,7 +1610,7 @@ static int qmp_usb_exit(struct phy *phy)
16381610
struct qmp_usb *qmp = phy_get_drvdata(phy);
16391611
const struct qmp_phy_cfg *cfg = qmp->cfg;
16401612

1641-
reset_control_bulk_assert(cfg->num_resets, qmp->resets);
1613+
reset_control_bulk_assert(qmp->num_resets, qmp->resets);
16421614

16431615
clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks);
16441616

@@ -1880,22 +1852,25 @@ static int qmp_usb_vreg_init(struct qmp_usb *qmp)
18801852
return devm_regulator_bulk_get(dev, num, qmp->vregs);
18811853
}
18821854

1883-
static int qmp_usb_reset_init(struct qmp_usb *qmp)
1855+
static int qmp_usb_reset_init(struct qmp_usb *qmp,
1856+
const char *const *reset_list,
1857+
int num_resets)
18841858
{
1885-
const struct qmp_phy_cfg *cfg = qmp->cfg;
18861859
struct device *dev = qmp->dev;
18871860
int i;
18881861
int ret;
18891862

1890-
qmp->resets = devm_kcalloc(dev, cfg->num_resets,
1863+
qmp->resets = devm_kcalloc(dev, num_resets,
18911864
sizeof(*qmp->resets), GFP_KERNEL);
18921865
if (!qmp->resets)
18931866
return -ENOMEM;
18941867

1895-
for (i = 0; i < cfg->num_resets; i++)
1896-
qmp->resets[i].id = cfg->reset_list[i];
1868+
for (i = 0; i < num_resets; i++)
1869+
qmp->resets[i].id = reset_list[i];
1870+
1871+
qmp->num_resets = num_resets;
18971872

1898-
ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets);
1873+
ret = devm_reset_control_bulk_get_exclusive(dev, num_resets, qmp->resets);
18991874
if (ret)
19001875
return dev_err_probe(dev, ret, "failed to get resets\n");
19011876

@@ -2064,6 +2039,11 @@ static int qmp_usb_parse_dt_legacy(struct qmp_usb *qmp, struct device_node *np)
20642039

20652040
qmp->num_clks = ret;
20662041

2042+
ret = qmp_usb_reset_init(qmp, usb3phy_legacy_reset_l,
2043+
ARRAY_SIZE(usb3phy_legacy_reset_l));
2044+
if (ret)
2045+
return ret;
2046+
20672047
return 0;
20682048
}
20692049

@@ -2105,6 +2085,11 @@ static int qmp_usb_parse_dt(struct qmp_usb *qmp)
21052085
"failed to get pipe clock\n");
21062086
}
21072087

2088+
ret = qmp_usb_reset_init(qmp, usb3phy_reset_l,
2089+
ARRAY_SIZE(usb3phy_reset_l));
2090+
if (ret)
2091+
return ret;
2092+
21082093
return 0;
21092094
}
21102095

@@ -2126,10 +2111,6 @@ static int qmp_usb_probe(struct platform_device *pdev)
21262111
if (!qmp->cfg)
21272112
return -EINVAL;
21282113

2129-
ret = qmp_usb_reset_init(qmp);
2130-
if (ret)
2131-
return ret;
2132-
21332114
ret = qmp_usb_vreg_init(qmp);
21342115
if (ret)
21352116
return ret;

0 commit comments

Comments
 (0)