Skip to content

Commit a8e981a

Browse files
Kuogee Hsiehrobclark
authored andcommitted
drm/msm/dp: enable HDP plugin/unplugged interrupts at hpd_enable/disable
The internal_hpd flag is set to true by dp_bridge_hpd_enable() and set to false by dp_bridge_hpd_disable() to handle GPIO pinmuxed into DP controller case. HDP related interrupts can not be enabled until internal_hpd is set to true. At current implementation dp_display_config_hpd() will initialize DP host controller first followed by enabling HDP related interrupts if internal_hpd was true at that time. Enable HDP related interrupts depends on internal_hpd status may leave system with DP driver host is in running state but without HDP related interrupts being enabled. This will prevent external display from being detected. Eliminated this dependency by moving HDP related interrupts enable/disable be done at dp_bridge_hpd_enable/disable() directly regardless of internal_hpd status. Changes in V3: -- dp_catalog_ctrl_hpd_enable() and dp_catalog_ctrl_hpd_disable() -- rewording ocmmit text Changes in V4: -- replace dp_display_config_hpd() with dp_display_host_start() -- move enable_irq() at dp_display_host_start(); Changes in V5: -- replace dp_display_host_start() with dp_display_host_init() Changes in V6: -- squash remove enable_irq() and disable_irq() Fixes: cd198ca ("drm/msm/dp: Rely on hpd_enable/disable callbacks") Signed-off-by: Kuogee Hsieh <[email protected]> Tested-by: Leonard Lausen <[email protected]> # on sc7180 lazor Reviewed-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Tested-by: Bjorn Andersson <[email protected]> Reviewed-by: Abhinav Kumar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Rob Clark <[email protected]>
1 parent b78c772 commit a8e981a

File tree

3 files changed

+35
-54
lines changed

3 files changed

+35
-54
lines changed

drivers/gpu/drm/msm/dp/dp_catalog.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ void dp_catalog_hpd_config_intr(struct dp_catalog *dp_catalog,
620620
config & DP_DP_HPD_INT_MASK);
621621
}
622622

623-
void dp_catalog_ctrl_hpd_config(struct dp_catalog *dp_catalog)
623+
void dp_catalog_ctrl_hpd_enable(struct dp_catalog *dp_catalog)
624624
{
625625
struct dp_catalog_private *catalog = container_of(dp_catalog,
626626
struct dp_catalog_private, dp_catalog);
@@ -635,6 +635,19 @@ void dp_catalog_ctrl_hpd_config(struct dp_catalog *dp_catalog)
635635
dp_write_aux(catalog, REG_DP_DP_HPD_CTRL, DP_DP_HPD_CTRL_HPD_EN);
636636
}
637637

638+
void dp_catalog_ctrl_hpd_disable(struct dp_catalog *dp_catalog)
639+
{
640+
struct dp_catalog_private *catalog = container_of(dp_catalog,
641+
struct dp_catalog_private, dp_catalog);
642+
643+
u32 reftimer = dp_read_aux(catalog, REG_DP_DP_HPD_REFTIMER);
644+
645+
reftimer &= ~DP_DP_HPD_REFTIMER_ENABLE;
646+
dp_write_aux(catalog, REG_DP_DP_HPD_REFTIMER, reftimer);
647+
648+
dp_write_aux(catalog, REG_DP_DP_HPD_CTRL, 0);
649+
}
650+
638651
static void dp_catalog_enable_sdp(struct dp_catalog_private *catalog)
639652
{
640653
/* trigger sdp */

drivers/gpu/drm/msm/dp/dp_catalog.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ bool dp_catalog_ctrl_mainlink_ready(struct dp_catalog *dp_catalog);
104104
void dp_catalog_ctrl_enable_irq(struct dp_catalog *dp_catalog, bool enable);
105105
void dp_catalog_hpd_config_intr(struct dp_catalog *dp_catalog,
106106
u32 intr_mask, bool en);
107-
void dp_catalog_ctrl_hpd_config(struct dp_catalog *dp_catalog);
107+
void dp_catalog_ctrl_hpd_enable(struct dp_catalog *dp_catalog);
108+
void dp_catalog_ctrl_hpd_disable(struct dp_catalog *dp_catalog);
108109
void dp_catalog_ctrl_config_psr(struct dp_catalog *dp_catalog);
109110
void dp_catalog_ctrl_set_psr(struct dp_catalog *dp_catalog, bool enter);
110111
u32 dp_catalog_link_is_connected(struct dp_catalog *dp_catalog);

drivers/gpu/drm/msm/dp/dp_display.c

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -620,12 +620,6 @@ static int dp_hpd_plug_handle(struct dp_display_private *dp, u32 data)
620620
dp->hpd_state = ST_MAINLINK_READY;
621621
}
622622

