Skip to content

Commit ced8eff

Browse files
jayesh-tigregkh
authored andcommitted
drm/bridge: ti-sn65dsi86: Add HPD for DisplayPort connector type
[ Upstream commit 55e8ff8 ] By default, HPD was disabled on SN65DSI86 bridge. When the driver was added (commit "a095f15c00e27"), the HPD_DISABLE bit was set in pre-enable call which was moved to other function calls subsequently. Later on, commit "c312b0df3b13" added detect utility for DP mode. But with HPD_DISABLE bit set, all the HPD events are disabled[0] and the debounced state always return 1 (always connected state). Set HPD_DISABLE bit conditionally based on display sink's connector type. Since the HPD_STATE is reflected correctly only after waiting for debounce time (~100-400ms) and adding this delay in detect() is not feasible owing to the performace impact (glitches and frame drop), remove runtime calls in detect() and add hpd_enable()/disable() bridge hooks with runtime calls, to detect hpd properly without any delay. [0]: <https://www.ti.com/lit/gpn/SN65DSI86> (Pg. 32) Fixes: c312b0d ("drm/bridge: ti-sn65dsi86: Implement bridge connector operations for DP") Cc: Max Krummenacher <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Tested-by: Ernest Van Hoecke <[email protected]> Signed-off-by: Jayesh Choudhary <[email protected]> Signed-off-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 1c9a8a8 commit ced8eff

File tree

1 file changed

+60
-9
lines changed

1 file changed

+60
-9
lines changed

drivers/gpu/drm/bridge/ti-sn65dsi86.c

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,18 @@ static void ti_sn65dsi86_enable_comms(struct ti_sn65dsi86 *pdata)
331331
* 200 ms. We'll assume that the panel driver will have the hardcoded
332332
* delay in its prepare and always disable HPD.
333333
*
334-
* If HPD somehow makes sense on some future panel we'll have to
335-
* change this to be conditional on someone specifying that HPD should
336-
* be used.
334+
* For DisplayPort bridge type, we need HPD. So we use the bridge type
335+
* to conditionally disable HPD.
336+
* NOTE: The bridge type is set in ti_sn_bridge_probe() but enable_comms()
337+
* can be called before. So for DisplayPort, HPD will be enabled once
338+
* bridge type is set. We are using bridge type instead of "no-hpd"
339+
* property because it is not used properly in devicetree description
340+
* and hence is unreliable.
337341
*/
338-
regmap_update_bits(pdata->regmap, SN_HPD_DISABLE_REG, HPD_DISABLE,
339-
HPD_DISABLE);
342+
343+
if (pdata->bridge.type != DRM_MODE_CONNECTOR_DisplayPort)
344+
regmap_update_bits(pdata->regmap, SN_HPD_DISABLE_REG, HPD_DISABLE,
345+
HPD_DISABLE);
340346

341347
pdata->comms_enabled = true;
342348

@@ -1173,9 +1179,14 @@ static enum drm_connector_status ti_sn_bridge_detect(struct drm_bridge *bridge)
11731179
struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
11741180
int val = 0;
11751181

1176-
pm_runtime_get_sync(pdata->dev);
1182+
/*
1183+
* Runtime reference is grabbed in ti_sn_bridge_hpd_enable()
1184+
* as the chip won't report HPD just after being powered on.
1185+
* HPD_DEBOUNCED_STATE reflects correct state only after the
1186+
* debounce time (~100-400 ms).
1187+
*/
1188+
11771189
regmap_read(pdata->regmap, SN_HPD_DISABLE_REG, &val);
1178-
pm_runtime_put_autosuspend(pdata->dev);
11791190

11801191
return val & HPD_DEBOUNCED_STATE ? connector_status_connected
11811192
: connector_status_disconnected;
@@ -1198,6 +1209,26 @@ static void ti_sn65dsi86_debugfs_init(struct drm_bridge *bridge, struct dentry *
11981209
debugfs_create_file("status", 0600, debugfs, pdata, &status_fops);
11991210
}
12001211

1212+
static void ti_sn_bridge_hpd_enable(struct drm_bridge *bridge)
1213+
{
1214+
struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
1215+
1216+
/*
1217+
* Device needs to be powered on before reading the HPD state
1218+
* for reliable hpd detection in ti_sn_bridge_detect() due to
1219+
* the high debounce time.
1220+
*/
1221+
1222+
pm_runtime_get_sync(pdata->dev);
1223+
}
1224+
1225+
static void ti_sn_bridge_hpd_disable(struct drm_bridge *bridge)
1226+
{
1227+
struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
1228+
1229+
pm_runtime_put_autosuspend(pdata->dev);
1230+
}
1231+
12011232
static const struct drm_bridge_funcs ti_sn_bridge_funcs = {
12021233
.attach = ti_sn_bridge_attach,
12031234
.detach = ti_sn_bridge_detach,
@@ -1212,6 +1243,8 @@ static const struct drm_bridge_funcs ti_sn_bridge_funcs = {
12121243
.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
12131244
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
12141245
.debugfs_init = ti_sn65dsi86_debugfs_init,
1246+
.hpd_enable = ti_sn_bridge_hpd_enable,
1247+
.hpd_disable = ti_sn_bridge_hpd_disable,
12151248
};
12161249

12171250
static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata,
@@ -1300,8 +1333,26 @@ static int ti_sn_bridge_probe(struct auxiliary_device *adev,
13001333
pdata->bridge.type = pdata->next_bridge->type == DRM_MODE_CONNECTOR_DisplayPort
13011334
? DRM_MODE_CONNECTOR_DisplayPort : DRM_MODE_CONNECTOR_eDP;
13021335

1303-
if (pdata->bridge.type == DRM_MODE_CONNECTOR_DisplayPort)
1304-
pdata->bridge.ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
1336+
if (pdata->bridge.type == DRM_MODE_CONNECTOR_DisplayPort) {
1337+
pdata->bridge.ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT |
1338+
DRM_BRIDGE_OP_HPD;
1339+
/*
1340+
* If comms were already enabled they would have been enabled
1341+
* with the wrong value of HPD_DISABLE. Update it now. Comms
1342+
* could be enabled if anyone is holding a pm_runtime reference
1343+
* (like if a GPIO is in use). Note that in most cases nobody
1344+
* is doing AUX channel xfers before the bridge is added so
1345+
* HPD doesn't _really_ matter then. The only exception is in
1346+
* the eDP case where the panel wants to read the EDID before
1347+
* the bridge is added. We always consistently have HPD disabled
1348+
* for eDP.
1349+
*/
1350+
mutex_lock(&pdata->comms_mutex);
1351+
if (pdata->comms_enabled)
1352+
regmap_update_bits(pdata->regmap, SN_HPD_DISABLE_REG,
1353+
HPD_DISABLE, 0);
1354+
mutex_unlock(&pdata->comms_mutex);
1355+
};
13051356

13061357
drm_bridge_add(&pdata->bridge);
13071358

0 commit comments

Comments
 (0)