diff options
-rw-r--r-- | drivers/media/dvb/frontends/tda1004x.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index 1465ff77b0cb..4981cef8b444 100644 --- a/drivers/media/dvb/frontends/tda1004x.c +++ b/drivers/media/dvb/frontends/tda1004x.c | |||
@@ -162,7 +162,7 @@ static int tda1004x_read_byte(struct tda1004x_state *state, int reg) | |||
162 | if (ret != 2) { | 162 | if (ret != 2) { |
163 | dprintk("%s: error reg=0x%x, ret=%i\n", __func__, reg, | 163 | dprintk("%s: error reg=0x%x, ret=%i\n", __func__, reg, |
164 | ret); | 164 | ret); |
165 | return -1; | 165 | return -EINVAL; |
166 | } | 166 | } |
167 | 167 | ||
168 | dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __func__, | 168 | dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __func__, |
@@ -481,16 +481,18 @@ static void tda10046_init_plls(struct dvb_frontend* fe) | |||
481 | static int tda10046_fwupload(struct dvb_frontend* fe) | 481 | static int tda10046_fwupload(struct dvb_frontend* fe) |
482 | { | 482 | { |
483 | struct tda1004x_state* state = fe->demodulator_priv; | 483 | struct tda1004x_state* state = fe->demodulator_priv; |
484 | int ret; | 484 | int ret, confc4; |
485 | const struct firmware *fw; | 485 | const struct firmware *fw; |
486 | 486 | ||
487 | /* reset + wake up chip */ | 487 | /* reset + wake up chip */ |
488 | if (state->config->xtal_freq == TDA10046_XTAL_4M) { | 488 | if (state->config->xtal_freq == TDA10046_XTAL_4M) { |
489 | tda1004x_write_byteI(state, TDA1004X_CONFC4, 0); | 489 | confc4 = 0; |
490 | } else { | 490 | } else { |
491 | dprintk("%s: 16MHz Xtal, reducing I2C speed\n", __func__); | 491 | dprintk("%s: 16MHz Xtal, reducing I2C speed\n", __func__); |
492 | tda1004x_write_byteI(state, TDA1004X_CONFC4, 0x80); | 492 | confc4 = 0x80; |
493 | } | 493 | } |
494 | tda1004x_write_byteI(state, TDA1004X_CONFC4, confc4); | ||
495 | |||
494 | tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0); | 496 | tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0); |
495 | /* set GPIO 1 and 3 */ | 497 | /* set GPIO 1 and 3 */ |
496 | if (state->config->gpio_config != TDA10046_GPTRI) { | 498 | if (state->config->gpio_config != TDA10046_GPTRI) { |
@@ -508,13 +510,29 @@ static int tda10046_fwupload(struct dvb_frontend* fe) | |||
508 | if (tda1004x_check_upload_ok(state) == 0) | 510 | if (tda1004x_check_upload_ok(state) == 0) |
509 | return 0; | 511 | return 0; |
510 | 512 | ||
513 | /* | ||
514 | For i2c normal work, we need to slow down the bus speed. | ||
515 | However, the slow down breaks the eeprom firmware load. | ||
516 | So, use normal speed for eeprom booting and then restore the | ||
517 | i2c speed after that. Tested with MSI TV @nyware A/D board, | ||
518 | that comes with firmware version 29 inside their eeprom. | ||
519 | |||
520 | It should also be noticed that no other I2C transfer should | ||
521 | be in course while booting from eeprom, otherwise, tda10046 | ||
522 | goes into an instable state. So, proper locking are needed | ||
523 | at the i2c bus master. | ||
524 | */ | ||
511 | printk(KERN_INFO "tda1004x: trying to boot from eeprom\n"); | 525 | printk(KERN_INFO "tda1004x: trying to boot from eeprom\n"); |
512 | tda1004x_write_mask(state, TDA1004X_CONFC4, 4, 4); | 526 | tda1004x_write_byteI(state, TDA1004X_CONFC4, 4); |
513 | msleep(300); | 527 | msleep(300); |
514 | /* don't re-upload unless necessary */ | 528 | tda1004x_write_byteI(state, TDA1004X_CONFC4, confc4); |
529 | |||
530 | /* Checks if eeprom firmware went without troubles */ | ||
515 | if (tda1004x_check_upload_ok(state) == 0) | 531 | if (tda1004x_check_upload_ok(state) == 0) |
516 | return 0; | 532 | return 0; |
517 | 533 | ||
534 | /* eeprom firmware didn't work. Load one manually. */ | ||
535 | |||
518 | if (state->config->request_firmware != NULL) { | 536 | if (state->config->request_firmware != NULL) { |
519 | /* request the firmware, this will block until someone uploads it */ | 537 | /* request the firmware, this will block until someone uploads it */ |
520 | printk(KERN_INFO "tda1004x: waiting for firmware upload...\n"); | 538 | printk(KERN_INFO "tda1004x: waiting for firmware upload...\n"); |