Commit 65171b2d authored by Chris Packham's avatar Chris Packham Committed by Wolfram Sang

i2c: mpc: Make use of i2c_recover_bus()

Move the existing calls of mpc_i2c_fixup() to a recovery function
registered via bus_recovery_info. This makes it more obvious that
recovery is supported and allows for a future where recovery is
triggered by the i2c core.
Signed-off-by: default avatarChris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 81acb401
...@@ -586,7 +586,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) ...@@ -586,7 +586,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) { if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) {
writeb(status & ~CSR_MAL, writeb(status & ~CSR_MAL,
i2c->base + MPC_I2C_SR); i2c->base + MPC_I2C_SR);
mpc_i2c_fixup(i2c); i2c_recover_bus(&i2c->adap);
} }
return -EIO; return -EIO;
} }
...@@ -622,7 +622,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) ...@@ -622,7 +622,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) { if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) {
writeb(status & ~CSR_MAL, writeb(status & ~CSR_MAL,
i2c->base + MPC_I2C_SR); i2c->base + MPC_I2C_SR);
mpc_i2c_fixup(i2c); i2c_recover_bus(&i2c->adap);
} }
return -EIO; return -EIO;
} }
...@@ -637,6 +637,15 @@ static u32 mpc_functionality(struct i2c_adapter *adap) ...@@ -637,6 +637,15 @@ static u32 mpc_functionality(struct i2c_adapter *adap)
| I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL; | I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL;
} }
static int fsl_i2c_bus_recovery(struct i2c_adapter *adap)
{
struct mpc_i2c *i2c = i2c_get_adapdata(adap);
mpc_i2c_fixup(i2c);
return 0;
}
static const struct i2c_algorithm mpc_algo = { static const struct i2c_algorithm mpc_algo = {
.master_xfer = mpc_xfer, .master_xfer = mpc_xfer,
.functionality = mpc_functionality, .functionality = mpc_functionality,
...@@ -648,6 +657,10 @@ static struct i2c_adapter mpc_ops = { ...@@ -648,6 +657,10 @@ static struct i2c_adapter mpc_ops = {
.timeout = HZ, .timeout = HZ,
}; };
static struct i2c_bus_recovery_info fsl_i2c_recovery_info = {
.recover_bus = fsl_i2c_bus_recovery,
};
static const struct of_device_id mpc_i2c_of_match[]; static const struct of_device_id mpc_i2c_of_match[];
static int fsl_i2c_probe(struct platform_device *op) static int fsl_i2c_probe(struct platform_device *op)
{ {
...@@ -740,6 +753,7 @@ static int fsl_i2c_probe(struct platform_device *op) ...@@ -740,6 +753,7 @@ static int fsl_i2c_probe(struct platform_device *op)
i2c_set_adapdata(&i2c->adap, i2c); i2c_set_adapdata(&i2c->adap, i2c);
i2c->adap.dev.parent = &op->dev; i2c->adap.dev.parent = &op->dev;
i2c->adap.dev.of_node = of_node_get(op->dev.of_node); i2c->adap.dev.of_node = of_node_get(op->dev.of_node);
i2c->adap.bus_recovery_info = &fsl_i2c_recovery_info;
result = i2c_add_adapter(&i2c->adap); result = i2c_add_adapter(&i2c->adap);
if (result < 0) if (result < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment