blob: 15517d78d5ff07d25913bc657cf30640ef97531d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/**
2 * i2c-ali1563.c - i2c driver for the ALi 1563 Southbridge
3 *
4 * Copyright (C) 2004 Patrick Mochel
Jean Delvare7188cc62006-12-12 18:18:30 +01005 * 2005 Rudolf Marek <r.marek@assembler.cz>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * The 1563 southbridge is deceptively similar to the 1533, with a
8 * few notable exceptions. One of those happens to be the fact they
9 * upgraded the i2c core to be 2.0 compliant, and happens to be almost
10 * identical to the i2c controller found in the Intel 801 south
11 * bridges.
12 *
13 * This driver is based on a mix of the 15x3, 1535, and i801 drivers,
14 * with a little help from the ALi 1563 spec.
15 *
16 * This file is released under the GPLv2
17 */
18
19#include <linux/module.h>
20#include <linux/delay.h>
21#include <linux/i2c.h>
22#include <linux/pci.h>
Jean Delvare54fb4a052008-07-14 22:38:33 +020023#include <linux/acpi.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25#define ALI1563_MAX_TIMEOUT 500
26#define ALI1563_SMBBA 0x80
27#define ALI1563_SMB_IOEN 1
28#define ALI1563_SMB_HOSTEN 2
29#define ALI1563_SMB_IOSIZE 16
30
31#define SMB_HST_STS (ali1563_smba + 0)
32#define SMB_HST_CNTL1 (ali1563_smba + 1)
33#define SMB_HST_CNTL2 (ali1563_smba + 2)
34#define SMB_HST_CMD (ali1563_smba + 3)
35#define SMB_HST_ADD (ali1563_smba + 4)
36#define SMB_HST_DAT0 (ali1563_smba + 5)
37#define SMB_HST_DAT1 (ali1563_smba + 6)
38#define SMB_BLK_DAT (ali1563_smba + 7)
39
40#define HST_STS_BUSY 0x01
41#define HST_STS_INTR 0x02
42#define HST_STS_DEVERR 0x04
43#define HST_STS_BUSERR 0x08
44#define HST_STS_FAIL 0x10
45#define HST_STS_DONE 0x80
46#define HST_STS_BAD 0x1c
47
48
49#define HST_CNTL1_TIMEOUT 0x80
50#define HST_CNTL1_LAST 0x40
51
52#define HST_CNTL2_KILL 0x04
53#define HST_CNTL2_START 0x40
54#define HST_CNTL2_QUICK 0x00
55#define HST_CNTL2_BYTE 0x01
56#define HST_CNTL2_BYTE_DATA 0x02
57#define HST_CNTL2_WORD_DATA 0x03
58#define HST_CNTL2_BLOCK 0x05
59
60
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +000061#define HST_CNTL2_SIZEMASK 0x38
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Jean Delvared6072f82005-09-25 16:37:04 +020063static struct pci_driver ali1563_pci_driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064static unsigned short ali1563_smba;
65
Richard Leitner482116b2014-04-11 13:44:44 +020066static int ali1563_transaction(struct i2c_adapter *a, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067{
68 u32 data;
69 int timeout;
David Brownell97140342008-07-14 22:38:25 +020070 int status = -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72 dev_dbg(&a->dev, "Transaction (pre): STS=%02x, CNTL1=%02x, "
73 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
74 inb_p(SMB_HST_STS), inb_p(SMB_HST_CNTL1), inb_p(SMB_HST_CNTL2),
75 inb_p(SMB_HST_CMD), inb_p(SMB_HST_ADD), inb_p(SMB_HST_DAT0),
76 inb_p(SMB_HST_DAT1));
77
78 data = inb_p(SMB_HST_STS);
79 if (data & HST_STS_BAD) {
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +000080 dev_err(&a->dev, "ali1563: Trying to reset busy device\n");
Richard Leitner482116b2014-04-11 13:44:44 +020081 outb_p(data | HST_STS_BAD, SMB_HST_STS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 data = inb_p(SMB_HST_STS);
83 if (data & HST_STS_BAD)
84 return -EBUSY;
85 }
86 outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2);
87
88 timeout = ALI1563_MAX_TIMEOUT;
Márton Németh7d53e792010-01-16 20:43:13 +010089 do {
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 msleep(1);
Márton Németh7d53e792010-01-16 20:43:13 +010091 } while (((data = inb_p(SMB_HST_STS)) & HST_STS_BUSY) && --timeout);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93 dev_dbg(&a->dev, "Transaction (post): STS=%02x, CNTL1=%02x, "
94 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
95 inb_p(SMB_HST_STS), inb_p(SMB_HST_CNTL1), inb_p(SMB_HST_CNTL2),
96 inb_p(SMB_HST_CMD), inb_p(SMB_HST_ADD), inb_p(SMB_HST_DAT0),
97 inb_p(SMB_HST_DAT1));
98
99 if (timeout && !(data & HST_STS_BAD))
100 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000102 if (!timeout) {
103 dev_err(&a->dev, "Timeout - Trying to KILL transaction!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 /* Issue 'kill' to host controller */
Richard Leitner482116b2014-04-11 13:44:44 +0200105 outb_p(HST_CNTL2_KILL, SMB_HST_CNTL2);
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000106 data = inb_p(SMB_HST_STS);
David Brownell97140342008-07-14 22:38:25 +0200107 status = -ETIMEDOUT;
Richard Leitner482116b2014-04-11 13:44:44 +0200108 }
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000109
110 /* device error - no response, ignore the autodetection case */
David Brownell97140342008-07-14 22:38:25 +0200111 if (data & HST_STS_DEVERR) {
112 if (size != HST_CNTL2_QUICK)
113 dev_err(&a->dev, "Device error!\n");
114 status = -ENXIO;
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000115 }
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000116 /* bus collision */
117 if (data & HST_STS_BUSERR) {
118 dev_err(&a->dev, "Bus collision!\n");
119 /* Issue timeout, hoping it helps */
Richard Leitner482116b2014-04-11 13:44:44 +0200120 outb_p(HST_CNTL1_TIMEOUT, SMB_HST_CNTL1);
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000121 }
122
123 if (data & HST_STS_FAIL) {
124 dev_err(&a->dev, "Cleaning fail after KILL!\n");
Richard Leitner482116b2014-04-11 13:44:44 +0200125 outb_p(0x0, SMB_HST_CNTL2);
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000126 }
127
David Brownell97140342008-07-14 22:38:25 +0200128 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129}
130
Richard Leitner482116b2014-04-11 13:44:44 +0200131static int ali1563_block_start(struct i2c_adapter *a)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132{
133 u32 data;
134 int timeout;
David Brownell97140342008-07-14 22:38:25 +0200135 int status = -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137 dev_dbg(&a->dev, "Block (pre): STS=%02x, CNTL1=%02x, "
138 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
139 inb_p(SMB_HST_STS), inb_p(SMB_HST_CNTL1), inb_p(SMB_HST_CNTL2),
140 inb_p(SMB_HST_CMD), inb_p(SMB_HST_ADD), inb_p(SMB_HST_DAT0),
141 inb_p(SMB_HST_DAT1));
142
143 data = inb_p(SMB_HST_STS);
144 if (data & HST_STS_BAD) {
Richard Leitner482116b2014-04-11 13:44:44 +0200145 dev_warn(&a->dev, "ali1563: Trying to reset busy device\n");
146 outb_p(data | HST_STS_BAD, SMB_HST_STS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 data = inb_p(SMB_HST_STS);
148 if (data & HST_STS_BAD)
149 return -EBUSY;
150 }
151
152 /* Clear byte-ready bit */
153 outb_p(data | HST_STS_DONE, SMB_HST_STS);
154
155 /* Start transaction and wait for byte-ready bit to be set */
156 outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2);
157
158 timeout = ALI1563_MAX_TIMEOUT;
Márton Németh7d53e792010-01-16 20:43:13 +0100159 do {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 msleep(1);
Márton Németh7d53e792010-01-16 20:43:13 +0100161 } while (!((data = inb_p(SMB_HST_STS)) & HST_STS_DONE) && --timeout);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163 dev_dbg(&a->dev, "Block (post): STS=%02x, CNTL1=%02x, "
164 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
165 inb_p(SMB_HST_STS), inb_p(SMB_HST_CNTL1), inb_p(SMB_HST_CNTL2),
166 inb_p(SMB_HST_CMD), inb_p(SMB_HST_ADD), inb_p(SMB_HST_DAT0),
167 inb_p(SMB_HST_DAT1));
168
169 if (timeout && !(data & HST_STS_BAD))
170 return 0;
David Brownell97140342008-07-14 22:38:25 +0200171
172 if (timeout == 0)
173 status = -ETIMEDOUT;
174
175 if (data & HST_STS_DEVERR)
176 status = -ENXIO;
177
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000178 dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n",
David Brownell97140342008-07-14 22:38:25 +0200179 timeout ? "" : "Timeout ",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 data & HST_STS_FAIL ? "Transaction Failed " : "",
181 data & HST_STS_BUSERR ? "No response or Bus Collision " : "",
182 data & HST_STS_DEVERR ? "Device Error " : "",
183 !(data & HST_STS_DONE) ? "Transaction Never Finished " : "");
David Brownell97140342008-07-14 22:38:25 +0200184 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185}
186
Richard Leitner482116b2014-04-11 13:44:44 +0200187static int ali1563_block(struct i2c_adapter *a,
188 union i2c_smbus_data *data, u8 rw)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189{
190 int i, len;
191 int error = 0;
192
193 /* Do we need this? */
Richard Leitner482116b2014-04-11 13:44:44 +0200194 outb_p(HST_CNTL1_LAST, SMB_HST_CNTL1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
196 if (rw == I2C_SMBUS_WRITE) {
197 len = data->block[0];
198 if (len < 1)
199 len = 1;
200 else if (len > 32)
201 len = 32;
Richard Leitner482116b2014-04-11 13:44:44 +0200202 outb_p(len, SMB_HST_DAT0);
203 outb_p(data->block[1], SMB_BLK_DAT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 } else
205 len = 32;
206
207 outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_BLOCK, SMB_HST_CNTL2);
208
209 for (i = 0; i < len; i++) {
210 if (rw == I2C_SMBUS_WRITE) {
211 outb_p(data->block[i + 1], SMB_BLK_DAT);
Richard Leitner482116b2014-04-11 13:44:44 +0200212 error = ali1563_block_start(a);
213 if (error)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 break;
215 } else {
Richard Leitner482116b2014-04-11 13:44:44 +0200216 error = ali1563_block_start(a);
217 if (error)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 break;
219 if (i == 0) {
220 len = inb_p(SMB_HST_DAT0);
221 if (len < 1)
222 len = 1;
223 else if (len > 32)
224 len = 32;
225 }
226 data->block[i+1] = inb_p(SMB_BLK_DAT);
227 }
228 }
229 /* Do we need this? */
Richard Leitner482116b2014-04-11 13:44:44 +0200230 outb_p(HST_CNTL1_LAST, SMB_HST_CNTL1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 return error;
232}
233
Richard Leitner482116b2014-04-11 13:44:44 +0200234static s32 ali1563_access(struct i2c_adapter *a, u16 addr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 unsigned short flags, char rw, u8 cmd,
Richard Leitner482116b2014-04-11 13:44:44 +0200236 int size, union i2c_smbus_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237{
238 int error = 0;
239 int timeout;
240 u32 reg;
241
242 for (timeout = ALI1563_MAX_TIMEOUT; timeout; timeout--) {
Richard Leitner482116b2014-04-11 13:44:44 +0200243 reg = inb_p(SMB_HST_STS);
244 if (!(reg & HST_STS_BUSY))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 break;
246 }
247 if (!timeout)
Richard Leitner482116b2014-04-11 13:44:44 +0200248 dev_warn(&a->dev, "SMBus not idle. HST_STS = %02x\n", reg);
249 outb_p(0xff, SMB_HST_STS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250
251 /* Map the size to what the chip understands */
252 switch (size) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 case I2C_SMBUS_QUICK:
254 size = HST_CNTL2_QUICK;
255 break;
256 case I2C_SMBUS_BYTE:
257 size = HST_CNTL2_BYTE;
258 break;
259 case I2C_SMBUS_BYTE_DATA:
260 size = HST_CNTL2_BYTE_DATA;
261 break;
262 case I2C_SMBUS_WORD_DATA:
263 size = HST_CNTL2_WORD_DATA;
264 break;
265 case I2C_SMBUS_BLOCK_DATA:
266 size = HST_CNTL2_BLOCK;
267 break;
Jean Delvareac7fc4f2008-07-14 22:38:25 +0200268 default:
269 dev_warn(&a->dev, "Unsupported transaction %d\n", size);
270 error = -EOPNOTSUPP;
271 goto Done;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 }
273
274 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD);
Richard Leitner482116b2014-04-11 13:44:44 +0200275 outb_p((inb_p(SMB_HST_CNTL2) & ~HST_CNTL2_SIZEMASK) |
276 (size << 3), SMB_HST_CNTL2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
278 /* Write the command register */
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000279
Richard Leitner482116b2014-04-11 13:44:44 +0200280 switch (size) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 case HST_CNTL2_BYTE:
Richard Leitner482116b2014-04-11 13:44:44 +0200282 if (rw == I2C_SMBUS_WRITE)
R.Marek@sh.cvut.cz4a4e5782005-04-21 09:07:56 +0000283 /* Beware it uses DAT0 register and not CMD! */
284 outb_p(cmd, SMB_HST_DAT0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 break;
286 case HST_CNTL2_BYTE_DATA:
287 outb_p(cmd, SMB_HST_CMD);
288 if (rw == I2C_SMBUS_WRITE)
289 outb_p(data->byte, SMB_HST_DAT0);
290 break;
291 case HST_CNTL2_WORD_DATA:
292 outb_p(cmd, SMB_HST_CMD);
293 if (rw == I2C_SMBUS_WRITE) {
294 outb_p(data->word & 0xff, SMB_HST_DAT0);
295 outb_p((data->word & 0xff00) >> 8, SMB_HST_DAT1);
296 }
297 break;
298 case HST_CNTL2_BLOCK:
299 outb_p(cmd, SMB_HST_CMD);
Richard Leitner482116b2014-04-11 13:44:44 +0200300 error = ali1563_block(a, data, rw);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 goto Done;
302 }
303
Richard Leitner482116b2014-04-11 13:44:44 +0200304 error = ali1563_transaction(a, size);
305 if (error)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 goto Done;
307
308 if ((rw == I2C_SMBUS_WRITE) || (size == HST_CNTL2_QUICK))
309 goto Done;
310
311 switch (size) {
312 case HST_CNTL2_BYTE: /* Result put in SMBHSTDAT0 */
313 data->byte = inb_p(SMB_HST_DAT0);
314 break;
315 case HST_CNTL2_BYTE_DATA:
316 data->byte = inb_p(SMB_HST_DAT0);
317 break;
318 case HST_CNTL2_WORD_DATA:
319 data->word = inb_p(SMB_HST_DAT0) + (inb_p(SMB_HST_DAT1) << 8);
320 break;
321 }
322Done:
323 return error;
324}
325
Richard Leitner482116b2014-04-11 13:44:44 +0200326static u32 ali1563_func(struct i2c_adapter *a)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
328 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
329 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
330 I2C_FUNC_SMBUS_BLOCK_DATA;
331}
332
333
Bill Pemberton0b255e92012-11-27 15:59:38 -0500334static int ali1563_setup(struct pci_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335{
336 u16 ctrl;
337
Richard Leitner482116b2014-04-11 13:44:44 +0200338 pci_read_config_word(dev, ALI1563_SMBBA, &ctrl);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 /* SMB I/O Base in high 12 bits and must be aligned with the
341 * size of the I/O space. */
342 ali1563_smba = ctrl & ~(ALI1563_SMB_IOSIZE - 1);
343 if (!ali1563_smba) {
Richard Leitner482116b2014-04-11 13:44:44 +0200344 dev_warn(&dev->dev, "ali1563_smba Uninitialized\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 goto Err;
346 }
Jean Delvare849be512007-02-13 22:08:57 +0100347
348 /* Check if device is enabled */
349 if (!(ctrl & ALI1563_SMB_HOSTEN)) {
350 dev_warn(&dev->dev, "Host Controller not enabled\n");
351 goto Err;
352 }
353 if (!(ctrl & ALI1563_SMB_IOEN)) {
354 dev_warn(&dev->dev, "I/O space not enabled, trying manually\n");
355 pci_write_config_word(dev, ALI1563_SMBBA,
356 ctrl | ALI1563_SMB_IOEN);
357 pci_read_config_word(dev, ALI1563_SMBBA, &ctrl);
358 if (!(ctrl & ALI1563_SMB_IOEN)) {
Richard Leitner482116b2014-04-11 13:44:44 +0200359 dev_err(&dev->dev,
360 "I/O space still not enabled, giving up\n");
Jean Delvare849be512007-02-13 22:08:57 +0100361 goto Err;
362 }
363 }
364
Jean Delvare54fb4a052008-07-14 22:38:33 +0200365 if (acpi_check_region(ali1563_smba, ALI1563_SMB_IOSIZE,
366 ali1563_pci_driver.name))
367 goto Err;
368
Jean Delvared6072f82005-09-25 16:37:04 +0200369 if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE,
370 ali1563_pci_driver.name)) {
Jean Delvare69735692007-02-13 22:08:57 +0100371 dev_err(&dev->dev, "Could not allocate I/O space at 0x%04x\n",
372 ali1563_smba);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 goto Err;
374 }
Jean Delvare69735692007-02-13 22:08:57 +0100375 dev_info(&dev->dev, "Found ALi1563 SMBus at 0x%04x\n", ali1563_smba);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376
377 return 0;
378Err:
379 return -ENODEV;
380}
381
382static void ali1563_shutdown(struct pci_dev *dev)
383{
Richard Leitner482116b2014-04-11 13:44:44 +0200384 release_region(ali1563_smba, ALI1563_SMB_IOSIZE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385}
386
Jean Delvare8f9082c2006-09-03 22:39:46 +0200387static const struct i2c_algorithm ali1563_algorithm = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 .smbus_xfer = ali1563_access,
389 .functionality = ali1563_func,
390};
391
392static struct i2c_adapter ali1563_adapter = {
393 .owner = THIS_MODULE,
Jean Delvare3401b2f2008-07-14 22:38:29 +0200394 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 .algo = &ali1563_algorithm,
396};
397
Bill Pemberton0b255e92012-11-27 15:59:38 -0500398static int ali1563_probe(struct pci_dev *dev,
399 const struct pci_device_id *id_table)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400{
401 int error;
402
Richard Leitner482116b2014-04-11 13:44:44 +0200403 error = ali1563_setup(dev);
404 if (error)
Jean Delvare69735692007-02-13 22:08:57 +0100405 goto exit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 ali1563_adapter.dev.parent = &dev->dev;
Jean Delvare66c7acf2009-01-07 14:29:18 +0100407 snprintf(ali1563_adapter.name, sizeof(ali1563_adapter.name),
408 "SMBus ALi 1563 Adapter @ %04x", ali1563_smba);
Richard Leitner482116b2014-04-11 13:44:44 +0200409 error = i2c_add_adapter(&ali1563_adapter);
410 if (error)
Jean Delvare69735692007-02-13 22:08:57 +0100411 goto exit_shutdown;
412 return 0;
413
414exit_shutdown:
415 ali1563_shutdown(dev);
416exit:
417 dev_warn(&dev->dev, "ALi1563 SMBus probe failed (%d)\n", error);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 return error;
419}
420
Bill Pemberton0b255e92012-11-27 15:59:38 -0500421static void ali1563_remove(struct pci_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422{
423 i2c_del_adapter(&ali1563_adapter);
424 ali1563_shutdown(dev);
425}
426
Jingoo Han392debf2013-12-03 08:11:20 +0900427static const struct pci_device_id ali1563_id_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1563) },
429 {},
430};
431
Richard Leitner482116b2014-04-11 13:44:44 +0200432MODULE_DEVICE_TABLE(pci, ali1563_id_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433
434static struct pci_driver ali1563_pci_driver = {
Richard Leitner482116b2014-04-11 13:44:44 +0200435 .name = "ali1563_smbus",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 .id_table = ali1563_id_table,
Richard Leitner482116b2014-04-11 13:44:44 +0200437 .probe = ali1563_probe,
Bill Pemberton0b255e92012-11-27 15:59:38 -0500438 .remove = ali1563_remove,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439};
440
Axel Lin56f21782012-07-24 14:13:56 +0200441module_pci_driver(ali1563_pci_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
443MODULE_LICENSE("GPL");