Lines Matching +full:sgmii +full:- +full:enable +full:- +full:pll

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",
468 for (i = 0; i < tbl->num_entries; i++) { in cdns_torrent_get_tbl_vals()
469 if (tbl->entries[i].key == key) in cdns_torrent_get_tbl_vals()
470 return tbl->entries[i].vals; in cdns_torrent_get_tbl_vals()
479 u32 offset = reg << ctx->reg_offset_shift; in cdns_regmap_write()
481 writew(val, ctx->base + offset); in cdns_regmap_write()
489 u32 offset = reg << ctx->reg_offset_shift; in cdns_regmap_read()
491 *val = readw(ctx->base + offset); in cdns_regmap_read()
501 writel(val, ctx->base + offset); in cdns_regmap_dptx_write()
512 *val = readl(ctx->base + offset); in cdns_regmap_dptx_read()
627 * Structure used to store values of PHY registers for voltage-related
628 * coefficients, for particular voltage swing and pre-emphasis level. Values
641 * Array consists of values of voltage-related registers for sd0801 PHY. A value
645 /* voltage swing 0, pre-emphasis 0->3 */
656 /* voltage swing 1, pre-emphasis 0->3 */
667 /* voltage swing 2, pre-emphasis 0->3 */
678 /* voltage swing 3, pre-emphasis 0->3 */
698 return "SGMII"; in cdns_torrent_get_phy_type()
718 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_19_2mhz()
734 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
838 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_25mhz()
854 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
958 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
965 if (cdns_phy->dp_pll & DP_PLL0) in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
968 if (cdns_phy->dp_pll & DP_PLL1) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
978 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
989 if (cdns_phy->dp_pll & DP_PLL1) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1004 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1015 if (cdns_phy->dp_pll & DP_PLL1) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1029 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1039 if (cdns_phy->dp_pll & DP_PLL1) { in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
1053 /* Set PLL used for DP configuration */
1060 cdns_phy->dp_pll = DP_PLL1; in cdns_torrent_dp_get_pll()
1064 cdns_phy->dp_pll = DP_PLL0; in cdns_torrent_dp_get_pll()
1067 cdns_phy->dp_pll = DP_PLL0 | DP_PLL1; in cdns_torrent_dp_get_pll()
1070 dev_err(cdns_phy->dev, "Unsupported PHY configuration\n"); in cdns_torrent_dp_get_pll()
1071 return -EINVAL; in cdns_torrent_dp_get_pll()
1078 * Enable or disable PLL for selected lanes.
1083 bool enable) in cdns_torrent_dp_set_pll_en() argument
1085 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_pll_en()
1090 * Used to determine, which bits to check for or enable in in cdns_torrent_dp_set_pll_en()
1094 /* Used to enable or disable lanes. */ in cdns_torrent_dp_set_pll_en()
1100 if (enable) { in cdns_torrent_dp_set_pll_en()
1101 pll_bits = ((1 << dp->lanes) - 1); in cdns_torrent_dp_set_pll_en()
1105 pll_bits = ((1 << inst->num_lanes) - 1); in cdns_torrent_dp_set_pll_en()
1133 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_power_state()
1175 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_run()
1184 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_run()
1185 dev_err(cdns_phy->dev, in cdns_torrent_dp_run()
1186 "timeout waiting for link PLL clock enable ack\n"); in cdns_torrent_dp_run()
1207 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_wait_pma_cmn_ready()
1211 if (ret == -ETIMEDOUT) { in cdns_torrent_dp_wait_pma_cmn_ready()
1212 dev_err(cdns_phy->dev, in cdns_torrent_dp_wait_pma_cmn_ready()
1214 return -ETIMEDOUT; in cdns_torrent_dp_wait_pma_cmn_ready()
1254 if (cdns_phy->dp_pll & DP_PLL0) 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 if (cdns_phy->dp_pll & DP_PLL1) in cdns_torrent_dp_pma_cmn_rate()
1259 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1262 /* PMA lane configuration to deal with multi-link operation */ in cdns_torrent_dp_pma_cmn_rate()
1264 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + i], in cdns_torrent_dp_pma_cmn_rate()
1270 * set and PLL disable request was processed.
1280 * Disable the associated PLL (cmn_pll0_en or cmn_pll1_en) before in cdns_torrent_dp_configure_rate()
1281 * re-programming the new data rate. in cdns_torrent_dp_configure_rate()
1283 ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val); in cdns_torrent_dp_configure_rate()
1286 field_val &= ~(cdns_phy->dp_pll); in cdns_torrent_dp_configure_rate()
1287 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val); in cdns_torrent_dp_configure_rate()
1290 * Wait for PLL ready de-assertion. in cdns_torrent_dp_configure_rate()
1291 * For PLL0 - PHY_PMA_CMN_CTRL2[2] == 1 in cdns_torrent_dp_configure_rate()
1292 * For PLL1 - PHY_PMA_CMN_CTRL2[3] == 1 in cdns_torrent_dp_configure_rate()
1294 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_configure_rate()
1295 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1303 if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1) { in cdns_torrent_dp_configure_rate()
1304 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1313 /* DP Rate Change - VCO Output settings. */ in cdns_torrent_dp_configure_rate()
1314 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_configure_rate()
1316 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1317 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_configure_rate()
1319 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1320 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_configure_rate()
1322 cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1324 cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, dp->link_rate, dp->lanes); in cdns_torrent_dp_configure_rate()
1326 /* Enable the associated PLL (cmn_pll0_en or cmn_pll1_en) */ in cdns_torrent_dp_configure_rate()
1327 ret = regmap_field_read(cdns_phy->phy_pma_pll_raw_ctrl, &field_val); in cdns_torrent_dp_configure_rate()
1330 field_val |= cdns_phy->dp_pll; in cdns_torrent_dp_configure_rate()
1331 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, field_val); in cdns_torrent_dp_configure_rate()
1334 * Wait for PLL ready assertion. in cdns_torrent_dp_configure_rate()
1335 * For PLL0 - PHY_PMA_CMN_CTRL2[0] == 1 in cdns_torrent_dp_configure_rate()
1336 * For PLL1 - PHY_PMA_CMN_CTRL2[1] == 1 in cdns_torrent_dp_configure_rate()
1338 if (cdns_phy->dp_pll & DP_PLL0) { in cdns_torrent_dp_configure_rate()
1339 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1347 if ((cdns_phy->dp_pll & DP_PLL1) && cdns_phy->nsubnodes != 1) in cdns_torrent_dp_configure_rate()
1348 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1365 if (dp->set_rate) { in cdns_torrent_dp_verify_config()
1366 switch (dp->link_rate) { in cdns_torrent_dp_verify_config()
1378 return -EINVAL; in cdns_torrent_dp_verify_config()
1383 switch (dp->lanes) { in cdns_torrent_dp_verify_config()
1390 return -EINVAL; in cdns_torrent_dp_verify_config()
1394 if (dp->lanes > inst->num_lanes) in cdns_torrent_dp_verify_config()
1395 return -EINVAL; in cdns_torrent_dp_verify_config()
1398 * If changing voltages is required, check swing and pre-emphasis in cdns_torrent_dp_verify_config()
1399 * levels, per-lane. in cdns_torrent_dp_verify_config()
1401 if (dp->set_voltages) { in cdns_torrent_dp_verify_config()
1403 for (i = 0; i < dp->lanes; i++) { in cdns_torrent_dp_verify_config()
1404 if (dp->voltage[i] > 3 || dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
1405 return -EINVAL; in cdns_torrent_dp_verify_config()
1407 /* Sum of voltage swing and pre-emphasis levels cannot in cdns_torrent_dp_verify_config()
1410 if (dp->voltage[i] + dp->pre[i] > 3) in cdns_torrent_dp_verify_config()
1411 return -EINVAL; in cdns_torrent_dp_verify_config()
1418 /* Set power state A0 and PLL clock enable to 0 on enabled lanes. */
1423 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_a0_pll()
1432 << PHY_POWER_STATE_LN(inst->mlane + i)); in cdns_torrent_dp_set_a0_pll()
1434 pll_clk_en &= ~(0x01U << (inst->mlane + i)); in cdns_torrent_dp_set_a0_pll()
1448 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_lanes()
1449 u8 lane_mask = (1 << dp->lanes) - 1; in cdns_torrent_dp_set_lanes()
1451 u32 clane = inst->mlane; in cdns_torrent_dp_set_lanes()
1457 pma_tx_elec_idle_mask = ((1 << inst->num_lanes) - 1) << clane; in cdns_torrent_dp_set_lanes()
1475 * and powered down when re-enabling the link in cdns_torrent_dp_set_lanes()
1477 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1480 for (i = 1; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1485 cdns_torrent_dp_set_a0_pll(cdns_phy, inst, dp->lanes); in cdns_torrent_dp_set_lanes()
1488 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1491 for (i = 0; i < inst->num_lanes; i++) in cdns_torrent_dp_set_lanes()
1508 ret = cdns_torrent_dp_run(cdns_phy, inst, dp->lanes); in cdns_torrent_dp_set_lanes()
1520 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()
1541 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes, in cdns_torrent_dp_set_rate()
1550 /* Configure voltage swing and pre-emphasis for all enabled lanes. */
1558 for (lane = 0; lane < dp->lanes; lane++) { in cdns_torrent_dp_set_voltages()
1559 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1566 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1569 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]].diag_tx_drv; 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()
1574 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].mgnfs_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()
1578 val = vltg_coeff[dp->voltage[lane]][dp->pre[lane]].cpost_mult; in cdns_torrent_dp_set_voltages()
1579 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1583 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1590 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], in cdns_torrent_dp_set_voltages()
1599 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_configure()
1602 if (cdns_phy->already_configured) in cdns_torrent_dp_configure()
1605 ret = cdns_torrent_dp_verify_config(inst, &opts->dp); in cdns_torrent_dp_configure()
1607 dev_err(&phy->dev, "invalid params for phy configure\n"); in cdns_torrent_dp_configure()
1611 if (opts->dp.set_lanes) { in cdns_torrent_dp_configure()
1612 ret = cdns_torrent_dp_set_lanes(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1614 dev_err(&phy->dev, "cdns_torrent_dp_set_lanes failed\n"); in cdns_torrent_dp_configure()
1619 if (opts->dp.set_rate) { in cdns_torrent_dp_configure()
1620 ret = cdns_torrent_dp_set_rate(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1622 dev_err(&phy->dev, "cdns_torrent_dp_set_rate failed\n"); in cdns_torrent_dp_configure()
1627 if (opts->dp.set_voltages) in cdns_torrent_dp_configure()
1628 cdns_torrent_dp_set_voltages(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1636 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_on()
1640 if (cdns_phy->already_configured) { in cdns_torrent_phy_on()
1646 if (cdns_phy->nsubnodes == 1) { in cdns_torrent_phy_on()
1648 reset_control_deassert(inst->lnk_rst); in cdns_torrent_phy_on()
1651 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_on()
1660 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1, in cdns_torrent_phy_on()
1664 dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n"); in cdns_torrent_phy_on()
1668 if (inst->phy_type == TYPE_PCIE || inst->phy_type == TYPE_USB) { in cdns_torrent_phy_on()
1669 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pcs_iso_link_ctrl_1[inst->mlane], in cdns_torrent_phy_on()
1672 if (ret == -ETIMEDOUT) { in cdns_torrent_phy_on()
1673 dev_err(cdns_phy->dev, "Timeout waiting for PHY status ready\n"); in cdns_torrent_phy_on()
1684 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_off()
1687 if (cdns_phy->nsubnodes != 1) in cdns_torrent_phy_off()
1690 ret = reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_off()
1694 return reset_control_assert(inst->lnk_rst); in cdns_torrent_phy_off()
1700 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_common_init()
1704 cdns_torrent_dp_write(regmap, PHY_AUX_CTRL, 0x0003); /* enable AUX */ in cdns_torrent_dp_common_init()
1708 * Set lines pll clk enable to 0 in cdns_torrent_dp_common_init()
1710 cdns_torrent_dp_set_a0_pll(cdns_phy, inst, inst->num_lanes); in cdns_torrent_dp_common_init()
1716 lane_bits = (1 << inst->num_lanes) - 1; in cdns_torrent_dp_common_init()
1732 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_common_init()
1734 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1736 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_common_init()
1738 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1740 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_common_init()
1742 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1745 cdns_torrent_dp_pma_cmn_rate(cdns_phy, inst, cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1746 inst->num_lanes); in cdns_torrent_dp_common_init()
1749 regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1); in cdns_torrent_dp_common_init()
1766 ret = cdns_torrent_dp_run(cdns_phy, inst, inst->num_lanes); in cdns_torrent_dp_start()
1774 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_init()
1777 switch (cdns_phy->ref_clk_rate) { in cdns_torrent_dp_init()
1784 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_init()
1785 return -EINVAL; in cdns_torrent_dp_init()
1801 if (cdns_phy->ref_clk_rate != CLK_100_MHZ) { in cdns_torrent_dp_multilink_init()
1802 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_multilink_init()
1803 return -EINVAL; in cdns_torrent_dp_multilink_init()
1815 regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 1); in cdns_torrent_derived_refclk_enable()
1816 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 1); in cdns_torrent_derived_refclk_enable()
1825 regmap_field_write(derived_refclk->phy_pipe_cmn_ctrl1_0, 0); in cdns_torrent_derived_refclk_disable()
1826 regmap_field_write(derived_refclk->cmn_cdiag_refclk_ovrd_4, 0); in cdns_torrent_derived_refclk_disable()
1834 regmap_field_read(derived_refclk->cmn_cdiag_refclk_ovrd_4, &val); in cdns_torrent_derived_refclk_is_enabled()
1840 .enable = cdns_torrent_derived_refclk_enable,
1848 struct device *dev = cdns_phy->dev; in cdns_torrent_derived_refclk_register()
1858 return -ENOMEM; in cdns_torrent_derived_refclk_register()
1869 init = &derived_refclk->clk_data; in cdns_torrent_derived_refclk_register()
1873 init->parent_names = &parent_name; in cdns_torrent_derived_refclk_register()
1874 init->num_parents = 1; in cdns_torrent_derived_refclk_register()
1876 init->ops = &cdns_torrent_derived_refclk_ops; in cdns_torrent_derived_refclk_register()
1877 init->flags = 0; in cdns_torrent_derived_refclk_register()
1878 init->name = clk_name; in cdns_torrent_derived_refclk_register()
1880 derived_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0; in cdns_torrent_derived_refclk_register()
1881 derived_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4; in cdns_torrent_derived_refclk_register()
1883 derived_refclk->hw.init = init; in cdns_torrent_derived_refclk_register()
1885 hw = &derived_refclk->hw; in cdns_torrent_derived_refclk_register()
1890 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_DERIVED_REFCLK] = hw; in cdns_torrent_derived_refclk_register()
1899 regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 1); in cdns_torrent_received_refclk_enable()
1908 regmap_field_write(received_refclk->phy_pipe_cmn_ctrl1_0, 0); in cdns_torrent_received_refclk_disable()
1916 regmap_field_read(received_refclk->phy_pipe_cmn_ctrl1_0, &val); in cdns_torrent_received_refclk_is_enabled()
1917 regmap_field_read(received_refclk->cmn_cdiag_refclk_ovrd_4, &cmn_val); in cdns_torrent_received_refclk_is_enabled()
1923 .enable = cdns_torrent_received_refclk_enable,
1931 struct device *dev = cdns_phy->dev; in cdns_torrent_received_refclk_register()
1941 return -ENOMEM; in cdns_torrent_received_refclk_register()
1952 init = &received_refclk->clk_data; in cdns_torrent_received_refclk_register()
1956 init->parent_names = &parent_name; in cdns_torrent_received_refclk_register()
1957 init->num_parents = 1; in cdns_torrent_received_refclk_register()
1959 init->ops = &cdns_torrent_received_refclk_ops; in cdns_torrent_received_refclk_register()
1960 init->flags = 0; in cdns_torrent_received_refclk_register()
1961 init->name = clk_name; in cdns_torrent_received_refclk_register()
1963 received_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0; in cdns_torrent_received_refclk_register()
1964 received_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4; in cdns_torrent_received_refclk_register()
1966 received_refclk->hw.init = init; in cdns_torrent_received_refclk_register()
1968 hw = &received_refclk->hw; in cdns_torrent_received_refclk_register()
1973 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_RECEIVED_REFCLK] = hw; in cdns_torrent_received_refclk_register()
1982 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_6], 0); in cdns_torrent_refclk_driver_enable()
1983 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_5], 1); in cdns_torrent_refclk_driver_enable()
1984 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 0); in cdns_torrent_refclk_driver_enable()
1993 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 1); in cdns_torrent_refclk_driver_disable()
2001 regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], &val); in cdns_torrent_refclk_driver_is_enabled()
2011 regmap_field_read(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], &val); in cdns_torrent_refclk_driver_get_parent()
2021 return regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], val); in cdns_torrent_refclk_driver_set_parent()
2025 .enable = cdns_torrent_refclk_driver_enable,
2036 struct device *dev = cdns_phy->dev; in cdns_torrent_refclk_driver_register()
2048 return -ENOMEM; in cdns_torrent_refclk_driver_register()
2053 return -ENOMEM; in cdns_torrent_refclk_driver_register()
2056 hw = cdns_phy->clk_hw_data->hws[refclk_driver_parent_index[i]]; in cdns_torrent_refclk_driver_register()
2059 return IS_ERR(hw) ? PTR_ERR(hw) : -ENOENT; in cdns_torrent_refclk_driver_register()
2067 init = &refclk_driver->clk_data; in cdns_torrent_refclk_driver_register()
2069 init->ops = &cdns_torrent_refclk_driver_ops; in cdns_torrent_refclk_driver_register()
2070 init->flags = CLK_SET_RATE_NO_REPARENT; in cdns_torrent_refclk_driver_register()
2071 init->parent_names = parent_names; in cdns_torrent_refclk_driver_register()
2072 init->num_parents = num_parents; in cdns_torrent_refclk_driver_register()
2073 init->name = clk_name; in cdns_torrent_refclk_driver_register()
2075 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_refclk_driver_register()
2083 refclk_driver->cmn_fields[i] = field; in cdns_torrent_refclk_driver_register()
2086 /* Enable Derived reference clock as default */ in cdns_torrent_refclk_driver_register()
2087 regmap_field_write(refclk_driver->cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], 1); in cdns_torrent_refclk_driver_register()
2089 refclk_driver->hw.init = init; in cdns_torrent_refclk_driver_register()
2091 hw = &refclk_driver->hw; in cdns_torrent_refclk_driver_register()
2096 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw; in cdns_torrent_refclk_driver_register()
2110 return ERR_PTR(-ENOMEM); in cdns_regmap_init()
2112 ctx->dev = dev; in cdns_regmap_init()
2113 ctx->base = base + block_offset; in cdns_regmap_init()
2114 ctx->reg_offset_shift = reg_offset_shift; in cdns_regmap_init()
2121 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regfield_init()
2125 regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_regfield_init()
2131 cdns_phy->phy_reset_ctrl = field; in cdns_torrent_dp_regfield_init()
2138 struct device *dev = cdns_phy->dev; in cdns_torrent_regfield_init()
2143 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
2149 cdns_phy->phy_pll_cfg = field; in cdns_torrent_regfield_init()
2151 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
2157 cdns_phy->phy_pipe_cmn_ctrl1_0 = field; in cdns_torrent_regfield_init()
2159 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_regfield_init()
2165 cdns_phy->cmn_cdiag_refclk_ovrd_4 = 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_cmn_ctrl_1 = field; in cdns_torrent_regfield_init()
2175 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2181 cdns_phy->phy_pma_cmn_ctrl_2 = field; in cdns_torrent_regfield_init()
2183 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2189 cdns_phy->phy_pma_pll_raw_ctrl = field; in cdns_torrent_regfield_init()
2192 regmap = cdns_phy->regmap_phy_pcs_lane_cdb[i]; in cdns_torrent_regfield_init()
2198 cdns_phy->phy_pcs_iso_link_ctrl_1[i] = field; in cdns_torrent_regfield_init()
2206 void __iomem *base = cdns_phy->base; in cdns_torrent_dp_regmap_init()
2207 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regmap_init()
2212 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_dp_regmap_init()
2222 cdns_phy->regmap_dptx_phy_reg = regmap; in cdns_torrent_dp_regmap_init()
2229 void __iomem *sd_base = cdns_phy->sd_base; in cdns_torrent_regmap_init()
2231 struct device *dev = cdns_phy->dev; in cdns_torrent_regmap_init()
2236 block_offset_shift = cdns_phy->init_data->block_offset_shift; in cdns_torrent_regmap_init()
2237 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_regmap_init()
2249 cdns_phy->regmap_tx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2260 cdns_phy->regmap_rx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2271 cdns_phy->regmap_phy_pcs_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2282 cdns_phy->regmap_common_cdb = regmap; in cdns_torrent_regmap_init()
2292 cdns_phy->regmap_phy_pcs_common_cdb = regmap; in cdns_torrent_regmap_init()
2302 cdns_phy->regmap_phy_pma_common_cdb = regmap; in cdns_torrent_regmap_init()
2309 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_init()
2311 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_init()
2313 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_init()
2315 enum cdns_torrent_phy_type phy_type = inst->phy_type; in cdns_torrent_phy_init()
2317 enum cdns_torrent_ssc_mode ssc = inst->ssc_mode; in cdns_torrent_phy_init()
2324 if (cdns_phy->already_configured) in cdns_torrent_phy_init()
2327 if (cdns_phy->nsubnodes > 1) { in cdns_torrent_phy_init()
2335 * for SGMII/QSGMII/USXGMII in cdns_torrent_phy_init()
2341 link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl, in cdns_torrent_phy_init()
2346 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2347 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_init()
2348 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
2354 regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val); in cdns_torrent_phy_init()
2361 xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl, in cdns_torrent_phy_init()
2366 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_init()
2367 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_init()
2368 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
2369 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2377 pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl, in cdns_torrent_phy_init()
2382 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2383 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_init()
2384 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_init()
2391 phy_pma_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->phy_pma_cmn_vals_tbl, in cdns_torrent_phy_init()
2396 reg_pairs = phy_pma_cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2397 num_regs = phy_pma_cmn_vals->num_regs; in cdns_torrent_phy_init()
2398 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_phy_init()
2405 cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl, in cdns_torrent_phy_init()
2410 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_init()
2411 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_init()
2412 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
2419 tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl, in cdns_torrent_phy_init()
2424 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
2425 num_regs = tx_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_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2435 rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl, in cdns_torrent_phy_init()
2440 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_init()
2441 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_init()
2442 for (i = 0; i < inst->num_lanes; i++) { in cdns_torrent_phy_init()
2443 regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2468 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_configure_multilink()
2470 enum cdns_torrent_ref_clk ref_clk1 = cdns_phy->ref_clk1_rate; in cdns_torrent_phy_configure_multilink()
2471 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_configure_multilink()
2477 struct device *dev = cdns_phy->dev; in cdns_torrent_phy_configure_multilink()
2482 num_protocols = hweight32(cdns_phy->protocol_bitmask); in cdns_torrent_phy_configure_multilink()
2486 return -EINVAL; in cdns_torrent_phy_configure_multilink()
2495 if (cdns_phy->nsubnodes == 2) { in cdns_torrent_phy_configure_multilink()
2496 phy_t1 = cdns_phy->phys[0].phy_type; in cdns_torrent_phy_configure_multilink()
2497 phy_t2 = cdns_phy->phys[1].phy_type; in cdns_torrent_phy_configure_multilink()
2502 * a) Single-Link (1 Sub-node) - handled via PHY APIs in cdns_torrent_phy_configure_multilink()
2504 * b) Double-Link (2 Sub-nodes) - handled above in cdns_torrent_phy_configure_multilink()
2508 return -EINVAL; in cdns_torrent_phy_configure_multilink()
2511 phy_t1 = fns(cdns_phy->protocol_bitmask, 0); in cdns_torrent_phy_configure_multilink()
2512 phy_t2 = fns(cdns_phy->protocol_bitmask, 1); in cdns_torrent_phy_configure_multilink()
2521 * iterations over the sub-nodes (links). in cdns_torrent_phy_configure_multilink()
2524 * is performed by iterating over all sub-nodes matching the first in cdns_torrent_phy_configure_multilink()
2526 * all sub-nodes matching the second protocol and configuring them in cdns_torrent_phy_configure_multilink()
2547 for (node = 0; node < cdns_phy->nsubnodes; node++) { in cdns_torrent_phy_configure_multilink()
2548 if (cdns_phy->phys[node].phy_type != phy_t1) in cdns_torrent_phy_configure_multilink()
2551 mlane = cdns_phy->phys[node].mlane; in cdns_torrent_phy_configure_multilink()
2552 ssc = cdns_phy->phys[node].ssc_mode; in cdns_torrent_phy_configure_multilink()
2553 num_lanes = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_configure_multilink()
2565 link_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->link_cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2569 reg_pairs = link_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2570 num_regs = link_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2571 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2577 regmap_field_write(cdns_phy->phy_pll_cfg, in cdns_torrent_phy_configure_multilink()
2585 xcvr_diag_vals = cdns_torrent_get_tbl_vals(&init_data->xcvr_diag_vals_tbl, in cdns_torrent_phy_configure_multilink()
2589 reg_pairs = xcvr_diag_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2590 num_regs = xcvr_diag_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2592 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2600 pcs_cmn_vals = cdns_torrent_get_tbl_vals(&init_data->pcs_cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2604 reg_pairs = pcs_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2605 num_regs = pcs_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2606 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_configure_multilink()
2614 cdns_torrent_get_tbl_vals(&init_data->phy_pma_cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2618 reg_pairs = phy_pma_cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2619 num_regs = phy_pma_cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2620 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_phy_configure_multilink()
2627 cmn_vals = cdns_torrent_get_tbl_vals(&init_data->cmn_vals_tbl, in cdns_torrent_phy_configure_multilink()
2631 reg_pairs = cmn_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2632 num_regs = cmn_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2633 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2640 tx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->tx_ln_vals_tbl, in cdns_torrent_phy_configure_multilink()
2644 reg_pairs = tx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2645 num_regs = tx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2647 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2655 rx_ln_vals = cdns_torrent_get_tbl_vals(&init_data->rx_ln_vals_tbl, in cdns_torrent_phy_configure_multilink()
2659 reg_pairs = rx_ln_vals->reg_pairs; in cdns_torrent_phy_configure_multilink()
2660 num_regs = rx_ln_vals->num_regs; in cdns_torrent_phy_configure_multilink()
2662 regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2675 reset_control_deassert(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_configure_multilink()
2680 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_configure_multilink()
2689 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_cleanup()
2691 of_clk_del_provider(dev->of_node); in cdns_torrent_clk_cleanup()
2696 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_register()
2697 struct device_node *node = dev->of_node; in cdns_torrent_clk_register()
2703 return -ENOMEM; in cdns_torrent_clk_register()
2705 data->num = CDNS_TORRENT_OUTPUT_CLOCKS; in cdns_torrent_clk_register()
2706 cdns_phy->clk_hw_data = data; in cdns_torrent_clk_register()
2728 dev_err(dev, "Failed to add clock provider: %s\n", node->name); in cdns_torrent_clk_register()
2737 struct device *dev = cdns_phy->dev; in cdns_torrent_of_get_reset()
2739 cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0); in cdns_torrent_of_get_reset()
2740 if (IS_ERR(cdns_phy->phy_rst)) { in cdns_torrent_of_get_reset()
2742 dev->of_node->full_name); in cdns_torrent_of_get_reset()
2743 return PTR_ERR(cdns_phy->phy_rst); in cdns_torrent_of_get_reset()
2746 cdns_phy->apb_rst = devm_reset_control_get_optional_exclusive(dev, "torrent_apb"); in cdns_torrent_of_get_reset()
2747 if (IS_ERR(cdns_phy->apb_rst)) { in cdns_torrent_of_get_reset()
2749 dev->of_node->full_name); in cdns_torrent_of_get_reset()
2750 return PTR_ERR(cdns_phy->apb_rst); in cdns_torrent_of_get_reset()
2759 cdns_phy->clk = devm_clk_get(cdns_phy->dev, "refclk"); in cdns_torrent_of_get_clk()
2760 if (IS_ERR(cdns_phy->clk)) in cdns_torrent_of_get_clk()
2761 return dev_err_probe(cdns_phy->dev, PTR_ERR(cdns_phy->clk), in cdns_torrent_of_get_clk()
2765 cdns_phy->clk1 = devm_clk_get_optional(cdns_phy->dev, "pll1_refclk"); in cdns_torrent_of_get_clk()
2766 if (IS_ERR(cdns_phy->clk1)) in cdns_torrent_of_get_clk()
2767 return dev_err_probe(cdns_phy->dev, PTR_ERR(cdns_phy->clk1), in cdns_torrent_of_get_clk()
2779 ret = clk_prepare_enable(cdns_phy->clk); in cdns_torrent_clk()
2781 dev_err(cdns_phy->dev, "Failed to prepare ref clock: %d\n", ret); in cdns_torrent_clk()
2785 ref_clk_rate = clk_get_rate(cdns_phy->clk); in cdns_torrent_clk()
2787 dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); in cdns_torrent_clk()
2788 ret = -EINVAL; in cdns_torrent_clk()
2794 cdns_phy->ref_clk_rate = CLK_19_2_MHZ; in cdns_torrent_clk()
2797 cdns_phy->ref_clk_rate = CLK_25_MHZ; in cdns_torrent_clk()
2800 cdns_phy->ref_clk_rate = CLK_100_MHZ; in cdns_torrent_clk()
2803 cdns_phy->ref_clk_rate = CLK_156_25_MHZ; in cdns_torrent_clk()
2806 dev_err(cdns_phy->dev, "Invalid ref clock rate\n"); in cdns_torrent_clk()
2807 ret = -EINVAL; in cdns_torrent_clk()
2811 if (cdns_phy->clk1) { in cdns_torrent_clk()
2812 ret = clk_prepare_enable(cdns_phy->clk1); in cdns_torrent_clk()
2814 dev_err(cdns_phy->dev, "Failed to prepare PLL1 ref clock: %d\n", ret); in cdns_torrent_clk()
2818 ref_clk1_rate = clk_get_rate(cdns_phy->clk1); in cdns_torrent_clk()
2820 dev_err(cdns_phy->dev, "Failed to get PLL1 ref clock rate\n"); in cdns_torrent_clk()
2821 ret = -EINVAL; in cdns_torrent_clk()
2827 cdns_phy->ref_clk1_rate = CLK_19_2_MHZ; in cdns_torrent_clk()
2830 cdns_phy->ref_clk1_rate = CLK_25_MHZ; in cdns_torrent_clk()
2833 cdns_phy->ref_clk1_rate = CLK_100_MHZ; in cdns_torrent_clk()
2836 cdns_phy->ref_clk1_rate = CLK_156_25_MHZ; in cdns_torrent_clk()
2839 dev_err(cdns_phy->dev, "Invalid PLL1 ref clock rate\n"); in cdns_torrent_clk()
2840 ret = -EINVAL; in cdns_torrent_clk()
2844 cdns_phy->ref_clk1_rate = cdns_phy->ref_clk_rate; in cdns_torrent_clk()
2850 clk_disable_unprepare(cdns_phy->clk1); in cdns_torrent_clk()
2852 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_clk()
2859 struct device *dev = &pdev->dev; in cdns_torrent_phy_probe()
2871 return -EINVAL; in cdns_torrent_phy_probe()
2875 return -ENOMEM; in cdns_torrent_phy_probe()
2878 cdns_phy->dev = dev; in cdns_torrent_phy_probe()
2879 cdns_phy->init_data = data; in cdns_torrent_phy_probe()
2880 cdns_phy->protocol_bitmask = 0; in cdns_torrent_phy_probe()
2882 cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0); in cdns_torrent_phy_probe()
2883 if (IS_ERR(cdns_phy->sd_base)) in cdns_torrent_phy_probe()
2884 return PTR_ERR(cdns_phy->sd_base); in cdns_torrent_phy_probe()
2886 subnodes = of_get_available_child_count(dev->of_node); in cdns_torrent_phy_probe()
2889 return -EINVAL; in cdns_torrent_phy_probe()
2912 regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &cdns_phy->already_configured); in cdns_torrent_phy_probe()
2914 if (!cdns_phy->already_configured) { in cdns_torrent_phy_probe()
2919 /* Enable APB */ in cdns_torrent_phy_probe()
2920 reset_control_deassert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2923 for_each_available_child_of_node(dev->of_node, child) { in cdns_torrent_phy_probe()
2930 cdns_phy->phys[node].lnk_rst = in cdns_torrent_phy_probe()
2932 if (IS_ERR(cdns_phy->phys[node].lnk_rst)) { in cdns_torrent_phy_probe()
2934 child->full_name); in cdns_torrent_phy_probe()
2935 ret = PTR_ERR(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_probe()
2940 &cdns_phy->phys[node].mlane)) { in cdns_torrent_phy_probe()
2941 dev_err(dev, "%s: No \"reg\"-property.\n", in cdns_torrent_phy_probe()
2942 child->full_name); in cdns_torrent_phy_probe()
2943 ret = -EINVAL; in cdns_torrent_phy_probe()
2947 if (of_property_read_u32(child, "cdns,phy-type", &phy_type)) { in cdns_torrent_phy_probe()
2948 dev_err(dev, "%s: No \"cdns,phy-type\"-property.\n", in cdns_torrent_phy_probe()
2949 child->full_name); in cdns_torrent_phy_probe()
2950 ret = -EINVAL; in cdns_torrent_phy_probe()
2956 cdns_phy->phys[node].phy_type = TYPE_PCIE; in cdns_torrent_phy_probe()
2959 cdns_phy->phys[node].phy_type = TYPE_DP; in cdns_torrent_phy_probe()
2962 cdns_phy->phys[node].phy_type = TYPE_SGMII; in cdns_torrent_phy_probe()
2965 cdns_phy->phys[node].phy_type = TYPE_QSGMII; in cdns_torrent_phy_probe()
2968 cdns_phy->phys[node].phy_type = TYPE_USB; in cdns_torrent_phy_probe()
2971 cdns_phy->phys[node].phy_type = TYPE_USXGMII; in cdns_torrent_phy_probe()
2975 ret = -EINVAL; in cdns_torrent_phy_probe()
2979 if (of_property_read_u32(child, "cdns,num-lanes", in cdns_torrent_phy_probe()
2980 &cdns_phy->phys[node].num_lanes)) { in cdns_torrent_phy_probe()
2981 dev_err(dev, "%s: No \"cdns,num-lanes\"-property.\n", in cdns_torrent_phy_probe()
2982 child->full_name); in cdns_torrent_phy_probe()
2983 ret = -EINVAL; in cdns_torrent_phy_probe()
2987 total_num_lanes += cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2990 cdns_phy->phys[node].ssc_mode = NO_SSC; in cdns_torrent_phy_probe()
2991 of_property_read_u32(child, "cdns,ssc-mode", in cdns_torrent_phy_probe()
2992 &cdns_phy->phys[node].ssc_mode); in cdns_torrent_phy_probe()
3000 if (cdns_phy->phys[node].phy_type == TYPE_DP) { in cdns_torrent_phy_probe()
3001 switch (cdns_phy->phys[node].num_lanes) { in cdns_torrent_phy_probe()
3009 cdns_phy->phys[node].num_lanes); in cdns_torrent_phy_probe()
3010 ret = -EINVAL; in cdns_torrent_phy_probe()
3014 cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE; in cdns_torrent_phy_probe()
3015 of_property_read_u32(child, "cdns,max-bit-rate", in cdns_torrent_phy_probe()
3016 &cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
3018 switch (cdns_phy->max_bit_rate) { in cdns_torrent_phy_probe()
3031 cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
3032 ret = -EINVAL; in cdns_torrent_phy_probe()
3037 cdns_phy->base = devm_platform_ioremap_resource(pdev, 1); in cdns_torrent_phy_probe()
3038 if (IS_ERR(cdns_phy->base)) { in cdns_torrent_phy_probe()
3039 ret = PTR_ERR(cdns_phy->base); in cdns_torrent_phy_probe()
3056 cdns_phy->max_bit_rate / 1000, in cdns_torrent_phy_probe()
3057 cdns_phy->max_bit_rate % 1000); in cdns_torrent_phy_probe()
3059 gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
3060 gphy->attrs.max_link_rate = cdns_phy->max_bit_rate; in cdns_torrent_phy_probe()
3061 gphy->attrs.mode = PHY_MODE_DP; in cdns_torrent_phy_probe()
3064 cdns_phy->phys[node].phy = gphy; in cdns_torrent_phy_probe()
3065 cdns_phy->protocol_bitmask |= BIT(cdns_phy->phys[node].phy_type); in cdns_torrent_phy_probe()
3066 phy_set_drvdata(gphy, &cdns_phy->phys[node]); in cdns_torrent_phy_probe()
3070 cdns_phy->nsubnodes = node; in cdns_torrent_phy_probe()
3074 ret = -EINVAL; in cdns_torrent_phy_probe()
3078 if (cdns_phy->nsubnodes > 1 && !cdns_phy->already_configured) { in cdns_torrent_phy_probe()
3090 if (cdns_phy->nsubnodes > 1) in cdns_torrent_phy_probe()
3091 dev_dbg(dev, "Multi-link: %s (%d lanes) & %s (%d lanes)", in cdns_torrent_phy_probe()
3092 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
3093 cdns_phy->phys[0].num_lanes, in cdns_torrent_phy_probe()
3094 cdns_torrent_get_phy_type(cdns_phy->phys[1].phy_type), in cdns_torrent_phy_probe()
3095 cdns_phy->phys[1].num_lanes); in cdns_torrent_phy_probe()
3098 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
3099 cdns_phy->phys[0].num_lanes); in cdns_torrent_phy_probe()
3107 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_probe()
3109 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
3110 clk_disable_unprepare(cdns_phy->clk1); in cdns_torrent_phy_probe()
3111 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_probe()
3122 reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_remove()
3123 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_remove()
3124 for (i = 0; i < cdns_phy->nsubnodes; i++) { in cdns_torrent_phy_remove()
3125 reset_control_assert(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
3126 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
3129 clk_disable_unprepare(cdns_phy->clk1); in cdns_torrent_phy_remove()
3130 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_remove()
3134 /* SGMII and QSGMII link configuration */
3159 reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_suspend_noirq()
3160 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_suspend_noirq()
3161 for (i = 0; i < cdns_phy->nsubnodes; i++) in cdns_torrent_phy_suspend_noirq()
3162 reset_control_assert(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_suspend_noirq()
3164 if (cdns_phy->already_configured) in cdns_torrent_phy_suspend_noirq()
3165 cdns_phy->already_configured = 0; in cdns_torrent_phy_suspend_noirq()
3167 clk_disable_unprepare(cdns_phy->clk1); in cdns_torrent_phy_suspend_noirq()
3168 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_suspend_noirq()
3177 int node = cdns_phy->nsubnodes; in cdns_torrent_phy_resume_noirq()
3184 /* Enable APB */ in cdns_torrent_phy_resume_noirq()
3185 reset_control_deassert(cdns_phy->apb_rst); in cdns_torrent_phy_resume_noirq()
3187 if (cdns_phy->nsubnodes > 1) { in cdns_torrent_phy_resume_noirq()
3197 reset_control_assert(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_resume_noirq()
3198 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_resume_noirq()
3200 clk_disable_unprepare(cdns_phy->clk1); in cdns_torrent_phy_resume_noirq()
3201 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_resume_noirq()
3242 /* USXGMII and SGMII/QSGMII link configuration */
3294 /* Multilink SGMII/QSGMII, using PLL1, 100 MHz Ref clk, no SSC */
3341 /* TI J7200, Multilink SGMII/QSGMII, using PLL1, 100 MHz Ref clk, no SSC */
3452 /* TI USXGMII configuration: Enable cmn_refclk_rcv_out_en */
3840 /* USB and SGMII/QSGMII link configuration */
4120 /* PCIe and SGMII/QSGMII Unique SSC link configuration */
4155 /* SGMII 100 MHz Ref clk, no SSC */
4231 /* TI J7200, multilink SGMII */
4275 /* SGMII 100 MHz Ref clk, internal SSC */
4512 /* Single SGMII/QSGMII link configuration */
5426 .compatible = "cdns,torrent-phy",
5430 .compatible = "ti,j721e-serdes-10g",
5434 .compatible = "ti,j7200-serdes-10g",
5445 .name = "cdns-torrent-phy",