diff options
author | Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com> | 2011-05-13 06:30:34 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2011-05-24 19:20:47 -0400 |
commit | 553553413a6abdda220a697ef439ba2f4b1d4a7c (patch) | |
tree | 7f3ea5e0f05c9cd00cb845e458f13ea1c5e968fd | |
parent | ebd10e0783d9fb92a147e60902e22c2d3f3ad69d (diff) |
i2c-nomadik: change the TX and RX threshold
1) Increase RX FIFO threshold so that there is a reduction in
the number of interrupts handled to complete a transaction.
2) Fill TX FIFO in the write function.
Signed-off-by: Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com>
Reviewed-by: Jonas Aberg <jonas.aberg@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
-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 |