Skip to content

Commit c871a31

Browse files
cristiccvinodkoul
authored andcommitted
phy: rockchip: samsung-hdptx: Setup TMDS char rate via phy_configure_opts_hdmi
The current workaround to setup the TMDS character rate relies on the unconventional usage of phy_set_bus_width(). Make use of the recently introduced HDMI PHY configuration API to properly handle the setup. The workaround will be dropped as soon as the switch has been completed on both ends. Rename rk_hdptx_phy_verify_config() to rk_hdptx_phy_verify_dp_config() and introduce the rk_hdptx_phy_verify_hdmi_config() helper to check the HDMI parameters during phy_configure(). Signed-off-by: Cristian Ciocaltea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 0edf9d2 commit c871a31

File tree

1 file changed

+47
-17
lines changed

1 file changed

+47
-17
lines changed

drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ struct rk_hdptx_phy {
394394

395395
int phy_id;
396396
struct phy *phy;
397+
struct phy_configure_opts_hdmi hdmi_cfg;
397398
struct clk_bulk_data *clks;
398399
int nr_clks;
399400
struct reset_control_bulk_data rsts[RST_MAX];
@@ -1412,20 +1413,24 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
14121413
{
14131414
struct rk_hdptx_phy *hdptx = phy_get_drvdata(phy);
14141415
enum phy_mode mode = phy_get_mode(phy);
1415-
unsigned long long rate;
14161416
int ret, lane;
14171417

1418-
/*
1419-
* FIXME: Temporary workaround to pass pixel_clk_rate
1420-
* from the HDMI bridge driver until phy_configure_opts_hdmi
1421-
* becomes available in the PHY API.
1422-
*/
1423-
rate = phy_get_bus_width(hdptx->phy) & 0xfffffff;
1424-
rate *= 100;
1418+
if (mode != PHY_MODE_DP) {
1419+
if (!hdptx->hdmi_cfg.tmds_char_rate) {
1420+
/*
1421+
* FIXME: Temporary workaround to setup TMDS char rate
1422+
* from the RK DW HDMI QP bridge driver.
1423+
* Will be removed as soon the switch to the HDMI PHY
1424+
* configuration API has been completed on both ends.
1425+
*/
1426+
hdptx->hdmi_cfg.tmds_char_rate = phy_get_bus_width(hdptx->phy) & 0xfffffff;
1427+
hdptx->hdmi_cfg.tmds_char_rate *= 100;
1428+
}
14251429

1426-
dev_dbg(hdptx->dev, "%s rate=%llu\n", __func__, rate);
1430+
dev_dbg(hdptx->dev, "%s rate=%llu\n", __func__, hdptx->hdmi_cfg.tmds_char_rate);
1431+
}
14271432

1428-
ret = rk_hdptx_phy_consumer_get(hdptx, rate);
1433+
ret = rk_hdptx_phy_consumer_get(hdptx, hdptx->hdmi_cfg.tmds_char_rate);
14291434
if (ret)
14301435
return ret;
14311436

@@ -1456,7 +1461,7 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
14561461
regmap_write(hdptx->grf, GRF_HDPTX_CON0,
14571462
HDPTX_MODE_SEL << 16 | FIELD_PREP(HDPTX_MODE_SEL, 0x0));
14581463

1459-
ret = rk_hdptx_ropll_tmds_mode_config(hdptx, rate);
1464+
ret = rk_hdptx_ropll_tmds_mode_config(hdptx, hdptx->hdmi_cfg.tmds_char_rate);
14601465
if (ret)
14611466
rk_hdptx_phy_consumer_put(hdptx, true);
14621467
}
@@ -1471,8 +1476,27 @@ static int rk_hdptx_phy_power_off(struct phy *phy)
14711476
return rk_hdptx_phy_consumer_put(hdptx, false);
14721477
}
14731478

1474-
static int rk_hdptx_phy_verify_config(struct rk_hdptx_phy *hdptx,
1475-
struct phy_configure_opts_dp *dp)
1479+
static int rk_hdptx_phy_verify_hdmi_config(struct rk_hdptx_phy *hdptx,
1480+
struct phy_configure_opts_hdmi *hdmi)
1481+
{
1482+
int i;
1483+
1484+
if (!hdmi->tmds_char_rate || hdmi->tmds_char_rate > HDMI20_MAX_RATE)
1485+
return -EINVAL;
1486+
1487+
for (i = 0; i < ARRAY_SIZE(ropll_tmds_cfg); i++)
1488+
if (hdmi->tmds_char_rate == ropll_tmds_cfg[i].rate)
1489+
break;
1490+
1491+
if (i == ARRAY_SIZE(ropll_tmds_cfg) &&
1492+
!rk_hdptx_phy_clk_pll_calc(hdmi->tmds_char_rate, NULL))
1493+
return -EINVAL;
1494+
1495+
return 0;
1496+
}
1497+
1498+
static int rk_hdptx_phy_verify_dp_config(struct rk_hdptx_phy *hdptx,
1499+
struct phy_configure_opts_dp *dp)
14761500
{
14771501
int i;
14781502

@@ -1732,12 +1756,18 @@ static int rk_hdptx_phy_configure(struct phy *phy, union phy_configure_opts *opt
17321756
enum phy_mode mode = phy_get_mode(phy);
17331757
int ret;
17341758

1735-
if (mode != PHY_MODE_DP)
1736-
return 0;
1759+
if (mode != PHY_MODE_DP) {
1760+
ret = rk_hdptx_phy_verify_hdmi_config(hdptx, &opts->hdmi);
1761+
if (ret)
1762+
dev_err(hdptx->dev, "invalid hdmi params for phy configure\n");
1763+
else
1764+
hdptx->hdmi_cfg = opts->hdmi;
1765+
return ret;
1766+
}
17371767

1738-
ret = rk_hdptx_phy_verify_config(hdptx, &opts->dp);
1768+
ret = rk_hdptx_phy_verify_dp_config(hdptx, &opts->dp);
17391769
if (ret) {
1740-
dev_err(hdptx->dev, "invalid params for phy configure\n");
1770+
dev_err(hdptx->dev, "invalid dp params for phy configure\n");
17411771
return ret;
17421772
}
17431773

0 commit comments

Comments
 (0)