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()
1171 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_run()
1180 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_run()
1181 dev_err(cdns_phy->dev, in cdns_torrent_dp_run()
1182 "timeout waiting for link PLL clock enable ack\n"); in cdns_torrent_dp_run()
1203 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_wait_pma_cmn_ready()
1207 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_wait_pma_cmn_ready()
1208 dev_err(cdns_phy->dev, in cdns_torrent_dp_wait_pma_cmn_ready()
1210 return -ETIMEDOUT; in cdns_torrent_dp_wait_pma_cmn_ready()
1250 if (cdns_phy->dp_pll & DP_PLL0) in cdns_torrent_dp_pma_cmn_rate()
1251 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1254 if (cdns_phy->dp_pll & DP_PLL1) in cdns_torrent_dp_pma_cmn_rate()
1255 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1258 /* PMA lane configuration to deal with multi-link operation */ in cdns_torrent_dp_pma_cmn_rate()
1260 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + i], in cdns_torrent_dp_pma_cmn_rate()
1277 * re-programming the new data rate. in cdns_torrent_dp_configure_rate()
1279 ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val); in cdns_torrent_dp_configure_rate()
1282 field_val &= ~(cdns_phy->dp_pll); in cdns_torrent_dp_configure_rate()
1283 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val); in cdns_torrent_dp_configure_rate()
1286 * Wait for PLL ready de-assertion. in cdns_torrent_dp_configure_rate()
1287 * For PLL0 - PHY_PMA_CMN_CTRL2[2] == 1 in cdns_torrent_dp_configure_rate()
1288 * For PLL1 - PHY_PMA_CMN_CTRL2[3] == 1 in cdns_torrent_dp_configure_rate()
1290 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_configure_rate()
1291 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1299 if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1) { in cdns_torrent_dp_configure_rate()
1300 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1309 /* DP Rate Change - VCO Output settings. */ in cdns_torrent_dp_configure_rate()
1310 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_configure_rate()
1312 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1313 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_configure_rate()
1315 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1316 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_configure_rate()
1318 cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1320 cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, dp->link_rate, dp->lanes); in cdns_torrent_dp_configure_rate()
1322 /* Enable the associated PLL (cmn_pll0_en or cmn_pll1_en) */ in cdns_torrent_dp_configure_rate()
1323 ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val); in cdns_torrent_dp_configure_rate()
1326 field_val |= cdns_phy->dp_pll; in cdns_torrent_dp_configure_rate()
1327 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val); in cdns_torrent_dp_configure_rate()
1331 * For PLL0 - PHY_PMA_CMN_CTRL2[0] == 1 in cdns_torrent_dp_configure_rate()
1332 * For PLL1 - PHY_PMA_CMN_CTRL2[1] == 1 in cdns_torrent_dp_configure_rate()
1334 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_configure_rate()
1335 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1343 if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1) in cdns_torrent_dp_configure_rate()
1344 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1361 if (dp->set_rate) { in cdns_torrent_dp_verify_config()
1362 switch (dp->link_rate) { in cdns_torrent_dp_verify_config()
1374 return -EINVAL; in cdns_torrent_dp_verify_config()
1379 switch (dp->lanes) { in cdns_torrent_dp_verify_config()
1386 return -EINVAL; in cdns_torrent_dp_verify_config()
1390 if (dp->lanes > inst->num_lanes) in cdns_torrent_dp_verify_config()
1391 return -EINVAL; in cdns_torrent_dp_verify_config()
1394 * If changing voltages is required, check swing and pre-emphasis in cdns_torrent_dp_verify_config()
1395 * levels, per-lane. in cdns_torrent_dp_verify_config()
1397 if (dp->set_voltages) { in cdns_torrent_dp_verify_config()
1399 for (i = 0; i < dp->lanes; i++) { in cdns_torrent_dp_verify_config()
1400 if (dp->voltage[i] > 3 || dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
1401 return -EINVAL; in cdns_torrent_dp_verify_config()
1403 /* Sum of voltage swing and pre-emphasis levels cannot in cdns_torrent_dp_verify_config()
1406 if (dp->voltage[i] + dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
1407 return -EINVAL; in cdns_torrent_dp_verify_config()
1414 /* Set power state A0 and PLL clock enable to 0 on enabled lanes. */
1419 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_a0_pll()
1428 << PHY_POWER_STATE_LN(inst->mlane + i)); in cdns_torrent_dp_set_a0_pll()
1430 pll_clk_en &= ~(0x01U << (inst->mlane + i)); in cdns_torrent_dp_set_a0_pll()
1444 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_lanes()
1445 u8 lane_mask = (1 << dp->lanes) - 1; in cdns_torrent_dp_set_lanes()
1447 u32 clane = inst->mlane; in cdns_torrent_dp_set_lanes()
1453 pma_tx_elec_idle_mask = ((1 << inst->num_lanes) - 1) << clane; in cdns_torrent_dp_set_lanes()
1471 * and powered down when re-enabling the link in cdns_torrent_dp_set_lanes()
1473 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1476 for (i = 1; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1481 cdns_torrent_dp_set_a0_pll(cdns_phy, inst, dp->lanes); in cdns_torrent_dp_set_lanes()
1484 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1487 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1504 ret = cdns_torrent_dp_run(cdns_phy, inst, dp->lanes); in cdns_torrent_dp_set_lanes()
1516 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes, in cdns_torrent_dp_set_rate()
1533 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes, in cdns_torrent_dp_set_rate()
1537 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes, in cdns_torrent_dp_set_rate()
1546 /* Configure voltage swing and pre-emphasis for all enabled lanes. */
1554 for (lane = 0; lane < dp->lanes; lane++) { in cdns_torrent_dp_set_voltages()
1555 val = cdns_torrent_phy_read(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()
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]].diag_tx_drv; 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()
1570 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].mgnfs_mult; in cdns_torrent_dp_set_voltages()
1571 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1574 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].cpost_mult; in cdns_torrent_dp_set_voltages()
1575 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1579 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1586 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1595 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_configure()
1598 ret = cdns_torrent_dp_verify_config(inst, &opts->dp); in cdns_torrent_dp_configure()
1600 dev_err(&phy->dev, "invalid params for phy configure\n"); in cdns_torrent_dp_configure()
1604 if (opts->dp.set_lanes) { in cdns_torrent_dp_configure()
1605 ret = cdns_torrent_dp_set_lanes(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1607 dev_err(&phy->dev, "cdns_torrent_dp_set_lanes failed\n"); in cdns_torrent_dp_configure()
1612 if (opts->dp.set_rate) { in cdns_torrent_dp_configure()
1613 ret = cdns_torrent_dp_set_rate(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1615 dev_err(&phy->dev, "cdns_torrent_dp_set_rate failed\n"); in cdns_torrent_dp_configure()
1620 if (opts->dp.set_voltages) in cdns_torrent_dp_configure()
1621 cdns_torrent_dp_set_voltages(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1629 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_on()
1633 if (cdns_phy->nsubnodes == 1) { in cdns_torrent_phy_on()
1635 reset_control_deassert(inst->lnk_rst); in cdns_torrent_phy_on()
1638 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_on()
1647 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1, in cdns_torrent_phy_on()
1651 dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n"); in cdns_torrent_phy_on()
1655 if (inst->phy_type == TYPE_PCIE || inst->phy_type == TYPE_USB) { in cdns_torrent_phy_on()
1656 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pcs_iso_link_ctrl_1[inst->mlane], in cdns_torrent_phy_on()
1659 if (ret == -ETIMEDOUT) { in cdns_torrent_phy_on()
1660 dev_err(cdns_phy->dev, "Timeout waiting for PHY status ready\n"); in cdns_torrent_phy_on()
1671 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_off()
1674 if (cdns_phy->nsubnodes != 1) in cdns_torrent_phy_off()
1677 ret = reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_off()
1681 return reset_control_assert(inst->lnk_rst); in cdns_torrent_phy_off()
1687 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_common_init()
1691 cdns_torrent_dp_write(regmap, PHY_AUX_CTRL, 0x0003); /* enable AUX */ in cdns_torrent_dp_common_init()
1695 * Set lines pll clk enable to 0 in cdns_torrent_dp_common_init()
1697 cdns_torrent_dp_set_a0_pll(cdns_phy, inst, inst->num_lanes); in cdns_torrent_dp_common_init()
1703 lane_bits = (1 << inst->num_lanes) - 1; in cdns_torrent_dp_common_init()
1717 * Initialize PHY with max supported link rate, without SSC. in cdns_torrent_dp_common_init()
1719 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_common_init()
1721 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1723 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_common_init()
1725 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1727 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_common_init()
1729 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1732 cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1733 inst->num_lanes); in cdns_torrent_dp_common_init()
1736 regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1); in cdns_torrent_dp_common_init()
1753 ret = cdns_torrent_dp_run(cdns_phy, inst, inst->num_lanes); in cdns_torrent_dp_start()
1761 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_init()
1764 switch (cdns_phy->ref_clk_rate) { in cdns_torrent_dp_init()
1771 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_init()
1772 return -EINVAL; in cdns_torrent_dp_init()
1788 if (cdns_phy->ref_clk_rate != CLK_100_MHZ) { in cdns_torrent_dp_multilink_init()
1789 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_multilink_init()
1790 return -EINVAL; in cdns_torrent_dp_multilink_init()
1802 regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 1); in cdns_torrent_derived_refclk_enable()
1803 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 1); in cdns_torrent_derived_refclk_enable()
1812 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 0); in cdns_torrent_derived_refclk_disable()
1813 regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 0); in cdns_torrent_derived_refclk_disable()
1821 regmap_field_read(derived_refclk->cmn_cdiag_refclk_ovrd_4, &val); in cdns_torrent_derived_refclk_is_enabled()
1827 .enable = cdns_torrent_derived_refclk_enable,
1835 struct device *dev = cdns_phy->dev; in cdns_torrent_derived_refclk_register()
1845 return -ENOMEM; in cdns_torrent_derived_refclk_register()
1856 init = &derived_refclk->clk_data; in cdns_torrent_derived_refclk_register()
1860 init->parent_names = &parent_name; in cdns_torrent_derived_refclk_register()
1861 init->num_parents = 1; in cdns_torrent_derived_refclk_register()
1863 init->ops = &cdns_torrent_derived_refclk_ops; in cdns_torrent_derived_refclk_register()
1864 init->flags = 0; in cdns_torrent_derived_refclk_register()
1865 init->name = clk_name; in cdns_torrent_derived_refclk_register()
1867 derived_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0; in cdns_torrent_derived_refclk_register()
1868 derived_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4; in cdns_torrent_derived_refclk_register()
1870 derived_refclk->hw.init = init; in cdns_torrent_derived_refclk_register()
1872 hw = &derived_refclk->hw; in cdns_torrent_derived_refclk_register()
1877 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_DERIVED_REFCLK] = hw; in cdns_torrent_derived_refclk_register()
1886 regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 1); in cdns_torrent_received_refclk_enable()
1895 regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 0); in cdns_torrent_received_refclk_disable()
1903 regmap_field_read(received_refclk->phy_pipe_cmn_ctrl1_0, &val); in cdns_torrent_received_refclk_is_enabled()
1904 regmap_field_read(received_refclk->cmn_cdiag_refclk_ovrd_4, &cmn_val); in cdns_torrent_received_refclk_is_enabled()
1910 .enable = cdns_torrent_received_refclk_enable,
1918 struct device *dev = cdns_phy->dev; in cdns_torrent_received_refclk_register()
1928 return -ENOMEM; in cdns_torrent_received_refclk_register()
1939 init = &received_refclk->clk_data; in cdns_torrent_received_refclk_register()
1943 init->parent_names = &parent_name; in cdns_torrent_received_refclk_register()
1944 init->num_parents = 1; in cdns_torrent_received_refclk_register()
1946 init->ops = &cdns_torrent_received_refclk_ops; in cdns_torrent_received_refclk_register()
1947 init->flags = 0; in cdns_torrent_received_refclk_register()
1948 init->name = clk_name; in cdns_torrent_received_refclk_register()
1950 received_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0; in cdns_torrent_received_refclk_register()
1951 received_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4; in cdns_torrent_received_refclk_register()
1953 received_refclk->hw.init = init; in cdns_torrent_received_refclk_register()
1955 hw = &received_refclk->hw; in cdns_torrent_received_refclk_register()
1960 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_RECEIVED_REFCLK] = hw; in cdns_torrent_received_refclk_register()
1969 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_6], 0); in cdns_torrent_refclk_driver_enable()
1970 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_5], 1); in cdns_torrent_refclk_driver_enable()
1971 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 0); in cdns_torrent_refclk_driver_enable()
1980 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 1); in cdns_torrent_refclk_driver_disable()
1988 regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], &val); in cdns_torrent_refclk_driver_is_enabled()
1998 regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], &val); in cdns_torrent_refclk_driver_get_parent()
2008 return regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], val); in cdns_torrent_refclk_driver_set_parent()
2012 .enable = cdns_torrent_refclk_driver_enable,
2023 struct device *dev = cdns_phy->dev; in cdns_torrent_refclk_driver_register()
2035 return -ENOMEM; in cdns_torrent_refclk_driver_register()
2040 return -ENOMEM; in cdns_torrent_refclk_driver_register()
2043 hw = cdns_phy->clk_hw_data->hws[refclk_driver_parent_index[i]]; in cdns_torrent_refclk_driver_register()
2046 return IS_ERR(hw) ? PTR_ERR(hw) : -ENOENT; in cdns_torrent_refclk_driver_register()
2054 init = &refclk_driver->clk_data; in cdns_torrent_refclk_driver_register()
2056 init->ops = &cdns_torrent_refclk_driver_ops; in cdns_torrent_refclk_driver_register()
2057 init->flags = CLK_SET_RATE_NO_REPARENT; in cdns_torrent_refclk_driver_register()
2058 init->parent_names = parent_names; in cdns_torrent_refclk_driver_register()
2059 init->num_parents = num_parents; in cdns_torrent_refclk_driver_register()
2060 init->name = clk_name; in cdns_torrent_refclk_driver_register()
2062 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_refclk_driver_register()
2070 refclk_driver->cmn_fields[i] = field; in cdns_torrent_refclk_driver_register()
2073 /* Enable Derived reference clock as default */ in cdns_torrent_refclk_driver_register()
2074 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], 1); in cdns_torrent_refclk_driver_register()
2076 refclk_driver->hw.init = init; in cdns_torrent_refclk_driver_register()
2078 hw = &refclk_driver->hw; in cdns_torrent_refclk_driver_register()
2083 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw; in cdns_torrent_refclk_driver_register()
2097 return ERR_PTR(-ENOMEM); in cdns_regmap_init()
2099 ctx->dev = dev; in cdns_regmap_init()
2100 ctx->base = base + block_offset; in cdns_regmap_init()
2101 ctx->reg_offset_shift = reg_offset_shift; in cdns_regmap_init()
2108 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regfield_init()
2112 regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_regfield_init()
2118 cdns_phy->phy_reset_ctrl = field; in cdns_torrent_dp_regfield_init()
2125 struct device *dev = cdns_phy->dev; in cdns_torrent_regfield_init()
2130 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
2136 cdns_phy->phy_pll_cfg = field; in cdns_torrent_regfield_init()
2138 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
2144 cdns_phy->phy_pipe_cmn_ctrl1_0 = field; in cdns_torrent_regfield_init()
2146 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_regfield_init()
2152 cdns_phy->cmn_cdiag_refclk_ovrd_4 = field; in cdns_torrent_regfield_init()
2154 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2160 cdns_phy->phy_pma_cmn_ctrl_1 = field; in cdns_torrent_regfield_init()
2162 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2168 cdns_phy->phy_pma_cmn_ctrl_2 = field; in cdns_torrent_regfield_init()
2170 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2176 cdns_phy->phy_pma_pll_raw_ctrl = field; in cdns_torrent_regfield_init()
2179 regmap = cdns_phy->regmap_phy_pcs_lane_cdb[i]; in cdns_torrent_regfield_init()
2185 cdns_phy->phy_pcs_iso_link_ctrl_1[i] = field; in cdns_torrent_regfield_init()
2193 void __iomem *base = cdns_phy->base; in cdns_torrent_dp_regmap_init()
2194 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regmap_init()
2199 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_dp_regmap_init()
2209 cdns_phy->regmap_dptx_phy_reg = regmap; in cdns_torrent_dp_regmap_init()
2216 void __iomem *sd_base = cdns_phy->sd_base; in cdns_torrent_regmap_init()
2218 struct device *dev = cdns_phy->dev; in cdns_torrent_regmap_init()
2223 block_offset_shift = cdns_phy->init_data->block_offset_shift; in cdns_torrent_regmap_init()
2224 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_regmap_init()
2236 cdns_phy->regmap_tx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2247 cdns_phy->regmap_rx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2258 cdns_phy->regmap_phy_pcs_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2269 cdns_phy->regmap_common_cdb = regmap; in cdns_torrent_regmap_init()
2279 cdns_phy->regmap_phy_pcs_common_cdb = regmap; in cdns_torrent_regmap_init()
2289 cdns_phy->regmap_phy_pma_common_cdb = regmap; in cdns_torrent_regmap_init()
2296 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_init()
2297 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_init()
2299 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_init()
2302 enum cdns_torrent_phy_type phy_type = inst->phy_type; in cdns_torrent_phy_init()
2303 enum cdns_torrent_ssc_mode ssc = inst->ssc_mode; in cdns_torrent_phy_init() local
2311 if (cdns_phy->nsubnodes > 1) { in cdns_torrent_phy_init()
2322 ssc = NO_SSC; in cdns_torrent_phy_init()
2325 link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl, in cdns_torrent_phy_init()
2330 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2331 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_init()
2332 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
2338 regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val); in cdns_torrent_phy_init()
2345 xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl, in cdns_torrent_phy_init()
2350 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_init()
2351 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_init()
2352 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
2353 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2361 pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl, in cdns_torrent_phy_init()
2366 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2367 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_init()
2368 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_init()
2375 phy_pma_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->phy_pma_cmn_vals_tbl, in cdns_torrent_phy_init()
2380 reg_pairs = phy_pma_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2381 num_regs = phy_pma_cmn_vals->num_regs; in cdns_torrent_phy_init()
2382 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_phy_init()
2389 cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl, in cdns_torrent_phy_init()
2392 ssc); in cdns_torrent_phy_init()
2394 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2395 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_init()
2396 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
2403 tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl, in cdns_torrent_phy_init()
2406 ssc); in cdns_torrent_phy_init()
2408 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
2409 num_regs = tx_ln_vals->num_regs; in cdns_torrent_phy_init()
2410 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
2411 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2419 rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl, in cdns_torrent_phy_init()
2422 ssc); in cdns_torrent_phy_init()
2424 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
2425 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_init()
2426 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
2427 regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2464 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_configure_multilink()
2466 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_configure_multilink()
2472 enum cdns_torrent_ssc_mode ssc; in cdns_torrent_phy_configure_multilink() local
2477 if (cdns_phy->nsubnodes != 2) in cdns_torrent_phy_configure_multilink()
2478 return -EINVAL; in cdns_torrent_phy_configure_multilink()
2480 phy_t1 = cdns_phy->phys[0].phy_type; in cdns_torrent_phy_configure_multilink()
2481 phy_t2 = cdns_phy->phys[1].phy_type; in cdns_torrent_phy_configure_multilink()
2485 * values as [phy_t1][phy_t2][ssc]. in cdns_torrent_phy_configure_multilink()
2487 for (node = 0; node < cdns_phy->nsubnodes; node++) { in cdns_torrent_phy_configure_multilink()
2492 * Get the array values as [phy_t2][phy_t1][ssc]. in cdns_torrent_phy_configure_multilink()
2497 mlane = cdns_phy->phys[node].mlane; in cdns_torrent_phy_configure_multilink()
2498 ssc = cdns_phy->phys[node].ssc_mode; in cdns_torrent_phy_configure_multilink()
2499 num_lanes = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_configure_multilink()
2505 * values should be same for [phy_t1][phy_t2][ssc] and in cdns_torrent_phy_configure_multilink()
2506 * [phy_t2][phy_t1][ssc]. in cdns_torrent_phy_configure_multilink()
2511 link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2515 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2516 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2517 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2523 regmap_field_write(cdns_phy->phy_pll_cfg, in cdns_torrent_phy_configure_multilink()
2531 xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl, in cdns_torrent_phy_configure_multilink()
2535 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2536 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2538 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2546 pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2550 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2551 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2552 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_configure_multilink()
2559 cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2561 phy_t1, phy_t2, ssc); in cdns_torrent_phy_configure_multilink()
2563 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2564 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2565 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2572 tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl, in cdns_torrent_phy_configure_multilink()
2574 phy_t1, phy_t2, ssc); in cdns_torrent_phy_configure_multilink()
2576 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2577 num_regs = tx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2579 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2587 rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl, in cdns_torrent_phy_configure_multilink()
2589 phy_t1, phy_t2, ssc); in cdns_torrent_phy_configure_multilink()
2591 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2592 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2594 regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2607 reset_control_deassert(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_configure_multilink()
2611 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_configure_multilink()
2620 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_cleanup()
2622 of_clk_del_provider(dev->of_node); in cdns_torrent_clk_cleanup()
2627 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_register()
2628 struct device_node *node = dev->of_node; in cdns_torrent_clk_register()
2634 return -ENOMEM; in cdns_torrent_clk_register()
2636 data->num = CDNS_TORRENT_OUTPUT_CLOCKS; in cdns_torrent_clk_register()
2637 cdns_phy->clk_hw_data = data; in cdns_torrent_clk_register()
2659 dev_err(dev, "Failed to add clock provider: %s\n", node->name); in cdns_torrent_clk_register()
2668 struct device *dev = cdns_phy->dev; in cdns_torrent_reset()
2670 cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0); in cdns_torrent_reset()
2671 if (IS_ERR(cdns_phy->phy_rst)) { in cdns_torrent_reset()
2673 dev->of_node->full_name); in cdns_torrent_reset()
2674 return PTR_ERR(cdns_phy->phy_rst); in cdns_torrent_reset()
2677 cdns_phy->apb_rst = devm_reset_control_get_optional_exclusive(dev, "torrent_apb"); in cdns_torrent_reset()
2678 if (IS_ERR(cdns_phy->apb_rst)) { in cdns_torrent_reset()
2680 dev->of_node->full_name); in cdns_torrent_reset()
2681 return PTR_ERR(cdns_phy->apb_rst); in cdns_torrent_reset()
2689 struct device *dev = cdns_phy->dev; in cdns_torrent_clk()
2693 cdns_phy->clk = devm_clk_get(dev, "refclk"); in cdns_torrent_clk()
2694 if (IS_ERR(cdns_phy->clk)) { in cdns_torrent_clk()
2696 return PTR_ERR(cdns_phy->clk); in cdns_torrent_clk()
2699 ret = clk_prepare_enable(cdns_phy->clk); in cdns_torrent_clk()
2701 dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); in cdns_torrent_clk()
2705 ref_clk_rate = clk_get_rate(cdns_phy->clk); in cdns_torrent_clk()
2707 dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); in cdns_torrent_clk()
2708 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_clk()
2709 return -EINVAL; in cdns_torrent_clk()
2714 cdns_phy->ref_clk_rate = CLK_19_2_MHZ; in cdns_torrent_clk()
2717 cdns_phy->ref_clk_rate = CLK_25_MHZ; in cdns_torrent_clk()
2720 cdns_phy->ref_clk_rate = CLK_100_MHZ; in cdns_torrent_clk()
2723 cdns_phy->ref_clk_rate = CLK_156_25_MHZ; in cdns_torrent_clk()
2726 dev_err(cdns_phy->dev, "Invalid Ref Clock Rate\n"); in cdns_torrent_clk()
2727 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_clk()
2728 return -EINVAL; in cdns_torrent_clk()
2737 struct device *dev = &pdev->dev; in cdns_torrent_phy_probe()
2750 return -EINVAL; in cdns_torrent_phy_probe()
2754 return -ENOMEM; in cdns_torrent_phy_probe()
2757 cdns_phy->dev = dev; in cdns_torrent_phy_probe()
2758 cdns_phy->init_data = data; in cdns_torrent_phy_probe()
2760 cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0); in cdns_torrent_phy_probe()
2761 if (IS_ERR(cdns_phy->sd_base)) in cdns_torrent_phy_probe()
2762 return PTR_ERR(cdns_phy->sd_base); in cdns_torrent_phy_probe()
2764 subnodes = of_get_available_child_count(dev->of_node); in cdns_torrent_phy_probe()
2767 return -EINVAL; in cdns_torrent_phy_probe()
2782 regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); in cdns_torrent_phy_probe()
2793 /* Enable APB */ in cdns_torrent_phy_probe()
2794 reset_control_deassert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2797 for_each_available_child_of_node(dev->of_node, child) { in cdns_torrent_phy_probe()
2804 cdns_phy->phys[node].lnk_rst = in cdns_torrent_phy_probe()
2806 if (IS_ERR(cdns_phy->phys[node].lnk_rst)) { in cdns_torrent_phy_probe()
2808 child->full_name); in cdns_torrent_phy_probe()
2809 ret = PTR_ERR(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_probe()
2814 &cdns_phy->phys[node].mlane)) { in cdns_torrent_phy_probe()
2815 dev_err(dev, "%s: No \"reg\"-property.\n", in cdns_torrent_phy_probe()
2816 child->full_name); in cdns_torrent_phy_probe()
2817 ret = -EINVAL; in cdns_torrent_phy_probe()
2821 if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) { in cdns_torrent_phy_probe()
2822 dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n", in cdns_torrent_phy_probe()
2823 child->full_name); in cdns_torrent_phy_probe()
2824 ret = -EINVAL; in cdns_torrent_phy_probe()
2830 cdns_phy->phys[node].phy_type = TYPE_PCIE; in cdns_torrent_phy_probe()
2833 cdns_phy->phys[node].phy_type = TYPE_DP; in cdns_torrent_phy_probe()
2836 cdns_phy->phys[node].phy_type = TYPE_SGMII; in cdns_torrent_phy_probe()
2839 cdns_phy->phys[node].phy_type = TYPE_QSGMII; in cdns_torrent_phy_probe()
2842 cdns_phy->phys[node].phy_type = TYPE_USB; in cdns_torrent_phy_probe()
2845 cdns_phy->phys[node].phy_type = TYPE_USXGMII; in cdns_torrent_phy_probe()
2849 ret = -EINVAL; in cdns_torrent_phy_probe()
2853 if (of_property_read_u32(child, "cdns,num-lanes", in cdns_torrent_phy_probe()
2854 &cdns_phy->phys[node].num_lanes)) { in cdns_torrent_phy_probe()
2855 dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n", in cdns_torrent_phy_probe()
2856 child->full_name); in cdns_torrent_phy_probe()
2857 ret = -EINVAL; in cdns_torrent_phy_probe()
2861 total_num_lanes += cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2863 /* Get SSC mode */ in cdns_torrent_phy_probe()
2864 cdns_phy->phys[node].ssc_mode = NO_SSC; in cdns_torrent_phy_probe()
2865 of_property_read_u32(child, "cdns,ssc-mode", in cdns_torrent_phy_probe()
2866 &cdns_phy->phys[node].ssc_mode); in cdns_torrent_phy_probe()
2877 if (cdns_phy->phys[node].phy_type == TYPE_DP) { in cdns_torrent_phy_probe()
2878 switch (cdns_phy->phys[node].num_lanes) { in cdns_torrent_phy_probe()
2886 cdns_phy->phys[node].num_lanes); in cdns_torrent_phy_probe()
2887 ret = -EINVAL; in cdns_torrent_phy_probe()
2891 cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE; in cdns_torrent_phy_probe()
2892 of_property_read_u32(child, "cdns,max-bit-rate", in cdns_torrent_phy_probe()
2893 &cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2895 switch (cdns_phy->max_bit_rate) { in cdns_torrent_phy_probe()
2908 cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2909 ret = -EINVAL; in cdns_torrent_phy_probe()
2914 cdns_phy->base = devm_platform_ioremap_resource(pdev, 1); in cdns_torrent_phy_probe()
2915 if (IS_ERR(cdns_phy->base)) { in cdns_torrent_phy_probe()
2916 ret = PTR_ERR(cdns_phy->base); in cdns_torrent_phy_probe()
2933 cdns_phy->max_bit_rate / 1000, in cdns_torrent_phy_probe()
2934 cdns_phy->max_bit_rate % 1000); in cdns_torrent_phy_probe()
2936 gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2937 gphy->attrs.max_link_rate = cdns_phy->max_bit_rate; in cdns_torrent_phy_probe()
2938 gphy->attrs.mode = PHY_MODE_DP; in cdns_torrent_phy_probe()
2941 cdns_phy->phys[node].phy = gphy; in cdns_torrent_phy_probe()
2942 phy_set_drvdata(gphy, &cdns_phy->phys[node]); in cdns_torrent_phy_probe()
2946 cdns_phy->nsubnodes = node; in cdns_torrent_phy_probe()
2950 ret = -EINVAL; in cdns_torrent_phy_probe()
2954 if (cdns_phy->nsubnodes > 1 && !already_configured) { in cdns_torrent_phy_probe()
2966 if (cdns_phy->nsubnodes > 1) in cdns_torrent_phy_probe()
2967 dev_dbg(dev, "Multi-link: %s (%d lanes) & %s (%d lanes)", in cdns_torrent_phy_probe()
2968 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
2969 cdns_phy->phys[0].num_lanes, in cdns_torrent_phy_probe()
2970 cdns_torrent_get_phy_type(cdns_phy->phys[1].phy_type), in cdns_torrent_phy_probe()
2971 cdns_phy->phys[1].num_lanes); in cdns_torrent_phy_probe()
2974 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
2975 cdns_phy->phys[0].num_lanes); in cdns_torrent_phy_probe()
2983 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_probe()
2985 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2986 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_probe()
2997 reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_remove()
2998 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_remove()
2999 for (i = 0; i < cdns_phy->nsubnodes; i++) { in cdns_torrent_phy_remove()
3000 reset_control_assert(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
3001 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
3004 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_remove()
3040 /* TI USXGMII configuration: Enable cmn_refclk_rcv_out_en */
3072 /* Single link USXGMII, 156.25 MHz Ref clk, no SSC */
3190 /* DP Multilink, 100 MHz Ref clk, no SSC */
3248 /* Single DP, 19.2 MHz Ref clk, no SSC */
3319 /* Single DP, 25 MHz Ref clk, no SSC */
3390 /* Single DP, 100 MHz Ref clk, no SSC */
3462 /* PCIe and USB Unique SSC link configuration */
3497 /* USB 100 MHz Ref clk, internal SSC */
3590 /* USB 100 MHz Ref clk, no SSC */
3661 /* Single link USB, 100 MHz Ref clk, internal SSC */
3708 /* PCIe and SGMII/QSGMII Unique SSC link configuration */
3743 /* SGMII 100 MHz Ref clk, no SSC */
3817 /* SGMII 100 MHz Ref clk, internal SSC */
3874 /* QSGMII 100 MHz Ref clk, no SSC */
3950 /* QSGMII 100 MHz Ref clk, internal SSC */
4029 /* Multi link PCIe, 100 MHz Ref clk, internal SSC */
4084 /* Single link PCIe, 100 MHz Ref clk, internal SSC */
4139 /* PCIe, 100 MHz Ref clk, no SSC & external SSC */
4562 .compatible = "cdns,torrent-phy",
4566 .compatible = "ti,j721e-serdes-10g",
4577 .name = "cdns-torrent-phy",