From patchwork Thu Jul 6 12:30:17 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: 116665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2525646vqx; Thu, 6 Jul 2023 05:34:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBFyoD4GKrKL7l+FObmrd50yXsPkTLbHdnM4aUkJmVttKi0SCASxlmRkBt/5ZWLbnwpdtT X-Received: by 2002:a17:90a:6984:b0:262:edb9:bf44 with SMTP id s4-20020a17090a698400b00262edb9bf44mr1136024pjj.19.1688646861258; Thu, 06 Jul 2023 05:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688646861; cv=none; d=google.com; s=arc-20160816; b=ED0BGbpHgFkiAEZT9m73Hixo4Oamv7UMa+cGmEeN0rO4biVrRebJnPIo73751kvKod DM2onA9vSqof0jfTSyAWut1PDUocbHczHuqcZk3Nf9Wu3YiSqt1R3NFbb+w5R8tqnfkw c9kItPyAr/kzJyJV/oHxSEl1BylfkFBIl6RR0zhU85IzREjEGSYY/iWd3gKfXcTuPvVW MkQpoVR2FYzo/LD527/nEcL2KM6VDmus48FYsXIZ4OVCQDjcJ/7rm/xX8N4tnfy2TzJl saRskUhnGDXjgcsN90ilE69D7uojSIHjlG6MvADljDb/rYaWwgMgQRzdIdQgFLIWaEXv ktPQ== 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=h9lWQGZH5f2sQ2laDm7mGZlq6jYEI89M6asaSgCSWoI=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=bA+0ONRgSunjHYWGVGa5YryYFK7HSIw7URmfT/A8MrrX88+jIkOZnk2jtKQNEZftGm Tclyrf1T3DcpraE45cO1k2y4NBvyx3OOS3mJhZigSzDUci+6rJQY1amKC5q9YN9qUi/l fYgbivubaLc79hJbsYt3zejRdO+yevaVtx2trkvhbe9BUKd8bpYKFtJ01kbao+E2nb/6 rbIWjFwYdEWrfl/8Ky4fJJ/uDtqMpi6/CBns9Vo0JGOAoCclNiUHFSobuHGmKrsqOeVP 0yztcHAozralJrJzLX6FqwZ/AzytJzxGVOd+5FXJEkVG4ISGn9B0vpKs0BuiWnE8/J7N WfEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iA3k0+3Z; 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 g4-20020a17090a9b8400b002640bed79cesi1270351pjp.122.2023.07.06.05.34.07; Thu, 06 Jul 2023 05:34:21 -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=iA3k0+3Z; 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 S231820AbjGFMaf (ORCPT + 99 others); Thu, 6 Jul 2023 08:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjGFMad (ORCPT ); Thu, 6 Jul 2023 08:30:33 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 585FF19B for ; Thu, 6 Jul 2023 05:30:32 -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 5BEB96606FC1; Thu, 6 Jul 2023 13:30:30 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688646631; bh=J4Fv7OzB3CUSENYuwp4dZcyez8bgaU+pGcJI0tK+03w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iA3k0+3Z/8ftJGh/iw9czlTaoBAbmxaJsnf7fY/9LOKFSPSqYPttEPLNFzJjCp5k/ +Eq59DJGP0p1v1IOJ0JG2ygY8qAm6gR5XFlbZAAv4bArNBalf6l658TQVffJJJg+Np ZxoekOQz4mSOirnNzxvam8Tu+yWG8lQcnsTfGzbY1h9+y/zKmykaYp3Ifn0Uu/pNW/ 7TAggRXJ53KdlZMZC264l4WU6xUkWX21pawlFovFjswUxlPmZ2bYj4WwntlJBZ4F9d YVsT3gjx3VmBtep05NHDePmoX0FrojI/nKZLkexv/KwfTROxosnocV6KvAgAHj0hLz 9Ax0qbbGGfYdQ== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v4 1/9] drm/mediatek: dp: Cache EDID for eDP panel Date: Thu, 6 Jul 2023 14:30:17 +0200 Message-Id: <20230706123025.208408-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> References: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770674570857594861?= X-GMAIL-MSGID: =?utf-8?q?1770674570857594861?= 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 Tested-by: Chen-Yu Tsai --- 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 64eee77452c0..fdf5b7686884 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->bridge.type == DRM_MODE_CONNECTOR_eDP && mtk_dp->edid) + 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 Jul 6 12:30:18 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: 116666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2525846vqx; Thu, 6 Jul 2023 05:34:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlEM83nTWvJS7iPM+j0r1hWGjVzRQtB0M+00cPXeUqs5aclBUA53N+iEZvgxHglXxAuIW53S X-Received: by 2002:a05:6808:298d:b0:39e:b58c:13d5 with SMTP id ex13-20020a056808298d00b0039eb58c13d5mr2023168oib.17.1688646879167; Thu, 06 Jul 2023 05:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688646879; cv=none; d=google.com; s=arc-20160816; b=OG1cb6koutCe5Rv4VMTQVwZavaZSpBrLIp8qfDX71DWvRPa5CT/fUXbEWVVxcdOk6k 5vgldRJSU8zoOIEG+WCDU5bq/oCAL93r5ILaJL9CuyJRPWWj2D1xRcd1dng/dzw1+KJX 1UThrxCJ1CLqL52gU9+VO+C6omUjx7Q/6Z7y5bAsAATvrr3p9vyqFucs4qMEn0RRPOGw gNPVaEC6r5T3fkeU4t9nDty0vWn4hGMif+UZav5Qhm8LjpVRvYJWNTCBqJlwdh0ir5wG nwVfhPRgECTDRJTFT18yTA7F+m9skXCBtp6fYKmJmLuAgWVtmeal3eqeg1DVzffa5KIy MeEw== 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=By7z10Out6+Mh5+vc8LbQ+0F5oKY1ti7f4DsV9GRx8A=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=XDwv5PtnoYBPQMAwpi177mIOO6+32UkIxkMWO0Qjxgnp+RAG7KhvtwqcbGJz5sdSaq 8QaVEKdOoEhcMSFQ/VK8W7wQ33rsoWRuilfr5xWdFTT6WyUj8zYK8ws5NdLnZDNF7sM0 ga3afybVBjN6fqKDmTYf/CKYJ4VAi2ppMxuKoOYJHE+2C76ywVC2CD0fG0jZCL1B0gxc V3dYqfqZDgNFCbOnMyECdqy8dAXzIsNzdHi+IW6wcWip3baGS9PxmlPmRw2V5GuDfCB9 GfdUPoU9soKhB1fqo8ahfe5i1NRVouE+Kgm5apa55P0R6X4R/6h95Ww1J+ojb7gDBu9t 3Bww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WFXJ75ye; 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 n13-20020a63e04d000000b00545072f800fsi1309642pgj.320.2023.07.06.05.34.09; Thu, 06 Jul 2023 05:34:39 -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=WFXJ75ye; 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 S232016AbjGFMah (ORCPT + 99 others); Thu, 6 Jul 2023 08:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231756AbjGFMae (ORCPT ); Thu, 6 Jul 2023 08:30:34 -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 9367F1BC2 for ; Thu, 6 Jul 2023 05:30:33 -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 4B89E6606FC4; Thu, 6 Jul 2023 13:30:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688646632; bh=uVXES41+SNz3wCuFFhff8HC0aikP7yFXG8f408XhhDc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WFXJ75yeyoU5fuGsN7X2BkXCJx8aKr8VGzX3SpqOHuhpdottuvpBXbS30D48F3Gsm 06KQo9PsMElMTMc+vU+vgBV9vg8qVWkp8dHKJz/bHBuf6zkWDSgMitjFBWN8oD/+QX I94PlrdB6AMyCk6SngH8PmsjRHNNhriASVMMLsfl7oQbfdIgYzdOyJIjHI8vyVBq7k NYoRBQAvt5umNN/4IQD4MNCtDIshyTsWR9bkTjO2/q6+8V1yj5ug29W7Tst8mSPpib /nLM6/T78jTNIKZGJR16QWqYFS6MmrS+QyjUI4mSZbL+31pgBxlhP2i3D3KZ0bk6Mz 8bjnZ5pVXulZA== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v4 2/9] drm/mediatek: dp: Move AUX and panel poweron/off sequence to function Date: Thu, 6 Jul 2023 14:30:18 +0200 Message-Id: <20230706123025.208408-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> References: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770674589820486248?= X-GMAIL-MSGID: =?utf-8?q?1770674589820486248?= 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 Tested-by: Chen-Yu Tsai --- 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 fdf5b7686884..8f7d4af7076f 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1252,6 +1252,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); } @@ -2187,15 +2179,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 Jul 6 12:30:19 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: 116669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2530599vqx; Thu, 6 Jul 2023 05:43:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlESYXqx6pnnmpGoh5u/fwrMhoj6fNpGtJi/Q+oxZeuEkYt8wg8g9AvXBwNH9VfMXXjn7B0z X-Received: by 2002:a17:903:1c5:b0:1b0:10a1:3da9 with SMTP id e5-20020a17090301c500b001b010a13da9mr2585792plh.32.1688647395378; Thu, 06 Jul 2023 05:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688647395; cv=none; d=google.com; s=arc-20160816; b=xrV6ArAjoiArgwRp1G3W1lHcEfUig2+jmGdL5m5TTnZX1Kuu9+Y4XFST4o7cX784G/ XycXJdD+LPPaW75oSJ7scStejAqvAQXmwgMhMZ9duTlTFyQlPuffqAC6QpjQNY3OSt3f otsCprJilzHrxdHv3nnIroe1kcB2QvKI4YGShcI2DiElZlQYA3CDhSoXTULpUOwbEaGp Pcenmnb8yWkEA3A1clR8gh3W1pHoPKbUnAGE46ynJQ/yTUpzaEoaRgbNIrsMpMt7O9Yu Ye3nW4FVWsPWKFYYDwHrMASQCXPuUAh0fudsQOFMAhpf+UONLF/GLJwJLxvqOVfwFPEB 7kDg== 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=CGjZqnv5f04g8ybF/32ZW4B+i3AYe2YPeOze4GlzXGQ=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=PKd3QFqiAeoE8YVrecSNQ2wJumOQ28wttFDAeXV1rzgEhq0yHyZT9uWbVPq472kL2h 4dMIAqqvZDlRuSOI9G4kF0bO38TJ7oykU6qxHMfa1eaCvc+fJ/d+NS1uHOhF2Q0Y9Fb9 G7jOt0b/wt7FPhW6Jv8LyeYV6idJXH2xmDt4PNsdKwzIlNeERr1VctnfO+ztyrHZfUcm E1z73f8ldEewjXK0+iBUrah5eR8v6phOnDPkh6UzBe3/25n2d5Anu+c/lrll+duejyWI jw0Xv4qweokzCf3iNa9JnV9whwOa1ELjmXfyCdmStT7TzUUty+/CEeKgFz8fPLeikOhK MJQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="OQNqTl/1"; 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 j12-20020a170902758c00b001b06e17610fsi1185660pll.321.2023.07.06.05.43.00; Thu, 06 Jul 2023 05:43:15 -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="OQNqTl/1"; 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 S232059AbjGFMak (ORCPT + 99 others); Thu, 6 Jul 2023 08:30:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231802AbjGFMaf (ORCPT ); Thu, 6 Jul 2023 08:30:35 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28EC519B for ; Thu, 6 Jul 2023 05:30:34 -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 3A3DC6606FC5; Thu, 6 Jul 2023 13:30:32 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688646633; bh=eiF+MPOcDv9CDEFKbz/2nzTwuFjo2RNY4YZzBre0LbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OQNqTl/1PE5lx6QecqCAcVKxRo9TdiDhT7DlARV+Z4YqyJ/ya30FTg+bdZdACDtsm 7e0moLQLKsb/m+Dj3P5R/vDXNkajz/e2UAQmmftQqiWrvuDsa1knmlOROGvvaBvqpN +2b5RROPznSuNeEFgL6CiSMwS6FndbuqHMifS2bx6egNtX7FMOaONukVQihSbkgXT3 KyUV8J7lylA+JV3qCTzARcLcThNe0r8FFdJ3HIQlcucYV17LRFWeCWskyNwH9S1kyE tPndYj+Dzlhap/boYAmt5uvxAwzuiYmdd21EtyKNq6eT6XigOxydQti+tx22ScBvx2 7+ZjXq2nSSkqw== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v4 3/9] drm/mediatek: dp: Always return connected status for eDP in .detect() Date: Thu, 6 Jul 2023 14:30:19 +0200 Message-Id: <20230706123025.208408-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> References: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770675131232547637?= X-GMAIL-MSGID: =?utf-8?q?1770675131232547637?= 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 Tested-by: Chen-Yu Tsai --- 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 8f7d4af7076f..5b35a2e23896 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 Jul 6 12:30:20 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: 116670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2530809vqx; Thu, 6 Jul 2023 05:43:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlHQrJN9BIQIJRR0QcrSUBYPLXKzlhLMK6nbhZym9wzLc3SFtlZDryztfjGGpJ4mdIonsXDp X-Received: by 2002:a05:6a20:258b:b0:12d:23ba:55da with SMTP id k11-20020a056a20258b00b0012d23ba55damr1287774pzd.59.1688647414939; Thu, 06 Jul 2023 05:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688647414; cv=none; d=google.com; s=arc-20160816; b=xWkxWE9FA4oQoms1k8Eqtip/n8LvOHRvC2R+zgKNfvnPHAfAQtTw8EdPq0hZaTbSns KxKjKF+P0Fw+hGtyYkMK19g2x9JqhWDGWg7K+uxxo3Fa+KIkNcSEyaWRnkFV0iWb8Af0 EgL6XGTOrcp1y6FSggBi8r3zX8pD6W29KsO2qpuqV1FD1VyME0k7eyOyKtxqx/5JCkSE UP0eAyPeRTEUzGmzHtDlxqscKbz4swZ7ENsMA11Y3JSn8l7igMzI0Fhdv0eo0myBl4Sv HSaoboCy7zduFADpgcUE9SDDJ01ExL0XigXVywh9Jk3GKN4ODuRsBXKox+lA0zsZf8KW 5s/w== 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=wkQrDbz11AsGHgXVO6Q2KjnrgpobXN/3E+qjgYSqTpI=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=j0auwptmXWZj0fKkcL1P/DfCDBnLYnt9jzdSbwd8MjxIm82s7lY7PFNk+LdsxhbZiW PPu9PabYFBehQ1DyDX2OWti53rjtf0nya3TfjahllAFHrGiW7P6OibFrpmPfo8Ga9f/W mm5L0NLAA2TnNpCj+PaGNqSgJy39yWYpkxo1nYC0jaj17Wg1M7j6Vjl+UT8f8fFc+s8d jBWIuXUnllqwj2pogIfDPypg9r/tmdkUCMonZ0MI+m3++rjaDEEYyIiwLRPQrCGybi8v PeADztB9HCjSAaEqh/0meKB88wLc9ZeMYAZu/qGIC91vp6s59S+jhp8TAxFqESZ/KAQy WBDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="GgT/1lsW"; 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 d8-20020a170903230800b001b8894c8e20si1359730plh.279.2023.07.06.05.43.19; Thu, 06 Jul 2023 05:43: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="GgT/1lsW"; 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 S232158AbjGFMao (ORCPT + 99 others); Thu, 6 Jul 2023 08:30:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231972AbjGFMag (ORCPT ); Thu, 6 Jul 2023 08:30:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09535E72 for ; Thu, 6 Jul 2023 05:30:35 -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 265726606FC6; Thu, 6 Jul 2023 13:30:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688646633; bh=yC6E/mBM/67sUzeZV3Il3wBBzCtdEOHPS+iJkXdky+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GgT/1lsWIVlTK/HPW/RWvCKuOXCXF14NVBF7ybqd8Ohqh6bjDOlSBJEXZOJk3G/9c JrVyaPTWeGT9kpcletskQGZpKvWpEATDYQ/vTcYc0sXBxaO2vH/Df1ZElhNxv37IBV NyGKvX9xbHkePJ+fnu4nakM8B30WZEjwyqrUAOmYEwyBlBf8hxq/v2qKzeZ97g1FjA IzTFX5jqv1IVizB3MQAcy9d9f3SqisJPDgK+j3H1/AZMa8R94sqQyK6qZEpquaia4c LpO8cU+TT1Feqyg928pAuxkDTWQnw+/Z9bQOU5pmZDBkwYua2r8ZDM7erYgdeqPeVP bNYJ4LCvTGijQ== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v4 4/9] drm/mediatek: dp: Always set cable_plugged_in at resume for eDP panel Date: Thu, 6 Jul 2023 14:30:20 +0200 Message-Id: <20230706123025.208408-5-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> References: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770675151617766993?= X-GMAIL-MSGID: =?utf-8?q?1770675151617766993?= eDP panels are not removable: at PM resume, the cable will obviously still be plugged in. Signed-off-by: AngeloGioacchino Del Regno Tested-by: Chen-Yu Tsai --- 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 5b35a2e23896..35f3549d258e 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -2606,6 +2606,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 Jul 6 12:30:21 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: 116668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2529485vqx; Thu, 6 Jul 2023 05:41:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlGpHZvzeHGwKCBIQ3yNAvTAOY5xxolpE21VMW0gTzaJKK4r8pFgeL2JwkIb2lKl6vLinCB4 X-Received: by 2002:a05:6808:1203:b0:3a1:de61:d414 with SMTP id a3-20020a056808120300b003a1de61d414mr1557294oil.51.1688647265093; Thu, 06 Jul 2023 05:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688647265; cv=none; d=google.com; s=arc-20160816; b=vTSLL3L4nlLySFpm9sW+XA9ehUyYVSqQkOFEKtMcBrRrC4VAzpb5LbnYrjhg8Wx/d2 IBSj4yBimB3CcyCVD30N0x86qNbKFVGq/+rt+Xd0n5bmFF+kn67847EUVpI832kZcFfk uq8fWIKG3bvpHyE5RO2YLiF1ynW5Yy9ruGgBzilSANu5Es7C/1fQ2RjsRNsijd+GicEd Ib+kGrkga5SExDQFzXW7kkaTtWuX4XUEtqLhOkA2F1gc0A7SNCtI8LGjUEwDE3lNVaPa eWBx2d8a52HlIGBze1hvW3qSnw3nxRAAMsDAYBgVcRS3NPX66enKoxG2S3LIb/hcHc+U j3Ew== 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=arrhT1IZJkl27pU31eQY/6FWv1dx7Q6u9+hntxkmUR0=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=ivXXsZR9kcU/gBrwAzMjg22PwtO7a1TUPSCq26eXsFzKHZwMHpwcBTtsHaySyo4vfs BaHICOugYITbxToldfd1VBbkD8/7nx1Ku+NgSAh3W6IKsrMk06gqcwALVLne5cySNqW5 vN7csVYkxIKWBocLWVEtmb+yo4CUfeb73WWJYMkiZ5Cu3cYyGD2gODyBGJN+/cKOFu7h fMNyYiYbPUjVGiFhNzTu4KfMAt/NvrXk94wK8NY9kl/YWW8IxGRPvoyDTZHoKMggZUu5 XA1lEENf37lgVREFMctC4XZ/osiTGRov8kNGUkOZje8IiUYCtSGSUvfiDnuxmPJucWLw 3rIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=U2pmuJ9Z; 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 a3-20020a17090a688300b00262d8c82bddsi3776057pjd.157.2023.07.06.05.40.49; Thu, 06 Jul 2023 05:41:05 -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=U2pmuJ9Z; 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 S232344AbjGFMaq (ORCPT + 99 others); Thu, 6 Jul 2023 08:30:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231980AbjGFMag (ORCPT ); Thu, 6 Jul 2023 08:30:36 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E96F5171A for ; Thu, 6 Jul 2023 05:30:35 -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 1AA9F6606FC7; Thu, 6 Jul 2023 13:30:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688646634; bh=MT3q4EebZmygE+KyNdwlHQ30iT82ATSvvXBZJkPrX44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2pmuJ9Zhma74iPKRa3VbSF+KtxhrXTCDQQQ7v5UiBANm8VwaEDMciIqSQy2/WKTS zS5Tc4F2x2tk46sS5Yz1/025SYo5YEDuepEVesh10KmTyrmjFdMuulHGjPVQvdzy9d pUstFb2AhQK9piecuumsOxii6vnrODdnmerqoE37+8VtoKuM0g4XyEVR0Ef9cTEAyp TRoBTJ8/bvikHm42nvEg3JSytGPWKnFCdHZkCoDxqJsrmk9/CjbDgbELxgrpuTn/GY Zt1fWRLYJaZdGGZK5CobN1cgxBKM+bcB6K+nhyI16gHU4qXA8TIUcQlr5sMeDxD64O HJ9H5O4m6q8QQ== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v4 5/9] drm/mediatek: dp: Change logging to dev for mtk_dp_aux_transfer() Date: Thu, 6 Jul 2023 14:30:21 +0200 Message-Id: <20230706123025.208408-6-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> References: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770674994763923986?= X-GMAIL-MSGID: =?utf-8?q?1770674994763923986?= 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 Tested-by: Chen-Yu Tsai --- 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 35f3549d258e..274119356dfb 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -848,7 +848,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, &msg->reply); 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 Jul 6 12:30:22 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: 116672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2531002vqx; Thu, 6 Jul 2023 05:43:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlE6tkiz3uIVv0GSwmloxqkCluuvwv1VC2pYwhdlu0KXmgtnudAh5XZuy9wjwH1EYZ9jGakJ X-Received: by 2002:a05:6a20:3d8b:b0:130:45cc:616a with SMTP id s11-20020a056a203d8b00b0013045cc616amr787800pzi.35.1688647434393; Thu, 06 Jul 2023 05:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688647434; cv=none; d=google.com; s=arc-20160816; b=anYuaQNrWjJG2T7RF932B3U6tKwZ1cjMRPrO4/DBbV1C0mglhaaJEWsE11pGGutZnV XUgEUu7RLgto596DLa84Xe0lPyz5LIy4dMWnMXpuII8HOq49UVolBMt1Qv6oBLFVEDjs fiVZTGDxsbloSH0F7z16swggNeqjPdGawU3Focvz7elFazSfsodfCQGwz+/XeexM8txP h02NumoUbpHzmEM+wnD9mrFuEfsXkjorUeLmkP/ANQLNkY+HNbjKQ50fmx3d4uSx2wA+ opHn84sqaY1YckIpgq5/YXwH28COP1Wh7D7xde83sqWa74MNGN0aSsVU17XJdVUORSfU 2BJA== 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=DYajwZEcNYa2twobkKKrKJe8PtjASN1Dir7J5wuBB6o=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=UWfZ0jA1cF1cPWPqPJKx7bv4iEMgjzsP2pNEUXVikDZRLzgeddjoYKjMujkNYCQJlw tT4xT/9ZXGMsaVj7XLDxWymcuG/Tag+k/fPV7+lnfM+K1duUrThcUAuFoY/BH7Ep6a4/ UQd3j+sghefLqOd4gJ0idG0zckQddB3NF9Es/yjLZ+bD+S7DhcMt3l0sYA27J9lxVaTk xOhiVvOfEBVpr2ENUPK4SWI9cANV+50nEHqwBNxl14YwFKI0H6OtcDoTEf3jACvwcWeg U+Abftl2MdRzQGi/9HSk0CL92gN69CBdGWEspbxIZK+EbANqS37eGf16h65/oa+RxomX KYlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=euhM+DGk; 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 jy7-20020a17090342c700b001afc602cd5esi1212301plb.90.2023.07.06.05.43.38; Thu, 06 Jul 2023 05:43:54 -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=euhM+DGk; 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 S232394AbjGFMay (ORCPT + 99 others); Thu, 6 Jul 2023 08:30:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbjGFMah (ORCPT ); Thu, 6 Jul 2023 08:30:37 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D70711BC9 for ; Thu, 6 Jul 2023 05:30:36 -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 07B4F6606FCD; Thu, 6 Jul 2023 13:30:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688646635; bh=SDqfcPu1Xm6TXPZRhcStnENnmo+lyeo6d7YVf6Sycu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=euhM+DGkPbR6J+sZeCx8RXgfRJH2oDNdzh6srd6wwkNDIOx+BzpPxg31HoBZ8zEZl mSMnLCiYl8JSzXxyFJwBsjHcKeppF5MwIpMCSf7quGyOpC0vPEAzLDzcvvYGUEJYlS Oc9//UfCPrS65h5BlDNQbu3h5zJZ5df0lTcsMsC7wyJqjudio3JQjuTui7ee0Fcky+ LcDFJ/I9fEAnHYhJw7V1WlpGhSPR7o4hozevRh5MKJi8dJO9L83p57KyCZaoV1AQS8 0WOFbJWezUoCJ+Zi15vWy88V1E8vwxzazZtBHLqRu3o003rw0TCikG8jV6j88w6GZi WTTTr7uJqjUGw== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v4 6/9] drm/mediatek: dp: Enable event interrupt only when bridge attached Date: Thu, 6 Jul 2023 14:30:22 +0200 Message-Id: <20230706123025.208408-7-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> References: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770675172542054278?= X-GMAIL-MSGID: =?utf-8?q?1770675172542054278?= 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 Tested-by: Chen-Yu Tsai --- 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 274119356dfb..eebcb32e67ee 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]; @@ -2147,6 +2148,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; @@ -2163,6 +2166,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); @@ -2481,7 +2485,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) @@ -2490,9 +2494,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); @@ -2513,7 +2517,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 Jul 6 12:30:23 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: 116667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2525876vqx; Thu, 6 Jul 2023 05:34:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFQJbNGjUeCcNeEjybXcdpiaFXC53NKkbX6HOvegnqnpdykJRWI0Hz9WumZC/T9A/RN9K88 X-Received: by 2002:a17:90b:4ac6:b0:262:e439:5013 with SMTP id mh6-20020a17090b4ac600b00262e4395013mr1186142pjb.9.1688646881236; Thu, 06 Jul 2023 05:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688646881; cv=none; d=google.com; s=arc-20160816; b=fwDp855NgBK0EnqpGic/Ws4+M67g0Ou73VXV3fHky2YHJefzzDrhpeXAfhpBNjL8bM Ek1Iq4Gtzj9jrxKi6HGOV9qPaYIJJE7OZnkSno4KoqrS1+TAS/El/cRrP/lH+glUQIWs 8y0vP7n7HgWTo6b05aK3o4/8F1Jfet0bvKrvXtikuJvNcuRA4wIGwbqlHa7ibhCB+MGO gXfeOtYcchSpxr2VXp/uu72ZSLEXhJMbgsD14O4RGQdyKM58fH9zOw1Q86qkrPR3A2OC dvPQwFwMCk2UXD/oQrBa0XjT7xjIJi5BiDUpZbPHWYSMIJ5A0sdzDOmXCU/7nDTg2gSH M9KA== 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=34Anw/wI92zz8P+zTww+gkLhetdCiKuz2Fn1f6zs4Jw=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=eWqDcOJ+wVAFg6KHV8jbybsmONIxM5yoNG/5lnlEQbpQS8O6eAC/iOtF0+v1r2ITM6 ITxxRg84/TT3jXipyLmZ7br2XyLiU5VfDGd/dJddJfut3yyVzsTIBP0xMz7WPtrMplE0 KhC3xCFrhOxwxuY8ZHaQ1HGCmGI5G4k1SdFygplWCrILdNJAXQTMS1fIUic00wl8ksM9 CinU1dloBvDiJ7DvPytMK005uqLKu8KAdoH8JykzVSBhIVoTCWjdMDgveTagYyZ89Igd vgH+qiGf9ZBwksaU8aLaidjbJcLnybHlKcf7m0zFvk7eHyZ8lANDhbneDtvdrbL/7yiL MQwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="PXRdj/hw"; 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 15-20020a63144f000000b00534780446d9si1336960pgu.640.2023.07.06.05.34.27; Thu, 06 Jul 2023 05:34:41 -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="PXRdj/hw"; 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 S232370AbjGFMaw (ORCPT + 99 others); Thu, 6 Jul 2023 08:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231751AbjGFMan (ORCPT ); Thu, 6 Jul 2023 08:30:43 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E62FD1BD6 for ; Thu, 6 Jul 2023 05:30:37 -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 E43326606FC1; Thu, 6 Jul 2023 13:30:35 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688646636; bh=5+0g34fw0wGVdF8pSXSyeJt5CPUOp79klTRlFXdGl4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PXRdj/hwHQs2SS81BQtrJIekePJZYwkIN/n2Ikp2BxktX6eGrI213k29FdWmkIYe5 hVg7B2E/Qrmy3m27lgj54mi/lEmr9stGO4ZeuQRis4apiQFKZyfxTGtNOb/6JhhB6T s2hE7LiTsKshLGTET5+QLNk8OO40i9FCJsR1dg28ncRoyPLq0d3d9/K4EDZm2hb3YK m2qYk8qRFiQorjGMfTJTRHAyQK84SaUKmApKeDWu2THIKisZlKErE64VTNpSCfyd7/ pHJVaOU+Vj3+qugYlIlfliCc1QUQx0wcjwKF4MlwmMpbvvqDoLF9XAHRLEzGLoTGey g6G9Ds1ehO4og== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v4 7/9] drm/mediatek: dp: Use devm variant of drm_bridge_add() Date: Thu, 6 Jul 2023 14:30:23 +0200 Message-Id: <20230706123025.208408-8-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> References: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770674591759574963?= X-GMAIL-MSGID: =?utf-8?q?1770674591759574963?= 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 Tested-by: Chen-Yu Tsai --- 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 eebcb32e67ee..6bc620aded45 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -2564,7 +2564,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 Jul 6 12:30:24 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: 116673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2531107vqx; Thu, 6 Jul 2023 05:44:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlEVXX+HrYcFG/nV/Gehj6kGB9Or4tqchcv+QeOpfEhC14GyGJV1OaRP3jZmY44wTcDc3zdl X-Received: by 2002:a05:6a00:1803:b0:666:ae6b:c484 with SMTP id y3-20020a056a00180300b00666ae6bc484mr2334165pfa.13.1688647443671; Thu, 06 Jul 2023 05:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688647443; cv=none; d=google.com; s=arc-20160816; b=N/enrWnhKBriJoqrMS0d1Qy+vegu3SYPx+N+W8XUhki7Tb5ZpaFMo8RsQXZVDSTray GG9oVGx/xzkJruVy9l+NF/T7feShElQrp/Quv/Si76st6HBut9T/KmTdug3KuLGBJzxU nmRGhGqWMbZxkqBoraXdgDs231DKT14f/SD7SbTWKLQYUQx2ln33Ven72FxV1Z8fBBEA 0pCDoB/aGqR5tfSW1b+xh3A1/SSZ6WS1js4GaEz0O+vk9NtO/uSgob1bB94+PMcVui5e r0RKoGBtyahSNrqZpY69bEYH4Xqdfl/tmgYxPZyEzv3yj8Z3SnkUpna9VyvigJJHe77d lVtQ== 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=vNgAcKrHoNxC7chEBTOVHcF+ATt+wBchYE0Ay2X8kSY=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=0grFLfAO4KjmkYr+WeLdh9K/crOX5vSuRucSOqbqg5HOiIu3jvbGfjeHsvy+5feC9t qFzoIIDJY4IkKfyXzLDS32FxaD50bUKj61PLVLaQqCyr7eyPJ8zWl9RsBEBe/a9eP+UY Vh30MnRVZtwJu+I2IY1TxNgjuIuwgZJyrMo9HXhZP5So/HdtGk9CMcXK1s1CSUUt56hD XcoFZRt2M/X5VsgaqDPTfl0kIso2jxuBvmjFFvx7p90Nn988DfVV4diaLUovEIHP1JGk R88wqrih21SRsV9SDk+6n6VRBsSj2lEVnIV6TbUJFavoNQxwSGYqtmlGqorA26C1cHy5 DnYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=ZbJh7Obj; 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 cd20-20020a056a00421400b00668230a86edsi1334454pfb.256.2023.07.06.05.43.48; Thu, 06 Jul 2023 05:44:03 -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=ZbJh7Obj; 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 S232215AbjGFMau (ORCPT + 99 others); Thu, 6 Jul 2023 08:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232178AbjGFMap (ORCPT ); Thu, 6 Jul 2023 08:30:45 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEF221BE3 for ; Thu, 6 Jul 2023 05:30:38 -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 D2FED6606FC4; Thu, 6 Jul 2023 13:30:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688646637; bh=ZoMduMOyhFGLpq32e7smW1OgDxFAiDhe86tDwqNFVyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZbJh7Objy5rebfeCtn91lhCxvUHElbhzTrM64pU1PV1nJIzAN9coGciR1/BRWjYTG 9j8yHLRMp4nBWT8YJgSYl37SZ+NEyQbGyghhECgjmutitaLpikGwq3eQljBmCOFPoF h++L+P5mOGlAmCBZBDgvP42+8Rm9b71zkNKzFeYm1R8F96Bn65D4tZoN2ss1QogaWy VZmIF+DBm0Gx0XGHGXhYqrF2By58+LBhU3P2uP3uVHwP8NdgmjTEJEnJ/TKKZ02deK y1XXoNualdeUyJEYJK0DI2fm67tbZQxMkXZYjgoX9gl2bxdyO0Dhoe+/VyXrn02dsu 6swOpVmjeynWQ== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v4 8/9] drm/mediatek: dp: Move AUX_P0 setting to mtk_dp_initialize_aux_settings() Date: Thu, 6 Jul 2023 14:30:24 +0200 Message-Id: <20230706123025.208408-9-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> References: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770675181750433001?= X-GMAIL-MSGID: =?utf-8?q?1770675181750433001?= 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 Tested-by: Chen-Yu Tsai --- 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 6bc620aded45..2ad836fbb7c4 100644 --- a/drivers/gpu/drm/mediatek/mtk_dp.c +++ b/drivers/gpu/drm/mediatek/mtk_dp.c @@ -1011,6 +1011,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) @@ -1823,10 +1828,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 Thu Jul 6 12:30:25 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: 116686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2536023vqx; Thu, 6 Jul 2023 05:53:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlF63KvxX0I9Pt+IrWcU0zwtEPQGnD5S1rEbqdXjMOnynZYGV8/UVAvF6Y1rLtRXz6Oy+/yc X-Received: by 2002:a17:902:b689:b0:1b1:7362:9a18 with SMTP id c9-20020a170902b68900b001b173629a18mr1415014pls.27.1688647990676; Thu, 06 Jul 2023 05:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688647990; cv=none; d=google.com; s=arc-20160816; b=R9XQi283iwsol2hxjbMvThJRXL3Ksg67nXl3nZc2FLXS3+Z1HaOnIDryHN7nhdqUup rvG9wCwMn9GIm9MLMPXn6QZtZPjCAyXphyjTI1uLs+LfHF3Mv8b3B3Qr5JNRIGcPXEbx SrwT9vAvi2IN+brqBOwuXbSmR0XFFnFn7iLgUIaZqW+p6PVkNEl1nd49Arsf2F5M80FE azniiuffAFWhytGBwf8swZhvZgxnryMcuTVLhmMTB+T1ARReEIblMHRhvEy7AFTrUuoS cW0K0tzR3KJFHIUct3C2C3wD6ulbPwKPNGR7aQ1yfQbDTZmlYvuqk8FhGry6xRambaVv 5igA== 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=MrZMfOJbJDw6FQRRoVget9cgH3Y09TLg6MN0JdLG5U0=; fh=JpmmvsKbFEtjFcPhKwAU/TS0J6xmkcPCzvp06hVht3s=; b=L4YHbXDJJHEcKJZAhyhurcD7eUza532ydmKmT5kpaLZz8TQ6Luph9aeBwPVA5Orp7P iLQTApyVk12F90iLXcAD0XLkjqUg3UQgCTdpVvLxOTzUf0YayclQZrhpRnF7MEAKbi8p 4eHOHwFiKhK6XSxyoWhI8o5gqMXpTZPHrgU9tTJ4bqqmL6kb9HdmrHy1sxmbXyY7tDzs VvrcCa4gDL1bjkOb2X1mg+ikuhYcFa+D6n0nFtjxWlwyrIIVTqbkoyZyUYoZKihyS/vS TJp7yKWE5ISswwdl9xfsLSTIJ6Owjh4TgYS3m+iJDR9m0uT2kM4kPpb7jHeRIDymqJKR Cepg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=S9fh0zEB; 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 m4-20020a170902768400b001b7fa0f052dsi1177932pll.484.2023.07.06.05.52.57; Thu, 06 Jul 2023 05:53:10 -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=S9fh0zEB; 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 S232453AbjGFMbB (ORCPT + 99 others); Thu, 6 Jul 2023 08:31:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232229AbjGFMap (ORCPT ); Thu, 6 Jul 2023 08:30:45 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6E081BF1 for ; Thu, 6 Jul 2023 05:30:39 -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 C1FD96606FC5; Thu, 6 Jul 2023 13:30:37 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688646638; bh=9O3oPbgNu2Rdb7yDbhzv2dqxXHdNKO6uVeeOVLaab60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S9fh0zEBn+hmDuKxNXcSQGYU3PiJv74boIpg00AXRaYaeGZxP4Ni8Ny2Amkx7qdl/ rGvdeaW6uqLFXPrlClXwRCWRp7wGTGV/jOzY/WKQjUXUhoohNueTEHC9IJSUul86UE DxSrEtVL2Z0LtEl86xJictTt3SMgb3bUIQFBa7+bu7Rc9RcXvcLqwKKC7kG3Pl/Bxq QYVMmO2xtndAaQnwDPrOKR+0Zb/dYTiZRAMmaRDmKKmBenFto8KbTOFVe62QqVh6/A 1ptYi6/AAxC95PB9pW359bQlxj1cOZehIjH6WmcwllwetLsr9HJEFrNbqz5kro2fUK ttYiWsPLR7dxg== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, wenst@chromium.org, nfraprado@collabora.com Subject: [PATCH v4 9/9] drm/mediatek: dp: Add support for embedded DisplayPort aux-bus Date: Thu, 6 Jul 2023 14:30:25 +0200 Message-Id: <20230706123025.208408-10-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> References: <20230706123025.208408-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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?1770675755487589246?= X-GMAIL-MSGID: =?utf-8?q?1770675755487589246?= 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 | 72 ++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c index 2ad836fbb7c4..16109d5ca5ae 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; } @@ -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) { + 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,25 @@ 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); + + /* Power off the DP: either detection is done, or no panel present */ + mtk_dp_aux_panel_poweron(mtk_dp, false); + mtk_dp_power_disable(mtk_dp); + + 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 +2526,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 +2589,39 @@ 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) { + /* + * Set the data lanes to idle in case the bootloader didn't + * properly close the eDP port to avoid stalls and then + * reinitialize, reset and power on the AUX block. + */ + mtk_dp_set_idle_pattern(mtk_dp, true); + mtk_dp_initialize_aux_settings(mtk_dp); + mtk_dp_power_enable(mtk_dp); + + /* + * Power on the panel to allow reading the EDID from aux-bus: + * please note that it is necessary to call power off in the + * .done_probing() callback (mtk_dp_edp_link_panel), as only + * there we can safely assume that we finished reading EDID. + */ + mtk_dp_aux_panel_poweron(mtk_dp, true); + + ret = devm_of_dp_aux_populate_bus(&mtk_dp->aux, mtk_dp_edp_link_panel); + if (ret) { + /* -ENODEV this means that the panel is not on the aux-bus */ + if (ret == -ENODEV) { + ret = mtk_dp_edp_link_panel(&mtk_dp->aux); + if (ret) + return ret; + } else { + mtk_dp_aux_panel_poweron(mtk_dp, false); + mtk_dp_power_disable(mtk_dp); + return ret; + } + } + } + pm_runtime_enable(dev); pm_runtime_get_sync(dev);