From: Linus Walleij <linus.walleij@linaro.org>
To: Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
Linus Walleij <linus.walleij@linaro.org>,
Brian Masney <masneyb@onstation.org>
Subject: [PATCH 5/6 v2] drm/msm/hdmi: Bring up HDMI connector OFF
Date: Fri, 23 Aug 2019 09:34:47 +0200 [thread overview]
Message-ID: <20190823073448.8385-5-linus.walleij@linaro.org> (raw)
In-Reply-To: <20190823073448.8385-1-linus.walleij@linaro.org>
There is elaborate code in the HDMI connector handling to
leave the connector in the state it was at power-on and
only touch the GPIOs when the connector .enable() and
.disable() callbacks are called.
I don't think this is what we normally want, initialize
the connector as OFF (possibly saving power?) using the
appropriate GPIO descriptor flags. It will still be
switched on/off in the enable()/disable() connector
callback as before, but we can drop some strange surplus
code.
Cc: Rob Clark <robdclark@gmail.com>
Cc: Sean Paul <sean@poorly.run>
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Reviewed-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Rebased on v5.3-rc1
- Collected review tag
---
drivers/gpu/drm/msm/hdmi/hdmi.c | 19 ++++++++++++-----
drivers/gpu/drm/msm/hdmi/hdmi_connector.c | 25 ++++++-----------------
2 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c
index 355afb936401..5739eec65659 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi.c
@@ -552,13 +552,22 @@ static int msm_hdmi_bind(struct device *dev, struct device *master, void *data)
for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
const char *name = msm_hdmi_gpio_pdata[i].name;
struct gpio_desc *gpiod;
+ enum gpiod_flags flags;
/*
- * We are fetching the GPIO lines "as is" since the connector
- * code is enabling and disabling the lines. Until that point
- * the power-on default value will be kept.
+ * Notice the inverse set up here: we initialize the connector
+ * to OFF state.
*/
- gpiod = devm_gpiod_get_optional(dev, name, GPIOD_ASIS);
+ if (msm_hdmi_gpio_pdata[i].output) {
+ if (msm_hdmi_gpio_pdata[i].value)
+ flags = GPIOD_OUT_LOW;
+ else
+ flags = GPIOD_OUT_HIGH;
+ } else {
+ flags = GPIOD_IN;
+ }
+
+ gpiod = devm_gpiod_get_optional(dev, name, flags);
/* This will catch e.g. -PROBE_DEFER */
if (IS_ERR(gpiod))
return PTR_ERR(gpiod);
@@ -572,7 +581,7 @@ static int msm_hdmi_bind(struct device *dev, struct device *master, void *data)
* in the upstream bindings.
*/
if (sscanf(name, "qcom,hdmi-tx-%s", name3))
- gpiod = devm_gpiod_get_optional(dev, name3, GPIOD_ASIS);
+ gpiod = devm_gpiod_get_optional(dev, name3, flags);
if (IS_ERR(gpiod))
return PTR_ERR(gpiod);
if (!gpiod)
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
index d0575d4f747d..f006682935e9 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
@@ -75,16 +75,9 @@ static int gpio_config(struct hdmi *hdmi, bool on)
for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
struct hdmi_gpio_data gpio = config->gpios[i];
- if (gpio.gpiod) {
- if (gpio.output) {
- gpiod_direction_output(gpio.gpiod,
- gpio.value);
- } else {
- gpiod_direction_input(gpio.gpiod);
- gpiod_set_value_cansleep(gpio.gpiod,
- gpio.value);
- }
- }
+ /* The value indicates the value for turning things on */
+ if (gpio.gpiod)
+ gpiod_set_value_cansleep(gpio.gpiod, gpio.value);
}
DBG("gpio on");
@@ -92,16 +85,10 @@ static int gpio_config(struct hdmi *hdmi, bool on)
for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
struct hdmi_gpio_data gpio = config->gpios[i];
- if (!gpio.gpiod)
- continue;
-
- if (gpio.output) {
- int value = gpio.value ? 0 : 1;
-
- gpiod_set_value_cansleep(gpio.gpiod, value);
- }
+ /* The inverse value turns stuff off */
+ if (gpio.gpiod && gpio.output)
+ gpiod_set_value_cansleep(gpio.gpiod, !gpio.value);
};
-
DBG("gpio off");
}
--
2.21.0
next prev parent reply other threads:[~2019-08-23 7:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-23 7:34 [PATCH 1/6 v2] drm/msm/mdp4: Drop unused GPIO include Linus Walleij
2019-08-23 7:34 ` [PATCH 2/6 v2] drm/msm/dsi: Drop unused GPIO includes Linus Walleij
2019-08-23 7:34 ` [PATCH 3/6 v2] drm/msm/dpu: Drop unused GPIO code Linus Walleij
2019-08-23 7:34 ` [PATCH 4/6 v2] drm/msm/hdmi: Convert to use GPIO descriptors Linus Walleij
2019-08-23 7:34 ` Linus Walleij [this message]
2019-09-01 16:28 ` [PATCH 5/6 v2] drm/msm/hdmi: Bring up HDMI connector OFF Rob Clark
2019-09-02 13:01 ` Linus Walleij
2019-08-23 7:34 ` [PATCH 6/6 v2] drm/msm/hdmi: Do not initialize HPD line value Linus Walleij
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=20190823073448.8385-5-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=masneyb@onstation.org \
--cc=robdclark@gmail.com \
--cc=sean@poorly.run \
/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;
as well as URLs for NNTP newsgroup(s).