Skip to content

Commit

Permalink
[media] lirc_zilog: z8 on usb doesn't like back-to-back i2c_master_send
Browse files Browse the repository at this point in the history
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.

Acked-by: Andy Walls <awalls@md.metrocast.net>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Jarod Wilson authored and Mauro Carvalho Chehab committed Jan 31, 2011
1 parent 7f2a06d commit 5766d20
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions drivers/staging/lirc/lirc_zilog.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,23 +495,35 @@ 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 */
ret = send_data_block(tx, tx_data->boot_data);
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);
if (ret != 2) {
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;
Expand All @@ -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 "
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5766d20

Please sign in to comment.