diff options
author | Oleg Ryjkov <olegr@olegr.ca> | 2007-10-13 17:56:33 -0400 |
---|---|---|
committer | Jean Delvare <khali@hyperion.delvare> | 2007-10-13 17:56:33 -0400 |
commit | d49584c4a37c7228e7778bcb60f79e7a08472fa8 (patch) | |
tree | 73d1d9e7c65d64d2f4cbe0f9fae4f97494df5006 | |
parent | 4153549734cbdba24e9cf5eb200b70b7b1572e15 (diff) |
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>
-rw-r--r-- | drivers/i2c/busses/i2c-nforce2.c | 33 |
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 | ||
104 | static struct pci_driver nforce2_driver; | 112 | static struct pci_driver nforce2_driver; |
105 | 113 | ||
114 | static 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 | |||
106 | static int nforce2_check_status(struct i2c_adapter *adap) | 133 | static 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 */ |