Lines Matching +full:enable +full:- +full:ssc
1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <dt-bindings/phy/phy.h>
10 #include <dt-bindings/phy/phy-cadence.h>
12 #include <linux/clk-provider.h>
239 [CDNS_TORRENT_REFCLK_DRIVER] = "refclk-driver",
393 u32 offset = reg << ctx->reg_offset_shift; in cdns_regmap_write()
395 writew(val, ctx->base + offset); in cdns_regmap_write()
403 u32 offset = reg << ctx->reg_offset_shift; in cdns_regmap_read()
405 *val = readw(ctx->base + offset); in cdns_regmap_read()
415 writel(val, ctx->base + offset); in cdns_regmap_dptx_write()
426 *val = readl(ctx->base + offset); in cdns_regmap_dptx_read()
541 * Structure used to store values of PHY registers for voltage-related
542 * coefficients, for particular voltage swing and pre-emphasis level. Values
555 * Array consists of values of voltage-related registers for sd0801 PHY. A value
559 /* voltage swing 0, pre-emphasis 0->3 */
570 /* voltage swing 1, pre-emphasis 0->3 */
581 /* voltage swing 2, pre-emphasis 0->3 */
592 /* voltage swing 3, pre-emphasis 0->3 */
623 * Set registers responsible for enabling and configuring SSC, with second and
630 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_19_2mhz()
644 u32 rate, bool ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz() argument
646 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
663 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
680 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
696 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
711 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
716 if (ssc) { in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
724 /* Set reset register values to disable SSC */ in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
744 * Set registers responsible for enabling and configuring SSC, with second
750 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_25mhz()
764 u32 rate, bool ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz() argument
766 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
781 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
796 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
810 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
823 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
831 if (ssc) { in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
845 /* Set reset register values to disable SSC */ in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
868 u32 rate, bool ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz() argument
870 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
950 * Enable or disable PLL for selected lanes.
954 bool enable) in cdns_torrent_dp_set_pll_en() argument
958 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_pll_en()
961 * Used to determine, which bits to check for or enable in in cdns_torrent_dp_set_pll_en()
965 /* Used to enable or disable lanes. */ in cdns_torrent_dp_set_pll_en()
971 switch (dp->lanes) { in cdns_torrent_dp_set_pll_en()
976 /* lanes 0-1 */ in cdns_torrent_dp_set_pll_en()
980 /* lanes 0-3, all */ in cdns_torrent_dp_set_pll_en()
986 if (enable) in cdns_torrent_dp_set_pll_en()
1013 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_power_state()
1037 /* lanes 0-1 */ in cdns_torrent_dp_set_power_state()
1043 /* lanes 0-3, all */ in cdns_torrent_dp_set_power_state()
1069 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_run()
1078 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_run()
1079 dev_err(cdns_phy->dev, in cdns_torrent_dp_run()
1080 "timeout waiting for link PLL clock enable ack\n"); in cdns_torrent_dp_run()
1101 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_wait_pma_cmn_ready()
1105 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_wait_pma_cmn_ready()
1106 dev_err(cdns_phy->dev, in cdns_torrent_dp_wait_pma_cmn_ready()
1108 return -ETIMEDOUT; in cdns_torrent_dp_wait_pma_cmn_ready()
1147 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1149 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1152 /* PMA lane configuration to deal with multi-link operation */ in cdns_torrent_dp_pma_cmn_rate()
1154 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[i], in cdns_torrent_dp_pma_cmn_rate()
1167 /* Disable the cmn_pll0_en before re-programming the new data rate. */ in cdns_torrent_dp_configure_rate()
1168 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x0); in cdns_torrent_dp_configure_rate()
1171 * Wait for PLL ready de-assertion. in cdns_torrent_dp_configure_rate()
1172 * For PLL0 - PHY_PMA_CMN_CTRL2[2] == 1 in cdns_torrent_dp_configure_rate()
1174 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1182 /* DP Rate Change - VCO Output settings. */ in cdns_torrent_dp_configure_rate()
1183 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_configure_rate()
1185 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1186 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_configure_rate()
1188 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1189 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_configure_rate()
1191 cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1193 cdns_torrent_dp_pma_cmn_rate(cdns_phy, dp->link_rate, dp->lanes); in cdns_torrent_dp_configure_rate()
1195 /* Enable the cmn_pll0_en. */ in cdns_torrent_dp_configure_rate()
1196 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x3); in cdns_torrent_dp_configure_rate()
1200 * For PLL0 - PHY_PMA_CMN_CTRL2[0] == 1 in cdns_torrent_dp_configure_rate()
1202 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1218 if (dp->set_rate) { in cdns_torrent_dp_verify_config()
1219 switch (dp->link_rate) { in cdns_torrent_dp_verify_config()
1231 return -EINVAL; in cdns_torrent_dp_verify_config()
1236 switch (dp->lanes) { in cdns_torrent_dp_verify_config()
1243 return -EINVAL; in cdns_torrent_dp_verify_config()
1247 if (dp->lanes > inst->num_lanes) in cdns_torrent_dp_verify_config()
1248 return -EINVAL; in cdns_torrent_dp_verify_config()
1251 * If changing voltages is required, check swing and pre-emphasis in cdns_torrent_dp_verify_config()
1252 * levels, per-lane. in cdns_torrent_dp_verify_config()
1254 if (dp->set_voltages) { in cdns_torrent_dp_verify_config()
1256 for (i = 0; i < dp->lanes; i++) { in cdns_torrent_dp_verify_config()
1257 if (dp->voltage[i] > 3 || dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
1258 return -EINVAL; in cdns_torrent_dp_verify_config()
1260 /* Sum of voltage swing and pre-emphasis levels cannot in cdns_torrent_dp_verify_config()
1263 if (dp->voltage[i] + dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
1264 return -EINVAL; in cdns_torrent_dp_verify_config()
1271 /* Set power state A0 and PLL clock enable to 0 on enabled lanes. */
1275 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_a0_pll()
1313 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_lanes()
1314 u8 lane_mask = (1 << dp->lanes) - 1; in cdns_torrent_dp_set_lanes()
1330 * and powered down when re-enabling the link in cdns_torrent_dp_set_lanes()
1335 cdns_torrent_dp_set_a0_pll(cdns_phy, dp->lanes); in cdns_torrent_dp_set_lanes()
1351 ret = cdns_torrent_dp_run(cdns_phy, dp->lanes); in cdns_torrent_dp_set_lanes()
1362 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
1379 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
1383 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
1392 /* Configure voltage swing and pre-emphasis for all enabled lanes. */
1399 for (lane = 0; lane < dp->lanes; lane++) { in cdns_torrent_dp_set_voltages()
1400 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1407 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1410 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1412 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].diag_tx_drv; in cdns_torrent_dp_set_voltages()
1413 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1415 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].mgnfs_mult; in cdns_torrent_dp_set_voltages()
1416 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1419 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].cpost_mult; in cdns_torrent_dp_set_voltages()
1420 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1424 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1431 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1440 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_configure()
1443 ret = cdns_torrent_dp_verify_config(inst, &opts->dp); in cdns_torrent_dp_configure()
1445 dev_err(&phy->dev, "invalid params for phy configure\n"); in cdns_torrent_dp_configure()
1449 if (opts->dp.set_lanes) { in cdns_torrent_dp_configure()
1450 ret = cdns_torrent_dp_set_lanes(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
1452 dev_err(&phy->dev, "cdns_torrent_dp_set_lanes failed\n"); in cdns_torrent_dp_configure()
1457 if (opts->dp.set_rate) { in cdns_torrent_dp_configure()
1458 ret = cdns_torrent_dp_set_rate(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
1460 dev_err(&phy->dev, "cdns_torrent_dp_set_rate failed\n"); in cdns_torrent_dp_configure()
1465 if (opts->dp.set_voltages) in cdns_torrent_dp_configure()
1466 cdns_torrent_dp_set_voltages(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
1474 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_on()
1478 if (cdns_phy->nsubnodes == 1) { in cdns_torrent_phy_on()
1480 reset_control_deassert(inst->lnk_rst); in cdns_torrent_phy_on()
1483 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_on()
1492 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1, in cdns_torrent_phy_on()
1496 dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n"); in cdns_torrent_phy_on()
1500 if (inst->phy_type == TYPE_PCIE || inst->phy_type == TYPE_USB) { in cdns_torrent_phy_on()
1501 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pcs_iso_link_ctrl_1[inst->mlane], in cdns_torrent_phy_on()
1504 if (ret == -ETIMEDOUT) { in cdns_torrent_phy_on()
1505 dev_err(cdns_phy->dev, "Timeout waiting for PHY status ready\n"); in cdns_torrent_phy_on()
1516 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_off()
1519 if (cdns_phy->nsubnodes != 1) in cdns_torrent_phy_off()
1522 ret = reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_off()
1526 return reset_control_assert(inst->lnk_rst); in cdns_torrent_phy_off()
1532 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_common_init()
1535 cdns_torrent_dp_write(regmap, PHY_AUX_CTRL, 0x0003); /* enable AUX */ in cdns_torrent_dp_common_init()
1539 * Set lines pll clk enable to 0 in cdns_torrent_dp_common_init()
1541 cdns_torrent_dp_set_a0_pll(cdns_phy, inst->num_lanes); in cdns_torrent_dp_common_init()
1547 lane_bits = (1 << inst->num_lanes) - 1; in cdns_torrent_dp_common_init()
1556 * Initialize PHY with max supported link rate, without SSC. in cdns_torrent_dp_common_init()
1558 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_common_init()
1560 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1562 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_common_init()
1564 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1566 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_common_init()
1568 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1571 cdns_torrent_dp_pma_cmn_rate(cdns_phy, cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1572 inst->num_lanes); in cdns_torrent_dp_common_init()
1575 regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1); in cdns_torrent_dp_common_init()
1590 ret = cdns_torrent_dp_run(cdns_phy, inst->num_lanes); in cdns_torrent_dp_start()
1598 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_init()
1600 switch (cdns_phy->ref_clk_rate) { in cdns_torrent_dp_init()
1607 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_init()
1608 return -EINVAL; in cdns_torrent_dp_init()
1620 regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_6], 0); in cdns_torrent_derived_refclk_enable()
1621 regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], 1); in cdns_torrent_derived_refclk_enable()
1622 regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_5], 1); in cdns_torrent_derived_refclk_enable()
1623 regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 0); in cdns_torrent_derived_refclk_enable()
1624 regmap_field_write(derived_refclk->cmn_fields[CMN_CDIAG_REFCLK_OVRD_4], 1); in cdns_torrent_derived_refclk_enable()
1625 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 1); in cdns_torrent_derived_refclk_enable()
1634 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 0); in cdns_torrent_derived_refclk_disable()
1642 regmap_field_read(derived_refclk->phy_pipe_cmn_ctrl1_0, &val); in cdns_torrent_derived_refclk_is_enabled()
1648 .enable = cdns_torrent_derived_refclk_enable,
1656 struct device *dev = cdns_phy->dev; in cdns_torrent_derived_refclk_register()
1667 return -ENOMEM; in cdns_torrent_derived_refclk_register()
1678 init = &derived_refclk->clk_data; in cdns_torrent_derived_refclk_register()
1682 init->parent_names = &parent_name; in cdns_torrent_derived_refclk_register()
1683 init->num_parents = 1; in cdns_torrent_derived_refclk_register()
1685 init->ops = &cdns_torrent_derived_refclk_ops; in cdns_torrent_derived_refclk_register()
1686 init->flags = 0; in cdns_torrent_derived_refclk_register()
1687 init->name = clk_name; in cdns_torrent_derived_refclk_register()
1689 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_derived_refclk_register()
1695 derived_refclk->phy_pipe_cmn_ctrl1_0 = field; in cdns_torrent_derived_refclk_register()
1697 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_derived_refclk_register()
1704 derived_refclk->cmn_fields[i] = field; in cdns_torrent_derived_refclk_register()
1707 derived_refclk->hw.init = init; in cdns_torrent_derived_refclk_register()
1709 clk = devm_clk_register(dev, &derived_refclk->hw); in cdns_torrent_derived_refclk_register()
1713 cdns_phy->clks[CDNS_TORRENT_REFCLK_DRIVER] = clk; in cdns_torrent_derived_refclk_register()
1727 return ERR_PTR(-ENOMEM); in cdns_regmap_init()
1729 ctx->dev = dev; in cdns_regmap_init()
1730 ctx->base = base + block_offset; in cdns_regmap_init()
1731 ctx->reg_offset_shift = reg_offset_shift; in cdns_regmap_init()
1738 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regfield_init()
1742 regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_regfield_init()
1748 cdns_phy->phy_reset_ctrl = field; in cdns_torrent_dp_regfield_init()
1755 struct device *dev = cdns_phy->dev; in cdns_torrent_regfield_init()
1760 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
1766 cdns_phy->phy_pll_cfg = field; in cdns_torrent_regfield_init()
1768 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
1774 cdns_phy->phy_pma_cmn_ctrl_1 = field; in cdns_torrent_regfield_init()
1776 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
1782 cdns_phy->phy_pma_cmn_ctrl_2 = field; in cdns_torrent_regfield_init()
1784 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
1790 cdns_phy->phy_pma_pll_raw_ctrl = field; in cdns_torrent_regfield_init()
1793 regmap = cdns_phy->regmap_phy_pcs_lane_cdb[i]; in cdns_torrent_regfield_init()
1799 cdns_phy->phy_pcs_iso_link_ctrl_1[i] = field; in cdns_torrent_regfield_init()
1807 void __iomem *base = cdns_phy->base; in cdns_torrent_dp_regmap_init()
1808 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regmap_init()
1813 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_dp_regmap_init()
1823 cdns_phy->regmap_dptx_phy_reg = regmap; in cdns_torrent_dp_regmap_init()
1830 void __iomem *sd_base = cdns_phy->sd_base; in cdns_torrent_regmap_init()
1832 struct device *dev = cdns_phy->dev; in cdns_torrent_regmap_init()
1837 block_offset_shift = cdns_phy->init_data->block_offset_shift; in cdns_torrent_regmap_init()
1838 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_regmap_init()
1850 cdns_phy->regmap_tx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
1861 cdns_phy->regmap_rx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
1872 cdns_phy->regmap_phy_pcs_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
1883 cdns_phy->regmap_common_cdb = regmap; in cdns_torrent_regmap_init()
1893 cdns_phy->regmap_phy_pcs_common_cdb = regmap; in cdns_torrent_regmap_init()
1903 cdns_phy->regmap_phy_pma_common_cdb = regmap; in cdns_torrent_regmap_init()
1910 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_init()
1911 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_init()
1913 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_init()
1916 enum cdns_torrent_phy_type phy_type = inst->phy_type; in cdns_torrent_phy_init()
1917 enum cdns_torrent_ssc_mode ssc = inst->ssc_mode; in cdns_torrent_phy_init() local
1924 if (cdns_phy->nsubnodes > 1) in cdns_torrent_phy_init()
1932 ssc = NO_SSC; in cdns_torrent_phy_init()
1935 link_cmn_vals = init_data->link_cmn_vals[phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1937 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
1938 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_init()
1939 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
1945 regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val); in cdns_torrent_phy_init()
1952 xcvr_diag_vals = init_data->xcvr_diag_vals[phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1954 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_init()
1955 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_init()
1956 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
1957 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
1965 pcs_cmn_vals = init_data->pcs_cmn_vals[phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1967 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
1968 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_init()
1969 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_init()
1976 cmn_vals = init_data->cmn_vals[ref_clk][phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1978 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_init()
1979 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_init()
1980 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
1987 tx_ln_vals = init_data->tx_ln_vals[ref_clk][phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
1989 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
1990 num_regs = tx_ln_vals->num_regs; in cdns_torrent_phy_init()
1991 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
1992 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2000 rx_ln_vals = init_data->rx_ln_vals[ref_clk][phy_type][TYPE_NONE][ssc]; in cdns_torrent_phy_init()
2002 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
2003 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_init()
2004 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
2005 regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2042 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_configure_multilink()
2044 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_configure_multilink()
2050 enum cdns_torrent_ssc_mode ssc; in cdns_torrent_phy_configure_multilink() local
2055 if (cdns_phy->nsubnodes != 2) in cdns_torrent_phy_configure_multilink()
2056 return -EINVAL; in cdns_torrent_phy_configure_multilink()
2058 phy_t1 = cdns_phy->phys[0].phy_type; in cdns_torrent_phy_configure_multilink()
2059 phy_t2 = cdns_phy->phys[1].phy_type; in cdns_torrent_phy_configure_multilink()
2063 * values as [phy_t1][phy_t2][ssc]. in cdns_torrent_phy_configure_multilink()
2065 for (node = 0; node < cdns_phy->nsubnodes; node++) { in cdns_torrent_phy_configure_multilink()
2070 * Get the array values as [phy_t2][phy_t1][ssc]. in cdns_torrent_phy_configure_multilink()
2077 mlane = cdns_phy->phys[node].mlane; in cdns_torrent_phy_configure_multilink()
2078 ssc = cdns_phy->phys[node].ssc_mode; in cdns_torrent_phy_configure_multilink()
2079 num_lanes = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_configure_multilink()
2085 * values should be same for [phy_t1][phy_t2][ssc] and in cdns_torrent_phy_configure_multilink()
2086 * [phy_t2][phy_t1][ssc]. in cdns_torrent_phy_configure_multilink()
2091 link_cmn_vals = init_data->link_cmn_vals[phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2093 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2094 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2095 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2101 regmap_field_write(cdns_phy->phy_pll_cfg, in cdns_torrent_phy_configure_multilink()
2109 xcvr_diag_vals = init_data->xcvr_diag_vals[phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2111 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2112 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2114 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2122 pcs_cmn_vals = init_data->pcs_cmn_vals[phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2124 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2125 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2126 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_configure_multilink()
2133 cmn_vals = init_data->cmn_vals[ref_clk][phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2135 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2136 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2137 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2144 tx_ln_vals = init_data->tx_ln_vals[ref_clk][phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2146 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2147 num_regs = tx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2149 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2157 rx_ln_vals = init_data->rx_ln_vals[ref_clk][phy_t1][phy_t2][ssc]; in cdns_torrent_phy_configure_multilink()
2159 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2160 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2162 regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2169 reset_control_deassert(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_configure_multilink()
2173 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_configure_multilink()
2182 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_cleanup()
2184 of_clk_del_provider(dev->of_node); in cdns_torrent_clk_cleanup()
2189 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_register()
2190 struct device_node *node = dev->of_node; in cdns_torrent_clk_register()
2199 cdns_phy->clk_data.clks = cdns_phy->clks; in cdns_torrent_clk_register()
2200 cdns_phy->clk_data.clk_num = CDNS_TORRENT_REFCLK_DRIVER + 1; in cdns_torrent_clk_register()
2202 ret = of_clk_add_provider(node, of_clk_src_onecell_get, &cdns_phy->clk_data); in cdns_torrent_clk_register()
2204 dev_err(dev, "Failed to add clock provider: %s\n", node->name); in cdns_torrent_clk_register()
2213 struct device *dev = cdns_phy->dev; in cdns_torrent_reset()
2215 cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0); in cdns_torrent_reset()
2216 if (IS_ERR(cdns_phy->phy_rst)) { in cdns_torrent_reset()
2218 dev->of_node->full_name); in cdns_torrent_reset()
2219 return PTR_ERR(cdns_phy->phy_rst); in cdns_torrent_reset()
2222 cdns_phy->apb_rst = devm_reset_control_get_optional_exclusive(dev, "torrent_apb"); in cdns_torrent_reset()
2223 if (IS_ERR(cdns_phy->apb_rst)) { in cdns_torrent_reset()
2225 dev->of_node->full_name); in cdns_torrent_reset()
2226 return PTR_ERR(cdns_phy->apb_rst); in cdns_torrent_reset()
2234 struct device *dev = cdns_phy->dev; in cdns_torrent_clk()
2238 cdns_phy->clk = devm_clk_get(dev, "refclk"); in cdns_torrent_clk()
2239 if (IS_ERR(cdns_phy->clk)) { in cdns_torrent_clk()
2241 return PTR_ERR(cdns_phy->clk); in cdns_torrent_clk()
2244 ret = clk_prepare_enable(cdns_phy->clk); in cdns_torrent_clk()
2246 dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); in cdns_torrent_clk()
2250 ref_clk_rate = clk_get_rate(cdns_phy->clk); in cdns_torrent_clk()
2252 dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); in cdns_torrent_clk()
2253 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_clk()
2254 return -EINVAL; in cdns_torrent_clk()
2259 cdns_phy->ref_clk_rate = CLK_19_2_MHZ; in cdns_torrent_clk()
2262 cdns_phy->ref_clk_rate = CLK_25_MHZ; in cdns_torrent_clk()
2265 cdns_phy->ref_clk_rate = CLK_100_MHZ; in cdns_torrent_clk()
2268 dev_err(cdns_phy->dev, "Invalid Ref Clock Rate\n"); in cdns_torrent_clk()
2269 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_clk()
2270 return -EINVAL; in cdns_torrent_clk()
2279 struct device *dev = &pdev->dev; in cdns_torrent_phy_probe()
2292 return -EINVAL; in cdns_torrent_phy_probe()
2296 return -ENOMEM; in cdns_torrent_phy_probe()
2299 cdns_phy->dev = dev; in cdns_torrent_phy_probe()
2300 cdns_phy->init_data = data; in cdns_torrent_phy_probe()
2302 cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0); in cdns_torrent_phy_probe()
2303 if (IS_ERR(cdns_phy->sd_base)) in cdns_torrent_phy_probe()
2304 return PTR_ERR(cdns_phy->sd_base); in cdns_torrent_phy_probe()
2306 subnodes = of_get_available_child_count(dev->of_node); in cdns_torrent_phy_probe()
2309 return -EINVAL; in cdns_torrent_phy_probe()
2324 regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); in cdns_torrent_phy_probe()
2335 /* Enable APB */ in cdns_torrent_phy_probe()
2336 reset_control_deassert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2339 for_each_available_child_of_node(dev->of_node, child) { in cdns_torrent_phy_probe()
2346 cdns_phy->phys[node].lnk_rst = in cdns_torrent_phy_probe()
2348 if (IS_ERR(cdns_phy->phys[node].lnk_rst)) { in cdns_torrent_phy_probe()
2350 child->full_name); in cdns_torrent_phy_probe()
2351 ret = PTR_ERR(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_probe()
2356 &cdns_phy->phys[node].mlane)) { in cdns_torrent_phy_probe()
2357 dev_err(dev, "%s: No \"reg\"-property.\n", in cdns_torrent_phy_probe()
2358 child->full_name); in cdns_torrent_phy_probe()
2359 ret = -EINVAL; in cdns_torrent_phy_probe()
2363 if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) { in cdns_torrent_phy_probe()
2364 dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n", in cdns_torrent_phy_probe()
2365 child->full_name); in cdns_torrent_phy_probe()
2366 ret = -EINVAL; in cdns_torrent_phy_probe()
2372 cdns_phy->phys[node].phy_type = TYPE_PCIE; in cdns_torrent_phy_probe()
2375 cdns_phy->phys[node].phy_type = TYPE_DP; in cdns_torrent_phy_probe()
2378 cdns_phy->phys[node].phy_type = TYPE_SGMII; in cdns_torrent_phy_probe()
2381 cdns_phy->phys[node].phy_type = TYPE_QSGMII; in cdns_torrent_phy_probe()
2384 cdns_phy->phys[node].phy_type = TYPE_USB; in cdns_torrent_phy_probe()
2388 ret = -EINVAL; in cdns_torrent_phy_probe()
2392 if (of_property_read_u32(child, "cdns,num-lanes", in cdns_torrent_phy_probe()
2393 &cdns_phy->phys[node].num_lanes)) { in cdns_torrent_phy_probe()
2394 dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n", in cdns_torrent_phy_probe()
2395 child->full_name); in cdns_torrent_phy_probe()
2396 ret = -EINVAL; in cdns_torrent_phy_probe()
2400 total_num_lanes += cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2402 /* Get SSC mode */ in cdns_torrent_phy_probe()
2403 cdns_phy->phys[node].ssc_mode = NO_SSC; in cdns_torrent_phy_probe()
2404 of_property_read_u32(child, "cdns,ssc-mode", in cdns_torrent_phy_probe()
2405 &cdns_phy->phys[node].ssc_mode); in cdns_torrent_phy_probe()
2416 if (cdns_phy->phys[node].phy_type == TYPE_DP) { in cdns_torrent_phy_probe()
2417 switch (cdns_phy->phys[node].num_lanes) { in cdns_torrent_phy_probe()
2425 cdns_phy->phys[node].num_lanes); in cdns_torrent_phy_probe()
2426 ret = -EINVAL; in cdns_torrent_phy_probe()
2430 cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE; in cdns_torrent_phy_probe()
2431 of_property_read_u32(child, "cdns,max-bit-rate", in cdns_torrent_phy_probe()
2432 &cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2434 switch (cdns_phy->max_bit_rate) { in cdns_torrent_phy_probe()
2447 cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2448 ret = -EINVAL; in cdns_torrent_phy_probe()
2453 cdns_phy->base = devm_platform_ioremap_resource(pdev, 1); in cdns_torrent_phy_probe()
2454 if (IS_ERR(cdns_phy->base)) { in cdns_torrent_phy_probe()
2455 ret = PTR_ERR(cdns_phy->base); in cdns_torrent_phy_probe()
2472 cdns_phy->max_bit_rate / 1000, in cdns_torrent_phy_probe()
2473 cdns_phy->max_bit_rate % 1000); in cdns_torrent_phy_probe()
2475 gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2476 gphy->attrs.max_link_rate = cdns_phy->max_bit_rate; in cdns_torrent_phy_probe()
2477 gphy->attrs.mode = PHY_MODE_DP; in cdns_torrent_phy_probe()
2480 cdns_phy->phys[node].phy = gphy; in cdns_torrent_phy_probe()
2481 phy_set_drvdata(gphy, &cdns_phy->phys[node]); in cdns_torrent_phy_probe()
2485 cdns_phy->nsubnodes = node; in cdns_torrent_phy_probe()
2489 ret = -EINVAL; in cdns_torrent_phy_probe()
2493 if (cdns_phy->nsubnodes > 1 && !already_configured) { in cdns_torrent_phy_probe()
2505 if (cdns_phy->nsubnodes > 1) in cdns_torrent_phy_probe()
2506 dev_dbg(dev, "Multi-link: %s (%d lanes) & %s (%d lanes)", in cdns_torrent_phy_probe()
2507 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
2508 cdns_phy->phys[0].num_lanes, in cdns_torrent_phy_probe()
2509 cdns_torrent_get_phy_type(cdns_phy->phys[1].phy_type), in cdns_torrent_phy_probe()
2510 cdns_phy->phys[1].num_lanes); in cdns_torrent_phy_probe()
2513 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
2514 cdns_phy->phys[0].num_lanes); in cdns_torrent_phy_probe()
2522 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_probe()
2524 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2525 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_probe()
2536 reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_remove()
2537 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_remove()
2538 for (i = 0; i < cdns_phy->nsubnodes; i++) { in cdns_torrent_phy_remove()
2539 reset_control_assert(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
2540 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
2543 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_remove()
2569 /* Single DP, 19.2 MHz Ref clk, no SSC */
2640 /* Single DP, 25 MHz Ref clk, no SSC */
2711 /* Single DP, 100 MHz Ref clk, no SSC */
2783 /* PCIe and USB Unique SSC link configuration */
2818 /* USB 100 MHz Ref clk, internal SSC */
2911 /* USB 100 MHz Ref clk, no SSC */
2982 /* Single link USB, 100 MHz Ref clk, internal SSC */
3029 /* PCIe and SGMII/QSGMII Unique SSC link configuration */
3064 /* SGMII 100 MHz Ref clk, no SSC */
3138 /* SGMII 100 MHz Ref clk, internal SSC */
3195 /* QSGMII 100 MHz Ref clk, no SSC */
3271 /* QSGMII 100 MHz Ref clk, internal SSC */
3350 /* Multi link PCIe, 100 MHz Ref clk, internal SSC */
3405 /* Single link PCIe, 100 MHz Ref clk, internal SSC */
3460 /* PCIe, 100 MHz Ref clk, no SSC & external SSC */
4449 .compatible = "cdns,torrent-phy",
4453 .compatible = "ti,j721e-serdes-10g",
4464 .name = "cdns-torrent-phy",