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",
240 [CDNS_TORRENT_DERIVED_REFCLK] = "refclk-der",
241 [CDNS_TORRENT_RECEIVED_REFCLK] = "refclk-rec",
329 #define CDNS_TORRENT_KEY(refclk0, refclk1, link0, link1, ssc) \ argument
334 (((ssc) << SSC_SHIFT) & SSC_MASK))
459 enum cdns_torrent_ssc_mode ssc) in cdns_torrent_get_tbl_vals() argument
462 u32 key = CDNS_TORRENT_KEY(refclk0, refclk1, link0, link1, ssc); in cdns_torrent_get_tbl_vals()
464 for (i = 0; i < tbl->num_entries; i++) { in cdns_torrent_get_tbl_vals()
465 if (tbl->entries[i].key == key) in cdns_torrent_get_tbl_vals()
466 return tbl->entries[i].vals; in cdns_torrent_get_tbl_vals()
475 u32 offset = reg << ctx->reg_offset_shift; in cdns_regmap_write()
477 writew(val, ctx->base + offset); in cdns_regmap_write()
485 u32 offset = reg << ctx->reg_offset_shift; in cdns_regmap_read()
487 *val = readw(ctx->base + offset); in cdns_regmap_read()
497 writel(val, ctx->base + offset); in cdns_regmap_dptx_write()
508 *val = readl(ctx->base + offset); in cdns_regmap_dptx_read()
623 * Structure used to store values of PHY registers for voltage-related
624 * coefficients, for particular voltage swing and pre-emphasis level. Values
637 * Array consists of values of voltage-related registers for sd0801 PHY. A value
641 /* voltage swing 0, pre-emphasis 0->3 */
652 /* voltage swing 1, pre-emphasis 0->3 */
663 /* voltage swing 2, pre-emphasis 0->3 */
674 /* voltage swing 3, pre-emphasis 0->3 */
707 * Set registers responsible for enabling and configuring SSC, with second and
714 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_19_2mhz()
728 u32 rate, bool ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz() argument
730 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
747 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
764 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
780 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
795 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
800 if (ssc) { in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
808 /* Set reset register values to disable SSC */ in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
828 * Set registers responsible for enabling and configuring SSC, with second
834 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_25mhz()
848 u32 rate, bool ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz() argument
850 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
865 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
880 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
894 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
907 if (ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
915 if (ssc) { in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
929 /* Set reset register values to disable SSC */ in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
952 u32 rate, bool ssc) in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz() argument
954 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
961 if (cdns_phy->dp_pll & DP_PLL0) in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
964 if (cdns_phy->dp_pll & DP_PLL1) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
974 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
985 if (cdns_phy->dp_pll & DP_PLL1) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1000 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1011 if (cdns_phy->dp_pll & DP_PLL1) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1025 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1035 if (cdns_phy->dp_pll & DP_PLL1) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1056 cdns_phy->dp_pll = DP_PLL1; in cdns_torrent_dp_get_pll()
1060 cdns_phy->dp_pll = DP_PLL0; in cdns_torrent_dp_get_pll()
1063 cdns_phy->dp_pll = DP_PLL0 | DP_PLL1; in cdns_torrent_dp_get_pll()
1066 dev_err(cdns_phy->dev, "Unsupported PHY configuration\n"); in cdns_torrent_dp_get_pll()
1067 return -EINVAL; in cdns_torrent_dp_get_pll()
1074 * Enable or disable PLL for selected lanes.
1079 bool enable) in cdns_torrent_dp_set_pll_en() argument
1081 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_pll_en()
1086 * Used to determine, which bits to check for or enable in in cdns_torrent_dp_set_pll_en()
1090 /* Used to enable or disable lanes. */ in cdns_torrent_dp_set_pll_en()
1096 if (enable) { in cdns_torrent_dp_set_pll_en()
1097 pll_bits = ((1 << dp->lanes) - 1); in cdns_torrent_dp_set_pll_en()
1101 pll_bits = ((1 << inst->num_lanes) - 1); in cdns_torrent_dp_set_pll_en()
1129 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_power_state()
1168 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_run()
1177 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_run()
1178 dev_err(cdns_phy->dev, in cdns_torrent_dp_run()
1179 "timeout waiting for link PLL clock enable ack\n"); in cdns_torrent_dp_run()
1200 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_wait_pma_cmn_ready()
1204 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_wait_pma_cmn_ready()
1205 dev_err(cdns_phy->dev, in cdns_torrent_dp_wait_pma_cmn_ready()
1207 return -ETIMEDOUT; in cdns_torrent_dp_wait_pma_cmn_ready()
1247 if (cdns_phy->dp_pll & DP_PLL0) in cdns_torrent_dp_pma_cmn_rate()
1248 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1251 if (cdns_phy->dp_pll & DP_PLL1) in cdns_torrent_dp_pma_cmn_rate()
1252 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1255 /* PMA lane configuration to deal with multi-link operation */ in cdns_torrent_dp_pma_cmn_rate()
1257 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + i], in cdns_torrent_dp_pma_cmn_rate()
1274 * re-programming the new data rate. in cdns_torrent_dp_configure_rate()
1276 ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val); in cdns_torrent_dp_configure_rate()
1279 field_val &= ~(cdns_phy->dp_pll); in cdns_torrent_dp_configure_rate()
1280 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val); in cdns_torrent_dp_configure_rate()
1283 * Wait for PLL ready de-assertion. in cdns_torrent_dp_configure_rate()
1284 * For PLL0 - PHY_PMA_CMN_CTRL2[2] == 1 in cdns_torrent_dp_configure_rate()
1285 * For PLL1 - PHY_PMA_CMN_CTRL2[3] == 1 in cdns_torrent_dp_configure_rate()
1287 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_configure_rate()
1288 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1296 if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1) { in cdns_torrent_dp_configure_rate()
1297 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1306 /* DP Rate Change - VCO Output settings. */ in cdns_torrent_dp_configure_rate()
1307 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_configure_rate()
1309 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1310 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_configure_rate()
1312 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1313 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_configure_rate()
1315 cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1317 cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, dp->link_rate, dp->lanes); in cdns_torrent_dp_configure_rate()
1319 /* Enable the associated PLL (cmn_pll0_en or cmn_pll1_en) */ in cdns_torrent_dp_configure_rate()
1320 ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val); in cdns_torrent_dp_configure_rate()
1323 field_val |= cdns_phy->dp_pll; in cdns_torrent_dp_configure_rate()
1324 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val); in cdns_torrent_dp_configure_rate()
1328 * For PLL0 - PHY_PMA_CMN_CTRL2[0] == 1 in cdns_torrent_dp_configure_rate()
1329 * For PLL1 - PHY_PMA_CMN_CTRL2[1] == 1 in cdns_torrent_dp_configure_rate()
1331 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_configure_rate()
1332 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1340 if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1) in cdns_torrent_dp_configure_rate()
1341 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1358 if (dp->set_rate) { in cdns_torrent_dp_verify_config()
1359 switch (dp->link_rate) { in cdns_torrent_dp_verify_config()
1371 return -EINVAL; in cdns_torrent_dp_verify_config()
1376 switch (dp->lanes) { in cdns_torrent_dp_verify_config()
1383 return -EINVAL; in cdns_torrent_dp_verify_config()
1387 if (dp->lanes > inst->num_lanes) in cdns_torrent_dp_verify_config()
1388 return -EINVAL; in cdns_torrent_dp_verify_config()
1391 * If changing voltages is required, check swing and pre-emphasis in cdns_torrent_dp_verify_config()
1392 * levels, per-lane. in cdns_torrent_dp_verify_config()
1394 if (dp->set_voltages) { in cdns_torrent_dp_verify_config()
1396 for (i = 0; i < dp->lanes; i++) { in cdns_torrent_dp_verify_config()
1397 if (dp->voltage[i] > 3 || dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
1398 return -EINVAL; in cdns_torrent_dp_verify_config()
1400 /* Sum of voltage swing and pre-emphasis levels cannot in cdns_torrent_dp_verify_config()
1403 if (dp->voltage[i] + dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
1404 return -EINVAL; in cdns_torrent_dp_verify_config()
1411 /* Set power state A0 and PLL clock enable to 0 on enabled lanes. */
1416 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_a0_pll()
1425 << PHY_POWER_STATE_LN(inst->mlane + i)); in cdns_torrent_dp_set_a0_pll()
1427 pll_clk_en &= ~(0x01U << (inst->mlane + i)); in cdns_torrent_dp_set_a0_pll()
1441 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_lanes()
1442 u8 lane_mask = (1 << dp->lanes) - 1; in cdns_torrent_dp_set_lanes()
1444 u32 clane = inst->mlane; in cdns_torrent_dp_set_lanes()
1450 pma_tx_elec_idle_mask = ((1 << inst->num_lanes) - 1) << clane; in cdns_torrent_dp_set_lanes()
1468 * and powered down when re-enabling the link in cdns_torrent_dp_set_lanes()
1470 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1473 for (i = 1; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1478 cdns_torrent_dp_set_a0_pll(cdns_phy, inst, dp->lanes); in cdns_torrent_dp_set_lanes()
1481 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1484 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1501 ret = cdns_torrent_dp_run(cdns_phy, inst, dp->lanes); in cdns_torrent_dp_set_lanes()
1513 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes, in cdns_torrent_dp_set_rate()
1530 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes, in cdns_torrent_dp_set_rate()
1534 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes, in cdns_torrent_dp_set_rate()
1543 /* Configure voltage swing and pre-emphasis for all enabled lanes. */
1551 for (lane = 0; lane < dp->lanes; lane++) { in cdns_torrent_dp_set_voltages()
1552 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1559 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1562 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1564 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].diag_tx_drv; in cdns_torrent_dp_set_voltages()
1565 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1567 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].mgnfs_mult; in cdns_torrent_dp_set_voltages()
1568 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1571 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].cpost_mult; in cdns_torrent_dp_set_voltages()
1572 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1576 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1583 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1592 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_configure()
1595 ret = cdns_torrent_dp_verify_config(inst, &opts->dp); in cdns_torrent_dp_configure()
1597 dev_err(&phy->dev, "invalid params for phy configure\n"); in cdns_torrent_dp_configure()
1601 if (opts->dp.set_lanes) { in cdns_torrent_dp_configure()
1602 ret = cdns_torrent_dp_set_lanes(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1604 dev_err(&phy->dev, "cdns_torrent_dp_set_lanes failed\n"); in cdns_torrent_dp_configure()
1609 if (opts->dp.set_rate) { in cdns_torrent_dp_configure()
1610 ret = cdns_torrent_dp_set_rate(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1612 dev_err(&phy->dev, "cdns_torrent_dp_set_rate failed\n"); in cdns_torrent_dp_configure()
1617 if (opts->dp.set_voltages) in cdns_torrent_dp_configure()
1618 cdns_torrent_dp_set_voltages(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1626 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_on()
1630 if (cdns_phy->nsubnodes == 1) { in cdns_torrent_phy_on()
1632 reset_control_deassert(inst->lnk_rst); in cdns_torrent_phy_on()
1635 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_on()
1644 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1, in cdns_torrent_phy_on()
1648 dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n"); in cdns_torrent_phy_on()
1652 if (inst->phy_type == TYPE_PCIE || inst->phy_type == TYPE_USB) { in cdns_torrent_phy_on()
1653 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pcs_iso_link_ctrl_1[inst->mlane], in cdns_torrent_phy_on()
1656 if (ret == -ETIMEDOUT) { in cdns_torrent_phy_on()
1657 dev_err(cdns_phy->dev, "Timeout waiting for PHY status ready\n"); in cdns_torrent_phy_on()
1668 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_off()
1671 if (cdns_phy->nsubnodes != 1) in cdns_torrent_phy_off()
1674 ret = reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_off()
1678 return reset_control_assert(inst->lnk_rst); in cdns_torrent_phy_off()
1684 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_common_init()
1688 cdns_torrent_dp_write(regmap, PHY_AUX_CTRL, 0x0003); /* enable AUX */ in cdns_torrent_dp_common_init()
1692 * Set lines pll clk enable to 0 in cdns_torrent_dp_common_init()
1694 cdns_torrent_dp_set_a0_pll(cdns_phy, inst, inst->num_lanes); in cdns_torrent_dp_common_init()
1700 lane_bits = (1 << inst->num_lanes) - 1; in cdns_torrent_dp_common_init()
1714 * Initialize PHY with max supported link rate, without SSC. in cdns_torrent_dp_common_init()
1716 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_common_init()
1718 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1720 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_common_init()
1722 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1724 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_common_init()
1726 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1729 cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1730 inst->num_lanes); in cdns_torrent_dp_common_init()
1733 regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1); in cdns_torrent_dp_common_init()
1750 ret = cdns_torrent_dp_run(cdns_phy, inst, inst->num_lanes); in cdns_torrent_dp_start()
1758 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_init()
1761 switch (cdns_phy->ref_clk_rate) { in cdns_torrent_dp_init()
1768 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_init()
1769 return -EINVAL; in cdns_torrent_dp_init()
1785 if (cdns_phy->ref_clk_rate != CLK_100_MHZ) { in cdns_torrent_dp_multilink_init()
1786 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_multilink_init()
1787 return -EINVAL; in cdns_torrent_dp_multilink_init()
1799 regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 1); in cdns_torrent_derived_refclk_enable()
1800 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 1); in cdns_torrent_derived_refclk_enable()
1809 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 0); in cdns_torrent_derived_refclk_disable()
1810 regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 0); in cdns_torrent_derived_refclk_disable()
1818 regmap_field_read(derived_refclk->cmn_cdiag_refclk_ovrd_4, &val); in cdns_torrent_derived_refclk_is_enabled()
1824 .enable = cdns_torrent_derived_refclk_enable,
1832 struct device *dev = cdns_phy->dev; in cdns_torrent_derived_refclk_register()
1842 return -ENOMEM; in cdns_torrent_derived_refclk_register()
1853 init = &derived_refclk->clk_data; in cdns_torrent_derived_refclk_register()
1857 init->parent_names = &parent_name; in cdns_torrent_derived_refclk_register()
1858 init->num_parents = 1; in cdns_torrent_derived_refclk_register()
1860 init->ops = &cdns_torrent_derived_refclk_ops; in cdns_torrent_derived_refclk_register()
1861 init->flags = 0; in cdns_torrent_derived_refclk_register()
1862 init->name = clk_name; in cdns_torrent_derived_refclk_register()
1864 derived_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0; in cdns_torrent_derived_refclk_register()
1865 derived_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4; in cdns_torrent_derived_refclk_register()
1867 derived_refclk->hw.init = init; in cdns_torrent_derived_refclk_register()
1869 hw = &derived_refclk->hw; in cdns_torrent_derived_refclk_register()
1874 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_DERIVED_REFCLK] = hw; in cdns_torrent_derived_refclk_register()
1883 regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 1); in cdns_torrent_received_refclk_enable()
1892 regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 0); in cdns_torrent_received_refclk_disable()
1900 regmap_field_read(received_refclk->phy_pipe_cmn_ctrl1_0, &val); in cdns_torrent_received_refclk_is_enabled()
1901 regmap_field_read(received_refclk->cmn_cdiag_refclk_ovrd_4, &cmn_val); in cdns_torrent_received_refclk_is_enabled()
1907 .enable = cdns_torrent_received_refclk_enable,
1915 struct device *dev = cdns_phy->dev; in cdns_torrent_received_refclk_register()
1925 return -ENOMEM; in cdns_torrent_received_refclk_register()
1936 init = &received_refclk->clk_data; in cdns_torrent_received_refclk_register()
1940 init->parent_names = &parent_name; in cdns_torrent_received_refclk_register()
1941 init->num_parents = 1; in cdns_torrent_received_refclk_register()
1943 init->ops = &cdns_torrent_received_refclk_ops; in cdns_torrent_received_refclk_register()
1944 init->flags = 0; in cdns_torrent_received_refclk_register()
1945 init->name = clk_name; in cdns_torrent_received_refclk_register()
1947 received_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0; in cdns_torrent_received_refclk_register()
1948 received_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4; in cdns_torrent_received_refclk_register()
1950 received_refclk->hw.init = init; in cdns_torrent_received_refclk_register()
1952 hw = &received_refclk->hw; in cdns_torrent_received_refclk_register()
1957 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_RECEIVED_REFCLK] = hw; in cdns_torrent_received_refclk_register()
1966 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_6], 0); in cdns_torrent_refclk_driver_enable()
1967 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_5], 1); in cdns_torrent_refclk_driver_enable()
1968 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 0); in cdns_torrent_refclk_driver_enable()
1977 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 1); in cdns_torrent_refclk_driver_disable()
1985 regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], &val); in cdns_torrent_refclk_driver_is_enabled()
1995 regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], &val); in cdns_torrent_refclk_driver_get_parent()
2005 return regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], val); in cdns_torrent_refclk_driver_set_parent()
2009 .enable = cdns_torrent_refclk_driver_enable,
2020 struct device *dev = cdns_phy->dev; in cdns_torrent_refclk_driver_register()
2032 return -ENOMEM; in cdns_torrent_refclk_driver_register()
2037 return -ENOMEM; in cdns_torrent_refclk_driver_register()
2040 hw = cdns_phy->clk_hw_data->hws[refclk_driver_parent_index[i]]; in cdns_torrent_refclk_driver_register()
2043 return IS_ERR(hw) ? PTR_ERR(hw) : -ENOENT; in cdns_torrent_refclk_driver_register()
2051 init = &refclk_driver->clk_data; in cdns_torrent_refclk_driver_register()
2053 init->ops = &cdns_torrent_refclk_driver_ops; in cdns_torrent_refclk_driver_register()
2054 init->flags = CLK_SET_RATE_NO_REPARENT; in cdns_torrent_refclk_driver_register()
2055 init->parent_names = parent_names; in cdns_torrent_refclk_driver_register()
2056 init->num_parents = num_parents; in cdns_torrent_refclk_driver_register()
2057 init->name = clk_name; in cdns_torrent_refclk_driver_register()
2059 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_refclk_driver_register()
2067 refclk_driver->cmn_fields[i] = field; in cdns_torrent_refclk_driver_register()
2070 /* Enable Derived reference clock as default */ in cdns_torrent_refclk_driver_register()
2071 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], 1); in cdns_torrent_refclk_driver_register()
2073 refclk_driver->hw.init = init; in cdns_torrent_refclk_driver_register()
2075 hw = &refclk_driver->hw; in cdns_torrent_refclk_driver_register()
2080 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw; in cdns_torrent_refclk_driver_register()
2094 return ERR_PTR(-ENOMEM); in cdns_regmap_init()
2096 ctx->dev = dev; in cdns_regmap_init()
2097 ctx->base = base + block_offset; in cdns_regmap_init()
2098 ctx->reg_offset_shift = reg_offset_shift; in cdns_regmap_init()
2105 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regfield_init()
2109 regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_regfield_init()
2115 cdns_phy->phy_reset_ctrl = field; in cdns_torrent_dp_regfield_init()
2122 struct device *dev = cdns_phy->dev; in cdns_torrent_regfield_init()
2127 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
2133 cdns_phy->phy_pll_cfg = field; in cdns_torrent_regfield_init()
2135 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
2141 cdns_phy->phy_pipe_cmn_ctrl1_0 = field; in cdns_torrent_regfield_init()
2143 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_regfield_init()
2149 cdns_phy->cmn_cdiag_refclk_ovrd_4 = field; in cdns_torrent_regfield_init()
2151 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2157 cdns_phy->phy_pma_cmn_ctrl_1 = field; in cdns_torrent_regfield_init()
2159 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2165 cdns_phy->phy_pma_cmn_ctrl_2 = field; in cdns_torrent_regfield_init()
2167 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2173 cdns_phy->phy_pma_pll_raw_ctrl = field; in cdns_torrent_regfield_init()
2176 regmap = cdns_phy->regmap_phy_pcs_lane_cdb[i]; in cdns_torrent_regfield_init()
2182 cdns_phy->phy_pcs_iso_link_ctrl_1[i] = field; in cdns_torrent_regfield_init()
2190 void __iomem *base = cdns_phy->base; in cdns_torrent_dp_regmap_init()
2191 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regmap_init()
2196 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_dp_regmap_init()
2206 cdns_phy->regmap_dptx_phy_reg = regmap; in cdns_torrent_dp_regmap_init()
2213 void __iomem *sd_base = cdns_phy->sd_base; in cdns_torrent_regmap_init()
2215 struct device *dev = cdns_phy->dev; in cdns_torrent_regmap_init()
2220 block_offset_shift = cdns_phy->init_data->block_offset_shift; in cdns_torrent_regmap_init()
2221 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_regmap_init()
2233 cdns_phy->regmap_tx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2244 cdns_phy->regmap_rx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2255 cdns_phy->regmap_phy_pcs_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2266 cdns_phy->regmap_common_cdb = regmap; in cdns_torrent_regmap_init()
2276 cdns_phy->regmap_phy_pcs_common_cdb = regmap; in cdns_torrent_regmap_init()
2286 cdns_phy->regmap_phy_pma_common_cdb = regmap; in cdns_torrent_regmap_init()
2293 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_init()
2294 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_init()
2296 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_init()
2299 enum cdns_torrent_phy_type phy_type = inst->phy_type; in cdns_torrent_phy_init()
2300 enum cdns_torrent_ssc_mode ssc = inst->ssc_mode; in cdns_torrent_phy_init() local
2308 if (cdns_phy->nsubnodes > 1) { in cdns_torrent_phy_init()
2319 ssc = NO_SSC; in cdns_torrent_phy_init()
2322 link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl, in cdns_torrent_phy_init()
2327 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2328 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_init()
2329 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
2335 regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val); in cdns_torrent_phy_init()
2342 xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl, in cdns_torrent_phy_init()
2347 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_init()
2348 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_init()
2349 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
2350 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2358 pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl, in cdns_torrent_phy_init()
2363 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2364 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_init()
2365 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_init()
2372 phy_pma_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->phy_pma_cmn_vals_tbl, in cdns_torrent_phy_init()
2377 reg_pairs = phy_pma_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2378 num_regs = phy_pma_cmn_vals->num_regs; in cdns_torrent_phy_init()
2379 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_phy_init()
2386 cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl, in cdns_torrent_phy_init()
2389 ssc); in cdns_torrent_phy_init()
2391 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2392 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_init()
2393 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
2400 tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl, in cdns_torrent_phy_init()
2403 ssc); in cdns_torrent_phy_init()
2405 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
2406 num_regs = tx_ln_vals->num_regs; in cdns_torrent_phy_init()
2407 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
2408 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2416 rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl, in cdns_torrent_phy_init()
2419 ssc); in cdns_torrent_phy_init()
2421 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
2422 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_init()
2423 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
2424 regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2461 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_configure_multilink()
2463 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_configure_multilink()
2469 enum cdns_torrent_ssc_mode ssc; in cdns_torrent_phy_configure_multilink() local
2474 if (cdns_phy->nsubnodes != 2) in cdns_torrent_phy_configure_multilink()
2475 return -EINVAL; in cdns_torrent_phy_configure_multilink()
2477 phy_t1 = cdns_phy->phys[0].phy_type; in cdns_torrent_phy_configure_multilink()
2478 phy_t2 = cdns_phy->phys[1].phy_type; in cdns_torrent_phy_configure_multilink()
2482 * values as [phy_t1][phy_t2][ssc]. in cdns_torrent_phy_configure_multilink()
2484 for (node = 0; node < cdns_phy->nsubnodes; node++) { in cdns_torrent_phy_configure_multilink()
2489 * Get the array values as [phy_t2][phy_t1][ssc]. in cdns_torrent_phy_configure_multilink()
2494 mlane = cdns_phy->phys[node].mlane; in cdns_torrent_phy_configure_multilink()
2495 ssc = cdns_phy->phys[node].ssc_mode; in cdns_torrent_phy_configure_multilink()
2496 num_lanes = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_configure_multilink()
2502 * values should be same for [phy_t1][phy_t2][ssc] and in cdns_torrent_phy_configure_multilink()
2503 * [phy_t2][phy_t1][ssc]. in cdns_torrent_phy_configure_multilink()
2508 link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2512 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2513 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2514 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2520 regmap_field_write(cdns_phy->phy_pll_cfg, in cdns_torrent_phy_configure_multilink()
2528 xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl, in cdns_torrent_phy_configure_multilink()
2532 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2533 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2535 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2543 pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2547 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2548 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2549 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_configure_multilink()
2556 cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2558 phy_t1, phy_t2, ssc); in cdns_torrent_phy_configure_multilink()
2560 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2561 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2562 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2569 tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl, in cdns_torrent_phy_configure_multilink()
2571 phy_t1, phy_t2, ssc); in cdns_torrent_phy_configure_multilink()
2573 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2574 num_regs = tx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2576 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2584 rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl, in cdns_torrent_phy_configure_multilink()
2586 phy_t1, phy_t2, ssc); in cdns_torrent_phy_configure_multilink()
2588 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2589 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2591 regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2604 reset_control_deassert(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_configure_multilink()
2608 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_configure_multilink()
2617 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_cleanup()
2619 of_clk_del_provider(dev->of_node); in cdns_torrent_clk_cleanup()
2624 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_register()
2625 struct device_node *node = dev->of_node; in cdns_torrent_clk_register()
2631 return -ENOMEM; in cdns_torrent_clk_register()
2633 data->num = CDNS_TORRENT_OUTPUT_CLOCKS; in cdns_torrent_clk_register()
2634 cdns_phy->clk_hw_data = data; in cdns_torrent_clk_register()
2656 dev_err(dev, "Failed to add clock provider: %s\n", node->name); in cdns_torrent_clk_register()
2665 struct device *dev = cdns_phy->dev; in cdns_torrent_reset()
2667 cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0); in cdns_torrent_reset()
2668 if (IS_ERR(cdns_phy->phy_rst)) { in cdns_torrent_reset()
2670 dev->of_node->full_name); in cdns_torrent_reset()
2671 return PTR_ERR(cdns_phy->phy_rst); in cdns_torrent_reset()
2674 cdns_phy->apb_rst = devm_reset_control_get_optional_exclusive(dev, "torrent_apb"); in cdns_torrent_reset()
2675 if (IS_ERR(cdns_phy->apb_rst)) { in cdns_torrent_reset()
2677 dev->of_node->full_name); in cdns_torrent_reset()
2678 return PTR_ERR(cdns_phy->apb_rst); in cdns_torrent_reset()
2686 struct device *dev = cdns_phy->dev; in cdns_torrent_clk()
2690 cdns_phy->clk = devm_clk_get(dev, "refclk"); in cdns_torrent_clk()
2691 if (IS_ERR(cdns_phy->clk)) { in cdns_torrent_clk()
2693 return PTR_ERR(cdns_phy->clk); in cdns_torrent_clk()
2696 ret = clk_prepare_enable(cdns_phy->clk); in cdns_torrent_clk()
2698 dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); in cdns_torrent_clk()
2702 ref_clk_rate = clk_get_rate(cdns_phy->clk); in cdns_torrent_clk()
2704 dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); in cdns_torrent_clk()
2705 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_clk()
2706 return -EINVAL; in cdns_torrent_clk()
2711 cdns_phy->ref_clk_rate = CLK_19_2_MHZ; in cdns_torrent_clk()
2714 cdns_phy->ref_clk_rate = CLK_25_MHZ; in cdns_torrent_clk()
2717 cdns_phy->ref_clk_rate = CLK_100_MHZ; in cdns_torrent_clk()
2720 cdns_phy->ref_clk_rate = CLK_156_25_MHZ; in cdns_torrent_clk()
2723 dev_err(cdns_phy->dev, "Invalid Ref Clock Rate\n"); in cdns_torrent_clk()
2724 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_clk()
2725 return -EINVAL; in cdns_torrent_clk()
2734 struct device *dev = &pdev->dev; in cdns_torrent_phy_probe()
2747 return -EINVAL; in cdns_torrent_phy_probe()
2751 return -ENOMEM; in cdns_torrent_phy_probe()
2754 cdns_phy->dev = dev; in cdns_torrent_phy_probe()
2755 cdns_phy->init_data = data; in cdns_torrent_phy_probe()
2757 cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0); in cdns_torrent_phy_probe()
2758 if (IS_ERR(cdns_phy->sd_base)) in cdns_torrent_phy_probe()
2759 return PTR_ERR(cdns_phy->sd_base); in cdns_torrent_phy_probe()
2761 subnodes = of_get_available_child_count(dev->of_node); in cdns_torrent_phy_probe()
2764 return -EINVAL; in cdns_torrent_phy_probe()
2779 regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); in cdns_torrent_phy_probe()
2790 /* Enable APB */ in cdns_torrent_phy_probe()
2791 reset_control_deassert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2794 for_each_available_child_of_node(dev->of_node, child) { in cdns_torrent_phy_probe()
2801 cdns_phy->phys[node].lnk_rst = in cdns_torrent_phy_probe()
2803 if (IS_ERR(cdns_phy->phys[node].lnk_rst)) { in cdns_torrent_phy_probe()
2805 child->full_name); in cdns_torrent_phy_probe()
2806 ret = PTR_ERR(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_probe()
2811 &cdns_phy->phys[node].mlane)) { in cdns_torrent_phy_probe()
2812 dev_err(dev, "%s: No \"reg\"-property.\n", in cdns_torrent_phy_probe()
2813 child->full_name); in cdns_torrent_phy_probe()
2814 ret = -EINVAL; in cdns_torrent_phy_probe()
2818 if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) { in cdns_torrent_phy_probe()
2819 dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n", in cdns_torrent_phy_probe()
2820 child->full_name); in cdns_torrent_phy_probe()
2821 ret = -EINVAL; in cdns_torrent_phy_probe()
2827 cdns_phy->phys[node].phy_type = TYPE_PCIE; in cdns_torrent_phy_probe()
2830 cdns_phy->phys[node].phy_type = TYPE_DP; in cdns_torrent_phy_probe()
2833 cdns_phy->phys[node].phy_type = TYPE_SGMII; in cdns_torrent_phy_probe()
2836 cdns_phy->phys[node].phy_type = TYPE_QSGMII; in cdns_torrent_phy_probe()
2839 cdns_phy->phys[node].phy_type = TYPE_USB; in cdns_torrent_phy_probe()
2842 cdns_phy->phys[node].phy_type = TYPE_USXGMII; in cdns_torrent_phy_probe()
2846 ret = -EINVAL; in cdns_torrent_phy_probe()
2850 if (of_property_read_u32(child, "cdns,num-lanes", in cdns_torrent_phy_probe()
2851 &cdns_phy->phys[node].num_lanes)) { in cdns_torrent_phy_probe()
2852 dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n", in cdns_torrent_phy_probe()
2853 child->full_name); in cdns_torrent_phy_probe()
2854 ret = -EINVAL; in cdns_torrent_phy_probe()
2858 total_num_lanes += cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2860 /* Get SSC mode */ in cdns_torrent_phy_probe()
2861 cdns_phy->phys[node].ssc_mode = NO_SSC; in cdns_torrent_phy_probe()
2862 of_property_read_u32(child, "cdns,ssc-mode", in cdns_torrent_phy_probe()
2863 &cdns_phy->phys[node].ssc_mode); in cdns_torrent_phy_probe()
2874 if (cdns_phy->phys[node].phy_type == TYPE_DP) { in cdns_torrent_phy_probe()
2875 switch (cdns_phy->phys[node].num_lanes) { in cdns_torrent_phy_probe()
2883 cdns_phy->phys[node].num_lanes); in cdns_torrent_phy_probe()
2884 ret = -EINVAL; in cdns_torrent_phy_probe()
2888 cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE; in cdns_torrent_phy_probe()
2889 of_property_read_u32(child, "cdns,max-bit-rate", in cdns_torrent_phy_probe()
2890 &cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2892 switch (cdns_phy->max_bit_rate) { in cdns_torrent_phy_probe()
2905 cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2906 ret = -EINVAL; in cdns_torrent_phy_probe()
2911 cdns_phy->base = devm_platform_ioremap_resource(pdev, 1); in cdns_torrent_phy_probe()
2912 if (IS_ERR(cdns_phy->base)) { in cdns_torrent_phy_probe()
2913 ret = PTR_ERR(cdns_phy->base); in cdns_torrent_phy_probe()
2930 cdns_phy->max_bit_rate / 1000, in cdns_torrent_phy_probe()
2931 cdns_phy->max_bit_rate % 1000); in cdns_torrent_phy_probe()
2933 gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2934 gphy->attrs.max_link_rate = cdns_phy->max_bit_rate; in cdns_torrent_phy_probe()
2935 gphy->attrs.mode = PHY_MODE_DP; in cdns_torrent_phy_probe()
2938 cdns_phy->phys[node].phy = gphy; in cdns_torrent_phy_probe()
2939 phy_set_drvdata(gphy, &cdns_phy->phys[node]); in cdns_torrent_phy_probe()
2943 cdns_phy->nsubnodes = node; in cdns_torrent_phy_probe()
2947 ret = -EINVAL; in cdns_torrent_phy_probe()
2951 if (cdns_phy->nsubnodes > 1 && !already_configured) { in cdns_torrent_phy_probe()
2963 if (cdns_phy->nsubnodes > 1) in cdns_torrent_phy_probe()
2964 dev_dbg(dev, "Multi-link: %s (%d lanes) & %s (%d lanes)", in cdns_torrent_phy_probe()
2965 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
2966 cdns_phy->phys[0].num_lanes, in cdns_torrent_phy_probe()
2967 cdns_torrent_get_phy_type(cdns_phy->phys[1].phy_type), in cdns_torrent_phy_probe()
2968 cdns_phy->phys[1].num_lanes); in cdns_torrent_phy_probe()
2971 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
2972 cdns_phy->phys[0].num_lanes); in cdns_torrent_phy_probe()
2980 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_probe()
2982 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2983 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_probe()
2994 reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_remove()
2995 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_remove()
2996 for (i = 0; i < cdns_phy->nsubnodes; i++) { in cdns_torrent_phy_remove()
2997 reset_control_assert(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
2998 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
3001 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_remove()
3037 /* TI USXGMII configuration: Enable cmn_refclk_rcv_out_en */
3069 /* Single link USXGMII, 156.25 MHz Ref clk, no SSC */
3187 /* DP Multilink, 100 MHz Ref clk, no SSC */
3245 /* Single DP, 19.2 MHz Ref clk, no SSC */
3316 /* Single DP, 25 MHz Ref clk, no SSC */
3387 /* Single DP, 100 MHz Ref clk, no SSC */
3459 /* PCIe and USB Unique SSC link configuration */
3494 /* USB 100 MHz Ref clk, internal SSC */
3587 /* USB 100 MHz Ref clk, no SSC */
3658 /* Single link USB, 100 MHz Ref clk, internal SSC */
3705 /* PCIe and SGMII/QSGMII Unique SSC link configuration */
3740 /* SGMII 100 MHz Ref clk, no SSC */
3814 /* SGMII 100 MHz Ref clk, internal SSC */
3871 /* QSGMII 100 MHz Ref clk, no SSC */
3947 /* QSGMII 100 MHz Ref clk, internal SSC */
4026 /* Multi link PCIe, 100 MHz Ref clk, internal SSC */
4081 /* Single link PCIe, 100 MHz Ref clk, internal SSC */
4136 /* PCIe, 100 MHz Ref clk, no SSC & external SSC */
4559 .compatible = "cdns,torrent-phy",
4563 .compatible = "ti,j721e-serdes-10g",
4574 .name = "cdns-torrent-phy",