aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMalcolm Priestley <tvboxspy@gmail.com>2012-03-25 05:57:49 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-04-09 08:42:10 -0400
commit4da28766140449e04270246fae310c137180652d (patch)
treee80d3913754f6868f76df23c2c7c2cd77ff9b6d7 /drivers/media
parentbc169e35e3a72c6888b7d12f50f2c4063436d834 (diff)
[media] it913x: fix firmware loading errors
On some systems the device does not respond or give obscure values after cold, warm or firmware reboot. This patch retries to get chip version and type 5 times. If it fails it applies chip version 0x1 and type 0x9135. This patch does not fix warm cycle problems from other operating systems and indeed the reverse applies. Users should power off cold boot. Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/dvb/dvb-usb/it913x.c54
1 files changed, 40 insertions, 14 deletions
diff --git a/drivers/media/dvb/dvb-usb/it913x.c b/drivers/media/dvb/dvb-usb/it913x.c
index 3b7b102f20ae..482d249ca7f3 100644
--- a/drivers/media/dvb/dvb-usb/it913x.c
+++ b/drivers/media/dvb/dvb-usb/it913x.c
@@ -238,12 +238,27 @@ static int it913x_read_reg(struct usb_device *udev, u32 reg)
238 238
239static u32 it913x_query(struct usb_device *udev, u8 pro) 239static u32 it913x_query(struct usb_device *udev, u8 pro)
240{ 240{
241 int ret; 241 int ret, i;
242 u8 data[4]; 242 u8 data[4];
243 ret = it913x_io(udev, READ_LONG, pro, CMD_DEMOD_READ, 243 u8 ver;
244 0x1222, 0, &data[0], 3); 244
245 for (i = 0; i < 5; i++) {
246 ret = it913x_io(udev, READ_LONG, pro, CMD_DEMOD_READ,
247 0x1222, 0, &data[0], 3);
248 ver = data[0];
249 if (ver > 0 && ver < 3)
250 break;
251 msleep(100);
252 }
245 253
246 it913x_config.chip_ver = data[0]; 254 if (ver < 1 || ver > 2) {
255 info("Failed to identify chip version applying 1");
256 it913x_config.chip_ver = 0x1;
257 it913x_config.chip_type = 0x9135;
258 return 0;
259 }
260
261 it913x_config.chip_ver = ver;
247 it913x_config.chip_type = (u16)(data[2] << 8) + data[1]; 262 it913x_config.chip_type = (u16)(data[2] << 8) + data[1];
248 263
249 info("Chip Version=%02x Chip Type=%04x", it913x_config.chip_ver, 264 info("Chip Version=%02x Chip Type=%04x", it913x_config.chip_ver,
@@ -660,30 +675,41 @@ static int it913x_download_firmware(struct usb_device *udev,
660 if ((packet_size > min_pkt) || (i == fw->size)) { 675 if ((packet_size > min_pkt) || (i == fw->size)) {
661 fw_data = (u8 *)(fw->data + pos); 676 fw_data = (u8 *)(fw->data + pos);
662 pos += packet_size; 677 pos += packet_size;
663 if (packet_size > 0) 678 if (packet_size > 0) {
664 ret |= it913x_io(udev, WRITE_DATA, 679 ret = it913x_io(udev, WRITE_DATA,
665 DEV_0, CMD_SCATTER_WRITE, 0, 680 DEV_0, CMD_SCATTER_WRITE, 0,
666 0, fw_data, packet_size); 681 0, fw_data, packet_size);
682 if (ret < 0)
683 break;
684 }
667 udelay(1000); 685 udelay(1000);
668 } 686 }
669 } 687 }
670 i++; 688 i++;
671 } 689 }
672 690
673 ret |= it913x_io(udev, WRITE_CMD, DEV_0, CMD_BOOT, 0, 0, NULL, 0);
674
675 msleep(100);
676
677 if (ret < 0) 691 if (ret < 0)
678 info("FRM Firmware Download Failed (%04x)" , ret); 692 info("FRM Firmware Download Failed (%d)" , ret);
679 else 693 else
680 info("FRM Firmware Download Completed - Resetting Device"); 694 info("FRM Firmware Download Completed - Resetting Device");
681 695
682 ret |= it913x_return_status(udev); 696 msleep(30);
697
698 ret = it913x_io(udev, WRITE_CMD, DEV_0, CMD_BOOT, 0, 0, NULL, 0);
699 if (ret < 0)
700 info("FRM Device not responding to reboot");
701
702 ret = it913x_return_status(udev);
703 if (ret == 0) {
704 info("FRM Failed to reboot device");
705 return -ENODEV;
706 }
683 707
684 msleep(30); 708 msleep(30);
685 709
686 ret |= it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_400); 710 ret = it913x_wr_reg(udev, DEV_0, I2C_CLK, I2C_CLK_400);
711
712 msleep(30);
687 713
688 /* Tuner function */ 714 /* Tuner function */
689 if (it913x_config.dual_mode) 715 if (it913x_config.dual_mode)
@@ -901,5 +927,5 @@ module_usb_driver(it913x_driver);
901 927
902MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>"); 928MODULE_AUTHOR("Malcolm Priestley <tvboxspy@gmail.com>");
903MODULE_DESCRIPTION("it913x USB 2 Driver"); 929MODULE_DESCRIPTION("it913x USB 2 Driver");
904MODULE_VERSION("1.27"); 930MODULE_VERSION("1.28");
905MODULE_LICENSE("GPL"); 931MODULE_LICENSE("GPL");