From patchwork Tue Apr 4 10:47:52 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: 78986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2927701vqo; Tue, 4 Apr 2023 03:49:18 -0700 (PDT) X-Google-Smtp-Source: AKy350Zj7n2HTBW5mRyVxod9MusJ+yUu1KIMZZkGuCexgy0ajJgNJYejgI+iilFY95YgcMK0UVN1 X-Received: by 2002:a17:906:a858:b0:931:91a:fa4f with SMTP id dx24-20020a170906a85800b00931091afa4fmr1927613ejb.41.1680605358322; Tue, 04 Apr 2023 03:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605358; cv=none; d=google.com; s=arc-20160816; b=LTGSDZE2jAHX8Rvh3nDWZCIvOAfS4/sQIj923VGz45Srm0XreMqkbfmhDQDLLtI5bu UaVI4xX6+FtvnHfQSlGuUlqPZN2Dll1GF1d8sFFAxBef9PO9Cw5KrGXX9LkpF2O0STWU 7II53xH13xSjsBbLN57BRmmO5QjMsyCsPEDL4o4xwf8VFYK65Ii2s9KYcJdbDJp09N8h X+zEezXCy8RY7l2KVrR/+iOnTic4fAIRoIubgWfOIwvWyKxnZGTRNKHwlwd++nnT7UhV tueXhg9Z7hHY79niLPkQ9+vQKcYy9htlcWrM0cZU1POi3qBYpr9qYH3oQKnNd/A6Qnwt r1qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mVHWryi7FLI6xgM1V7O/CpgS+CHXop+pa1pZRj1UBLM=; b=Tz7UHuvcEkM+UANHmfRSSjHJBbQHpwX/hRFSvY106JkPbZcnqtPYwEEHNsTXNlMNAn BqvPN453E+7PTKfPXmAbQarAKT1FLAF9zslY2R/B5d2NRA9IGJRYZMsWFp3i2HryfU8F OILXckx9BL5soQ/+giSeczqxnqm4+CE70asd+ybpJmHlL0QhdAL3FN4GzLl5M+8dShB/ 2bHCktzbLg66i9qYTNwyB04BpoDMzkEWRi823qUdnIrf9CcwQeIHO6LOLFX0IRv8LYIA dq7b2ahWKlfzfzHTteBrv47NXRcXFbYbUgfmoLv2TMV3IG5Uz9bZxVtiLARS44TeEiIN Ngog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kWfqTIxK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a50ea84000000b00502b7d134b1si2643899edo.475.2023.04.04.03.48.54; Tue, 04 Apr 2023 03:49:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=kWfqTIxK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234556AbjDDKsQ (ORCPT + 99 others); Tue, 4 Apr 2023 06:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234526AbjDDKsL (ORCPT ); Tue, 4 Apr 2023 06:48:11 -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 7E5A0199C for ; Tue, 4 Apr 2023 03:48:09 -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 2C69A660314D; Tue, 4 Apr 2023 11:48:06 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605286; bh=aTfefQf7wUPldM8GfwxyIBQhpoEf1h/RP3aMOHoG5mg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kWfqTIxKcDdyeFg0DuDrmjBHofBlnVH8+mggL2nm6pPo3GMHiqcATAJRE/eU6dzOH 3+rdxbDZ0Xvla3h4ldRGLQqF3TX9/US1lXUBG5GgY3HMsDhcsyS71IrTFdeV5/CRsP 6TqKWiAomBXeW+FBFbA0RkYreM6xM8wGfGQCXA/jofm+D+2uQvsHm9NEHgDaJ9PcJz nlAh4El7NDHGRAhSsIpV1d/LK9H4B3HOqGB+gfwZf7hHvzR8Q9ElFd9h8ahLJbStZI eIBOjEaOMUTJ03A34oQA/QWSKXlAA48mLtlaIYd3z971cmmTbneceyiyu2hb+GzJd/ 0wZtvdnFDljhQ== 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 v3 1/9] drm/mediatek: dp: Cache EDID for eDP panel Date: Tue, 4 Apr 2023 12:47:52 +0200 Message-Id: <20230404104800.301150-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242444368748236?= X-GMAIL-MSGID: =?utf-8?q?1762242444368748236?= 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 Reviewed-by: Matthias Brugger --- 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 Tue Apr 4 10:47:53 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: 78988 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2927837vqo; Tue, 4 Apr 2023 03:49:37 -0700 (PDT) X-Google-Smtp-Source: AKy350ZO8/vhtnyGzOzqfgG0/dIdDPBJB0Edyen07PMhYGZcNPkjySbgqcsfvUawXoE2egQR7nwA X-Received: by 2002:a17:906:9c8a:b0:948:d1af:3a11 with SMTP id fj10-20020a1709069c8a00b00948d1af3a11mr1779241ejc.50.1680605377724; Tue, 04 Apr 2023 03:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605377; cv=none; d=google.com; s=arc-20160816; b=HNlLiR6ri6OcuWUdmLRV0sHSJAMVyNpUrlgfKLoyYleqkfkIm4Ly7lv3cSk9EGBbL0 s79IE9SxiW8S3UsZPdC5m4sjEoAcXH5n4ZgMIECy2NEifIK01WXKReGLxgI0XjxZZ7yk UNOaThrcUX7JMzPO8lajZ9DM86Vw+k+QmU399iLvmVwLq3fc2K7Ay3gmoUV+syInGPkG 5XLKzhkT8HGuAg5QpKWVvXXAIuqRPSkEtzW5f2+pLhAjiZPcendapoRXs6oSoZncn81m xUiKv0CDJA9ZWRboBp1+8lVu/AeYkcahR0QpSmItRum/IzagD4TLaeTbehBV5E40hqGm G70g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=J5DWD32OWLq13uaRlJE+1ppOi8qnCqTf5ZEGPUBOy/k=; b=uVq1KEzVr7RQx5XlvCzVNa/DBR8y1exablmZygEdtN6WvldxAtg55pxAh1R9N1uXIL Am7WvqJ8YFqbcJg5skN+kLz5BT/0afIKCzdN9zCdgWePFhNfQ7NCfxMRPELffbj3ql/B SKj8RwO+iBsUS5mhAMWt+/drjan/R9zbpHWLwWnf2rMQ1dVdUF2RmlTXVxdJiW2807yy Vd/wVAPJ8qwTVlU9z9noPetF73irctQn+qfaPHgcygMWoMFioBajugGGsZDBuTRThOfU EfDzgKWCuhpGhEU1qe/suo45yso310BTYJXXQAyjfWiboY81ZSd5AM3Vo987oxdSi3Fg DIdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ETl2LZ5B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z18-20020a170906271200b0092be82bf914si811650ejc.863.2023.04.04.03.49.13; Tue, 04 Apr 2023 03:49:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ETl2LZ5B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234570AbjDDKsX (ORCPT + 99 others); Tue, 4 Apr 2023 06:48:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234538AbjDDKsL (ORCPT ); Tue, 4 Apr 2023 06:48:11 -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 7E4F91737 for ; Tue, 4 Apr 2023 03:48:09 -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 F1C1F66031A6; Tue, 4 Apr 2023 11:48:06 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605287; bh=IS0da1vr/9JtA9BZ0bqYXl4kxrPBhntX0yK9vYbXQe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ETl2LZ5B0dPCEdKCCHFJa7r9nE7hqf3FX9QX+Ef2UPuNT0deDxMYBJ8jhGINo6Iwm OF8RLZ5vxvBJU1JpBbb4m0RdkjZuMMIIji9O6zQH3zesvhvDqK8sztiQ4gdEy4K8g2 dI8ge8h3/H2+IPAmfHjOZXYxK/FeMjXQgxPt64ArwcqXgft1sacwP/jfHeSX0esh5S OdCvC2CCe/uFTRV/CMI+2yu/qrf97Yacvn3aXmvJqG/EjDon5HYu2wr2sFjeuzcPgl coNYcYEUqo/huY6Kz0fCl52jpaqz43qcjhdC1Ji8GRwj3GqB3Xp5U06rwS/MTmetVX Ere/RQ3GrkvQg== 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 v3 2/9] drm/mediatek: dp: Move AUX and panel poweron/off sequence to function Date: Tue, 4 Apr 2023 12:47:53 +0200 Message-Id: <20230404104800.301150-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242464563371217?= X-GMAIL-MSGID: =?utf-8?q?1762242464563371217?= 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 Tue Apr 4 10:47:54 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: 78990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2929175vqo; Tue, 4 Apr 2023 03:52:55 -0700 (PDT) X-Google-Smtp-Source: AKy350bBQK1EZkoJvUafvFKTBGg801VNQgRQeMno9BeVOOIik1sl5gle8XBAU2I63HcqSlcezZDg X-Received: by 2002:aa7:9e09:0:b0:62d:e95c:fef5 with SMTP id y9-20020aa79e09000000b0062de95cfef5mr2028870pfq.6.1680605575229; Tue, 04 Apr 2023 03:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605575; cv=none; d=google.com; s=arc-20160816; b=oyTfuAJgXuZa27PAlh42mzxqb7/kqG2+XcB2IZOispcmelb158Td/g2qfXDUmD4ADI bLrY/MhJXaKLUYluX7acO4/bqGfd/SpgmQDGSJ8rgLKHauqkTimXkXcD7UokeW6jAdac 4riZBtX4aLqYH71SRITDHnbSDpml5upP75dM1L3KVvOuqBNtNAR7MPWvub0SPF6+/rQV OHQFM/S9vOzgyYto/zYUosrh+tn7Bw00i6285QV0kt2tR7zIQ/HL43Zj1AqvHGZ1K5TP zzkHRYvJNCBigObFMoHbUawYzMO5k76/ugK9v3PsMUyZXyhlCCOtxbMVwJcy2Luz3jZ1 LD6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SA7K1DKPDuni2CUxMFtz6LVzpvZXN/0fsgagtyIjImk=; b=VlgCDCwp+ucNv1NnLavUT1qaXzmxUdaS0R+Qj5Wa2bce/Z8uxi3XzLMtLvGJwmewwM 9j7OlOTDY8/ORNLmEc2JMmRB2HEWIk5ImyM/YGOMW/oeVTaoAz3+k+h7vyngFBB4vOXe BDnP3N7+94hnQK/J7kzBive8m/RSmuoOw0TI7PLq4yNejetC6K/c2P7DYfuER4DDVC/I 1+H14Fz2kujM1SyEN+Tma7bRCgSV20FjjTTNJ4nKZwiVZ5EdTQ0VWfF7yd0KcrV6owio Hi4ElKX5EgOs7bf6poFA1+toCIizxSfiSiNPxQq0nZ8CZ8J5VhNrdmiIXJwApv+Y+mYK myzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Qcj4Qi+7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u23-20020a632357000000b0051323712244si9883129pgm.2.2023.04.04.03.52.42; Tue, 04 Apr 2023 03:52:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Qcj4Qi+7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234587AbjDDKsV (ORCPT + 99 others); Tue, 4 Apr 2023 06:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234529AbjDDKsL (ORCPT ); Tue, 4 Apr 2023 06:48:11 -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 915111BD6 for ; Tue, 4 Apr 2023 03:48:09 -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 BF23966031BE; Tue, 4 Apr 2023 11:48:07 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605288; bh=l7DxgZbkLf1a/NAX8ACnOYom2qi3A95N4rbvhFxlUX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qcj4Qi+79FHY08lDUv+IuJKMzkByf37aVI6u5qC0jUQt3ZRcXDE1iKNkwKAq2Bvsd dbjH9R/pjLEzjaFHWiA1KrsQ6XFOB/gBkX2GLDIE5Z48yMBCBZN7dbrPJUzaPnWif0 ob71RyaxPPNz7znBU21XEctjcQlz+z4Ifal8886rn3voYj0vU5gIMlXRbKIhPqAow6 qr9M8tMGcwcc9u0QR11iqc5qWFcaktMOak5trBzLhY2hgYB+l1lshhgO8eIffXUu/R GpTp/MpfsBcxGstaOgjf0AIpxY8ve//lyl+l707t1O4al5VMbv0FvTLYyuCmKLqDWC t7uuXgEBymStA== 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 v3 3/9] drm/mediatek: dp: Always return connected status for eDP in .detect() Date: Tue, 4 Apr 2023 12:47:54 +0200 Message-Id: <20230404104800.301150-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242672067168678?= X-GMAIL-MSGID: =?utf-8?q?1762242672067168678?= 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 Tue Apr 4 10:47:55 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: 78987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2927793vqo; Tue, 4 Apr 2023 03:49:32 -0700 (PDT) X-Google-Smtp-Source: AKy350awA3LEAt8zfUMtJLXOLsfTAl0bk/HJVTS5sPB+oA9VLeyWZP7VSQMfO37ekUHlBFv9a8tU X-Received: by 2002:aa7:c913:0:b0:502:2953:8ecb with SMTP id b19-20020aa7c913000000b0050229538ecbmr2359864edt.13.1680605372402; Tue, 04 Apr 2023 03:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605372; cv=none; d=google.com; s=arc-20160816; b=hRJafBngk4IWG1Z9nJrHTbXsn3kNrXjHU6jjGoP7xS8Yn3Vxi/UBE5FaWe4Jbxo4Hq nvPV5UpjbUDoAegfONqCfM3w0yU2PZYZkrR3sA8GwEc0H0Q/Jy0kQwfioNXqHEbk7QL2 XBqG5X/EJc1SLZX/HpjBt2pQR7YZXqxttqzUGopb+F86CY2AgyyhJY/Tmi7V3SBbT9Sf xBBJeFGVrzvCzLOq/vEMbqnATwdTvZkENDJd4YqnXN7BHqlacHbt1Zj+J0yU2d7t1pMQ JifhPyUIv9fefLWtCKuSzaLm7lEmHAMOCC3ppiuqB+6HDhqozMhmojKJFJTcF8b+PoCK cyyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nCg5ICz9XbPYs8GpKnZD2kdwz9IxKkREMg8mLvGBySg=; b=p4Ja7SVlQUFp4BG0hGrviT0orkNu6fwD31VEsn6h9wV+vk1LOHbV6D5u31c+cVzM1b wsk88ahkpo6bU8Efn1pPaEpioLItCF+9ejUjAxCRtYKa4/fK1e8g6WGFJ+zrgS+C161w 3k4p5NMhYhyzsxs0tw8n2cKwS2bQhm0pLg2+k5D4q3Pzrwn7u0yw4WziipSxXfmrBFyn XFPH5kAI79gIjqHrWNnnQcasyxTIJh1ujHvj3ZbDau1/9fs5IEFB6Y2Fg0Xsv78aJF4Q YbQxN049CWf6llq36zrgqY7ZqGrMyWCA+jHGwPMG/8BsQpm1WoRSimbLiU0EuCAXtH3r 5z+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=U65vJLbk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a1709067cc300b0094596c17d14si2176320ejp.4.2023.04.04.03.49.00; Tue, 04 Apr 2023 03:49:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=U65vJLbk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234571AbjDDKsS (ORCPT + 99 others); Tue, 4 Apr 2023 06:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234530AbjDDKsL (ORCPT ); Tue, 4 Apr 2023 06:48:11 -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 7E16C1981 for ; Tue, 4 Apr 2023 03:48:10 -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 8C48066031D7; Tue, 4 Apr 2023 11:48:08 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605289; bh=3ZbLGCMsG/gn15JDSWm25FtN0N4B/ueru9VCCfJiapw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U65vJLbkHVn4r+uuF2YhhtYmHp5qXs0ftuN5Y3CT7UAOt2OGGxXN0WM5jRjfbEgww 5BJ1jT0UkjrFvLGc926p/2n7q5bo5rLnRt3V1rf0D+3Z+khqr9VRKnYKt1iiHJqRsR Vv5dlPn5vZtHViLjpUgzq9ifxSp03hJIpMfByRpCEgBnsnQ0jrmd7uGqWu1DW1/anm Pf9i6QYSJ5d0VU0TxLpf35Uatxykno4XcqJrICuDAyjHDxyky/wHIo1zXr26AsanPj e19ilkNCkvwuxYybQVX9Q9eTAh+zfnvp69owPDTJSiQXZZwACMdp57HBmFCpnbbSOl upSnirqsOj9Mw== 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 v3 4/9] drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel Date: Tue, 4 Apr 2023 12:47:55 +0200 Message-Id: <20230404104800.301150-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242458635756579?= X-GMAIL-MSGID: =?utf-8?q?1762242458635756579?= 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 Tue Apr 4 10:47:56 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: 78989 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2928925vqo; Tue, 4 Apr 2023 03:52:23 -0700 (PDT) X-Google-Smtp-Source: AKy350YQU41HGXMX3x98cRd8WQUahDvR7aR0nPfXTMjdMAlIXmyzetAppBHHbdPO/JbmOGdGVoLp X-Received: by 2002:a05:6a20:3aa6:b0:d9:5a7c:b1c5 with SMTP id d38-20020a056a203aa600b000d95a7cb1c5mr1867606pzh.11.1680605543642; Tue, 04 Apr 2023 03:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605543; cv=none; d=google.com; s=arc-20160816; b=Jg2E5upTE9NXV24ItkNdpr0y2LVyRZUatXO4oUVbpy7YGHJWG24Wd7VKTHLTRlsWMM JZ1VPEiij1G5dEaOnK88NSSsEJt/CqHyxihiYV+qEhoRK6FOQ6PlKrDOKm0Aofc03+Nn NUHpatC36P3NEomVJcabqWQKXzWD81StQu5R/KdO7Q1WjIzmNFIZ8IbQ4p/SwunZgV0O UqGUkBGHFcu4UWmQMRr6q6JTicCsGZAnwtC5Bwx47koVM1xiWNCEb6wkMleRhF+IBaHw lN3xais8EYXXoTisesyAl1TloiC8p/T+K9AcZxTv6flGN62iaelxuERHHKCuGV7ug6xD sJiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6FtVoiMV/omg48bRFmqt6pDYPYlhyrqg6evx0w4MWTE=; b=K5WuSFwaHhr4EvrPN1PcV1HChLtWNaBLNaT+fbNpDK7Oq490fkqohgy481OMYV83zl pUpx6/gGv7s1JnGYKPZh9hCp0JvrGTx31uEDNreUnBNUmBLAruBmAtsoFcKbb55DT6kF 5SooFFhnM0lNS/GjopbIIAv69C2UexTVrjNYA5OTK9pJpYjsVtNlYCViwwVV495Z6vQd JhexpJQ246Cm+3CrS+C5imaX1ihbkx8kU96HRDjdpnnSxqlh6Ub9PetV7MTilnj+4unC 1qh5wmtq3Jn7sUbSmQxrbhGmJDic9ksE3CmDmmGFi+npRggiujZfQSZZDQBk5nqyYSst 440A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i5C7Dnru; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p7-20020a63f447000000b0051410d92aeesi1929472pgk.184.2023.04.04.03.52.09; Tue, 04 Apr 2023 03:52:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i5C7Dnru; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234577AbjDDKs1 (ORCPT + 99 others); Tue, 4 Apr 2023 06:48:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234539AbjDDKsM (ORCPT ); Tue, 4 Apr 2023 06:48:12 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 202C61BD9 for ; Tue, 4 Apr 2023 03:48:11 -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 5F47166031F3; Tue, 4 Apr 2023 11:48:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605290; bh=dxC6MHx3NJXRAEW1ywTcNfOZX7I8dn5v2i9D/PKGK9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i5C7DnruKzSV3Agq2NqRphzX/Cx52AGby+gu0C7QGWQ5Imikzj8NFp4HQkc+PLgxQ ZiyN6JcMIpFRHHlsJdj5XvlYS2XgWDXes5ALWZP0AfhQbh0E3fVc0Ry8rKqalRFS3Q rDBb6W2dW3cY7WXdqXPlTNuYYYA5yUnfmI9kEaqKLQS3wtEzvVwYCaeVkEg1bn1ToK yckdl50XJ6WH/y2rGqZWpWBjrGG/nGgpMFKCenAIV6rj/nc620CTm0uwo7fC33X6/2 xwtQb/uxE5YMBMpjiYbRzWmDlXomG3arTedylYohRbUFkjS21Luo58QEiFCifgjFQV 19Yg+zRPBLDQg== 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 v3 5/9] drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer() Date: Tue, 4 Apr 2023 12:47:56 +0200 Message-Id: <20230404104800.301150-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242638493379184?= X-GMAIL-MSGID: =?utf-8?q?1762242638493379184?= 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 Tue Apr 4 10:47:57 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: 78994 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2930109vqo; Tue, 4 Apr 2023 03:55:15 -0700 (PDT) X-Google-Smtp-Source: AKy350ZaQ5nIzKoFPFEeHFHv4Ih2NFBkwIQZqaZDK3PcJbJ/g1wUC14YSw/Ncq389r8krxnrJfvY X-Received: by 2002:a17:903:42c5:b0:19e:8688:86fe with SMTP id jy5-20020a17090342c500b0019e868886femr2161160plb.42.1680605714991; Tue, 04 Apr 2023 03:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605714; cv=none; d=google.com; s=arc-20160816; b=JRwIUUwrAUJMIr83ZIxqV5Qip6p0cIqo+BUAGnrG94WG4z5aC+bVd+I5VEGlAAmCqU 3lTgkUd2NkbKgFtZAKSKJ0+Ghlp4N1V/6RZm3BvNYcBjFOZg6WKW3lKw1Gbh63kUwQdu 9C4sGvG5gL4Lf4LEaas5zU4rr0wSKRWgjpnsCSb9xeQctzcnxzMlCU4YT0BuV2UY6G7J vv13pqi/n7ycT5FxwBo7Jfc+4zTtUULzk4qnZ4IMQPIGn+z5tNMQxu9OkAxzNz6G1IX8 SQooNyqCZj4upHu3UKcHFnxszusb/hlShCsGrfJwf3jYER2prc1bV0ocoypunr1ynEfL RSaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5aR76aUK66V+oOGD/BsUrwTZt7JhshN2uJKaf7z8324=; b=j7Wjw9QOoDLdXzlWJNjQPEOOAv4nvbqJczSlKP04I+8KgS0pU/kIzg/o4R4GgM27jK G3arJmths3AEn/zoBTNUGG0WJHUfjt/7vhJpKaHyHE2emXsSMIzbmheWpKkGZuLx7zWq HrzO2z0kwgBJsSpB1oQh9Ax5aImHkLBJ/PKNHjlL+b36ZzQwIarqIPs0EIFAFDUZQ2eh DdcQRTBdn0K97z/BA6KxMaYRzuvhFjJhA5DF/92u1bp6VGLd8mj4TgESYF7GUNtPhQra dyQ71Q6Ch2fknwJCXCApoeY1pYsKIIOP17Ih0QCFU9fU4cxTHihvwTNgZyuS5pYHcF7t es+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=QvnhtDxp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z3-20020a170903018300b001960e5dcb99si10670231plg.223.2023.04.04.03.55.01; Tue, 04 Apr 2023 03:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=QvnhtDxp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234618AbjDDKsa (ORCPT + 99 others); Tue, 4 Apr 2023 06:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234540AbjDDKsN (ORCPT ); Tue, 4 Apr 2023 06:48:13 -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 009452107 for ; Tue, 4 Apr 2023 03:48:11 -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 2C524660320F; Tue, 4 Apr 2023 11:48:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605290; bh=piJKx8AJRTNo3xZLCBhwQ0b5ZyuIg8W2w0zGxP4Udgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QvnhtDxpm5FEQgsz+h24rX861+Xfdo7zKks0F+FXwMkDyZ+ODrvhCqRdElDkT3XtR CQHzgk3CUfVn8LJQKckgq5FGfF8Mbi9AgaDIs5siaOGw1rtGynZsA5g/rLvFHvDYQY QGS01Dbfv46uDaCnksm8zWy4ftQrwkWrPO4uCCaG8ggyRdAIGm8yL+NvaN7Kj86KJt a9Jpl8HxYu1OLrVOQRDEZeSzhozk/4Ipa8i2vc+ZStFpYZYURN9e7ViS6ODwDltu9q VzXbh6G9DcKKHIr4mWs9gXebXjJ9p9TumusV9t3c0RIJrFQLG+jTw9q5B5UCLOVqq9 6LOu3KclKU6iw== 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 v3 6/9] drm/mediatek: dp: Enable event interrupt only when bridge attached Date: Tue, 4 Apr 2023 12:47:57 +0200 Message-Id: <20230404104800.301150-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242818218661962?= X-GMAIL-MSGID: =?utf-8?q?1762242818218661962?= 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 Tue Apr 4 10:47:58 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: 78993 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2929938vqo; Tue, 4 Apr 2023 03:54:53 -0700 (PDT) X-Google-Smtp-Source: AKy350b+RsNc49eHOF2G81evyv8A+e2vKOuARuTzyfO1h+o3j9/xTGpeXxWQ8mffz6UKnUPZF8fa X-Received: by 2002:a05:6a20:66a6:b0:dd:c49c:dced with SMTP id o38-20020a056a2066a600b000ddc49cdcedmr1873521pzh.49.1680605693514; Tue, 04 Apr 2023 03:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605693; cv=none; d=google.com; s=arc-20160816; b=0IKp2seqdojKKQv5QtsKs28jNQ3HMidVmtf6kMyObVtjwzp6AQPPrFIffw7sDbVH/8 priz+0SqhHA72mMJXEW/ptwJQdXmQPGBqLKrEdIiBd8rjoiKG9q++AVmPpwi2kxPlBc2 eT+BZWBrHwYfeWNMXhwtzU9czBCXf1reRJljym0vI+XbI2iRpXvUs4Qg96yGMCpbR6J6 ltxgQ6Inu8tv8Vn2bdYkCbQN+01sNVrL0U0P1UleIjDGCqKUrAQSyoU5q0SVUI6/SrJU W/hzP2L4wQ8cPUBwrWvylroQ9jiWJKXDzNJZYbYO5CBznT6VvPv/4CnXczghXC8OnyVm 96SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FPL/NFW6a4XbVx65QKR0eZskSslmSBbVywRw1jCRzh4=; b=J+6HuRvht9g9WHpm4hZLQYw9+w52wKu3vnQwM59L1vV+nhX7XVrYy4CpdENyJ42icb JaBLLXOZVzetMl4VZ+/SLzFlC0B4d8FnGyfDS6ZWLGkTMkcdeowTo9lqq8k3g78cokZz TeiFHGYZFWWfYo90NbHDPdjISWobdx+WEsMWfFMdeXqS1/RqRtkGAi1sy63zxHIBe8tU VzE0Tvf2QOcQgzI1m6Yd9K8806H4Z9TvRd4LwQ8tj0vOf3TPs5JufafxOYvTLKqpORN6 SNzsOnBI85SS0noKgngSynG6A//GCC4z6EfTr2Saox0Aj3dcJctxwTtP81D6/ggJBVGZ +4TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SPGO9OA4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h128-20020a636c86000000b0050fa0296769si1967048pgc.602.2023.04.04.03.54.40; Tue, 04 Apr 2023 03:54:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SPGO9OA4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234584AbjDDKse (ORCPT + 99 others); Tue, 4 Apr 2023 06:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234544AbjDDKsN (ORCPT ); Tue, 4 Apr 2023 06:48:13 -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 B13951BD6 for ; Tue, 4 Apr 2023 03:48:12 -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 E9F25660322D; Tue, 4 Apr 2023 11:48:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605291; bh=/+IRk8GyWs1c9yVT0iTCxo8DT1414PGgt9mTBDTdxe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPGO9OA4EvnviyFD/xK0I1xL2C/OLQEQ/GPiNOqq+yF/A3OwNKEgP2GQs9NhinxxX bQ9qCms8NoFZ5np9Yg0VDAL0ZLr3wd5GIIWfbxtL4cwjkY18eamjA+vH1o9Rx83udL DSwDFxHLwoDhtdFasIPBtt/U8jNiFqrN7K7tBGlc6OlP6FaRfsQHFwNLHTrMgnoZIS jYyamDm2iQyGjww0QlmzlQF1EgQYjfZgfEHx8WkgCM0ecI+w+LhcBdvYNfgnfAkRMW 2GVdvsnpeoiVHHENyQ7UVLvPODwJnhum3iP6NiTR2M1TgB9r76Il69Hsm0JmV/2bis NtbGdwzRufi5Q== 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 v3 7/9] drm/mediatek: dp: Use devm variant of drm_bridge_add() Date: Tue, 4 Apr 2023 12:47:58 +0200 Message-Id: <20230404104800.301150-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242795835004730?= X-GMAIL-MSGID: =?utf-8?q?1762242795835004730?= 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 Tue Apr 4 10:47:59 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: 78992 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2929783vqo; Tue, 4 Apr 2023 03:54:35 -0700 (PDT) X-Google-Smtp-Source: AKy350YcQRjz9CpEJXk3W29CDe52Vk7uvu21eRbGlgIahPViNc+QhCYrElF4mMQFX42PbRx9w1Bk X-Received: by 2002:a17:90b:4a50:b0:23b:4f2a:8016 with SMTP id lb16-20020a17090b4a5000b0023b4f2a8016mr2436514pjb.3.1680605674979; Tue, 04 Apr 2023 03:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605674; cv=none; d=google.com; s=arc-20160816; b=mW731y9yJf/eEingODay7dU3oXX7MyFwQiyWU2StgAxZsZArHbHsksyFPu/M/uj/bb MWxGl3IKePbT/I1HrWmukyojXfB+HG/6fAkK9ZKdsVO/ySIAxh8ZxVhYQBqGWzWWXLo9 BvS4TWxPc1/1d/l1JOHd75AezerPE6vBfj3LJasj2/1HJs1wK8QcfqlIyBuQIxiJ7iw5 hVfqPqxkk7qLG1rBBFVccchqRokBg4B2Vq7EWA6C0kU+x7reYU+nA0pMAufeGKIcHx+r STqi4//pptMb2LKerPdIpfw6gpijWXmkj9AYuTKPgoHwmIIKG73dRrOe+1M+u0bytfsj 11aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RGd+PI052R0541NhQSxOYQvPZSuT1XNowmc4pxQ7KC0=; b=cY2MWrUJ4iTqAs5JnGhZ1RD699/Zhu587jXcvvZz/UbIfMA7rtP7hQRLBhHtBnXBZV ixy3lOOxpZ/huFuIbqVvRrfWdL0iHKs6scvWjICSTNgKbTVqS7EypPjglGMzLLRt9/kC tTouo/RE9zKZOrdVVwiu64fWjtJpkgaszOfDa4aQGe20zjEBpX1T0UEUKKFeZxpa0/TH yQJ3lOnNokl/LEXNKqnsR9zX5+Ac3VYHliPbkrFJ+hOizNv4u/aUEEenPvRVNwwEiebE s0OlFYJl1tfGDGlxGUUVET3rebznERNVm6H0wL4KJTi6JLhlVa1pl4lAGX+9hFRi9Y48 JdNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="P0haN/ki"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x10-20020a17090aa38a00b0023f14c9a5fesi9525742pjp.100.2023.04.04.03.54.22; Tue, 04 Apr 2023 03:54:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="P0haN/ki"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234638AbjDDKsk (ORCPT + 99 others); Tue, 4 Apr 2023 06:48:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234550AbjDDKsO (ORCPT ); Tue, 4 Apr 2023 06:48:14 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A07D1BD7 for ; Tue, 4 Apr 2023 03:48:13 -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 B47AF6603248; Tue, 4 Apr 2023 11:48:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605292; bh=tcQ9BX88nK9YxCCQgMpPmnIGYL+QZroOMn+8gvsxyw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0haN/kimeW4Mcc5mvkbjr2J/kgNSrwZBhMOihrTSNAZrZNm0LRl8tk910dEGRAac 28g3oneEz6gUiN3PnJmk8wUH0Uc9UGdE2yzib0fhlq/Tg8Ya63yzzS6vSU5k3WS+uL zoEWY5RCdreDJSjIf27zsJ2T+V63etk7zrkPYKc9Cx/8iL6XhX+Pyn7RjCSYGWGXqR MrECPvXM4Q2xmkOoFFXQfIv9MCf2O8xjYmySpe12giowJAVTET2ApLVOPEABDlgQLU dU03srC+DL9Lz1UepObT7rTDqPKIQEH5xZSQNAP/24K3PW0FFSwPqXquMyOETOcQPs DKuQGdyFB9bkQ== 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 v3 8/9] drm/mediatek: dp: Move AUX_P0 setting to mtk_dp_initialize_aux_settings() Date: Tue, 4 Apr 2023 12:47:59 +0200 Message-Id: <20230404104800.301150-9-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242776227776292?= X-GMAIL-MSGID: =?utf-8?q?1762242776227776292?= Move the register write to MTK_DP_AUX_P0_3690 to set the AUX reply mode to function mtk_dp_initialize_aux_settings(), as this is effectively part of the DPTX AUX setup sequence. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 62d53c4b3feb..a67143c22024 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1012,6 +1012,11 @@ static void mtk_dp_initialize_aux_settings(struct mtk_dp *mtk_dp) mtk_dp_update_bits(mtk_dp, MTK_DP_AUX_P0_37C8, MTK_ATOP_EN_AUX_TX_P0, MTK_ATOP_EN_AUX_TX_P0); + + /* Set complete reply mode for AUX */ + mtk_dp_update_bits(mtk_dp, MTK_DP_AUX_P0_3690, + RX_REPLY_COMPLETE_MODE_AUX_TX_P0, + RX_REPLY_COMPLETE_MODE_AUX_TX_P0); } static void mtk_dp_initialize_digital_settings(struct mtk_dp *mtk_dp) @@ -1824,10 +1829,6 @@ static void mtk_dp_init_port(struct mtk_dp *mtk_dp) mtk_dp_initialize_settings(mtk_dp); mtk_dp_initialize_aux_settings(mtk_dp); mtk_dp_initialize_digital_settings(mtk_dp); - - mtk_dp_update_bits(mtk_dp, MTK_DP_AUX_P0_3690, - RX_REPLY_COMPLETE_MODE_AUX_TX_P0, - RX_REPLY_COMPLETE_MODE_AUX_TX_P0); mtk_dp_initialize_hpd_detect_settings(mtk_dp); mtk_dp_digital_sw_reset(mtk_dp); From patchwork Tue Apr 4 10:48:00 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: 78991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2929750vqo; Tue, 4 Apr 2023 03:54:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZfxVIVOydRt/uwBTPhxCeQAPrVXfGWsVx5Qdq3xTRD8s+yZYz/sBOiIZsIU8nPX6wPBHZh X-Received: by 2002:a17:903:2283:b0:1a1:ad5e:bdbb with SMTP id b3-20020a170903228300b001a1ad5ebdbbmr2539330plh.36.1680605668850; Tue, 04 Apr 2023 03:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680605668; cv=none; d=google.com; s=arc-20160816; b=cklhYKKIA6G+gmsp8xEsqWrjSbcJ+k/CIh+IGsX+1P1z78BzXVUcnKvqk8fRJF4GMV 6dDjqbZDGE9bC/wB5CBytuPinbdo5EAWQjZJ5acIW1sF13A6oANLLwxk4PNe14gokBcK XagWUUfy27HuGnouNQS2T96ogeTnDII3FG9X6QbrRWN7geMNmlQ32YRd1SWqL6yfug42 qOhTbgedV4w/92//YtTixNNljq3gg6YEERI+J5ASMQY/1Q1P/hN3Nf0kmspWn4aqrtKz uw7bn1oXzTPwtjQTXRbmu25EqqZ56QygPbDh0G7wJ5iz7K8raPlht+6vCEhoHYB5Ukte QKtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hmWKdqxDsvfexi1yEi6FSub5mgsp34ZQ9W6zOyDfYqA=; b=zCMvceH8/q157MVK6OGxtE6W9xjXCHF5Cp3Evclu43V6fTNYHkSyw5LWJpit1+hIF7 4gGPejXqyR2Mrx5GejNbO9XPnXs2kJo+uC2WGd8J1iM9GtiZRVqCh/fzW7qOTKhydvz2 yCyVTmbJADcUzw75cpV276PiQXCVeWWKWvj9EMBVpVMGHPn1J+YEogIJoKob6a7prluX IopdxgeVYns4vDLL9FSL2xzh0ov9B/Mdz444W5JgH+hBT6qPHqdoA4+GSQP/2XX/A5xQ YxTII2J/yXpxgCvaf8beBhXGsSIl55Ze3PEmpY2llKQfmZhSR3AgSWURPX4SFSLjvbSC yuPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Efpx2sJ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix2-20020a170902f80200b0019ca5ddf234si9783360plb.627.2023.04.04.03.54.15; Tue, 04 Apr 2023 03:54:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Efpx2sJ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234645AbjDDKsq (ORCPT + 99 others); Tue, 4 Apr 2023 06:48:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234049AbjDDKsS (ORCPT ); Tue, 4 Apr 2023 06:48:18 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5072230C5 for ; Tue, 4 Apr 2023 03:48:14 -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 85711660326B; Tue, 4 Apr 2023 11:48:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1680605293; bh=+E8hTN3wC4q97x93aXteKC9CVFfI18J5GBPZJYT7VQ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Efpx2sJ5N9N3X1hL/oznHMWpKTzXWKL+gA3TXF9fED37IxvaVpNVe5nHbegXovHDM 7P55UpaxPdbpHkV3cbGNVAP00olpklBSGn1m/ZK1LRAw3mC8pjMYBdha3AI2FjF9Oe F5Vw6aUDUi3DxHRsl/dRugvuEAWhjQrl8JZ4qMSXzXa8BCjBAK3L1Ya0Ug7FzjrYHZ zNA7PWcT4/dCCJc5CrDnGj+B372wlqMbZDDS7encx4SKPnYoZIsi9NqaLXGvi4s7ob 9zT3NjbsuSweIkQJTvUJxsyAp4WPnvPEMrkzqczPvLLBmVAP42b5elmYCs3yn/YHAv 0F5oSJhBxnxJA== 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 v3 9/9] drm/mediatek: dp: Add support for embedded DisplayPort aux-bus Date: Tue, 4 Apr 2023 12:48:00 +0200 Message-Id: <20230404104800.301150-10-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> References: <20230404104800.301150-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762242769364401824?= X-GMAIL-MSGID: =?utf-8?q?1762242769364401824?= 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 initialize the DPTX AUX block and power both on as, when we populate the aux-bus, the panel driver will trigger an EDID read to perform panel detection. 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 | 61 ++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index a67143c22024..8109f5b4392b 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 @@ -2042,7 +2043,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; } @@ -2154,6 +2156,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) { + mtk_dp->train_info.cable_plugged_in = true; + drm_helper_hpd_irq_event(mtk_dp->drm_dev); + } + return 0; err_bridge_attach: @@ -2483,6 +2490,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; @@ -2501,21 +2522,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); @@ -2571,6 +2585,33 @@ 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) { + /* Initialize, reset and poweron the DPTX AUX block */ + mtk_dp_initialize_aux_settings(mtk_dp); + mtk_dp_power_enable(mtk_dp); + + /* Power on the panel to allow EDID read from aux-bus */ + mtk_dp_aux_panel_poweron(mtk_dp, true); + + ret = devm_of_dp_aux_populate_bus(&mtk_dp->aux, NULL); + + /* If the panel is present, detection is done: power off! */ + mtk_dp_aux_panel_poweron(mtk_dp, false); + mtk_dp_power_disable(mtk_dp); + + /* 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);