Lines Matching refs:cdns_phy
293 static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy,
296 int cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy *cdns_phy);
297 static void cdns_torrent_dp_pma_cfg(struct cdns_torrent_phy *cdns_phy,
300 void cdns_torrent_dp_pma_cmn_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy);
302 void cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy,
305 void cdns_torrent_dp_pma_cmn_cfg_25mhz(struct cdns_torrent_phy *cdns_phy);
307 void cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy *cdns_phy,
309 static void cdns_torrent_dp_pma_lane_cfg(struct cdns_torrent_phy *cdns_phy,
311 static void cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy *cdns_phy,
315 static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy,
563 static int cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_pll_en() argument
569 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_pll_en()
618 static int cdns_torrent_dp_configure_rate(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_configure_rate() argument
625 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x0); in cdns_torrent_dp_configure_rate()
631 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
640 if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz) { in cdns_torrent_dp_configure_rate()
642 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, in cdns_torrent_dp_configure_rate()
644 cdns_torrent_dp_pma_cmn_cfg_19_2mhz(cdns_phy); in cdns_torrent_dp_configure_rate()
645 } else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz) { in cdns_torrent_dp_configure_rate()
647 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, in cdns_torrent_dp_configure_rate()
649 cdns_torrent_dp_pma_cmn_cfg_25mhz(cdns_phy); in cdns_torrent_dp_configure_rate()
651 cdns_torrent_dp_pma_cmn_rate(cdns_phy, dp->link_rate, dp->lanes); in cdns_torrent_dp_configure_rate()
654 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x3); in cdns_torrent_dp_configure_rate()
660 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
730 static void cdns_torrent_dp_set_a0_pll(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_a0_pll() argument
733 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_a0_pll()
766 static int cdns_torrent_dp_set_lanes(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_lanes() argument
771 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_lanes()
793 cdns_torrent_dp_set_a0_pll(cdns_phy, dp->lanes); in cdns_torrent_dp_set_lanes()
800 ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy); in cdns_torrent_dp_set_lanes()
809 ret = cdns_torrent_dp_run(cdns_phy, dp->lanes); in cdns_torrent_dp_set_lanes()
815 static int cdns_torrent_dp_set_rate(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_rate() argument
820 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
824 ret = cdns_torrent_dp_set_pll_en(cdns_phy, dp, false); in cdns_torrent_dp_set_rate()
829 ret = cdns_torrent_dp_configure_rate(cdns_phy, dp); in cdns_torrent_dp_set_rate()
834 ret = cdns_torrent_dp_set_pll_en(cdns_phy, dp, true); in cdns_torrent_dp_set_rate()
837 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
841 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
851 static void cdns_torrent_dp_set_voltages(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_voltages() argument
858 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
865 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
868 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
871 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
874 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
878 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
882 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
889 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
898 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_configure() local
908 ret = cdns_torrent_dp_set_lanes(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
916 ret = cdns_torrent_dp_set_rate(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
924 cdns_torrent_dp_set_voltages(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
934 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_init() local
935 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_init()
937 switch (cdns_phy->ref_clk_rate) { in cdns_torrent_dp_init()
943 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_init()
950 cdns_torrent_dp_pma_cfg(cdns_phy, inst); in cdns_torrent_dp_init()
956 cdns_torrent_dp_set_a0_pll(cdns_phy, inst->num_lanes); in cdns_torrent_dp_init()
971 if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz) in cdns_torrent_dp_init()
972 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, in cdns_torrent_dp_init()
973 cdns_phy->max_bit_rate, in cdns_torrent_dp_init()
975 else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz) in cdns_torrent_dp_init()
976 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, in cdns_torrent_dp_init()
977 cdns_phy->max_bit_rate, in cdns_torrent_dp_init()
979 cdns_torrent_dp_pma_cmn_rate(cdns_phy, cdns_phy->max_bit_rate, in cdns_torrent_dp_init()
983 regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1); in cdns_torrent_dp_init()
987 ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy); in cdns_torrent_dp_init()
991 ret = cdns_torrent_dp_run(cdns_phy, inst->num_lanes); in cdns_torrent_dp_init()
997 int cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_wait_pma_cmn_ready() argument
1001 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_wait_pma_cmn_ready()
1006 dev_err(cdns_phy->dev, in cdns_torrent_dp_wait_pma_cmn_ready()
1014 static void cdns_torrent_dp_pma_cfg(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_pma_cfg() argument
1019 if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz) in cdns_torrent_dp_pma_cfg()
1021 cdns_torrent_dp_pma_cmn_cfg_19_2mhz(cdns_phy); in cdns_torrent_dp_pma_cfg()
1022 else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz) in cdns_torrent_dp_pma_cfg()
1024 cdns_torrent_dp_pma_cmn_cfg_25mhz(cdns_phy); in cdns_torrent_dp_pma_cfg()
1028 cdns_torrent_dp_pma_lane_cfg(cdns_phy, i); in cdns_torrent_dp_pma_cfg()
1032 void cdns_torrent_dp_pma_cmn_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_pma_cmn_cfg_19_2mhz() argument
1034 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_cfg_19_2mhz()
1080 void cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_enable_ssc_19_2mhz() argument
1083 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_19_2mhz()
1096 void cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz() argument
1099 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
1127 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x033A, in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
1155 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x05DD, in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
1182 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x0536, in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
1208 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x04D7, in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
1257 void cdns_torrent_dp_pma_cmn_cfg_25mhz(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_pma_cmn_cfg_25mhz() argument
1259 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_cfg_25mhz()
1304 static void cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_enable_ssc_25mhz() argument
1307 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_25mhz()
1320 void cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz() argument
1323 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
1339 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x0423); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
1354 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x03B9); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
1368 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x034F); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
1381 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x031A); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
1423 static void cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_pma_cmn_rate() argument
1431 regmap_field_write(cdns_phy->phy_pll_cfg, 0x0); in cdns_torrent_dp_pma_cmn_rate()
1459 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1461 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1466 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[i], in cdns_torrent_dp_pma_cmn_rate()
1470 static void cdns_torrent_dp_pma_lane_cfg(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_pma_lane_cfg() argument
1474 if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz) in cdns_torrent_dp_pma_lane_cfg()
1475 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1477 else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz) in cdns_torrent_dp_pma_lane_cfg()
1478 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1482 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1484 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1486 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1488 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1490 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1492 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1495 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1498 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1500 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1502 cdns_torrent_phy_write(cdns_phy->regmap_rx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1505 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1507 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1509 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_pma_lane_cfg()
1513 static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_power_state() argument
1523 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_power_state()
1575 static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy, u32 num_lanes) in cdns_torrent_dp_run() argument
1579 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_run()
1589 dev_err(cdns_phy->dev, in cdns_torrent_dp_run()
1596 ret = cdns_torrent_dp_set_power_state(cdns_phy, num_lanes, in cdns_torrent_dp_run()
1601 ret = cdns_torrent_dp_set_power_state(cdns_phy, num_lanes, in cdns_torrent_dp_run()
1610 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_on() local
1614 if (cdns_phy->nsubnodes == 1) { in cdns_torrent_phy_on()
1619 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_on()
1628 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1, in cdns_torrent_phy_on()
1632 dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n"); in cdns_torrent_phy_on()
1644 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_off() local
1647 if (cdns_phy->nsubnodes != 1) in cdns_torrent_phy_off()
1650 ret = reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_off()
1675 static int cdns_torrent_dp_regfield_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_regfield_init() argument
1677 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regfield_init()
1681 regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_regfield_init()
1687 cdns_phy->phy_reset_ctrl = field; in cdns_torrent_dp_regfield_init()
1692 static int cdns_torrent_regfield_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_regfield_init() argument
1694 struct device *dev = cdns_phy->dev; in cdns_torrent_regfield_init()
1698 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
1704 cdns_phy->phy_pll_cfg = field; in cdns_torrent_regfield_init()
1706 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
1712 cdns_phy->phy_pma_cmn_ctrl_1 = field; in cdns_torrent_regfield_init()
1714 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
1720 cdns_phy->phy_pma_cmn_ctrl_2 = field; in cdns_torrent_regfield_init()
1722 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
1728 cdns_phy->phy_pma_pll_raw_ctrl = field; in cdns_torrent_regfield_init()
1733 static int cdns_torrent_dp_regmap_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_regmap_init() argument
1735 void __iomem *base = cdns_phy->base; in cdns_torrent_dp_regmap_init()
1736 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regmap_init()
1741 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_dp_regmap_init()
1751 cdns_phy->regmap_dptx_phy_reg = regmap; in cdns_torrent_dp_regmap_init()
1756 static int cdns_torrent_regmap_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_regmap_init() argument
1758 void __iomem *sd_base = cdns_phy->sd_base; in cdns_torrent_regmap_init()
1760 struct device *dev = cdns_phy->dev; in cdns_torrent_regmap_init()
1765 block_offset_shift = cdns_phy->init_data->block_offset_shift; in cdns_torrent_regmap_init()
1766 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_regmap_init()
1778 cdns_phy->regmap_tx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
1789 cdns_phy->regmap_rx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
1800 cdns_phy->regmap_common_cdb = regmap; in cdns_torrent_regmap_init()
1810 cdns_phy->regmap_phy_pcs_common_cdb = regmap; in cdns_torrent_regmap_init()
1820 cdns_phy->regmap_phy_pma_common_cdb = regmap; in cdns_torrent_regmap_init()
1827 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_init() local
1828 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_init()
1840 if (cdns_phy->nsubnodes > 1) in cdns_torrent_phy_init()
1858 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
1864 regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val); in cdns_torrent_phy_init()
1876 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
1888 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_init()
1899 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
1911 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
1924 regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
1935 int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_phy_configure_multilink() argument
1937 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_configure_multilink()
1949 if (cdns_phy->nsubnodes != 2) in cdns_torrent_phy_configure_multilink()
1952 phy_t1 = cdns_phy->phys[0].phy_type; in cdns_torrent_phy_configure_multilink()
1953 phy_t2 = cdns_phy->phys[1].phy_type; in cdns_torrent_phy_configure_multilink()
1959 for (node = 0; node < cdns_phy->nsubnodes; node++) { in cdns_torrent_phy_configure_multilink()
1971 mlane = cdns_phy->phys[node].mlane; in cdns_torrent_phy_configure_multilink()
1972 ssc = cdns_phy->phys[node].ssc_mode; in cdns_torrent_phy_configure_multilink()
1973 num_lanes = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_configure_multilink()
1989 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
1995 regmap_field_write(cdns_phy->phy_pll_cfg, in cdns_torrent_phy_configure_multilink()
2008 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2020 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_configure_multilink()
2031 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2043 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2056 regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2063 reset_control_deassert(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_configure_multilink()
2067 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_configure_multilink()
2076 struct cdns_torrent_phy *cdns_phy; in cdns_torrent_phy_probe() local
2091 cdns_phy = devm_kzalloc(dev, sizeof(*cdns_phy), GFP_KERNEL); in cdns_torrent_phy_probe()
2092 if (!cdns_phy) in cdns_torrent_phy_probe()
2095 dev_set_drvdata(dev, cdns_phy); in cdns_torrent_phy_probe()
2096 cdns_phy->dev = dev; in cdns_torrent_phy_probe()
2097 cdns_phy->init_data = data; in cdns_torrent_phy_probe()
2099 cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0); in cdns_torrent_phy_probe()
2100 if (IS_ERR(cdns_phy->phy_rst)) { in cdns_torrent_phy_probe()
2103 return PTR_ERR(cdns_phy->phy_rst); in cdns_torrent_phy_probe()
2106 cdns_phy->apb_rst = devm_reset_control_get_optional(dev, "torrent_apb"); in cdns_torrent_phy_probe()
2107 if (IS_ERR(cdns_phy->apb_rst)) { in cdns_torrent_phy_probe()
2110 return PTR_ERR(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2113 cdns_phy->clk = devm_clk_get(dev, "refclk"); in cdns_torrent_phy_probe()
2114 if (IS_ERR(cdns_phy->clk)) { in cdns_torrent_phy_probe()
2116 return PTR_ERR(cdns_phy->clk); in cdns_torrent_phy_probe()
2119 cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0); in cdns_torrent_phy_probe()
2120 if (IS_ERR(cdns_phy->sd_base)) in cdns_torrent_phy_probe()
2121 return PTR_ERR(cdns_phy->sd_base); in cdns_torrent_phy_probe()
2129 ret = cdns_torrent_regmap_init(cdns_phy); in cdns_torrent_phy_probe()
2133 ret = cdns_torrent_regfield_init(cdns_phy); in cdns_torrent_phy_probe()
2137 ret = clk_prepare_enable(cdns_phy->clk); in cdns_torrent_phy_probe()
2139 dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); in cdns_torrent_phy_probe()
2143 cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk); in cdns_torrent_phy_probe()
2144 if (!(cdns_phy->ref_clk_rate)) { in cdns_torrent_phy_probe()
2145 dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); in cdns_torrent_phy_probe()
2146 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_probe()
2151 reset_control_deassert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2160 cdns_phy->phys[node].lnk_rst = in cdns_torrent_phy_probe()
2162 if (IS_ERR(cdns_phy->phys[node].lnk_rst)) { in cdns_torrent_phy_probe()
2165 ret = PTR_ERR(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_probe()
2170 &cdns_phy->phys[node].mlane)) { in cdns_torrent_phy_probe()
2186 cdns_phy->phys[node].phy_type = TYPE_PCIE; in cdns_torrent_phy_probe()
2189 cdns_phy->phys[node].phy_type = TYPE_DP; in cdns_torrent_phy_probe()
2192 cdns_phy->phys[node].phy_type = TYPE_SGMII; in cdns_torrent_phy_probe()
2195 cdns_phy->phys[node].phy_type = TYPE_QSGMII; in cdns_torrent_phy_probe()
2198 cdns_phy->phys[node].phy_type = TYPE_USB; in cdns_torrent_phy_probe()
2207 &cdns_phy->phys[node].num_lanes)) { in cdns_torrent_phy_probe()
2214 total_num_lanes += cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2217 cdns_phy->phys[node].ssc_mode = NO_SSC; in cdns_torrent_phy_probe()
2219 &cdns_phy->phys[node].ssc_mode); in cdns_torrent_phy_probe()
2227 if (cdns_phy->phys[node].phy_type == TYPE_DP) { in cdns_torrent_phy_probe()
2228 switch (cdns_phy->phys[node].num_lanes) { in cdns_torrent_phy_probe()
2236 cdns_phy->phys[node].num_lanes); in cdns_torrent_phy_probe()
2241 cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE; in cdns_torrent_phy_probe()
2243 &cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2245 switch (cdns_phy->max_bit_rate) { in cdns_torrent_phy_probe()
2258 cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2264 cdns_phy->base = devm_platform_ioremap_resource(pdev, 1); in cdns_torrent_phy_probe()
2265 if (IS_ERR(cdns_phy->base)) { in cdns_torrent_phy_probe()
2266 ret = PTR_ERR(cdns_phy->base); in cdns_torrent_phy_probe()
2271 ret = cdns_torrent_dp_regmap_init(cdns_phy); in cdns_torrent_phy_probe()
2275 ret = cdns_torrent_dp_regfield_init(cdns_phy); in cdns_torrent_phy_probe()
2283 cdns_phy->phys[node].num_lanes, in cdns_torrent_phy_probe()
2284 cdns_phy->max_bit_rate / 1000, in cdns_torrent_phy_probe()
2285 cdns_phy->max_bit_rate % 1000); in cdns_torrent_phy_probe()
2287 gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2288 gphy->attrs.max_link_rate = cdns_phy->max_bit_rate; in cdns_torrent_phy_probe()
2292 cdns_phy->phys[node].phy = gphy; in cdns_torrent_phy_probe()
2293 phy_set_drvdata(gphy, &cdns_phy->phys[node]); in cdns_torrent_phy_probe()
2297 cdns_phy->nsubnodes = node; in cdns_torrent_phy_probe()
2305 if (cdns_phy->nsubnodes > 1) { in cdns_torrent_phy_probe()
2306 ret = cdns_torrent_phy_configure_multilink(cdns_phy); in cdns_torrent_phy_probe()
2323 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_probe()
2325 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2326 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_probe()
2332 struct cdns_torrent_phy *cdns_phy = platform_get_drvdata(pdev); in cdns_torrent_phy_remove() local
2335 reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_remove()
2336 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_remove()
2337 for (i = 0; i < cdns_phy->nsubnodes; i++) { in cdns_torrent_phy_remove()
2338 reset_control_assert(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
2339 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
2342 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_remove()