From nobody Thu Nov 14 06:00:00 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 000FEC001B0 for ; Mon, 17 Jul 2023 14:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232240AbjGQOPV (ORCPT ); Mon, 17 Jul 2023 10:15:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232161AbjGQOO4 (ORCPT ); Mon, 17 Jul 2023 10:14:56 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4926D1A3 for ; Mon, 17 Jul 2023 07:14:53 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 61E4B6607073; Mon, 17 Jul 2023 15:14:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1689603292; bh=0hGL/8LzIM49OnwR70sh4p7tQJGg8O110NQk4ZNHwd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QlRzY3+6MjLfPwDht+YhnrAPXd0qTP00SI/ZJs2PVH+7PXopK2VH41JfJu/yqRZzu 1Ad1vWTsiHqOmy6zhyDLWO8WjlCbsKGY17jGmGS0bHQoxHh39rf0h4m4FeM7IVnRDD lgT1dksa5r6wqTpQRKJgmBNx3ayp554dNJaNO/vOzkzxmU1PoUrcQ5tiY4eeT5bXoD ara+vDSZng/mTtHOJlayeZYvGC5N0B7orm+01qASJttnJhBEVx2olZWnK50jk4J5Oc IDRIykJmehSe7uMioWTLaO7qRrCPrJ77MGrt3c5K4EIYzjL4pHhI8zC0bWJFLrHMwA 9RY0AWrj3uhTg== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v6 10/11] drm/mediatek: dp: Add .wait_hpd_asserted() for AUX bus Date: Mon, 17 Jul 2023 16:14:37 +0200 Message-Id: <20230717141438.274419-11-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230717141438.274419-1-angelogioacchino.delregno@collabora.com> References: <20230717141438.274419-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Alexandre Mergnat Reviewed-by: CK Hu --- drivers/gpu/drm/mediatek/mtk_dp.c | 45 ++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/m= tk_dp.c index acdd457b5449..e74295ba9707 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1920,6 +1920,31 @@ static irqreturn_t mtk_dp_hpd_event(int hpd, void *d= ev) return IRQ_WAKE_THREAD; } =20 +static int mtk_dp_wait_hpd_asserted(struct drm_dp_aux *mtk_aux, unsigned l= ong wait_us) +{ + struct mtk_dp *mtk_dp =3D container_of(mtk_aux, struct mtk_dp, aux); + u32 val; + int ret; + + ret =3D regmap_read_poll_timeout(mtk_dp->regs, MTK_DP_TRANS_P0_3414, + val, !!(val & HPD_DB_DP_TRANS_P0_MASK), + wait_us / 100, wait_us); + if (ret) { + mtk_dp->train_info.cable_plugged_in =3D false; + return ret; + } + + mtk_dp->train_info.cable_plugged_in =3D true; + + ret =3D mtk_dp_parse_capabilities(mtk_dp); + if (ret) { + drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n"); + return ret; + } + + return 0; +} + static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp, struct platform_device *pdev) { @@ -2532,6 +2557,12 @@ static int mtk_dp_edp_link_panel(struct drm_dp_aux *= mtk_aux) mtk_dp->next_bridge =3D NULL; return ret; } + + /* For eDP, we add the bridge only if the panel was found */ + ret =3D devm_drm_bridge_add(dev, &mtk_dp->bridge); + if (ret) + return ret; + return 0; } =20 @@ -2568,6 +2599,7 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->aux.name =3D "aux_mtk_dp"; mtk_dp->aux.dev =3D dev; mtk_dp->aux.transfer =3D mtk_dp_aux_transfer; + mtk_dp->aux.wait_hpd_asserted =3D mtk_dp_wait_hpd_asserted; drm_dp_aux_init(&mtk_dp->aux); =20 spin_lock_init(&mtk_dp->irq_thread_lock); @@ -2600,15 +2632,8 @@ static int mtk_dp_probe(struct platform_device *pdev) =20 mtk_dp->bridge.funcs =3D &mtk_dp_bridge_funcs; mtk_dp->bridge.of_node =3D dev->of_node; - - mtk_dp->bridge.ops =3D - DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD; mtk_dp->bridge.type =3D mtk_dp->data->bridge_type; =20 - ret =3D devm_drm_bridge_add(dev, &mtk_dp->bridge); - if (ret) - return dev_err_probe(dev, ret, "Failed to add bridge\n"); - mtk_dp->need_debounce =3D true; timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0); =20 @@ -2647,6 +2672,12 @@ static int mtk_dp_probe(struct platform_device *pdev) return ret; } } + } else { + mtk_dp->bridge.ops =3D DRM_BRIDGE_OP_DETECT | + DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD; + ret =3D devm_drm_bridge_add(dev, &mtk_dp->bridge); + if (ret) + return dev_err_probe(dev, ret, "Failed to add bridge\n"); } =20 pm_runtime_enable(dev); --=20 2.40.1