Lines Matching full:qmp

24 #include "phy-qcom-qmp-common.h"
26 #include "phy-qcom-qmp.h"
27 #include "phy-qcom-qmp-pcs-ufs-v2.h"
28 #include "phy-qcom-qmp-pcs-ufs-v3.h"
29 #include "phy-qcom-qmp-pcs-ufs-v4.h"
30 #include "phy-qcom-qmp-pcs-ufs-v5.h"
31 #include "phy-qcom-qmp-pcs-ufs-v6.h"
33 #include "phy-qcom-qmp-qserdes-txrx-ufs-v6.h"
1526 static void qmp_ufs_serdes_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls) in qmp_ufs_serdes_init() argument
1528 void __iomem *serdes = qmp->serdes; in qmp_ufs_serdes_init()
1530 qmp_configure(qmp->dev, serdes, tbls->serdes, tbls->serdes_num); in qmp_ufs_serdes_init()
1533 static void qmp_ufs_lanes_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls) in qmp_ufs_lanes_init() argument
1535 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_lanes_init()
1536 void __iomem *tx = qmp->tx; in qmp_ufs_lanes_init()
1537 void __iomem *rx = qmp->rx; in qmp_ufs_lanes_init()
1539 qmp_configure_lane(qmp->dev, tx, tbls->tx, tbls->tx_num, 1); in qmp_ufs_lanes_init()
1540 qmp_configure_lane(qmp->dev, rx, tbls->rx, tbls->rx_num, 1); in qmp_ufs_lanes_init()
1543 qmp_configure_lane(qmp->dev, qmp->tx2, tbls->tx, tbls->tx_num, 2); in qmp_ufs_lanes_init()
1544 qmp_configure_lane(qmp->dev, qmp->rx2, tbls->rx, tbls->rx_num, 2); in qmp_ufs_lanes_init()
1548 static void qmp_ufs_pcs_init(struct qmp_ufs *qmp, const struct qmp_phy_cfg_tbls *tbls) in qmp_ufs_pcs_init() argument
1550 void __iomem *pcs = qmp->pcs; in qmp_ufs_pcs_init()
1552 qmp_configure(qmp->dev, pcs, tbls->pcs, tbls->pcs_num); in qmp_ufs_pcs_init()
1555 static int qmp_ufs_get_gear_overlay(struct qmp_ufs *qmp, const struct qmp_phy_cfg *cfg) in qmp_ufs_get_gear_overlay() argument
1568 if (qmp->submode == max_gear) in qmp_ufs_get_gear_overlay()
1581 static void qmp_ufs_init_registers(struct qmp_ufs *qmp, const struct qmp_phy_cfg *cfg) in qmp_ufs_init_registers() argument
1585 qmp_ufs_serdes_init(qmp, &cfg->tbls); in qmp_ufs_init_registers()
1586 qmp_ufs_lanes_init(qmp, &cfg->tbls); in qmp_ufs_init_registers()
1587 qmp_ufs_pcs_init(qmp, &cfg->tbls); in qmp_ufs_init_registers()
1589 i = qmp_ufs_get_gear_overlay(qmp, cfg); in qmp_ufs_init_registers()
1591 qmp_ufs_serdes_init(qmp, &cfg->tbls_hs_overlay[i]); in qmp_ufs_init_registers()
1592 qmp_ufs_lanes_init(qmp, &cfg->tbls_hs_overlay[i]); in qmp_ufs_init_registers()
1593 qmp_ufs_pcs_init(qmp, &cfg->tbls_hs_overlay[i]); in qmp_ufs_init_registers()
1596 if (qmp->mode == PHY_MODE_UFS_HS_B) in qmp_ufs_init_registers()
1597 qmp_ufs_serdes_init(qmp, &cfg->tbls_hs_b); in qmp_ufs_init_registers()
1600 static int qmp_ufs_com_init(struct qmp_ufs *qmp) in qmp_ufs_com_init() argument
1602 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_com_init()
1603 void __iomem *pcs = qmp->pcs; in qmp_ufs_com_init()
1606 ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); in qmp_ufs_com_init()
1608 dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); in qmp_ufs_com_init()
1612 ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks); in qmp_ufs_com_init()
1621 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_ufs_com_init()
1626 static int qmp_ufs_com_exit(struct qmp_ufs *qmp) in qmp_ufs_com_exit() argument
1628 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_com_exit()
1630 reset_control_assert(qmp->ufs_reset); in qmp_ufs_com_exit()
1632 clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); in qmp_ufs_com_exit()
1634 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_ufs_com_exit()
1641 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_init() local
1642 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_init()
1644 dev_vdbg(qmp->dev, "Initializing QMP phy\n"); in qmp_ufs_init()
1652 if (!qmp->ufs_reset) { in qmp_ufs_init()
1653 qmp->ufs_reset = in qmp_ufs_init()
1654 devm_reset_control_get_exclusive(qmp->dev, in qmp_ufs_init()
1657 if (IS_ERR(qmp->ufs_reset)) { in qmp_ufs_init()
1658 ret = PTR_ERR(qmp->ufs_reset); in qmp_ufs_init()
1659 dev_err(qmp->dev, in qmp_ufs_init()
1663 qmp->ufs_reset = NULL; in qmp_ufs_init()
1668 ret = reset_control_assert(qmp->ufs_reset); in qmp_ufs_init()
1673 ret = qmp_ufs_com_init(qmp); in qmp_ufs_init()
1682 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_power_on() local
1683 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_power_on()
1684 void __iomem *pcs = qmp->pcs; in qmp_ufs_power_on()
1689 qmp_ufs_init_registers(qmp, cfg); in qmp_ufs_power_on()
1691 ret = reset_control_deassert(qmp->ufs_reset); in qmp_ufs_power_on()
1706 dev_err(qmp->dev, "phy initialization timed-out\n"); in qmp_ufs_power_on()
1715 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_power_off() local
1716 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_power_off()
1720 qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_ufs_power_off()
1723 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL], SERDES_START); in qmp_ufs_power_off()
1726 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], in qmp_ufs_power_off()
1734 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_exit() local
1736 qmp_ufs_com_exit(qmp); in qmp_ufs_exit()
1768 struct qmp_ufs *qmp = phy_get_drvdata(phy); in qmp_ufs_set_mode() local
1769 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_set_mode()
1772 dev_err(qmp->dev, "Invalid PHY submode %d\n", submode); in qmp_ufs_set_mode()
1776 qmp->mode = mode; in qmp_ufs_set_mode()
1777 qmp->submode = submode; in qmp_ufs_set_mode()
1789 static int qmp_ufs_vreg_init(struct qmp_ufs *qmp) in qmp_ufs_vreg_init() argument
1791 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_vreg_init()
1792 struct device *dev = qmp->dev; in qmp_ufs_vreg_init()
1796 qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); in qmp_ufs_vreg_init()
1797 if (!qmp->vregs) in qmp_ufs_vreg_init()
1801 qmp->vregs[i].supply = cfg->vreg_list[i]; in qmp_ufs_vreg_init()
1803 return devm_regulator_bulk_get(dev, num, qmp->vregs); in qmp_ufs_vreg_init()
1806 static int qmp_ufs_clk_init(struct qmp_ufs *qmp) in qmp_ufs_clk_init() argument
1808 struct device *dev = qmp->dev; in qmp_ufs_clk_init()
1810 qmp->num_clks = devm_clk_bulk_get_all(dev, &qmp->clks); in qmp_ufs_clk_init()
1811 if (qmp->num_clks < 0) in qmp_ufs_clk_init()
1812 return qmp->num_clks; in qmp_ufs_clk_init()
1824 static int qmp_ufs_register_clocks(struct qmp_ufs *qmp, struct device_node *np) in qmp_ufs_register_clocks() argument
1831 clk_data = devm_kzalloc(qmp->dev, in qmp_ufs_register_clocks()
1839 snprintf(name, sizeof(name), "%s::rx_symbol_0", dev_name(qmp->dev)); in qmp_ufs_register_clocks()
1840 hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); in qmp_ufs_register_clocks()
1846 snprintf(name, sizeof(name), "%s::rx_symbol_1", dev_name(qmp->dev)); in qmp_ufs_register_clocks()
1847 hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); in qmp_ufs_register_clocks()
1853 snprintf(name, sizeof(name), "%s::tx_symbol_0", dev_name(qmp->dev)); in qmp_ufs_register_clocks()
1854 hw = devm_clk_hw_register_fixed_rate(qmp->dev, name, NULL, 0, 0); in qmp_ufs_register_clocks()
1867 return devm_add_action_or_reset(qmp->dev, qmp_ufs_clk_release_provider, np); in qmp_ufs_register_clocks()
1870 static int qmp_ufs_parse_dt_legacy(struct qmp_ufs *qmp, struct device_node *np) in qmp_ufs_parse_dt_legacy() argument
1872 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_ufs_parse_dt_legacy()
1873 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_parse_dt_legacy()
1874 struct device *dev = qmp->dev; in qmp_ufs_parse_dt_legacy()
1876 qmp->serdes = devm_platform_ioremap_resource(pdev, 0); in qmp_ufs_parse_dt_legacy()
1877 if (IS_ERR(qmp->serdes)) in qmp_ufs_parse_dt_legacy()
1878 return PTR_ERR(qmp->serdes); in qmp_ufs_parse_dt_legacy()
1886 qmp->tx = devm_of_iomap(dev, np, 0, NULL); in qmp_ufs_parse_dt_legacy()
1887 if (IS_ERR(qmp->tx)) in qmp_ufs_parse_dt_legacy()
1888 return PTR_ERR(qmp->tx); in qmp_ufs_parse_dt_legacy()
1890 qmp->rx = devm_of_iomap(dev, np, 1, NULL); in qmp_ufs_parse_dt_legacy()
1891 if (IS_ERR(qmp->rx)) in qmp_ufs_parse_dt_legacy()
1892 return PTR_ERR(qmp->rx); in qmp_ufs_parse_dt_legacy()
1894 qmp->pcs = devm_of_iomap(dev, np, 2, NULL); in qmp_ufs_parse_dt_legacy()
1895 if (IS_ERR(qmp->pcs)) in qmp_ufs_parse_dt_legacy()
1896 return PTR_ERR(qmp->pcs); in qmp_ufs_parse_dt_legacy()
1899 qmp->tx2 = devm_of_iomap(dev, np, 3, NULL); in qmp_ufs_parse_dt_legacy()
1900 if (IS_ERR(qmp->tx2)) in qmp_ufs_parse_dt_legacy()
1901 return PTR_ERR(qmp->tx2); in qmp_ufs_parse_dt_legacy()
1903 qmp->rx2 = devm_of_iomap(dev, np, 4, NULL); in qmp_ufs_parse_dt_legacy()
1904 if (IS_ERR(qmp->rx2)) in qmp_ufs_parse_dt_legacy()
1905 return PTR_ERR(qmp->rx2); in qmp_ufs_parse_dt_legacy()
1907 qmp->pcs_misc = devm_of_iomap(dev, np, 5, NULL); in qmp_ufs_parse_dt_legacy()
1909 qmp->pcs_misc = devm_of_iomap(dev, np, 3, NULL); in qmp_ufs_parse_dt_legacy()
1912 if (IS_ERR(qmp->pcs_misc)) in qmp_ufs_parse_dt_legacy()
1918 static int qmp_ufs_parse_dt(struct qmp_ufs *qmp) in qmp_ufs_parse_dt() argument
1920 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_ufs_parse_dt()
1921 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_ufs_parse_dt()
1932 qmp->serdes = base + offs->serdes; in qmp_ufs_parse_dt()
1933 qmp->pcs = base + offs->pcs; in qmp_ufs_parse_dt()
1934 qmp->tx = base + offs->tx; in qmp_ufs_parse_dt()
1935 qmp->rx = base + offs->rx; in qmp_ufs_parse_dt()
1938 qmp->tx2 = base + offs->tx2; in qmp_ufs_parse_dt()
1939 qmp->rx2 = base + offs->rx2; in qmp_ufs_parse_dt()
1950 struct qmp_ufs *qmp; in qmp_ufs_probe() local
1953 qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); in qmp_ufs_probe()
1954 if (!qmp) in qmp_ufs_probe()
1957 qmp->dev = dev; in qmp_ufs_probe()
1959 qmp->cfg = of_device_get_match_data(dev); in qmp_ufs_probe()
1960 if (!qmp->cfg) in qmp_ufs_probe()
1963 ret = qmp_ufs_clk_init(qmp); in qmp_ufs_probe()
1967 ret = qmp_ufs_vreg_init(qmp); in qmp_ufs_probe()
1974 ret = qmp_ufs_parse_dt_legacy(qmp, np); in qmp_ufs_probe()
1977 ret = qmp_ufs_parse_dt(qmp); in qmp_ufs_probe()
1982 ret = qmp_ufs_register_clocks(qmp, np); in qmp_ufs_probe()
1986 qmp->phy = devm_phy_create(dev, np, &qcom_qmp_ufs_phy_ops); in qmp_ufs_probe()
1987 if (IS_ERR(qmp->phy)) { in qmp_ufs_probe()
1988 ret = PTR_ERR(qmp->phy); in qmp_ufs_probe()
1993 phy_set_drvdata(qmp->phy, qmp); in qmp_ufs_probe()
2008 .compatible = "qcom,msm8996-qmp-ufs-phy",
2011 .compatible = "qcom,msm8998-qmp-ufs-phy",
2014 .compatible = "qcom,sa8775p-qmp-ufs-phy",
2017 .compatible = "qcom,sc7180-qmp-ufs-phy",
2020 .compatible = "qcom,sc7280-qmp-ufs-phy",
2023 .compatible = "qcom,sc8180x-qmp-ufs-phy",
2026 .compatible = "qcom,sc8280xp-qmp-ufs-phy",
2029 .compatible = "qcom,sdm845-qmp-ufs-phy",
2032 .compatible = "qcom,sm6115-qmp-ufs-phy",
2035 .compatible = "qcom,sm6125-qmp-ufs-phy",
2038 .compatible = "qcom,sm6350-qmp-ufs-phy",
2041 .compatible = "qcom,sm7150-qmp-ufs-phy",
2044 .compatible = "qcom,sm8150-qmp-ufs-phy",
2047 .compatible = "qcom,sm8250-qmp-ufs-phy",
2050 .compatible = "qcom,sm8350-qmp-ufs-phy",
2053 .compatible = "qcom,sm8450-qmp-ufs-phy",
2056 .compatible = "qcom,sm8475-qmp-ufs-phy",
2059 .compatible = "qcom,sm8550-qmp-ufs-phy",
2062 .compatible = "qcom,sm8650-qmp-ufs-phy",
2072 .name = "qcom-qmp-ufs-phy",
2080 MODULE_DESCRIPTION("Qualcomm QMP UFS PHY driver");