Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Dmitry Baryshkov and committed by
Vinod Koul
fcf63482 7233090a

+26 -45
+26 -45
drivers/phy/qualcomm/phy-qcom-qmp-usb.c
··· 1172 1172 const struct qmp_phy_init_tbl *pcs_usb_tbl; 1173 1173 int pcs_usb_tbl_num; 1174 1174 1175 - /* resets to be requested */ 1176 - const char * const *reset_list; 1177 - int num_resets; 1178 1175 /* regulators to be requested */ 1179 1176 const char * const *vreg_list; 1180 1177 int num_vregs; ··· 1203 1206 struct clk *pipe_clk; 1204 1207 struct clk_bulk_data *clks; 1205 1208 int num_clks; 1209 + int num_resets; 1206 1210 struct reset_control_bulk_data *resets; 1207 1211 struct regulator_bulk_data *vregs; 1208 1212 ··· 1244 1246 }; 1245 1247 1246 1248 /* list of resets */ 1247 - static const char * const msm8996_usb3phy_reset_l[] = { 1249 + static const char * const usb3phy_legacy_reset_l[] = { 1248 1250 "phy", "common", 1249 1251 }; 1250 1252 1251 - static const char * const qcm2290_usb3phy_reset_l[] = { 1253 + static const char * const usb3phy_reset_l[] = { 1252 1254 "phy_phy", "phy", 1253 1255 }; 1254 1256 ··· 1294 1296 .rx_tbl_num = ARRAY_SIZE(ipq8074_usb3_rx_tbl), 1295 1297 .pcs_tbl = ipq8074_usb3_pcs_tbl, 1296 1298 .pcs_tbl_num = ARRAY_SIZE(ipq8074_usb3_pcs_tbl), 1297 - .reset_list = msm8996_usb3phy_reset_l, 1298 - .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1299 1299 .vreg_list = qmp_phy_vreg_l, 1300 1300 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1301 1301 .regs = qmp_v3_usb3phy_regs_layout, ··· 1312 1316 .rx_tbl_num = ARRAY_SIZE(ipq9574_usb3_rx_tbl), 1313 1317 .pcs_tbl = ipq9574_usb3_pcs_tbl, 1314 1318 .pcs_tbl_num = ARRAY_SIZE(ipq9574_usb3_pcs_tbl), 1315 - .reset_list = qcm2290_usb3phy_reset_l, 1316 - .num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l), 1317 1319 .vreg_list = qmp_phy_vreg_l, 1318 1320 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1319 1321 .regs = qmp_v3_usb3phy_regs_layout, ··· 1328 1334 .rx_tbl_num = ARRAY_SIZE(msm8996_usb3_rx_tbl), 1329 1335 .pcs_tbl = msm8996_usb3_pcs_tbl, 1330 1336 .pcs_tbl_num = ARRAY_SIZE(msm8996_usb3_pcs_tbl), 1331 - .reset_list = msm8996_usb3phy_reset_l, 1332 - .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1333 1337 .vreg_list = qmp_phy_vreg_l, 1334 1338 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1335 1339 .regs = qmp_v2_usb3phy_regs_layout, ··· 1346 1354 .rx_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_rx_tbl), 1347 1355 .pcs_tbl = sa8775p_usb3_uniphy_pcs_tbl, 1348 1356 .pcs_tbl_num = ARRAY_SIZE(sa8775p_usb3_uniphy_pcs_tbl), 1349 - .reset_list = qcm2290_usb3phy_reset_l, 1350 - .num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l), 1351 1357 .vreg_list = qmp_phy_vreg_l, 1352 1358 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1353 1359 .regs = qmp_v5_usb3phy_regs_layout, ··· 1364 1374 .rx_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_rx_tbl), 1365 1375 .pcs_tbl = sc8280xp_usb3_uniphy_pcs_tbl, 1366 1376 .pcs_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_pcs_tbl), 1367 - .reset_list = qcm2290_usb3phy_reset_l, 1368 - .num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l), 1369 1377 .vreg_list = qmp_phy_vreg_l, 1370 1378 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1371 1379 .regs = qmp_v5_usb3phy_regs_layout, ··· 1380 1392 .rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_rx_tbl), 1381 1393 .pcs_tbl = qmp_v3_usb3_uniphy_pcs_tbl, 1382 1394 .pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_pcs_tbl), 1383 - .reset_list = msm8996_usb3phy_reset_l, 1384 - .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1385 1395 .vreg_list = qmp_phy_vreg_l, 1386 1396 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1387 1397 .regs = qmp_v3_usb3phy_regs_layout, ··· 1398 1412 .rx_tbl_num = ARRAY_SIZE(msm8998_usb3_rx_tbl), 1399 1413 .pcs_tbl = msm8998_usb3_pcs_tbl, 1400 1414 .pcs_tbl_num = ARRAY_SIZE(msm8998_usb3_pcs_tbl), 1401 - .reset_list = msm8996_usb3phy_reset_l, 1402 - .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1403 1415 .vreg_list = qmp_phy_vreg_l, 1404 1416 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1405 1417 .regs = qmp_v3_usb3phy_regs_layout, ··· 1416 1432 .pcs_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_pcs_tbl), 1417 1433 .pcs_usb_tbl = sm8150_usb3_uniphy_pcs_usb_tbl, 1418 1434 .pcs_usb_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_pcs_usb_tbl), 1419 - .reset_list = msm8996_usb3phy_reset_l, 1420 - .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1421 1435 .vreg_list = qmp_phy_vreg_l, 1422 1436 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1423 1437 .regs = qmp_v4_usb3phy_regs_layout, ··· 1437 1455 .pcs_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_tbl), 1438 1456 .pcs_usb_tbl = sm8250_usb3_uniphy_pcs_usb_tbl, 1439 1457 .pcs_usb_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_usb_tbl), 1440 - .reset_list = msm8996_usb3phy_reset_l, 1441 - .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1442 1458 .vreg_list = qmp_phy_vreg_l, 1443 1459 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1444 1460 .regs = qmp_v4_usb3phy_regs_layout, ··· 1458 1478 .pcs_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_tbl), 1459 1479 .pcs_usb_tbl = sm8250_usb3_uniphy_pcs_usb_tbl, 1460 1480 .pcs_usb_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_usb_tbl), 1461 - .reset_list = msm8996_usb3phy_reset_l, 1462 - .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1463 1481 .vreg_list = qmp_phy_vreg_l, 1464 1482 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1465 1483 .regs = qmp_v4_usb3phy_regs_layout, ··· 1479 1501 .pcs_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_tbl), 1480 1502 .pcs_usb_tbl = sm8350_usb3_uniphy_pcs_usb_tbl, 1481 1503 .pcs_usb_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_usb_tbl), 1482 - .reset_list = msm8996_usb3phy_reset_l, 1483 - .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1484 1504 .vreg_list = qmp_phy_vreg_l, 1485 1505 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1486 1506 .regs = qmp_v5_usb3phy_regs_layout, ··· 1500 1524 .pcs_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_tbl), 1501 1525 .pcs_usb_tbl = sm8350_usb3_uniphy_pcs_usb_tbl, 1502 1526 .pcs_usb_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_usb_tbl), 1503 - .reset_list = msm8996_usb3phy_reset_l, 1504 - .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1505 1527 .vreg_list = qmp_phy_vreg_l, 1506 1528 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1507 1529 .regs = qmp_v5_usb3phy_regs_layout, ··· 1521 1547 .rx_tbl_num = ARRAY_SIZE(qcm2290_usb3_rx_tbl), 1522 1548 .pcs_tbl = qcm2290_usb3_pcs_tbl, 1523 1549 .pcs_tbl_num = ARRAY_SIZE(qcm2290_usb3_pcs_tbl), 1524 - .reset_list = qcm2290_usb3phy_reset_l, 1525 - .num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l), 1526 1550 .vreg_list = qmp_phy_vreg_l, 1527 1551 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1528 1552 .regs = qmp_v3_usb3phy_regs_layout, ··· 1577 1605 return ret; 1578 1606 } 1579 1607 1580 - ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets); 1608 + ret = reset_control_bulk_assert(qmp->num_resets, qmp->resets); 1581 1609 if (ret) { 1582 1610 dev_err(qmp->dev, "reset assert failed\n"); 1583 1611 goto err_disable_regulators; 1584 1612 } 1585 1613 1586 - ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets); 1614 + ret = reset_control_bulk_deassert(qmp->num_resets, qmp->resets); 1587 1615 if (ret) { 1588 1616 dev_err(qmp->dev, "reset deassert failed\n"); 1589 1617 goto err_disable_regulators; ··· 1598 1626 return 0; 1599 1627 1600 1628 err_assert_reset: 1601 - reset_control_bulk_assert(cfg->num_resets, qmp->resets); 1629 + reset_control_bulk_assert(qmp->num_resets, qmp->resets); 1602 1630 err_disable_regulators: 1603 1631 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); 1604 1632 ··· 1610 1638 struct qmp_usb *qmp = phy_get_drvdata(phy); 1611 1639 const struct qmp_phy_cfg *cfg = qmp->cfg; 1612 1640 1613 - reset_control_bulk_assert(cfg->num_resets, qmp->resets); 1641 + reset_control_bulk_assert(qmp->num_resets, qmp->resets); 1614 1642 1615 1643 clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); 1616 1644 ··· 1852 1880 return devm_regulator_bulk_get(dev, num, qmp->vregs); 1853 1881 } 1854 1882 1855 - static int qmp_usb_reset_init(struct qmp_usb *qmp) 1883 + static int qmp_usb_reset_init(struct qmp_usb *qmp, 1884 + const char *const *reset_list, 1885 + int num_resets) 1856 1886 { 1857 - const struct qmp_phy_cfg *cfg = qmp->cfg; 1858 1887 struct device *dev = qmp->dev; 1859 1888 int i; 1860 1889 int ret; 1861 1890 1862 - qmp->resets = devm_kcalloc(dev, cfg->num_resets, 1891 + qmp->resets = devm_kcalloc(dev, num_resets, 1863 1892 sizeof(*qmp->resets), GFP_KERNEL); 1864 1893 if (!qmp->resets) 1865 1894 return -ENOMEM; 1866 1895 1867 - for (i = 0; i < cfg->num_resets; i++) 1868 - qmp->resets[i].id = cfg->reset_list[i]; 1896 + for (i = 0; i < num_resets; i++) 1897 + qmp->resets[i].id = reset_list[i]; 1869 1898 1870 - ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets); 1899 + qmp->num_resets = num_resets; 1900 + 1901 + ret = devm_reset_control_bulk_get_exclusive(dev, num_resets, qmp->resets); 1871 1902 if (ret) 1872 1903 return dev_err_probe(dev, ret, "failed to get resets\n"); 1873 1904 ··· 2039 2064 2040 2065 qmp->num_clks = ret; 2041 2066 2067 + ret = qmp_usb_reset_init(qmp, usb3phy_legacy_reset_l, 2068 + ARRAY_SIZE(usb3phy_legacy_reset_l)); 2069 + if (ret) 2070 + return ret; 2071 + 2042 2072 return 0; 2043 2073 } 2044 2074 ··· 2085 2105 "failed to get pipe clock\n"); 2086 2106 } 2087 2107 2108 + ret = qmp_usb_reset_init(qmp, usb3phy_reset_l, 2109 + ARRAY_SIZE(usb3phy_reset_l)); 2110 + if (ret) 2111 + return ret; 2112 + 2088 2113 return 0; 2089 2114 } 2090 2115 ··· 2110 2125 qmp->cfg = of_device_get_match_data(dev); 2111 2126 if (!qmp->cfg) 2112 2127 return -EINVAL; 2113 - 2114 - ret = qmp_usb_reset_init(qmp); 2115 - if (ret) 2116 - return ret; 2117 2128 2118 2129 ret = qmp_usb_vreg_init(qmp); 2119 2130 if (ret)