diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-09-10 12:43:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-09-10 12:43:10 -0400 |
commit | b8db3714d7479881e23de20735f60f1733723241 (patch) | |
tree | 398e50ba60df642d66d470755ead99b24383daf5 | |
parent | 6905732c80bc7f85602abbe27f7bdc3fe81f56d0 (diff) | |
parent | cbfff439c54f37fc363b1d365183fa61af43585c (diff) |
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang:
"Mostly driver bugfixes, but also a few cleanups which are nice to have
out of the way"
* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: rk3x: Restore clock settings at resume time
i2c: Spelling s/acknowedge/acknowledge/
i2c: designware: save the preset value of DW_IC_SDA_HOLD
Documentation: i2c: slave-interface: add note for driver development
i2c: mux: demux-pinctrl: run properly with multiple instances
i2c: bcm-kona: fix inconsistent indenting
i2c: rcar: use proper device with dma_mapping_error
i2c: sh_mobile: use proper device with dma_mapping_error
i2c: mux: demux-pinctrl: invalidate properly when switching fails
-rw-r--r-- | Documentation/i2c/slave-interface | 5 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-bcm-kona.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-cadence.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-designware-core.c | 16 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-rcar.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-rk3x.c | 14 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-sh_mobile.c | 2 | ||||
-rw-r--r-- | drivers/i2c/muxes/i2c-demux-pinctrl.c | 15 |
8 files changed, 43 insertions, 15 deletions
diff --git a/Documentation/i2c/slave-interface b/Documentation/i2c/slave-interface index 80807adb8ded..7e2a228f21bc 100644 --- a/Documentation/i2c/slave-interface +++ b/Documentation/i2c/slave-interface | |||
@@ -145,6 +145,11 @@ If you want to add slave support to the bus driver: | |||
145 | 145 | ||
146 | * Catch the slave interrupts and send appropriate i2c_slave_events to the backend. | 146 | * Catch the slave interrupts and send appropriate i2c_slave_events to the backend. |
147 | 147 | ||
148 | Note that most hardware supports being master _and_ slave on the same bus. So, | ||
149 | if you extend a bus driver, please make sure that the driver supports that as | ||
150 | well. In almost all cases, slave support does not need to disable the master | ||
151 | functionality. | ||
152 | |||
148 | Check the i2c-rcar driver as an example. | 153 | Check the i2c-rcar driver as an example. |
149 | 154 | ||
150 | 155 | ||
diff --git a/drivers/i2c/busses/i2c-bcm-kona.c b/drivers/i2c/busses/i2c-bcm-kona.c index f98743277e3c..258cb9a40ab3 100644 --- a/drivers/i2c/busses/i2c-bcm-kona.c +++ b/drivers/i2c/busses/i2c-bcm-kona.c | |||
@@ -643,7 +643,7 @@ static int bcm_kona_i2c_xfer(struct i2c_adapter *adapter, | |||
643 | if (rc < 0) { | 643 | if (rc < 0) { |
644 | dev_err(dev->device, | 644 | dev_err(dev->device, |
645 | "restart cmd failed rc = %d\n", rc); | 645 | "restart cmd failed rc = %d\n", rc); |
646 | goto xfer_send_stop; | 646 | goto xfer_send_stop; |
647 | } | 647 | } |
648 | } | 648 | } |
649 | 649 | ||
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index 90bbd9f9dd8f..3c16a2f7c673 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c | |||
@@ -767,7 +767,7 @@ static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id) | |||
767 | * depending on the scaling direction. | 767 | * depending on the scaling direction. |
768 | * | 768 | * |
769 | * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK | 769 | * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK |
770 | * to acknowedge the change, NOTIFY_DONE if the notification is | 770 | * to acknowledge the change, NOTIFY_DONE if the notification is |
771 | * considered irrelevant. | 771 | * considered irrelevant. |
772 | */ | 772 | */ |
773 | static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long | 773 | static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long |
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c index c6922b806fb7..fcd973d5131e 100644 --- a/drivers/i2c/busses/i2c-designware-core.c +++ b/drivers/i2c/busses/i2c-designware-core.c | |||
@@ -367,13 +367,17 @@ int i2c_dw_init(struct dw_i2c_dev *dev) | |||
367 | dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt); | 367 | dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt); |
368 | 368 | ||
369 | /* Configure SDA Hold Time if required */ | 369 | /* Configure SDA Hold Time if required */ |
370 | if (dev->sda_hold_time) { | 370 | reg = dw_readl(dev, DW_IC_COMP_VERSION); |
371 | reg = dw_readl(dev, DW_IC_COMP_VERSION); | 371 | if (reg >= DW_IC_SDA_HOLD_MIN_VERS) { |
372 | if (reg >= DW_IC_SDA_HOLD_MIN_VERS) | 372 | if (dev->sda_hold_time) { |
373 | dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD); | 373 | dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD); |
374 | else | 374 | } else { |
375 | dev_warn(dev->dev, | 375 | /* Keep previous hold time setting if no one set it */ |
376 | "Hardware too old to adjust SDA hold time."); | 376 | dev->sda_hold_time = dw_readl(dev, DW_IC_SDA_HOLD); |
377 | } | ||
378 | } else { | ||
379 | dev_warn(dev->dev, | ||
380 | "Hardware too old to adjust SDA hold time.\n"); | ||
377 | } | 381 | } |
378 | 382 | ||
379 | /* Configure Tx/Rx FIFO threshold levels */ | 383 | /* Configure Tx/Rx FIFO threshold levels */ |
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 52407f3c9e1c..9bd849dacee8 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c | |||
@@ -378,7 +378,7 @@ static void rcar_i2c_dma(struct rcar_i2c_priv *priv) | |||
378 | } | 378 | } |
379 | 379 | ||
380 | dma_addr = dma_map_single(chan->device->dev, buf, len, dir); | 380 | dma_addr = dma_map_single(chan->device->dev, buf, len, dir); |
381 | if (dma_mapping_error(dev, dma_addr)) { | 381 | if (dma_mapping_error(chan->device->dev, dma_addr)) { |
382 | dev_dbg(dev, "dma map failed, using PIO\n"); | 382 | dev_dbg(dev, "dma map failed, using PIO\n"); |
383 | return; | 383 | return; |
384 | } | 384 | } |
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 2bc8b01153d6..5c5b7cada8be 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c | |||
@@ -918,7 +918,7 @@ static void rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate) | |||
918 | * Code adapted from i2c-cadence.c. | 918 | * Code adapted from i2c-cadence.c. |
919 | * | 919 | * |
920 | * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK | 920 | * Return: NOTIFY_STOP if the rate change should be aborted, NOTIFY_OK |
921 | * to acknowedge the change, NOTIFY_DONE if the notification is | 921 | * to acknowledge the change, NOTIFY_DONE if the notification is |
922 | * considered irrelevant. | 922 | * considered irrelevant. |
923 | */ | 923 | */ |
924 | static int rk3x_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long | 924 | static int rk3x_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long |
@@ -1111,6 +1111,15 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap, | |||
1111 | return ret < 0 ? ret : num; | 1111 | return ret < 0 ? ret : num; |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | static __maybe_unused int rk3x_i2c_resume(struct device *dev) | ||
1115 | { | ||
1116 | struct rk3x_i2c *i2c = dev_get_drvdata(dev); | ||
1117 | |||
1118 | rk3x_i2c_adapt_div(i2c, clk_get_rate(i2c->clk)); | ||
1119 | |||
1120 | return 0; | ||
1121 | } | ||
1122 | |||
1114 | static u32 rk3x_i2c_func(struct i2c_adapter *adap) | 1123 | static u32 rk3x_i2c_func(struct i2c_adapter *adap) |
1115 | { | 1124 | { |
1116 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; | 1125 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; |
@@ -1334,12 +1343,15 @@ static int rk3x_i2c_remove(struct platform_device *pdev) | |||
1334 | return 0; | 1343 | return 0; |
1335 | } | 1344 | } |
1336 | 1345 | ||
1346 | static SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume); | ||
1347 | |||
1337 | static struct platform_driver rk3x_i2c_driver = { | 1348 | static struct platform_driver rk3x_i2c_driver = { |
1338 | .probe = rk3x_i2c_probe, | 1349 | .probe = rk3x_i2c_probe, |
1339 | .remove = rk3x_i2c_remove, | 1350 | .remove = rk3x_i2c_remove, |
1340 | .driver = { | 1351 | .driver = { |
1341 | .name = "rk3x-i2c", | 1352 | .name = "rk3x-i2c", |
1342 | .of_match_table = rk3x_i2c_match, | 1353 | .of_match_table = rk3x_i2c_match, |
1354 | .pm = &rk3x_i2c_pm_ops, | ||
1343 | }, | 1355 | }, |
1344 | }; | 1356 | }; |
1345 | 1357 | ||
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 6fb3e2645992..05b1eeab9cf5 100644 --- a/drivers/i2c/busses/i2c-sh_mobile.c +++ b/drivers/i2c/busses/i2c-sh_mobile.c | |||
@@ -610,7 +610,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd) | |||
610 | return; | 610 | return; |
611 | 611 | ||
612 | dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir); | 612 | dma_addr = dma_map_single(chan->device->dev, pd->msg->buf, pd->msg->len, dir); |
613 | if (dma_mapping_error(pd->dev, dma_addr)) { | 613 | if (dma_mapping_error(chan->device->dev, dma_addr)) { |
614 | dev_dbg(pd->dev, "dma map failed, using PIO\n"); | 614 | dev_dbg(pd->dev, "dma map failed, using PIO\n"); |
615 | return; | 615 | return; |
616 | } | 616 | } |
diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c index 215ac87f606d..b3893f6282ba 100644 --- a/drivers/i2c/muxes/i2c-demux-pinctrl.c +++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c | |||
@@ -37,8 +37,6 @@ struct i2c_demux_pinctrl_priv { | |||
37 | struct i2c_demux_pinctrl_chan chan[]; | 37 | struct i2c_demux_pinctrl_chan chan[]; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static struct property status_okay = { .name = "status", .length = 3, .value = "ok" }; | ||
41 | |||
42 | static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) | 40 | static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) |
43 | { | 41 | { |
44 | struct i2c_demux_pinctrl_priv *priv = adap->algo_data; | 42 | struct i2c_demux_pinctrl_priv *priv = adap->algo_data; |
@@ -107,6 +105,7 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne | |||
107 | of_changeset_revert(&priv->chan[new_chan].chgset); | 105 | of_changeset_revert(&priv->chan[new_chan].chgset); |
108 | err: | 106 | err: |
109 | dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, ret); | 107 | dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, ret); |
108 | priv->cur_chan = -EINVAL; | ||
110 | return ret; | 109 | return ret; |
111 | } | 110 | } |
112 | 111 | ||
@@ -192,6 +191,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) | |||
192 | { | 191 | { |
193 | struct device_node *np = pdev->dev.of_node; | 192 | struct device_node *np = pdev->dev.of_node; |
194 | struct i2c_demux_pinctrl_priv *priv; | 193 | struct i2c_demux_pinctrl_priv *priv; |
194 | struct property *props; | ||
195 | int num_chan, i, j, err; | 195 | int num_chan, i, j, err; |
196 | 196 | ||
197 | num_chan = of_count_phandle_with_args(np, "i2c-parent", NULL); | 197 | num_chan = of_count_phandle_with_args(np, "i2c-parent", NULL); |
@@ -202,7 +202,10 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) | |||
202 | 202 | ||
203 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv) | 203 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv) |
204 | + num_chan * sizeof(struct i2c_demux_pinctrl_chan), GFP_KERNEL); | 204 | + num_chan * sizeof(struct i2c_demux_pinctrl_chan), GFP_KERNEL); |
205 | if (!priv) | 205 | |
206 | props = devm_kcalloc(&pdev->dev, num_chan, sizeof(*props), GFP_KERNEL); | ||
207 | |||
208 | if (!priv || !props) | ||
206 | return -ENOMEM; | 209 | return -ENOMEM; |
207 | 210 | ||
208 | err = of_property_read_string(np, "i2c-bus-name", &priv->bus_name); | 211 | err = of_property_read_string(np, "i2c-bus-name", &priv->bus_name); |
@@ -220,8 +223,12 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) | |||
220 | } | 223 | } |
221 | priv->chan[i].parent_np = adap_np; | 224 | priv->chan[i].parent_np = adap_np; |
222 | 225 | ||
226 | props[i].name = devm_kstrdup(&pdev->dev, "status", GFP_KERNEL); | ||
227 | props[i].value = devm_kstrdup(&pdev->dev, "ok", GFP_KERNEL); | ||
228 | props[i].length = 3; | ||
229 | |||
223 | of_changeset_init(&priv->chan[i].chgset); | 230 | of_changeset_init(&priv->chan[i].chgset); |
224 | of_changeset_update_property(&priv->chan[i].chgset, adap_np, &status_okay); | 231 | of_changeset_update_property(&priv->chan[i].chgset, adap_np, &props[i]); |
225 | } | 232 | } |
226 | 233 | ||
227 | priv->num_chan = num_chan; | 234 | priv->num_chan = num_chan; |