diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-31 13:34:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-01-31 13:34:25 -0500 |
commit | 788807d7ca3821b5ea835a588a52d55631c17e18 (patch) | |
tree | c6e96d872f801de74dff20fd08635b8830de4473 | |
parent | 2141fd018156db0f29efb384f4d99ead23b48f18 (diff) | |
parent | 32e224090fa310a58fdb47049caf631272ceb044 (diff) |
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang:
"i2c driver bugfixes (s3c2410, slave-eeprom, sh_mobile), size
regression "bugfix" (i2c slave), documentation bugfix (st).
Also, one documentation update (da9063), so some devicetrees can now
be verified"
* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: sh_mobile: terminate DMA reads properly
i2c: Only include slave support if selected
i2c: s3c2410: fix ABBA deadlock by keeping clock prepared
i2c: slave-eeprom: fix boundary check when using sysfs
i2c: st: Rename clock reference to something that exists
DT: i2c: Add devices handled by the da9063 MFD driver
-rw-r--r-- | Documentation/devicetree/bindings/i2c/i2c-st.txt | 2 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/i2c/trivial-devices.txt | 1 | ||||
-rw-r--r-- | drivers/i2c/busses/Kconfig | 1 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-s3c2410.c | 23 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-sh_mobile.c | 12 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 2 | ||||
-rw-r--r-- | drivers/i2c/i2c-slave-eeprom.c | 4 | ||||
-rw-r--r-- | include/linux/i2c.h | 6 |
8 files changed, 41 insertions, 10 deletions
diff --git a/Documentation/devicetree/bindings/i2c/i2c-st.txt b/Documentation/devicetree/bindings/i2c/i2c-st.txt index 437e0db3823c..4c26fda3844a 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-st.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-st.txt | |||
@@ -31,7 +31,7 @@ i2c0: i2c@fed40000 { | |||
31 | compatible = "st,comms-ssc4-i2c"; | 31 | compatible = "st,comms-ssc4-i2c"; |
32 | reg = <0xfed40000 0x110>; | 32 | reg = <0xfed40000 0x110>; |
33 | interrupts = <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>; | 33 | interrupts = <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>; |
34 | clocks = <&CLK_S_ICN_REG_0>; | 34 | clocks = <&clk_s_a0_ls CLK_ICN_REG>; |
35 | clock-names = "ssc"; | 35 | clock-names = "ssc"; |
36 | clock-frequency = <400000>; | 36 | clock-frequency = <400000>; |
37 | pinctrl-names = "default"; | 37 | pinctrl-names = "default"; |
diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt index 9f4e3824e71e..9f41d05be3be 100644 --- a/Documentation/devicetree/bindings/i2c/trivial-devices.txt +++ b/Documentation/devicetree/bindings/i2c/trivial-devices.txt | |||
@@ -47,6 +47,7 @@ dallas,ds3232 Extremely Accurate I²C RTC with Integrated Crystal and SRAM | |||
47 | dallas,ds4510 CPU Supervisor with Nonvolatile Memory and Programmable I/O | 47 | dallas,ds4510 CPU Supervisor with Nonvolatile Memory and Programmable I/O |
48 | dallas,ds75 Digital Thermometer and Thermostat | 48 | dallas,ds75 Digital Thermometer and Thermostat |
49 | dlg,da9053 DA9053: flexible system level PMIC with multicore support | 49 | dlg,da9053 DA9053: flexible system level PMIC with multicore support |
50 | dlg,da9063 DA9063: system PMIC for quad-core application processors | ||
50 | epson,rx8025 High-Stability. I2C-Bus INTERFACE REAL TIME CLOCK MODULE | 51 | epson,rx8025 High-Stability. I2C-Bus INTERFACE REAL TIME CLOCK MODULE |
51 | epson,rx8581 I2C-BUS INTERFACE REAL TIME CLOCK MODULE | 52 | epson,rx8581 I2C-BUS INTERFACE REAL TIME CLOCK MODULE |
52 | fsl,mag3110 MAG3110: Xtrinsic High Accuracy, 3D Magnetometer | 53 | fsl,mag3110 MAG3110: Xtrinsic High Accuracy, 3D Magnetometer |
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 31e8308ba899..ab838d9e28b6 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -881,6 +881,7 @@ config I2C_XLR | |||
881 | config I2C_RCAR | 881 | config I2C_RCAR |
882 | tristate "Renesas R-Car I2C Controller" | 882 | tristate "Renesas R-Car I2C Controller" |
883 | depends on ARCH_SHMOBILE || COMPILE_TEST | 883 | depends on ARCH_SHMOBILE || COMPILE_TEST |
884 | select I2C_SLAVE | ||
884 | help | 885 | help |
885 | If you say yes to this option, support will be included for the | 886 | If you say yes to this option, support will be included for the |
886 | R-Car I2C controller. | 887 | R-Car I2C controller. |
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index bff20a589621..958c8db4ec30 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c | |||
@@ -785,14 +785,16 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, | |||
785 | int ret; | 785 | int ret; |
786 | 786 | ||
787 | pm_runtime_get_sync(&adap->dev); | 787 | pm_runtime_get_sync(&adap->dev); |
788 | clk_prepare_enable(i2c->clk); | 788 | ret = clk_enable(i2c->clk); |
789 | if (ret) | ||
790 | return ret; | ||
789 | 791 | ||
790 | for (retry = 0; retry < adap->retries; retry++) { | 792 | for (retry = 0; retry < adap->retries; retry++) { |
791 | 793 | ||
792 | ret = s3c24xx_i2c_doxfer(i2c, msgs, num); | 794 | ret = s3c24xx_i2c_doxfer(i2c, msgs, num); |
793 | 795 | ||
794 | if (ret != -EAGAIN) { | 796 | if (ret != -EAGAIN) { |
795 | clk_disable_unprepare(i2c->clk); | 797 | clk_disable(i2c->clk); |
796 | pm_runtime_put(&adap->dev); | 798 | pm_runtime_put(&adap->dev); |
797 | return ret; | 799 | return ret; |
798 | } | 800 | } |
@@ -802,7 +804,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, | |||
802 | udelay(100); | 804 | udelay(100); |
803 | } | 805 | } |
804 | 806 | ||
805 | clk_disable_unprepare(i2c->clk); | 807 | clk_disable(i2c->clk); |
806 | pm_runtime_put(&adap->dev); | 808 | pm_runtime_put(&adap->dev); |
807 | return -EREMOTEIO; | 809 | return -EREMOTEIO; |
808 | } | 810 | } |
@@ -1197,7 +1199,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1197 | 1199 | ||
1198 | clk_prepare_enable(i2c->clk); | 1200 | clk_prepare_enable(i2c->clk); |
1199 | ret = s3c24xx_i2c_init(i2c); | 1201 | ret = s3c24xx_i2c_init(i2c); |
1200 | clk_disable_unprepare(i2c->clk); | 1202 | clk_disable(i2c->clk); |
1201 | if (ret != 0) { | 1203 | if (ret != 0) { |
1202 | dev_err(&pdev->dev, "I2C controller init failed\n"); | 1204 | dev_err(&pdev->dev, "I2C controller init failed\n"); |
1203 | return ret; | 1205 | return ret; |
@@ -1210,6 +1212,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1210 | i2c->irq = ret = platform_get_irq(pdev, 0); | 1212 | i2c->irq = ret = platform_get_irq(pdev, 0); |
1211 | if (ret <= 0) { | 1213 | if (ret <= 0) { |
1212 | dev_err(&pdev->dev, "cannot find IRQ\n"); | 1214 | dev_err(&pdev->dev, "cannot find IRQ\n"); |
1215 | clk_unprepare(i2c->clk); | ||
1213 | return ret; | 1216 | return ret; |
1214 | } | 1217 | } |
1215 | 1218 | ||
@@ -1218,6 +1221,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1218 | 1221 | ||
1219 | if (ret != 0) { | 1222 | if (ret != 0) { |
1220 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); | 1223 | dev_err(&pdev->dev, "cannot claim IRQ %d\n", i2c->irq); |
1224 | clk_unprepare(i2c->clk); | ||
1221 | return ret; | 1225 | return ret; |
1222 | } | 1226 | } |
1223 | } | 1227 | } |
@@ -1225,6 +1229,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1225 | ret = s3c24xx_i2c_register_cpufreq(i2c); | 1229 | ret = s3c24xx_i2c_register_cpufreq(i2c); |
1226 | if (ret < 0) { | 1230 | if (ret < 0) { |
1227 | dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); | 1231 | dev_err(&pdev->dev, "failed to register cpufreq notifier\n"); |
1232 | clk_unprepare(i2c->clk); | ||
1228 | return ret; | 1233 | return ret; |
1229 | } | 1234 | } |
1230 | 1235 | ||
@@ -1241,6 +1246,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) | |||
1241 | if (ret < 0) { | 1246 | if (ret < 0) { |
1242 | dev_err(&pdev->dev, "failed to add bus to i2c core\n"); | 1247 | dev_err(&pdev->dev, "failed to add bus to i2c core\n"); |
1243 | s3c24xx_i2c_deregister_cpufreq(i2c); | 1248 | s3c24xx_i2c_deregister_cpufreq(i2c); |
1249 | clk_unprepare(i2c->clk); | ||
1244 | return ret; | 1250 | return ret; |
1245 | } | 1251 | } |
1246 | 1252 | ||
@@ -1262,6 +1268,8 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev) | |||
1262 | { | 1268 | { |
1263 | struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); | 1269 | struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); |
1264 | 1270 | ||
1271 | clk_unprepare(i2c->clk); | ||
1272 | |||
1265 | pm_runtime_disable(&i2c->adap.dev); | 1273 | pm_runtime_disable(&i2c->adap.dev); |
1266 | pm_runtime_disable(&pdev->dev); | 1274 | pm_runtime_disable(&pdev->dev); |
1267 | 1275 | ||
@@ -1293,13 +1301,16 @@ static int s3c24xx_i2c_resume_noirq(struct device *dev) | |||
1293 | { | 1301 | { |
1294 | struct platform_device *pdev = to_platform_device(dev); | 1302 | struct platform_device *pdev = to_platform_device(dev); |
1295 | struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); | 1303 | struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev); |
1304 | int ret; | ||
1296 | 1305 | ||
1297 | if (!IS_ERR(i2c->sysreg)) | 1306 | if (!IS_ERR(i2c->sysreg)) |
1298 | regmap_write(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, i2c->sys_i2c_cfg); | 1307 | regmap_write(i2c->sysreg, EXYNOS5_SYS_I2C_CFG, i2c->sys_i2c_cfg); |
1299 | 1308 | ||
1300 | clk_prepare_enable(i2c->clk); | 1309 | ret = clk_enable(i2c->clk); |
1310 | if (ret) | ||
1311 | return ret; | ||
1301 | s3c24xx_i2c_init(i2c); | 1312 | s3c24xx_i2c_init(i2c); |
1302 | clk_disable_unprepare(i2c->clk); | 1313 | clk_disable(i2c->clk); |
1303 | i2c->suspended = 0; | 1314 | i2c->suspended = 0; |
1304 | 1315 | ||
1305 | return 0; | 1316 | return 0; |
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 440d5dbc8b5f..007818b3e174 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -139,6 +139,7 @@ struct sh_mobile_i2c_data { | |||
139 | int pos; | 139 | int pos; |
140 | int sr; | 140 | int sr; |
141 | bool send_stop; | 141 | bool send_stop; |
142 | bool stop_after_dma; | ||
142 | 143 | ||
143 | struct resource *res; | 144 | struct resource *res; |
144 | struct dma_chan *dma_tx; | 145 | struct dma_chan *dma_tx; |
@@ -407,7 +408,7 @@ static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd) | |||
407 | 408 | ||
408 | if (pd->pos == pd->msg->len) { | 409 | if (pd->pos == pd->msg->len) { |
409 | /* Send stop if we haven't yet (DMA case) */ | 410 | /* Send stop if we haven't yet (DMA case) */ |
410 | if (pd->send_stop && (iic_rd(pd, ICCR) & ICCR_BBSY)) | 411 | if (pd->send_stop && pd->stop_after_dma) |
411 | i2c_op(pd, OP_TX_STOP, 0); | 412 | i2c_op(pd, OP_TX_STOP, 0); |
412 | return 1; | 413 | return 1; |
413 | } | 414 | } |
@@ -449,6 +450,13 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) | |||
449 | real_pos = pd->pos - 2; | 450 | real_pos = pd->pos - 2; |
450 | 451 | ||
451 | if (pd->pos == pd->msg->len) { | 452 | if (pd->pos == pd->msg->len) { |
453 | if (pd->stop_after_dma) { | ||
454 | /* Simulate PIO end condition after DMA transfer */ | ||
455 | i2c_op(pd, OP_RX_STOP, 0); | ||
456 | pd->pos++; | ||
457 | break; | ||
458 | } | ||
459 | |||
452 | if (real_pos < 0) { | 460 | if (real_pos < 0) { |
453 | i2c_op(pd, OP_RX_STOP, 0); | 461 | i2c_op(pd, OP_RX_STOP, 0); |
454 | break; | 462 | break; |
@@ -536,6 +544,7 @@ static void sh_mobile_i2c_dma_callback(void *data) | |||
536 | 544 | ||
537 | sh_mobile_i2c_dma_unmap(pd); | 545 | sh_mobile_i2c_dma_unmap(pd); |
538 | pd->pos = pd->msg->len; | 546 | pd->pos = pd->msg->len; |
547 | pd->stop_after_dma = true; | ||
539 | 548 | ||
540 | iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE); | 549 | iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE); |
541 | } | 550 | } |
@@ -726,6 +735,7 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter, | |||
726 | bool do_start = pd->send_stop || !i; | 735 | bool do_start = pd->send_stop || !i; |
727 | msg = &msgs[i]; | 736 | msg = &msgs[i]; |
728 | pd->send_stop = i == num - 1 || msg->flags & I2C_M_STOP; | 737 | pd->send_stop = i == num - 1 || msg->flags & I2C_M_STOP; |
738 | pd->stop_after_dma = false; | ||
729 | 739 | ||
730 | err = start_ch(pd, msg, do_start); | 740 | err = start_ch(pd, msg, do_start); |
731 | if (err) | 741 | if (err) |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 39d25a8cb1ad..e9eae57a2b50 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -2972,6 +2972,7 @@ trace: | |||
2972 | } | 2972 | } |
2973 | EXPORT_SYMBOL(i2c_smbus_xfer); | 2973 | EXPORT_SYMBOL(i2c_smbus_xfer); |
2974 | 2974 | ||
2975 | #if IS_ENABLED(CONFIG_I2C_SLAVE) | ||
2975 | int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb) | 2976 | int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb) |
2976 | { | 2977 | { |
2977 | int ret; | 2978 | int ret; |
@@ -3019,6 +3020,7 @@ int i2c_slave_unregister(struct i2c_client *client) | |||
3019 | return ret; | 3020 | return ret; |
3020 | } | 3021 | } |
3021 | EXPORT_SYMBOL_GPL(i2c_slave_unregister); | 3022 | EXPORT_SYMBOL_GPL(i2c_slave_unregister); |
3023 | #endif | ||
3022 | 3024 | ||
3023 | MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); | 3025 | MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); |
3024 | MODULE_DESCRIPTION("I2C-Bus main module"); | 3026 | MODULE_DESCRIPTION("I2C-Bus main module"); |
diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c index 6631400b5f02..cf9b09db092f 100644 --- a/drivers/i2c/i2c-slave-eeprom.c +++ b/drivers/i2c/i2c-slave-eeprom.c | |||
@@ -74,7 +74,7 @@ static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj | |||
74 | struct eeprom_data *eeprom; | 74 | struct eeprom_data *eeprom; |
75 | unsigned long flags; | 75 | unsigned long flags; |
76 | 76 | ||
77 | if (off + count >= attr->size) | 77 | if (off + count > attr->size) |
78 | return -EFBIG; | 78 | return -EFBIG; |
79 | 79 | ||
80 | eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj)); | 80 | eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj)); |
@@ -92,7 +92,7 @@ static ssize_t i2c_slave_eeprom_bin_write(struct file *filp, struct kobject *kob | |||
92 | struct eeprom_data *eeprom; | 92 | struct eeprom_data *eeprom; |
93 | unsigned long flags; | 93 | unsigned long flags; |
94 | 94 | ||
95 | if (off + count >= attr->size) | 95 | if (off + count > attr->size) |
96 | return -EFBIG; | 96 | return -EFBIG; |
97 | 97 | ||
98 | eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj)); | 98 | eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj)); |
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index e3a1721c8354..7c7695940ddd 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
@@ -228,7 +228,9 @@ struct i2c_client { | |||
228 | struct device dev; /* the device structure */ | 228 | struct device dev; /* the device structure */ |
229 | int irq; /* irq issued by device */ | 229 | int irq; /* irq issued by device */ |
230 | struct list_head detected; | 230 | struct list_head detected; |
231 | #if IS_ENABLED(CONFIG_I2C_SLAVE) | ||
231 | i2c_slave_cb_t slave_cb; /* callback for slave mode */ | 232 | i2c_slave_cb_t slave_cb; /* callback for slave mode */ |
233 | #endif | ||
232 | }; | 234 | }; |
233 | #define to_i2c_client(d) container_of(d, struct i2c_client, dev) | 235 | #define to_i2c_client(d) container_of(d, struct i2c_client, dev) |
234 | 236 | ||
@@ -253,6 +255,7 @@ static inline void i2c_set_clientdata(struct i2c_client *dev, void *data) | |||
253 | 255 | ||
254 | /* I2C slave support */ | 256 | /* I2C slave support */ |
255 | 257 | ||
258 | #if IS_ENABLED(CONFIG_I2C_SLAVE) | ||
256 | enum i2c_slave_event { | 259 | enum i2c_slave_event { |
257 | I2C_SLAVE_REQ_READ_START, | 260 | I2C_SLAVE_REQ_READ_START, |
258 | I2C_SLAVE_REQ_READ_END, | 261 | I2C_SLAVE_REQ_READ_END, |
@@ -269,6 +272,7 @@ static inline int i2c_slave_event(struct i2c_client *client, | |||
269 | { | 272 | { |
270 | return client->slave_cb(client, event, val); | 273 | return client->slave_cb(client, event, val); |
271 | } | 274 | } |
275 | #endif | ||
272 | 276 | ||
273 | /** | 277 | /** |
274 | * struct i2c_board_info - template for device creation | 278 | * struct i2c_board_info - template for device creation |
@@ -404,8 +408,10 @@ struct i2c_algorithm { | |||
404 | /* To determine what the adapter supports */ | 408 | /* To determine what the adapter supports */ |
405 | u32 (*functionality) (struct i2c_adapter *); | 409 | u32 (*functionality) (struct i2c_adapter *); |
406 | 410 | ||
411 | #if IS_ENABLED(CONFIG_I2C_SLAVE) | ||
407 | int (*reg_slave)(struct i2c_client *client); | 412 | int (*reg_slave)(struct i2c_client *client); |
408 | int (*unreg_slave)(struct i2c_client *client); | 413 | int (*unreg_slave)(struct i2c_client *client); |
414 | #endif | ||
409 | }; | 415 | }; |
410 | 416 | ||
411 | /** | 417 | /** |