Skip to content

Commit 45b14bd

Browse files
cristiccvinodkoul
authored andcommitted
phy: rockchip: samsung-hdptx: Optimize internal rate handling
Drop the rate parameter from a bunch of internal helpers and, instead, make better use of the newly introduced ->hdmi_cfg.tmds_char_rate driver data. Signed-off-by: Cristian Ciocaltea <[email protected]> Acked-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 37f335d commit 45b14bd

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

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

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -968,31 +968,34 @@ static bool rk_hdptx_phy_clk_pll_calc(unsigned long long rate,
968968
return true;
969969
}
970970

971-
static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
972-
unsigned long long rate)
971+
static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx)
973972
{
974973
const struct ropll_config *cfg = NULL;
975974
struct ropll_config rc = {0};
976975
int ret, i;
977976

977+
if (!hdptx->hdmi_cfg.tmds_char_rate)
978+
return 0;
979+
978980
for (i = 0; i < ARRAY_SIZE(ropll_tmds_cfg); i++)
979-
if (rate == ropll_tmds_cfg[i].rate) {
981+
if (hdptx->hdmi_cfg.tmds_char_rate == ropll_tmds_cfg[i].rate) {
980982
cfg = &ropll_tmds_cfg[i];
981983
break;
982984
}
983985

984986
if (!cfg) {
985-
if (rk_hdptx_phy_clk_pll_calc(rate, &rc)) {
986-
cfg = &rc;
987-
} else {
988-
dev_err(hdptx->dev, "%s cannot find pll cfg\n", __func__);
987+
if (!rk_hdptx_phy_clk_pll_calc(hdptx->hdmi_cfg.tmds_char_rate, &rc)) {
988+
dev_err(hdptx->dev, "%s cannot find pll cfg for rate=%llu\n",
989+
__func__, hdptx->hdmi_cfg.tmds_char_rate);
989990
return -EINVAL;
990991
}
992+
993+
cfg = &rc;
991994
}
992995

993996
dev_dbg(hdptx->dev, "%s rate=%llu mdiv=%u sdiv=%u sdm_en=%u k_sign=%u k=%u lc=%u\n",
994-
__func__, rate, cfg->pms_mdiv, cfg->pms_sdiv + 1, cfg->sdm_en,
995-
cfg->sdm_num_sign, cfg->sdm_num, cfg->sdm_deno);
997+
__func__, hdptx->hdmi_cfg.tmds_char_rate, cfg->pms_mdiv, cfg->pms_sdiv + 1,
998+
cfg->sdm_en, cfg->sdm_num_sign, cfg->sdm_num, cfg->sdm_deno);
996999

9971000
rk_hdptx_pre_power_up(hdptx);
9981001

@@ -1030,19 +1033,18 @@ static int rk_hdptx_ropll_tmds_cmn_config(struct rk_hdptx_phy *hdptx,
10301033

10311034
ret = rk_hdptx_post_enable_pll(hdptx);
10321035
if (!ret)
1033-
hdptx->hw_rate = rate;
1036+
hdptx->hw_rate = hdptx->hdmi_cfg.tmds_char_rate;
10341037

10351038
return ret;
10361039
}
10371040

1038-
static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx,
1039-
unsigned long long rate)
1041+
static int rk_hdptx_ropll_tmds_mode_config(struct rk_hdptx_phy *hdptx)
10401042
{
10411043
rk_hdptx_multi_reg_write(hdptx, rk_hdtpx_common_sb_init_seq);
10421044

10431045
regmap_write(hdptx->regmap, LNTOP_REG(0200), 0x06);
10441046

1045-
if (rate > HDMI14_MAX_RATE) {
1047+
if (hdptx->hdmi_cfg.tmds_char_rate > HDMI14_MAX_RATE) {
10461048
/* For 1/40 bitrate clk */
10471049
rk_hdptx_multi_reg_write(hdptx, rk_hdtpx_tmds_lntop_highbr_seq);
10481050
} else {
@@ -1094,8 +1096,7 @@ static void rk_hdptx_dp_reset(struct rk_hdptx_phy *hdptx)
10941096
HDPTX_I_BGR_EN << 16 | FIELD_PREP(HDPTX_I_BGR_EN, 0x0));
10951097
}
10961098

1097-
static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx,
1098-
unsigned long long rate)
1099+
static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx)
10991100
{
11001101
enum phy_mode mode = phy_get_mode(hdptx->phy);
11011102
u32 status;
@@ -1114,11 +1115,9 @@ static int rk_hdptx_phy_consumer_get(struct rk_hdptx_phy *hdptx,
11141115
if (mode == PHY_MODE_DP) {
11151116
rk_hdptx_dp_reset(hdptx);
11161117
} else {
1117-
if (rate) {
1118-
ret = rk_hdptx_ropll_tmds_cmn_config(hdptx, rate);
1119-
if (ret)
1120-
goto dec_usage;
1121-
}
1118+
ret = rk_hdptx_ropll_tmds_cmn_config(hdptx);
1119+
if (ret)
1120+
goto dec_usage;
11221121
}
11231122

11241123
return 0;
@@ -1431,7 +1430,7 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
14311430
dev_dbg(hdptx->dev, "%s rate=%llu\n", __func__, hdptx->hdmi_cfg.tmds_char_rate);
14321431
}
14331432

1434-
ret = rk_hdptx_phy_consumer_get(hdptx, hdptx->hdmi_cfg.tmds_char_rate);
1433+
ret = rk_hdptx_phy_consumer_get(hdptx);
14351434
if (ret)
14361435
return ret;
14371436

@@ -1462,7 +1461,7 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
14621461
regmap_write(hdptx->grf, GRF_HDPTX_CON0,
14631462
HDPTX_MODE_SEL << 16 | FIELD_PREP(HDPTX_MODE_SEL, 0x0));
14641463

1465-
ret = rk_hdptx_ropll_tmds_mode_config(hdptx, hdptx->hdmi_cfg.tmds_char_rate);
1464+
ret = rk_hdptx_ropll_tmds_mode_config(hdptx);
14661465
if (ret)
14671466
rk_hdptx_phy_consumer_put(hdptx, true);
14681467
}
@@ -1830,7 +1829,7 @@ static int rk_hdptx_phy_clk_prepare(struct clk_hw *hw)
18301829
{
18311830
struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
18321831

1833-
return rk_hdptx_phy_consumer_get(hdptx, hdptx->hw_rate);
1832+
return rk_hdptx_phy_consumer_get(hdptx);
18341833
}
18351834

18361835
static void rk_hdptx_phy_clk_unprepare(struct clk_hw *hw)
@@ -1897,7 +1896,7 @@ static int rk_hdptx_phy_clk_set_rate(struct clk_hw *hw, unsigned long rate,
18971896
* while the latter being executed only once, i.e. when clock remains
18981897
* in the prepared state during rate changes.
18991898
*/
1900-
return rk_hdptx_ropll_tmds_cmn_config(hdptx, rate);
1899+
return rk_hdptx_ropll_tmds_cmn_config(hdptx);
19011900
}
19021901

19031902
static const struct clk_ops hdptx_phy_clk_ops = {

0 commit comments

Comments
 (0)