[PATCH] drm/bridge: dw_hdmi: use rx sense pins for plug detection if hpd is unreliable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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 <p.zabel@xxxxxxxxxxxxxx>
---
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);
 
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux