Lines Matching +full:rx +full:- +full:pcs

1 // SPDX-License-Identifier: GPL-2.0
7 #include <linux/clk-provider.h>
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"
88 /* set of registers with offsets different per-PHY */
90 /* PCS registers */
1153 u16 pcs; member
1157 u16 rx; member
1163 /* struct qmp_phy_cfg - per-PHY initialization config */
1169 /* Init sequence for PHY blocks - serdes, tx, rx, pcs */
1197 /* Offset from PCS to PCS_USB region */
1207 void __iomem *pcs; member
1211 void __iomem *rx; member
1288 "vdda-phy", "vdda-pll",
1293 .pcs = 0x800,
1296 .rx = 0x400,
1301 .pcs = 0xc00,
1304 .rx = 0x400,
1311 .pcs = 0x0200,
1314 .rx = 0x1000,
1628 if (!(t->lane_mask & lane_mask)) in qmp_usb_configure_lane()
1631 writel(t->val, base + t->offset); in qmp_usb_configure_lane()
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()
1646 const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; in qmp_usb_serdes_init()
1647 int serdes_tbl_num = cfg->serdes_tbl_num; in qmp_usb_serdes_init()
1657 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_init()
1658 void __iomem *pcs = qmp->pcs; in qmp_usb_init() local
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()
1683 qphy_setbits(pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], SW_PWRDN); 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()
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()
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() local
1715 void __iomem *pcs = qmp->pcs; in qmp_usb_power_on() local
1716 void __iomem *pcs_usb = qmp->pcs_usb; 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()
1729 /* Tx, Rx, and PCS configurations */ in qmp_usb_power_on()
1730 qmp_usb_configure_lane(tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); in qmp_usb_power_on()
1731 qmp_usb_configure_lane(rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); in qmp_usb_power_on()
1733 if (cfg->lanes >= 2) { 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()
1738 qmp_usb_configure(pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); in qmp_usb_power_on()
1741 qmp_usb_configure(pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num); in qmp_usb_power_on()
1743 if (cfg->has_pwrdn_delay) in qmp_usb_power_on()
1747 qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_usb_power_on()
1749 /* start SerDes and Phy-Coding-Sublayer */ in qmp_usb_power_on()
1750 qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], SERDES_START | PCS_START); in qmp_usb_power_on()
1752 status = pcs + cfg->regs[QPHY_PCS_STATUS]; 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()
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()
1778 /* stop SerDes and Phy-Coding-Sublayer */ 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()
1818 qmp->mode = mode; in qmp_usb_set_mode()
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()
1844 qphy_setbits(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_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_enable_autonomous_mode()
1848 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], in qmp_usb_enable_autonomous_mode()
1852 qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], intr_mask); in qmp_usb_enable_autonomous_mode()
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()
1869 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], in qmp_usb_disable_autonomous_mode()
1872 qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_disable_autonomous_mode()
1874 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_disable_autonomous_mode()
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()
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()
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()
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()
1935 int num = cfg->num_vregs; 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()
1940 return -ENOMEM; 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()
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()
1958 return -ENOMEM; in qmp_usb_reset_init()
1960 for (i = 0; i < cfg->num_resets; i++) 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()
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()
1974 int num = cfg->num_clks; 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()
1979 return -ENOMEM; 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()
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()
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()
2071 * mappings for PCS. 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()
2080 * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. in qmp_usb_parse_dt_legacy()
2081 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 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 if (cfg->lanes >= 2) { 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()
2114 dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 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()
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()
2131 const struct qmp_usb_offsets *offs = cfg->offsets; in qmp_usb_parse_dt()
2132 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 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()
2149 if (cfg->lanes >= 2) { 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()
2165 struct device *dev = &pdev->dev; in qmp_usb_probe()
2173 return -ENOMEM; in qmp_usb_probe()
2175 qmp->dev = dev; 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()
2180 return -EINVAL; in qmp_usb_probe()
2195 np = of_get_next_available_child(dev->of_node, NULL); in qmp_usb_probe()
2199 np = of_node_get(dev->of_node); 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",