diff options
author | Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com> | 2011-05-13 06:29:12 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2011-05-24 19:20:13 -0400 |
commit | 9772760079253cd9a428434b43d415d18b152332 (patch) | |
tree | 1379806baba2f945e656bd8f86db91f2398c4bfc | |
parent | a20d23945f30ec701a544fdd90d6537f4041af6f (diff) |
i2c-nomadik: make i2c timeout specific per i2c bus
Add option to have different i2c timeout delay for different i2c buses
specified in platform data. Default to the old value unless specified.
Signed-off-by: Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com>
Reviewed-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
-rw-r--r-- | arch/arm/plat-nomadik/include/plat/i2c.h | 6 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-nomadik.c | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/arch/arm/plat-nomadik/include/plat/i2c.h b/arch/arm/plat-nomadik/include/plat/i2c.h index 1621db67a53d..4ed4e27d1368 100644 --- a/arch/arm/plat-nomadik/include/plat/i2c.h +++ b/arch/arm/plat-nomadik/include/plat/i2c.h | |||
@@ -24,13 +24,15 @@ enum i2c_freq_mode { | |||
24 | * to the values of 14, 6, 2 for a 48 MHz i2c clk | 24 | * to the values of 14, 6, 2 for a 48 MHz i2c clk |
25 | * @tft: Tx FIFO Threshold in bytes | 25 | * @tft: Tx FIFO Threshold in bytes |
26 | * @rft: Rx FIFO Threshold in bytes | 26 | * @rft: Rx FIFO Threshold in bytes |
27 | * @timeout Slave response timeout(ms) | ||
27 | * @sm: speed mode | 28 | * @sm: speed mode |
28 | */ | 29 | */ |
29 | struct nmk_i2c_controller { | 30 | struct nmk_i2c_controller { |
30 | unsigned long clk_freq; | 31 | unsigned long clk_freq; |
31 | unsigned short slsu; | 32 | unsigned short slsu; |
32 | unsigned char tft; | 33 | unsigned char tft; |
33 | unsigned char rft; | 34 | unsigned char rft; |
35 | int timeout; | ||
34 | enum i2c_freq_mode sm; | 36 | enum i2c_freq_mode sm; |
35 | }; | 37 | }; |
36 | 38 | ||
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 182761eace80..3bf95b90abae 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c | |||
@@ -121,9 +121,6 @@ enum i2c_operation { | |||
121 | I2C_READ = 0x01 | 121 | I2C_READ = 0x01 |
122 | }; | 122 | }; |
123 | 123 | ||
124 | /* controller response timeout in ms */ | ||
125 | #define I2C_TIMEOUT_MS 2000 | ||
126 | |||
127 | /** | 124 | /** |
128 | * struct i2c_nmk_client - client specific data | 125 | * struct i2c_nmk_client - client specific data |
129 | * @slave_adr: 7-bit slave address | 126 | * @slave_adr: 7-bit slave address |
@@ -213,7 +210,7 @@ static int flush_i2c_fifo(struct nmk_i2c_dev *dev) | |||
213 | writel((I2C_CR_FTX | I2C_CR_FRX), dev->virtbase + I2C_CR); | 210 | writel((I2C_CR_FTX | I2C_CR_FRX), dev->virtbase + I2C_CR); |
214 | 211 | ||
215 | for (i = 0; i < LOOP_ATTEMPTS; i++) { | 212 | for (i = 0; i < LOOP_ATTEMPTS; i++) { |
216 | timeout = jiffies + msecs_to_jiffies(I2C_TIMEOUT_MS); | 213 | timeout = jiffies + msecs_to_jiffies(dev->adap.timeout); |
217 | 214 | ||
218 | while (!time_after(jiffies, timeout)) { | 215 | while (!time_after(jiffies, timeout)) { |
219 | if ((readl(dev->virtbase + I2C_CR) & | 216 | if ((readl(dev->virtbase + I2C_CR) & |
@@ -434,7 +431,7 @@ static int read_i2c(struct nmk_i2c_dev *dev) | |||
434 | dev->virtbase + I2C_IMSCR); | 431 | dev->virtbase + I2C_IMSCR); |
435 | 432 | ||
436 | timeout = wait_for_completion_interruptible_timeout( | 433 | timeout = wait_for_completion_interruptible_timeout( |
437 | &dev->xfer_complete, msecs_to_jiffies(I2C_TIMEOUT_MS)); | 434 | &dev->xfer_complete, msecs_to_jiffies(dev->adap.timeout)); |
438 | 435 | ||
439 | if (timeout < 0) { | 436 | if (timeout < 0) { |
440 | dev_err(&dev->pdev->dev, | 437 | dev_err(&dev->pdev->dev, |
@@ -498,7 +495,7 @@ static int write_i2c(struct nmk_i2c_dev *dev) | |||
498 | dev->virtbase + I2C_IMSCR); | 495 | dev->virtbase + I2C_IMSCR); |
499 | 496 | ||
500 | timeout = wait_for_completion_interruptible_timeout( | 497 | timeout = wait_for_completion_interruptible_timeout( |
501 | &dev->xfer_complete, msecs_to_jiffies(I2C_TIMEOUT_MS)); | 498 | &dev->xfer_complete, msecs_to_jiffies(dev->adap.timeout)); |
502 | 499 | ||
503 | if (timeout < 0) { | 500 | if (timeout < 0) { |
504 | dev_err(&dev->pdev->dev, | 501 | dev_err(&dev->pdev->dev, |
@@ -917,6 +914,7 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) | |||
917 | adap->owner = THIS_MODULE; | 914 | adap->owner = THIS_MODULE; |
918 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; | 915 | adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; |
919 | adap->algo = &nmk_i2c_algo; | 916 | adap->algo = &nmk_i2c_algo; |
917 | adap->timeout = pdata->timeout ? pdata->timeout : 20000; | ||
920 | snprintf(adap->name, sizeof(adap->name), | 918 | snprintf(adap->name, sizeof(adap->name), |
921 | "Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start); | 919 | "Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start); |
922 | 920 | ||