Skip to content

Commit ac079c1

Browse files
cristiccvinodkoul
authored andcommitted
phy: rockchip: samsung-hdptx: Switch to driver specific HDMI config
In preparation to support the FRL operation mode which gets configured via the lanes and rate per lane tuple, switch to a driver specific struct for configuring the link rate and bpc. This simplifies and optimizes the implementation by allowing implicit switches between TMDS and FRL rates, without requiring additional checks of the active PHY mode followed by recalculations of the link rate when operating in FRL mode. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://patch.msgid.link/20260113-phy-hdptx-frl-v6-9-8d5f97419c0b@collabora.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 66d76b6 commit ac079c1

1 file changed

Lines changed: 26 additions & 21 deletions

File tree

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

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,19 @@ struct rk_hdptx_phy_cfg {
373373
unsigned int phy_ids[MAX_HDPTX_PHY_NUM];
374374
};
375375

376+
struct rk_hdptx_hdmi_cfg {
377+
unsigned long long rate;
378+
unsigned int bpc;
379+
};
380+
376381
struct rk_hdptx_phy {
377382
struct device *dev;
378383
struct regmap *regmap;
379384
struct regmap *grf;
380385

381386
int phy_id;
382387
struct phy *phy;
383-
struct phy_configure_opts_hdmi hdmi_cfg;
388+
struct rk_hdptx_hdmi_cfg hdmi_cfg;
384389
struct clk_bulk_data *clks;
385390
int nr_clks;
386391
struct reset_control_bulk_data rsts[RST_MAX];
@@ -932,27 +937,27 @@ static int rk_hdptx_tmds_ropll_cmn_config(struct rk_hdptx_phy *hdptx)
932937
struct ropll_config rc = {0};
933938
int i;
934939

935-
if (!hdptx->hdmi_cfg.tmds_char_rate)
940+
if (!hdptx->hdmi_cfg.rate)
936941
return 0;
937942

938943
for (i = 0; i < ARRAY_SIZE(rk_hdptx_tmds_ropll_cfg); i++)
939-
if (hdptx->hdmi_cfg.tmds_char_rate == rk_hdptx_tmds_ropll_cfg[i].rate) {
944+
if (hdptx->hdmi_cfg.rate == rk_hdptx_tmds_ropll_cfg[i].rate) {
940945
cfg = &rk_hdptx_tmds_ropll_cfg[i];
941946
break;
942947
}
943948

944949
if (!cfg) {
945-
if (!rk_hdptx_phy_clk_pll_calc(hdptx->hdmi_cfg.tmds_char_rate, &rc)) {
950+
if (!rk_hdptx_phy_clk_pll_calc(hdptx->hdmi_cfg.rate, &rc)) {
946951
dev_err(hdptx->dev, "%s cannot find pll cfg for rate=%llu\n",
947-
__func__, hdptx->hdmi_cfg.tmds_char_rate);
952+
__func__, hdptx->hdmi_cfg.rate);
948953
return -EINVAL;
949954
}
950955

951956
cfg = &rc;
952957
}
953958

954959
dev_dbg(hdptx->dev, "%s rate=%llu mdiv=%u sdiv=%u sdm_en=%u k_sign=%u k=%u lc=%u\n",
955-
__func__, hdptx->hdmi_cfg.tmds_char_rate, cfg->pms_mdiv, cfg->pms_sdiv + 1,
960+
__func__, hdptx->hdmi_cfg.rate, cfg->pms_mdiv, cfg->pms_sdiv + 1,
956961
cfg->sdm_en, cfg->sdm_num_sign, cfg->sdm_num, cfg->sdm_deno);
957962

958963
rk_hdptx_pre_power_up(hdptx);
@@ -1001,7 +1006,7 @@ static int rk_hdptx_tmds_ropll_mode_config(struct rk_hdptx_phy *hdptx)
10011006

10021007
regmap_write(hdptx->regmap, LNTOP_REG(0200), 0x06);
10031008

1004-
if (hdptx->hdmi_cfg.tmds_char_rate > HDMI14_MAX_RATE) {
1009+
if (hdptx->hdmi_cfg.rate > HDMI14_MAX_RATE) {
10051010
/* For 1/40 bitrate clk */
10061011
rk_hdptx_multi_reg_write(hdptx, rk_hdptx_tmds_lntop_highbr_seq);
10071012
} else {
@@ -1372,19 +1377,19 @@ static int rk_hdptx_phy_power_on(struct phy *phy)
13721377
int ret, lane;
13731378

13741379
if (mode != PHY_MODE_DP) {
1375-
if (!hdptx->hdmi_cfg.tmds_char_rate) {
1380+
if (!hdptx->hdmi_cfg.rate) {
13761381
/*
13771382
* FIXME: Temporary workaround to setup TMDS char rate
13781383
* from the RK DW HDMI QP bridge driver.
13791384
* Will be removed as soon the switch to the HDMI PHY
13801385
* configuration API has been completed on both ends.
13811386
*/
1382-
hdptx->hdmi_cfg.tmds_char_rate = phy_get_bus_width(hdptx->phy) & 0xfffffff;
1383-
hdptx->hdmi_cfg.tmds_char_rate *= 100;
1387+
hdptx->hdmi_cfg.rate = phy_get_bus_width(hdptx->phy) & 0xfffffff;
1388+
hdptx->hdmi_cfg.rate *= 100;
13841389
}
13851390

13861391
dev_dbg(hdptx->dev, "%s rate=%llu bpc=%u\n", __func__,
1387-
hdptx->hdmi_cfg.tmds_char_rate, hdptx->hdmi_cfg.bpc);
1392+
hdptx->hdmi_cfg.rate, hdptx->hdmi_cfg.bpc);
13881393
}
13891394

13901395
ret = rk_hdptx_phy_consumer_get(hdptx);
@@ -1731,12 +1736,13 @@ static int rk_hdptx_phy_configure(struct phy *phy, union phy_configure_opts *opt
17311736
if (ret) {
17321737
dev_err(hdptx->dev, "invalid hdmi params for phy configure\n");
17331738
} else {
1734-
hdptx->hdmi_cfg = opts->hdmi;
1739+
hdptx->hdmi_cfg.rate = opts->hdmi.tmds_char_rate;
1740+
hdptx->hdmi_cfg.bpc = opts->hdmi.bpc;
17351741
hdptx->restrict_rate_change = true;
17361742
}
17371743

17381744
dev_dbg(hdptx->dev, "%s rate=%llu bpc=%u\n", __func__,
1739-
hdptx->hdmi_cfg.tmds_char_rate, hdptx->hdmi_cfg.bpc);
1745+
hdptx->hdmi_cfg.rate, hdptx->hdmi_cfg.bpc);
17401746
return ret;
17411747
}
17421748

@@ -1916,7 +1922,7 @@ static int rk_hdptx_phy_clk_determine_rate(struct clk_hw *hw,
19161922
* To be dropped as soon as the RK DW HDMI QP bridge driver
19171923
* switches to make use of phy_configure().
19181924
*/
1919-
if (!hdptx->restrict_rate_change && req->rate != hdptx->hdmi_cfg.tmds_char_rate) {
1925+
if (!hdptx->restrict_rate_change && req->rate != hdptx->hdmi_cfg.rate) {
19201926
struct phy_configure_opts_hdmi hdmi = {
19211927
.tmds_char_rate = req->rate,
19221928
};
@@ -1925,16 +1931,15 @@ static int rk_hdptx_phy_clk_determine_rate(struct clk_hw *hw,
19251931
if (ret)
19261932
return ret;
19271933

1928-
hdptx->hdmi_cfg = hdmi;
1934+
hdptx->hdmi_cfg.rate = req->rate;
19291935
}
19301936

19311937
/*
19321938
* The TMDS char rate shall be adjusted via phy_configure() only,
19331939
* hence ensure rk_hdptx_phy_clk_set_rate() won't be invoked with
19341940
* a different rate argument.
19351941
*/
1936-
req->rate = DIV_ROUND_CLOSEST_ULL(hdptx->hdmi_cfg.tmds_char_rate * 8,
1937-
hdptx->hdmi_cfg.bpc);
1942+
req->rate = DIV_ROUND_CLOSEST_ULL(hdptx->hdmi_cfg.rate * 8, hdptx->hdmi_cfg.bpc);
19381943

19391944
return 0;
19401945
}
@@ -1945,11 +1950,11 @@ static int rk_hdptx_phy_clk_set_rate(struct clk_hw *hw, unsigned long rate,
19451950
struct rk_hdptx_phy *hdptx = to_rk_hdptx_phy(hw);
19461951
unsigned long long tmds_rate = DIV_ROUND_CLOSEST_ULL(rate * hdptx->hdmi_cfg.bpc, 8);
19471952

1948-
/* Revert any unlikely TMDS char rate change since round_rate() */
1949-
if (hdptx->hdmi_cfg.tmds_char_rate != tmds_rate) {
1953+
/* Revert any unlikely TMDS char rate change since determine_rate() */
1954+
if (hdptx->hdmi_cfg.rate != tmds_rate) {
19501955
dev_warn(hdptx->dev, "Reverting unexpected rate change from %llu to %llu\n",
1951-
tmds_rate, hdptx->hdmi_cfg.tmds_char_rate);
1952-
hdptx->hdmi_cfg.tmds_char_rate = tmds_rate;
1956+
tmds_rate, hdptx->hdmi_cfg.rate);
1957+
hdptx->hdmi_cfg.rate = tmds_rate;
19531958
}
19541959

19551960
/*

0 commit comments

Comments
 (0)