623-
/* enable HDP irq_hpd/replug interrupt */
624-
if (dp->dp_display.internal_hpd)
625-
dp_catalog_hpd_config_intr(dp->catalog,
626-
DP_DP_IRQ_HPD_INT_MASK | DP_DP_HPD_REPLUG_INT_MASK,
627-
true);
628-
629623
drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n",
630624
dp->dp_display.connector_type, state);
631625
mutex_unlock(&dp->event_mutex);
@@ -663,12 +657,6 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data)
663657
drm_dbg_dp(dp->drm_dev, "Before, type=%d hpd_state=%d\n",
664658
dp->dp_display.connector_type, state);
665659

666-
/* disable irq_hpd/replug interrupts */
667-
if (dp->dp_display.internal_hpd)
668-
dp_catalog_hpd_config_intr(dp->catalog,
669-
DP_DP_IRQ_HPD_INT_MASK | DP_DP_HPD_REPLUG_INT_MASK,
670-
false);
671-
672660
/* unplugged, no more irq_hpd handle */
673661
dp_del_event(dp, EV_IRQ_HPD_INT);
674662

@@ -692,10 +680,6 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data)
692680
return 0;
693681
}
694682

695-
/* disable HPD plug interrupts */
696-
if (dp->dp_display.internal_hpd)
697-
dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_PLUG_INT_MASK, false);
698-
699683
/*
700684
* We don't need separate work for disconnect as
701685
* connect/attention interrupts are disabled
@@ -711,10 +695,6 @@ static int dp_hpd_unplug_handle(struct dp_display_private *dp, u32 data)
711695
/* signal the disconnect event early to ensure proper teardown */
712696
dp_display_handle_plugged_change(&dp->dp_display, false);
713697

714-
/* enable HDP plug interrupt to prepare for next plugin */
715-
if (dp->dp_display.internal_hpd)
716-
dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_PLUG_INT_MASK, true);
717-
718698
drm_dbg_dp(dp->drm_dev, "After, type=%d hpd_state=%d\n",
719699
dp->dp_display.connector_type, state);
720700

@@ -1087,26 +1067,6 @@ void msm_dp_snapshot(struct msm_disp_state *disp_state, struct msm_dp *dp)
10871067
mutex_unlock(&dp_display->event_mutex);
10881068
}
10891069

1090-
static void dp_display_config_hpd(struct dp_display_private *dp)
1091-
{
1092-
1093-
dp_display_host_init(dp);
1094-
dp_catalog_ctrl_hpd_config(dp->catalog);
1095-
1096-
/* Enable plug and unplug interrupts only if requested */
1097-
if (dp->dp_display.internal_hpd)
1098-
dp_catalog_hpd_config_intr(dp->catalog,
1099-
DP_DP_HPD_PLUG_INT_MASK |
1100-
DP_DP_HPD_UNPLUG_INT_MASK,
1101-
true);
1102-
1103-
/* Enable interrupt first time
1104-
* we are leaving dp clocks on during disconnect
1105-
* and never disable interrupt
1106-
*/
1107-
enable_irq(dp->irq);
1108-
}
1109-
11101070
void dp_display_set_psr(struct msm_dp *dp_display, bool enter)
11111071
{
11121072
struct dp_display_private *dp;
@@ -1181,7 +1141,7 @@ static int hpd_event_thread(void *data)
11811141

11821142
switch (todo->event_id) {
11831143
case EV_HPD_INIT_SETUP:
1184-
dp_display_config_hpd(dp_priv);
1144+
dp_display_host_init(dp_priv);
11851145
break;
11861146
case EV_HPD_PLUG_INT:
11871147
dp_hpd_plug_handle(dp_priv, todo->data);
@@ -1287,7 +1247,6 @@ int dp_display_request_irq(struct msm_dp *dp_display)
12871247
dp->irq, rc);
12881248
return rc;
12891249
}
1290-
disable_irq(dp->irq);
12911250

