Lines Matching +full:qdu1000 +full:- +full:gcc

1 // SPDX-License-Identifier: GPL-2.0
7 #include <linux/clk-provider.h>
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"
34 /* set of registers with offsets different per-PHY */
1208 /* struct qmp_phy_cfg - per-PHY initialization config */
1212 /* Init sequence for PHY blocks - serdes, tx, rx, pcs */
1304 "vdda-phy", "vdda-pll",
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()
1649 const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; in qmp_usb_serdes_init()
1650 int serdes_tbl_num = cfg->serdes_tbl_num; in qmp_usb_serdes_init()
1652 qmp_configure(qmp->dev, serdes, serdes_tbl, serdes_tbl_num); in qmp_usb_serdes_init()
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()
1686 qphy_setbits(pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], SW_PWRDN); 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()
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()
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()
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()
1741 if (cfg->has_pwrdn_delay) in qmp_usb_power_on()
1745 qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_usb_power_on()
1747 /* start SerDes and Phy-Coding-Sublayer */ in qmp_usb_power_on()
1748 qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], SERDES_START | PCS_START); in qmp_usb_power_on()
1750 status = pcs + cfg->regs[QPHY_PCS_STATUS]; 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()
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()
1776 /* stop SerDes and Phy-Coding-Sublayer */ 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()
1816 qmp->mode = mode; in qmp_usb_set_mode()
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()
1842 qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_enable_autonomous_mode()
1844 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_enable_autonomous_mode()
1846 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], in qmp_usb_enable_autonomous_mode()
1850 qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], intr_mask); in qmp_usb_enable_autonomous_mode()
1853 if (pcs_misc && cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE]) in qmp_usb_enable_autonomous_mode()
1854 qphy_clrbits(pcs_misc, cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE], CLAMP_EN); in qmp_usb_enable_autonomous_mode()
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()
1864 if (pcs_misc && cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE]) in qmp_usb_disable_autonomous_mode()
1865 qphy_setbits(pcs_misc, cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE], CLAMP_EN); in qmp_usb_disable_autonomous_mode()
1867 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], in qmp_usb_disable_autonomous_mode()
1870 qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_disable_autonomous_mode()
1872 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_disable_autonomous_mode()
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()
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()
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()
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()
1931 int num = cfg->num_vregs; 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()
1936 return -ENOMEM; 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()
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()
1955 return -ENOMEM; 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()
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()
1977 return -ENOMEM; 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()
1995 * The <s>_pipe_clksrc generated by PHY goes to the GCC that gate
1996 * controls it. The <s>_pipe_clk coming out of the GCC is requested
1998 * We register the <s>_pipe_clksrc here. The gcc driver takes care
2002 * +---------------+
2003 * | PHY block |<<---------------------------------------+
2005 * | +-------+ | +-----+ |
2006 * I/P---^-->| PLL |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+
2007 * clk | +-------+ | +-----+
2008 * +---------------+
2012 struct clk_fixed_rate *fixed = &qmp->pipe_clk_fixed; in phy_pipe_clk_register()
2016 ret = of_property_read_string(np, "clock-output-names", &init.name); in phy_pipe_clk_register()
2018 dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); in phy_pipe_clk_register()
2025 fixed->fixed_rate = 125000000; in phy_pipe_clk_register()
2026 fixed->hw.init = &init; in phy_pipe_clk_register()
2028 ret = devm_clk_hw_register(qmp->dev, &fixed->hw); in phy_pipe_clk_register()
2032 ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &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()
2050 return IOMEM_ERR_PTR(-EINVAL); in qmp_usb_iomap()
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()
2081 * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. in qmp_usb_parse_dt_legacy()
2082 * For single lane PHYs: pcs_misc (optional) -> 3. 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()
2096 if (cfg->pcs_usb_offset) 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()
2102 dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 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()
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()
2130 const struct qmp_usb_offsets *offs = cfg->offsets; in qmp_usb_parse_dt()
2131 struct device *dev = qmp->dev; in qmp_usb_parse_dt()
2136 return -EINVAL; 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 if (offs->pcs_usb) in qmp_usb_parse_dt()
2145 qmp->pcs_usb = base + offs->pcs_usb; in qmp_usb_parse_dt()
2146 if (offs->pcs_misc) 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()
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()
2171 struct device *dev = &pdev->dev; in qmp_usb_probe()
2179 return -ENOMEM; in qmp_usb_probe()
2181 qmp->dev = dev; 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()
2186 return -EINVAL; in qmp_usb_probe()
2193 np = of_get_next_available_child(dev->of_node, NULL); in qmp_usb_probe()
2197 np = of_node_get(dev->of_node); 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",