Skip to content

Commit bd0c7d7

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: "Regular set of fixes for drivers and the dev-interface" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: ismt: Fix undefined behavior due to shift overflowing the constant i2c: dev: Force case user pointers in compat_i2cdev_ioctl() i2c: dev: check return value when calling dev_set_name() i2c: qcom-geni: Use dev_err_probe() for GPI DMA error i2c: imx: Implement errata ERR007805 or e7805 bus frequency limit i2c: pasemi: Wait for write xfers to finish
2 parents a2c29cc + e35c936 commit bd0c7d7

5 files changed

Lines changed: 54 additions & 12 deletions

File tree

drivers/i2c/busses/i2c-imx.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ struct imx_i2c_hwdata {
179179
unsigned int ndivs;
180180
unsigned int i2sr_clr_opcode;
181181
unsigned int i2cr_ien_opcode;
182+
/*
183+
* Errata ERR007805 or e7805:
184+
* I2C: When the I2C clock speed is configured for 400 kHz,
185+
* the SCL low period violates the I2C spec of 1.3 uS min.
186+
*/
187+
bool has_err007805;
182188
};
183189

184190
struct imx_i2c_dma {
@@ -240,6 +246,16 @@ static const struct imx_i2c_hwdata imx21_i2c_hwdata = {
240246

241247
};
242248

249+
static const struct imx_i2c_hwdata imx6_i2c_hwdata = {
250+
.devtype = IMX21_I2C,
251+
.regshift = IMX_I2C_REGSHIFT,
252+
.clk_div = imx_i2c_clk_div,
253+
.ndivs = ARRAY_SIZE(imx_i2c_clk_div),
254+
.i2sr_clr_opcode = I2SR_CLR_OPCODE_W0C,
255+
.i2cr_ien_opcode = I2CR_IEN_OPCODE_1,
256+
.has_err007805 = true,
257+
};
258+
243259
static struct imx_i2c_hwdata vf610_i2c_hwdata = {
244260
.devtype = VF610_I2C,
245261
.regshift = VF610_I2C_REGSHIFT,
@@ -266,6 +282,16 @@ MODULE_DEVICE_TABLE(platform, imx_i2c_devtype);
266282
static const struct of_device_id i2c_imx_dt_ids[] = {
267283
{ .compatible = "fsl,imx1-i2c", .data = &imx1_i2c_hwdata, },
268284
{ .compatible = "fsl,imx21-i2c", .data = &imx21_i2c_hwdata, },
285+
{ .compatible = "fsl,imx6q-i2c", .data = &imx6_i2c_hwdata, },
286+
{ .compatible = "fsl,imx6sl-i2c", .data = &imx6_i2c_hwdata, },
287+
{ .compatible = "fsl,imx6sll-i2c", .data = &imx6_i2c_hwdata, },
288+
{ .compatible = "fsl,imx6sx-i2c", .data = &imx6_i2c_hwdata, },
289+
{ .compatible = "fsl,imx6ul-i2c", .data = &imx6_i2c_hwdata, },
290+
{ .compatible = "fsl,imx7s-i2c", .data = &imx6_i2c_hwdata, },
291+
{ .compatible = "fsl,imx8mm-i2c", .data = &imx6_i2c_hwdata, },
292+
{ .compatible = "fsl,imx8mn-i2c", .data = &imx6_i2c_hwdata, },
293+
{ .compatible = "fsl,imx8mp-i2c", .data = &imx6_i2c_hwdata, },
294+
{ .compatible = "fsl,imx8mq-i2c", .data = &imx6_i2c_hwdata, },
269295
{ .compatible = "fsl,vf610-i2c", .data = &vf610_i2c_hwdata, },
270296
{ /* sentinel */ }
271297
};
@@ -551,6 +577,13 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
551577
unsigned int div;
552578
int i;
553579

580+
if (i2c_imx->hwdata->has_err007805 && i2c_imx->bitrate > 384000) {
581+
dev_dbg(&i2c_imx->adapter.dev,
582+
"SoC errata ERR007805 or e7805 applies, bus frequency limited from %d Hz to 384000 Hz.\n",
583+
i2c_imx->bitrate);
584+
i2c_imx->bitrate = 384000;
585+
}
586+
554587
/* Divider value calculation */
555588
if (i2c_imx->cur_clk == i2c_clk_rate)
556589
return;

drivers/i2c/busses/i2c-ismt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@
145145
#define ISMT_SPGT_SPD_MASK 0xc0000000 /* SMBus Speed mask */
146146
#define ISMT_SPGT_SPD_80K 0x00 /* 80 kHz */
147147
#define ISMT_SPGT_SPD_100K (0x1 << 30) /* 100 kHz */
148-
#define ISMT_SPGT_SPD_400K (0x2 << 30) /* 400 kHz */
149-
#define ISMT_SPGT_SPD_1M (0x3 << 30) /* 1 MHz */
148+
#define ISMT_SPGT_SPD_400K (0x2U << 30) /* 400 kHz */
149+
#define ISMT_SPGT_SPD_1M (0x3U << 30) /* 1 MHz */
150150

151151

152152
/* MSI Control Register (MSICTL) bit definitions */

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ static int pasemi_i2c_xfer_msg(struct i2c_adapter *adapter,
137137

138138
TXFIFO_WR(smbus, msg->buf[msg->len-1] |
139139
(stop ? MTXFIFO_STOP : 0));
140+
141+
if (stop) {
142+
err = pasemi_smb_waitready(smbus);
143+
if (err)
144+
goto reset_out;
145+
}
140146
}
141147

142148
return 0;

drivers/i2c/busses/i2c-qcom-geni.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,8 @@ static int geni_i2c_probe(struct platform_device *pdev)
843843
/* FIFO is disabled, so we can only use GPI DMA */
844844
gi2c->gpi_mode = true;
845845
ret = setup_gpi_dma(gi2c);
846-
if (ret) {
847-
dev_err(dev, "Failed to setup GPI DMA mode:%d ret\n", ret);
848-
return ret;
849-
}
846+
if (ret)
847+
return dev_err_probe(dev, ret, "Failed to setup GPI DMA mode\n");
850848

851849
dev_dbg(dev, "Using GPI DMA mode for I2C\n");
852850
} else {

drivers/i2c/i2c-dev.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ static long compat_i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned lo
557557
.addr = umsg.addr,
558558
.flags = umsg.flags,
559559
.len = umsg.len,
560-
.buf = compat_ptr(umsg.buf)
560+
.buf = (__force __u8 *)compat_ptr(umsg.buf),
561561
};
562562
}
563563

@@ -668,16 +668,21 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy)
668668
i2c_dev->dev.class = i2c_dev_class;
669669
i2c_dev->dev.parent = &adap->dev;
670670
i2c_dev->dev.release = i2cdev_dev_release;
671-
dev_set_name(&i2c_dev->dev, "i2c-%d", adap->nr);
671+
672+
res = dev_set_name(&i2c_dev->dev, "i2c-%d", adap->nr);
673+
if (res)
674+
goto err_put_i2c_dev;
672675

673676
res = cdev_device_add(&i2c_dev->cdev, &i2c_dev->dev);
674-
if (res) {
675-
put_i2c_dev(i2c_dev, false);
676-
return res;
677-
}
677+
if (res)
678+
goto err_put_i2c_dev;
678679

679680
pr_debug("adapter [%s] registered as minor %d\n", adap->name, adap->nr);
680681
return 0;
682+
683+
err_put_i2c_dev:
684+
put_i2c_dev(i2c_dev, false);
685+
return res;
681686
}
682687

683688
static int i2cdev_detach_adapter(struct device *dev, void *dummy)

0 commit comments

Comments
 (0)