Skip to content

Commit 6692694

Browse files
eichenbergerAndi Shyti
authored andcommitted
i2c: imx: do not poll for bus busy in single master mode
According to the i.MX8M Mini reference manual chapter "16.1.4.2 Generation of Start" it is only necessary to poll for bus busy and arbitration lost in multi master mode. This helps to avoid rescheduling while the i2c bus is busy and avoids SMBus devices to timeout. For backward compatibility, the single-master property needs to be explicitly set to disable the bus busy polling. Signed-off-by: Stefan Eichenberger <[email protected]> Reviewed-by: Frank Li <[email protected]> Acked-by: Oleksij Rempel <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent 6816ce5 commit 6692694

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/i2c/busses/i2c-imx.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ struct imx_i2c_struct {
216216
struct i2c_client *slave;
217217
enum i2c_slave_event last_slave_event;
218218

219+
bool multi_master;
220+
219221
/* For checking slave events. */
220222
spinlock_t slave_lock;
221223
struct hrtimer slave_timer;
@@ -481,6 +483,9 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy, bool a
481483
unsigned long orig_jiffies = jiffies;
482484
unsigned int temp;
483485

486+
if (!i2c_imx->multi_master)
487+
return 0;
488+
484489
while (1) {
485490
temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR);
486491

@@ -540,8 +545,8 @@ static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx, bool atomic)
540545
return -ETIMEDOUT;
541546
}
542547

543-
/* check for arbitration lost */
544-
if (i2c_imx->i2csr & I2SR_IAL) {
548+
/* In multi-master mode check for arbitration lost */
549+
if (i2c_imx->multi_master && (i2c_imx->i2csr & I2SR_IAL)) {
545550
dev_dbg(&i2c_imx->adapter.dev, "<%s> Arbitration lost\n", __func__);
546551
i2c_imx_clear_irq(i2c_imx, I2SR_IAL);
547552

@@ -1468,6 +1473,12 @@ static int i2c_imx_probe(struct platform_device *pdev)
14681473
goto rpm_disable;
14691474
}
14701475

1476+
/*
1477+
* We use the single-master property for backward compatibility.
1478+
* By default multi master mode is enabled.
1479+
*/
1480+
i2c_imx->multi_master = !of_property_read_bool(pdev->dev.of_node, "single-master");
1481+
14711482
/* Set up clock divider */
14721483
i2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ;
14731484
ret = of_property_read_u32(pdev->dev.of_node,

0 commit comments

Comments
 (0)