diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-nomadik.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index b49ff25a2688..e3cd62e40df5 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c | |||
@@ -447,6 +447,24 @@ static int read_i2c(struct nmk_i2c_dev *dev) | |||
447 | return status; | 447 | return status; |
448 | } | 448 | } |
449 | 449 | ||
450 | static void fill_tx_fifo(struct nmk_i2c_dev *dev, int no_bytes) | ||
451 | { | ||
452 | int count; | ||
453 | |||
454 | for (count = (no_bytes - 2); | ||
455 | (count > 0) && | ||
456 | (dev->cli.count != 0); | ||
457 | count--) { | ||
458 | /* write to the Tx FIFO */ | ||
459 | writeb(*dev->cli.buffer, | ||
460 | dev->virtbase + I2C_TFR); | ||
461 | dev->cli.buffer++; | ||
462 | dev->cli.count--; | ||
463 | dev->cli.xfer_bytes++; | ||
464 | } | ||
465 | |||
466 | } | ||
467 | |||
450 | /** | 468 | /** |
451 | * write_i2c() - Write data to I2C client. | 469 | * write_i2c() - Write data to I2C client. |
452 | * @dev: private data of I2C Driver | 470 | * @dev: private data of I2C Driver |
@@ -474,8 +492,13 @@ static int write_i2c(struct nmk_i2c_dev *dev) | |||
474 | init_completion(&dev->xfer_complete); | 492 | init_completion(&dev->xfer_complete); |
475 | 493 | ||
476 | /* enable interrupts by settings the masks */ | 494 | /* enable interrupts by settings the masks */ |
477 | irq_mask = (I2C_IT_TXFNE | I2C_IT_TXFOVR | | 495 | irq_mask = (I2C_IT_TXFOVR | I2C_IT_MAL | I2C_IT_BERR); |
478 | I2C_IT_MAL | I2C_IT_BERR); | 496 | |
497 | /* Fill the TX FIFO with transmit data */ | ||
498 | fill_tx_fifo(dev, MAX_I2C_FIFO_THRESHOLD); | ||
499 | |||
500 | if (dev->cli.count != 0) | ||
501 | irq_mask |= I2C_IT_TXFNE; | ||
479 | 502 | ||
480 | /* | 503 | /* |
481 | * check if we want to transfer a single or multiple bytes, if so | 504 | * check if we want to transfer a single or multiple bytes, if so |
@@ -702,17 +725,7 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg) | |||
702 | */ | 725 | */ |
703 | disable_interrupts(dev, I2C_IT_TXFNE); | 726 | disable_interrupts(dev, I2C_IT_TXFNE); |
704 | } else { | 727 | } else { |
705 | for (count = (MAX_I2C_FIFO_THRESHOLD - tft - 2); | 728 | fill_tx_fifo(dev, (MAX_I2C_FIFO_THRESHOLD - tft)); |
706 | (count > 0) && | ||
707 | (dev->cli.count != 0); | ||
708 | count--) { | ||
709 | /* write to the Tx FIFO */ | ||
710 | writeb(*dev->cli.buffer, | ||
711 | dev->virtbase + I2C_TFR); | ||
712 | dev->cli.buffer++; | ||
713 | dev->cli.count--; | ||
714 | dev->cli.xfer_bytes++; | ||
715 | } | ||
716 | /* | 729 | /* |
717 | * if done, close the transfer by disabling the | 730 | * if done, close the transfer by disabling the |
718 | * corresponding TXFNE interrupt | 731 | * corresponding TXFNE interrupt |