diff options
Diffstat (limited to 'meta-phosphor/common/recipes-kernel/linux/linux-obmc/linux-dev-4.10-v2-5-6-drivers-i2c-Add-bus-recovery-for-FSI-algorithm.patch')
-rw-r--r-- | meta-phosphor/common/recipes-kernel/linux/linux-obmc/linux-dev-4.10-v2-5-6-drivers-i2c-Add-bus-recovery-for-FSI-algorithm.patch | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/meta-phosphor/common/recipes-kernel/linux/linux-obmc/linux-dev-4.10-v2-5-6-drivers-i2c-Add-bus-recovery-for-FSI-algorithm.patch b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/linux-dev-4.10-v2-5-6-drivers-i2c-Add-bus-recovery-for-FSI-algorithm.patch new file mode 100644 index 000000000..f9fc75d4a --- /dev/null +++ b/meta-phosphor/common/recipes-kernel/linux/linux-obmc/linux-dev-4.10-v2-5-6-drivers-i2c-Add-bus-recovery-for-FSI-algorithm.patch @@ -0,0 +1,117 @@ +From patchwork Wed May 10 15:52:41 2017 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Subject: [linux, dev-4.10, v2, + 5/6] drivers: i2c: Add bus recovery for FSI algorithm +From: eajames@linux.vnet.ibm.com +X-Patchwork-Id: 760701 +Message-Id: <1494431562-25101-6-git-send-email-eajames@linux.vnet.ibm.com> +To: openbmc@lists.ozlabs.org +Cc: "Edward A. James" <eajames@us.ibm.com>, cbostic@linux.vnet.ibm.com +Date: Wed, 10 May 2017 10:52:41 -0500 + +From: "Edward A. James" <eajames@us.ibm.com> + +Bus recovery should reset the engine and force block the bus 9 times +to recover most situations. + +Signed-off-by: Edward A. James <eajames@us.ibm.com> +--- + drivers/i2c/busses/i2c-fsi.c | 76 ++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 76 insertions(+) + +diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c +index d757aee..4689479 100644 +--- a/drivers/i2c/busses/i2c-fsi.c ++++ b/drivers/i2c/busses/i2c-fsi.c +@@ -467,6 +467,80 @@ static u32 fsi_i2c_functionality(struct i2c_adapter *adap) + return I2C_FUNC_I2C | I2C_FUNC_PROTOCOL_MANGLING | I2C_FUNC_10BIT_ADDR; + } + ++static int fsi_i2c_low_level_recover_bus(struct fsi_i2c_master *i2c) ++{ ++ int i, rc; ++ u32 mode, dummy = 0; ++ ++ rc = fsi_i2c_read_reg(i2c->fsi, I2C_FSI_MODE, &mode); ++ if (rc) ++ return rc; ++ ++ mode |= I2C_MODE_DIAG; ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); ++ if (rc) ++ return rc; ++ ++ for (i = 0; i < 9; ++i) { ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_SCL, &dummy); ++ if (rc) ++ return rc; ++ ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_SET_SCL, &dummy); ++ if (rc) ++ return rc; ++ } ++ ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_SCL, &dummy); ++ if (rc) ++ return rc; ++ ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_SDA, &dummy); ++ if (rc) ++ return rc; ++ ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_SET_SCL, &dummy); ++ if (rc) ++ return rc; ++ ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_SET_SDA, &dummy); ++ if (rc) ++ return rc; ++ ++ mode &= ~I2C_MODE_DIAG; ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_MODE, &mode); ++ ++ return rc; ++} ++ ++static int fsi_i2c_recover_bus(struct i2c_adapter *adap) ++{ ++ int rc; ++ u32 dummy = 0; ++ struct fsi_i2c_port *port = adap->algo_data; ++ struct fsi_i2c_master *i2c = port->master; ++ ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_I2C, &dummy); ++ if (rc) ++ return rc; ++ ++ rc = fsi_i2c_dev_init(i2c); ++ if (rc) ++ return rc; ++ ++ rc = fsi_i2c_low_level_recover_bus(i2c); ++ if (rc) ++ return rc; ++ ++ rc = fsi_i2c_write_reg(i2c->fsi, I2C_FSI_RESET_ERR, &dummy); ++ ++ return rc; ++} ++ ++static struct i2c_bus_recovery_info fsi_i2c_bus_recovery_info = { ++ .recover_bus = fsi_i2c_recover_bus, ++}; ++ + static const struct i2c_algorithm fsi_i2c_algorithm = { + .master_xfer = fsi_i2c_xfer, + .functionality = fsi_i2c_functionality, +@@ -514,6 +588,8 @@ static int fsi_i2c_probe(struct device *dev) + port->adapter.owner = THIS_MODULE; + port->adapter.dev.parent = dev; + port->adapter.algo = &fsi_i2c_algorithm; ++ port->adapter.bus_recovery_info = ++ &fsi_i2c_bus_recovery_info; + port->adapter.algo_data = port; + /* number ports uniquely */ + port->adapter.nr = (i2c->idx * I2C_MASTER_NR_OFFSET) + |