aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 1c63c4f2e4b6..c359eabe85fb 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -62,6 +62,7 @@ struct nforce2_smbus {
62 int base; 62 int base;
63 int size; 63 int size;
64 int blockops; 64 int blockops;
65 int can_abort;
65}; 66};
66 67
67 68
@@ -83,7 +84,14 @@ struct nforce2_smbus {
83#define NVIDIA_SMB_DATA (smbus->base + 0x04) /* 32 data registers */ 84#define NVIDIA_SMB_DATA (smbus->base + 0x04) /* 32 data registers */
84#define NVIDIA_SMB_BCNT (smbus->base + 0x24) /* number of data 85#define NVIDIA_SMB_BCNT (smbus->base + 0x24) /* number of data
85 bytes */ 86 bytes */
86 87#define NVIDIA_SMB_STATUS_ABRT (smbus->base + 0x3c) /* register used to
88 check the status of
89 the abort command */
90#define NVIDIA_SMB_CTRL (smbus->base + 0x3e) /* control register */
91
92#define NVIDIA_SMB_STATUS_ABRT_STS 0x01 /* Bit to notify that
93 abort succeeded */
94#define NVIDIA_SMB_CTRL_ABORT 0x20
87#define NVIDIA_SMB_STS_DONE 0x80 95#define NVIDIA_SMB_STS_DONE 0x80
88#define NVIDIA_SMB_STS_ALRM 0x40 96#define NVIDIA_SMB_STS_ALRM 0x40
89#define NVIDIA_SMB_STS_RES 0x20 97#define NVIDIA_SMB_STS_RES 0x20
@@ -103,6 +111,25 @@ struct nforce2_smbus {
103 111
104static struct pci_driver nforce2_driver; 112static struct pci_driver nforce2_driver;
105 113
114static void nforce2_abort(struct i2c_adapter *adap)
115{
116 struct nforce2_smbus *smbus = adap->algo_data;
117 int timeout = 0;
118 unsigned char temp;
119
120 dev_dbg(&adap->dev, "Aborting current transaction\n");
121
122 outb_p(NVIDIA_SMB_CTRL_ABORT, NVIDIA_SMB_CTRL);
123 do {
124 msleep(1);
125 temp = inb_p(NVIDIA_SMB_STATUS_ABRT);
126 } while (!(temp & NVIDIA_SMB_STATUS_ABRT_STS) &&
127 (timeout++ < MAX_TIMEOUT));
128 if (!(temp & NVIDIA_SMB_STATUS_ABRT_STS))
129 dev_err(&adap->dev, "Can't reset the smbus\n");
130 outb_p(NVIDIA_SMB_STATUS_ABRT_STS, NVIDIA_SMB_STATUS_ABRT);
131}
132
106static int nforce2_check_status(struct i2c_adapter *adap) 133static int nforce2_check_status(struct i2c_adapter *adap)
107{ 134{
108 struct nforce2_smbus *smbus = adap->algo_data; 135 struct nforce2_smbus *smbus = adap->algo_data;
@@ -116,6 +143,8 @@ static int nforce2_check_status(struct i2c_adapter *adap)
116 143
117 if (timeout >= MAX_TIMEOUT) { 144 if (timeout >= MAX_TIMEOUT) {
118 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 145 dev_dbg(&adap->dev, "SMBus Timeout!\n");
146 if (smbus->can_abort)
147 nforce2_abort(adap);
119 return -1; 148 return -1;
120 } 149 }
121 if (!(temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) { 150 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_
325 case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS: 354 case PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_SMBUS:
326 smbuses[0].blockops = 1; 355 smbuses[0].blockops = 1;
327 smbuses[1].blockops = 1; 356 smbuses[1].blockops = 1;
357 smbuses[0].can_abort = 1;
358 smbuses[1].can_abort = 1;
328 } 359 }
329 360
330 /* SMBus adapter 1 */ 361 /* SMBus adapter 1 */