Skip to content

Commit 7eacba9

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: dp: Add .wait_hpd_asserted() for AUX bus
In order to support usecases in which the panel regulator can be switched on and off to save power, and usecases in which the panel regulator is off at boot, add a .wait_hpd_asserted() callback for the AUX bus: this will make sure to wait until the panel is fully ready after power-on before trying to communicate with it. Also, parse the eDP display capabilities in that callback, so that we can also avoid using the .get_edid() callback from this bridge. Since at this point the hpd machinery is performed in the new hpd callback and the detection and edid reading are done outside of this driver, assign the DRM_BRIDGE_OP_{DETECT, EDID, HPD} ops and register the bridge unconditionally at probe time only if we are probing full DisplayPort and not eDP while, for the latter, we register the bridge in the .done_probing() callback and only if the panel was found and triggered HPD. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Tested-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com> Reviewed-by: CK Hu <ck.hu@mediatek.com> Link: https://patchwork.kernel.org/project/dri-devel/patch/20230725073234.55892-11-angelogioacchino.delregno@collabora.com/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
1 parent caf2ae4 commit 7eacba9

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

drivers/gpu/drm/mediatek/mtk_dp.c

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,31 @@ static irqreturn_t mtk_dp_hpd_event(int hpd, void *dev)
19201920
return IRQ_WAKE_THREAD;
19211921
}
19221922

1923+
static int mtk_dp_wait_hpd_asserted(struct drm_dp_aux *mtk_aux, unsigned long wait_us)
1924+
{
1925+
struct mtk_dp *mtk_dp = container_of(mtk_aux, struct mtk_dp, aux);
1926+
u32 val;
1927+
int ret;
1928+
1929+
ret = regmap_read_poll_timeout(mtk_dp->regs, MTK_DP_TRANS_P0_3414,
1930+
val, !!(val & HPD_DB_DP_TRANS_P0_MASK),
1931+
wait_us / 100, wait_us);
1932+
if (ret) {
1933+
mtk_dp->train_info.cable_plugged_in = false;
1934+
return ret;
1935+
}
1936+
1937+
mtk_dp->train_info.cable_plugged_in = true;
1938+
1939+
ret = mtk_dp_parse_capabilities(mtk_dp);
1940+
if (ret) {
1941+
drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n");
1942+
return ret;
1943+
}
1944+
1945+
return 0;
1946+
}
1947+
19231948
static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,
19241949
struct platform_device *pdev)
19251950
{
@@ -2532,6 +2557,12 @@ static int mtk_dp_edp_link_panel(struct drm_dp_aux *mtk_aux)
25322557
mtk_dp->next_bridge = NULL;
25332558
return ret;
25342559
}
2560+
2561+
/* For eDP, we add the bridge only if the panel was found */
2562+
ret = devm_drm_bridge_add(dev, &mtk_dp->bridge);
2563+
if (ret)
2564+
return ret;
2565+
25352566
return 0;
25362567
}
25372568

@@ -2560,6 +2591,7 @@ static int mtk_dp_probe(struct platform_device *pdev)
25602591
mtk_dp->aux.name = "aux_mtk_dp";
25612592
mtk_dp->aux.dev = dev;
25622593
mtk_dp->aux.transfer = mtk_dp_aux_transfer;
2594+
mtk_dp->aux.wait_hpd_asserted = mtk_dp_wait_hpd_asserted;
25632595
drm_dp_aux_init(&mtk_dp->aux);
25642596

25652597
spin_lock_init(&mtk_dp->irq_thread_lock);
@@ -2592,15 +2624,8 @@ static int mtk_dp_probe(struct platform_device *pdev)
25922624

25932625
mtk_dp->bridge.funcs = &mtk_dp_bridge_funcs;
25942626
mtk_dp->bridge.of_node = dev->of_node;
2595-
2596-
mtk_dp->bridge.ops =
2597-
DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD;
25982627
mtk_dp->bridge.type = mtk_dp->data->bridge_type;
25992628

2600-
ret = devm_drm_bridge_add(dev, &mtk_dp->bridge);
2601-
if (ret)
2602-
return dev_err_probe(dev, ret, "Failed to add bridge\n");
2603-
26042629
mtk_dp->need_debounce = true;
26052630
timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0);
26062631

@@ -2639,6 +2664,12 @@ static int mtk_dp_probe(struct platform_device *pdev)
26392664
return ret;
26402665
}
26412666
}
2667+
} else {
2668+
mtk_dp->bridge.ops = DRM_BRIDGE_OP_DETECT |
2669+
DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD;
2670+
ret = devm_drm_bridge_add(dev, &mtk_dp->bridge);
2671+
if (ret)
2672+
return dev_err_probe(dev, ret, "Failed to add bridge\n");
26422673
}
26432674

26442675
pm_runtime_enable(dev);

0 commit comments

Comments
 (0)