Skip to content

Commit 077e81d

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: "Another bunch of driver fixes" * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: sprd: depend on COMMON_CLK to fix compile tests Revert "i2c: imx: Remove unused .id_table support" i2c: octeon: check correct size of maximum RECV_LEN packet i2c: tegra: Create i2c_writesl_vi() to use with VI I2C for filling TX FIFO i2c: bpmp-tegra: Ignore unknown I2C_M flags i2c: tegra: Wait for config load atomically while in ISR
2 parents 15cfb0f + 9ecd1d2 commit 077e81d

5 files changed

Lines changed: 44 additions & 5 deletions

File tree

drivers/i2c/busses/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,7 @@ config I2C_SIRF
10131013
config I2C_SPRD
10141014
tristate "Spreadtrum I2C interface"
10151015
depends on I2C=y && (ARCH_SPRD || COMPILE_TEST)
1016+
depends on COMMON_CLK
10161017
help
10171018
If you say yes to this option, support will be included for the
10181019
Spreadtrum I2C interface.

drivers/i2c/busses/i2c-imx.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,19 @@ static struct imx_i2c_hwdata vf610_i2c_hwdata = {
241241

242242
};
243243

244+
static const struct platform_device_id imx_i2c_devtype[] = {
245+
{
246+
.name = "imx1-i2c",
247+
.driver_data = (kernel_ulong_t)&imx1_i2c_hwdata,
248+
}, {
249+
.name = "imx21-i2c",
250+
.driver_data = (kernel_ulong_t)&imx21_i2c_hwdata,
251+
}, {
252+
/* sentinel */
253+
}
254+
};
255+
MODULE_DEVICE_TABLE(platform, imx_i2c_devtype);
256+
244257
static const struct of_device_id i2c_imx_dt_ids[] = {
245258
{ .compatible = "fsl,imx1-i2c", .data = &imx1_i2c_hwdata, },
246259
{ .compatible = "fsl,imx21-i2c", .data = &imx21_i2c_hwdata, },
@@ -1330,7 +1343,11 @@ static int i2c_imx_probe(struct platform_device *pdev)
13301343
return -ENOMEM;
13311344

13321345
match = device_get_match_data(&pdev->dev);
1333-
i2c_imx->hwdata = match;
1346+
if (match)
1347+
i2c_imx->hwdata = match;
1348+
else
1349+
i2c_imx->hwdata = (struct imx_i2c_hwdata *)
1350+
platform_get_device_id(pdev)->driver_data;
13341351

13351352
/* Setup i2c_imx driver structure */
13361353
strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name));
@@ -1498,6 +1515,7 @@ static struct platform_driver i2c_imx_driver = {
14981515
.of_match_table = i2c_imx_dt_ids,
14991516
.acpi_match_table = i2c_imx_acpi_ids,
15001517
},
1518+
.id_table = imx_i2c_devtype,
15011519
};
15021520

15031521
static int __init i2c_adap_imx_init(void)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static int octeon_i2c_read(struct octeon_i2c *i2c, int target,
347347
if (result)
348348
return result;
349349
if (recv_len && i == 0) {
350-
if (data[i] > I2C_SMBUS_BLOCK_MAX + 1)
350+
if (data[i] > I2C_SMBUS_BLOCK_MAX)
351351
return -EPROTO;
352352
length += data[i];
353353
}

drivers/i2c/busses/i2c-tegra-bpmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int tegra_bpmp_xlate_flags(u16 flags, u16 *out)
8080
flags &= ~I2C_M_RECV_LEN;
8181
}
8282

83-
return (flags != 0) ? -EINVAL : 0;
83+
return 0;
8484
}
8585

8686
/**

drivers/i2c/busses/i2c-tegra.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ static void i2c_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned int reg)
326326
/* read back register to make sure that register writes completed */
327327
if (reg != I2C_TX_FIFO)
328328
readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg));
329+
else if (i2c_dev->is_vi)
330+
readl_relaxed(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, I2C_INT_STATUS));
329331
}
330332

331333
static u32 i2c_readl(struct tegra_i2c_dev *i2c_dev, unsigned int reg)
@@ -339,6 +341,21 @@ static void i2c_writesl(struct tegra_i2c_dev *i2c_dev, void *data,
339341
writesl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg), data, len);
340342
}
341343

344+
static void i2c_writesl_vi(struct tegra_i2c_dev *i2c_dev, void *data,
345+
unsigned int reg, unsigned int len)
346+
{
347+
u32 *data32 = data;
348+
349+
/*
350+
* VI I2C controller has known hardware bug where writes get stuck
351+
* when immediate multiple writes happen to TX_FIFO register.
352+
* Recommended software work around is to read I2C register after
353+
* each write to TX_FIFO register to flush out the data.
354+
*/
355+
while (len--)
356+
i2c_writel(i2c_dev, *data32++, reg);
357+
}
358+
342359
static void i2c_readsl(struct tegra_i2c_dev *i2c_dev, void *data,
343360
unsigned int reg, unsigned int len)
344361
{
@@ -533,7 +550,7 @@ static int tegra_i2c_poll_register(struct tegra_i2c_dev *i2c_dev,
533550
void __iomem *addr = i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg);
534551
u32 val;
535552

536-
if (!i2c_dev->atomic_mode)
553+
if (!i2c_dev->atomic_mode && !in_irq())
537554
return readl_relaxed_poll_timeout(addr, val, !(val & mask),
538555
delay_us, timeout_us);
539556

@@ -811,7 +828,10 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev)
811828
i2c_dev->msg_buf_remaining = buf_remaining;
812829
i2c_dev->msg_buf = buf + words_to_transfer * BYTES_PER_FIFO_WORD;
813830

814-
i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
831+
if (i2c_dev->is_vi)
832+
i2c_writesl_vi(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
833+
else
834+
i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
815835

816836
buf += words_to_transfer * BYTES_PER_FIFO_WORD;
817837
}

0 commit comments

Comments
 (0)