Lines Matching full:qmp

23 #include "phy-qcom-qmp.h"
24 #include "phy-qcom-qmp-pcs-ufs-v2.h"
25 #include "phy-qcom-qmp-pcs-ufs-v3.h"
26 #include "phy-qcom-qmp-pcs-ufs-v4.h"
27 #include "phy-qcom-qmp-pcs-ufs-v5.h"
28 #include "phy-qcom-qmp-pcs-ufs-v6.h"
30 #include "phy-qcom-qmp-qserdes-txrx-ufs-v6.h"
1193 static void qmp_ufs_serdes_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls) in qmp_ufs_serdes_init() argument
1195 void __iomem *serdes = qmp->serdes; in qmp_ufs_serdes_init()
1200 static void qmp_ufs_lanes_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls) in qmp_ufs_lanes_init() argument
1202 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_lanes_init()
1203 void __iomem *tx = qmp->tx; in qmp_ufs_lanes_init()
1204 void __iomem *rx = qmp->rx; in qmp_ufs_lanes_init()
1210 qmp_ufs_configure_lane(qmp->tx2, tbls->tx, tbls->tx_num, 2); in qmp_ufs_lanes_init()
1211 qmp_ufs_configure_lane(qmp->rx2, tbls->rx, tbls->rx_num, 2); in qmp_ufs_lanes_init()
1215 static void qmp_ufs_pcs_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls) in qmp_ufs_pcs_init() argument
1217 void __iomem *pcs = qmp->pcs; in qmp_ufs_pcs_init()
1222 static void qmp_ufs_init_registers(struct qmp_ufs *qmp, const struct qmp_phy_cfg *cfg) in qmp_ufs_init_registers() argument
1224 qmp_ufs_serdes_init(qmp, &cfg->tbls); in qmp_ufs_init_registers()
1225 if (qmp->mode == PHY_MODE_UFS_HS_B) in qmp_ufs_init_registers()
1226 qmp_ufs_serdes_init(qmp, &cfg->tbls_hs_b); in qmp_ufs_init_registers()
1227 qmp_ufs_lanes_init(qmp, &cfg->tbls); in qmp_ufs_init_registers()
1228 if (qmp->submode == UFS_HS_G4) in qmp_ufs_init_registers()
1229 qmp_ufs_lanes_init(qmp, &cfg->tbls_hs_g4); in qmp_ufs_init_registers()
1230 qmp_ufs_pcs_init(qmp, &cfg->tbls); in qmp_ufs_init_registers()
1231 if (qmp->submode == UFS_HS_G4) in qmp_ufs_init_registers()
1232 qmp_ufs_pcs_init(qmp, &cfg->tbls_hs_g4); in qmp_ufs_init_registers()
1235 static int qmp_ufs_com_init(struct qmp_ufs *qmp) in qmp_ufs_com_init() argument
1237 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_com_init()
1238 void __iomem *pcs = qmp->pcs; in qmp_ufs_com_init()
1241 ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); in qmp_ufs_com_init()
1243 dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); in qmp_ufs_com_init()
1247 ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); in qmp_ufs_com_init()
1256 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_ufs_com_init()
1261 static int qmp_ufs_com_exit(struct qmp_ufs *qmp) in qmp_ufs_com_exit() argument
1263 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_com_exit()
1265 reset_control_assert(qmp->ufs_reset); in qmp_ufs_com_exit()
1267 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); in qmp_ufs_com_exit()
1269 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_ufs_com_exit()
1276 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_init() local
1277 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_init()
1279 dev_vdbg(qmp->dev, "Initializing QMP phy\n"); in qmp_ufs_init()
1287 if (!qmp->ufs_reset) { in qmp_ufs_init()
1288 qmp->ufs_reset = in qmp_ufs_init()
1289 devm_reset_control_get_exclusive(qmp->dev, in qmp_ufs_init()
1292 if (IS_ERR(qmp->ufs_reset)) { in qmp_ufs_init()
1293 ret = PTR_ERR(qmp->ufs_reset); in qmp_ufs_init()
1294 dev_err(qmp->dev, in qmp_ufs_init()
1298 qmp->ufs_reset = NULL; in qmp_ufs_init()
1303 ret = reset_control_assert(qmp->ufs_reset); in qmp_ufs_init()
1308 ret = qmp_ufs_com_init(qmp); in qmp_ufs_init()
1317 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_power_on() local
1318 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_power_on()
1319 void __iomem *pcs = qmp->pcs; in qmp_ufs_power_on()
1324 qmp_ufs_init_registers(qmp, cfg); in qmp_ufs_power_on()
1326 ret = reset_control_deassert(qmp->ufs_reset); in qmp_ufs_power_on()
1341 dev_err(qmp->dev, "phy initialization timed-out\n"); in qmp_ufs_power_on()
1350 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_power_off() local
1351 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_power_off()
1355 qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_ufs_power_off()
1358 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL], SERDES_START); in qmp_ufs_power_off()
1361 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], in qmp_ufs_power_off()
1369 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_exit() local
1371 qmp_ufs_com_exit(qmp); in qmp_ufs_exit()
1403 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_set_mode() local
1405 qmp->mode = mode; in qmp_ufs_set_mode()
1406 qmp->submode = submode; in qmp_ufs_set_mode()
1418 static int qmp_ufs_vreg_init(struct qmp_ufs *qmp) in qmp_ufs_vreg_init() argument
1420 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_vreg_init()
1421 struct device *dev = qmp->dev; in qmp_ufs_vreg_init()
1425 qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); in qmp_ufs_vreg_init()
1426 if (!qmp->vregs) in qmp_ufs_vreg_init()
1430 qmp->vregs[i].supply = cfg->vreg_list[i]; in qmp_ufs_vreg_init()
1432 return devm_regulator_bulk_get(dev, num, qmp->vregs); in qmp_ufs_vreg_init()
1435 static int qmp_ufs_clk_init(struct qmp_ufs *qmp) in qmp_ufs_clk_init() argument
1437 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_clk_init()
1438 struct device *dev = qmp->dev; in qmp_ufs_clk_init()
1442 qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); in qmp_ufs_clk_init()
1443 if (!qmp->clks) in qmp_ufs_clk_init()
1447 qmp->clks[i].id = cfg->clk_list[i]; in qmp_ufs_clk_init()
1449 return devm_clk_bulk_get(dev, num, qmp->clks); in qmp_ufs_clk_init()
1459 static int qmp_ufs_register_clocks(struct qmp_ufs *qmp, struct device_node *np) in qmp_ufs_register_clocks() argument
1466 clk_data = devm_kzalloc(qmp->dev, in qmp_ufs_register_clocks()
1474 snprintf(name, sizeof(name), "%s::rx_symbol_0", dev_name(qmp->dev)); in qmp_ufs_register_clocks()
1475 hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); in qmp_ufs_register_clocks()
1481 snprintf(name, sizeof(name), "%s::rx_symbol_1", dev_name(qmp->dev)); in qmp_ufs_register_clocks()
1482 hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); in qmp_ufs_register_clocks()
1488 snprintf(name, sizeof(name), "%s::tx_symbol_0", dev_name(qmp->dev)); in qmp_ufs_register_clocks()
1489 hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); in qmp_ufs_register_clocks()
1502 return devm_add_action_or_reset(qmp->dev, qmp_ufs_clk_release_provider, np); in qmp_ufs_register_clocks()
1505 static int qmp_ufs_parse_dt_legacy(struct qmp_ufs *qmp, struct device_node *np) in qmp_ufs_parse_dt_legacy() argument
1507 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_ufs_parse_dt_legacy()
1508 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_parse_dt_legacy()
1509 struct device *dev = qmp->dev; in qmp_ufs_parse_dt_legacy()
1511 qmp->serdes = devm_platform_ioremap_resource(pdev, 0); in qmp_ufs_parse_dt_legacy()
1512 if (IS_ERR(qmp->serdes)) in qmp_ufs_parse_dt_legacy()
1513 return PTR_ERR(qmp->serdes); in qmp_ufs_parse_dt_legacy()
1521 qmp->tx = devm_of_iomap(dev, np, 0, NULL); in qmp_ufs_parse_dt_legacy()
1522 if (IS_ERR(qmp->tx)) in qmp_ufs_parse_dt_legacy()
1523 return PTR_ERR(qmp->tx); in qmp_ufs_parse_dt_legacy()
1525 qmp->rx = devm_of_iomap(dev, np, 1, NULL); in qmp_ufs_parse_dt_legacy()
1526 if (IS_ERR(qmp->rx)) in qmp_ufs_parse_dt_legacy()
1527 return PTR_ERR(qmp->rx); in qmp_ufs_parse_dt_legacy()
1529 qmp->pcs = devm_of_iomap(dev, np, 2, NULL); in qmp_ufs_parse_dt_legacy()
1530 if (IS_ERR(qmp->pcs)) in qmp_ufs_parse_dt_legacy()
1531 return PTR_ERR(qmp->pcs); in qmp_ufs_parse_dt_legacy()
1534 qmp->tx2 = devm_of_iomap(dev, np, 3, NULL); in qmp_ufs_parse_dt_legacy()
1535 if (IS_ERR(qmp->tx2)) in qmp_ufs_parse_dt_legacy()
1536 return PTR_ERR(qmp->tx2); in qmp_ufs_parse_dt_legacy()
1538 qmp->rx2 = devm_of_iomap(dev, np, 4, NULL); in qmp_ufs_parse_dt_legacy()
1539 if (IS_ERR(qmp->rx2)) in qmp_ufs_parse_dt_legacy()
1540 return PTR_ERR(qmp->rx2); in qmp_ufs_parse_dt_legacy()
1542 qmp->pcs_misc = devm_of_iomap(dev, np, 5, NULL); in qmp_ufs_parse_dt_legacy()
1544 qmp->pcs_misc = devm_of_iomap(dev, np, 3, NULL); in qmp_ufs_parse_dt_legacy()
1547 if (IS_ERR(qmp->pcs_misc)) in qmp_ufs_parse_dt_legacy()
1553 static int qmp_ufs_parse_dt(struct qmp_ufs *qmp) in qmp_ufs_parse_dt() argument
1555 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_ufs_parse_dt()
1556 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_parse_dt()
1567 qmp->serdes = base + offs->serdes; in qmp_ufs_parse_dt()
1568 qmp->pcs = base + offs->pcs; in qmp_ufs_parse_dt()
1569 qmp->tx = base + offs->tx; in qmp_ufs_parse_dt()
1570 qmp->rx = base + offs->rx; in qmp_ufs_parse_dt()
1573 qmp->tx2 = base + offs->tx2; in qmp_ufs_parse_dt()
1574 qmp->rx2 = base + offs->rx2; in qmp_ufs_parse_dt()
1585 struct qmp_ufs *qmp; in qmp_ufs_probe() local
1588 qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); in qmp_ufs_probe()
1589 if (!qmp) in qmp_ufs_probe()
1592 qmp->dev = dev; in qmp_ufs_probe()
1594 qmp->cfg = of_device_get_match_data(dev); in qmp_ufs_probe()
1595 if (!qmp->cfg) in qmp_ufs_probe()
1598 ret = qmp_ufs_clk_init(qmp); in qmp_ufs_probe()
1602 ret = qmp_ufs_vreg_init(qmp); in qmp_ufs_probe()
1609 ret = qmp_ufs_parse_dt_legacy(qmp, np); in qmp_ufs_probe()
1612 ret = qmp_ufs_parse_dt(qmp); in qmp_ufs_probe()
1617 ret = qmp_ufs_register_clocks(qmp, np); in qmp_ufs_probe()
1621 qmp->phy = devm_phy_create(dev, np, &qcom_qmp_ufs_phy_ops); in qmp_ufs_probe()
1622 if (IS_ERR(qmp->phy)) { in qmp_ufs_probe()
1623 ret = PTR_ERR(qmp->phy); in qmp_ufs_probe()
1628 phy_set_drvdata(qmp->phy, qmp); in qmp_ufs_probe()
1643 .compatible = "qcom,msm8996-qmp-ufs-phy",
1646 .compatible = "qcom,msm8998-qmp-ufs-phy",
1649 .compatible = "qcom,sa8775p-qmp-ufs-phy",
1652 .compatible = "qcom,sc8180x-qmp-ufs-phy",
1655 .compatible = "qcom,sc8280xp-qmp-ufs-phy",
1658 .compatible = "qcom,sdm845-qmp-ufs-phy",
1661 .compatible = "qcom,sm6115-qmp-ufs-phy",
1664 .compatible = "qcom,sm6125-qmp-ufs-phy",
1667 .compatible = "qcom,sm6350-qmp-ufs-phy",
1670 .compatible = "qcom,sm7150-qmp-ufs-phy",
1673 .compatible = "qcom,sm8150-qmp-ufs-phy",
1676 .compatible = "qcom,sm8250-qmp-ufs-phy",
1679 .compatible = "qcom,sm8350-qmp-ufs-phy",
1682 .compatible = "qcom,sm8450-qmp-ufs-phy",
1685 .compatible = "qcom,sm8550-qmp-ufs-phy",
1695 .name = "qcom-qmp-ufs-phy",
1703 MODULE_DESCRIPTION("Qualcomm QMP UFS PHY driver");