diff options
Diffstat (limited to 'drivers/i2c')
| -rw-r--r-- | drivers/i2c/busses/i2c-cpm.c | 5 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-davinci.c | 6 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-ibm_iic.c | 3 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-mpc.c | 1 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-octeon.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-omap.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-pca-isa.c | 12 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-pca-platform.c | 11 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-s3c2410.c | 4 | ||||
| -rw-r--r-- | drivers/i2c/i2c-core.c | 54 |
10 files changed, 56 insertions, 44 deletions
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c index f7bd2613cecc..f2de3be35df3 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c | |||
| @@ -677,6 +677,11 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev, | |||
| 677 | dev_dbg(&ofdev->dev, "hw routines for %s registered.\n", | 677 | dev_dbg(&ofdev->dev, "hw routines for %s registered.\n", |
| 678 | cpm->adap.name); | 678 | cpm->adap.name); |
| 679 | 679 | ||
| 680 | /* | ||
| 681 | * register OF I2C devices | ||
| 682 | */ | ||
| 683 | of_i2c_register_devices(&cpm->adap); | ||
| 684 | |||
| 680 | return 0; | 685 | return 0; |
| 681 | out_shut: | 686 | out_shut: |
| 682 | cpm_i2c_shutdown(cpm); | 687 | cpm_i2c_shutdown(cpm); |
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index 2222c87876b9..b8feac5f2ef4 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c | |||
| @@ -357,9 +357,6 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) | |||
| 357 | 357 | ||
| 358 | dev->terminate = 0; | 358 | dev->terminate = 0; |
| 359 | 359 | ||
| 360 | /* write the data into mode register */ | ||
| 361 | davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); | ||
| 362 | |||
| 363 | /* | 360 | /* |
| 364 | * First byte should be set here, not after interrupt, | 361 | * First byte should be set here, not after interrupt, |
| 365 | * because transmit-data-ready interrupt can come before | 362 | * because transmit-data-ready interrupt can come before |
| @@ -371,6 +368,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop) | |||
| 371 | dev->buf_len--; | 368 | dev->buf_len--; |
| 372 | } | 369 | } |
| 373 | 370 | ||
| 371 | /* write the data into mode register; start transmitting */ | ||
| 372 | davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); | ||
| 373 | |||
| 374 | r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, | 374 | r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, |
| 375 | dev->adapter.timeout); | 375 | dev->adapter.timeout); |
| 376 | if (r == 0) { | 376 | if (r == 0) { |
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index 43ca32fddde2..89eedf45d30e 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c | |||
| @@ -761,6 +761,9 @@ static int __devinit iic_probe(struct platform_device *ofdev, | |||
| 761 | dev_info(&ofdev->dev, "using %s mode\n", | 761 | dev_info(&ofdev->dev, "using %s mode\n", |
| 762 | dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)"); | 762 | dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)"); |
| 763 | 763 | ||
| 764 | /* Now register all the child nodes */ | ||
| 765 | of_i2c_register_devices(adap); | ||
| 766 | |||
| 764 | return 0; | 767 | return 0; |
| 765 | 768 | ||
| 766 | error_cleanup: | 769 | error_cleanup: |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index a1c419a716af..b74e6dc6886c 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
| @@ -632,6 +632,7 @@ static int __devinit fsl_i2c_probe(struct platform_device *op, | |||
| 632 | dev_err(i2c->dev, "failed to add adapter\n"); | 632 | dev_err(i2c->dev, "failed to add adapter\n"); |
| 633 | goto fail_add; | 633 | goto fail_add; |
| 634 | } | 634 | } |
| 635 | of_i2c_register_devices(&i2c->adap); | ||
| 635 | 636 | ||
| 636 | return result; | 637 | return result; |
| 637 | 638 | ||
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c index 0e9f85d0a835..56dbe54e8811 100644 --- a/drivers/i2c/busses/i2c-octeon.c +++ b/drivers/i2c/busses/i2c-octeon.c | |||
| @@ -218,7 +218,7 @@ static int octeon_i2c_wait(struct octeon_i2c *i2c) | |||
| 218 | return result; | 218 | return result; |
| 219 | } else if (result == 0) { | 219 | } else if (result == 0) { |
| 220 | dev_dbg(i2c->dev, "%s: timeout\n", __func__); | 220 | dev_dbg(i2c->dev, "%s: timeout\n", __func__); |
| 221 | result = -ETIMEDOUT; | 221 | return -ETIMEDOUT; |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | return 0; | 224 | return 0; |
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 7674efb55378..b33c78586bfc 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
| @@ -680,6 +680,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) | |||
| 680 | 680 | ||
| 681 | if (r == 0) | 681 | if (r == 0) |
| 682 | r = num; | 682 | r = num; |
| 683 | |||
| 684 | omap_i2c_wait_for_bb(dev); | ||
| 683 | out: | 685 | out: |
| 684 | omap_i2c_idle(dev); | 686 | omap_i2c_idle(dev); |
| 685 | return r; | 687 | return r; |
diff --git a/drivers/i2c/busses/i2c-pca-isa.c b/drivers/i2c/busses/i2c-pca-isa.c index bbd77603a417..29933f87d8fa 100644 --- a/drivers/i2c/busses/i2c-pca-isa.c +++ b/drivers/i2c/busses/i2c-pca-isa.c | |||
| @@ -71,8 +71,8 @@ static int pca_isa_readbyte(void *pd, int reg) | |||
| 71 | 71 | ||
| 72 | static int pca_isa_waitforcompletion(void *pd) | 72 | static int pca_isa_waitforcompletion(void *pd) |
| 73 | { | 73 | { |
| 74 | long ret = ~0; | ||
| 75 | unsigned long timeout; | 74 | unsigned long timeout; |
| 75 | long ret; | ||
| 76 | 76 | ||
| 77 | if (irq > -1) { | 77 | if (irq > -1) { |
| 78 | ret = wait_event_timeout(pca_wait, | 78 | ret = wait_event_timeout(pca_wait, |
| @@ -81,11 +81,15 @@ static int pca_isa_waitforcompletion(void *pd) | |||
| 81 | } else { | 81 | } else { |
| 82 | /* Do polling */ | 82 | /* Do polling */ |
| 83 | timeout = jiffies + pca_isa_ops.timeout; | 83 | timeout = jiffies + pca_isa_ops.timeout; |
| 84 | while (((pca_isa_readbyte(pd, I2C_PCA_CON) | 84 | do { |
| 85 | & I2C_PCA_CON_SI) == 0) | 85 | ret = time_before(jiffies, timeout); |
| 86 | && (ret = time_before(jiffies, timeout))) | 86 | if (pca_isa_readbyte(pd, I2C_PCA_CON) |
| 87 | & I2C_PCA_CON_SI) | ||
| 88 | break; | ||
| 87 | udelay(100); | 89 | udelay(100); |
| 90 | } while (ret); | ||
| 88 | } | 91 | } |
| 92 | |||
| 89 | return ret > 0; | 93 | return ret > 0; |
| 90 | } | 94 | } |
| 91 | 95 | ||
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c index ef5c78487eb7..5f6d7f89e225 100644 --- a/drivers/i2c/busses/i2c-pca-platform.c +++ b/drivers/i2c/busses/i2c-pca-platform.c | |||
| @@ -80,8 +80,8 @@ static void i2c_pca_pf_writebyte32(void *pd, int reg, int val) | |||
| 80 | static int i2c_pca_pf_waitforcompletion(void *pd) | 80 | static int i2c_pca_pf_waitforcompletion(void *pd) |
| 81 | { | 81 | { |
| 82 | struct i2c_pca_pf_data *i2c = pd; | 82 | struct i2c_pca_pf_data *i2c = pd; |
| 83 | long ret = ~0; | ||
| 84 | unsigned long timeout; | 83 | unsigned long timeout; |
| 84 | long ret; | ||
| 85 | 85 | ||
| 86 | if (i2c->irq) { | 86 | if (i2c->irq) { |
| 87 | ret = wait_event_timeout(i2c->wait, | 87 | ret = wait_event_timeout(i2c->wait, |
| @@ -90,10 +90,13 @@ static int i2c_pca_pf_waitforcompletion(void *pd) | |||
| 90 | } else { | 90 | } else { |
| 91 | /* Do polling */ | 91 | /* Do polling */ |
| 92 | timeout = jiffies + i2c->adap.timeout; | 92 | timeout = jiffies + i2c->adap.timeout; |
| 93 | while (((i2c->algo_data.read_byte(i2c, I2C_PCA_CON) | 93 | do { |
| 94 | & I2C_PCA_CON_SI) == 0) | 94 | ret = time_before(jiffies, timeout); |
| 95 | && (ret = time_before(jiffies, timeout))) | 95 | if (i2c->algo_data.read_byte(i2c, I2C_PCA_CON) |
| 96 | & I2C_PCA_CON_SI) | ||
| 97 | break; | ||
| 96 | udelay(100); | 98 | udelay(100); |
| 99 | } while (ret); | ||
| 97 | } | 100 | } |
| 98 | 101 | ||
| 99 | return ret > 0; | 102 | return ret > 0; |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 72902e0bbfa7..bf831bf81587 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
| @@ -662,8 +662,8 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got) | |||
| 662 | unsigned long sda_delay; | 662 | unsigned long sda_delay; |
| 663 | 663 | ||
| 664 | if (pdata->sda_delay) { | 664 | if (pdata->sda_delay) { |
| 665 | sda_delay = (freq / 1000) * pdata->sda_delay; | 665 | sda_delay = clkin * pdata->sda_delay; |
| 666 | sda_delay /= 1000000; | 666 | sda_delay = DIV_ROUND_UP(sda_delay, 1000000); |
| 667 | sda_delay = DIV_ROUND_UP(sda_delay, 5); | 667 | sda_delay = DIV_ROUND_UP(sda_delay, 5); |
| 668 | if (sda_delay > 3) | 668 | if (sda_delay > 3) |
| 669 | sda_delay = 3; | 669 | sda_delay = 3; |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 6649176de940..bea4c5021d26 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
| @@ -32,7 +32,6 @@ | |||
| 32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
| 33 | #include <linux/idr.h> | 33 | #include <linux/idr.h> |
| 34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
| 35 | #include <linux/of_i2c.h> | ||
| 36 | #include <linux/of_device.h> | 35 | #include <linux/of_device.h> |
| 37 | #include <linux/completion.h> | 36 | #include <linux/completion.h> |
| 38 | #include <linux/hardirq.h> | 37 | #include <linux/hardirq.h> |
| @@ -197,11 +196,12 @@ static int i2c_device_pm_suspend(struct device *dev) | |||
| 197 | { | 196 | { |
| 198 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 197 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
| 199 | 198 | ||
| 200 | if (pm_runtime_suspended(dev)) | 199 | if (pm) { |
| 201 | return 0; | 200 | if (pm_runtime_suspended(dev)) |
| 202 | 201 | return 0; | |
| 203 | if (pm) | 202 | else |
| 204 | return pm->suspend ? pm->suspend(dev) : 0; | 203 | return pm->suspend ? pm->suspend(dev) : 0; |
| 204 | } | ||
| 205 | 205 | ||
| 206 | return i2c_legacy_suspend(dev, PMSG_SUSPEND); | 206 | return i2c_legacy_suspend(dev, PMSG_SUSPEND); |
| 207 | } | 207 | } |
| @@ -216,12 +216,6 @@ static int i2c_device_pm_resume(struct device *dev) | |||
| 216 | else | 216 | else |
| 217 | ret = i2c_legacy_resume(dev); | 217 | ret = i2c_legacy_resume(dev); |
| 218 | 218 | ||
| 219 | if (!ret) { | ||
| 220 | pm_runtime_disable(dev); | ||
| 221 | pm_runtime_set_active(dev); | ||
| 222 | pm_runtime_enable(dev); | ||
| 223 | } | ||
| 224 | |||
| 225 | return ret; | 219 | return ret; |
| 226 | } | 220 | } |
| 227 | 221 | ||
| @@ -229,11 +223,12 @@ static int i2c_device_pm_freeze(struct device *dev) | |||
| 229 | { | 223 | { |
| 230 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 224 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
| 231 | 225 | ||
| 232 | if (pm_runtime_suspended(dev)) | 226 | if (pm) { |
| 233 | return 0; | 227 | if (pm_runtime_suspended(dev)) |
| 234 | 228 | return 0; | |
| 235 | if (pm) | 229 | else |
| 236 | return pm->freeze ? pm->freeze(dev) : 0; | 230 | return pm->freeze ? pm->freeze(dev) : 0; |
| 231 | } | ||
| 237 | 232 | ||
| 238 | return i2c_legacy_suspend(dev, PMSG_FREEZE); | 233 | return i2c_legacy_suspend(dev, PMSG_FREEZE); |
| 239 | } | 234 | } |
| @@ -242,11 +237,12 @@ static int i2c_device_pm_thaw(struct device *dev) | |||
| 242 | { | 237 | { |
| 243 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 238 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
| 244 | 239 | ||
| 245 | if (pm_runtime_suspended(dev)) | 240 | if (pm) { |
| 246 | return 0; | 241 | if (pm_runtime_suspended(dev)) |
| 247 | 242 | return 0; | |
| 248 | if (pm) | 243 | else |
| 249 | return pm->thaw ? pm->thaw(dev) : 0; | 244 | return pm->thaw ? pm->thaw(dev) : 0; |
| 245 | } | ||
| 250 | 246 | ||
| 251 | return i2c_legacy_resume(dev); | 247 | return i2c_legacy_resume(dev); |
| 252 | } | 248 | } |
| @@ -255,11 +251,12 @@ static int i2c_device_pm_poweroff(struct device *dev) | |||
| 255 | { | 251 | { |
| 256 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; | 252 | const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; |
| 257 | 253 | ||
| 258 | if (pm_runtime_suspended(dev)) | 254 | if (pm) { |
| 259 | return 0; | 255 | if (pm_runtime_suspended(dev)) |
| 260 | 256 | return 0; | |
| 261 | if (pm) | 257 | else |
| 262 | return pm->poweroff ? pm->poweroff(dev) : 0; | 258 | return pm->poweroff ? pm->poweroff(dev) : 0; |
| 259 | } | ||
| 263 | 260 | ||
| 264 | return i2c_legacy_suspend(dev, PMSG_HIBERNATE); | 261 | return i2c_legacy_suspend(dev, PMSG_HIBERNATE); |
| 265 | } | 262 | } |
| @@ -876,9 +873,6 @@ static int i2c_register_adapter(struct i2c_adapter *adap) | |||
| 876 | if (adap->nr < __i2c_first_dynamic_bus_num) | 873 | if (adap->nr < __i2c_first_dynamic_bus_num) |
| 877 | i2c_scan_static_board_info(adap); | 874 | i2c_scan_static_board_info(adap); |
| 878 | 875 | ||
| 879 | /* Register devices from the device tree */ | ||
| 880 | of_i2c_register_devices(adap); | ||
| 881 | |||
| 882 | /* Notify drivers */ | 876 | /* Notify drivers */ |
| 883 | mutex_lock(&core_lock); | 877 | mutex_lock(&core_lock); |
| 884 | bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter); | 878 | bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter); |
