Lines Matching full:qmp
22 #include "phy-qcom-qmp.h"
23 #include "phy-qcom-qmp-pcs-misc-v3.h"
24 #include "phy-qcom-qmp-pcs-usb-v4.h"
25 #include "phy-qcom-qmp-pcs-usb-v5.h"
1642 static int qmp_usb_serdes_init(struct qmp_usb *qmp) in qmp_usb_serdes_init() argument
1644 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_serdes_init()
1645 void __iomem *serdes = qmp->serdes; in qmp_usb_serdes_init()
1656 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_init() local
1657 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_init()
1658 void __iomem *pcs = qmp->pcs; in qmp_usb_init()
1661 ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); in qmp_usb_init()
1663 dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); in qmp_usb_init()
1667 ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets); in qmp_usb_init()
1669 dev_err(qmp->dev, "reset assert failed\n"); in qmp_usb_init()
1673 ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets); in qmp_usb_init()
1675 dev_err(qmp->dev, "reset deassert failed\n"); in qmp_usb_init()
1679 ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); in qmp_usb_init()
1688 reset_control_bulk_assert(cfg->num_resets, qmp->resets); in qmp_usb_init()
1690 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_usb_init()
1697 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_exit() local
1698 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_exit()
1700 reset_control_bulk_assert(cfg->num_resets, qmp->resets); in qmp_usb_exit()
1702 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); in qmp_usb_exit()
1704 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_usb_exit()
1711 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_power_on() local
1712 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_power_on()
1713 void __iomem *tx = qmp->tx; in qmp_usb_power_on()
1714 void __iomem *rx = qmp->rx; in qmp_usb_power_on()
1715 void __iomem *pcs = qmp->pcs; in qmp_usb_power_on()
1716 void __iomem *pcs_usb = qmp->pcs_usb; in qmp_usb_power_on()
1721 qmp_usb_serdes_init(qmp); in qmp_usb_power_on()
1723 ret = clk_prepare_enable(qmp->pipe_clk); in qmp_usb_power_on()
1725 dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret); in qmp_usb_power_on()
1734 qmp_usb_configure_lane(qmp->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2); in qmp_usb_power_on()
1735 qmp_usb_configure_lane(qmp->rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2); in qmp_usb_power_on()
1756 dev_err(qmp->dev, "phy initialization timed-out\n"); in qmp_usb_power_on()
1763 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_power_on()
1770 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_power_off() local
1771 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_power_off()
1773 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_power_off()
1776 qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_usb_power_off()
1779 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL], in qmp_usb_power_off()
1783 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], in qmp_usb_power_off()
1816 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_set_mode() local
1818 qmp->mode = mode; in qmp_usb_set_mode()
1830 static void qmp_usb_enable_autonomous_mode(struct qmp_usb *qmp) in qmp_usb_enable_autonomous_mode() argument
1832 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_enable_autonomous_mode()
1833 void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs; in qmp_usb_enable_autonomous_mode()
1834 void __iomem *pcs_misc = qmp->pcs_misc; in qmp_usb_enable_autonomous_mode()
1837 if (qmp->mode == PHY_MODE_USB_HOST_SS || in qmp_usb_enable_autonomous_mode()
1838 qmp->mode == PHY_MODE_USB_DEVICE_SS) in qmp_usb_enable_autonomous_mode()
1859 static void qmp_usb_disable_autonomous_mode(struct qmp_usb *qmp) in qmp_usb_disable_autonomous_mode() argument
1861 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_disable_autonomous_mode()
1862 void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs; in qmp_usb_disable_autonomous_mode()
1863 void __iomem *pcs_misc = qmp->pcs_misc; in qmp_usb_disable_autonomous_mode()
1879 struct qmp_usb *qmp = dev_get_drvdata(dev); in qmp_usb_runtime_suspend() local
1880 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_runtime_suspend()
1882 dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode); in qmp_usb_runtime_suspend()
1884 if (!qmp->phy->init_count) { in qmp_usb_runtime_suspend()
1889 qmp_usb_enable_autonomous_mode(qmp); in qmp_usb_runtime_suspend()
1891 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_runtime_suspend()
1892 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); in qmp_usb_runtime_suspend()
1899 struct qmp_usb *qmp = dev_get_drvdata(dev); in qmp_usb_runtime_resume() local
1900 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_runtime_resume()
1903 dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode); in qmp_usb_runtime_resume()
1905 if (!qmp->phy->init_count) { in qmp_usb_runtime_resume()
1910 ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); in qmp_usb_runtime_resume()
1914 ret = clk_prepare_enable(qmp->pipe_clk); in qmp_usb_runtime_resume()
1917 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); in qmp_usb_runtime_resume()
1921 qmp_usb_disable_autonomous_mode(qmp); in qmp_usb_runtime_resume()
1931 static int qmp_usb_vreg_init(struct qmp_usb *qmp) in qmp_usb_vreg_init() argument
1933 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_vreg_init()
1934 struct device *dev = qmp->dev; in qmp_usb_vreg_init()
1938 qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); in qmp_usb_vreg_init()
1939 if (!qmp->vregs) in qmp_usb_vreg_init()
1943 qmp->vregs[i].supply = cfg->vreg_list[i]; in qmp_usb_vreg_init()
1945 return devm_regulator_bulk_get(dev, num, qmp->vregs); in qmp_usb_vreg_init()
1948 static int qmp_usb_reset_init(struct qmp_usb *qmp) in qmp_usb_reset_init() argument
1950 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_reset_init()
1951 struct device *dev = qmp->dev; in qmp_usb_reset_init()
1955 qmp->resets = devm_kcalloc(dev, cfg->num_resets, in qmp_usb_reset_init()
1956 sizeof(*qmp->resets), GFP_KERNEL); in qmp_usb_reset_init()
1957 if (!qmp->resets) in qmp_usb_reset_init()
1961 qmp->resets[i].id = cfg->reset_list[i]; in qmp_usb_reset_init()
1963 ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets); in qmp_usb_reset_init()
1970 static int qmp_usb_clk_init(struct qmp_usb *qmp) in qmp_usb_clk_init() argument
1972 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_clk_init()
1973 struct device *dev = qmp->dev; in qmp_usb_clk_init()
1977 qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); in qmp_usb_clk_init()
1978 if (!qmp->clks) in qmp_usb_clk_init()
1982 qmp->clks[i].id = cfg->clk_list[i]; in qmp_usb_clk_init()
1984 return devm_clk_bulk_get(dev, num, qmp->clks); in qmp_usb_clk_init()
2010 static int phy_pipe_clk_register(struct qmp_usb *qmp, struct device_node *np) in phy_pipe_clk_register() argument
2012 struct clk_fixed_rate *fixed = &qmp->pipe_clk_fixed; in phy_pipe_clk_register()
2018 dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); in phy_pipe_clk_register()
2024 /* controllers using QMP phys use 125MHz pipe clock interface */ in phy_pipe_clk_register()
2028 ret = devm_clk_hw_register(qmp->dev, &fixed->hw); in phy_pipe_clk_register()
2040 return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); in phy_pipe_clk_register()
2058 static int qmp_usb_parse_dt_legacy(struct qmp_usb *qmp, struct device_node *np) in qmp_usb_parse_dt_legacy() argument
2060 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_usb_parse_dt_legacy()
2061 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_parse_dt_legacy()
2062 struct device *dev = qmp->dev; in qmp_usb_parse_dt_legacy()
2065 qmp->serdes = devm_platform_ioremap_resource(pdev, 0); in qmp_usb_parse_dt_legacy()
2066 if (IS_ERR(qmp->serdes)) in qmp_usb_parse_dt_legacy()
2067 return PTR_ERR(qmp->serdes); in qmp_usb_parse_dt_legacy()
2073 if (of_device_is_compatible(dev->of_node, "qcom,sdx65-qmp-usb3-uni-phy")) in qmp_usb_parse_dt_legacy()
2075 if (of_device_is_compatible(dev->of_node, "qcom,sm8350-qmp-usb3-uni-phy")) in qmp_usb_parse_dt_legacy()
2084 qmp->tx = devm_of_iomap(dev, np, 0, NULL); in qmp_usb_parse_dt_legacy()
2085 if (IS_ERR(qmp->tx)) in qmp_usb_parse_dt_legacy()
2086 return PTR_ERR(qmp->tx); in qmp_usb_parse_dt_legacy()
2088 qmp->rx = devm_of_iomap(dev, np, 1, NULL); in qmp_usb_parse_dt_legacy()
2089 if (IS_ERR(qmp->rx)) in qmp_usb_parse_dt_legacy()
2090 return PTR_ERR(qmp->rx); in qmp_usb_parse_dt_legacy()
2092 qmp->pcs = qmp_usb_iomap(dev, np, 2, exclusive); in qmp_usb_parse_dt_legacy()
2093 if (IS_ERR(qmp->pcs)) in qmp_usb_parse_dt_legacy()
2094 return PTR_ERR(qmp->pcs); in qmp_usb_parse_dt_legacy()
2097 qmp->pcs_usb = qmp->pcs + cfg->pcs_usb_offset; in qmp_usb_parse_dt_legacy()
2100 qmp->tx2 = devm_of_iomap(dev, np, 3, NULL); in qmp_usb_parse_dt_legacy()
2101 if (IS_ERR(qmp->tx2)) in qmp_usb_parse_dt_legacy()
2102 return PTR_ERR(qmp->tx2); in qmp_usb_parse_dt_legacy()
2104 qmp->rx2 = devm_of_iomap(dev, np, 4, NULL); in qmp_usb_parse_dt_legacy()
2105 if (IS_ERR(qmp->rx2)) in qmp_usb_parse_dt_legacy()
2106 return PTR_ERR(qmp->rx2); in qmp_usb_parse_dt_legacy()
2108 qmp->pcs_misc = devm_of_iomap(dev, np, 5, NULL); in qmp_usb_parse_dt_legacy()
2110 qmp->pcs_misc = devm_of_iomap(dev, np, 3, NULL); in qmp_usb_parse_dt_legacy()
2113 if (IS_ERR(qmp->pcs_misc)) { in qmp_usb_parse_dt_legacy()
2115 qmp->pcs_misc = NULL; in qmp_usb_parse_dt_legacy()
2118 qmp->pipe_clk = devm_get_clk_from_child(dev, np, NULL); in qmp_usb_parse_dt_legacy()
2119 if (IS_ERR(qmp->pipe_clk)) { in qmp_usb_parse_dt_legacy()
2120 return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk), in qmp_usb_parse_dt_legacy()
2127 static int qmp_usb_parse_dt(struct qmp_usb *qmp) in qmp_usb_parse_dt() argument
2129 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_usb_parse_dt()
2130 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_parse_dt()
2132 struct device *dev = qmp->dev; in qmp_usb_parse_dt()
2142 qmp->serdes = base + offs->serdes; in qmp_usb_parse_dt()
2143 qmp->pcs = base + offs->pcs; in qmp_usb_parse_dt()
2144 qmp->pcs_misc = base + offs->pcs_misc; in qmp_usb_parse_dt()
2145 qmp->pcs_usb = base + offs->pcs_usb; in qmp_usb_parse_dt()
2146 qmp->tx = base + offs->tx; in qmp_usb_parse_dt()
2147 qmp->rx = base + offs->rx; in qmp_usb_parse_dt()
2150 qmp->tx2 = base + offs->tx2; in qmp_usb_parse_dt()
2151 qmp->rx2 = base + offs->rx2; in qmp_usb_parse_dt()
2154 qmp->pipe_clk = devm_clk_get(dev, "pipe"); in qmp_usb_parse_dt()
2155 if (IS_ERR(qmp->pipe_clk)) { in qmp_usb_parse_dt()
2156 return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk), in qmp_usb_parse_dt()
2168 struct qmp_usb *qmp; in qmp_usb_probe() local
2171 qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); in qmp_usb_probe()
2172 if (!qmp) in qmp_usb_probe()
2175 qmp->dev = dev; in qmp_usb_probe()
2176 dev_set_drvdata(dev, qmp); in qmp_usb_probe()
2178 qmp->cfg = of_device_get_match_data(dev); in qmp_usb_probe()
2179 if (!qmp->cfg) in qmp_usb_probe()
2182 ret = qmp_usb_clk_init(qmp); in qmp_usb_probe()
2186 ret = qmp_usb_reset_init(qmp); in qmp_usb_probe()
2190 ret = qmp_usb_vreg_init(qmp); in qmp_usb_probe()
2197 ret = qmp_usb_parse_dt_legacy(qmp, np); in qmp_usb_probe()
2200 ret = qmp_usb_parse_dt(qmp); in qmp_usb_probe()
2215 ret = phy_pipe_clk_register(qmp, np); in qmp_usb_probe()
2219 qmp->phy = devm_phy_create(dev, np, &qmp_usb_phy_ops); in qmp_usb_probe()
2220 if (IS_ERR(qmp->phy)) { in qmp_usb_probe()
2221 ret = PTR_ERR(qmp->phy); in qmp_usb_probe()
2226 phy_set_drvdata(qmp->phy, qmp); in qmp_usb_probe()
2241 .compatible = "qcom,ipq6018-qmp-usb3-phy",
2244 .compatible = "qcom,ipq8074-qmp-usb3-phy",
2247 .compatible = "qcom,ipq9574-qmp-usb3-phy",
2250 .compatible = "qcom,msm8996-qmp-usb3-phy",
2253 .compatible = "qcom,msm8998-qmp-usb3-phy",
2256 .compatible = "qcom,qcm2290-qmp-usb3-phy",
2259 .compatible = "qcom,sa8775p-qmp-usb3-uni-phy",
2262 .compatible = "qcom,sc8280xp-qmp-usb3-uni-phy",
2265 .compatible = "qcom,sdm845-qmp-usb3-uni-phy",
2268 .compatible = "qcom,sdx55-qmp-usb3-uni-phy",
2271 .compatible = "qcom,sdx65-qmp-usb3-uni-phy",
2274 .compatible = "qcom,sm6115-qmp-usb3-phy",
2277 .compatible = "qcom,sm8150-qmp-usb3-uni-phy",
2280 .compatible = "qcom,sm8250-qmp-usb3-uni-phy",
2283 .compatible = "qcom,sm8350-qmp-usb3-uni-phy",
2293 .name = "qcom-qmp-usb-phy",
2302 MODULE_DESCRIPTION("Qualcomm QMP USB PHY driver");