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: simplify clock handling

For the existing PHYs for new binding we are going to drop ref_clk_src
clock and always use ref clock. Rather than introducing additional code
to handle legacy vs current bindings (and clock names), use
devm_clk_bulk_get_optional() when new bindings are used and
devm_clk_bulk_get_all() when legacy bindings are in place.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230824211952.1397699-3-dmitry.baryshkov@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Dmitry Baryshkov and committed by
Vinod Koul
7233090a 15c83637

+24 -66
+24 -66
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 - /* clock ids to be requested */ 1176 - const char * const *clk_list; 1177 - int num_clks; 1178 1175 /* resets to be requested */ 1179 1176 const char * const *reset_list; 1180 1177 int num_resets; ··· 1205 1208 1206 1209 struct clk *pipe_clk; 1207 1210 struct clk_bulk_data *clks; 1211 + int num_clks; 1208 1212 struct reset_control_bulk_data *resets; 1209 1213 struct regulator_bulk_data *vregs; 1210 1214 ··· 1241 1243 } 1242 1244 1243 1245 /* list of clocks required by phy */ 1244 - static const char * const msm8996_phy_clk_l[] = { 1245 - "aux", "cfg_ahb", "ref", 1246 - }; 1247 - 1248 - static const char * const qmp_v3_phy_clk_l[] = { 1246 + static const char * const qmp_usb_phy_clk_l[] = { 1249 1247 "aux", "cfg_ahb", "ref", "com_aux", 1250 - }; 1251 - 1252 - static const char * const qmp_v4_phy_clk_l[] = { 1253 - "aux", "ref", "com_aux", 1254 - }; 1255 - 1256 - static const char * const qmp_v4_ref_phy_clk_l[] = { 1257 - "aux", "ref_clk_src", "ref", "com_aux", 1258 - }; 1259 - 1260 - /* usb3 phy on sdx55 doesn't have com_aux clock */ 1261 - static const char * const qmp_v4_sdx55_usbphy_clk_l[] = { 1262 - "aux", "cfg_ahb", "ref" 1263 - }; 1264 - 1265 - static const char * const qcm2290_usb3phy_clk_l[] = { 1266 - "cfg_ahb", "ref", "com_aux", 1267 1248 }; 1268 1249 1269 1250 /* list of resets */ ··· 1296 1319 .rx_tbl_num = ARRAY_SIZE(ipq8074_usb3_rx_tbl), 1297 1320 .pcs_tbl = ipq8074_usb3_pcs_tbl, 1298 1321 .pcs_tbl_num = ARRAY_SIZE(ipq8074_usb3_pcs_tbl), 1299 - .clk_list = msm8996_phy_clk_l, 1300 - .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), 1301 1322 .reset_list = msm8996_usb3phy_reset_l, 1302 1323 .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1303 1324 .vreg_list = qmp_phy_vreg_l, ··· 1316 1341 .rx_tbl_num = ARRAY_SIZE(ipq9574_usb3_rx_tbl), 1317 1342 .pcs_tbl = ipq9574_usb3_pcs_tbl, 1318 1343 .pcs_tbl_num = ARRAY_SIZE(ipq9574_usb3_pcs_tbl), 1319 - .clk_list = msm8996_phy_clk_l, 1320 - .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), 1321 1344 .reset_list = qcm2290_usb3phy_reset_l, 1322 1345 .num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l), 1323 1346 .vreg_list = qmp_phy_vreg_l, ··· 1334 1361 .rx_tbl_num = ARRAY_SIZE(msm8996_usb3_rx_tbl), 1335 1362 .pcs_tbl = msm8996_usb3_pcs_tbl, 1336 1363 .pcs_tbl_num = ARRAY_SIZE(msm8996_usb3_pcs_tbl), 1337 - .clk_list = msm8996_phy_clk_l, 1338 - .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), 1339 1364 .reset_list = msm8996_usb3phy_reset_l, 1340 1365 .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1341 1366 .vreg_list = qmp_phy_vreg_l, ··· 1354 1383 .rx_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_rx_tbl), 1355 1384 .pcs_tbl = sa8775p_usb3_uniphy_pcs_tbl, 1356 1385 .pcs_tbl_num = ARRAY_SIZE(sa8775p_usb3_uniphy_pcs_tbl), 1357 - .clk_list = qmp_v4_phy_clk_l, 1358 - .num_clks = ARRAY_SIZE(qmp_v4_phy_clk_l), 1359 1386 .reset_list = qcm2290_usb3phy_reset_l, 1360 1387 .num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l), 1361 1388 .vreg_list = qmp_phy_vreg_l, ··· 1374 1405 .rx_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_rx_tbl), 1375 1406 .pcs_tbl = sc8280xp_usb3_uniphy_pcs_tbl, 1376 1407 .pcs_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_pcs_tbl), 1377 - .clk_list = qmp_v4_phy_clk_l, 1378 - .num_clks = ARRAY_SIZE(qmp_v4_phy_clk_l), 1379 1408 .reset_list = qcm2290_usb3phy_reset_l, 1380 1409 .num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l), 1381 1410 .vreg_list = qmp_phy_vreg_l, ··· 1392 1425 .rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_rx_tbl), 1393 1426 .pcs_tbl = qmp_v3_usb3_uniphy_pcs_tbl, 1394 1427 .pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_pcs_tbl), 1395 - .clk_list = qmp_v3_phy_clk_l, 1396 - .num_clks = ARRAY_SIZE(qmp_v3_phy_clk_l), 1397 1428 .reset_list = msm8996_usb3phy_reset_l, 1398 1429 .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1399 1430 .vreg_list = qmp_phy_vreg_l, ··· 1412 1447 .rx_tbl_num = ARRAY_SIZE(msm8998_usb3_rx_tbl), 1413 1448 .pcs_tbl = msm8998_usb3_pcs_tbl, 1414 1449 .pcs_tbl_num = ARRAY_SIZE(msm8998_usb3_pcs_tbl), 1415 - .clk_list = msm8996_phy_clk_l, 1416 - .num_clks = ARRAY_SIZE(msm8996_phy_clk_l), 1417 1450 .reset_list = msm8996_usb3phy_reset_l, 1418 1451 .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1419 1452 .vreg_list = qmp_phy_vreg_l, ··· 1432 1469 .pcs_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_pcs_tbl), 1433 1470 .pcs_usb_tbl = sm8150_usb3_uniphy_pcs_usb_tbl, 1434 1471 .pcs_usb_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_pcs_usb_tbl), 1435 - .clk_list = qmp_v4_ref_phy_clk_l, 1436 - .num_clks = ARRAY_SIZE(qmp_v4_ref_phy_clk_l), 1437 1472 .reset_list = msm8996_usb3phy_reset_l, 1438 1473 .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1439 1474 .vreg_list = qmp_phy_vreg_l, ··· 1455 1494 .pcs_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_tbl), 1456 1495 .pcs_usb_tbl = sm8250_usb3_uniphy_pcs_usb_tbl, 1457 1496 .pcs_usb_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_usb_tbl), 1458 - .clk_list = qmp_v4_ref_phy_clk_l, 1459 - .num_clks = ARRAY_SIZE(qmp_v4_ref_phy_clk_l), 1460 1497 .reset_list = msm8996_usb3phy_reset_l, 1461 1498 .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1462 1499 .vreg_list = qmp_phy_vreg_l, ··· 1478 1519 .pcs_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_tbl), 1479 1520 .pcs_usb_tbl = sm8250_usb3_uniphy_pcs_usb_tbl, 1480 1521 .pcs_usb_tbl_num = ARRAY_SIZE(sm8250_usb3_uniphy_pcs_usb_tbl), 1481 - .clk_list = qmp_v4_sdx55_usbphy_clk_l, 1482 - .num_clks = ARRAY_SIZE(qmp_v4_sdx55_usbphy_clk_l), 1483 1522 .reset_list = msm8996_usb3phy_reset_l, 1484 1523 .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1485 1524 .vreg_list = qmp_phy_vreg_l, ··· 1501 1544 .pcs_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_tbl), 1502 1545 .pcs_usb_tbl = sm8350_usb3_uniphy_pcs_usb_tbl, 1503 1546 .pcs_usb_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_usb_tbl), 1504 - .clk_list = qmp_v4_sdx55_usbphy_clk_l, 1505 - .num_clks = ARRAY_SIZE(qmp_v4_sdx55_usbphy_clk_l), 1506 1547 .reset_list = msm8996_usb3phy_reset_l, 1507 1548 .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1508 1549 .vreg_list = qmp_phy_vreg_l, ··· 1524 1569 .pcs_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_tbl), 1525 1570 .pcs_usb_tbl = sm8350_usb3_uniphy_pcs_usb_tbl, 1526 1571 .pcs_usb_tbl_num = ARRAY_SIZE(sm8350_usb3_uniphy_pcs_usb_tbl), 1527 - .clk_list = qmp_v4_ref_phy_clk_l, 1528 - .num_clks = ARRAY_SIZE(qmp_v4_ref_phy_clk_l), 1529 1572 .reset_list = msm8996_usb3phy_reset_l, 1530 1573 .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1531 1574 .vreg_list = qmp_phy_vreg_l, ··· 1547 1594 .rx_tbl_num = ARRAY_SIZE(qcm2290_usb3_rx_tbl), 1548 1595 .pcs_tbl = qcm2290_usb3_pcs_tbl, 1549 1596 .pcs_tbl_num = ARRAY_SIZE(qcm2290_usb3_pcs_tbl), 1550 - .clk_list = qcm2290_usb3phy_clk_l, 1551 - .num_clks = ARRAY_SIZE(qcm2290_usb3phy_clk_l), 1552 1597 .reset_list = qcm2290_usb3phy_reset_l, 1553 1598 .num_resets = ARRAY_SIZE(qcm2290_usb3phy_reset_l), 1554 1599 .vreg_list = qmp_phy_vreg_l, ··· 1617 1666 goto err_disable_regulators; 1618 1667 } 1619 1668 1620 - ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); 1669 + ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks); 1621 1670 if (ret) 1622 1671 goto err_assert_reset; 1623 1672 ··· 1640 1689 1641 1690 reset_control_bulk_assert(cfg->num_resets, qmp->resets); 1642 1691 1643 - clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); 1692 + clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); 1644 1693 1645 1694 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); 1646 1695 ··· 1814 1863 static int __maybe_unused qmp_usb_runtime_suspend(struct device *dev) 1815 1864 { 1816 1865 struct qmp_usb *qmp = dev_get_drvdata(dev); 1817 - const struct qmp_phy_cfg *cfg = qmp->cfg; 1818 1866 1819 1867 dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode); 1820 1868 ··· 1825 1875 qmp_usb_enable_autonomous_mode(qmp); 1826 1876 1827 1877 clk_disable_unprepare(qmp->pipe_clk); 1828 - clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); 1878 + clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); 1829 1879 1830 1880 return 0; 1831 1881 } ··· 1833 1883 static int __maybe_unused qmp_usb_runtime_resume(struct device *dev) 1834 1884 { 1835 1885 struct qmp_usb *qmp = dev_get_drvdata(dev); 1836 - const struct qmp_phy_cfg *cfg = qmp->cfg; 1837 1886 int ret = 0; 1838 1887 1839 1888 dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode); ··· 1842 1893 return 0; 1843 1894 } 1844 1895 1845 - ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); 1896 + ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks); 1846 1897 if (ret) 1847 1898 return ret; 1848 1899 1849 1900 ret = clk_prepare_enable(qmp->pipe_clk); 1850 1901 if (ret) { 1851 1902 dev_err(dev, "pipe_clk enable failed, err=%d\n", ret); 1852 - clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); 1903 + clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); 1853 1904 return ret; 1854 1905 } 1855 1906 ··· 1904 1955 1905 1956 static int qmp_usb_clk_init(struct qmp_usb *qmp) 1906 1957 { 1907 - const struct qmp_phy_cfg *cfg = qmp->cfg; 1908 1958 struct device *dev = qmp->dev; 1909 - int num = cfg->num_clks; 1959 + int num = ARRAY_SIZE(qmp_usb_phy_clk_l); 1910 1960 int i; 1911 1961 1912 1962 qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); ··· 1913 1965 return -ENOMEM; 1914 1966 1915 1967 for (i = 0; i < num; i++) 1916 - qmp->clks[i].id = cfg->clk_list[i]; 1968 + qmp->clks[i].id = qmp_usb_phy_clk_l[i]; 1917 1969 1918 - return devm_clk_bulk_get(dev, num, qmp->clks); 1970 + qmp->num_clks = num; 1971 + 1972 + return devm_clk_bulk_get_optional(dev, num, qmp->clks); 1919 1973 } 1920 1974 1921 1975 static void phy_clk_release_provider(void *res) ··· 1997 2047 const struct qmp_phy_cfg *cfg = qmp->cfg; 1998 2048 struct device *dev = qmp->dev; 1999 2049 bool exclusive = true; 2050 + int ret; 2000 2051 2001 2052 qmp->serdes = devm_platform_ioremap_resource(pdev, 0); 2002 2053 if (IS_ERR(qmp->serdes)) ··· 2058 2107 "failed to get pipe clock\n"); 2059 2108 } 2060 2109 2110 + ret = devm_clk_bulk_get_all(qmp->dev, &qmp->clks); 2111 + if (ret < 0) 2112 + return ret; 2113 + 2114 + qmp->num_clks = ret; 2115 + 2061 2116 return 0; 2062 2117 } 2063 2118 ··· 2074 2117 const struct qmp_usb_offsets *offs = cfg->offsets; 2075 2118 struct device *dev = qmp->dev; 2076 2119 void __iomem *base; 2120 + int ret; 2077 2121 2078 2122 if (!offs) 2079 2123 return -EINVAL; ··· 2094 2136 qmp->tx2 = base + offs->tx2; 2095 2137 qmp->rx2 = base + offs->rx2; 2096 2138 } 2139 + 2140 + ret = qmp_usb_clk_init(qmp); 2141 + if (ret) 2142 + return ret; 2097 2143 2098 2144 qmp->pipe_clk = devm_clk_get(dev, "pipe"); 2099 2145 if (IS_ERR(qmp->pipe_clk)) { ··· 2125 2163 qmp->cfg = of_device_get_match_data(dev); 2126 2164 if (!qmp->cfg) 2127 2165 return -EINVAL; 2128 - 2129 - ret = qmp_usb_clk_init(qmp); 2130 - if (ret) 2131 - return ret; 2132 2166 2133 2167 ret = qmp_usb_reset_init(qmp); 2134 2168 if (ret)