public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Walls <awalls@md.metrocast.net>
To: Jarod Wilson <jarod@redhat.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 2/3] lirc_zilog: z8 on usb doesn't like back-to-back i2c_master_send
Date: Fri, 21 Jan 2011 08:36:44 -0500	[thread overview]
Message-ID: <1295617004.2114.32.camel@morgan.silverblock.net> (raw)
In-Reply-To: <1295584225-21210-3-git-send-email-jarod@redhat.com>

On Thu, 2011-01-20 at 23:30 -0500, Jarod Wilson wrote:
> Both the HD-PVR and HVR-1950, driven by the hdpvr and pvrusb2 drivers
> respectively, have a zilog z8 chip exposed via i2c. These are both
> usb-connected devices, and on both of them, back-to-back i2c_master_send
> calls that work fine with a z8 on a pci card fail with a -EIO, as the
> chip isn't yet ready from the prior command. To cope with that, add a
> delay and retry loop where necessary.
> 
> Signed-off-by: Jarod Wilson <jarod@redhat.com>

I haven't tested it, but it looks good.

Acked-by: Andy Walls <awalls@md.metrocast.net>


> ---
>  drivers/staging/lirc/lirc_zilog.c |   32 ++++++++++++++++++++++++++------
>  1 files changed, 26 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c
> index 3fe5f41..0aad0d7 100644
> --- a/drivers/staging/lirc/lirc_zilog.c
> +++ b/drivers/staging/lirc/lirc_zilog.c
> @@ -495,7 +495,7 @@ static int send_data_block(struct IR_tx *tx, unsigned char *data_block)
>  /* send boot data to the IR TX device */
>  static int send_boot_data(struct IR_tx *tx)
>  {
> -	int ret;
> +	int ret, i;
>  	unsigned char buf[4];
>  
>  	/* send the boot block */
> @@ -503,7 +503,7 @@ static int send_boot_data(struct IR_tx *tx)
>  	if (ret != 0)
>  		return ret;
>  
> -	/* kick it off? */
> +	/* Hit the go button to activate the new boot data */
>  	buf[0] = 0x00;
>  	buf[1] = 0x20;
>  	ret = i2c_master_send(tx->c, buf, 2);
> @@ -511,7 +511,19 @@ static int send_boot_data(struct IR_tx *tx)
>  		zilog_error("i2c_master_send failed with %d\n", ret);
>  		return ret < 0 ? ret : -EFAULT;
>  	}
> -	ret = i2c_master_send(tx->c, buf, 1);
> +
> +	/*
> +	 * Wait for zilog to settle after hitting go post boot block upload.
> +	 * Without this delay, the HD-PVR and HVR-1950 both return an -EIO
> +	 * upon attempting to get firmware revision, and tx probe thus fails.
> +	 */
> +	for (i = 0; i < 10; i++) {
> +		ret = i2c_master_send(tx->c, buf, 1);
> +		if (ret == 1)
> +			break;
> +		udelay(100);
> +	}
> +
>  	if (ret != 1) {
>  		zilog_error("i2c_master_send failed with %d\n", ret);
>  		return ret < 0 ? ret : -EFAULT;
> @@ -523,8 +535,8 @@ static int send_boot_data(struct IR_tx *tx)
>  		zilog_error("i2c_master_recv failed with %d\n", ret);
>  		return 0;
>  	}
> -	if (buf[0] != 0x80) {
> -		zilog_error("unexpected IR TX response: %02x\n", buf[0]);
> +	if ((buf[0] != 0x80) && (buf[0] != 0xa0)) {
> +		zilog_error("unexpected IR TX init response: %02x\n", buf[0]);
>  		return 0;
>  	}
>  	zilog_notify("Zilog/Hauppauge IR blaster firmware version "
> @@ -827,7 +839,15 @@ static int send_code(struct IR_tx *tx, unsigned int code, unsigned int key)
>  		zilog_error("i2c_master_send failed with %d\n", ret);
>  		return ret < 0 ? ret : -EFAULT;
>  	}
> -	ret = i2c_master_send(tx->c, buf, 1);
> +
> +	/* Give the z8 a moment to process data block */
> +	for (i = 0; i < 10; i++) {
> +		ret = i2c_master_send(tx->c, buf, 1);
> +		if (ret == 1)
> +			break;
> +		udelay(100);
> +	}
> +
>  	if (ret != 1) {
>  		zilog_error("i2c_master_send failed with %d\n", ret);
>  		return ret < 0 ? ret : -EFAULT;



  reply	other threads:[~2011-01-21 13:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-21  4:30 [PATCH 0/3] i2c IR fixups Jarod Wilson
2011-01-21  4:30 ` [PATCH 1/3] hdpvr: fix up i2c device registration Jarod Wilson
2011-01-21 13:34   ` Andy Walls
2011-01-21 14:14     ` Jarod Wilson
2011-01-21 16:41     ` [PATCH 1/3 v2] " Jarod Wilson
2011-01-21  4:30 ` [PATCH 2/3] lirc_zilog: z8 on usb doesn't like back-to-back i2c_master_send Jarod Wilson
2011-01-21 13:36   ` Andy Walls [this message]
2011-01-21  4:30 ` [PATCH 3/3] ir-kbd-i2c: improve remote behavior with z8 behind usb Jarod Wilson
2011-01-21  4:51   ` Jarod Wilson
2011-01-21 13:50   ` Andy Walls
2011-01-21 16:31   ` Mike Isely
2011-01-21 16:34     ` Jarod Wilson
2011-01-21 16:40       ` Mike Isely
2011-01-21 16:36     ` Mike Isely

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=1295617004.2114.32.camel@morgan.silverblock.net \
    --to=awalls@md.metrocast.net \
    --cc=jarod@redhat.com \
    --cc=linux-media@vger.kernel.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