From nobody Mon Apr 27 09:13:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FA90C433EF for ; Tue, 14 Jun 2022 21:54:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357359AbiFNVyp (ORCPT ); Tue, 14 Jun 2022 17:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238917AbiFNVyl (ORCPT ); Tue, 14 Jun 2022 17:54:41 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FDE5255B9 for ; Tue, 14 Jun 2022 14:54:40 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d13so8819032plh.13 for ; Tue, 14 Jun 2022 14:54: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=65Y41kdawwG1n+2uI4rvZLnKQNlAIFaOOfNmllqQLv8=; b=EdN0uGZ3OZRMm5vATmxr2x7Q5Cqn1/DD3mCxrzY/7OzjM2t7U4pHdEYKoigjkl//R6 6KHpMtFP09kwukqqwTCO+MB0yRbh6qqhSZDR3PUAKoMnDXxjd/G04PPSJ9tJa6HHQOHE Fps7YmaMWDzhf+p0hG/bCMP/LfAC/qOt3cNeo= 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=65Y41kdawwG1n+2uI4rvZLnKQNlAIFaOOfNmllqQLv8=; b=gB7XPL0US5+MXJxcAsN9c+nHzAk0a5MLoErsUUD3XIy4Lnsvh5bXlJZph3x0bSJcl8 yOdJOt0U3Pgy2jJyHP3Dp9OcikvUwLXLuMAweX0S3mVIWnjrd3k8ZpkK39T2WH7bYTvT bhAFCjvtWAPZXLmiiLXHmx/0Yfh/cNZ1hOmuFkkNUBy/CAyN5u9AW7dp5H6/5S4n5R8b 4hh9yO9T3DRJmkULvNMjNKs+nBcUb5NzbTimNW/ViAChrYJs/VgHX1qM8yN3zTKbyNKU ZyyIoEDjBnZOn5P16Fm2qcfK+ahRYP+a0BZx4EBMi2wg2fapBkHAsYoxQ8JNq5F0uaVy tAwg== X-Gm-Message-State: AJIora+Tk3T6sYXXp5Nis6yNOteXQ6H8jAwU2+ggz90qh7clcdCp73BQ eqUEakRXDaKQE3sGpDgRIUN/sA== X-Google-Smtp-Source: AGRyM1uthElZF57fyUFL/+OiAZrcfH8RH/6cIit8YmMun/0EwOG0PbFroYO/GhXjJ2LU/4JIZrnS/w== X-Received: by 2002:a17:902:ec84:b0:167:6f74:ba76 with SMTP id x4-20020a170902ec8400b001676f74ba76mr6121089plg.17.1655243680141; Tue, 14 Jun 2022 14:54:40 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f355:be2d:74b7:3c7c]) by smtp.gmail.com with ESMTPSA id y2-20020a17090264c200b0016641a646cbsm7668968pli.218.2022.06.14.14.54.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 14:54:39 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org Cc: Dmitry Baryshkov , Stephen Boyd , Robert Foss , Philip Chen , Sankeerth Billakanti , Hsin-Yi Wang , Abhinav Kumar , Douglas Anderson , Daniel Vetter , David Airlie , Imre Deak , Jani Nikula , Lyude Paul , Maxime Ripard , Thomas Zimmermann , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , linux-kernel@vger.kernel.org Subject: [PATCH v4 1/4] drm/dp: Add wait_hpd_asserted() callback to struct drm_dp_aux Date: Tue, 14 Jun 2022 14:54:15 -0700 Message-Id: <20220614145327.v4.1.Icf57bb12233a47727013c6ab69eebf803e22ebc1@changeid> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220614215418.910948-1-dianders@chromium.org> References: <20220614215418.910948-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Dmitry Baryshkov --- Changes in v4: - Comments now explain that we may wait longer due to debouncing. - Rebased to handle the fact that the stuct moved files. Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted() include/drm/display/drm_dp_helper.h | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_= dp_helper.h index c5f8f45511ed..db0fe9f8a612 100644 --- a/include/drm/display/drm_dp_helper.h +++ b/include/drm/display/drm_dp_helper.h @@ -389,6 +389,36 @@ struct drm_dp_aux { ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg); =20 + /** + * @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 the HPD signal to be + * asserted. The `wait_us` parameter that is passed in says that we + * know that the HPD signal is expected to be asserted within `wait_us` + * microseconds. This function could wait for longer than `wait_us` if + * the logic in the DP controller has a long debouncing time. The + * important thing is that if this function returns success that the + * DP controller is ready to send AUX transactions. + * + * 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. Like readx_poll_timeout(), this function may sleep. + * + * 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. */ --=20 2.36.1.476.g0c4daa206d-goog From nobody Mon Apr 27 09:13:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61335C43334 for ; Tue, 14 Jun 2022 21:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357947AbiFNVyr (ORCPT ); Tue, 14 Jun 2022 17:54:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352995AbiFNVym (ORCPT ); Tue, 14 Jun 2022 17:54:42 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDEB42251F for ; Tue, 14 Jun 2022 14:54:41 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id 3-20020a17090a174300b001e426a02ac5so297187pjm.2 for ; Tue, 14 Jun 2022 14:54:41 -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=AwX0A/0Dxcjuy9zRSFxAY+0IKc5Dbas55VbNobVwPJc=; b=CSv9NkEHHzkwLhmuXSgOOHqRPc31dwtBa3/7oUsRLH0ubS19jeVHMW6b5KZcE6XzBA FeCH7ES5/xJCaRRVyr9usmVB1jKYuKfsYiZLWsWFLGRNR/Mot8qZEIm4Z6uvbIqvfk6+ 15XBa1ozkpPIxqYJJUSfgJX449FeHmFTesIS4= 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=AwX0A/0Dxcjuy9zRSFxAY+0IKc5Dbas55VbNobVwPJc=; b=1HnBvfSp674pcZOBVPtK2UJDpKXbnpFTOxdAoNlpyijEkAyQkuKESBt5XjR9VJsHmm ziTTKzlZfy/mGTy+BzNxO4Yq/58UYPHfgkP/pzxxEqQDlUUgH2jkSRzFbmau1qkNCNom DawPHntIIc6aWKUAtNPWeDb6yFe0MpDlJQgvhUAN7KaVPuYdpq77/3ueBkwfHvz2CrD2 kVqgJFRIUFcOyUw4R75GOvqJxvQV2JJQyv8DC10bvZU8f/38GPSEFE5KdrzPPUXRg826 oeN4ZOBWu9KfDlyQFP6Uvxh5nUIHn1/Ap9hoeua2p9n86HeLuqqhyTUAFf5rHHZHUbQC 8oXQ== X-Gm-Message-State: AJIora9HoQzJXFm7d50YToezeM5YxpHSDQ3uTAUqAMdeaXOoMBFDS1wo WkQh24baLDMxCDDvk7/iwzP/sA== X-Google-Smtp-Source: AGRyM1tHNbZg3tUer/X0adYqmmmBkipXJYdJHb+DnbzGyZ3+LncrF6Fbyslgnj8PvfBaB3VMuzImyQ== X-Received: by 2002:a17:90a:4503:b0:1ea:4718:829f with SMTP id u3-20020a17090a450300b001ea4718829fmr6431527pjg.103.1655243681464; Tue, 14 Jun 2022 14:54:41 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f355:be2d:74b7:3c7c]) by smtp.gmail.com with ESMTPSA id y2-20020a17090264c200b0016641a646cbsm7668968pli.218.2022.06.14.14.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 14:54:41 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org Cc: Dmitry Baryshkov , Stephen Boyd , Robert Foss , Philip Chen , Sankeerth Billakanti , Hsin-Yi Wang , Abhinav Kumar , Douglas Anderson , Daniel Vetter , David Airlie , Sam Ravnborg , Thierry Reding , linux-kernel@vger.kernel.org Subject: [PATCH v4 2/4] drm/panel-edp: Take advantage of wait_hpd_asserted() in struct drm_dp_aux Date: Tue, 14 Jun 2022 14:54:16 -0700 Message-Id: <20220614145327.v4.2.Icea616f57331fbaa3d48c529f300c9a8ebd37fb5@changeid> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220614215418.910948-1-dianders@chromium.org> References: <20220614215418.910948-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Dmitry Baryshkov --- (no changes since v2) 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/pane= l-edp.c index c96014464355..ce5821132151 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; } =20 +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 =3D p->base.dev; @@ -441,17 +446,21 @@ static int panel_edp_prepare_once(struct panel_edp *p) if (delay) msleep(delay); =20 - if (p->hpd_gpio) { + if (panel_edp_can_read_hpd(p)) { if (p->desc->delay.hpd_absent) hpd_wait_us =3D p->desc->delay.hpd_absent * 1000UL; else hpd_wait_us =3D 2000000; =20 - err =3D readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, - hpd_asserted, hpd_asserted, - 1000, hpd_wait_us); - if (hpd_asserted < 0) - err =3D hpd_asserted; + if (p->hpd_gpio) { + err =3D readx_poll_timeout(gpiod_get_value_cansleep, + p->hpd_gpio, hpd_asserted, + hpd_asserted, 1000, hpd_wait_us); + if (hpd_asserted < 0) + err =3D hpd_asserted; + } else { + err =3D p->aux->wait_hpd_asserted(p->aux, hpd_wait_us); + } =20 if (err) { if (err !=3D -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 =3D max(delay, p->desc->delay.prepare_to_enable); =20 if (delay) --=20 2.36.1.476.g0c4daa206d-goog From nobody Mon Apr 27 09:13:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5E2FC43334 for ; Tue, 14 Jun 2022 21:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358287AbiFNVyt (ORCPT ); Tue, 14 Jun 2022 17:54:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357414AbiFNVyp (ORCPT ); Tue, 14 Jun 2022 17:54:45 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EDE9286CD for ; Tue, 14 Jun 2022 14:54:44 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id o33-20020a17090a0a2400b001ea806e48c6so272409pjo.1 for ; Tue, 14 Jun 2022 14:54:44 -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=AD7rNua84LlpGzzclSVfd7h/uJzjd+oRcysHkAmzKsw=; b=E6g2uu+oxpS1JAhdNGcoZ/m+u2SH9aq8/IJUrbP/T9uoW5ClLt7+i4LSDHU80R6p6H AIHW/ZujOsDDOTjxLhZC61o0e/vuRjrUHZwNqYODIq001c+p9T/wevgNpf1xPbktTV2b edydObcQVymMztpOJfyT2bpJ+FiwIyO0uF9P0= 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=AD7rNua84LlpGzzclSVfd7h/uJzjd+oRcysHkAmzKsw=; b=JOjvGj/cwt69t50NLkyCfqWc2oa4OtysbqC6eFPAL45TW1T0UJZQKJCmIJX59SYHDO 0HtMmRAGLf6cfHnb/0LYbKSdSnXP2gXG/sFo4XPIvmEXau0OBpZGB789V0cTVO1gukmg VgLHhVWC3i8wHJtlHtylkC/DY4FTf7a0ZVV+v4TaRcC1TdV31GKUMPKyBxG8G7qNXYGz UqA/dwEfyY+YLnbX6vDy3UJ72fvZChU1mgU9M+JGW7zClcce5HWqqV8hywDhDYkgpd/f F+bgwfPrYyJRw9e0ADYMCB+OEqMK7QCOLt5NRr957rvI8pYrVQ2XD3MVOUjrfnApZM0Y s1/A== X-Gm-Message-State: AJIora/GTR+h9fh/DdFMUEx0B3G6K7RMohOaviCDP+58IQAKSUAzQARS xFfNqCFEELdOzBQaioe56CwruQ== X-Google-Smtp-Source: AGRyM1tx5s5qzREkLsZOH+1kx714eDFK00lma0iUr3Sr8mskoDfH3W518hO6TI+ELqROUZUIu2iwjQ== X-Received: by 2002:a17:902:d2c9:b0:167:1195:3a41 with SMTP id n9-20020a170902d2c900b0016711953a41mr6502284plc.126.1655243683801; Tue, 14 Jun 2022 14:54:43 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f355:be2d:74b7:3c7c]) by smtp.gmail.com with ESMTPSA id y2-20020a17090264c200b0016641a646cbsm7668968pli.218.2022.06.14.14.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 14:54:43 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org Cc: Dmitry Baryshkov , Stephen Boyd , Robert Foss , Philip Chen , Sankeerth Billakanti , Hsin-Yi Wang , Abhinav Kumar , Douglas Anderson , Daniel Vetter , David Airlie , Sam Ravnborg , Thierry Reding , linux-kernel@vger.kernel.org Subject: [PATCH v4 3/4] drm/panel: atna33xc20: Take advantage of wait_hpd_asserted() in struct drm_dp_aux Date: Tue, 14 Jun 2022 14:54:17 -0700 Message-Id: <20220614145327.v4.3.I9ee239f6b95b944c8fa030f300ad222a7af9899d@changeid> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220614215418.910948-1-dianders@chromium.org> References: <20220614215418.910948-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Dmitry Baryshkov --- Changes in v4: - Reorganized logic as per Dmitry's suggestion. Changes in v3: - Don't check "hpd_asserted" boolean when unset. - Handle errors from gpiod_get_value_cansleep() properly. Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted() .../gpu/drm/panel/panel-samsung-atna33xc20.c | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c b/drivers/gpu= /drm/panel/panel-samsung-atna33xc20.c index 3dd10412d147..5a8b978c6415 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 =20 +/* 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 { =20 struct regulator *supply; struct gpio_desc *el_on3_gpio; + struct drm_dp_aux *aux; =20 struct edid *edid; =20 @@ -79,7 +84,7 @@ static int atana33xc20_suspend(struct device *dev) static int atana33xc20_resume(struct device *dev) { struct atana33xc20_panel *p =3D dev_get_drvdata(dev); - bool hpd_asserted =3D false; + int hpd_asserted; int ret; =20 /* T12 (Power off time) is min 500 ms */ @@ -90,23 +95,41 @@ static int atana33xc20_resume(struct device *dev) return ret; p->powered_on_time =3D ktime_get(); =20 - /* - * 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) { + msleep(HPD_MAX_MS); + return 0; + } + + if (p->hpd_gpio) { ret =3D readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, hpd_asserted, hpd_asserted, - 1000, 200000); - if (!hpd_asserted) - dev_warn(dev, "Timeout waiting for HPD\n"); + 1000, HPD_MAX_US); + if (hpd_asserted < 0) + ret =3D hpd_asserted; + + if (ret) + dev_warn(dev, "Error waiting for HPD GPIO: %d\n", ret); + + return ret; } =20 + if (p->aux->wait_hpd_asserted) { + ret =3D p->aux->wait_hpd_asserted(p->aux, HPD_MAX_US); + + if (ret) + dev_warn(dev, "Controller error waiting for HPD: %d\n", ret); + + return ret; + } + + /* + * 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. + */ return 0; } =20 @@ -263,6 +286,8 @@ static int atana33xc20_probe(struct dp_aux_ep_device *a= ux_ep) return -ENOMEM; dev_set_drvdata(dev, panel); =20 + panel->aux =3D aux_ep->aux; + panel->supply =3D devm_regulator_get(dev, "power"); if (IS_ERR(panel->supply)) return dev_err_probe(dev, PTR_ERR(panel->supply), --=20 2.36.1.476.g0c4daa206d-goog From nobody Mon Apr 27 09:13:37 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 288E7C43334 for ; Tue, 14 Jun 2022 21:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237756AbiFNVyx (ORCPT ); Tue, 14 Jun 2022 17:54:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357858AbiFNVyr (ORCPT ); Tue, 14 Jun 2022 17:54:47 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E48EF2B19F for ; Tue, 14 Jun 2022 14:54:45 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id x138so9707789pfc.12 for ; Tue, 14 Jun 2022 14:54:45 -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=/m4CI4QQSCApkc/AOcjH4+peoaHbWtmSNURLAr70/iQ=; b=TOa5A/MPY0GzRyi8zVHJ708N42r0XfCt1ehWJaLsmgLM8s8zQBpWq9MEFEOPX5zDlK axqfAEaJA8UdjLyWX7q2dPlYPbqpCSI5kOGLVp5Jm4N2fowSwRoD2tPrG3A9IaccgeQM R8p1SKi1HbpfqULH3PrEBfWZG8rswJbQvzyAI= 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=/m4CI4QQSCApkc/AOcjH4+peoaHbWtmSNURLAr70/iQ=; b=pJqEze5gz5pbUQ4kOyGmAqaWOvPIsxDRYsvapVG7JEGyD2e/YuwW/2Ge18YpozNRem w55aqNdrAXm24b+lvWMZLGoRwjeB5nFMTvY+vFDkvqR9Rss56FvLJtLdXSFuE95DR4tM pz6GPPuJvgAjhzDNCN6aiY26rsXI7HEzF5Kxx7h/mQ9CU8Tns/w2A+99YXW/G6ryNlH7 Swi2Xbrrju34t/fIYwGLJ3lo9ABCJtH1QyjudMw/rZMmcaqfJhQ3oYEkc7mpQ+1v0CSw ZG9Tunvw+GywbIlP41bKDibCVwPkriJ/SqfVNsGbQR41crCsnLx03XWh2tngeQrxd2Zl pm1Q== X-Gm-Message-State: AOAM533xmDq7m/a1k5/vsA0gK2gvyzxN1nCmOoMIijM/ja++ADrgZChK FY0DEWRskr2AXZPRoswUUh10XQ== X-Google-Smtp-Source: ABdhPJwa1rc1AecnmEH9sWNMtW8IyHVRsgkxDHCAHJ8r0pyupbJHEokJH2CNZh7GCiuaSsAg7mSDsA== X-Received: by 2002:a63:2b16:0:b0:3fa:faf9:e6d7 with SMTP id r22-20020a632b16000000b003fafaf9e6d7mr6217810pgr.325.1655243685302; Tue, 14 Jun 2022 14:54:45 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f355:be2d:74b7:3c7c]) by smtp.gmail.com with ESMTPSA id y2-20020a17090264c200b0016641a646cbsm7668968pli.218.2022.06.14.14.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 14:54:45 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org Cc: Dmitry Baryshkov , Stephen Boyd , Robert Foss , Philip Chen , Sankeerth Billakanti , Hsin-Yi Wang , Abhinav Kumar , Douglas Anderson , Andrzej Hajda , Daniel Vetter , David Airlie , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Neil Armstrong , linux-kernel@vger.kernel.org Subject: [PATCH v4 4/4] drm/bridge: parade-ps8640: Provide wait_hpd_asserted() in struct drm_dp_aux Date: Tue, 14 Jun 2022 14:54:18 -0700 Message-Id: <20220614145327.v4.4.Ie827321ce263be52fdb8c1276f6f8cc00d78029f@changeid> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220614215418.910948-1-dianders@chromium.org> References: <20220614215418.910948-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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. NOTE: When handling the timeout for HPD we start the timer _after_ we've runtime resumed the device. This is definitely important for the panel on my homestar which comes up 170 ms after we start timing (the panel specifies 200 ms max). It's a little unclear how much of this extra time is due to some internal state machine in the parade firmware vs. debouncing but it seems to work for the two test cases I have to do it this way. Signed-off-by: Douglas Anderson Reviewed-by: Dmitry Baryshkov --- Changes in v4: - Add comment that caller powered up the panel. - Mention in commit message debouncing vs. powering on timing. Changes in v2: - Change is_hpd_asserted() to wait_hpd_asserted() drivers/gpu/drm/bridge/parade-ps8640.c | 39 +++++++++++++++++--------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridg= e/parade-ps8640.c index ff4227f6d800..e880eee55822 100644 --- a/drivers/gpu/drm/bridge/parade-ps8640.c +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -168,23 +168,35 @@ static bool ps8640_of_panel_on_aux_bus(struct device = *dev) return true; } =20 -static int ps8640_ensure_hpd(struct ps8640 *ps_bridge) +static int _ps8640_wait_hpd_asserted(struct ps8640 *ps_bridge, unsigned lo= ng wait_us) { struct regmap *map =3D ps_bridge->regmap[PAGE2_TOP_CNTL]; - struct device *dev =3D &ps_bridge->page[PAGE2_TOP_CNTL]->dev; int status; - int ret; =20 /* * 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 =3D 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); +} =20 - 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 =3D aux_to_ps8640(aux); + struct device *dev =3D &ps_bridge->page[PAGE0_DP_CNTL]->dev; + int ret; + + /* + * Note that this function is called by code that has already powered + * the panel. We have to power ourselves up but we don't need to worry + * about powering the panel. + */ + pm_runtime_get_sync(dev); + ret =3D _ps8640_wait_hpd_asserted(ps_bridge, wait_us); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); =20 return ret; } @@ -323,9 +335,7 @@ static ssize_t ps8640_aux_transfer(struct drm_dp_aux *a= ux, int ret; =20 pm_runtime_get_sync(dev); - ret =3D ps8640_ensure_hpd(ps_bridge); - if (!ret) - ret =3D ps8640_aux_transfer_msg(aux, msg); + ret =3D ps8640_aux_transfer_msg(aux, msg); pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); =20 @@ -369,8 +379,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); =20 @@ -406,7 +416,9 @@ static void ps8640_pre_enable(struct drm_bridge *bridge) int ret; =20 pm_runtime_get_sync(dev); - ps8640_ensure_hpd(ps_bridge); + ret =3D _ps8640_wait_hpd_asserted(ps_bridge, 200 * 1000); + if (ret < 0) + dev_warn(dev, "HPD didn't go high: %d\n", ret); =20 /* * The Manufacturer Command Set (MCS) is a device dependent interface @@ -682,6 +694,7 @@ static int ps8640_probe(struct i2c_client *client) ps_bridge->aux.name =3D "parade-ps8640-aux"; ps_bridge->aux.dev =3D dev; ps_bridge->aux.transfer =3D ps8640_aux_transfer; + ps_bridge->aux.wait_hpd_asserted =3D ps8640_wait_hpd_asserted; drm_dp_aux_init(&ps_bridge->aux); =20 pm_runtime_enable(dev); --=20 2.36.1.476.g0c4daa206d-goog