From patchwork Fri Jan 8 09:02:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 7983481 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4BBC89FCC4 for ; Fri, 8 Jan 2016 09:02:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6997820122 for ; Fri, 8 Jan 2016 09:02:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2A70C201C8 for ; Fri, 8 Jan 2016 09:02:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74EC56E731; Fri, 8 Jan 2016 01:02:26 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.ORg Delivered-To: dri-devel@lists.freedesktop.ORg Received: from metis.ext.4.pengutronix.de (metis.ext.4.pengutronix.de [92.198.50.35]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8101E6E731 for ; Fri, 8 Jan 2016 01:02:24 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1aHSw9-0000FA-2H; Fri, 08 Jan 2016 10:02:21 +0100 From: Philipp Zabel To: Thierry Reding Subject: [PATCH 4/4] drm: bridge/dw-hdmi: use rx sense for plug detection if hpd is unreliable Date: Fri, 8 Jan 2016 10:02:07 +0100 Message-Id: <1452243727-7242-4-git-send-email-p.zabel@pengutronix.de> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1452243727-7242-1-git-send-email-p.zabel@pengutronix.de> References: <1452243727-7242-1-git-send-email-p.zabel@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::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: dri-devel@lists.freedesktop.org Cc: Russell King , kernel@pengutronix.de, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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_SENSE signals as a workaround when enabled by a boolean device tree property 'hpd-unreliable'. Signed-off-by: Philipp Zabel --- drivers/gpu/drm/bridge/dw-hdmi.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c index 2388a55..7ffaa44 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -111,6 +111,7 @@ struct dw_hdmi { struct device *dev; struct clk *isfr_clk; struct clk *iahb_clk; + bool hpd_unreliable; struct hdmi_data_info hdmi_data; const struct dw_hdmi_plat_data *plat_data; @@ -1413,6 +1414,8 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) { struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, connector); + /* If HPD is not reliable, use RX_SENSE as fallback */ + u8 stat_mask = hdmi->hpd_unreliable ? HDMI_PHY_RX_SENSE : HDMI_PHY_HPD; mutex_lock(&hdmi->mutex); hdmi->force = DRM_FORCE_UNSPECIFIED; @@ -1420,7 +1423,7 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) dw_hdmi_update_phy_mask(hdmi); mutex_unlock(&hdmi->mutex); - if (hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD) + if ((hdmi_readb(hdmi, HDMI_PHY_STAT0) & stat_mask) == stat_mask) return connector_status_connected; /* free previous EDID block */ @@ -1556,7 +1559,7 @@ static irqreturn_t dw_hdmi_hardirq(int irq, void *dev_id) static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) { struct dw_hdmi *hdmi = dev_id; - u8 intr_stat, phy_int_pol, phy_pol_mask, phy_stat; + u8 intr_stat, intr_mask, phy_int_pol, phy_pol_mask, phy_stat; intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0); phy_int_pol = hdmi_readb(hdmi, HDMI_PHY_POL0); @@ -1583,9 +1586,12 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) * other end of the link. Use this to decide whether we should * power on the phy as HPD may be toggled by the sink to merely * ask the source to re-read the EDID. + * If HPD is known to be unreliable, ignore it completely. */ - if (intr_stat & - (HDMI_IH_PHY_STAT0_RX_SENSE | HDMI_IH_PHY_STAT0_HPD)) { + intr_mask = hdmi->hpd_unreliable ? + HDMI_IH_PHY_STAT0_RX_SENSE : + HDMI_IH_PHY_STAT0_RX_SENSE | HDMI_IH_PHY_STAT0_HPD; + if (intr_stat & intr_mask) { mutex_lock(&hdmi->mutex); if (!hdmi->disabled && !hdmi->force) { /* @@ -1594,14 +1600,14 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id) */ if (!(phy_stat & HDMI_PHY_RX_SENSE)) hdmi->rxsense = false; - /* * Only set the software rxsense status when both * rxsense and hpd indicates we're connected. * This avoids what seems to be bad behaviour in * at least iMX6S versions of the phy. */ - if (phy_stat & HDMI_PHY_HPD) + else if ((phy_stat & HDMI_PHY_HPD) || + hdmi->hpd_unreliable) hdmi->rxsense = true; dw_hdmi_update_power(hdmi); @@ -1617,8 +1623,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_PHY_STAT0_RX_SENSE), - HDMI_IH_MUTE_PHY_STAT0); + hdmi_writeb(hdmi, ~intr_mask, HDMI_IH_MUTE_PHY_STAT0); return IRQ_HANDLED; } @@ -1679,6 +1684,7 @@ int dw_hdmi_bind(struct device *dev, struct device *master, struct device_node *ddc_node; struct dw_hdmi_audio_data audio; struct dw_hdmi *hdmi; + u8 intr_mask; int ret; u32 val = 1; @@ -1770,6 +1776,8 @@ int dw_hdmi_bind(struct device *dev, struct device *master, initialize_hdmi_ih_mutes(hdmi); + hdmi->hpd_unreliable = of_property_read_bool(np, "hpd-unreliable"); + ret = devm_request_threaded_irq(dev, irq, dw_hdmi_hardirq, dw_hdmi_irq, IRQF_SHARED, dev_name(dev), hdmi); @@ -1801,8 +1809,10 @@ 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_PHY_STAT0_RX_SENSE), - HDMI_IH_MUTE_PHY_STAT0); + intr_mask = hdmi->hpd_unreliable ? + HDMI_IH_PHY_STAT0_RX_SENSE : + HDMI_IH_PHY_STAT0_RX_SENSE | HDMI_IH_PHY_STAT0_HPD; + hdmi_writeb(hdmi, ~intr_mask, HDMI_IH_MUTE_PHY_STAT0); memset(&pdevinfo, 0, sizeof(pdevinfo)); pdevinfo.parent = dev;