From patchwork Thu Mar 30 14:20:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13194247 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C536FC761A6 for ; Thu, 30 Mar 2023 14:20:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mVHWryi7FLI6xgM1V7O/CpgS+CHXop+pa1pZRj1UBLM=; b=fdn1lDXoF16BGN3i026Veczd1Q olppZxCWL089wvRzPTCe2NnaJKKKRc8pQ+UrmK5wZB17WA34WacqJYx6rZm5oQNuf1Q5TIzZSIsgw e2zJDzGYSqqDDhmSaJSCUDoaIhNZ3Exr5F3dhI/YP7R4qiXwFIxRIjuSHYrlX4lp6YLjpIVrTzJDS gIStPuu8jNwpNniGLGSsIDlfWWG2e4R+/heXSOcedsGGRWlPlLKBvbsJW3KnM5LGiMbz6t0iClBaX nuLqK2WliRFW/SuDtnMg5IXhy+fMT5lS1Ecf+1hUezJ5p7IPirXSK0KIqSX+k9MZGcillqcZWuITI z/zmM7UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pht92-0042NV-2m; Thu, 30 Mar 2023 14:20:52 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pht8s-0042Dw-18; Thu, 30 Mar 2023 14:20:43 +0000 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 7587D6603182; Thu, 30 Mar 2023 15:20:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186041; bh=aTfefQf7wUPldM8GfwxyIBQhpoEf1h/RP3aMOHoG5mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fPKMaUB9pcKRhv67iSyOx+sUENsvJDupMI3jonnm9Rm8BPcttpu+7x3p4EEQsiW9C yz6VK78dYKCALS6f4jauo7bR8O/uLpxVSENMCprMBm9+fYlG0nz2tzq5AYz4owxxX7 Pp8RicYGQGWQea6wDJ+Qky/Y4617oEjcXcSl2m4KgpTEwhk3i4sAYAtcKVoMlD/rh3 DXXWsQPAxnj4eXifnCESevLdl9IoUAbJhpPr0gHV5xwdZizK517iTFTDpseamSiYNe bj+Z4bQAc5kwvIcmIbH/S2UinzEC+t8iOLv9x20s7RG7wA+wkYliZQv0CSLXX6rw98 K1iPrA0Y0Vk+w== 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 Subject: [PATCH v2 1/8] drm/mediatek: dp: Cache EDID for eDP panel Date: Thu, 30 Mar 2023 16:20:28 +0200 Message-Id: <20230330142035.191399-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_072042_544265_B700C8DB X-CRM114-Status: GOOD ( 12.94 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Since eDP panels are not removable it is safe to cache the EDID: this will avoid a relatively long read transaction at every PM resume that is unnecessary only in the "special" case of eDP, hence speeding it up a little, as from now on, as resume operation, we will perform only link training. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 1f94fcc144d3..84f82cc68672 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -118,6 +118,7 @@ struct mtk_dp { const struct mtk_dp_data *data; struct mtk_dp_info info; struct mtk_dp_train_info train_info; + struct edid *edid; struct platform_device *phy_dev; struct phy *phy; @@ -1993,7 +1994,11 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, usleep_range(2000, 5000); } - new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); + /* eDP panels aren't removable, so we can return a cached EDID. */ + if (mtk_dp->edid && mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) + new_edid = drm_edid_duplicate(mtk_dp->edid); + else + new_edid = drm_get_edid(connector, &mtk_dp->aux.ddc); /* * Parse capability here to let atomic_get_input_bus_fmts and @@ -2022,6 +2027,10 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, drm_atomic_bridge_chain_post_disable(bridge, connector->state->state); } + /* If this is an eDP panel and the read EDID is good, cache it for later */ + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP && !mtk_dp->edid && new_edid) + mtk_dp->edid = drm_edid_duplicate(new_edid); + return new_edid; } From patchwork Thu Mar 30 14:20:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13194249 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6B1FC6FD1D for ; Thu, 30 Mar 2023 14:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=J5DWD32OWLq13uaRlJE+1ppOi8qnCqTf5ZEGPUBOy/k=; b=FNGOKcGqIW0iYNbApFoDTV1Yoh /idtkJnTL22cqCxRiyZYaq0j9Z3GQDlDMMgTrlbJlMpj1XMkn9ucX8XGpJm1ZrefnLqmm7ODtPhNY ZUkkdwAA46lEmu0Az+LITJlRgBSfFPx+2sA0Ep6w4DWyT5DzNccqsciKcQZSWhgbCN5/imGUENd4t WRVF0Ikjt9eSj3vfp7TXIzWqDyQxh9mhwpbXgHVAemaXMBtyIJFGPV7FbuuVil6BIzKDaBtcRDng9 M4n1xRCYNXVP3lao8NI1fiBrZXy/H3eBIQSPEFdL4pv7FM5AK+UB75E4kC5lWOtMJ5u/Xy6cpPfDF ExYRUvFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pht9I-0042ab-0e; Thu, 30 Mar 2023 14:21:08 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pht8t-0042EN-1I; Thu, 30 Mar 2023 14:20:45 +0000 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 466326603188; Thu, 30 Mar 2023 15:20:41 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186041; bh=IS0da1vr/9JtA9BZ0bqYXl4kxrPBhntX0yK9vYbXQe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cmNm9GUrXZ1goxAMnVTinMesGeXyqZZgfnNqDakJ28ylnpLG2Wjo12UhUq0jqFutf lpxLpcQK4fR26/fKufBGpLZoITp3dPCR9xj9IrEx+4QcicMg6Uff0knwJ3g9OZ1MEI mcYF1yIXnfaw0niCgkmn1S9P8MXXdRl+hPJeuNA475q2uAi9sGKrZrGSpqWXKJwVBO I3eiCOtJXgci6UWFhvfyMZjlI/1ziY/tdzeeOS55kp4Jz0Fq+d0YMl7ApUyY4fmULp W9JmZCOdhrWdvclW5vT13e0Ci5J7JmOlTY+C5qCAjxqBAPFxBAkj7ho9FY3dtU8MWn rjySkUSxZtDtw== 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 Subject: [PATCH v2 2/8] drm/mediatek: dp: Move AUX and panel poweron/off sequence to function Date: Thu, 30 Mar 2023 16:20:29 +0200 Message-Id: <20230330142035.191399-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_072043_702504_2C9390BD X-CRM114-Status: GOOD ( 16.57 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org 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 --- drivers/gpu/drm/mediatek/mtk_dp.c | 76 ++++++++++++------------------- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 84f82cc68672..76ea94167531 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1253,6 +1253,29 @@ static void mtk_dp_audio_mute(struct mtk_dp *mtk_dp, bool mute) val[2], AU_TS_CFG_DP_ENC0_P0_MASK); } +static void mtk_dp_aux_panel_poweron(struct mtk_dp *mtk_dp, bool pwron) +{ + if (pwron) { + /* power on aux */ + mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, + DP_PWR_STATE_BANDGAP_TPLL_LANE, + DP_PWR_STATE_MASK); + + /* power on panel */ + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0); + usleep_range(2000, 5000); + } else { + /* power off panel */ + drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3); + usleep_range(2000, 3000); + + /* power off aux */ + mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, + DP_PWR_STATE_BANDGAP_TPLL, + DP_PWR_STATE_MASK); + } +} + static void mtk_dp_power_enable(struct mtk_dp *mtk_dp) { mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_RESET_AND_PROBE, @@ -1937,16 +1960,9 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge) if (!mtk_dp->train_info.cable_plugged_in) return ret; - if (!enabled) { - /* power on aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL_LANE, - DP_PWR_STATE_MASK); + if (!enabled) + mtk_dp_aux_panel_poweron(mtk_dp, true); - /* power on panel */ - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0); - usleep_range(2000, 5000); - } /* * Some dongles still source HPD when they do not connect to any * sink device. To avoid this, we need to read the sink count @@ -1958,16 +1974,8 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge) if (DP_GET_SINK_COUNT(sink_count)) ret = connector_status_connected; - if (!enabled) { - /* power off panel */ - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3); - usleep_range(2000, 3000); - - /* power off aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL, - DP_PWR_STATE_MASK); - } + if (!enabled) + mtk_dp_aux_panel_poweron(mtk_dp, false); return ret; } @@ -1983,15 +1991,7 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, if (!enabled) { drm_atomic_bridge_chain_pre_enable(bridge, connector->state->state); - - /* power on aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL_LANE, - DP_PWR_STATE_MASK); - - /* power on panel */ - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0); - usleep_range(2000, 5000); + mtk_dp_aux_panel_poweron(mtk_dp, true); } /* eDP panels aren't removable, so we can return a cached EDID. */ @@ -2015,15 +2015,7 @@ static struct edid *mtk_dp_get_edid(struct drm_bridge *bridge, } if (!enabled) { - /* power off panel */ - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3); - usleep_range(2000, 3000); - - /* power off aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL, - DP_PWR_STATE_MASK); - + mtk_dp_aux_panel_poweron(mtk_dp, false); drm_atomic_bridge_chain_post_disable(bridge, connector->state->state); } @@ -2188,15 +2180,7 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge, return; } - /* power on aux */ - mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, - DP_PWR_STATE_BANDGAP_TPLL_LANE, - DP_PWR_STATE_MASK); - - if (mtk_dp->train_info.cable_plugged_in) { - drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D0); - usleep_range(2000, 5000); - } + mtk_dp_aux_panel_poweron(mtk_dp, true); /* Training */ ret = mtk_dp_training(mtk_dp); From patchwork Thu Mar 30 14:20:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13194248 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E789DC761A6 for ; Thu, 30 Mar 2023 14:21:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SA7K1DKPDuni2CUxMFtz6LVzpvZXN/0fsgagtyIjImk=; b=nzvEUC9VmPlOfj1kEnFXvASBgB qwvShgV8sUZbbQadDLYAoKO5147sGskvm38ns+JIr7XAKDSmBEH6ZSoKjVlqTuER/WfFEYdNpMJ+r B3+Xq4KDv+LEdvTYmu/APym4w6EeFKGlh0IZobOtAMRBP2/8/Q4X1TPjWgDGLG+8TPGrhkv1ZGXC+ iUg/U9tlPdKHy/rUNTaoWcWTwaebMbO3BOV56OzhYFw38CYjh00QihUFw9j6S3InUswHQHclXPsJ5 wxXgJBvQLXkMksxT6OvrCOQj6WkOBiiOlEorGliyMq0m6qR6Xt0OMb7OA+DHggv9NvCP44rW6SQlI 0RLFDbyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pht9H-0042ZJ-0O; Thu, 30 Mar 2023 14:21:07 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pht8t-0042Et-2w; Thu, 30 Mar 2023 14:20:45 +0000 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 166E9660000E; Thu, 30 Mar 2023 15:20:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186042; bh=l7DxgZbkLf1a/NAX8ACnOYom2qi3A95N4rbvhFxlUX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G+N7Mm5p05ibAjldy0ztpMj2bog3cgiYrH6vEB4EDL/2kVNHu6Wdcd/0CHcpnOdy9 PkVQnTF0JZowrF0aJhNMRqikGo19zxRYJs4VBNIYHpcZkbxAwcxPJyWJsmTFP2WOKP qRFrx3+GiO52hsZejPFSNbIxuhdi/m7u+k92akp2y3bLcHD+00rp0OeqLNsOoG3LJO 0/KzS5KP4piExrR/Fn3UropaOKfZRXV85m7umZK0qYDVE/pbOEkwZbFvHZk+cv1hxl oATil3lGCIuzoPjuCCCGmLV+eF4EhdQB0opGbFPK3sFE2vW1gsrWQG7zqXXhRN4d5Z Y4V30RHoIja9A== 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 Subject: [PATCH v2 3/8] drm/mediatek: dp: Always return connected status for eDP in .detect() Date: Thu, 30 Mar 2023 16:20:30 +0200 Message-Id: <20230330142035.191399-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_072044_104938_2D378F79 X-CRM114-Status: UNSURE ( 9.99 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org If this is an eDP panel it's not removable, hence it's always connected: as a shortcut, always return connector_status_connected in the .detect() callback for eDP connector, avoiding a poweron, a check for sink count and a poweroff. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 76ea94167531..c82dd1f0675d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1957,6 +1957,9 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge) bool enabled = mtk_dp->enabled; u8 sink_count = 0; + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) + return connector_status_connected; + if (!mtk_dp->train_info.cable_plugged_in) return ret; From patchwork Thu Mar 30 14:20:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13194250 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9276AC761A6 for ; Thu, 30 Mar 2023 14:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nCg5ICz9XbPYs8GpKnZD2kdwz9IxKkREMg8mLvGBySg=; b=zcDpywAwjTHeSCF1cDbGPKJQWJ 3cPVVZ1g74OgC3ZGGDSTDuMj5X5PXsrKTsuA27lZr5Qn+QhvVrxh+Bgp2yV+5sOxtgOYG5JuJE8hS YJbkglOwv3vxPnwnkipuISpQDguQ+F80tHQ9OvL5sqVPTkHGsG9vRY0kopfj7pYI3uaidQ5AqLRzZ JXmua4OgMKwf6ZUO02FjCGZ3TuJvT39xzTNSNvHUKsnjLTOd9+nhdMwNtMaaO8N80ZiQWCZ4XAYip QSFRODZHtvrRiWSKOi8fGhNAUCn23aVMeP2prCSGaImeq8iD6KfKCiJG1ygrj8NIlsm2YUM7S65AP N8M5pmEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pht9R-0042iQ-3C; Thu, 30 Mar 2023 14:21:18 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pht8u-0042Fb-2V; Thu, 30 Mar 2023 14:20:46 +0000 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 DD27F6600011; Thu, 30 Mar 2023 15:20:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186043; bh=3ZbLGCMsG/gn15JDSWm25FtN0N4B/ueru9VCCfJiapw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E3kmtNCgUZL+OdsGrOaq9hF2DNEwCFoZ1/UMI9b4gxV4utcQ2iiSrW28KKmGfKIy8 yvbC697ZegPXuvwYgghQbwC8QYgRjuQiD6dKZS8BmEWrpk1VHkokcIH0cZ3+SQMb3I ctszC4j/dCXFhGXaVCB+vbqob83p64wUJGdcb0uaWB401uwPIGVHBMpTiMB58JRxX0 QyblxFaz9rMWY1x8idFdkXoei+EY/I8uw+IcOWazPdkMdjUSiktIXqVGqlHNvwRbDT re1e7kDDFEK2zn3Io98oyupnqDztiO3SgCAyuyBDLutKgNkair+RYilKSFAD6ng1IH TbeEZmpuakYJw== 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 Subject: [PATCH v2 4/8] drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel Date: Thu, 30 Mar 2023 16:20:31 +0200 Message-Id: <20230330142035.191399-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_072044_951308_695AD7DD X-CRM114-Status: UNSURE ( 9.41 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org eDP panels are not removable: at PM resume, the cable will obviously still be plugged in. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index c82dd1f0675d..ac21eca0e20e 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -2607,6 +2607,9 @@ static int mtk_dp_resume(struct device *dev) mtk_dp_hwirq_enable(mtk_dp, true); mtk_dp_power_enable(mtk_dp); + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) + mtk_dp->train_info.cable_plugged_in = true; + return 0; } #endif From patchwork Thu Mar 30 14:20:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13194251 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 201FDC6FD1D for ; Thu, 30 Mar 2023 14:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6FtVoiMV/omg48bRFmqt6pDYPYlhyrqg6evx0w4MWTE=; b=bUg6tFUM9uB+GaErNwdd50RYqS GnMSXY2uYKoeM7vwqZHATjHSJt4uwVNAAodN8e+wLX6cjuEsix6czMHbidcVd4/JSNdSLAM/b0CJx uWddFjCEuZb7hPu7SWe8/0S1/kXJauA/xh+o5ctzcAQEqnHwjBPpS72nG1moGn9h1Kmn/ew+bwCyt wfmoTm/NS/RxRXygtZVCdjpcUYAGBA/13qId93zcx84m43mS3f/TIo5sY56of0OtQhmrDiur/IhUK xGwsZFhgbnOtIV7hrAlnbFJMBZRzUzHGKE6U2PGmMLn04MQolKheih7Eri/rhGrdlG/PJF52DF8v6 IRTDKT7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pht9T-0042jM-1h; Thu, 30 Mar 2023 14:21:19 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pht8v-0042GO-21; Thu, 30 Mar 2023 14:20:47 +0000 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 BB7AD66030CD; Thu, 30 Mar 2023 15:20:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186044; bh=dxC6MHx3NJXRAEW1ywTcNfOZX7I8dn5v2i9D/PKGK9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ddYdW2due7/9HVKbxzYtu9mprbB08wIKWQvw7V7jkmkq3Tr9/fDFlQC3KR66FRz8g lE4wuH0bQKrkItvUv+pc5Zb70A4A02tzNvtQTwEcRLWnny8xPpwWZrjNT3QzKmIHQv 9aa/dQlKmuuENG556zDsKvgmZ646n+THpfldeBu6TYfglRdRkOWEQiexg1kKsSUJRB ECqUUtIbWd9WoLI1g2qTsGTSVZeYa/u/YVfAJpodGlxby0xCbzMrJuKy8BSlFGOgHI d3TJKp+Bw60mMFEDn85JzOwAvEH4IBPkP3w4RM9RimqfIYbeEPh2J6rE3xUjbEj3zU ROLlnEE8/NoPQ== 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 Subject: [PATCH v2 5/8] drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer() Date: Thu, 30 Mar 2023 16:20:32 +0200 Message-Id: <20230330142035.191399-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_072045_835064_9E054AC4 X-CRM114-Status: GOOD ( 12.22 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Change logging from drm_{err,info}() to dev_{err,info}() in functions mtk_dp_aux_transfer() and mtk_dp_aux_do_transfer(): this will be essential to avoid getting NULL pointer kernel panics if any kind of error happens during AUX transfers happening before the bridge is attached. This may potentially start happening in a later commit implementing aux-bus support, as AUX transfers will be triggered from the panel driver (for EDID) before the mtk-dp bridge gets attached, and it's done in preparation for the same. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index ac21eca0e20e..19b145cf2e05 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -849,7 +849,7 @@ static int mtk_dp_aux_do_transfer(struct mtk_dp *mtk_dp, bool is_read, u8 cmd, u32 phy_status = mtk_dp_read(mtk_dp, MTK_DP_AUX_P0_3628) & AUX_RX_PHY_STATE_AUX_TX_P0_MASK; if (phy_status != AUX_RX_PHY_STATE_AUX_TX_P0_RX_IDLE) { - drm_err(mtk_dp->drm_dev, + dev_err(mtk_dp->dev, "AUX Rx Aux hang, need SW reset\n"); return -EIO; } @@ -2061,7 +2061,7 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux, is_read = true; break; default: - drm_err(mtk_aux->drm_dev, "invalid aux cmd = %d\n", + dev_err(mtk_dp->dev, "invalid aux cmd = %d\n", msg->request); ret = -EINVAL; goto err; @@ -2077,7 +2077,7 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux, to_access); if (ret) { - drm_info(mtk_dp->drm_dev, + dev_info(mtk_dp->dev, "Failed to do AUX transfer: %d\n", ret); goto err; } From patchwork Thu Mar 30 14:20:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13194252 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49DC3C761A6 for ; Thu, 30 Mar 2023 14:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5aR76aUK66V+oOGD/BsUrwTZt7JhshN2uJKaf7z8324=; b=2CyXJYWN+KHkF2sDlHivusGocJ B+A7kwcWoAQs7viLoCXQmPxCBFbPHv8Lt6vMGYsMHNt69vVgAB2VNFnns778qu/xjhgPkNP54QggM xfINzBRpuBdUUn1yEqpmmgfmA+nudwQ5prhqK2Awm6FkON6jfwdzlNffO+w/xbdGY38Ivz/mPQbqz /mHM16mXJzMKouC2o5Nzx/E555AJVik6Cf0SlCbilZk/m+qLeClbrYMEGRGIMPfoZ2Z7lg47K65+D e+ibEKjsEe3Glun4cXEzwFsYu40O2vSN9sexwXpnzrhmzQVwQ2mbvuL9ckcr1R5tjFRJD669TKQF9 e/t/I9pQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pht9o-0042z4-10; Thu, 30 Mar 2023 14:21:40 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pht8w-0042Gx-1c; Thu, 30 Mar 2023 14:20:48 +0000 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 8C811660318D; Thu, 30 Mar 2023 15:20:44 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186045; bh=piJKx8AJRTNo3xZLCBhwQ0b5ZyuIg8W2w0zGxP4Udgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dFFKk7tkMdrxgV29TKXItcjQ8VK6+yTcAue+SKpS+dJlxyYCh033az1Fbx04nLkhx aPIuM9EbxrSdmPUVssrVecUq99vE9/S+MyAe9v5/Z/dLyyA6Efpyf7WOGsuBGtij4x tw+ehm7xwuXINyeL0jdJDY2ybUhQwtct+TWywgZPsgx3w4xjv7tShHr1MgRBT3bM6v n7NUnuYhFeswARfyaJDECrwXzMjGP+JG2HJD+u8nszbq9F+VhG70DohMamZWWZrEv+ +DvXJtl45u/WRfNXeoEqLlCCcvjjLMKKqac1tTf+Z+T8rq97l/tn2jgUAtaNTBe3YV hE+H66Ni5DtMQ== 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 Subject: [PATCH v2 6/8] drm/mediatek: dp: Enable event interrupt only when bridge attached Date: Thu, 30 Mar 2023 16:20:33 +0200 Message-Id: <20230330142035.191399-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_072046_722934_41F178E8 X-CRM114-Status: GOOD ( 14.86 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org In preparation for implementing support for aux-bus in this driver, add a IRQ_NOAUTOEN flag to the event interrupt that we request at probe time and manage the enablement of the ISR at bridge_attach and detach time. When aux-bus will be implemented, enabling the interrupt before attaching the bridge will create an event storm and hang the kernel during boot. In any case, the interrupt handler anyway requires resources that are initialized by mtk_dp_bridge_attach(), so it cannot do anything meaningful without... and even crash, but that's not happening in the current code because the HW remains unpowered until resources are made available. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 19b145cf2e05..6aaf162a6bfe 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -100,6 +100,7 @@ struct mtk_dp_efuse_fmt { struct mtk_dp { bool enabled; bool need_debounce; + int irq; u8 max_lanes; u8 max_linkrate; u8 rx_cap[DP_RECEIVER_CAP_SIZE]; @@ -2148,6 +2149,8 @@ static int mtk_dp_bridge_attach(struct drm_bridge *bridge, mtk_dp->drm_dev = bridge->dev; + irq_clear_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); + enable_irq(mtk_dp->irq); mtk_dp_hwirq_enable(mtk_dp, true); return 0; @@ -2164,6 +2167,7 @@ static void mtk_dp_bridge_detach(struct drm_bridge *bridge) struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge); mtk_dp_hwirq_enable(mtk_dp, false); + disable_irq(mtk_dp->irq); mtk_dp->drm_dev = NULL; mtk_dp_poweroff(mtk_dp); drm_dp_aux_unregister(&mtk_dp->aux); @@ -2482,7 +2486,7 @@ static int mtk_dp_probe(struct platform_device *pdev) { struct mtk_dp *mtk_dp; struct device *dev = &pdev->dev; - int ret, irq_num; + int ret; mtk_dp = devm_kzalloc(dev, sizeof(*mtk_dp), GFP_KERNEL); if (!mtk_dp) @@ -2491,9 +2495,9 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->dev = dev; mtk_dp->data = (struct mtk_dp_data *)of_device_get_match_data(dev); - irq_num = platform_get_irq(pdev, 0); - if (irq_num < 0) - return dev_err_probe(dev, irq_num, + mtk_dp->irq = platform_get_irq(pdev, 0); + if (mtk_dp->irq < 0) + return dev_err_probe(dev, mtk_dp->irq, "failed to request dp irq resource\n"); mtk_dp->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); @@ -2514,7 +2518,8 @@ static int mtk_dp_probe(struct platform_device *pdev) spin_lock_init(&mtk_dp->irq_thread_lock); - ret = devm_request_threaded_irq(dev, irq_num, mtk_dp_hpd_event, + irq_set_status_flags(mtk_dp->irq, IRQ_NOAUTOEN); + ret = devm_request_threaded_irq(dev, mtk_dp->irq, mtk_dp_hpd_event, mtk_dp_hpd_event_thread, IRQ_TYPE_LEVEL_HIGH, dev_name(dev), mtk_dp); From patchwork Thu Mar 30 14:20:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13194253 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95F6AC6FD1D for ; Thu, 30 Mar 2023 14:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FPL/NFW6a4XbVx65QKR0eZskSslmSBbVywRw1jCRzh4=; b=H3hW4pPUdhUzyA8ji8nxzz6xNT r/sTprmbaz24laLY41W+lhbczzUOjViaaaE27bMVPMoZBvch5y3eY7BHTh48sW50WxEtY9ikANf8z hN+eKEOE6jSXKEmdmQt3NCa6XeDCN/jdGNYKUJPGA9ejJwAR+P+05pBoixFdmQiLxbBdbRIahcrjf XJVR/1rqta4FDds3yemFv+ddvXSTholnh9zcMrV6KiyNfrGUys5FESXQw82BESDpk0h1crYxR8KHD jGoZe2qPgCaNslEdmmWf4TRHFt04OuIgmvABoaRrSW/xknuM0A8Ez2sdyKI20A/8IpV7FxJc4O+JL aELOCWug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pht9p-00430S-3A; Thu, 30 Mar 2023 14:21:41 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pht8x-0042Hb-0f; Thu, 30 Mar 2023 14:20:49 +0000 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 5DA05660318E; Thu, 30 Mar 2023 15:20:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186046; bh=/+IRk8GyWs1c9yVT0iTCxo8DT1414PGgt9mTBDTdxe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QLBEtwjs1qWVOhMCWnpkoysjK4MG8i+7/i3SkOc7q7YkVyGAsieH7Z6KkH67kMdcu FalAsEghikxy0Hl80qt3tLP8SNP+Erca+YxndYwhgTG7VPxUMFCzsW+Vljpwa6kFvD 9irU1kRogE8aACWBb/4mjholJmELhB0aVoKnOSpu8ibSVbf650lb6vybCnwrOHmXTN uT6vq6M967cvkaSvUiuBmjJM/GofLGZDnlCnz8x0yMuwBYOFfHKnBf4QoTRlGQAruX 4/a1BgN8l5U05ieQrbWo9roJEdtiUVf/AIGdZgOhetV/MmskbKjHUPEg/l68X9zcP/ k8j281uu3nZAg== 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 Subject: [PATCH v2 7/8] drm/mediatek: dp: Use devm variant of drm_bridge_add() Date: Thu, 30 Mar 2023 16:20:34 +0200 Message-Id: <20230330142035.191399-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_072047_403809_7E6B16CB X-CRM114-Status: GOOD ( 12.01 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org In preparation for adding support for aux-bus, which will add a code path that may fail after the drm_bridge_add() call, change that to devm_drm_bridge_add() to simplify failure paths later. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 6aaf162a6bfe..62d53c4b3feb 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -2565,7 +2565,7 @@ static int mtk_dp_probe(struct platform_device *pdev) DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_HPD; mtk_dp->bridge.type = mtk_dp->data->bridge_type; - drm_bridge_add(&mtk_dp->bridge); + devm_drm_bridge_add(dev, &mtk_dp->bridge); mtk_dp->need_debounce = true; timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0); From patchwork Thu Mar 30 14:20:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 13194254 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EE7EBC761AF for ; Thu, 30 Mar 2023 14:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hCVZf8/29WGYT30PSsvdyMj8mlVRvLlPog6iZa30nLM=; b=o3rdfl8xxunRWHDwTxmpOlx152 rruvXyz4u8X5kE5hzOWPTH1BLVuZZ9TeLt3IBtpvdQ6BynRzCVLGOKnZ7xARMBQldsPcbd65HSqAR Qjz40Ht71t9pCLvFs0NNP18eDCNHB/T7y/0sYbLlwPiSKrwgt2SA5pfNDDOZQXEyY6YBn7eNYLY7N PXFW3J0iAeNGAr+YkJIjYYVlfLS2MctkS3LBJkA+lP70dywTp1fmBtFSn4o3hqXDoJ7lk5cCZy9Tt 6lW/0+WtwZJ3VdVuTtZijvbdBmvtF79q2MJoFKiyK5vA5iuve6zRcsdvbBO4JtL+u2c2vCMA1/FrE dfxDH4+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1phtA2-00439p-0m; Thu, 30 Mar 2023 14:21:54 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pht8y-0042IX-0Z; Thu, 30 Mar 2023 14:20:50 +0000 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 2ECB76603188; Thu, 30 Mar 2023 15:20:46 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680186046; bh=eZ/KgEJ3/NtZRipFLNfrQ0jkavJVDGo3ZnqqWIgjfIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J6eT9hopJTfhMn18I6oYzTmUvqzKs9vpBPbgqF+fdtu07yw0ynkbWdjWHyPuL3UU/ U1+dQxHJeYgxp8f1RgMMd8xdqLEy/ZyckdVQ76gyCZp+RLx44/v0LZF1FOGjsXZ37l ISC4MY4EgB+xvKC1hWdanMhrrhPx3/D889LgWNuqmjC81Exa1CGvh84e7AhXKa/R+t 2bNxMulH4r6fZJF+9KdEPHJHYygNVyJqATnz8FrfK2WUhoExVBi6mXZXIxmraHpbDj BlUBvN9AaVujKIKBfTe6+jZTfs3vQmQLSAYlTQx7GCUgbOFM0NEGHRwd87c/QxOcE9 /pbZfV4lK7Nbw== 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 Subject: [PATCH v2 8/8] drm/mediatek: dp: Add support for embedded DisplayPort aux-bus Date: Thu, 30 Mar 2023 16:20:35 +0200 Message-Id: <20230330142035.191399-9-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> References: <20230330142035.191399-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230330_072048_518484_B6E5072A X-CRM114-Status: GOOD ( 21.59 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org For the eDP case we can support using aux-bus on MediaTek DP: this gives us the possibility to declare our panel as generic "panel-edp" which will automatically configure the timings and available modes via the EDID that we read from it. To do this, move the panel parsing at the end of the probe function so that the hardware is initialized beforehand and also power it on as, when we populate the aux-bus, the panel driver will trigger an EDID read as panel detection. **** CUT **** Also, since the DP IP will always trigger a HPD interrupt at this stage, it was necessary to add a new `bridge_attached` member to the mtk_dp structure to make sure that `drm_helper_hpd_irq_event()` will not be called before the bridge gets actually attached, or otherwise we will get a NULL pointer KP due to mtk_dp->bridge.dev being uninitialized. **** CUT **** Last but not least, since now the AUX transfers can happen in the separated aux-bus, it was necessary to add an exclusion for the cable_plugged_in check in `mtk_dp_aux_transfer()` and the easiest way to do this is to simply ignore checking that when the bridge type is eDP. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 56 +++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 62d53c4b3feb..f62ef24db67d 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -4,6 +4,7 @@ * Copyright (c) 2022 BayLibre */ +#include #include #include #include @@ -2041,7 +2042,8 @@ static ssize_t mtk_dp_aux_transfer(struct drm_dp_aux *mtk_aux, mtk_dp = container_of(mtk_aux, struct mtk_dp, aux); - if (!mtk_dp->train_info.cable_plugged_in) { + if (mtk_dp->bridge.type != DRM_MODE_CONNECTOR_eDP && + !mtk_dp->train_info.cable_plugged_in) { ret = -EAGAIN; goto err; } @@ -2153,6 +2155,11 @@ static int mtk_dp_bridge_attach(struct drm_bridge *bridge, enable_irq(mtk_dp->irq); mtk_dp_hwirq_enable(mtk_dp, true); + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP /* && panel_on_aux_bus() */) { + mtk_dp->train_info.cable_plugged_in = true; + drm_helper_hpd_irq_event(mtk_dp->drm_dev); + } + return 0; err_bridge_attach: @@ -2482,6 +2489,20 @@ static int mtk_dp_register_audio_driver(struct device *dev) return PTR_ERR_OR_ZERO(mtk_dp->audio_pdev); } +static int mtk_dp_edp_link_panel(struct drm_dp_aux *mtk_aux) +{ + struct mtk_dp *mtk_dp = container_of(mtk_aux, struct mtk_dp, aux); + struct device *dev = mtk_aux->dev; + struct drm_bridge *panel_aux_bridge; + + panel_aux_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); + if (IS_ERR(panel_aux_bridge)) + return PTR_ERR(panel_aux_bridge); + + mtk_dp->next_bridge = panel_aux_bridge; + return 0; +} + static int mtk_dp_probe(struct platform_device *pdev) { struct mtk_dp *mtk_dp; @@ -2500,21 +2521,14 @@ static int mtk_dp_probe(struct platform_device *pdev) return dev_err_probe(dev, mtk_dp->irq, "failed to request dp irq resource\n"); - mtk_dp->next_bridge = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0); - if (IS_ERR(mtk_dp->next_bridge) && - PTR_ERR(mtk_dp->next_bridge) == -ENODEV) - mtk_dp->next_bridge = NULL; - else if (IS_ERR(mtk_dp->next_bridge)) - return dev_err_probe(dev, PTR_ERR(mtk_dp->next_bridge), - "Failed to get bridge\n"); - ret = mtk_dp_dt_parse(mtk_dp, pdev); if (ret) return dev_err_probe(dev, ret, "Failed to parse dt\n"); - drm_dp_aux_init(&mtk_dp->aux); mtk_dp->aux.name = "aux_mtk_dp"; + mtk_dp->aux.dev = dev; mtk_dp->aux.transfer = mtk_dp_aux_transfer; + drm_dp_aux_init(&mtk_dp->aux); spin_lock_init(&mtk_dp->irq_thread_lock); @@ -2570,6 +2584,28 @@ static int mtk_dp_probe(struct platform_device *pdev) mtk_dp->need_debounce = true; timer_setup(&mtk_dp->debounce_timer, mtk_dp_debounce_timer, 0); + if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) { + /* Need to power on HW because aux-bus will read EDID */ + mtk_dp_aux_panel_poweron(mtk_dp, true); + + ret = devm_of_dp_aux_populate_bus(&mtk_dp->aux, NULL); + + /* Power off AUX and panel now as detection is done. */ + mtk_dp_aux_panel_poweron(mtk_dp, false); + + /* We ignore -ENODEV error, as the panel may not be on aux-bus */ + if (ret && ret != -ENODEV) + return ret; + + /* + * Here we don't ignore any error, as if there's no panel to + * link, eDP is not configured correctly and will be unusable. + */ + ret = mtk_dp_edp_link_panel(&mtk_dp->aux); + if (ret) + return ret; + } + pm_runtime_enable(dev); pm_runtime_get_sync(dev);