From: Hsin-Yi Wang <hsinyi@chromium.org>
To: dri-devel@lists.freedesktop.org
Cc: Archit Taneja <architt@codeaurora.org>,
Nicolas Boichat <drinkcat@chromium.org>,
Enric Balletbo i Serra <enric.balletbo@collabora.com>,
Thierry Reding <treding@nvidia.com>,
Russell King <rmk+kernel@arm.linux.org.uk>,
Matthias Brugger <mbrugger@suse.com>,
p.zabel@pengutronix.de, linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] drm: bridge: anx7688: Support bypass GPIO feature
Date: Mon, 9 Dec 2019 20:20:13 +0800 [thread overview]
Message-ID: <20191209122013.178564-5-hsinyi@chromium.org> (raw)
In-Reply-To: <20191209122013.178564-1-hsinyi@chromium.org>
Support optional feature: bypass GPIO.
Get GPIO status in irq handler. If GPIO is active, mode_fixup would be
bypassed.
Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
---
drivers/gpu/drm/bridge/analogix-anx7688.c | 57 +++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/drivers/gpu/drm/bridge/analogix-anx7688.c b/drivers/gpu/drm/bridge/analogix-anx7688.c
index 5a3a2251c1c5..1d09db2cf8e9 100644
--- a/drivers/gpu/drm/bridge/analogix-anx7688.c
+++ b/drivers/gpu/drm/bridge/analogix-anx7688.c
@@ -5,11 +5,16 @@
* Copyright 2016 Google LLC
*/
+#include <linux/gpio.h>
#include <linux/i2c.h>
+#include <linux/interrupt.h>
#include <linux/module.h>
+#include <linux/of_gpio.h>
#include <linux/regmap.h>
#include <drm/drm_bridge.h>
#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_probe_helper.h>
/* Register addresses */
#define VENDOR_ID_REG 0x00
@@ -31,6 +36,9 @@ struct anx7688 {
struct i2c_client *client;
struct regmap *regmap;
+ struct gpio_desc *gpiod_bypass;
+ int bypass;
+
bool filter;
};
@@ -49,6 +57,10 @@ static bool anx7688_bridge_mode_fixup(struct drm_bridge *bridge,
int totalbw, requiredbw;
int ret;
+ /* bypass anx mode fixup */
+ if (anx7688->bypass)
+ return true;
+
if (!anx7688->filter)
return true;
@@ -93,6 +105,19 @@ static const struct drm_bridge_funcs anx7688_bridge_funcs = {
.mode_fixup = anx7688_bridge_mode_fixup,
};
+static irqreturn_t gpio_display_mux_det_threaded_handler(int unused, void *data)
+{
+ struct anx7688 *anx7688 = data;
+
+ anx7688->bypass = gpiod_get_value(anx7688->gpiod_bypass);
+ dev_dbg(&anx7688->client->dev, "Interrupt %d!\n", anx7688->bypass);
+
+ if (anx7688->bridge.dev)
+ drm_kms_helper_hotplug_event(anx7688->bridge.dev);
+
+ return IRQ_HANDLED;
+}
+
static const struct regmap_config anx7688_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -156,6 +181,38 @@ static int anx7688_i2c_probe(struct i2c_client *client,
buffer[0], buffer[1]);
}
+ /* Optional bypass-gpios */
+ anx7688->gpiod_bypass = devm_gpiod_get_optional(dev, "bypass",
+ GPIOD_IN);
+ if (IS_ERR(anx7688->gpiod_bypass)) {
+ ret = PTR_ERR(anx7688->gpiod_bypass);
+ if (ret != -EPROBE_DEFER)
+ dev_err(dev, "bypass-gpios assigned failed\n");
+ return ret;
+ }
+ if (anx7688->gpiod_bypass) {
+ int irq;
+
+ irq = gpiod_to_irq(anx7688->gpiod_bypass);
+ if (irq < 0) {
+ dev_err(dev, "Failed to get output irq %d\n", irq);
+ return -ENODEV;
+ }
+
+ anx7688->bypass = gpiod_get_value(anx7688->gpiod_bypass);
+
+ ret = devm_request_threaded_irq(dev, irq, NULL,
+ gpio_display_mux_det_threaded_handler,
+ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
+ "gpio-display-mux-det", anx7688);
+ if (ret) {
+ dev_err(dev,
+ "Failed to request MUX_DET threaded irq\n");
+ return ret;
+ }
+ }
+
anx7688->bridge.funcs = &anx7688_bridge_funcs;
drm_bridge_add(&anx7688->bridge);
--
2.24.0.393.g34dc348eaf-goog
prev parent reply other threads:[~2019-12-09 12:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-09 12:20 [PATCH 0/4] drm: bridge: anx7688 and an optional feature Hsin-Yi Wang
2019-12-09 12:20 ` [PATCH 1/4] dt-bindings: drm/bridge: analogix-anx7688: Add ANX7688 transmitter binding Hsin-Yi Wang
2019-12-09 12:20 ` [PATCH 2/4] drm: bridge: anx7688: Add anx7688 bridge driver support Hsin-Yi Wang
2019-12-09 12:20 ` [PATCH 3/4] dt-bindings: drm/bridge: analogix-anx78xx: support bypass GPIO Hsin-Yi Wang
2019-12-09 12:20 ` Hsin-Yi Wang [this message]
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=20191209122013.178564-5-hsinyi@chromium.org \
--to=hsinyi@chromium.org \
--cc=architt@codeaurora.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=drinkcat@chromium.org \
--cc=enric.balletbo@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mbrugger@suse.com \
--cc=p.zabel@pengutronix.de \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=treding@nvidia.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;
as well as URLs for NNTP newsgroup(s).