stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [ 52/68] OMAPDSS: HDMI: PHY burnout fix
Date: Fri, 09 Mar 2012 11:03:06 -0800	[thread overview]
Message-ID: <20120309190219.129446135@linuxfoundation.org> (raw)
In-Reply-To: <20120309194409.GA2069@kroah.com>

3.0-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Tomi Valkeinen <tomi.valkeinen@ti.com>

commit c49d005b6cc8491fad5b24f82805be2d6bcbd3dd upstream.

A hardware bug in the OMAP4 HDMI PHY causes physical damage to the board
if the HDMI PHY is kept powered on when the cable is not connected.

This patch solves the problem by adding hot-plug-detection into the HDMI
IP driver. This is not a real HPD support in the sense that nobody else
than the IP driver gets to know about the HPD events, but is only meant
to fix the HW bug.

The strategy is simple: If the display device is turned off by the user,
the PHY power is set to OFF. When the display device is turned on by the
user, the PHY power is set either to LDOON or TXON, depending on whether
the HDMI cable is connected.

The reason to avoid PHY OFF when the display device is on, but the cable
is disconnected, is that when the PHY is turned OFF, the HDMI IP is not
"ticking" and thus the DISPC does not receive pixel clock from the HDMI
IP. This would, for example, prevent any VSYNCs from happening, and
would thus affect the users of omapdss. By using LDOON when the cable is
disconnected we'll avoid the HW bug, but keep the HDMI working as usual
from the user's point of view.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arm/mach-omap2/board-4430sdp.c    |    5 ++
 arch/arm/mach-omap2/board-omap4panda.c |    5 ++
 drivers/video/omap2/dss/hdmi.c         |   71 +++++++++++++++++++++++++++++++--
 include/video/omapdss.h                |    5 ++
 4 files changed, 82 insertions(+), 4 deletions(-)

--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -610,6 +610,10 @@ static void sdp4430_panel_disable_hdmi(s
 	gpio_free_array(sdp4430_hdmi_gpios, ARRAY_SIZE(sdp4430_hdmi_gpios));
 }
 
+static struct omap_dss_hdmi_data sdp4430_hdmi_data = {
+	.hpd_gpio = HDMI_GPIO_HPD,
+};
+
 static struct omap_dss_device sdp4430_hdmi_device = {
 	.name = "hdmi",
 	.driver_name = "hdmi_panel",
@@ -617,6 +621,7 @@ static struct omap_dss_device sdp4430_hd
 	.platform_enable = sdp4430_panel_enable_hdmi,
 	.platform_disable = sdp4430_panel_disable_hdmi,
 	.channel = OMAP_DSS_CHANNEL_DIGIT,
+	.data = &sdp4430_hdmi_data,
 };
 
 static struct omap_dss_device *sdp4430_dss_devices[] = {
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -646,6 +646,10 @@ static void omap4_panda_panel_disable_hd
 	gpio_free_array(panda_hdmi_gpios, ARRAY_SIZE(panda_hdmi_gpios));
 }
 
+static struct omap_dss_hdmi_data omap4_panda_hdmi_data = {
+	.hpd_gpio = HDMI_GPIO_HPD,
+};
+
 static struct omap_dss_device  omap4_panda_hdmi_device = {
 	.name = "hdmi",
 	.driver_name = "hdmi_panel",
@@ -653,6 +657,7 @@ static struct omap_dss_device  omap4_pan
 	.platform_enable = omap4_panda_panel_enable_hdmi,
 	.platform_disable = omap4_panda_panel_disable_hdmi,
 	.channel = OMAP_DSS_CHANNEL_DIGIT,
+	.data = &omap4_panda_hdmi_data,
 };
 
 static struct omap_dss_device *omap4_panda_dss_devices[] = {
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -29,6 +29,7 @@
 #include <linux/mutex.h>
 #include <linux/delay.h>
 #include <linux/string.h>
+#include <linux/gpio.h>
 #include <video/omapdss.h>
 #if defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI) || \
 	defined(CONFIG_SND_OMAP_SOC_OMAP4_HDMI_MODULE)
@@ -54,6 +55,9 @@ static struct {
 	u8 edid_set;
 	bool custom_set;
 	struct hdmi_config cfg;
+
+	int hpd_gpio;
+	bool phy_tx_enabled;
 } hdmi;
 
 /*
@@ -278,6 +282,47 @@ static int hdmi_pll_reset(void)
 	return 0;
 }
 
+static int hdmi_check_hpd_state(void)
+{
+	unsigned long flags;
+	bool hpd;
+	int r;
+	/* this should be in ti_hdmi_4xxx_ip private data */
+	static DEFINE_SPINLOCK(phy_tx_lock);
+
+	spin_lock_irqsave(&phy_tx_lock, flags);
+
+	hpd = gpio_get_value(hdmi.hpd_gpio);
+
+	if (hpd == hdmi.phy_tx_enabled) {
+		spin_unlock_irqrestore(&phy_tx_lock, flags);
+		return 0;
+	}
+
+	if (hpd)
+		r = hdmi_set_phy_pwr(HDMI_PHYPWRCMD_TXON);
+	else
+		r = hdmi_set_phy_pwr(HDMI_PHYPWRCMD_LDOON);
+
+	if (r) {
+		DSSERR("Failed to %s PHY TX power\n",
+				hpd ? "enable" : "disable");
+		goto err;
+	}
+
+	hdmi.phy_tx_enabled = hpd;
+err:
+	spin_unlock_irqrestore(&phy_tx_lock, flags);
+	return r;
+}
+
+static irqreturn_t hpd_irq_handler(int irq, void *data)
+{
+	hdmi_check_hpd_state();
+
+	return IRQ_HANDLED;
+}
+
 static int hdmi_phy_init(void)
 {
 	u16 r = 0;
@@ -286,10 +331,6 @@ static int hdmi_phy_init(void)
 	if (r)
 		return r;
 
-	r = hdmi_set_phy_pwr(HDMI_PHYPWRCMD_TXON);
-	if (r)
-		return r;
-
 	/*
 	 * Read address 0 in order to get the SCP reset done completed
 	 * Dummy access performed to make sure reset is done
@@ -311,6 +352,23 @@ static int hdmi_phy_init(void)
 	/* Write to phy address 3 to change the polarity control */
 	REG_FLD_MOD(HDMI_TXPHY_PAD_CFG_CTRL, 0x1, 27, 27);
 
+	r = request_threaded_irq(gpio_to_irq(hdmi.hpd_gpio),
+			NULL, hpd_irq_handler,
+			IRQF_DISABLED | IRQF_TRIGGER_RISING |
+			IRQF_TRIGGER_FALLING, "hpd", NULL);
+	if (r) {
+		DSSERR("HPD IRQ request failed\n");
+		hdmi_set_phy_pwr(HDMI_PHYPWRCMD_OFF);
+		return r;
+	}
+
+	r = hdmi_check_hpd_state();
+	if (r) {
+		free_irq(gpio_to_irq(hdmi.hpd_gpio), NULL);
+		hdmi_set_phy_pwr(HDMI_PHYPWRCMD_OFF);
+		return r;
+	}
+
 	return 0;
 }
 
@@ -361,7 +419,9 @@ static int hdmi_pll_program(struct hdmi_
 
 static void hdmi_phy_off(void)
 {
+	free_irq(gpio_to_irq(hdmi.hpd_gpio), NULL);
 	hdmi_set_phy_pwr(HDMI_PHYPWRCMD_OFF);
+	hdmi.phy_tx_enabled = false;
 }
 
 static int hdmi_core_ddc_edid(u8 *pedid, int ext)
@@ -1236,12 +1296,15 @@ void omapdss_hdmi_display_set_timing(str
 
 int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev)
 {
+	struct omap_dss_hdmi_data *priv = dssdev->data;
 	int r = 0;
 
 	DSSDBG("ENTER hdmi_display_enable\n");
 
 	mutex_lock(&hdmi.lock);
 
+	hdmi.hpd_gpio = priv->hpd_gpio;
+
 	r = omap_dss_start_device(dssdev);
 	if (r) {
 		DSSERR("failed to start device\n");
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -514,6 +514,11 @@ struct omap_dss_device {
 	int (*get_backlight)(struct omap_dss_device *dssdev);
 };
 
+struct omap_dss_hdmi_data
+{
+	int hpd_gpio;
+};
+
 struct omap_dss_driver {
 	struct device_driver driver;
 



  parent reply	other threads:[~2012-03-09 19:03 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-09 19:44 [ 00/68] 3.0.24-stable review Greg KH
2012-03-09 19:02 ` [ 01/68] autofs: work around unhappy compat problem on x86-64 Greg KH
2012-03-09 19:02 ` [ 02/68] Fix autofs compile without CONFIG_COMPAT Greg KH
2012-03-09 19:02 ` [ 03/68] compat: fix compile breakage on s390 Greg KH
2012-03-09 19:02 ` [ 04/68] drm/i915: Prevent a machine hang by checking crtc->active before loading lut Greg KH
2012-03-09 19:02 ` [ 05/68] ARM: LPC32xx: serial.c: HW bug workaround Greg KH
2012-03-09 19:02 ` [ 06/68] ARM: LPC32xx: serial.c: Fixed loop limit Greg KH
2012-03-09 19:02 ` [ 07/68] ARM: LPC32xx: irq.c: Clear latched event Greg KH
2012-03-09 19:02 ` [ 08/68] ARM: LPC32xx: Fix interrupt controller init Greg KH
2012-03-09 19:02 ` [ 09/68] ARM: LPC32xx: Fix irq on GPI_28 Greg KH
2012-03-09 19:02 ` [ 10/68] watchdog: hpwdt: clean up set_memory_x call for 32 bit Greg KH
2012-03-09 19:02 ` [ 11/68] i2c: mxs: only flag completion when queue is completely done Greg KH
2012-03-09 19:02 ` [ 12/68] regulator: fix the ldo configure according to 88pm860x spec Greg KH
2012-03-09 19:02 ` [ 13/68] S390: KEYS: Enable the compat keyctl wrapper on s390x Greg KH
2012-03-09 19:02 ` [ 14/68] ALSA: hda - Add a fake mute feature Greg KH
2012-03-09 19:02 ` [ 15/68] ALSA: hda - Always set HP pin in unsol handler for STAC/IDT codecs Greg KH
2012-03-09 19:02 ` [ 16/68] regset: Prevent null pointer reference on readonly regsets Greg KH
2012-03-09 19:02 ` [ 17/68] regset: Return -EFAULT, not -EIO, on host-side memory fault Greg KH
2012-03-09 20:34   ` Jonathan Nieder
2012-03-09 20:41     ` Greg KH
2012-03-09 20:52       ` Jonathan Nieder
2012-03-09 19:02 ` [ 18/68] mfd: Fix ACPI conflict check Greg KH
2012-03-09 19:02 ` [ 19/68] genirq: Clear action->thread_mask if IRQ_ONESHOT is not set Greg KH
2012-03-09 19:02 ` [ 20/68] ARM: S3C24XX: DMA resume regression fix Greg KH
2012-03-09 19:02 ` [ 21/68] Move Logitech Harmony 900 from cdc_ether to zaurus Greg KH
2012-03-09 19:02 ` [ 22/68] alpha: fix 32/64-bit bug in futex support Greg KH
2012-03-09 19:02 ` [ 23/68] mmc: sdhci-esdhc-imx: fix for mmc cards on i.MX5 Greg KH
2012-03-09 19:02 ` [ 24/68] mm: memcg: Correct unregistring of events attached to the same eventfd Greg KH
2012-03-09 19:02 ` [ 25/68] NOMMU: Dont need to clear vm_mm when deleting a VMA Greg KH
2012-03-09 19:02 ` [ 26/68] cifs: fix dentry refcount leak when opening a FIFO on lookup Greg KH
2012-03-09 19:02 ` [ 27/68] mac80211: zero initialize count field in ieee80211_tx_rate Greg KH
2012-03-09 19:02 ` [ 28/68] ath9k_hw: prevent writes to const data on AR9160 Greg KH
2012-03-09 19:02 ` [ 29/68] kprobes: return proper error code from register_kprobe() Greg KH
2012-03-12  4:57   ` Jonathan Nieder
2012-03-12 17:31     ` Greg KH
2012-03-09 19:02 ` [ 30/68] mm: thp: fix BUG on mm->nr_ptes Greg KH
2012-03-09 19:02 ` [ 31/68] HID: usbhid: Add NOGET quirk for the AIREN Slim+ keyboard Greg KH
2012-03-09 19:02 ` [ 32/68] crypto: mv_cesa - fix final callback not ignoring input data Greg KH
2012-03-09 19:02 ` [ 33/68] [SCSI] osd_uld: Bump MAX_OSD_DEVICES from 64 to 1,048,576 Greg KH
2012-03-09 19:02 ` [ 34/68] ASoC: dapm: Check for bias level when powering down Greg KH
2012-03-09 19:02 ` [ 35/68] ASoC: i.MX SSI: Fix DSP_A format Greg KH
2012-03-09 19:02 ` [ 36/68] bsg: fix sysfs link remove warning Greg KH
2012-03-09 19:02 ` [ 37/68] ACPI / PM: Do not save/restore NVS on Asus K54C/K54HR Greg KH
2012-03-09 19:02 ` [ 38/68] avr32: select generic atomic64_t support Greg KH
2012-03-09 19:02 ` [ 39/68] kprobes: adjust "fix a memory leak in function pre_handler_kretprobe()" Greg KH
2012-03-09 19:02 ` [ 40/68] drm/i915: gen7: implement rczunit workaround Greg KH
2012-03-09 19:02 ` [ 41/68] drm/i915: gen7: Implement an L3 caching workaround Greg KH
2012-03-09 19:02 ` [ 42/68] drm/i915: gen7: work around a system hang on IVB Greg KH
2012-03-09 19:02 ` [ 43/68] drm/i915: gen7: Disable the RHWO optimization as it can cause GPU hangs Greg KH
2012-03-09 19:02 ` [ 44/68] ARM: orion: Fix USB phy for orion5x Greg KH
2012-03-09 19:02 ` [ 45/68] ARM: orion: Fix Orion5x GPIO regression from MPP cleanup Greg KH
2012-03-09 19:03 ` [ 46/68] OMAP: DSS2: HDMI: use default dividers Greg KH
2012-03-09 19:03 ` [ 47/68] OMAP: 4430SDP/Panda: use gpio_free_array to free HDMI gpios Greg KH
2012-03-09 19:03 ` [ 48/68] OMAP: 4430SDP/Panda: rename HPD GPIO to CT_CP_HPD Greg KH
2012-03-09 19:03 ` [ 49/68] OMAPDSS: remove wrong HDMI HPD muxing Greg KH
2012-03-09 19:03 ` [ 50/68] OMAP: 4430SDP/Panda: setup HDMI GPIO muxes Greg KH
2012-03-09 19:03 ` [ 51/68] OMAP: 4430SDP/Panda: add HDMI HPD gpio Greg KH
2012-03-09 19:03 ` Greg KH [this message]
2012-03-09 19:03 ` [ 53/68] ARM: 7345/1: errata: update workaround for A9 erratum #743622 Greg KH
2012-03-09 19:03 ` [ 54/68] media: staging: lirc_serial: Fix init/exit order Greg KH
2012-03-09 19:03 ` [ 55/68] media: staging: lirc_serial: Free resources on failure paths of lirc_serial_probe() Greg KH
2012-03-09 19:03 ` [ 56/68] media: staging: lirc_serial: Fix deadlock on resume failure Greg KH
2012-03-09 19:03 ` [ 57/68] media: staging: lirc_serial: Do not assume error codes returned by request_irq() Greg KH
2012-03-09 19:03 ` [ 58/68] Input: ALPS - fix touchpad detection when buttons are pressed Greg KH
2012-03-09 19:03 ` [ 59/68] hwmon: (pmbus_core) Fix maximum number of POUT alarm attributes Greg KH
2012-03-09 19:03 ` [ 60/68] hwmon: (jc42) Add support for ST Microelectronics STTS2002 and STTS3000 Greg KH
2012-03-09 19:03 ` [ 61/68] hwmon: (jc42) Add support for AT30TS00, TS3000GB2, TSE2002GB2, and MCP9804 Greg KH
2012-03-09 19:03 ` [ 62/68] carl9170: Fix memory accounting when sta is in power-save mode Greg KH
2012-03-09 19:03 ` [ 63/68] drm/radeon/kms: set SX_MISC in the r6xx blit code (v2) Greg KH
2012-03-09 19:03 ` [ 64/68] net/usbnet: avoid recursive locking in usbnet_stop() Greg KH
2012-03-09 19:03 ` [ 65/68] dm io: fix discard support Greg KH
2012-03-09 19:03 ` [ 66/68] dm raid: fix flush support Greg KH
2012-03-09 19:03 ` [ 67/68] cs5535-mfgpt: dont call __init function from __devinit Greg KH
2012-03-09 19:03 ` [ 68/68] mfd: Fix cs5535 section mismatch Greg KH

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=20120309190219.129446135@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    --cc=torvalds@linux-foundation.org \
    /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).