Lines Matching full:qmp
22 #include "phy-qcom-qmp-common.h"
24 #include "phy-qcom-qmp.h"
25 #include "phy-qcom-qmp-pcs-misc-v3.h"
26 #include "phy-qcom-qmp-pcs-misc-v4.h"
27 #include "phy-qcom-qmp-pcs-usb-v4.h"
28 #include "phy-qcom-qmp-pcs-usb-v5.h"
29 #include "phy-qcom-qmp-pcs-usb-v6.h"
30 #include "phy-qcom-qmp-pcs-usb-v7.h"
1645 static int qmp_usb_serdes_init(struct qmp_usb *qmp) in qmp_usb_serdes_init() argument
1647 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_serdes_init()
1648 void __iomem *serdes = qmp->serdes; in qmp_usb_serdes_init()
1652 qmp_configure(qmp->dev, serdes, serdes_tbl, serdes_tbl_num); in qmp_usb_serdes_init()
1659 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_init() local
1660 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_init()
1661 void __iomem *pcs = qmp->pcs; in qmp_usb_init()
1664 ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); in qmp_usb_init()
1666 dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); in qmp_usb_init()
1670 ret = reset_control_bulk_assert(qmp->num_resets, qmp->resets); in qmp_usb_init()
1672 dev_err(qmp->dev, "reset assert failed\n"); in qmp_usb_init()
1676 ret = reset_control_bulk_deassert(qmp->num_resets, qmp->resets); in qmp_usb_init()
1678 dev_err(qmp->dev, "reset deassert failed\n"); in qmp_usb_init()
1682 ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks); in qmp_usb_init()
1691 reset_control_bulk_assert(qmp->num_resets, qmp->resets); in qmp_usb_init()
1693 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_usb_init()
1700 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_exit() local
1701 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_exit()
1703 reset_control_bulk_assert(qmp->num_resets, qmp->resets); in qmp_usb_exit()
1705 clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); in qmp_usb_exit()
1707 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_usb_exit()
1714 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_power_on() local
1715 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_power_on()
1716 void __iomem *tx = qmp->tx; in qmp_usb_power_on()
1717 void __iomem *rx = qmp->rx; in qmp_usb_power_on()
1718 void __iomem *pcs = qmp->pcs; in qmp_usb_power_on()
1719 void __iomem *pcs_usb = qmp->pcs_usb; in qmp_usb_power_on()
1724 qmp_usb_serdes_init(qmp); in qmp_usb_power_on()
1726 ret = clk_prepare_enable(qmp->pipe_clk); in qmp_usb_power_on()
1728 dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret); in qmp_usb_power_on()
1733 qmp_configure_lane(qmp->dev, tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); in qmp_usb_power_on()
1734 qmp_configure_lane(qmp->dev, rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); in qmp_usb_power_on()
1736 qmp_configure(qmp->dev, pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); in qmp_usb_power_on()
1739 qmp_configure(qmp->dev, pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num); in qmp_usb_power_on()
1754 dev_err(qmp->dev, "phy initialization timed-out\n"); in qmp_usb_power_on()
1761 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_power_on()
1768 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_power_off() local
1769 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_power_off()
1771 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_power_off()
1774 qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_usb_power_off()
1777 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL], in qmp_usb_power_off()
1781 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], in qmp_usb_power_off()
1814 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_set_mode() local
1816 qmp->mode = mode; in qmp_usb_set_mode()
1828 static void qmp_usb_enable_autonomous_mode(struct qmp_usb *qmp) in qmp_usb_enable_autonomous_mode() argument
1830 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_enable_autonomous_mode()
1831 void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs; in qmp_usb_enable_autonomous_mode()
1832 void __iomem *pcs_misc = qmp->pcs_misc; in qmp_usb_enable_autonomous_mode()
1835 if (qmp->mode == PHY_MODE_USB_HOST_SS || in qmp_usb_enable_autonomous_mode()
1836 qmp->mode == PHY_MODE_USB_DEVICE_SS) in qmp_usb_enable_autonomous_mode()
1857 static void qmp_usb_disable_autonomous_mode(struct qmp_usb *qmp) in qmp_usb_disable_autonomous_mode() argument
1859 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_disable_autonomous_mode()
1860 void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs; in qmp_usb_disable_autonomous_mode()
1861 void __iomem *pcs_misc = qmp->pcs_misc; in qmp_usb_disable_autonomous_mode()
1877 struct qmp_usb *qmp = dev_get_drvdata(dev); in qmp_usb_runtime_suspend() local
1879 dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode); in qmp_usb_runtime_suspend()
1881 if (!qmp->phy->init_count) { in qmp_usb_runtime_suspend()
1886 qmp_usb_enable_autonomous_mode(qmp); in qmp_usb_runtime_suspend()
1888 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_runtime_suspend()
1889 clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); in qmp_usb_runtime_suspend()
1896 struct qmp_usb *qmp = dev_get_drvdata(dev); in qmp_usb_runtime_resume() local
1899 dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode); in qmp_usb_runtime_resume()
1901 if (!qmp->phy->init_count) { in qmp_usb_runtime_resume()
1906 ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks); in qmp_usb_runtime_resume()
1910 ret = clk_prepare_enable(qmp->pipe_clk); in qmp_usb_runtime_resume()
1913 clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); in qmp_usb_runtime_resume()
1917 qmp_usb_disable_autonomous_mode(qmp); in qmp_usb_runtime_resume()
1927 static int qmp_usb_vreg_init(struct qmp_usb *qmp) in qmp_usb_vreg_init() argument
1929 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_vreg_init()
1930 struct device *dev = qmp->dev; in qmp_usb_vreg_init()
1934 qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); in qmp_usb_vreg_init()
1935 if (!qmp->vregs) in qmp_usb_vreg_init()
1939 qmp->vregs[i].supply = cfg->vreg_list[i]; in qmp_usb_vreg_init()
1941 return devm_regulator_bulk_get(dev, num, qmp->vregs); in qmp_usb_vreg_init()
1944 static int qmp_usb_reset_init(struct qmp_usb *qmp, in qmp_usb_reset_init() argument
1948 struct device *dev = qmp->dev; in qmp_usb_reset_init()
1952 qmp->resets = devm_kcalloc(dev, num_resets, in qmp_usb_reset_init()
1953 sizeof(*qmp->resets), GFP_KERNEL); in qmp_usb_reset_init()
1954 if (!qmp->resets) in qmp_usb_reset_init()
1958 qmp->resets[i].id = reset_list[i]; in qmp_usb_reset_init()
1960 qmp->num_resets = num_resets; in qmp_usb_reset_init()
1962 ret = devm_reset_control_bulk_get_exclusive(dev, num_resets, qmp->resets); in qmp_usb_reset_init()
1969 static int qmp_usb_clk_init(struct qmp_usb *qmp) in qmp_usb_clk_init() argument
1971 struct device *dev = qmp->dev; in qmp_usb_clk_init()
1975 qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); in qmp_usb_clk_init()
1976 if (!qmp->clks) in qmp_usb_clk_init()
1980 qmp->clks[i].id = qmp_usb_phy_clk_l[i]; in qmp_usb_clk_init()
1982 qmp->num_clks = num; in qmp_usb_clk_init()
1984 return devm_clk_bulk_get_optional(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()
2066 qmp->serdes = devm_platform_ioremap_resource(pdev, 0); in qmp_usb_parse_dt_legacy()
2067 if (IS_ERR(qmp->serdes)) in qmp_usb_parse_dt_legacy()
2068 return PTR_ERR(qmp->serdes); in qmp_usb_parse_dt_legacy()
2074 if (of_device_is_compatible(dev->of_node, "qcom,sdx65-qmp-usb3-uni-phy")) in qmp_usb_parse_dt_legacy()
2076 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()
2099 qmp->pcs_misc = devm_of_iomap(dev, np, 3, NULL); in qmp_usb_parse_dt_legacy()
2101 if (IS_ERR(qmp->pcs_misc)) { in qmp_usb_parse_dt_legacy()
2103 qmp->pcs_misc = NULL; in qmp_usb_parse_dt_legacy()
2106 qmp->pipe_clk = devm_get_clk_from_child(dev, np, NULL); in qmp_usb_parse_dt_legacy()
2107 if (IS_ERR(qmp->pipe_clk)) { in qmp_usb_parse_dt_legacy()
2108 return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk), in qmp_usb_parse_dt_legacy()
2112 ret = devm_clk_bulk_get_all(qmp->dev, &qmp->clks); in qmp_usb_parse_dt_legacy()
2116 qmp->num_clks = ret; in qmp_usb_parse_dt_legacy()
2118 ret = qmp_usb_reset_init(qmp, usb3phy_legacy_reset_l, in qmp_usb_parse_dt_legacy()
2126 static int qmp_usb_parse_dt(struct qmp_usb *qmp) in qmp_usb_parse_dt() argument
2128 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_usb_parse_dt()
2129 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_parse_dt()
2131 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()
2145 qmp->pcs_usb = base + offs->pcs_usb; in qmp_usb_parse_dt()
2147 qmp->pcs_misc = base + offs->pcs_misc; in qmp_usb_parse_dt()
2148 qmp->tx = base + offs->tx; in qmp_usb_parse_dt()
2149 qmp->rx = base + offs->rx; in qmp_usb_parse_dt()
2151 ret = qmp_usb_clk_init(qmp); in qmp_usb_parse_dt()
2155 qmp->pipe_clk = devm_clk_get(dev, "pipe"); in qmp_usb_parse_dt()
2156 if (IS_ERR(qmp->pipe_clk)) { in qmp_usb_parse_dt()
2157 return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk), in qmp_usb_parse_dt()
2161 ret = qmp_usb_reset_init(qmp, usb3phy_reset_l, in qmp_usb_parse_dt()
2174 struct qmp_usb *qmp; in qmp_usb_probe() local
2177 qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); in qmp_usb_probe()
2178 if (!qmp) in qmp_usb_probe()
2181 qmp->dev = dev; in qmp_usb_probe()
2182 dev_set_drvdata(dev, qmp); in qmp_usb_probe()
2184 qmp->cfg = of_device_get_match_data(dev); in qmp_usb_probe()
2185 if (!qmp->cfg) in qmp_usb_probe()
2188 ret = qmp_usb_vreg_init(qmp); in qmp_usb_probe()
2195 ret = qmp_usb_parse_dt_legacy(qmp, np); in qmp_usb_probe()
2198 ret = qmp_usb_parse_dt(qmp); in qmp_usb_probe()
2213 ret = phy_pipe_clk_register(qmp, np); in qmp_usb_probe()
2217 qmp->phy = devm_phy_create(dev, np, &qmp_usb_phy_ops); in qmp_usb_probe()
2218 if (IS_ERR(qmp->phy)) { in qmp_usb_probe()
2219 ret = PTR_ERR(qmp->phy); in qmp_usb_probe()
2224 phy_set_drvdata(qmp->phy, qmp); in qmp_usb_probe()
2239 .compatible = "qcom,ipq6018-qmp-usb3-phy",
2242 .compatible = "qcom,ipq8074-qmp-usb3-phy",
2245 .compatible = "qcom,ipq9574-qmp-usb3-phy",
2248 .compatible = "qcom,msm8996-qmp-usb3-phy",
2251 .compatible = "qcom,qdu1000-qmp-usb3-uni-phy",
2254 .compatible = "qcom,sa8775p-qmp-usb3-uni-phy",
2257 .compatible = "qcom,sc8180x-qmp-usb3-uni-phy",
2260 .compatible = "qcom,sc8280xp-qmp-usb3-uni-phy",
2263 .compatible = "qcom,sdm845-qmp-usb3-uni-phy",
2266 .compatible = "qcom,sdx55-qmp-usb3-uni-phy",
2269 .compatible = "qcom,sdx65-qmp-usb3-uni-phy",
2272 .compatible = "qcom,sdx75-qmp-usb3-uni-phy",
2275 .compatible = "qcom,sm8150-qmp-usb3-uni-phy",
2278 .compatible = "qcom,sm8250-qmp-usb3-uni-phy",
2281 .compatible = "qcom,sm8350-qmp-usb3-uni-phy",
2284 .compatible = "qcom,x1e80100-qmp-usb3-uni-phy",
2294 .name = "qcom-qmp-usb-phy",
2303 MODULE_DESCRIPTION("Qualcomm QMP USB PHY driver");