Lines Matching +full:pll0 +full:- +full:refclk
1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <dt-bindings/phy/phy.h>
365 u32 offset = reg << ctx->reg_offset_shift; in cdns_regmap_write()
367 writew(val, ctx->base + offset); in cdns_regmap_write()
375 u32 offset = reg << ctx->reg_offset_shift; in cdns_regmap_read()
377 *val = readw(ctx->base + offset); in cdns_regmap_read()
387 writel(val, ctx->base + offset); in cdns_regmap_dptx_write()
398 *val = readl(ctx->base + offset); in cdns_regmap_dptx_read()
497 * Structure used to store values of PHY registers for voltage-related
498 * coefficients, for particular voltage swing and pre-emphasis level. Values
511 * Array consists of values of voltage-related registers for sd0801 PHY. A value
515 /* voltage swing 0, pre-emphasis 0->3 */
526 /* voltage swing 1, pre-emphasis 0->3 */
537 /* voltage swing 2, pre-emphasis 0->3 */
548 /* voltage swing 3, pre-emphasis 0->3 */
569 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_pll_en()
582 switch (dp->lanes) { in cdns_torrent_dp_set_pll_en()
587 /* lanes 0-1 */ in cdns_torrent_dp_set_pll_en()
591 /* lanes 0-3, all */ in cdns_torrent_dp_set_pll_en()
624 /* Disable the cmn_pll0_en before re-programming the new data rate. */ in cdns_torrent_dp_configure_rate()
625 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x0); in cdns_torrent_dp_configure_rate()
628 * Wait for PLL ready de-assertion. in cdns_torrent_dp_configure_rate()
629 * For PLL0 - PHY_PMA_CMN_CTRL2[2] == 1 in cdns_torrent_dp_configure_rate()
631 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
639 /* DP Rate Change - VCO Output settings. */ in cdns_torrent_dp_configure_rate()
640 if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz) { in cdns_torrent_dp_configure_rate()
642 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, in cdns_torrent_dp_configure_rate()
643 dp->ssc); in cdns_torrent_dp_configure_rate()
645 } else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz) { in cdns_torrent_dp_configure_rate()
647 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, in cdns_torrent_dp_configure_rate()
648 dp->ssc); in cdns_torrent_dp_configure_rate()
651 cdns_torrent_dp_pma_cmn_rate(cdns_phy, dp->link_rate, dp->lanes); in cdns_torrent_dp_configure_rate()
654 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x3); in cdns_torrent_dp_configure_rate()
658 * For PLL0 - PHY_PMA_CMN_CTRL2[0] == 1 in cdns_torrent_dp_configure_rate()
660 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
676 if (dp->set_rate) { in cdns_torrent_dp_verify_config()
677 switch (dp->link_rate) { in cdns_torrent_dp_verify_config()
689 return -EINVAL; in cdns_torrent_dp_verify_config()
694 switch (dp->lanes) { in cdns_torrent_dp_verify_config()
701 return -EINVAL; in cdns_torrent_dp_verify_config()
705 if (dp->lanes > inst->num_lanes) in cdns_torrent_dp_verify_config()
706 return -EINVAL; in cdns_torrent_dp_verify_config()
709 * If changing voltages is required, check swing and pre-emphasis in cdns_torrent_dp_verify_config()
710 * levels, per-lane. in cdns_torrent_dp_verify_config()
712 if (dp->set_voltages) { in cdns_torrent_dp_verify_config()
714 for (i = 0; i < dp->lanes; i++) { in cdns_torrent_dp_verify_config()
715 if (dp->voltage[i] > 3 || dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
716 return -EINVAL; in cdns_torrent_dp_verify_config()
718 /* Sum of voltage swing and pre-emphasis levels cannot in cdns_torrent_dp_verify_config()
721 if (dp->voltage[i] + dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
722 return -EINVAL; in cdns_torrent_dp_verify_config()
733 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_a0_pll()
771 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_lanes()
772 u8 lane_mask = (1 << dp->lanes) - 1; in cdns_torrent_dp_set_lanes()
788 * and powered down when re-enabling the link in cdns_torrent_dp_set_lanes()
793 cdns_torrent_dp_set_a0_pll(cdns_phy, dp->lanes); in cdns_torrent_dp_set_lanes()
809 ret = cdns_torrent_dp_run(cdns_phy, dp->lanes); in cdns_torrent_dp_set_lanes()
820 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
837 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
841 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
850 /* Configure voltage swing and pre-emphasis for all enabled lanes. */
857 for (lane = 0; lane < dp->lanes; lane++) { in cdns_torrent_dp_set_voltages()
858 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
865 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
868 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
870 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].diag_tx_drv; in cdns_torrent_dp_set_voltages()
871 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
873 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].mgnfs_mult; in cdns_torrent_dp_set_voltages()
874 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
877 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].cpost_mult; in cdns_torrent_dp_set_voltages()
878 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
882 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
889 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
898 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_configure()
901 ret = cdns_torrent_dp_verify_config(inst, &opts->dp); in cdns_torrent_dp_configure()
903 dev_err(&phy->dev, "invalid params for phy configure\n"); in cdns_torrent_dp_configure()
907 if (opts->dp.set_lanes) { in cdns_torrent_dp_configure()
908 ret = cdns_torrent_dp_set_lanes(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
910 dev_err(&phy->dev, "cdns_torrent_dp_set_lanes failed\n"); in cdns_torrent_dp_configure()
915 if (opts->dp.set_rate) { in cdns_torrent_dp_configure()
916 ret = cdns_torrent_dp_set_rate(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
918 dev_err(&phy->dev, "cdns_torrent_dp_set_rate failed\n"); in cdns_torrent_dp_configure()
923 if (opts->dp.set_voltages) in cdns_torrent_dp_configure()
924 cdns_torrent_dp_set_voltages(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
934 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_init()
935 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_init()
937 switch (cdns_phy->ref_clk_rate) { in cdns_torrent_dp_init()
943 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_init()
944 return -EINVAL; in cdns_torrent_dp_init()
956 cdns_torrent_dp_set_a0_pll(cdns_phy, inst->num_lanes); in cdns_torrent_dp_init()
962 lane_bits = (1 << inst->num_lanes) - 1; in cdns_torrent_dp_init()
971 if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz) in cdns_torrent_dp_init()
973 cdns_phy->max_bit_rate, in cdns_torrent_dp_init()
975 else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz) in cdns_torrent_dp_init()
977 cdns_phy->max_bit_rate, in cdns_torrent_dp_init()
979 cdns_torrent_dp_pma_cmn_rate(cdns_phy, cdns_phy->max_bit_rate, in cdns_torrent_dp_init()
980 inst->num_lanes); in cdns_torrent_dp_init()
983 regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1); in cdns_torrent_dp_init()
991 ret = cdns_torrent_dp_run(cdns_phy, inst->num_lanes); in cdns_torrent_dp_init()
1001 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_wait_pma_cmn_ready()
1005 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_wait_pma_cmn_ready()
1006 dev_err(cdns_phy->dev, in cdns_torrent_dp_wait_pma_cmn_ready()
1008 return -ETIMEDOUT; in cdns_torrent_dp_wait_pma_cmn_ready()
1019 if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz) in cdns_torrent_dp_pma_cfg()
1022 else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz) in cdns_torrent_dp_pma_cfg()
1026 /* PMA lane configuration to deal with multi-link operation */ in cdns_torrent_dp_pma_cfg()
1027 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_pma_cfg()
1034 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_cfg_19_2mhz()
1036 /* refclock registers - assumes 19.2 MHz refclock */ in cdns_torrent_dp_pma_cmn_cfg_19_2mhz()
1083 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_19_2mhz()
1099 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
1259 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_cfg_25mhz()
1261 /* refclock registers - assumes 25 MHz refclock */ in cdns_torrent_dp_pma_cmn_cfg_25mhz()
1307 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_25mhz()
1323 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
1431 regmap_field_write(cdns_phy->phy_pll_cfg, 0x0); in cdns_torrent_dp_pma_cmn_rate()
1459 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1461 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1464 /* PMA lane configuration to deal with multi-link operation */ in cdns_torrent_dp_pma_cmn_rate()
1466 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[i], in cdns_torrent_dp_pma_cmn_rate()
1473 /* Per lane, refclock-dependent receiver detection setting */ in cdns_torrent_dp_pma_lane_cfg()
1474 if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz) in cdns_torrent_dp_pma_lane_cfg()
1475 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1477 else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz) in cdns_torrent_dp_pma_lane_cfg()
1478 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1482 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1484 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1486 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1488 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1490 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1492 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1495 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1498 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1500 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1502 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1505 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1507 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1509 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1523 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_power_state()
1547 /* lanes 0-1 */ in cdns_torrent_dp_set_power_state()
1553 /* lanes 0-3, all */ in cdns_torrent_dp_set_power_state()
1579 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_run()
1588 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_run()
1589 dev_err(cdns_phy->dev, in cdns_torrent_dp_run()
1610 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_on()
1614 if (cdns_phy->nsubnodes == 1) { in cdns_torrent_phy_on()
1616 reset_control_deassert(inst->lnk_rst); in cdns_torrent_phy_on()
1619 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_on()
1628 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1, in cdns_torrent_phy_on()
1632 dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n"); in cdns_torrent_phy_on()
1644 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_off()
1647 if (cdns_phy->nsubnodes != 1) in cdns_torrent_phy_off()
1650 ret = reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_off()
1654 return reset_control_assert(inst->lnk_rst); in cdns_torrent_phy_off()
1666 return ERR_PTR(-ENOMEM); in cdns_regmap_init()
1668 ctx->dev = dev; in cdns_regmap_init()
1669 ctx->base = base + block_offset; in cdns_regmap_init()
1670 ctx->reg_offset_shift = reg_offset_shift; in cdns_regmap_init()
1677 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regfield_init()
1681 regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_regfield_init()
1687 cdns_phy->phy_reset_ctrl = field; in cdns_torrent_dp_regfield_init()
1694 struct device *dev = cdns_phy->dev; in cdns_torrent_regfield_init()
1698 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
1704 cdns_phy->phy_pll_cfg = field; in cdns_torrent_regfield_init()
1706 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
1712 cdns_phy->phy_pma_cmn_ctrl_1 = field; in cdns_torrent_regfield_init()
1714 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
1720 cdns_phy->phy_pma_cmn_ctrl_2 = field; in cdns_torrent_regfield_init()
1722 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
1728 cdns_phy->phy_pma_pll_raw_ctrl = field; in cdns_torrent_regfield_init()
1735 void __iomem *base = cdns_phy->base; in cdns_torrent_dp_regmap_init()
1736 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regmap_init()
1741 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_dp_regmap_init()
1751 cdns_phy->regmap_dptx_phy_reg = regmap; in cdns_torrent_dp_regmap_init()
1758 void __iomem *sd_base = cdns_phy->sd_base; in cdns_torrent_regmap_init()
1760 struct device *dev = cdns_phy->dev; in cdns_torrent_regmap_init()
1765 block_offset_shift = cdns_phy->init_data->block_offset_shift; in cdns_torrent_regmap_init()
1766 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_regmap_init()
1778 cdns_phy->regmap_tx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
1789 cdns_phy->regmap_rx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
1800 cdns_phy->regmap_common_cdb = regmap; in cdns_torrent_regmap_init()
1810 cdns_phy->regmap_phy_pcs_common_cdb = regmap; in cdns_torrent_regmap_init()
1820 cdns_phy->regmap_phy_pma_common_cdb = regmap; in cdns_torrent_regmap_init()
1827 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_init()
1828 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_init()
1832 enum cdns_torrent_phy_type phy_type = inst->phy_type; in cdns_torrent_phy_init()
1833 enum cdns_torrent_ssc_mode ssc = inst->ssc_mode; in cdns_torrent_phy_init()
1840 if (cdns_phy->nsubnodes > 1) in cdns_torrent_phy_init()
1854 link_cmn_vals = init_data->link_cmn_vals[phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1856 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
1857 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_init()
1858 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
1864 regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val); in cdns_torrent_phy_init()
1871 xcvr_diag_vals = init_data->xcvr_diag_vals[phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1873 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_init()
1874 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_init()
1875 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
1876 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
1884 pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1886 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
1887 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_init()
1888 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_init()
1895 cmn_vals = init_data->cmn_vals[phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1897 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_init()
1898 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_init()
1899 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
1906 tx_ln_vals = init_data->tx_ln_vals[phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1908 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
1909 num_regs = tx_ln_vals->num_regs; in cdns_torrent_phy_init()
1910 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
1911 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
1919 rx_ln_vals = init_data->rx_ln_vals[phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1921 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
1922 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_init()
1923 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
1924 regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
1937 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_configure_multilink()
1949 if (cdns_phy->nsubnodes != 2) in cdns_torrent_phy_configure_multilink()
1950 return -EINVAL; in cdns_torrent_phy_configure_multilink()
1952 phy_t1 = cdns_phy->phys[0].phy_type; in cdns_torrent_phy_configure_multilink()
1953 phy_t2 = cdns_phy->phys[1].phy_type; in cdns_torrent_phy_configure_multilink()
1959 for (node = 0; node < cdns_phy->nsubnodes; node++) { in cdns_torrent_phy_configure_multilink()
1971 mlane = cdns_phy->phys[node].mlane; in cdns_torrent_phy_configure_multilink()
1972 ssc = cdns_phy->phys[node].ssc_mode; in cdns_torrent_phy_configure_multilink()
1973 num_lanes = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_configure_multilink()
1985 link_cmn_vals = init_data->link_cmn_vals[phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
1987 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
1988 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
1989 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
1995 regmap_field_write(cdns_phy->phy_pll_cfg, in cdns_torrent_phy_configure_multilink()
2003 xcvr_diag_vals = init_data->xcvr_diag_vals[phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2005 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2006 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2008 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2016 pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2018 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2019 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2020 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_configure_multilink()
2027 cmn_vals = init_data->cmn_vals[phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2029 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2030 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2031 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2038 tx_ln_vals = init_data->tx_ln_vals[phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2040 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2041 num_regs = tx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2043 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2051 rx_ln_vals = init_data->rx_ln_vals[phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2053 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2054 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2056 regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2063 reset_control_deassert(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_configure_multilink()
2067 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_configure_multilink()
2077 struct device *dev = &pdev->dev; in cdns_torrent_phy_probe()
2089 return -EINVAL; in cdns_torrent_phy_probe()
2093 return -ENOMEM; in cdns_torrent_phy_probe()
2096 cdns_phy->dev = dev; in cdns_torrent_phy_probe()
2097 cdns_phy->init_data = data; in cdns_torrent_phy_probe()
2099 cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0); in cdns_torrent_phy_probe()
2100 if (IS_ERR(cdns_phy->phy_rst)) { in cdns_torrent_phy_probe()
2102 dev->of_node->full_name); in cdns_torrent_phy_probe()
2103 return PTR_ERR(cdns_phy->phy_rst); in cdns_torrent_phy_probe()
2106 cdns_phy->apb_rst = devm_reset_control_get_optional(dev, "torrent_apb"); in cdns_torrent_phy_probe()
2107 if (IS_ERR(cdns_phy->apb_rst)) { in cdns_torrent_phy_probe()
2109 dev->of_node->full_name); in cdns_torrent_phy_probe()
2110 return PTR_ERR(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2113 cdns_phy->clk = devm_clk_get(dev, "refclk"); in cdns_torrent_phy_probe()
2114 if (IS_ERR(cdns_phy->clk)) { in cdns_torrent_phy_probe()
2116 return PTR_ERR(cdns_phy->clk); in cdns_torrent_phy_probe()
2119 cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0); in cdns_torrent_phy_probe()
2120 if (IS_ERR(cdns_phy->sd_base)) in cdns_torrent_phy_probe()
2121 return PTR_ERR(cdns_phy->sd_base); in cdns_torrent_phy_probe()
2123 subnodes = of_get_available_child_count(dev->of_node); in cdns_torrent_phy_probe()
2126 return -EINVAL; in cdns_torrent_phy_probe()
2137 ret = clk_prepare_enable(cdns_phy->clk); in cdns_torrent_phy_probe()
2139 dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); in cdns_torrent_phy_probe()
2143 cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk); in cdns_torrent_phy_probe()
2144 if (!(cdns_phy->ref_clk_rate)) { in cdns_torrent_phy_probe()
2145 dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); in cdns_torrent_phy_probe()
2146 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_probe()
2147 return -EINVAL; in cdns_torrent_phy_probe()
2151 reset_control_deassert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2153 for_each_available_child_of_node(dev->of_node, child) { in cdns_torrent_phy_probe()
2160 cdns_phy->phys[node].lnk_rst = in cdns_torrent_phy_probe()
2162 if (IS_ERR(cdns_phy->phys[node].lnk_rst)) { in cdns_torrent_phy_probe()
2164 child->full_name); in cdns_torrent_phy_probe()
2165 ret = PTR_ERR(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_probe()
2170 &cdns_phy->phys[node].mlane)) { in cdns_torrent_phy_probe()
2171 dev_err(dev, "%s: No \"reg\"-property.\n", in cdns_torrent_phy_probe()
2172 child->full_name); in cdns_torrent_phy_probe()
2173 ret = -EINVAL; in cdns_torrent_phy_probe()
2177 if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) { in cdns_torrent_phy_probe()
2178 dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n", in cdns_torrent_phy_probe()
2179 child->full_name); in cdns_torrent_phy_probe()
2180 ret = -EINVAL; in cdns_torrent_phy_probe()
2186 cdns_phy->phys[node].phy_type = TYPE_PCIE; in cdns_torrent_phy_probe()
2189 cdns_phy->phys[node].phy_type = TYPE_DP; in cdns_torrent_phy_probe()
2192 cdns_phy->phys[node].phy_type = TYPE_SGMII; in cdns_torrent_phy_probe()
2195 cdns_phy->phys[node].phy_type = TYPE_QSGMII; in cdns_torrent_phy_probe()
2198 cdns_phy->phys[node].phy_type = TYPE_USB; in cdns_torrent_phy_probe()
2202 ret = -EINVAL; in cdns_torrent_phy_probe()
2206 if (of_property_read_u32(child, "cdns,num-lanes", in cdns_torrent_phy_probe()
2207 &cdns_phy->phys[node].num_lanes)) { in cdns_torrent_phy_probe()
2208 dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n", in cdns_torrent_phy_probe()
2209 child->full_name); in cdns_torrent_phy_probe()
2210 ret = -EINVAL; in cdns_torrent_phy_probe()
2214 total_num_lanes += cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2217 cdns_phy->phys[node].ssc_mode = NO_SSC; in cdns_torrent_phy_probe()
2218 of_property_read_u32(child, "cdns,ssc-mode", in cdns_torrent_phy_probe()
2219 &cdns_phy->phys[node].ssc_mode); in cdns_torrent_phy_probe()
2227 if (cdns_phy->phys[node].phy_type == TYPE_DP) { in cdns_torrent_phy_probe()
2228 switch (cdns_phy->phys[node].num_lanes) { in cdns_torrent_phy_probe()
2236 cdns_phy->phys[node].num_lanes); in cdns_torrent_phy_probe()
2237 ret = -EINVAL; in cdns_torrent_phy_probe()
2241 cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE; in cdns_torrent_phy_probe()
2242 of_property_read_u32(child, "cdns,max-bit-rate", in cdns_torrent_phy_probe()
2243 &cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2245 switch (cdns_phy->max_bit_rate) { in cdns_torrent_phy_probe()
2258 cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2259 ret = -EINVAL; in cdns_torrent_phy_probe()
2264 cdns_phy->base = devm_platform_ioremap_resource(pdev, 1); in cdns_torrent_phy_probe()
2265 if (IS_ERR(cdns_phy->base)) { in cdns_torrent_phy_probe()
2266 ret = PTR_ERR(cdns_phy->base); in cdns_torrent_phy_probe()
2283 cdns_phy->phys[node].num_lanes, in cdns_torrent_phy_probe()
2284 cdns_phy->max_bit_rate / 1000, in cdns_torrent_phy_probe()
2285 cdns_phy->max_bit_rate % 1000); in cdns_torrent_phy_probe()
2287 gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2288 gphy->attrs.max_link_rate = cdns_phy->max_bit_rate; in cdns_torrent_phy_probe()
2289 gphy->attrs.mode = PHY_MODE_DP; in cdns_torrent_phy_probe()
2292 cdns_phy->phys[node].phy = gphy; in cdns_torrent_phy_probe()
2293 phy_set_drvdata(gphy, &cdns_phy->phys[node]); in cdns_torrent_phy_probe()
2297 cdns_phy->nsubnodes = node; in cdns_torrent_phy_probe()
2304 if (cdns_phy->nsubnodes > 1) { in cdns_torrent_phy_probe()
2322 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_probe()
2324 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2325 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_probe()
2334 reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_remove()
2335 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_remove()
2336 for (i = 0; i < cdns_phy->nsubnodes; i++) { in cdns_torrent_phy_remove()
2337 reset_control_assert(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
2338 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
2341 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_remove()
3838 .compatible = "cdns,torrent-phy",
3842 .compatible = "ti,j721e-serdes-10g",
3853 .name = "cdns-torrent-phy",