Commit 3b5765df authored by Douglas Anderson's avatar Douglas Anderson

drm/panel: atna33xc20: Take advantage of wait_hpd_asserted() in struct drm_dp_aux

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: default avatarDouglas Anderson <dianders@chromium.org>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220614145327.v4.3.I9ee239f6b95b944c8fa030f300ad222a7af9899d@changeid
parent 2327b13d
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
#include <drm/drm_edid.h> #include <drm/drm_edid.h>
#include <drm/drm_panel.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 atana33xc20_panel {
struct drm_panel base; struct drm_panel base;
bool prepared; bool prepared;
...@@ -30,6 +34,7 @@ struct atana33xc20_panel { ...@@ -30,6 +34,7 @@ struct atana33xc20_panel {
struct regulator *supply; struct regulator *supply;
struct gpio_desc *el_on3_gpio; struct gpio_desc *el_on3_gpio;
struct drm_dp_aux *aux;
struct edid *edid; struct edid *edid;
...@@ -79,7 +84,7 @@ static int atana33xc20_suspend(struct device *dev) ...@@ -79,7 +84,7 @@ static int atana33xc20_suspend(struct device *dev)
static int atana33xc20_resume(struct device *dev) static int atana33xc20_resume(struct device *dev)
{ {
struct atana33xc20_panel *p = dev_get_drvdata(dev); struct atana33xc20_panel *p = dev_get_drvdata(dev);
bool hpd_asserted = false; int hpd_asserted;
int ret; int ret;
/* T12 (Power off time) is min 500 ms */ /* T12 (Power off time) is min 500 ms */
...@@ -90,23 +95,41 @@ static int atana33xc20_resume(struct device *dev) ...@@ -90,23 +95,41 @@ static int atana33xc20_resume(struct device *dev)
return ret; return ret;
p->powered_on_time = ktime_get(); 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) { if (p->no_hpd) {
/* T3 VCC to HPD high is max 200 ms */ msleep(HPD_MAX_MS);
msleep(200); return 0;
} else if (p->hpd_gpio) { }
if (p->hpd_gpio) {
ret = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, ret = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio,
hpd_asserted, hpd_asserted, hpd_asserted, hpd_asserted,
1000, 200000); 1000, HPD_MAX_US);
if (!hpd_asserted) if (hpd_asserted < 0)
dev_warn(dev, "Timeout waiting for HPD\n"); ret = hpd_asserted;
if (ret)
dev_warn(dev, "Error waiting for HPD GPIO: %d\n", ret);
return ret;
} }
if (p->aux->wait_hpd_asserted) {
ret = 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; return 0;
} }
...@@ -263,6 +286,8 @@ static int atana33xc20_probe(struct dp_aux_ep_device *aux_ep) ...@@ -263,6 +286,8 @@ static int atana33xc20_probe(struct dp_aux_ep_device *aux_ep)
return -ENOMEM; return -ENOMEM;
dev_set_drvdata(dev, panel); dev_set_drvdata(dev, panel);
panel->aux = aux_ep->aux;
panel->supply = devm_regulator_get(dev, "power"); panel->supply = devm_regulator_get(dev, "power");
if (IS_ERR(panel->supply)) if (IS_ERR(panel->supply))
return dev_err_probe(dev, PTR_ERR(panel->supply), return dev_err_probe(dev, PTR_ERR(panel->supply),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment