From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: mythripk@ti.com
Cc: linux-omap@vger.kernel.org
Subject: Re: [PATCH 3/3] OMAPDSS: HDMI: wait for TMDS to be high before putting
Date: Tue, 27 Mar 2012 13:30:02 +0300 [thread overview]
Message-ID: <1332844202.1867.112.camel@deskari> (raw)
In-Reply-To: <1332249307-26875-4-git-send-email-mythripk@ti.com>
[-- Attachment #1: Type: text/plain, Size: 6044 bytes --]
On Tue, 2012-03-20 at 18:45 +0530, mythripk@ti.com wrote:
> From: Mythri P K <mythripk@ti.com>
>
> Currently TX_PHY is put to TX_ON(transmission state) on receiving HPD.
> It just ensures that the TV is connected but does not guarantee
> that TMDS data lines and clock lines are up and ready for transmission.
> Which although is very rare scenario has a potential to damage the HDMI
> port.
> Thus this patch adds the support based on PHY interrupts.
> On getting a HPD it registers for PHY connect/disconnect interrupt,
> On recieving those it is made sure TMDS lines are UP before changing
> the PHY state from LDO_ON to TX_ON.
>
> Signed-off-by: Mythri P K <mythripk@ti.com>
> ---
> drivers/video/omap2/dss/ti_hdmi.h | 1 +
> drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c | 61 ++++++++++++++++++++++++++---
> drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h | 2 +
> 3 files changed, 58 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/video/omap2/dss/ti_hdmi.h b/drivers/video/omap2/dss/ti_hdmi.h
> index 5e7e0da..5051df6 100644
> --- a/drivers/video/omap2/dss/ti_hdmi.h
> +++ b/drivers/video/omap2/dss/ti_hdmi.h
> @@ -186,6 +186,7 @@ struct hdmi_ip_data {
> /* ti_hdmi_4xxx_ip private data. These should be in a separate struct */
> int hpd_gpio;
> bool phy_tx_enabled;
> + bool phy_enabled;
> };
> int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data);
> void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data);
> diff --git a/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c b/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c
> index 31d9927..a54c811 100644
> --- a/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c
> +++ b/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.c
> @@ -273,7 +273,8 @@ static int hdmi_check_hpd_state(struct hdmi_ip_data *ip_data)
> {
> unsigned long flags;
> bool hpd;
> - int r;
> + int r = 0;
> + struct hdmi_irq_vector irq_enable;
> /* this should be in ti_hdmi_4xxx_ip private data */
> static DEFINE_SPINLOCK(phy_tx_lock);
>
> @@ -286,11 +287,21 @@ static int hdmi_check_hpd_state(struct hdmi_ip_data *ip_data)
> return 0;
> }
>
> - if (hpd)
> - r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_TXON);
> - else
> + hdmi_wp_clr_irq(ip_data);
> + hdmi_wp_irq_init(&irq_enable);
> + if (hpd) {
> + if (ip_data->phy_enabled) {
> + r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_TXON);
> + } else {
> + irq_enable.phy_connect = 1;
> + irq_enable.phy_disconnect = 0;
> + }
> + } else {
> r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_LDOON);
> -
> + irq_enable.phy_connect = 0;
> + irq_enable.phy_disconnect = 0;
> + ip_data->phy_enabled = false;
> + }
Why do you need this elaborate mechanism where you turn on/off the PHY
CONNECT/DISCONNECT interrupts? Why don't you just enable them when the
HDMI is enabled?
> if (r) {
> DSSERR("Failed to %s PHY TX power\n",
> hpd ? "enable" : "disable");
> @@ -300,6 +311,7 @@ static int hdmi_check_hpd_state(struct hdmi_ip_data *ip_data)
> ip_data->phy_tx_enabled = hpd;
> err:
> spin_unlock_irqrestore(&phy_tx_lock, flags);
> + hdmi_wp_irq_enable(ip_data, &irq_enable);
What happens if the connect irq happened before you enable the
interrupt?
> return r;
> }
>
> @@ -312,17 +324,54 @@ static irqreturn_t hpd_irq_handler(int irq, void *data)
> return IRQ_HANDLED;
> }
>
> +int hdmi_ti_4xxx_rxdet(struct hdmi_ip_data *ip_data)
> +{
> + int tmds_lines =0;
> +
> + tmds_lines = hdmi_read_reg(hdmi_phy_base(ip_data),
> + HDMI_TXPHY_PAD_CFG_CTRL);
> +
> + return (tmds_lines && 0x7F80);
I'm quite sure the line above is not correct, and thus the whole rxdet
system doesn't work properly.
> /* Interrupt handler */
> void ti_hdmi_4xxx_intr_handler(struct hdmi_ip_data *ip_data)
> {
> - u32 val;
> + u32 val, r = 0;
> + struct hdmi_irq_vector irq_enable;
>
> val = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_IRQSTATUS);
> +
> + hdmi_wp_clr_irq(ip_data);
> + hdmi_wp_irq_init(&irq_enable);
> +
> + if (val & HDMI_WP_IRQSTATUS_PHYCONNECT) {
> + if (ip_data->phy_tx_enabled && hdmi_ti_4xxx_rxdet(ip_data)) {
> + r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_TXON);
> + irq_enable.phy_connect = 0;
> + irq_enable.phy_disconnect = 1;
> + ip_data->phy_enabled = true;
> + }
> + }
> +
> + /* We can get connect / disconnect simultaneously due to glitch */
> + if (val & HDMI_WP_IRQSTATUS_PHYDISCONNECT) {
> + if (ip_data->phy_tx_enabled && !hdmi_ti_4xxx_rxdet(ip_data)) {
> + r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_LDOON);
> + irq_enable.phy_connect = 1;
> + irq_enable.phy_disconnect = 0;
> + ip_data->phy_enabled = false;
> + }
> + }
Instead of spreading this code into two functions, why not handle
everything in one function. You have four states, connected/disconnected
for both HPD and PHY. Just track the states of those, and have one
function decide what to do depending on those states.
> +
> + if (r)
> + DSSERR("Failed to set PHY TX power\n");
> +
> /* Ack other interrupts if any */
> hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_IRQSTATUS, val);
> /* flush posted write */
> hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_IRQSTATUS);
>
> + hdmi_wp_irq_enable(ip_data, &irq_enable);
> }
>
> int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data)
> diff --git a/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h b/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h
> index 3090e81..38af675 100644
> --- a/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h
> +++ b/drivers/video/omap2/dss/ti_hdmi_4xxx_ip.h
> @@ -48,6 +48,8 @@
> #define HDMI_WP_AUDIO_CFG2 0x84
> #define HDMI_WP_AUDIO_CTRL 0x88
> #define HDMI_WP_AUDIO_DATA 0x8C
> +#define HDMI_WP_IRQSTATUS_PHYCONNECT 0x02000000
> +#define HDMI_WP_IRQSTATUS_PHYDISCONNECT 0x04000000
Use (1 << xx) style there. And you could name them the same way as other
components: HDMI_WP_IRQ_PHYCONNECT. And if you add few, just add them
all.
Tomi
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-03-27 10:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-20 13:15 [PATCH 0/3] OMAPDSS: HDMI: Interrupt and PHY state handling support mythripk
2012-03-20 13:15 ` [PATCH 1/3] OMAPDSS: HDMI: support for interrupt enabling mythripk
2012-03-20 13:15 ` [PATCH 2/3] OMAPDSS: HDMI: Add support for DSS_HDMI Interrupt mythripk
2012-03-20 13:15 ` [PATCH 3/3] OMAPDSS: HDMI: wait for TMDS to be high before putting mythripk
2012-03-27 10:30 ` Tomi Valkeinen [this message]
2012-03-27 10:30 ` [PATCH 2/3] OMAPDSS: HDMI: Add support for DSS_HDMI Interrupt Tomi Valkeinen
2012-03-27 10:29 ` [PATCH 1/3] OMAPDSS: HDMI: support for interrupt enabling Tomi Valkeinen
2012-03-27 10:29 ` [PATCH 0/3] OMAPDSS: HDMI: Interrupt and PHY state handling support Tomi Valkeinen
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=1332844202.1867.112.camel@deskari \
--to=tomi.valkeinen@ti.com \
--cc=linux-omap@vger.kernel.org \
--cc=mythripk@ti.com \
/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).