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 <stefan.eichenberger@toradex.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Acked-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
This commit is contained in:
parent
6816ce57c4
commit
6692694aca
1 changed files with 13 additions and 2 deletions
|
@ -216,6 +216,8 @@ struct imx_i2c_struct {
|
||||||
struct i2c_client *slave;
|
struct i2c_client *slave;
|
||||||
enum i2c_slave_event last_slave_event;
|
enum i2c_slave_event last_slave_event;
|
||||||
|
|
||||||
|
bool multi_master;
|
||||||
|
|
||||||
/* For checking slave events. */
|
/* For checking slave events. */
|
||||||
spinlock_t slave_lock;
|
spinlock_t slave_lock;
|
||||||
struct hrtimer slave_timer;
|
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
|
||||||
unsigned long orig_jiffies = jiffies;
|
unsigned long orig_jiffies = jiffies;
|
||||||
unsigned int temp;
|
unsigned int temp;
|
||||||
|
|
||||||
|
if (!i2c_imx->multi_master)
|
||||||
|
return 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR);
|
temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR);
|
||||||
|
|
||||||
|
@ -540,8 +545,8 @@ static int i2c_imx_trx_complete(struct imx_i2c_struct *i2c_imx, bool atomic)
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for arbitration lost */
|
/* In multi-master mode check for arbitration lost */
|
||||||
if (i2c_imx->i2csr & I2SR_IAL) {
|
if (i2c_imx->multi_master && (i2c_imx->i2csr & I2SR_IAL)) {
|
||||||
dev_dbg(&i2c_imx->adapter.dev, "<%s> Arbitration lost\n", __func__);
|
dev_dbg(&i2c_imx->adapter.dev, "<%s> Arbitration lost\n", __func__);
|
||||||
i2c_imx_clear_irq(i2c_imx, I2SR_IAL);
|
i2c_imx_clear_irq(i2c_imx, I2SR_IAL);
|
||||||
|
|
||||||
|
@ -1468,6 +1473,12 @@ static int i2c_imx_probe(struct platform_device *pdev)
|
||||||
goto rpm_disable;
|
goto rpm_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We use the single-master property for backward compatibility.
|
||||||
|
* By default multi master mode is enabled.
|
||||||
|
*/
|
||||||
|
i2c_imx->multi_master = !of_property_read_bool(pdev->dev.of_node, "single-master");
|
||||||
|
|
||||||
/* Set up clock divider */
|
/* Set up clock divider */
|
||||||
i2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ;
|
i2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ;
|
||||||
ret = of_property_read_u32(pdev->dev.of_node,
|
ret = of_property_read_u32(pdev->dev.of_node,
|
||||||
|
|
Loading…
Add table
Reference in a new issue