Lines Matching refs:cdns_phy
711 void cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_enable_ssc_19_2mhz() argument
714 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_19_2mhz()
727 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
730 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
748 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x033A, 0x006A); in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
765 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x05DD, 0x0069); in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
781 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x0536, 0x0069); in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
796 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x04D7, 0x006A); in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
831 static void cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_enable_ssc_25mhz() argument
834 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_25mhz()
847 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
850 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
866 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x0423); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
881 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x03B9); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
895 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x034F); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
908 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x031A); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
951 void cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(struct cdns_torrent_phy *cdns_phy, 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()
1050 static int cdns_torrent_dp_get_pll(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_get_pll() argument
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()
1076 static int cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy *cdns_phy, 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()
1118 static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_power_state() argument
1129 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_power_state()
1166 static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_run() argument
1171 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_run()
1181 dev_err(cdns_phy->dev, in cdns_torrent_dp_run()
1188 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, num_lanes, in cdns_torrent_dp_run()
1193 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, num_lanes, in cdns_torrent_dp_run()
1199 static int cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_wait_pma_cmn_ready() argument
1203 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_wait_pma_cmn_ready()
1208 dev_err(cdns_phy->dev, in cdns_torrent_dp_wait_pma_cmn_ready()
1216 static void cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_pma_cmn_rate() argument
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()
1260 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + i], in cdns_torrent_dp_pma_cmn_rate()
1268 static int cdns_torrent_dp_configure_rate(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_configure_rate() argument
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()
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()
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()
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()
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()
1415 static void cdns_torrent_dp_set_a0_pll(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_a0_pll() argument
1419 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_a0_pll()
1438 static int cdns_torrent_dp_set_lanes(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_lanes() argument
1444 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_lanes()
1481 cdns_torrent_dp_set_a0_pll(cdns_phy, inst, dp->lanes); in cdns_torrent_dp_set_lanes()
1493 ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy); in cdns_torrent_dp_set_lanes()
1504 ret = cdns_torrent_dp_run(cdns_phy, inst, dp->lanes); in cdns_torrent_dp_set_lanes()
1510 static int cdns_torrent_dp_set_rate(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_rate() argument
1516 ret = cdns_torrent_dp_set_power_state(cdns_phy, inst, dp->lanes, in cdns_torrent_dp_set_rate()
1520 ret = cdns_torrent_dp_set_pll_en(cdns_phy, inst, dp, false); in cdns_torrent_dp_set_rate()
1525 ret = cdns_torrent_dp_configure_rate(cdns_phy, inst, dp); in cdns_torrent_dp_set_rate()
1530 ret = cdns_torrent_dp_set_pll_en(cdns_phy, inst, dp, true); 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()
1547 static void cdns_torrent_dp_set_voltages(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_voltages() argument
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()
1568 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[inst->mlane + lane], 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()
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() local
1605 ret = cdns_torrent_dp_set_lanes(cdns_phy, inst, &opts->dp); in cdns_torrent_dp_configure()
1613 ret = cdns_torrent_dp_set_rate(cdns_phy, inst, &opts->dp); 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() local
1633 if (cdns_phy->nsubnodes == 1) { 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()
1656 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pcs_iso_link_ctrl_1[inst->mlane], 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() local
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()
1684 static void cdns_torrent_dp_common_init(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_common_init() argument
1687 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; 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()
1719 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_common_init()
1720 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, 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()
1724 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, 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()
1728 cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, 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()
1736 regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1); in cdns_torrent_dp_common_init()
1739 static int cdns_torrent_dp_start(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_start() argument
1749 ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy); in cdns_torrent_dp_start()
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() local
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()
1775 ret = cdns_torrent_dp_get_pll(cdns_phy, TYPE_NONE); in cdns_torrent_dp_init()
1779 cdns_torrent_dp_common_init(cdns_phy, inst); in cdns_torrent_dp_init()
1781 return cdns_torrent_dp_start(cdns_phy, inst, phy); in cdns_torrent_dp_init()
1784 static int cdns_torrent_dp_multilink_init(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_multilink_init() argument
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()
1793 cdns_torrent_dp_common_init(cdns_phy, inst); in cdns_torrent_dp_multilink_init()
1795 return cdns_torrent_dp_start(cdns_phy, inst, phy); in cdns_torrent_dp_multilink_init()
1832 static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_derived_refclk_register() argument
1835 struct device *dev = cdns_phy->dev; 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()
1877 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_DERIVED_REFCLK] = hw; in cdns_torrent_derived_refclk_register()
1915 static int cdns_torrent_received_refclk_register(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_received_refclk_register() argument
1918 struct device *dev = cdns_phy->dev; 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()
1960 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_RECEIVED_REFCLK] = hw; in cdns_torrent_received_refclk_register()
2020 static int cdns_torrent_refclk_driver_register(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_refclk_driver_register() argument
2023 struct device *dev = cdns_phy->dev; 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()
2062 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_refclk_driver_register()
2083 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw; in cdns_torrent_refclk_driver_register()
2106 static int cdns_torrent_dp_regfield_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_regfield_init() argument
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()
2123 static int cdns_torrent_regfield_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_regfield_init() argument
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()
2191 static int cdns_torrent_dp_regmap_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_regmap_init() argument
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()
2214 static int cdns_torrent_regmap_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_regmap_init() argument
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() local
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()
2311 if (cdns_phy->nsubnodes > 1) { in cdns_torrent_phy_init()
2313 return cdns_torrent_dp_multilink_init(cdns_phy, inst, phy); 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()
2353 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2368 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_init()
2382 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_phy_init()
2396 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
2411 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2427 regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2462 int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_phy_configure_multilink() argument
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()
2477 if (cdns_phy->nsubnodes != 2) 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()
2487 for (node = 0; node < cdns_phy->nsubnodes; node++) { 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()
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()
2538 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2552 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_configure_multilink()
2565 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2579 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2594 regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2602 ret = cdns_torrent_dp_get_pll(cdns_phy, phy_t2); 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()
2618 static void cdns_torrent_clk_cleanup(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_clk_cleanup() argument
2620 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_cleanup()
2625 static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_clk_register() argument
2627 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_register()
2637 cdns_phy->clk_hw_data = data; in cdns_torrent_clk_register()
2639 ret = cdns_torrent_derived_refclk_register(cdns_phy); in cdns_torrent_clk_register()
2645 ret = cdns_torrent_received_refclk_register(cdns_phy); in cdns_torrent_clk_register()
2651 ret = cdns_torrent_refclk_driver_register(cdns_phy); in cdns_torrent_clk_register()
2666 static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_reset() argument
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()
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()
2681 return PTR_ERR(cdns_phy->apb_rst); in cdns_torrent_reset()
2687 static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_clk() argument
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()
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()
2736 struct cdns_torrent_phy *cdns_phy; in cdns_torrent_phy_probe() local
2752 cdns_phy = devm_kzalloc(dev, sizeof(*cdns_phy), GFP_KERNEL); in cdns_torrent_phy_probe()
2753 if (!cdns_phy) in cdns_torrent_phy_probe()
2756 dev_set_drvdata(dev, cdns_phy); 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()
2770 ret = cdns_torrent_regmap_init(cdns_phy); in cdns_torrent_phy_probe()
2774 ret = cdns_torrent_regfield_init(cdns_phy); in cdns_torrent_phy_probe()
2778 ret = cdns_torrent_clk_register(cdns_phy); in cdns_torrent_phy_probe()
2782 regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); in cdns_torrent_phy_probe()
2785 ret = cdns_torrent_reset(cdns_phy); in cdns_torrent_phy_probe()
2789 ret = cdns_torrent_clk(cdns_phy); in cdns_torrent_phy_probe()
2794 reset_control_deassert(cdns_phy->apb_rst); 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()
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()
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()
2854 &cdns_phy->phys[node].num_lanes)) { in cdns_torrent_phy_probe()
2861 total_num_lanes += cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2864 cdns_phy->phys[node].ssc_mode = NO_SSC; 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()
2891 cdns_phy->max_bit_rate = DEFAULT_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()
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()
2921 ret = cdns_torrent_dp_regmap_init(cdns_phy); in cdns_torrent_phy_probe()
2925 ret = cdns_torrent_dp_regfield_init(cdns_phy); 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()
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()
2954 if (cdns_phy->nsubnodes > 1 && !already_configured) { in cdns_torrent_phy_probe()
2955 ret = cdns_torrent_phy_configure_multilink(cdns_phy); in cdns_torrent_phy_probe()
2966 if (cdns_phy->nsubnodes > 1) 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()
2988 cdns_torrent_clk_cleanup(cdns_phy); in cdns_torrent_phy_probe()
2994 struct cdns_torrent_phy *cdns_phy = platform_get_drvdata(pdev); in cdns_torrent_phy_remove() local
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()
3005 cdns_torrent_clk_cleanup(cdns_phy); in cdns_torrent_phy_remove()