提交 97727600 编写于 作者: V Virupax Sadashivpetimath 提交者: Ben Dooks

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: NVirupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com>
Reviewed-by: NSrinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NBen Dooks <ben-linux@fluff.org>
上级 a20d2394
...@@ -24,13 +24,15 @@ enum i2c_freq_mode { ...@@ -24,13 +24,15 @@ enum i2c_freq_mode {
* to the values of 14, 6, 2 for a 48 MHz i2c clk * to the values of 14, 6, 2 for a 48 MHz i2c clk
* @tft: Tx FIFO Threshold in bytes * @tft: Tx FIFO Threshold in bytes
* @rft: Rx FIFO Threshold in bytes * @rft: Rx FIFO Threshold in bytes
* @timeout Slave response timeout(ms)
* @sm: speed mode * @sm: speed mode
*/ */
struct nmk_i2c_controller { struct nmk_i2c_controller {
unsigned long clk_freq; unsigned long clk_freq;
unsigned short slsu; unsigned short slsu;
unsigned char tft; unsigned char tft;
unsigned char rft; unsigned char rft;
int timeout;
enum i2c_freq_mode sm; enum i2c_freq_mode sm;
}; };
......
...@@ -121,9 +121,6 @@ enum i2c_operation { ...@@ -121,9 +121,6 @@ enum i2c_operation {
I2C_READ = 0x01 I2C_READ = 0x01
}; };
/* controller response timeout in ms */
#define I2C_TIMEOUT_MS 2000
/** /**
* struct i2c_nmk_client - client specific data * struct i2c_nmk_client - client specific data
* @slave_adr: 7-bit slave address * @slave_adr: 7-bit slave address
...@@ -213,7 +210,7 @@ static int flush_i2c_fifo(struct nmk_i2c_dev *dev) ...@@ -213,7 +210,7 @@ static int flush_i2c_fifo(struct nmk_i2c_dev *dev)
writel((I2C_CR_FTX | I2C_CR_FRX), dev->virtbase + I2C_CR); writel((I2C_CR_FTX | I2C_CR_FRX), dev->virtbase + I2C_CR);
for (i = 0; i < LOOP_ATTEMPTS; i++) { for (i = 0; i < LOOP_ATTEMPTS; i++) {
timeout = jiffies + msecs_to_jiffies(I2C_TIMEOUT_MS); timeout = jiffies + msecs_to_jiffies(dev->adap.timeout);
while (!time_after(jiffies, timeout)) { while (!time_after(jiffies, timeout)) {
if ((readl(dev->virtbase + I2C_CR) & if ((readl(dev->virtbase + I2C_CR) &
...@@ -434,7 +431,7 @@ static int read_i2c(struct nmk_i2c_dev *dev) ...@@ -434,7 +431,7 @@ static int read_i2c(struct nmk_i2c_dev *dev)
dev->virtbase + I2C_IMSCR); dev->virtbase + I2C_IMSCR);
timeout = wait_for_completion_interruptible_timeout( timeout = wait_for_completion_interruptible_timeout(
&dev->xfer_complete, msecs_to_jiffies(I2C_TIMEOUT_MS)); &dev->xfer_complete, msecs_to_jiffies(dev->adap.timeout));
if (timeout < 0) { if (timeout < 0) {
dev_err(&dev->pdev->dev, dev_err(&dev->pdev->dev,
...@@ -498,7 +495,7 @@ static int write_i2c(struct nmk_i2c_dev *dev) ...@@ -498,7 +495,7 @@ static int write_i2c(struct nmk_i2c_dev *dev)
dev->virtbase + I2C_IMSCR); dev->virtbase + I2C_IMSCR);
timeout = wait_for_completion_interruptible_timeout( timeout = wait_for_completion_interruptible_timeout(
&dev->xfer_complete, msecs_to_jiffies(I2C_TIMEOUT_MS)); &dev->xfer_complete, msecs_to_jiffies(dev->adap.timeout));
if (timeout < 0) { if (timeout < 0) {
dev_err(&dev->pdev->dev, dev_err(&dev->pdev->dev,
...@@ -917,6 +914,7 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev) ...@@ -917,6 +914,7 @@ static int __devinit nmk_i2c_probe(struct platform_device *pdev)
adap->owner = THIS_MODULE; adap->owner = THIS_MODULE;
adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
adap->algo = &nmk_i2c_algo; adap->algo = &nmk_i2c_algo;
adap->timeout = pdata->timeout ? pdata->timeout : 20000;
snprintf(adap->name, sizeof(adap->name), snprintf(adap->name, sizeof(adap->name),
"Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start); "Nomadik I2C%d at %lx", pdev->id, (unsigned long)res->start);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册