From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Douglas Anderson <dianders@chromium.org>,
dri-devel@lists.freedesktop.org
Cc: Hsin-Yi Wang <hsinyi@chromium.org>,
Sankeerth Billakanti <quic_sbillaka@quicinc.com>,
Philip Chen <philipchen@chromium.org>,
Robert Foss <robert.foss@linaro.org>,
Stephen Boyd <swboyd@chromium.org>,
Abhinav Kumar <quic_abhinavk@quicinc.com>,
Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>,
Sam Ravnborg <sam@ravnborg.org>,
Thierry Reding <thierry.reding@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/4] drm/panel: atna33xc20: Take advantage of wait_hpd_asserted() in struct drm_dp_aux
Date: Thu, 2 Jun 2022 17:49:28 +0300 [thread overview]
Message-ID: <5f3cf3a6-1cc2-63e4-f76b-4ee686764705@linaro.org> (raw)
In-Reply-To: <20220418101725.v3.3.I9ee239f6b95b944c8fa030f300ad222a7af9899d@changeid>
On 18/04/2022 20:17, Douglas Anderson wrote:
> 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 <dianders@chromium.org>
> ---
>
> 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 | 41 +++++++++++++------
> 1 file changed, 28 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..5ef1b4032c56 100644
> --- a/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c
> +++ b/drivers/gpu/drm/panel/panel-samsung-atna33xc20.c
> @@ -19,6 +19,10 @@
> #include <drm/drm_edid.h>
> #include <drm/drm_panel.h>
>
> +/* 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;
>
> @@ -79,7 +84,7 @@ static int atana33xc20_suspend(struct device *dev)
> static int atana33xc20_resume(struct device *dev)
> {
> struct atana33xc20_panel *p = dev_get_drvdata(dev);
> - bool hpd_asserted = false;
> + int hpd_asserted;
> int ret;
>
> /* T12 (Power off time) is min 500 ms */
> @@ -91,20 +96,28 @@ static int atana33xc20_resume(struct device *dev)
> 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.
> + * 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 (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)
> - dev_warn(dev, "Timeout waiting for HPD\n");
> + 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);
> + if (hpd_asserted < 0)
> + ret = hpd_asserted;
> + } else if (p->aux->wait_hpd_asserted) {
> + ret = p->aux->wait_hpd_asserted(p->aux, HPD_MAX_US);
> + }
> +
> + if (ret)
> + dev_warn(dev, "Error waiting for HPD: %d\n", ret);
I'd suggest reworking this to:
if (p->no_hpd) {
msleep();
return 0;
}
if (p->hpd_gpio) {
ret = readx_poll_timeout(...)
if (ret)
dev_warn()
return ret;
}
if (p->aux->wait_hpd_asserted) {
ret = p->aux->wait....
if (ret)
dev_warn(...)
return ret;
}
return 0;
> }
>
> return 0;
> @@ -263,6 +276,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),
--
With best wishes
Dmitry
next prev parent reply other threads:[~2022-06-02 14:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-18 17:17 [PATCH v3 0/4] drm/dp: Introduce wait_hpd_asserted() for the DP AUX bus Douglas Anderson
2022-04-18 17:17 ` [PATCH v3 1/4] drm/dp: Add wait_hpd_asserted() callback to struct drm_dp_aux Douglas Anderson
2022-05-12 1:58 ` Stephen Boyd
2022-05-12 23:24 ` Doug Anderson
2022-05-20 0:34 ` Stephen Boyd
2022-05-20 15:45 ` Doug Anderson
2022-06-02 10:22 ` Dmitry Baryshkov
2022-04-18 17:17 ` [PATCH v3 2/4] drm/panel-edp: Take advantage of wait_hpd_asserted() in " Douglas Anderson
2022-06-02 15:12 ` Dmitry Baryshkov
2022-06-14 21:57 ` Doug Anderson
2022-04-18 17:17 ` [PATCH v3 3/4] drm/panel: atna33xc20: " Douglas Anderson
2022-06-02 14:49 ` Dmitry Baryshkov [this message]
2022-04-18 17:17 ` [PATCH v3 4/4] drm/bridge: parade-ps8640: Provide " Douglas Anderson
2022-06-02 14:56 ` Dmitry Baryshkov
2022-05-03 23:26 ` [PATCH v3 0/4] drm/dp: Introduce wait_hpd_asserted() for the DP AUX bus Doug Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5f3cf3a6-1cc2-63e4-f76b-4ee686764705@linaro.org \
--to=dmitry.baryshkov@linaro.org \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=hsinyi@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=philipchen@chromium.org \
--cc=quic_abhinavk@quicinc.com \
--cc=quic_sbillaka@quicinc.com \
--cc=robert.foss@linaro.org \
--cc=sam@ravnborg.org \
--cc=swboyd@chromium.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®