Skip to content

Commit

Permalink
phy: cadence-torrent: Add function to get PLL to be configured for DP
Browse files Browse the repository at this point in the history
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: Swapnil Jakhade <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vinod Koul <[email protected]>
  • Loading branch information
sjakhadecdns authored and vinodkoul committed May 8, 2023
1 parent d8c66cb commit 1b0524f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions drivers/phy/cadence/phy-cadence-torrent.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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:
Expand All @@ -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);
Expand Down

0 comments on commit 1b0524f

Please sign in to comment.