Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220614145327.v4.3.I9ee239f6b95b944c8fa030f300ad222a7af9899d@changeid

+40 -15
+40 -15
drivers/gpu/drm/panel/panel-samsung-atna33xc20.c
··· 19 19 #include <drm/drm_edid.h> 20 20 #include <drm/drm_panel.h> 21 21 22 + /* T3 VCC to HPD high is max 200 ms */ 23 + #define HPD_MAX_MS 200 24 + #define HPD_MAX_US (HPD_MAX_MS * 1000) 25 + 22 26 struct atana33xc20_panel { 23 27 struct drm_panel base; 24 28 bool prepared; ··· 34 30 35 31 struct regulator *supply; 36 32 struct gpio_desc *el_on3_gpio; 33 + struct drm_dp_aux *aux; 37 34 38 35 struct edid *edid; 39 36 ··· 84 79 static int atana33xc20_resume(struct device *dev) 85 80 { 86 81 struct atana33xc20_panel *p = dev_get_drvdata(dev); 87 - bool hpd_asserted = false; 82 + int hpd_asserted; 88 83 int ret; 89 84 90 85 /* T12 (Power off time) is min 500 ms */ ··· 95 90 return ret; 96 91 p->powered_on_time = ktime_get(); 97 92 98 - /* 99 - * Handle HPD. Note: if HPD is hooked up to a dedicated pin on the 100 - * eDP controller then "no_hpd" will be false _and_ "hpd_gpio" will be 101 - * NULL. It's up to the controller driver to wait for HPD after 102 - * preparing the panel in that case. 103 - */ 104 93 if (p->no_hpd) { 105 - /* T3 VCC to HPD high is max 200 ms */ 106 - msleep(200); 107 - } else if (p->hpd_gpio) { 108 - ret = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, 109 - hpd_asserted, hpd_asserted, 110 - 1000, 200000); 111 - if (!hpd_asserted) 112 - dev_warn(dev, "Timeout waiting for HPD\n"); 94 + msleep(HPD_MAX_MS); 95 + return 0; 113 96 } 114 97 98 + if (p->hpd_gpio) { 99 + ret = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, 100 + hpd_asserted, hpd_asserted, 101 + 1000, HPD_MAX_US); 102 + if (hpd_asserted < 0) 103 + ret = hpd_asserted; 104 + 105 + if (ret) 106 + dev_warn(dev, "Error waiting for HPD GPIO: %d\n", ret); 107 + 108 + return ret; 109 + } 110 + 111 + if (p->aux->wait_hpd_asserted) { 112 + ret = p->aux->wait_hpd_asserted(p->aux, HPD_MAX_US); 113 + 114 + if (ret) 115 + dev_warn(dev, "Controller error waiting for HPD: %d\n", ret); 116 + 117 + return ret; 118 + } 119 + 120 + /* 121 + * Note that it's possible that no_hpd is false, hpd_gpio is 122 + * NULL, and wait_hpd_asserted is NULL. This is because 123 + * wait_hpd_asserted() is optional even if HPD is hooked up to 124 + * a dedicated pin on the eDP controller. In this case we just 125 + * assume that the controller driver will wait for HPD at the 126 + * right times. 127 + */ 115 128 return 0; 116 129 } 117 130 ··· 285 262 if (!panel) 286 263 return -ENOMEM; 287 264 dev_set_drvdata(dev, panel); 265 + 266 + panel->aux = aux_ep->aux; 288 267 289 268 panel->supply = devm_regulator_get(dev, "power"); 290 269 if (IS_ERR(panel->supply))