12921251
return 0;
12931252
}
@@ -1399,13 +1358,8 @@ static int dp_pm_resume(struct device *dev)
13991358
/* turn on dp ctrl/phy */
14001359
dp_display_host_init(dp);
14011360

1402-
dp_catalog_ctrl_hpd_config(dp->catalog);
1403-
1404-
if (dp->dp_display.internal_hpd)
1405-
dp_catalog_hpd_config_intr(dp->catalog,
1406-
DP_DP_HPD_PLUG_INT_MASK |
1407-
DP_DP_HPD_UNPLUG_INT_MASK,
1408-
true);
1361+
if (dp_display->is_edp)
1362+
dp_catalog_ctrl_hpd_enable(dp->catalog);
14091363

14101364
if (dp_catalog_link_is_connected(dp->catalog)) {
14111365
/*
@@ -1573,9 +1527,8 @@ static int dp_display_get_next_bridge(struct msm_dp *dp)
15731527

15741528
if (aux_bus && dp->is_edp) {
15751529
dp_display_host_init(dp_priv);
1576-
dp_catalog_ctrl_hpd_config(dp_priv->catalog);
1530+
dp_catalog_ctrl_hpd_enable(dp_priv->catalog);
15771531
dp_display_host_phy_init(dp_priv);
1578-
enable_irq(dp_priv->irq);
15791532

15801533
/*
15811534
* The code below assumes that the panel will finish probing
@@ -1617,7 +1570,6 @@ static int dp_display_get_next_bridge(struct msm_dp *dp)
16171570

16181571
error:
16191572
if (dp->is_edp) {
1620-
disable_irq(dp_priv->irq);
16211573
dp_display_host_phy_exit(dp_priv);
16221574
dp_display_host_deinit(dp_priv);
16231575
}
@@ -1806,16 +1758,31 @@ void dp_bridge_hpd_enable(struct drm_bridge *bridge)
18061758
{
18071759
struct msm_dp_bridge *dp_bridge = to_dp_bridge(bridge);
18081760
struct msm_dp *dp_display = dp_bridge->dp_display;
1761+
struct dp_display_private *dp = container_of(dp_display, struct dp_display_private, dp_display);
1762+
1763+
mutex_lock(&dp->event_mutex);
1764+
dp_catalog_ctrl_hpd_enable(dp->catalog);
1765+
1766+
/* enable HDP interrupts */
1767+
dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_INT_MASK, true);
18091768

18101769
dp_display->internal_hpd = true;
1770+
mutex_unlock(&dp->event_mutex);
18111771
}
18121772

18131773
void dp_bridge_hpd_disable(struct drm_bridge *bridge)
18141774
{
18151775
struct msm_dp_bridge *dp_bridge = to_dp_bridge(bridge);
18161776
struct msm_dp *dp_display = dp_bridge->dp_display;
1777+
struct dp_display_private *dp = container_of(dp_display, struct dp_display_private, dp_display);
1778+
1779+
mutex_lock(&dp->event_mutex);
1780+
/* disable HDP interrupts */
1781+
dp_catalog_hpd_config_intr(dp->catalog, DP_DP_HPD_INT_MASK, false);
1782+
dp_catalog_ctrl_hpd_disable(dp->catalog);
18171783

18181784
dp_display->internal_hpd = false;
1785+
mutex_unlock(&dp->event_mutex);
18191786
}
18201787

18211788
void dp_bridge_hpd_notify(struct drm_bridge *bridge,

0 commit comments

Comments
 (0)