Skip to content

Commit b8db371

Browse files
committed
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
2 parents 6905732 + cbfff43 commit b8db371

File tree

8 files changed

+43
-15
lines changed

8 files changed

+43
-15
lines changed

Documentation/i2c/slave-interface

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ If you want to add slave support to the bus driver:
145145

146146
* Catch the slave interrupts and send appropriate i2c_slave_events to the backend.
147147

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+
148153
Check the i2c-rcar driver as an example.
149154

150155

drivers/i2c/busses/i2c-bcm-kona.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static int bcm_kona_i2c_xfer(struct i2c_adapter *adapter,
643643
if (rc < 0) {
644644
dev_err(dev->device,
645645
"restart cmd failed rc = %d\n", rc);
646-
goto xfer_send_stop;
646+
goto xfer_send_stop;
647647
}
648648
}
649649

drivers/i2c/busses/i2c-cadence.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ static int cdns_i2c_setclk(unsigned long clk_in, struct cdns_i2c *id)
767767
* depending on the scaling direction.
768768
*
769769
* 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
771771
* considered irrelevant.
772772
*/
773773
static int cdns_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long

drivers/i2c/busses/i2c-designware-core.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,17 @@ int i2c_dw_init(struct dw_i2c_dev *dev)
367367
dev_dbg(dev->dev, "Fast-mode HCNT:LCNT = %d:%d\n", hcnt, lcnt);
368368

369369
/* Configure SDA Hold Time if required */
370-
if (dev->sda_hold_time) {
371-
reg = dw_readl(dev, DW_IC_COMP_VERSION);
372-
if (reg >= DW_IC_SDA_HOLD_MIN_VERS)
370+
reg = dw_readl(dev, DW_IC_COMP_VERSION);
371+
if (reg >= DW_IC_SDA_HOLD_MIN_VERS) {
372+
if (dev->sda_hold_time) {
373373
dw_writel(dev, dev->sda_hold_time, DW_IC_SDA_HOLD);
374-
else
375-
dev_warn(dev->dev,
376-
"Hardware too old to adjust SDA hold time.");
374+
} else {
375+
/* Keep previous hold time setting if no one set it */
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");
377381
}
378382

379383
/* Configure Tx/Rx FIFO threshold levels */

drivers/i2c/busses/i2c-rcar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static void rcar_i2c_dma(struct rcar_i2c_priv *priv)
378378
}
379379

380380
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)) {
382382
dev_dbg(dev, "dma map failed, using PIO\n");
383383
return;
384384
}

drivers/i2c/busses/i2c-rk3x.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ static void rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate)
918918
* Code adapted from i2c-cadence.c.
919919
*
920920
* 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
922922
* considered irrelevant.
923923
*/
924924
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,
11111111
return ret < 0 ? ret : num;
11121112
}
11131113

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+
11141123
static u32 rk3x_i2c_func(struct i2c_adapter *adap)
11151124
{
11161125
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)
13341343
return 0;
13351344
}
13361345

1346+
static SIMPLE_DEV_PM_OPS(rk3x_i2c_pm_ops, NULL, rk3x_i2c_resume);
1347+
13371348
static struct platform_driver rk3x_i2c_driver = {
13381349
.probe = rk3x_i2c_probe,
13391350
.remove = rk3x_i2c_remove,
13401351
.driver = {
13411352
.name = "rk3x-i2c",
13421353
.of_match_table = rk3x_i2c_match,
1354+
.pm = &rk3x_i2c_pm_ops,
13431355
},
13441356
};
13451357

drivers/i2c/busses/i2c-sh_mobile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static void sh_mobile_i2c_xfer_dma(struct sh_mobile_i2c_data *pd)
610610
return;
611611

612612
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)) {
614614
dev_dbg(pd->dev, "dma map failed, using PIO\n");
615615
return;
616616
}

drivers/i2c/muxes/i2c-demux-pinctrl.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ struct i2c_demux_pinctrl_priv {
3737
struct i2c_demux_pinctrl_chan chan[];
3838
};
3939

40-
static struct property status_okay = { .name = "status", .length = 3, .value = "ok" };
41-
4240
static int i2c_demux_master_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
4341
{
4442
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
107105
of_changeset_revert(&priv->chan[new_chan].chgset);
108106
err:
109107
dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, ret);
108+
priv->cur_chan = -EINVAL;
110109
return ret;
111110
}
112111

@@ -192,6 +191,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
192191
{
193192
struct device_node *np = pdev->dev.of_node;
194193
struct i2c_demux_pinctrl_priv *priv;
194+
struct property *props;
195195
int num_chan, i, j, err;
196196

197197
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)
202202

203203
priv = devm_kzalloc(&pdev->dev, sizeof(*priv)
204204
+ 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)
206209
return -ENOMEM;
207210

208211
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)
220223
}
221224
priv->chan[i].parent_np = adap_np;
222225

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+
223230
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]);
225232
}
226233

227234
priv->num_chan = num_chan;

0 commit comments

Comments
 (0)