From patchwork Mon Apr 18 16:56:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 12816955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCF5FC433F5 for ; Mon, 18 Apr 2022 16:58:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5BF6910E275; Mon, 18 Apr 2022 16:58:38 +0000 (UTC) Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 596C810E272 for ; Mon, 18 Apr 2022 16:58:35 +0000 (UTC) Received: by mail-pj1-x102b.google.com with SMTP id z5-20020a17090a468500b001d2bc2743c4so1059174pjf.0 for ; Mon, 18 Apr 2022 09:58:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6oixKBcCsCGFR4aUQt/tdt+p4qsIdjpTUDNTqLJ+UgM=; b=DsxdfJZZnKidzVPkjEN8yyUDWjCsJqByNG9+TdHU4o42WMmxNPH8Yp36mIV/daIscW 7cNxu8SvonrXTSDpOOOipLirQYrOlf16tNmZ0+vxdb/wGZXfxZA404ipdOazg3I/OkrM 0+zvrl6X1pFZbr0+SitCe57qkBRmdQco5No2g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6oixKBcCsCGFR4aUQt/tdt+p4qsIdjpTUDNTqLJ+UgM=; b=oiXsXChJppMjtZjFJkMBBlpuq9Hz9sT4/gY7sTUq2NhGZfLa+tAPNE4YWS9iRgV556 HrjepNs9M1M0KGuntjFXTMG89IB3C1Qv5NhAagT1gKYL8+qRvliTFPPwwWHJv26ZbF28 030F3oxB72k9AYqZGD3Uu8+oUIyIT17SwNin6kg3vl6gCPWKRBK+iUclI1isWBeI7+Mm cJD3lhfhmrbR5S6mAZdLwMKgJwx7ezcgH9mv9RnRzSY9lvygfI+41ztKPi6Ror+3dGrr nhDVc2DG86g7TMJjYuqWjwS5h95de8gYUG2sxu/HsFQHZrQAkyBriBSCmOzJlDiWaXS7 iSvQ== X-Gm-Message-State: AOAM533DaKzyuaL9tyBJ+nWQFfGUXLKxDT13cy0ZMwqZ3SrhcppP31AU gAsNnNRUyxfQ/7F5MRKkkik5XE2/Bl7tF0od X-Google-Smtp-Source: ABdhPJw5Ni08pwShHanj9IT5Yn5mjBegsZi5inslW8DtFVC0iBkiQhglSWrJEcEEcbje89EQVRuy/A== X-Received: by 2002:a17:902:70c8:b0:156:509b:68e3 with SMTP id l8-20020a17090270c800b00156509b68e3mr11594454plt.113.1650301114799; Mon, 18 Apr 2022 09:58:34 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:94f4:f90:c59f:129b]) by smtp.gmail.com with ESMTPSA id l8-20020a17090a150800b001cbaf536a3esm17700980pja.18.2022.04.18.09.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 09:58:34 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/4] drm/dp: Add wait_hpd_asserted() callback to struct drm_dp_aux Date: Mon, 18 Apr 2022 09:56:39 -0700 Message-Id: <20220418095557.v2.1.Icf57bb12233a47727013c6ab69eebf803e22ebc1@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220418165642.2218514-1-dianders@chromium.org> References: <20220418165642.2218514-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Douglas Anderson , Sankeerth Billakanti , Philip Chen , Kees Cook , David Airlie , linux-kernel@vger.kernel.org, Abhinav Kumar , Robert Foss , Stephen Boyd , Jani Nikula , Maxime Ripard , Hsin-Yi Wang , Dmitry Baryshkov Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Sometimes it's useful for users of the DP AUX bus (like panels) to be able to poll HPD. Let's add a callback that allows DP AUX busses drivers to provide this. Suggested-by: Dmitry Baryshkov Signed-off-by: Douglas Anderson --- Left Dmitry's Reviewed-by tag off since patch changed enough. Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted() include/drm/dp/drm_dp_helper.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/drm/dp/drm_dp_helper.h b/include/drm/dp/drm_dp_helper.h index 53d1e722f4de..0940c415db8c 100644 --- a/include/drm/dp/drm_dp_helper.h +++ b/include/drm/dp/drm_dp_helper.h @@ -2035,6 +2035,32 @@ struct drm_dp_aux { ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg); + /** + * @wait_hpd_asserted: wait for HPD to be asserted + * + * This is mainly useful for eDP panels drivers to wait for an eDP + * panel to finish powering on. This is an optional function. + * + * This function will efficiently wait for up to `wait_us` microseconds + * for HPD to be asserted and might sleep. + * + * This function returns 0 if HPD was asserted or -ETIMEDOUT if time + * expired and HPD wasn't asserted. This function should not print + * timeout errors to the log. + * + * The semantics of this function are designed to match the + * readx_poll_timeout() function. That means a `wait_us` of 0 means + * to wait forever. If you want to do a quick poll you could pass 1 + * for `wait_us`. + * + * NOTE: this function specifically reports the state of the HPD pin + * that's associated with the DP AUX channel. This is different from + * the HPD concept in much of the rest of DRM which is more about + * physical presence of a display. For eDP, for instance, a display is + * assumed always present even if the HPD pin is deasserted. + */ + int (*wait_hpd_asserted)(struct drm_dp_aux *aux, unsigned long wait_us); + /** * @i2c_nack_count: Counts I2C NACKs, used for DP validation. */ From patchwork Mon Apr 18 16:56:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 12816956 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BF5DC433EF for ; Mon, 18 Apr 2022 16:58:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE72D10E2A8; Mon, 18 Apr 2022 16:58:38 +0000 (UTC) Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by gabe.freedesktop.org (Postfix) with ESMTPS id 096C210E17B for ; Mon, 18 Apr 2022 16:58:37 +0000 (UTC) Received: by mail-pj1-x1034.google.com with SMTP id 2so13468903pjw.2 for ; Mon, 18 Apr 2022 09:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CC9jkjjrl6o9e+m2QrQyEFgI0n/S9yVQ8H3riU8oA9o=; b=Iau0mJqjglK3h0t7SvYSqp8QbKm1ztccvyDYYCkGRp1Gg2143E8UHix/S4JXpHIWoG aq5ZJOv2CUXljCg0Mkrv4S83zRDopc5d90yk1EeUX/wPSZcF54Sm3l1RQCKgEgT/F736 gxq+Why9Hajy2zn0MMbZMdqabTgKFyIcCKsXI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CC9jkjjrl6o9e+m2QrQyEFgI0n/S9yVQ8H3riU8oA9o=; b=XDEto8l9yM2FsCnDJYp3s/VO2NLfc4+1caX+JUXI0kvdSbLxC2QP/Ohqy7kXSRyuTY 7aToQ9pR8xGsiLF+dR1rYb6LSj+IgquNK3RIjtWB7GGuasrJ5FGIM+QML87dF9kzzoaU 7eTgDzxErKOOeWIc4getVlxPdIWlkiGmRv4jDLkvQ3yxUk3TPPmeBF0BNcu3KYQLXKnj nQkCAZCYcQM7ZZYeHRilJyZDowLhngwOiJEKi7PMhoglzk4qd/pPZd6heer00pl520Fb PSzqRhBhN4fEfFPkSBNTL3i6v+cyGVX17vsn0erEes0f1xnIXnt/KEk0cGjDA0wM1vvW L6Kw== X-Gm-Message-State: AOAM532eDvHaKIVonkzugUd+TR/bdvichWdPunvK+v/qF+0Rd6wScu43 xaAoT3yNLgyi9ZeURDskNfevkHWXQD4Elljs X-Google-Smtp-Source: ABdhPJxMrpFLO1E/CkQC+viUKJbZKgLwOm1B4sMWpkvC80G70lohY/cBOdd8j8PgCo/0uJ7i+KBbvQ== X-Received: by 2002:a17:90b:4d0a:b0:1d1:7bd:cb00 with SMTP id mw10-20020a17090b4d0a00b001d107bdcb00mr17354367pjb.242.1650301116542; Mon, 18 Apr 2022 09:58:36 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:94f4:f90:c59f:129b]) by smtp.gmail.com with ESMTPSA id l8-20020a17090a150800b001cbaf536a3esm17700980pja.18.2022.04.18.09.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 09:58:35 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/4] drm/panel-edp: Take advantage of wait_hpd_asserted() in struct drm_dp_aux Date: Mon, 18 Apr 2022 09:56:40 -0700 Message-Id: <20220418095557.v2.2.Icea616f57331fbaa3d48c529f300c9a8ebd37fb5@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220418165642.2218514-1-dianders@chromium.org> References: <20220418165642.2218514-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Douglas Anderson , Sankeerth Billakanti , Philip Chen , David Airlie , linux-kernel@vger.kernel.org, Abhinav Kumar , Robert Foss , Stephen Boyd , Thierry Reding , Hsin-Yi Wang , Dmitry Baryshkov , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Let's add support for being able to read the HPD pin even if it's hooked directly to the controller. This will allow us to get more accurate delays also lets us take away the waiting in the AUX transfer functions of the eDP controller drivers. Signed-off-by: Douglas Anderson --- Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted() drivers/gpu/drm/panel/panel-edp.c | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index 1732b4f56e38..086e0bf52fb9 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -417,6 +417,11 @@ static int panel_edp_get_hpd_gpio(struct device *dev, struct panel_edp *p) return 0; } +static bool panel_edp_can_read_hpd(struct panel_edp *p) +{ + return !p->no_hpd && (p->hpd_gpio || (p->aux && p->aux->wait_hpd_asserted)); +} + static int panel_edp_prepare_once(struct panel_edp *p) { struct device *dev = p->base.dev; @@ -441,17 +446,21 @@ static int panel_edp_prepare_once(struct panel_edp *p) if (delay) msleep(delay); - if (p->hpd_gpio) { + if (panel_edp_can_read_hpd(p)) { if (p->desc->delay.hpd_absent) hpd_wait_us = p->desc->delay.hpd_absent * 1000UL; else hpd_wait_us = 2000000; - err = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, - hpd_asserted, hpd_asserted, - 1000, hpd_wait_us); - if (hpd_asserted < 0) - err = hpd_asserted; + if (p->hpd_gpio) { + err = readx_poll_timeout(gpiod_get_value_cansleep, + p->hpd_gpio, hpd_asserted, + hpd_asserted, 1000, hpd_wait_us); + if (hpd_asserted < 0) + err = hpd_asserted; + } else { + err = p->aux->wait_hpd_asserted(p->aux, hpd_wait_us); + } if (err) { if (err != -ETIMEDOUT) @@ -532,18 +541,22 @@ static int panel_edp_enable(struct drm_panel *panel) /* * If there is a "prepare_to_enable" delay then that's supposed to be * the delay from HPD going high until we can turn the backlight on. - * However, we can only count this if HPD is handled by the panel - * driver, not if it goes to a dedicated pin on the controller. + * However, we can only count this if HPD is readable by the panel + * driver. + * * If we aren't handling the HPD pin ourselves then the best we * can do is assume that HPD went high immediately before we were - * called (and link training took zero time). + * called (and link training took zero time). Note that "no-hpd" + * actually counts as handling HPD ourselves since we're doing the + * worst case delay (in prepare) ourselves. * * NOTE: if we ever end up in this "if" statement then we're * guaranteed that the panel_edp_wait() call below will do no delay. * It already handles that case, though, so we don't need any special * code for it. */ - if (p->desc->delay.prepare_to_enable && !p->hpd_gpio && !p->no_hpd) + if (p->desc->delay.prepare_to_enable && + !panel_edp_can_read_hpd(p) && !p->no_hpd) delay = max(delay, p->desc->delay.prepare_to_enable); if (delay) From patchwork Mon Apr 18 16:56:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 12816957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18200C433EF for ; Mon, 18 Apr 2022 16:58:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 28AAA10E272; Mon, 18 Apr 2022 16:58:45 +0000 (UTC) Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9C18E10E295 for ; Mon, 18 Apr 2022 16:58:38 +0000 (UTC) Received: by mail-pj1-x1032.google.com with SMTP id n33-20020a17090a5aa400b001d28f5ee3f9so3076241pji.4 for ; Mon, 18 Apr 2022 09:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J1QFnxHD7U+Ao84z0nfTT0ExEc1/lOyohaOkN2UcR24=; b=CZbSmX/i5jES+5RWi+JOQsTJ2Htdbaoh7NlFmpocxP9XJuCHQj17CZXDzULn6D0fJG BXEBtnF6OUJcmQdxRkGDdkfYv2lUHKb2IGR8K4BpW7neWgAsyfcPK2xKLcEtZinPGwSy PnuNQocQ/bQF5MGtIvlphUKzBsHaJYDutd6TA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J1QFnxHD7U+Ao84z0nfTT0ExEc1/lOyohaOkN2UcR24=; b=1wwzOf9/bg2S0qUSp93gQ/6KpxEVnof3WvLS3fqquqqtCFwOo4t6GYKf45HEoZsjjS bfvuzaGcwFmMqhDD5oIgdvdPCjSwSGxsWQ+o2Ww/wJ1o7m657b1CqIGxjF5eRWn/oS8D pIPkAg4ndrAnBVgWIEO/WXPRJNMa5A/aCicu7W56ou7p4UqvkT+jB87Ai/ZWo9pmVZX6 UrVkb0Jn5rQpAPiMLH4Z9Es17UDZSwK5cGQDfheCZguULQZJKHu4VbfknqZx5XUQsDpo mLzfl358wj9rCysOIWb0E9v+9gpCE1D4usEl1Lp6lOZ5vS0QCjuFQtSE8rPJ6KSuoQbT 1tag== X-Gm-Message-State: AOAM530CQmtum3/OZYCO4KIPYeVaRrt4cHCCP947GiFfw27eVmQIB/yl jzy+M/hOli51lM2q2aLKTX6TtCagSS18C1Y3 X-Google-Smtp-Source: ABdhPJwLdYhma2u6XQc+ES5orztwhXRFtVhZ1lMWtpfsGvAB78t7vY39NXx+5ntfYDoatZnLspf7yw== X-Received: by 2002:a17:90b:1891:b0:1d2:66e1:62b2 with SMTP id mn17-20020a17090b189100b001d266e162b2mr11793459pjb.56.1650301118033; Mon, 18 Apr 2022 09:58:38 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:94f4:f90:c59f:129b]) by smtp.gmail.com with ESMTPSA id l8-20020a17090a150800b001cbaf536a3esm17700980pja.18.2022.04.18.09.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 09:58:37 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 3/4] drm/panel: atna33xc20: Take advantage of wait_hpd_asserted() in struct drm_dp_aux Date: Mon, 18 Apr 2022 09:56:41 -0700 Message-Id: <20220418095557.v2.3.I9ee239f6b95b944c8fa030f300ad222a7af9899d@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220418165642.2218514-1-dianders@chromium.org> References: <20220418165642.2218514-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Douglas Anderson , Sankeerth Billakanti , Philip Chen , David Airlie , linux-kernel@vger.kernel.org, Abhinav Kumar , Robert Foss , Stephen Boyd , Thierry Reding , Hsin-Yi Wang , Dmitry Baryshkov , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Let's add support for being able to read the HPD pin even if it's hooked directly to the controller. This will let us take away the waiting in the AUX transfer functions of the eDP controller drivers. Signed-off-by: Douglas Anderson --- Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted() .../gpu/drm/panel/panel-samsung-atna33xc20.c | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c b/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c index 20666b6217e7..7f9af3e9aeb8 100644 --- a/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c +++ b/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c @@ -19,6 +19,10 @@ #include #include +/* T3 VCC to HPD high is max 200 ms */ +#define HPD_MAX_MS 200 +#define HPD_MAX_US (HPD_MAX_MS * 1000) + struct atana33xc20_panel { struct drm_panel base; bool prepared; @@ -30,6 +34,7 @@ struct atana33xc20_panel { struct regulator *supply; struct gpio_desc *el_on3_gpio; + struct drm_dp_aux *aux; struct edid *edid; @@ -90,20 +95,25 @@ static int atana33xc20_resume(struct device *dev) return ret; p->powered_on_time = ktime_get(); - /* - * Handle HPD. Note: if HPD is hooked up to a dedicated pin on the - * eDP controller then "no_hpd" will be false _and_ "hpd_gpio" will be - * NULL. It's up to the controller driver to wait for HPD after - * preparing the panel in that case. - */ if (p->no_hpd) { - /* T3 VCC to HPD high is max 200 ms */ - msleep(200); - } else if (p->hpd_gpio) { - ret = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, - hpd_asserted, hpd_asserted, - 1000, 200000); - if (!hpd_asserted) + msleep(HPD_MAX_MS); + } else { + if (p->hpd_gpio) + ret = readx_poll_timeout(gpiod_get_value_cansleep, + p->hpd_gpio, hpd_asserted, + hpd_asserted, 1000, HPD_MAX_US); + else if (p->aux->wait_hpd_asserted) + ret = p->aux->wait_hpd_asserted(p->aux, HPD_MAX_US); + + /* + * Note that it's possible that no_hpd is false, hpd_gpio is + * NULL, and wait_hpd_asserted is NULL. This is because + * wait_hpd_asserted() is optional even if HPD is hooked up to + * a dedicated pin on the eDP controller. In this case we just + * assume that the controller driver will wait for HPD at the + * right times. + */ + if (!hpd_asserted && (p->hpd_gpio || p->aux->wait_hpd_asserted)) dev_warn(dev, "Timeout waiting for HPD\n"); } @@ -263,6 +273,8 @@ static int atana33xc20_probe(struct dp_aux_ep_device *aux_ep) return -ENOMEM; dev_set_drvdata(dev, panel); + panel->aux = aux_ep->aux; + panel->supply = devm_regulator_get(dev, "power"); if (IS_ERR(panel->supply)) return dev_err_probe(dev, PTR_ERR(panel->supply), From patchwork Mon Apr 18 16:56:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 12816958 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33E55C433F5 for ; Mon, 18 Apr 2022 16:58:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 57BF610E295; Mon, 18 Apr 2022 16:58:48 +0000 (UTC) Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by gabe.freedesktop.org (Postfix) with ESMTPS id 74F7510E272 for ; Mon, 18 Apr 2022 16:58:40 +0000 (UTC) Received: by mail-pl1-x632.google.com with SMTP id v12so12816843plv.4 for ; Mon, 18 Apr 2022 09:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dgl5eKn4iSzXB9l06M4fwVd6TIsHNtzaSHHFv1Wa9zw=; b=BZQFA9pcqNGWWm/TFoYFFVZdh6KTVdcVLfXm/LYOkpxORHlZJkWyJzamzdep7WPyws ZJPpjlwYhKtM38pYvGQB8OV5r2gkjnNdFrinAOXarjmIh5CKSeQ/Vs4R8ZuF+eIU37zE vXeyRDrb56V0yWMcCRSp96qh6Aytunonn02UM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dgl5eKn4iSzXB9l06M4fwVd6TIsHNtzaSHHFv1Wa9zw=; b=21/tfdEzCSCksUEYmgDrGmfpxN+B4AnWxjSqe2D1BrwQwhYgOUz9EUgj91dB+uA/QV q/i1DOkuK35GVcQX5kfmr4jNhkGug5XocXF/3L0FHj2dSa9F+hMM1e1mChiKnipDe/+h S28436Jb7LbVtGJnoTeFwPH1RXhlUTReNk7TOuTFigfFVtUiPmW9fy1ECIvWjVXDrcR8 U2uhJqJ44yecZ1REj1/Xn6fT8Kw+QOLxGSIf93CW+UsaiM1eaXzEe64dMaFyup2ASfwf HwUqjFC9kyQD81kgUuoy7OoY03qrZD/hDlTdKSyjL8dX1ZYDunbem/U/PNO6/yGQArmZ mYrw== X-Gm-Message-State: AOAM532DL2nAcRiXHT9oJI50M6fYvXw8xFnwN1de0WwrXsr3MlLH1ku7 jAF01qnbkdebPlCcG3bUhhAennqzAvO0Dqlw X-Google-Smtp-Source: ABdhPJxQVsYC/f7eoCzdIS38t+LLRJmAkBiI96AdewmBzcUliQs0YJQ/uNxYdYHYGIw1Keing25HWQ== X-Received: by 2002:a17:90a:c781:b0:1d0:c23e:5842 with SMTP id gn1-20020a17090ac78100b001d0c23e5842mr18487206pjb.182.1650301119843; Mon, 18 Apr 2022 09:58:39 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:94f4:f90:c59f:129b]) by smtp.gmail.com with ESMTPSA id l8-20020a17090a150800b001cbaf536a3esm17700980pja.18.2022.04.18.09.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 09:58:39 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 4/4] drm/bridge: parade-ps8640: Provide wait_hpd_asserted() in struct drm_dp_aux Date: Mon, 18 Apr 2022 09:56:42 -0700 Message-Id: <20220418095557.v2.4.Ie827321ce263be52fdb8c1276f6f8cc00d78029f@changeid> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220418165642.2218514-1-dianders@chromium.org> References: <20220418165642.2218514-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Douglas Anderson , Sankeerth Billakanti , Philip Chen , Jonas Karlman , David Airlie , linux-kernel@vger.kernel.org, Neil Armstrong , Abhinav Kumar , Robert Foss , Stephen Boyd , Jernej Skrabec , Andrzej Hajda , Hsin-Yi Wang , Dmitry Baryshkov , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This implements the callback added by the patch ("drm/dp: Add wait_hpd_asserted() callback to struct drm_dp_aux"). With this change and all the two "DP AUX Endpoint" drivers changed to use wait_hpd_asserted(), we no longer need to have an long delay in the AUX transfer function. It's up to the panel code to make sure that the panel is powered now. If someone tried to call the aux transfer function without making sure the panel is powered we'll just get a normal transfer failure. We'll still keep the wait for HPD in the pre_enable() function. Though it's probably not actually needed there, this driver is used in the old mode (pre-DP AUX Endpoints) and it may be important for those cases. If nothing else, it shouldn't cause any big problems. Signed-off-by: Douglas Anderson --- Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted() drivers/gpu/drm/bridge/parade-ps8640.c | 34 ++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c index 9766cbbd62ad..2f19a8c89880 100644 --- a/drivers/gpu/drm/bridge/parade-ps8640.c +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -168,23 +168,30 @@ static bool ps8640_of_panel_on_aux_bus(struct device *dev) return true; } -static int ps8640_ensure_hpd(struct ps8640 *ps_bridge) +static int _ps8640_wait_hpd_asserted(struct ps8640 *ps_bridge, unsigned long wait_us) { struct regmap *map = ps_bridge->regmap[PAGE2_TOP_CNTL]; - struct device *dev = &ps_bridge->page[PAGE2_TOP_CNTL]->dev; int status; - int ret; /* * Apparently something about the firmware in the chip signals that * HPD goes high by reporting GPIO9 as high (even though HPD isn't * actually connected to GPIO9). */ - ret = regmap_read_poll_timeout(map, PAGE2_GPIO_H, status, - status & PS_GPIO9, 20 * 1000, 200 * 1000); + return regmap_read_poll_timeout(map, PAGE2_GPIO_H, status, + status & PS_GPIO9, wait_us / 10, wait_us); +} - if (ret < 0) - dev_warn(dev, "HPD didn't go high: %d\n", ret); +static int ps8640_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned long wait_us) +{ + struct ps8640 *ps_bridge = aux_to_ps8640(aux); + struct device *dev = &ps_bridge->page[PAGE0_DP_CNTL]->dev; + int ret; + + pm_runtime_get_sync(dev); + ret = _ps8640_wait_hpd_asserted(ps_bridge, wait_us); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return ret; } @@ -323,9 +330,7 @@ static ssize_t ps8640_aux_transfer(struct drm_dp_aux *aux, int ret; pm_runtime_get_sync(dev); - ret = ps8640_ensure_hpd(ps_bridge); - if (!ret) - ret = ps8640_aux_transfer_msg(aux, msg); + ret = ps8640_aux_transfer_msg(aux, msg); pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); @@ -369,8 +374,8 @@ static int __maybe_unused ps8640_resume(struct device *dev) * Mystery 200 ms delay for the "MCU to be ready". It's unclear if * this is truly necessary since the MCU will already signal that * things are "good to go" by signaling HPD on "gpio 9". See - * ps8640_ensure_hpd(). For now we'll keep this mystery delay just in - * case. + * _ps8640_wait_hpd_asserted(). For now we'll keep this mystery delay + * just in case. */ msleep(200); @@ -406,7 +411,9 @@ static void ps8640_pre_enable(struct drm_bridge *bridge) int ret; pm_runtime_get_sync(dev); - ps8640_ensure_hpd(ps_bridge); + ret = _ps8640_wait_hpd_asserted(ps_bridge, 200 * 1000); + if (ret < 0) + dev_warn(dev, "HPD didn't go high: %d\n", ret); /* * The Manufacturer Command Set (MCS) is a device dependent interface @@ -652,6 +659,7 @@ static int ps8640_probe(struct i2c_client *client) ps_bridge->aux.name = "parade-ps8640-aux"; ps_bridge->aux.dev = dev; ps_bridge->aux.transfer = ps8640_aux_transfer; + ps_bridge->aux.wait_hpd_asserted = ps8640_wait_hpd_asserted; drm_dp_aux_init(&ps_bridge->aux); pm_runtime_enable(dev);