Commit 1b0524fc authored by Swapnil Jakhade's avatar Swapnil Jakhade Committed by Vinod Koul

phy: cadence-torrent: Add function to get PLL to be configured for DP

Torrent PHY PLL0 or PLL1 is used for DP depending on the single link or
multilink protocol configuration for which PHY is configured. In multilink
configurations with other protocols, either PLL0 or PLL1 will be used
for DP. For single link DP, both PLLs need to be configured at POR.
Signed-off-by: default avatarSwapnil Jakhade <sjakhade@cadence.com>
Link: https://lore.kernel.org/r/20230418173157.25607-2-sjakhade@cadence.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent d8c66cbb
......@@ -38,6 +38,9 @@
#define POLL_TIMEOUT_US 5000
#define PLL_LOCK_TIMEOUT 100000
#define DP_PLL0 BIT(0)
#define DP_PLL1 BIT(1)
#define TORRENT_COMMON_CDB_OFFSET 0x0
#define TORRENT_TX_LANE_CDB_OFFSET(ln, block_offset, reg_offset) \
......@@ -323,6 +326,7 @@ struct cdns_torrent_phy {
void __iomem *base; /* DPTX registers base */
void __iomem *sd_base; /* SD0801 registers base */
u32 max_bit_rate; /* Maximum link bit rate to use (in Mbps) */
u32 dp_pll;
struct reset_control *phy_rst;
struct reset_control *apb_rst;
struct device *dev;
......@@ -977,6 +981,30 @@ void cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(struct cdns_torrent_phy *cdns_phy,
}
}
/* Set PLL used for DP configuration */
static int cdns_torrent_dp_get_pll(struct cdns_torrent_phy *cdns_phy,
enum cdns_torrent_phy_type phy_t2)
{
switch (phy_t2) {
case TYPE_PCIE:
case TYPE_USB:
cdns_phy->dp_pll = DP_PLL1;
break;
case TYPE_SGMII:
case TYPE_QSGMII:
cdns_phy->dp_pll = DP_PLL0;
break;
case TYPE_NONE:
cdns_phy->dp_pll = DP_PLL0 | DP_PLL1;
break;
default:
dev_err(cdns_phy->dev, "Unsupported PHY configuration\n");
return -EINVAL;
}
return 0;
}
/*
* Enable or disable PLL for selected lanes.
*/
......@@ -1627,6 +1655,7 @@ static int cdns_torrent_dp_init(struct phy *phy)
{
struct cdns_torrent_inst *inst = phy_get_drvdata(phy);
struct cdns_torrent_phy *cdns_phy = dev_get_drvdata(phy->dev.parent);
int ret;
switch (cdns_phy->ref_clk_rate) {
case CLK_19_2_MHZ:
......@@ -1639,6 +1668,10 @@ static int cdns_torrent_dp_init(struct phy *phy)
return -EINVAL;
}
ret = cdns_torrent_dp_get_pll(cdns_phy, TYPE_NONE);
if (ret)
return ret;
cdns_torrent_dp_common_init(cdns_phy, inst);
return cdns_torrent_dp_start(cdns_phy, inst, phy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment