Lines Matching +full:tx +full:- +full:pcs

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 */
36 /* PCS registers */
1245 u16 pcs; member
1248 u16 tx; member
1252 /* struct qmp_phy_cfg - per-PHY initialization config */
1256 /* Init sequence for PHY blocks - serdes, tx, rx, pcs */
1278 /* Offset from PCS to PCS_USB region */
1288 void __iomem *pcs; member
1291 void __iomem *tx; member
1348 "vdda-phy", "vdda-pll",
1353 .pcs = 0x800,
1355 .tx = 0x200,
1361 .pcs = 0x800,
1363 .tx = 0x200,
1369 .pcs = 0x600,
1370 .tx = 0x200,
1376 .pcs = 0x0800,
1378 .tx = 0x0200,
1384 .pcs = 0x0200,
1386 .tx = 0x0e00,
1392 .pcs = 0x0200,
1394 .tx = 0x0e00,
1400 .pcs = 0x0200,
1402 .tx = 0x0e00,
1709 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_serdes_init()
1710 void __iomem *serdes = qmp->serdes; in qmp_usb_serdes_init()
1711 const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; in qmp_usb_serdes_init()
1712 int serdes_tbl_num = cfg->serdes_tbl_num; in qmp_usb_serdes_init()
1714 qmp_configure(qmp->dev, serdes, serdes_tbl, serdes_tbl_num); in qmp_usb_serdes_init()
1722 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_init()
1723 void __iomem *pcs = qmp->pcs; in qmp_usb_init() local
1726 ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); in qmp_usb_init()
1728 dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); in qmp_usb_init()
1732 ret = reset_control_bulk_assert(qmp->num_resets, qmp->resets); in qmp_usb_init()
1734 dev_err(qmp->dev, "reset assert failed\n"); in qmp_usb_init()
1738 ret = reset_control_bulk_deassert(qmp->num_resets, qmp->resets); in qmp_usb_init()
1740 dev_err(qmp->dev, "reset deassert failed\n"); in qmp_usb_init()
1744 ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks); in qmp_usb_init()
1748 qphy_setbits(pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], SW_PWRDN); in qmp_usb_init()
1753 reset_control_bulk_assert(qmp->num_resets, qmp->resets); in qmp_usb_init()
1755 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_usb_init()
1763 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_exit()
1765 reset_control_bulk_assert(qmp->num_resets, qmp->resets); in qmp_usb_exit()
1767 clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); in qmp_usb_exit()
1769 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_usb_exit()
1777 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_power_on()
1778 void __iomem *tx = qmp->tx; in qmp_usb_power_on() local
1779 void __iomem *rx = qmp->rx; in qmp_usb_power_on()
1780 void __iomem *pcs = qmp->pcs; in qmp_usb_power_on() local
1781 void __iomem *pcs_usb = qmp->pcs_usb; in qmp_usb_power_on()
1788 ret = clk_prepare_enable(qmp->pipe_clk); in qmp_usb_power_on()
1790 dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret); in qmp_usb_power_on()
1794 /* Tx, Rx, and PCS configurations */ in qmp_usb_power_on()
1795 qmp_configure_lane(qmp->dev, tx, cfg->tx_tbl, cfg->tx_tbl_num, 1); in qmp_usb_power_on()
1796 qmp_configure_lane(qmp->dev, rx, cfg->rx_tbl, cfg->rx_tbl_num, 1); in qmp_usb_power_on()
1798 qmp_configure(qmp->dev, pcs, cfg->pcs_tbl, cfg->pcs_tbl_num); in qmp_usb_power_on()
1801 qmp_configure(qmp->dev, pcs_usb, cfg->pcs_usb_tbl, cfg->pcs_usb_tbl_num); in qmp_usb_power_on()
1803 if (cfg->has_pwrdn_delay) in qmp_usb_power_on()
1807 qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_usb_power_on()
1809 /* start SerDes and Phy-Coding-Sublayer */ in qmp_usb_power_on()
1810 qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], SERDES_START | PCS_START); in qmp_usb_power_on()
1812 status = pcs + cfg->regs[QPHY_PCS_STATUS]; in qmp_usb_power_on()
1816 dev_err(qmp->dev, "phy initialization timed-out\n"); in qmp_usb_power_on()
1823 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_power_on()
1831 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_power_off()
1833 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_power_off()
1836 qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_usb_power_off()
1838 /* stop SerDes and Phy-Coding-Sublayer */ in qmp_usb_power_off()
1839 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL], in qmp_usb_power_off()
1843 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], in qmp_usb_power_off()
1878 qmp->mode = mode; in qmp_usb_set_mode()
1892 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_enable_autonomous_mode()
1893 void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs; in qmp_usb_enable_autonomous_mode()
1894 void __iomem *pcs_misc = qmp->pcs_misc; in qmp_usb_enable_autonomous_mode()
1897 if (qmp->mode == PHY_MODE_USB_HOST_SS || in qmp_usb_enable_autonomous_mode()
1898 qmp->mode == PHY_MODE_USB_DEVICE_SS) in qmp_usb_enable_autonomous_mode()
1904 qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_enable_autonomous_mode()
1906 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_enable_autonomous_mode()
1908 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], in qmp_usb_enable_autonomous_mode()
1912 qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], intr_mask); in qmp_usb_enable_autonomous_mode()
1915 if (pcs_misc && cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE]) in qmp_usb_enable_autonomous_mode()
1916 qphy_clrbits(pcs_misc, cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE], CLAMP_EN); in qmp_usb_enable_autonomous_mode()
1921 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_disable_autonomous_mode()
1922 void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs; in qmp_usb_disable_autonomous_mode()
1923 void __iomem *pcs_misc = qmp->pcs_misc; in qmp_usb_disable_autonomous_mode()
1926 if (pcs_misc && cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE]) in qmp_usb_disable_autonomous_mode()
1927 qphy_setbits(pcs_misc, cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE], CLAMP_EN); in qmp_usb_disable_autonomous_mode()
1929 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], in qmp_usb_disable_autonomous_mode()
1932 qphy_setbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_disable_autonomous_mode()
1934 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); in qmp_usb_disable_autonomous_mode()
1941 dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode); in qmp_usb_runtime_suspend()
1943 if (!qmp->phy->init_count) { in qmp_usb_runtime_suspend()
1950 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_runtime_suspend()
1951 clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); in qmp_usb_runtime_suspend()
1961 dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode); in qmp_usb_runtime_resume()
1963 if (!qmp->phy->init_count) { in qmp_usb_runtime_resume()
1968 ret = clk_bulk_prepare_enable(qmp->num_clks, qmp->clks); in qmp_usb_runtime_resume()
1972 ret = clk_prepare_enable(qmp->pipe_clk); in qmp_usb_runtime_resume()
1975 clk_bulk_disable_unprepare(qmp->num_clks, qmp->clks); in qmp_usb_runtime_resume()
1991 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_vreg_init()
1992 struct device *dev = qmp->dev; in qmp_usb_vreg_init()
1993 int num = cfg->num_vregs; in qmp_usb_vreg_init()
1996 qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); in qmp_usb_vreg_init()
1997 if (!qmp->vregs) in qmp_usb_vreg_init()
1998 return -ENOMEM; in qmp_usb_vreg_init()
2001 qmp->vregs[i].supply = cfg->vreg_list[i]; in qmp_usb_vreg_init()
2003 return devm_regulator_bulk_get(dev, num, qmp->vregs); in qmp_usb_vreg_init()
2010 struct device *dev = qmp->dev; in qmp_usb_reset_init()
2014 qmp->resets = devm_kcalloc(dev, num_resets, in qmp_usb_reset_init()
2015 sizeof(*qmp->resets), GFP_KERNEL); in qmp_usb_reset_init()
2016 if (!qmp->resets) in qmp_usb_reset_init()
2017 return -ENOMEM; in qmp_usb_reset_init()
2020 qmp->resets[i].id = reset_list[i]; in qmp_usb_reset_init()
2022 qmp->num_resets = num_resets; in qmp_usb_reset_init()
2024 ret = devm_reset_control_bulk_get_exclusive(dev, num_resets, qmp->resets); in qmp_usb_reset_init()
2033 struct device *dev = qmp->dev; in qmp_usb_clk_init()
2037 qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); in qmp_usb_clk_init()
2038 if (!qmp->clks) in qmp_usb_clk_init()
2039 return -ENOMEM; in qmp_usb_clk_init()
2042 qmp->clks[i].id = qmp_usb_phy_clk_l[i]; in qmp_usb_clk_init()
2044 qmp->num_clks = num; in qmp_usb_clk_init()
2046 return devm_clk_bulk_get_optional(dev, num, qmp->clks); in qmp_usb_clk_init()
2064 * +---------------+
2065 * | PHY block |<<---------------------------------------+
2067 * | +-------+ | +-----+ |
2068 * I/P---^-->| PLL |---^--->pipe_clksrc--->| GCC |--->pipe_clk---+
2069 * clk | +-------+ | +-----+
2070 * +---------------+
2074 struct clk_fixed_rate *fixed = &qmp->pipe_clk_fixed; in phy_pipe_clk_register()
2078 ret = of_property_read_string(np, "clock-output-names", &init.name); in phy_pipe_clk_register()
2080 dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); in phy_pipe_clk_register()
2087 fixed->fixed_rate = 125000000; in phy_pipe_clk_register()
2088 fixed->hw.init = &init; in phy_pipe_clk_register()
2090 ret = devm_clk_hw_register(qmp->dev, &fixed->hw); in phy_pipe_clk_register()
2094 ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &fixed->hw); in phy_pipe_clk_register()
2102 return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); in phy_pipe_clk_register()
2112 return IOMEM_ERR_PTR(-EINVAL); in qmp_usb_iomap()
2122 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_usb_parse_dt_legacy()
2123 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_parse_dt_legacy()
2124 struct device *dev = qmp->dev; in qmp_usb_parse_dt_legacy()
2128 qmp->serdes = devm_platform_ioremap_resource(pdev, 0); in qmp_usb_parse_dt_legacy()
2129 if (IS_ERR(qmp->serdes)) in qmp_usb_parse_dt_legacy()
2130 return PTR_ERR(qmp->serdes); in qmp_usb_parse_dt_legacy()
2134 * mappings for PCS. in qmp_usb_parse_dt_legacy()
2136 if (of_device_is_compatible(dev->of_node, "qcom,sdx65-qmp-usb3-uni-phy")) in qmp_usb_parse_dt_legacy()
2138 if (of_device_is_compatible(dev->of_node, "qcom,sm8350-qmp-usb3-uni-phy")) in qmp_usb_parse_dt_legacy()
2143 * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. in qmp_usb_parse_dt_legacy()
2144 * For single lane PHYs: pcs_misc (optional) -> 3. in qmp_usb_parse_dt_legacy()
2146 qmp->tx = devm_of_iomap(dev, np, 0, NULL); in qmp_usb_parse_dt_legacy()
2147 if (IS_ERR(qmp->tx)) in qmp_usb_parse_dt_legacy()
2148 return PTR_ERR(qmp->tx); in qmp_usb_parse_dt_legacy()
2150 qmp->rx = devm_of_iomap(dev, np, 1, NULL); in qmp_usb_parse_dt_legacy()
2151 if (IS_ERR(qmp->rx)) in qmp_usb_parse_dt_legacy()
2152 return PTR_ERR(qmp->rx); in qmp_usb_parse_dt_legacy()
2154 qmp->pcs = qmp_usb_iomap(dev, np, 2, exclusive); in qmp_usb_parse_dt_legacy()
2155 if (IS_ERR(qmp->pcs)) in qmp_usb_parse_dt_legacy()
2156 return PTR_ERR(qmp->pcs); in qmp_usb_parse_dt_legacy()
2158 if (cfg->pcs_usb_offset) in qmp_usb_parse_dt_legacy()
2159 qmp->pcs_usb = qmp->pcs + cfg->pcs_usb_offset; in qmp_usb_parse_dt_legacy()
2161 qmp->pcs_misc = devm_of_iomap(dev, np, 3, NULL); in qmp_usb_parse_dt_legacy()
2163 if (IS_ERR(qmp->pcs_misc)) { in qmp_usb_parse_dt_legacy()
2164 dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); in qmp_usb_parse_dt_legacy()
2165 qmp->pcs_misc = NULL; in qmp_usb_parse_dt_legacy()
2168 qmp->pipe_clk = devm_get_clk_from_child(dev, np, NULL); in qmp_usb_parse_dt_legacy()
2169 if (IS_ERR(qmp->pipe_clk)) { in qmp_usb_parse_dt_legacy()
2170 return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk), in qmp_usb_parse_dt_legacy()
2174 ret = devm_clk_bulk_get_all(qmp->dev, &qmp->clks); in qmp_usb_parse_dt_legacy()
2178 qmp->num_clks = ret; in qmp_usb_parse_dt_legacy()
2190 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_usb_parse_dt()
2191 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_parse_dt()
2192 const struct qmp_usb_offsets *offs = cfg->offsets; in qmp_usb_parse_dt()
2193 struct device *dev = qmp->dev; in qmp_usb_parse_dt()
2198 return -EINVAL; in qmp_usb_parse_dt()
2204 qmp->serdes = base + offs->serdes; in qmp_usb_parse_dt()
2205 qmp->pcs = base + offs->pcs; in qmp_usb_parse_dt()
2206 if (offs->pcs_usb) in qmp_usb_parse_dt()
2207 qmp->pcs_usb = base + offs->pcs_usb; in qmp_usb_parse_dt()
2208 if (offs->pcs_misc) in qmp_usb_parse_dt()
2209 qmp->pcs_misc = base + offs->pcs_misc; in qmp_usb_parse_dt()
2210 qmp->tx = base + offs->tx; in qmp_usb_parse_dt()
2211 qmp->rx = base + offs->rx; in qmp_usb_parse_dt()
2217 qmp->pipe_clk = devm_clk_get(dev, "pipe"); in qmp_usb_parse_dt()
2218 if (IS_ERR(qmp->pipe_clk)) { in qmp_usb_parse_dt()
2219 return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk), in qmp_usb_parse_dt()
2233 struct device *dev = &pdev->dev; in qmp_usb_probe()
2241 return -ENOMEM; in qmp_usb_probe()
2243 qmp->dev = dev; in qmp_usb_probe()
2246 qmp->cfg = of_device_get_match_data(dev); in qmp_usb_probe()
2247 if (!qmp->cfg) in qmp_usb_probe()
2248 return -EINVAL; in qmp_usb_probe()
2255 np = of_get_next_available_child(dev->of_node, NULL); in qmp_usb_probe()
2259 np = of_node_get(dev->of_node); in qmp_usb_probe()
2279 qmp->phy = devm_phy_create(dev, np, &qmp_usb_phy_ops); in qmp_usb_probe()
2280 if (IS_ERR(qmp->phy)) { in qmp_usb_probe()
2281 ret = PTR_ERR(qmp->phy); in qmp_usb_probe()
2286 phy_set_drvdata(qmp->phy, qmp); in qmp_usb_probe()
2301 .compatible = "qcom,ipq6018-qmp-usb3-phy",
2304 .compatible = "qcom,ipq8074-qmp-usb3-phy",
2307 .compatible = "qcom,ipq9574-qmp-usb3-phy",
2310 .compatible = "qcom,msm8996-qmp-usb3-phy",
2313 .compatible = "qcom,qcs8300-qmp-usb3-uni-phy",
2316 .compatible = "qcom,qdu1000-qmp-usb3-uni-phy",
2319 .compatible = "qcom,sa8775p-qmp-usb3-uni-phy",
2322 .compatible = "qcom,sc8180x-qmp-usb3-uni-phy",
2325 .compatible = "qcom,sc8280xp-qmp-usb3-uni-phy",
2328 .compatible = "qcom,sdm845-qmp-usb3-uni-phy",
2331 .compatible = "qcom,sdx55-qmp-usb3-uni-phy",
2334 .compatible = "qcom,sdx65-qmp-usb3-uni-phy",
2337 .compatible = "qcom,sdx75-qmp-usb3-uni-phy",
2340 .compatible = "qcom,sm8150-qmp-usb3-uni-phy",
2343 .compatible = "qcom,sm8250-qmp-usb3-uni-phy",
2346 .compatible = "qcom,sm8350-qmp-usb3-uni-phy",
2349 .compatible = "qcom,x1e80100-qmp-usb3-uni-phy",
2359 .name = "qcom-qmp-usb-phy",