summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorOleg Ryjkov <olegr@olegr.ca>2007-10-13 23:56:33 +0200
committerJean Delvare <khali@hyperion.delvare>2007-10-13 23:56:33 +0200
commitd49584c4a37c7228e7778bcb60f79e7a08472fa8 (patch)
tree73d1d9e7c65d64d2f4cbe0f9fae4f97494df5006 /drivers
parent4153549734cbdba24e9cf5eb200b70b7b1572e15 (diff)
downloadop-kernel-dev-d49584c4a37c7228e7778bcb60f79e7a08472fa8.zip
op-kernel-dev-d49584c4a37c7228e7778bcb60f79e7a08472fa8.tar.gz
i2c-nforce2: Abort the transaction on error
This patch is to add an abort function that will bring back the MCP51/55 controller if it was blocked by a block-read operation, in particular. (When a slave sends a wrong byte count on a byte read, the host gets locked up). I've only tested it on an MCP51 and MCP55. However, I'm almost certain it will also work on MCP65, I just did not have the board to test it on. Thus for now the abort function will only be called if an MCP51/55 was detected. Signed-off-by: Oleg Ryjkov <olegr@olegr.ca> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 1c63c4f..c359eab 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -62,6 +62,7 @@ struct nforce2_smbus {
int base;
int size;
int blockops;
+ int can_abort;
};
@@ -83,7 +84,14 @@ struct nforce2_smbus {
#define NVIDIA_SMB_DATA (smbus->base + 0x04) /* 32 data registers */
#define NVIDIA_SMB_BCNT (smbus->base + 0x24) /* number of data
bytes */
-
+#define NVIDIA_SMB_STATUS_ABRT (smbus->base + 0x3c) /* register used to
+ check the status of
+ the abort command */
+#define NVIDIA_SMB_CTRL (smbus->base + 0x3e) /* control register */
+
+#define NVIDIA_SMB_STATUS_ABRT_STS 0x01 /* Bit to notify that
+ abort succeeded */
+#define NVIDIA_SMB_CTRL_ABORT 0x20
#define NVIDIA_SMB_STS_DONE 0x80
#define NVIDIA_SMB_STS_ALRM 0x40
#define NVIDIA_SMB_STS_RES 0x20
@@ -103,6 +111,25 @@ struct nforce2_smbus {
static struct pci_driver nforce2_driver;
+static void nforce2_abort(struct i2c_adapter *adap)
+{
+ struct nforce2_smbus *smbus = adap->algo_data;
+ int timeout = 0;
+ unsigned char temp;
+
+ dev_dbg(&adap->dev, "Aborting current transaction\n");
+
+ outb_p(NVIDIA_SMB_CTRL_ABORT, NVIDIA_SMB_CTRL);
+ do {
+ msleep(1);
+ temp = inb_p(NVIDIA_SMB_STATUS_ABRT);
+ } while (!(temp & NVIDIA_SMB_STATUS_ABRT_STS) &&
+ (timeout++ < MAX_TIMEOUT));
+ if (!(temp & NVIDIA_SMB_STATUS_ABRT_STS))
+ dev_err(&adap->dev, "Can't reset the smbus\n");
+ outb_p(NVIDIA_SMB_STATUS_ABRT_STS, NVIDIA_SMB_STATUS_ABRT);
+}
+
static int nforce2_check_status(struct i2c_adapter *adap)
{
struct nforce2_smbus *smbus = adap->algo_data;
@@ -116,6 +143,8 @@ static int nforce2_check_status(struct i2c_adapter *adap)
if (timeout >= MAX_TIMEOUT) {
dev_dbg(&adap->dev, "SMBus Timeout!\n");
+ if (smbus->can_abort)
+ nforce2_abort(adap);
return -1;
}
if (!(temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) {
@@ -325,6 +354,8 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_
case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS:
smbuses[0].blockops = 1;
smbuses[1].blockops = 1;
+ smbuses[0].can_abort = 1;
+ smbuses[1].can_abort = 1;
}
/* SMBus adapter 1 */
OpenPOWER on IntegriCloud