aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/bridge/ti-tfp410.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-03 11:44:24 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-03 11:44:24 -0700
commit2f34c1231bfc9f2550f934acb268ac7315fb3837 (patch)
treeff8114b3b4ec4723a11b041c6b74c389e9f0eeb9 /drivers/gpu/drm/bridge/ti-tfp410.c
parentMerge branch 'generic' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs (diff)
parentMerge branch 'linux-4.12' of git://github.com/skeggsb/linux into drm-next (diff)
downloadlinux-dev-2f34c1231bfc9f2550f934acb268ac7315fb3837.tar.xz
linux-dev-2f34c1231bfc9f2550f934acb268ac7315fb3837.zip
Merge tag 'drm-for-v4.12' of git://people.freedesktop.org/~airlied/linux
Pull drm u pdates from Dave Airlie: "This is the main drm pull request for v4.12. Apart from two fixes pulls, everything should have been in drm-next for at least 2 weeks. The biggest thing in here is AMD released the public headers for their upcoming VEGA GPUs. These as always are quite a sizeable chunk of header files. They've also added initial non-display support for those GPUs, though they aren't available in production yet. Otherwise it's pretty much normal. New bridge drivers: - megachips-stdpxxxx-ge-b850v3-fw LVDS->DP++ - generic LVDS bridge support. Core: - Displayport link train failure reporting to userspace - debugfs interface cleaned up - subsystem TODO in kerneldoc now - Extended fbdev support (flipping and vblank wait) - drm_platform removed - EDP CRC support in helper - HF-VSDB SCDC support in EDID parser - Lots of code cleanups and header extraction - Thunderbolt external GPU awareness - Atomic helper improvements - Documentation improvements panel: - Sitronix and Samsung new panel support amdgpu: - Preliminary vega10 support - Multi-level page table support - GPU sensor support for userspace - PRT support for sparse buffers - SR-IOV improvements - Non-contig VRAM CPU mapping i915: - Atomic modesetting enabled by default on Gen5+ - LSPCON improvements - Atomic state handling for cdclk - GPU reset improvements - In-kernel unit tests - Geminilake improvements and color manager support - Designware i2c fixes - vblank evasion improvements - Hotplug safe connector iterators - GVT scheduler QoS support - GVT Kabylake support nouveau: - Acceleration support for Pascal (GP10x). - Rearchitecture of code handling proprietary signed firmware - Fix GTX 970 with odd MMU configuration - GP10B support - GP107 acceleration support vmwgfx: - Atomic modesetting support for vmwgfx omapdrm: - Support for render nodes - Refactor omapdss code - Fix some probe ordering issues - Fix too dark RGB565 rendering sunxi: - prelim rework for multiple pipes. mali-dp: - Color management support - Plane scaling - Power management improvements imx-drm: - Prefetch Resolve Engine/Gasket on i.MX6QP - Deferred plane disabling - Separate alpha support mediatek: - Mediatek SoC MT2701 support rcar-du: - Gen3 HDMI support msm: - 4k support for newer chips - OPP bindings for gpu - prep work for per-process pagetables vc4: - HDMI audio support - fixes qxl: - minor fixes. dw-hdmi: - PHY improvements - CSC fixes - Amlogic GX SoC support" * tag 'drm-for-v4.12' of git://people.freedesktop.org/~airlied/linux: (1778 commits) drm/nouveau/fb/gf100-: Fix 32 bit wraparound in new ram detection drm/nouveau/secboot/gm20b: fix the error return code in gm20b_secboot_tegra_read_wpr() drm/nouveau/kms: Increase max retries in scanout position queries. drm/nouveau/bios/bitP: check that table is long enough for optional pointers drm/nouveau/fifo/nv40: no ctxsw for pre-nv44 mpeg engine drm: mali-dp: use div_u64 for expensive 64-bit divisions drm/i915: Confirm the request is still active before adding it to the await drm/i915: Avoid busy-spinning on VLV_GLTC_PW_STATUS mmio drm/i915/selftests: Allocate inode/file dynamically drm/i915: Fix system hang with EI UP masked on Haswell drm/i915: checking for NULL instead of IS_ERR() in mock selftests drm/i915: Perform link quality check unconditionally during long pulse drm/i915: Fix use after free in lpe_audio_platdev_destroy() drm/i915: Use the right mapping_gfp_mask for final shmem allocation drm/i915: Make legacy cursor updates more unsynced drm/i915: Apply a cond_resched() to the saturated signaler drm/i915: Park the signaler before sleeping drm: mali-dp: Check the mclk rate and allow up/down scaling drm: mali-dp: Enable image enhancement when scaling drm: mali-dp: Add plane upscaling support ...
Diffstat (limited to 'drivers/gpu/drm/bridge/ti-tfp410.c')
-rw-r--r--drivers/gpu/drm/bridge/ti-tfp410.c89
1 files changed, 76 insertions, 13 deletions
diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c
index b054ea349952..eee4efda829e 100644
--- a/drivers/gpu/drm/bridge/ti-tfp410.c
+++ b/drivers/gpu/drm/bridge/ti-tfp410.c
@@ -8,6 +8,10 @@
*
*/
+#include <linux/delay.h>
+#include <linux/fwnode.h>
+#include <linux/gpio/consumer.h>
+#include <linux/irq.h>
#include <linux/module.h>
#include <linux/of_graph.h>
#include <linux/platform_device.h>
@@ -18,11 +22,15 @@
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
+#define HOTPLUG_DEBOUNCE_MS 1100
+
struct tfp410 {
struct drm_bridge bridge;
struct drm_connector connector;
struct i2c_adapter *ddc;
+ struct gpio_desc *hpd;
+ struct delayed_work hpd_work;
struct device *dev;
};
@@ -76,6 +84,13 @@ tfp410_connector_detect(struct drm_connector *connector, bool force)
{
struct tfp410 *dvi = drm_connector_to_tfp410(connector);
+ if (dvi->hpd) {
+ if (gpiod_get_value_cansleep(dvi->hpd))
+ return connector_status_connected;
+ else
+ return connector_status_disconnected;
+ }
+
if (dvi->ddc) {
if (drm_probe_ddc(dvi->ddc))
return connector_status_connected;
@@ -106,6 +121,9 @@ static int tfp410_attach(struct drm_bridge *bridge)
return -ENODEV;
}
+ if (dvi->hpd)
+ dvi->connector.polled = DRM_CONNECTOR_POLL_HPD;
+
drm_connector_helper_add(&dvi->connector,
&tfp410_con_helper_funcs);
ret = drm_connector_init(bridge->dev, &dvi->connector,
@@ -125,20 +143,46 @@ static const struct drm_bridge_funcs tfp410_bridge_funcs = {
.attach = tfp410_attach,
};
-static int tfp410_get_connector_ddc(struct tfp410 *dvi)
+static void tfp410_hpd_work_func(struct work_struct *work)
+{
+ struct tfp410 *dvi;
+
+ dvi = container_of(work, struct tfp410, hpd_work.work);
+
+ if (dvi->bridge.dev)
+ drm_helper_hpd_irq_event(dvi->bridge.dev);
+}
+
+static irqreturn_t tfp410_hpd_irq_thread(int irq, void *arg)
{
- struct device_node *ep = NULL, *connector_node = NULL;
- struct device_node *ddc_phandle = NULL;
+ struct tfp410 *dvi = arg;
+
+ mod_delayed_work(system_wq, &dvi->hpd_work,
+ msecs_to_jiffies(HOTPLUG_DEBOUNCE_MS));
+
+ return IRQ_HANDLED;
+}
+
+static int tfp410_get_connector_properties(struct tfp410 *dvi)
+{
+ struct device_node *connector_node, *ddc_phandle;
int ret = 0;
/* port@1 is the connector node */
- ep = of_graph_get_endpoint_by_regs(dvi->dev->of_node, 1, -1);
- if (!ep)
- goto fail;
-
- connector_node = of_graph_get_remote_port_parent(ep);
+ connector_node = of_graph_get_remote_node(dvi->dev->of_node, 1, -1);
if (!connector_node)
- goto fail;
+ return -ENODEV;
+
+ dvi->hpd = fwnode_get_named_gpiod(&connector_node->fwnode,
+ "hpd-gpios", 0, GPIOD_IN, "hpd");
+ if (IS_ERR(dvi->hpd)) {
+ ret = PTR_ERR(dvi->hpd);
+ dvi->hpd = NULL;
+ if (ret == -ENOENT)
+ ret = 0;
+ else
+ goto fail;
+ }
ddc_phandle = of_parse_phandle(connector_node, "ddc-i2c-bus", 0);
if (!ddc_phandle)
@@ -150,10 +194,10 @@ static int tfp410_get_connector_ddc(struct tfp410 *dvi)
else
ret = -EPROBE_DEFER;
+ of_node_put(ddc_phandle);
+
fail:
- of_node_put(ep);
of_node_put(connector_node);
- of_node_put(ddc_phandle);
return ret;
}
@@ -176,10 +220,23 @@ static int tfp410_init(struct device *dev)
dvi->bridge.of_node = dev->of_node;
dvi->dev = dev;
- ret = tfp410_get_connector_ddc(dvi);
+ ret = tfp410_get_connector_properties(dvi);
if (ret)
goto fail;
+ if (dvi->hpd) {
+ INIT_DELAYED_WORK(&dvi->hpd_work, tfp410_hpd_work_func);
+
+ ret = devm_request_threaded_irq(dev, gpiod_to_irq(dvi->hpd),
+ NULL, tfp410_hpd_irq_thread, IRQF_TRIGGER_RISING |
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ "hdmi-hpd", dvi);
+ if (ret) {
+ DRM_ERROR("failed to register hpd interrupt\n");
+ goto fail;
+ }
+ }
+
ret = drm_bridge_add(&dvi->bridge);
if (ret) {
dev_err(dev, "drm_bridge_add() failed: %d\n", ret);
@@ -189,6 +246,8 @@ static int tfp410_init(struct device *dev)
return 0;
fail:
i2c_put_adapter(dvi->ddc);
+ if (dvi->hpd)
+ gpiod_put(dvi->hpd);
return ret;
}
@@ -196,10 +255,14 @@ static int tfp410_fini(struct device *dev)
{
struct tfp410 *dvi = dev_get_drvdata(dev);
+ cancel_delayed_work_sync(&dvi->hpd_work);
+
drm_bridge_remove(&dvi->bridge);
if (dvi->ddc)
i2c_put_adapter(dvi->ddc);
+ if (dvi->hpd)
+ gpiod_put(dvi->hpd);
return 0;
}
@@ -220,7 +283,7 @@ static const struct of_device_id tfp410_match[] = {
};
MODULE_DEVICE_TABLE(of, tfp410_match);
-struct platform_driver tfp410_platform_driver = {
+static struct platform_driver tfp410_platform_driver = {
.probe = tfp410_probe,
.remove = tfp410_remove,
.driver = {