Lines Matching refs:cdns_phy

658 void cdns_torrent_dp_enable_ssc_19_2mhz(struct cdns_torrent_phy *cdns_phy,  in cdns_torrent_dp_enable_ssc_19_2mhz()  argument
661 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_19_2mhz()
674 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
677 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
695 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x033A, 0x006A); in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
712 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x05DD, 0x0069); in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
728 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x0536, 0x0069); in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
743 cdns_torrent_dp_enable_ssc_19_2mhz(cdns_phy, 0x04D7, 0x006A); in cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz()
778 static void cdns_torrent_dp_enable_ssc_25mhz(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_enable_ssc_25mhz() argument
781 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_enable_ssc_25mhz()
794 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
797 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
813 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x0423); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
828 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x03B9); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
842 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x034F); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
855 cdns_torrent_dp_enable_ssc_25mhz(cdns_phy, 0x031A); in cdns_torrent_dp_pma_cmn_vco_cfg_25mhz()
898 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
901 struct regmap *regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_dp_pma_cmn_vco_cfg_100mhz()
983 static int cdns_torrent_dp_set_pll_en(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_pll_en() argument
989 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_pll_en()
1034 static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_power_state() argument
1044 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_power_state()
1096 static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy, u32 num_lanes) in cdns_torrent_dp_run() argument
1100 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_run()
1110 dev_err(cdns_phy->dev, in cdns_torrent_dp_run()
1117 ret = cdns_torrent_dp_set_power_state(cdns_phy, num_lanes, in cdns_torrent_dp_run()
1122 ret = cdns_torrent_dp_set_power_state(cdns_phy, num_lanes, in cdns_torrent_dp_run()
1128 static int cdns_torrent_dp_wait_pma_cmn_ready(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_wait_pma_cmn_ready() argument
1132 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_wait_pma_cmn_ready()
1137 dev_err(cdns_phy->dev, in cdns_torrent_dp_wait_pma_cmn_ready()
1145 static void cdns_torrent_dp_pma_cmn_rate(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_pma_cmn_rate() argument
1178 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1180 cdns_torrent_phy_write(cdns_phy->regmap_common_cdb, in cdns_torrent_dp_pma_cmn_rate()
1185 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[i], in cdns_torrent_dp_pma_cmn_rate()
1193 static int cdns_torrent_dp_configure_rate(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_configure_rate() argument
1199 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x0); in cdns_torrent_dp_configure_rate()
1205 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1214 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_configure_rate()
1216 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1217 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_configure_rate()
1219 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1220 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_configure_rate()
1222 cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, dp->link_rate, dp->ssc); in cdns_torrent_dp_configure_rate()
1224 cdns_torrent_dp_pma_cmn_rate(cdns_phy, dp->link_rate, dp->lanes); in cdns_torrent_dp_configure_rate()
1227 regmap_field_write(cdns_phy->phy_pma_pll_raw_ctrl, 0x3); in cdns_torrent_dp_configure_rate()
1233 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_2, in cdns_torrent_dp_configure_rate()
1303 static void cdns_torrent_dp_set_a0_pll(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_a0_pll() argument
1306 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_a0_pll()
1339 static int cdns_torrent_dp_set_lanes(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_lanes() argument
1344 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_set_lanes()
1366 cdns_torrent_dp_set_a0_pll(cdns_phy, dp->lanes); in cdns_torrent_dp_set_lanes()
1373 ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy); in cdns_torrent_dp_set_lanes()
1382 ret = cdns_torrent_dp_run(cdns_phy, dp->lanes); in cdns_torrent_dp_set_lanes()
1388 static int cdns_torrent_dp_set_rate(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_rate() argument
1393 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
1397 ret = cdns_torrent_dp_set_pll_en(cdns_phy, dp, false); in cdns_torrent_dp_set_rate()
1402 ret = cdns_torrent_dp_configure_rate(cdns_phy, dp); in cdns_torrent_dp_set_rate()
1407 ret = cdns_torrent_dp_set_pll_en(cdns_phy, dp, true); in cdns_torrent_dp_set_rate()
1410 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
1414 ret = cdns_torrent_dp_set_power_state(cdns_phy, dp->lanes, in cdns_torrent_dp_set_rate()
1424 static void cdns_torrent_dp_set_voltages(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_set_voltages() argument
1431 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1438 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1441 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1444 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1447 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1451 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1455 val = cdns_torrent_phy_read(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1462 cdns_torrent_phy_write(cdns_phy->regmap_tx_lane_cdb[lane], in cdns_torrent_dp_set_voltages()
1471 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_configure() local
1481 ret = cdns_torrent_dp_set_lanes(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
1489 ret = cdns_torrent_dp_set_rate(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
1497 cdns_torrent_dp_set_voltages(cdns_phy, &opts->dp); in cdns_torrent_dp_configure()
1505 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_on() local
1509 if (cdns_phy->nsubnodes == 1) { in cdns_torrent_phy_on()
1514 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_on()
1523 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pma_cmn_ctrl_1, in cdns_torrent_phy_on()
1527 dev_err(cdns_phy->dev, "Timeout waiting for CMN ready\n"); in cdns_torrent_phy_on()
1532 ret = regmap_field_read_poll_timeout(cdns_phy->phy_pcs_iso_link_ctrl_1[inst->mlane], in cdns_torrent_phy_on()
1536 dev_err(cdns_phy->dev, "Timeout waiting for PHY status ready\n"); in cdns_torrent_phy_on()
1547 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_off() local
1550 if (cdns_phy->nsubnodes != 1) in cdns_torrent_phy_off()
1553 ret = reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_off()
1560 static void cdns_torrent_dp_common_init(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_common_init() argument
1563 struct regmap *regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_common_init()
1572 cdns_torrent_dp_set_a0_pll(cdns_phy, inst->num_lanes); in cdns_torrent_dp_common_init()
1589 if (cdns_phy->ref_clk_rate == CLK_19_2_MHZ) in cdns_torrent_dp_common_init()
1590 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy, in cdns_torrent_dp_common_init()
1591 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1593 else if (cdns_phy->ref_clk_rate == CLK_25_MHZ) in cdns_torrent_dp_common_init()
1594 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy, in cdns_torrent_dp_common_init()
1595 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1597 else if (cdns_phy->ref_clk_rate == CLK_100_MHZ) in cdns_torrent_dp_common_init()
1598 cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(cdns_phy, in cdns_torrent_dp_common_init()
1599 cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1602 cdns_torrent_dp_pma_cmn_rate(cdns_phy, cdns_phy->max_bit_rate, in cdns_torrent_dp_common_init()
1606 regmap_field_write(cdns_phy->phy_reset_ctrl, 0x1); in cdns_torrent_dp_common_init()
1609 static int cdns_torrent_dp_start(struct cdns_torrent_phy *cdns_phy, in cdns_torrent_dp_start() argument
1617 ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy); in cdns_torrent_dp_start()
1621 ret = cdns_torrent_dp_run(cdns_phy, inst->num_lanes); in cdns_torrent_dp_start()
1629 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_dp_init() local
1631 switch (cdns_phy->ref_clk_rate) { in cdns_torrent_dp_init()
1638 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n"); in cdns_torrent_dp_init()
1642 cdns_torrent_dp_common_init(cdns_phy, inst); in cdns_torrent_dp_init()
1644 return cdns_torrent_dp_start(cdns_phy, inst, phy); in cdns_torrent_dp_init()
1681 static int cdns_torrent_derived_refclk_register(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_derived_refclk_register() argument
1684 struct device *dev = cdns_phy->dev; in cdns_torrent_derived_refclk_register()
1716 derived_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0; in cdns_torrent_derived_refclk_register()
1717 derived_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4; in cdns_torrent_derived_refclk_register()
1726 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_DERIVED_REFCLK] = hw; in cdns_torrent_derived_refclk_register()
1764 static int cdns_torrent_received_refclk_register(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_received_refclk_register() argument
1767 struct device *dev = cdns_phy->dev; in cdns_torrent_received_refclk_register()
1799 received_refclk->phy_pipe_cmn_ctrl1_0 = cdns_phy->phy_pipe_cmn_ctrl1_0; in cdns_torrent_received_refclk_register()
1800 received_refclk->cmn_cdiag_refclk_ovrd_4 = cdns_phy->cmn_cdiag_refclk_ovrd_4; in cdns_torrent_received_refclk_register()
1809 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_RECEIVED_REFCLK] = hw; in cdns_torrent_received_refclk_register()
1868 static int cdns_torrent_refclk_driver_register(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_refclk_driver_register() argument
1871 struct device *dev = cdns_phy->dev; in cdns_torrent_refclk_driver_register()
1891 hw = cdns_phy->clk_hw_data->hws[refclk_driver_parent_index[i]]; in cdns_torrent_refclk_driver_register()
1910 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_refclk_driver_register()
1931 cdns_phy->clk_hw_data->hws[CDNS_TORRENT_REFCLK_DRIVER] = hw; in cdns_torrent_refclk_driver_register()
1954 static int cdns_torrent_dp_regfield_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_regfield_init() argument
1956 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regfield_init()
1960 regmap = cdns_phy->regmap_dptx_phy_reg; in cdns_torrent_dp_regfield_init()
1966 cdns_phy->phy_reset_ctrl = field; in cdns_torrent_dp_regfield_init()
1971 static int cdns_torrent_regfield_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_regfield_init() argument
1973 struct device *dev = cdns_phy->dev; in cdns_torrent_regfield_init()
1978 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
1984 cdns_phy->phy_pll_cfg = field; in cdns_torrent_regfield_init()
1986 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_regfield_init()
1992 cdns_phy->phy_pipe_cmn_ctrl1_0 = field; in cdns_torrent_regfield_init()
1994 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_regfield_init()
2000 cdns_phy->cmn_cdiag_refclk_ovrd_4 = field; in cdns_torrent_regfield_init()
2002 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2008 cdns_phy->phy_pma_cmn_ctrl_1 = field; in cdns_torrent_regfield_init()
2010 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2016 cdns_phy->phy_pma_cmn_ctrl_2 = field; in cdns_torrent_regfield_init()
2018 regmap = cdns_phy->regmap_phy_pma_common_cdb; in cdns_torrent_regfield_init()
2024 cdns_phy->phy_pma_pll_raw_ctrl = field; in cdns_torrent_regfield_init()
2027 regmap = cdns_phy->regmap_phy_pcs_lane_cdb[i]; in cdns_torrent_regfield_init()
2033 cdns_phy->phy_pcs_iso_link_ctrl_1[i] = field; in cdns_torrent_regfield_init()
2039 static int cdns_torrent_dp_regmap_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_dp_regmap_init() argument
2041 void __iomem *base = cdns_phy->base; in cdns_torrent_dp_regmap_init()
2042 struct device *dev = cdns_phy->dev; in cdns_torrent_dp_regmap_init()
2047 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_dp_regmap_init()
2057 cdns_phy->regmap_dptx_phy_reg = regmap; in cdns_torrent_dp_regmap_init()
2062 static int cdns_torrent_regmap_init(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_regmap_init() argument
2064 void __iomem *sd_base = cdns_phy->sd_base; in cdns_torrent_regmap_init()
2066 struct device *dev = cdns_phy->dev; in cdns_torrent_regmap_init()
2071 block_offset_shift = cdns_phy->init_data->block_offset_shift; in cdns_torrent_regmap_init()
2072 reg_offset_shift = cdns_phy->init_data->reg_offset_shift; in cdns_torrent_regmap_init()
2084 cdns_phy->regmap_tx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2095 cdns_phy->regmap_rx_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2106 cdns_phy->regmap_phy_pcs_lane_cdb[i] = regmap; in cdns_torrent_regmap_init()
2117 cdns_phy->regmap_common_cdb = regmap; in cdns_torrent_regmap_init()
2127 cdns_phy->regmap_phy_pcs_common_cdb = regmap; in cdns_torrent_regmap_init()
2137 cdns_phy->regmap_phy_pma_common_cdb = regmap; in cdns_torrent_regmap_init()
2144 struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent); in cdns_torrent_phy_init() local
2145 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_init()
2147 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_init()
2158 if (cdns_phy->nsubnodes > 1) in cdns_torrent_phy_init()
2173 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
2179 regmap_field_write(cdns_phy->phy_pll_cfg, reg_pairs[0].val); in cdns_torrent_phy_init()
2191 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2203 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_init()
2214 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_init()
2226 regmap = cdns_phy->regmap_tx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2239 regmap = cdns_phy->regmap_rx_lane_cdb[i + inst->mlane]; in cdns_torrent_phy_init()
2274 int cdns_torrent_phy_configure_multilink(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_phy_configure_multilink() argument
2276 const struct cdns_torrent_data *init_data = cdns_phy->init_data; in cdns_torrent_phy_configure_multilink()
2278 enum cdns_torrent_ref_clk ref_clk = cdns_phy->ref_clk_rate; in cdns_torrent_phy_configure_multilink()
2289 if (cdns_phy->nsubnodes != 2) in cdns_torrent_phy_configure_multilink()
2292 phy_t1 = cdns_phy->phys[0].phy_type; in cdns_torrent_phy_configure_multilink()
2293 phy_t2 = cdns_phy->phys[1].phy_type; in cdns_torrent_phy_configure_multilink()
2299 for (node = 0; node < cdns_phy->nsubnodes; node++) { in cdns_torrent_phy_configure_multilink()
2309 mlane = cdns_phy->phys[node].mlane; in cdns_torrent_phy_configure_multilink()
2310 ssc = cdns_phy->phys[node].ssc_mode; in cdns_torrent_phy_configure_multilink()
2311 num_lanes = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_configure_multilink()
2327 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2333 regmap_field_write(cdns_phy->phy_pll_cfg, in cdns_torrent_phy_configure_multilink()
2346 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2358 regmap = cdns_phy->regmap_phy_pcs_common_cdb; in cdns_torrent_phy_configure_multilink()
2369 regmap = cdns_phy->regmap_common_cdb; in cdns_torrent_phy_configure_multilink()
2381 regmap = cdns_phy->regmap_tx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2394 regmap = cdns_phy->regmap_rx_lane_cdb[i + mlane]; in cdns_torrent_phy_configure_multilink()
2401 reset_control_deassert(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_configure_multilink()
2405 ret = reset_control_deassert(cdns_phy->phy_rst); in cdns_torrent_phy_configure_multilink()
2412 static void cdns_torrent_clk_cleanup(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_clk_cleanup() argument
2414 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_cleanup()
2419 static int cdns_torrent_clk_register(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_clk_register() argument
2421 struct device *dev = cdns_phy->dev; in cdns_torrent_clk_register()
2431 cdns_phy->clk_hw_data = data; in cdns_torrent_clk_register()
2433 ret = cdns_torrent_derived_refclk_register(cdns_phy); in cdns_torrent_clk_register()
2439 ret = cdns_torrent_received_refclk_register(cdns_phy); in cdns_torrent_clk_register()
2445 ret = cdns_torrent_refclk_driver_register(cdns_phy); in cdns_torrent_clk_register()
2460 static int cdns_torrent_reset(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_reset() argument
2462 struct device *dev = cdns_phy->dev; in cdns_torrent_reset()
2464 cdns_phy->phy_rst = devm_reset_control_get_exclusive_by_index(dev, 0); in cdns_torrent_reset()
2465 if (IS_ERR(cdns_phy->phy_rst)) { in cdns_torrent_reset()
2468 return PTR_ERR(cdns_phy->phy_rst); in cdns_torrent_reset()
2471 cdns_phy->apb_rst = devm_reset_control_get_optional_exclusive(dev, "torrent_apb"); in cdns_torrent_reset()
2472 if (IS_ERR(cdns_phy->apb_rst)) { in cdns_torrent_reset()
2475 return PTR_ERR(cdns_phy->apb_rst); in cdns_torrent_reset()
2481 static int cdns_torrent_clk(struct cdns_torrent_phy *cdns_phy) in cdns_torrent_clk() argument
2483 struct device *dev = cdns_phy->dev; in cdns_torrent_clk()
2487 cdns_phy->clk = devm_clk_get(dev, "refclk"); in cdns_torrent_clk()
2488 if (IS_ERR(cdns_phy->clk)) { in cdns_torrent_clk()
2490 return PTR_ERR(cdns_phy->clk); in cdns_torrent_clk()
2493 ret = clk_prepare_enable(cdns_phy->clk); in cdns_torrent_clk()
2495 dev_err(cdns_phy->dev, "Failed to prepare ref clock\n"); in cdns_torrent_clk()
2499 ref_clk_rate = clk_get_rate(cdns_phy->clk); in cdns_torrent_clk()
2501 dev_err(cdns_phy->dev, "Failed to get ref clock rate\n"); in cdns_torrent_clk()
2502 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_clk()
2508 cdns_phy->ref_clk_rate = CLK_19_2_MHZ; in cdns_torrent_clk()
2511 cdns_phy->ref_clk_rate = CLK_25_MHZ; in cdns_torrent_clk()
2514 cdns_phy->ref_clk_rate = CLK_100_MHZ; in cdns_torrent_clk()
2517 dev_err(cdns_phy->dev, "Invalid Ref Clock Rate\n"); in cdns_torrent_clk()
2518 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_clk()
2527 struct cdns_torrent_phy *cdns_phy; in cdns_torrent_phy_probe() local
2543 cdns_phy = devm_kzalloc(dev, sizeof(*cdns_phy), GFP_KERNEL); in cdns_torrent_phy_probe()
2544 if (!cdns_phy) in cdns_torrent_phy_probe()
2547 dev_set_drvdata(dev, cdns_phy); in cdns_torrent_phy_probe()
2548 cdns_phy->dev = dev; in cdns_torrent_phy_probe()
2549 cdns_phy->init_data = data; in cdns_torrent_phy_probe()
2551 cdns_phy->sd_base = devm_platform_ioremap_resource(pdev, 0); in cdns_torrent_phy_probe()
2552 if (IS_ERR(cdns_phy->sd_base)) in cdns_torrent_phy_probe()
2553 return PTR_ERR(cdns_phy->sd_base); in cdns_torrent_phy_probe()
2561 ret = cdns_torrent_regmap_init(cdns_phy); in cdns_torrent_phy_probe()
2565 ret = cdns_torrent_regfield_init(cdns_phy); in cdns_torrent_phy_probe()
2569 ret = cdns_torrent_clk_register(cdns_phy); in cdns_torrent_phy_probe()
2573 regmap_field_read(cdns_phy->phy_pma_cmn_ctrl_1, &already_configured); in cdns_torrent_phy_probe()
2576 ret = cdns_torrent_reset(cdns_phy); in cdns_torrent_phy_probe()
2580 ret = cdns_torrent_clk(cdns_phy); in cdns_torrent_phy_probe()
2585 reset_control_deassert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2595 cdns_phy->phys[node].lnk_rst = in cdns_torrent_phy_probe()
2597 if (IS_ERR(cdns_phy->phys[node].lnk_rst)) { in cdns_torrent_phy_probe()
2600 ret = PTR_ERR(cdns_phy->phys[node].lnk_rst); in cdns_torrent_phy_probe()
2605 &cdns_phy->phys[node].mlane)) { in cdns_torrent_phy_probe()
2621 cdns_phy->phys[node].phy_type = TYPE_PCIE; in cdns_torrent_phy_probe()
2624 cdns_phy->phys[node].phy_type = TYPE_DP; in cdns_torrent_phy_probe()
2627 cdns_phy->phys[node].phy_type = TYPE_SGMII; in cdns_torrent_phy_probe()
2630 cdns_phy->phys[node].phy_type = TYPE_QSGMII; in cdns_torrent_phy_probe()
2633 cdns_phy->phys[node].phy_type = TYPE_USB; in cdns_torrent_phy_probe()
2642 &cdns_phy->phys[node].num_lanes)) { in cdns_torrent_phy_probe()
2649 total_num_lanes += cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2652 cdns_phy->phys[node].ssc_mode = NO_SSC; in cdns_torrent_phy_probe()
2654 &cdns_phy->phys[node].ssc_mode); in cdns_torrent_phy_probe()
2665 if (cdns_phy->phys[node].phy_type == TYPE_DP) { in cdns_torrent_phy_probe()
2666 switch (cdns_phy->phys[node].num_lanes) { in cdns_torrent_phy_probe()
2674 cdns_phy->phys[node].num_lanes); in cdns_torrent_phy_probe()
2679 cdns_phy->max_bit_rate = DEFAULT_MAX_BIT_RATE; in cdns_torrent_phy_probe()
2681 &cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2683 switch (cdns_phy->max_bit_rate) { in cdns_torrent_phy_probe()
2696 cdns_phy->max_bit_rate); in cdns_torrent_phy_probe()
2702 cdns_phy->base = devm_platform_ioremap_resource(pdev, 1); in cdns_torrent_phy_probe()
2703 if (IS_ERR(cdns_phy->base)) { in cdns_torrent_phy_probe()
2704 ret = PTR_ERR(cdns_phy->base); in cdns_torrent_phy_probe()
2709 ret = cdns_torrent_dp_regmap_init(cdns_phy); in cdns_torrent_phy_probe()
2713 ret = cdns_torrent_dp_regfield_init(cdns_phy); in cdns_torrent_phy_probe()
2721 cdns_phy->max_bit_rate / 1000, in cdns_torrent_phy_probe()
2722 cdns_phy->max_bit_rate % 1000); in cdns_torrent_phy_probe()
2724 gphy->attrs.bus_width = cdns_phy->phys[node].num_lanes; in cdns_torrent_phy_probe()
2725 gphy->attrs.max_link_rate = cdns_phy->max_bit_rate; in cdns_torrent_phy_probe()
2729 cdns_phy->phys[node].phy = gphy; in cdns_torrent_phy_probe()
2730 phy_set_drvdata(gphy, &cdns_phy->phys[node]); in cdns_torrent_phy_probe()
2734 cdns_phy->nsubnodes = node; in cdns_torrent_phy_probe()
2742 if (cdns_phy->nsubnodes > 1 && !already_configured) { in cdns_torrent_phy_probe()
2743 ret = cdns_torrent_phy_configure_multilink(cdns_phy); in cdns_torrent_phy_probe()
2754 if (cdns_phy->nsubnodes > 1) in cdns_torrent_phy_probe()
2756 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
2757 cdns_phy->phys[0].num_lanes, in cdns_torrent_phy_probe()
2758 cdns_torrent_get_phy_type(cdns_phy->phys[1].phy_type), in cdns_torrent_phy_probe()
2759 cdns_phy->phys[1].num_lanes); in cdns_torrent_phy_probe()
2762 cdns_torrent_get_phy_type(cdns_phy->phys[0].phy_type), in cdns_torrent_phy_probe()
2763 cdns_phy->phys[0].num_lanes); in cdns_torrent_phy_probe()
2771 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_probe()
2773 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_probe()
2774 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_probe()
2776 cdns_torrent_clk_cleanup(cdns_phy); in cdns_torrent_phy_probe()
2782 struct cdns_torrent_phy *cdns_phy = platform_get_drvdata(pdev); in cdns_torrent_phy_remove() local
2785 reset_control_assert(cdns_phy->phy_rst); in cdns_torrent_phy_remove()
2786 reset_control_assert(cdns_phy->apb_rst); in cdns_torrent_phy_remove()
2787 for (i = 0; i < cdns_phy->nsubnodes; i++) { in cdns_torrent_phy_remove()
2788 reset_control_assert(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
2789 reset_control_put(cdns_phy->phys[i].lnk_rst); in cdns_torrent_phy_remove()
2792 clk_disable_unprepare(cdns_phy->clk); in cdns_torrent_phy_remove()
2793 cdns_torrent_clk_cleanup(cdns_phy); in cdns_torrent_phy_remove()