aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorJarod Wilson <jarod@redhat.com>2011-01-19 16:49:19 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-01-31 09:18:42 -0500
commit5766d204ae6c1f54beaef37a18c3c9b5e32c3b16 (patch)
tree05858f379d89689bf9245e2a0caccab5dfe949fc /drivers/staging
parent7f2a06deaa22104a4cf4c0cc3d7c44c7e3228ef3 (diff)
[media] lirc_zilog: z8 on usb doesn't like back-to-back i2c_master_send
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>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/lirc/lirc_zilog.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/drivers/staging/lirc/lirc_zilog.c b/drivers/staging/lirc/lirc_zilog.c
index 3fe5f4160194..0aad0d7a74a3 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)
495/* send boot data to the IR TX device */ 495/* send boot data to the IR TX device */
496static int send_boot_data(struct IR_tx *tx) 496static int send_boot_data(struct IR_tx *tx)
497{ 497{
498 int ret; 498 int ret, i;
499 unsigned char buf[4]; 499 unsigned char buf[4];
500 500
501 /* send the boot block */ 501 /* send the boot block */
@@ -503,7 +503,7 @@ static int send_boot_data(struct IR_tx *tx)
503 if (ret != 0) 503 if (ret != 0)
504 return ret; 504 return ret;
505 505
506 /* kick it off? */ 506 /* Hit the go button to activate the new boot data */
507 buf[0] = 0x00; 507 buf[0] = 0x00;
508 buf[1] = 0x20; 508 buf[1] = 0x20;
509 ret = i2c_master_send(tx->c, buf, 2); 509 ret = i2c_master_send(tx->c, buf, 2);
@@ -511,7 +511,19 @@ static int send_boot_data(struct IR_tx *tx)
511 zilog_error("i2c_master_send failed with %d\n", ret); 511 zilog_error("i2c_master_send failed with %d\n", ret);
512 return ret < 0 ? ret : -EFAULT; 512 return ret < 0 ? ret : -EFAULT;
513 } 513 }
514 ret = i2c_master_send(tx->c, buf, 1); 514
515 /*
516 * Wait for zilog to settle after hitting go post boot block upload.
517 * Without this delay, the HD-PVR and HVR-1950 both return an -EIO
518 * upon attempting to get firmware revision, and tx probe thus fails.
519 */
520 for (i = 0; i < 10; i++) {
521 ret = i2c_master_send(tx->c, buf, 1);
522 if (ret == 1)
523 break;
524 udelay(100);
525 }
526
515 if (ret != 1) { 527 if (ret != 1) {
516 zilog_error("i2c_master_send failed with %d\n", ret); 528 zilog_error("i2c_master_send failed with %d\n", ret);
517 return ret < 0 ? ret : -EFAULT; 529 return ret < 0 ? ret : -EFAULT;
@@ -523,8 +535,8 @@ static int send_boot_data(struct IR_tx *tx)
523 zilog_error("i2c_master_recv failed with %d\n", ret); 535 zilog_error("i2c_master_recv failed with %d\n", ret);
524 return 0; 536 return 0;
525 } 537 }
526 if (buf[0] != 0x80) { 538 if ((buf[0] != 0x80) && (buf[0] != 0xa0)) {
527 zilog_error("unexpected IR TX response: %02x\n", buf[0]); 539 zilog_error("unexpected IR TX init response: %02x\n", buf[0]);
528 return 0; 540 return 0;
529 } 541 }
530 zilog_notify("Zilog/Hauppauge IR blaster firmware version " 542 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)
827 zilog_error("i2c_master_send failed with %d\n", ret); 839 zilog_error("i2c_master_send failed with %d\n", ret);
828 return ret < 0 ? ret : -EFAULT; 840 return ret < 0 ? ret : -EFAULT;
829 } 841 }
830 ret = i2c_master_send(tx->c, buf, 1); 842
843 /* Give the z8 a moment to process data block */
844 for (i = 0; i < 10; i++) {
845 ret = i2c_master_send(tx->c, buf, 1);
846 if (ret == 1)
847 break;
848 udelay(100);
849 }
850
831 if (ret != 1) { 851 if (ret != 1) {
832 zilog_error("i2c_master_send failed with %d\n", ret); 852 zilog_error("i2c_master_send failed with %d\n", ret);
833 return ret < 0 ? ret : -EFAULT; 853 return ret < 0 ? ret : -EFAULT;