Skip to content

Commit e04b56c

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: dp: Move AUX and panel poweron/off sequence to function
Everytime we run bridge detection and/or EDID read we run a poweron and poweroff sequence for both the AUX and the panel; moreover, this is also done when enabling the bridge in the .atomic_enable() callback. Move this power on/off sequence to a new mtk_dp_aux_panel_poweron() function as to commonize it. Note that, before this commit, in mtk_dp_bridge_atomic_enable() only the AUX was getting powered on but the panel was left powered off if the DP cable wasn't plugged in while now we unconditionally send a D0 request and this is done for two reasons: - First, whether this request fails or not, it takes the same time and anyway the DP hardware won't produce any error (or, if it does, it's ignorable because it won't block further commands) - Second, training the link between a sleeping/standby/unpowered display makes little sense. Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Tested-by: Chen-Yu Tsai <[email protected]> Reviewed-by: CK Hu <[email protected]> Reviewed-by: Alexandre Mergnat <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent cfc1461 commit e04b56c

File tree

1 file changed

+30
-46
lines changed

1 file changed

+30
-46
lines changed

drivers/gpu/drm/mediatek/mtk_dp.c

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,29 @@ static void mtk_dp_audio_mute(struct mtk_dp *mtk_dp, bool mute)
12511251
val[2], AU_TS_CFG_DP_ENC0_P0_MASK);
12521252
}
12531253

1254+
static void mtk_dp_aux_panel_poweron(struct mtk_dp *mtk_dp, bool pwron)
1255+
{
1256+
if (pwron) {
1257+
/* power on aux */
1258+
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
1259+
DP_PWR_STATE_BANDGAP_TPLL_LANE,
1260+
DP_PWR_STATE_MASK);
1261+
1262+
/* power on panel */
1263+
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
1264+
usleep_range(2000, 5000);
1265+
} else {
1266+
/* power off panel */
1267+
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3);
1268+
usleep_range(2000, 3000);
1269+
1270+
/* power off aux */
1271+
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
1272+
DP_PWR_STATE_BANDGAP_TPLL,
1273+
DP_PWR_STATE_MASK);
1274+
}
1275+
}
1276+
12541277
static void mtk_dp_power_enable(struct mtk_dp *mtk_dp)
12551278
{
12561279
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_RESET_AND_PROBE,
@@ -1941,16 +1964,9 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
19411964
if (!mtk_dp->train_info.cable_plugged_in)
19421965
return ret;
19431966

1944-
if (!enabled) {
1945-
/* power on aux */
1946-
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
1947-
DP_PWR_STATE_BANDGAP_TPLL_LANE,
1948-
DP_PWR_STATE_MASK);
1967+
if (!enabled)
1968+
mtk_dp_aux_panel_poweron(mtk_dp, true);
19491969

1950-
/* power on panel */
1951-
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
1952-
usleep_range(2000, 5000);
1953-
}
19541970
/*
19551971
* Some dongles still source HPD when they do not connect to any
19561972
* sink device. To avoid this, we need to read the sink count
@@ -1962,16 +1978,8 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)
19621978
if (DP_GET_SINK_COUNT(sink_count))
19631979
ret = connector_status_connected;
19641980

1965-
if (!enabled) {
1966-
/* power off panel */
1967-
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3);
1968-
usleep_range(2000, 3000);
1969-
1970-
/* power off aux */
1971-
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
1972-
DP_PWR_STATE_BANDGAP_TPLL,
1973-
DP_PWR_STATE_MASK);
1974-
}
1981+
if (!enabled)
1982+
mtk_dp_aux_panel_poweron(mtk_dp, false);
19751983

19761984
return ret;
19771985
}
@@ -1987,15 +1995,7 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,
19871995

19881996
if (!enabled) {
19891997
drm_atomic_bridge_chain_pre_enable(bridge, connector->state->state);
1990-
1991-
/* power on aux */
1992-
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
1993-
DP_PWR_STATE_BANDGAP_TPLL_LANE,
1994-
DP_PWR_STATE_MASK);
1995-
1996-
/* power on panel */
1997-
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
1998-
usleep_range(2000, 5000);
1998+
mtk_dp_aux_panel_poweron(mtk_dp, true);
19991999
}
20002000

20012001
new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc);
@@ -2015,15 +2015,7 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge,
20152015
}
20162016

20172017
if (!enabled) {
2018-
/* power off panel */
2019-
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3);
2020-
usleep_range(2000, 3000);
2021-
2022-
/* power off aux */
2023-
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
2024-
DP_PWR_STATE_BANDGAP_TPLL,
2025-
DP_PWR_STATE_MASK);
2026-
2018+
mtk_dp_aux_panel_poweron(mtk_dp, false);
20272019
drm_atomic_bridge_chain_post_disable(bridge, connector->state->state);
20282020
}
20292021

@@ -2183,15 +2175,7 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge,
21832175
return;
21842176
}
21852177

2186-
/* power on aux */
2187-
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
2188-
DP_PWR_STATE_BANDGAP_TPLL_LANE,
2189-
DP_PWR_STATE_MASK);
2190-
2191-
if (mtk_dp->train_info.cable_plugged_in) {
2192-
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0);
2193-
usleep_range(2000, 5000);
2194-
}
2178+
mtk_dp_aux_panel_poweron(mtk_dp, true);
21952179

21962180
/* Training */
21972181
ret = mtk_dp_training(mtk_dp);

0 commit comments

Comments
 (0)