From patchwork Fri Dec 5 13:59:20 2014
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Philipp Zabel
X-Patchwork-Id: 418108
Return-Path:
X-Original-To: incoming-dt@patchwork.ozlabs.org
Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
by ozlabs.org (Postfix) with ESMTP id CE47B1400D5
for ;
Sat, 6 Dec 2014 00:59:32 +1100 (AEDT)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1751213AbaLEN7b (ORCPT
);
Fri, 5 Dec 2014 08:59:31 -0500
Received: from metis.ext.pengutronix.de ([92.198.50.35]:41345 "EHLO
metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1751474AbaLEN7b (ORCPT
); Fri, 5 Dec 2014 08:59:31 -0500
Received: from dude.hi.4.pengutronix.de ([10.1.0.7]
helo=dude.pengutronix.de.)
by metis.ext.pengutronix.de with esmtp (Exim 4.72)
(envelope-from )
id 1XwtPl-0001cF-2R; Fri, 05 Dec 2014 14:59:21 +0100
From: Philipp Zabel
To: dri-devel@lists.freedesktop.org
Cc: Rob Herring , Pawel Moll ,
Mark Rutland ,
Ian Campbell ,
Kumar Gala , David Airlie ,
Russell King ,
Andy Yan , devicetree@vger.kernel.org,
kernel@pengutronix.de, Philipp Zabel
Subject: [PATCH] drm/bridge: dw_hdmi: use rx sense pins for plug detection if
hpd is unreliable
Date: Fri, 5 Dec 2014 14:59:20 +0100
Message-Id: <1417787960-14078-1-git-send-email-p.zabel@pengutronix.de>
X-Mailer: git-send-email 2.1.3
X-SA-Exim-Connect-IP: 10.1.0.7
X-SA-Exim-Mail-From: p.zabel@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de);
SAEximRunCond expanded to false
X-PTX-Original-Recipient: devicetree@vger.kernel.org
Sender: devicetree-owner@vger.kernel.org
Precedence: bulk
List-ID:
X-Mailing-List: devicetree@vger.kernel.org
Due to the voltage divider on the HPD line, the HDMI connector on
imx6q-sabrelite doesn't reliably detect connected DVI monitors.
This patch allows to use the RX_SENSE0 signal as a workaround when
enabled by a boolean device tree property 'hpd-unreliable'.
Signed-off-by: Philipp Zabel
---
This patch is updated from
http://www.spinics.net/lists/linux-driver-devel/msg45207.html
and rebased on top of Andy Yan's "dw-hdmi: convert imx hdmi to bridge/dw_hdmi"
series.
---
Documentation/devicetree/bindings/drm/imx/hdmi.txt | 2 ++
drivers/gpu/drm/bridge/dw_hdmi.c | 40 ++++++++++++++++------
2 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/Documentation/devicetree/bindings/drm/imx/hdmi.txt b/Documentation/devicetree/bindings/drm/imx/hdmi.txt
index 1b756cf..c997a3a 100644
--- a/Documentation/devicetree/bindings/drm/imx/hdmi.txt
+++ b/Documentation/devicetree/bindings/drm/imx/hdmi.txt
@@ -22,6 +22,8 @@ Required properties:
Optional properties:
- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+ - hpd-unreliable : if present, the HPD line is to be ignored and the driver
+ should instead use a workaround for sink detection.
example:
diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index cecc46a..b88225c 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -125,6 +125,9 @@ struct dw_hdmi {
struct regmap *regmap;
struct i2c_adapter *ddc;
void __iomem *regs;
+ u8 sink_detect_polarity;
+ u8 sink_detect_status;
+ u8 sink_detect_mask;
unsigned int sample_rate;
int ratio;
@@ -1267,10 +1270,10 @@ static int dw_hdmi_fb_registered(struct dw_hdmi *hdmi)
HDMI_PHY_I2CM_CTLINT_ADDR);
/* enable cable hot plug irq */
- hdmi_writeb(hdmi, (u8)~HDMI_PHY_HPD, HDMI_PHY_MASK0);
+ hdmi_writeb(hdmi, hdmi->sink_detect_mask, HDMI_PHY_MASK0);
/* Clear Hotplug interrupts */
- hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD, HDMI_IH_PHY_STAT0);
+ hdmi_writeb(hdmi, hdmi->sink_detect_status, HDMI_IH_PHY_STAT0);
return 0;
}
@@ -1490,18 +1493,19 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
phy_int_pol = hdmi_readb(hdmi, HDMI_PHY_POL0);
- if (intr_stat & HDMI_IH_PHY_STAT0_HPD) {
- if (phy_int_pol & HDMI_PHY_HPD) {
+ if (intr_stat & hdmi->sink_detect_status) {
+ int pol_bit = hdmi->sink_detect_polarity;
+
+ if (phy_int_pol & pol_bit) {
dev_dbg(hdmi->dev, "EVENT=plugin\n");
- hdmi_modb(hdmi, 0, HDMI_PHY_HPD, HDMI_PHY_POL0);
+ hdmi_modb(hdmi, 0, pol_bit, HDMI_PHY_POL0);
dw_hdmi_poweron(hdmi);
} else {
dev_dbg(hdmi->dev, "EVENT=plugout\n");
- hdmi_modb(hdmi, HDMI_PHY_HPD, HDMI_PHY_HPD,
- HDMI_PHY_POL0);
+ hdmi_modb(hdmi, pol_bit, pol_bit, HDMI_PHY_POL0);
dw_hdmi_poweroff(hdmi);
}
@@ -1509,7 +1513,7 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
}
hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0);
- hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0);
+ hdmi_writeb(hdmi, ~hdmi->sink_detect_status, HDMI_IH_MUTE_PHY_STAT0);
return IRQ_HANDLED;
}
@@ -1648,6 +1652,16 @@ int dw_hdmi_bind(struct device *dev, struct device *master,
initialize_hdmi_ih_mutes(hdmi);
+ hdmi->sink_detect_status = HDMI_IH_PHY_STAT0_HPD;
+ hdmi->sink_detect_polarity = HDMI_PHY_HPD;
+ hdmi->sink_detect_mask = ~HDMI_PHY_HPD;
+
+ if (of_property_read_bool(np, "hpd-unreliable")) {
+ hdmi->sink_detect_status = HDMI_IH_PHY_STAT0_RX_SENSE0;
+ hdmi->sink_detect_polarity = HDMI_PHY_RX_SENSE0;
+ hdmi->sink_detect_mask = ~HDMI_PHY_RX_SENSE0;
+ }
+
/*
* To prevent overflows in HDMI_IH_FC_STAT2, set the clk regenerator
* N and cts values before enabling phy
@@ -1658,10 +1672,14 @@ int dw_hdmi_bind(struct device *dev, struct device *master,
* Configure registers related to HDMI interrupt
* generation before registering IRQ.
*/
- hdmi_writeb(hdmi, HDMI_PHY_HPD, HDMI_PHY_POL0);
+ hdmi_writeb(hdmi, hdmi->sink_detect_polarity, HDMI_PHY_POL0);
/* Clear Hotplug interrupts */
- hdmi_writeb(hdmi, HDMI_IH_PHY_STAT0_HPD, HDMI_IH_PHY_STAT0);
+ hdmi_writeb(hdmi,
+ HDMI_IH_PHY_STAT0_RX_SENSE3 | HDMI_IH_PHY_STAT0_RX_SENSE2 |
+ HDMI_IH_PHY_STAT0_RX_SENSE1 | HDMI_IH_PHY_STAT0_RX_SENSE0 |
+ HDMI_IH_PHY_STAT0_TX_PHY_LOCK | HDMI_IH_PHY_STAT0_HPD,
+ HDMI_IH_PHY_STAT0);
ret = dw_hdmi_fb_registered(hdmi);
if (ret)
@@ -1672,7 +1690,7 @@ int dw_hdmi_bind(struct device *dev, struct device *master,
goto err_iahb;
/* Unmute interrupts */
- hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0);
+ hdmi_writeb(hdmi, ~hdmi->sink_detect_status, HDMI_IH_MUTE_PHY_STAT0);
dev_set_drvdata(dev, hdmi);