blob: 5cf8fe182806173c5fb27599759752a467e7283e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
Jean Delvare5f49ef82005-09-22 21:50:47 +02004 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>,
6 Mark D. Studebaker <mdsxyz123@yahoo.com>
Jean Delvaref1183012005-09-22 21:58:41 +02007 Copyright (C) 2005 Jean Delvare <khali@linux-fr.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/
23
24/*
25 Supports Via devices:
26 82C596A/B (0x3050)
27 82C596B (0x3051)
28 82C686A/B
29 8231
30 8233
31 8233A (0x3147 and 0x3177)
32 8235
33 8237
34 Note: we assume there can only be one device, with one SMBus interface.
35*/
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <linux/module.h>
38#include <linux/delay.h>
39#include <linux/pci.h>
40#include <linux/kernel.h>
41#include <linux/stddef.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <linux/ioport.h>
43#include <linux/i2c.h>
44#include <linux/init.h>
45#include <asm/io.h>
46
47static struct pci_dev *vt596_pdev;
48
Jean Delvare5f49ef82005-09-22 21:50:47 +020049#define SMBBA1 0x90
50#define SMBBA2 0x80
51#define SMBBA3 0xD0
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53/* SMBus address offsets */
54static unsigned short vt596_smba;
55#define SMBHSTSTS (vt596_smba + 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056#define SMBHSTCNT (vt596_smba + 2)
57#define SMBHSTCMD (vt596_smba + 3)
58#define SMBHSTADD (vt596_smba + 4)
59#define SMBHSTDAT0 (vt596_smba + 5)
60#define SMBHSTDAT1 (vt596_smba + 6)
61#define SMBBLKDAT (vt596_smba + 7)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63/* PCI Address Constants */
64
65/* SMBus data in configuration space can be found in two places,
Jean Delvare5f49ef82005-09-22 21:50:47 +020066 We try to select the better one */
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Jean Delvarec2f559d2005-09-22 22:01:07 +020068static unsigned short SMBHSTCFG = 0xD2;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70/* Other settings */
71#define MAX_TIMEOUT 500
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73/* VT82C596 constants */
Jean Delvare5f49ef82005-09-22 21:50:47 +020074#define VT596_QUICK 0x00
75#define VT596_BYTE 0x04
76#define VT596_BYTE_DATA 0x08
77#define VT596_WORD_DATA 0x0C
78#define VT596_BLOCK_DATA 0x14
Jean Delvaref1183012005-09-22 21:58:41 +020079#define VT596_I2C_BLOCK_DATA 0x34
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81
82/* If force is set to anything different from 0, we forcibly enable the
83 VT596. DANGEROUS! */
84static int force;
85module_param(force, bool, 0);
86MODULE_PARM_DESC(force, "Forcibly enable the SMBus. DANGEROUS!");
87
88/* If force_addr is set to anything different from 0, we forcibly enable
89 the VT596 at the given address. VERY DANGEROUS! */
90static u16 force_addr;
91module_param(force_addr, ushort, 0);
92MODULE_PARM_DESC(force_addr,
93 "Forcibly enable the SMBus at the given address. "
94 "EXTREMELY DANGEROUS!");
95
96
Jean Delvarec2f559d2005-09-22 22:01:07 +020097static struct pci_driver vt596_driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098static struct i2c_adapter vt596_adapter;
99
Jean Delvaref1183012005-09-22 21:58:41 +0200100#define FEATURE_I2CBLOCK (1<<0)
101static unsigned int vt596_features;
102
Jean Delvarec2f559d2005-09-22 22:01:07 +0200103/* Return -1 on error, 0 on success */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104static int vt596_transaction(void)
105{
106 int temp;
107 int result = 0;
108 int timeout = 0;
109
110 dev_dbg(&vt596_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
Jean Delvare5f49ef82005-09-22 21:50:47 +0200111 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
112 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 inb_p(SMBHSTDAT1));
114
115 /* Make sure the SMBus host is ready to start transmitting */
116 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
117 dev_dbg(&vt596_adapter.dev, "SMBus busy (0x%02x). "
Jean Delvarec2f559d2005-09-22 22:01:07 +0200118 "Resetting... ", temp);
Jean Delvare5f49ef82005-09-22 21:50:47 +0200119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 outb_p(temp, SMBHSTSTS);
121 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
Jean Delvarec2f559d2005-09-22 22:01:07 +0200122 printk("Failed! (0x%02x)\n", temp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 return -1;
124 } else {
Jean Delvarec2f559d2005-09-22 22:01:07 +0200125 printk("Successful!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 }
127 }
128
Jean Delvarec2f559d2005-09-22 22:01:07 +0200129 /* Start the transaction by setting bit 6 */
130 outb_p(inb(SMBHSTCNT) | 0x40, SMBHSTCNT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Jean Delvarec2f559d2005-09-22 22:01:07 +0200132 /* We will always wait for a fraction of a second */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 do {
134 msleep(1);
135 temp = inb_p(SMBHSTSTS);
136 } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
137
138 /* If the SMBus is still busy, we give up */
139 if (timeout >= MAX_TIMEOUT) {
140 result = -1;
Jean Delvarec2f559d2005-09-22 22:01:07 +0200141 dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 }
143
144 if (temp & 0x10) {
145 result = -1;
Jean Delvarec2f559d2005-09-22 22:01:07 +0200146 dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n",
147 inb_p(SMBHSTCNT) & 0x3C);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 }
149
150 if (temp & 0x08) {
151 result = -1;
Jean Delvarec2f559d2005-09-22 22:01:07 +0200152 dev_err(&vt596_adapter.dev, "SMBus collision!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 }
154
155 if (temp & 0x04) {
156 result = -1;
Jean Delvarec2f559d2005-09-22 22:01:07 +0200157 /* Quick commands are used to probe for chips, so
158 errors are expected, and we don't want to frighten the
159 user. */
160 if ((inb_p(SMBHSTCNT) & 0x3C) != VT596_QUICK)
161 dev_err(&vt596_adapter.dev, "Transaction error!\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 }
163
Jean Delvarec2f559d2005-09-22 22:01:07 +0200164 /* Resetting status register */
165 if (temp & 0x1F)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 outb_p(temp, SMBHSTSTS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
168 dev_dbg(&vt596_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, "
169 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
Jean Delvare5f49ef82005-09-22 21:50:47 +0200170 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 inb_p(SMBHSTDAT1));
Jean Delvare5f49ef82005-09-22 21:50:47 +0200172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 return result;
174}
175
Jean Delvarec2f559d2005-09-22 22:01:07 +0200176/* Return -1 on error, 0 on success */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
Jean Delvare5f49ef82005-09-22 21:50:47 +0200178 unsigned short flags, char read_write, u8 command,
179 int size, union i2c_smbus_data *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180{
Jean Delvarec2f559d2005-09-22 22:01:07 +0200181 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183 switch (size) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 case I2C_SMBUS_QUICK:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 size = VT596_QUICK;
186 break;
187 case I2C_SMBUS_BYTE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 if (read_write == I2C_SMBUS_WRITE)
189 outb_p(command, SMBHSTCMD);
190 size = VT596_BYTE;
191 break;
192 case I2C_SMBUS_BYTE_DATA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 outb_p(command, SMBHSTCMD);
194 if (read_write == I2C_SMBUS_WRITE)
195 outb_p(data->byte, SMBHSTDAT0);
196 size = VT596_BYTE_DATA;
197 break;
198 case I2C_SMBUS_WORD_DATA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 outb_p(command, SMBHSTCMD);
200 if (read_write == I2C_SMBUS_WRITE) {
201 outb_p(data->word & 0xff, SMBHSTDAT0);
202 outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1);
203 }
204 size = VT596_WORD_DATA;
205 break;
Jean Delvaref1183012005-09-22 21:58:41 +0200206 case I2C_SMBUS_I2C_BLOCK_DATA:
207 if (!(vt596_features & FEATURE_I2CBLOCK))
Jean Delvarec2f559d2005-09-22 22:01:07 +0200208 goto exit_unsupported;
Jean Delvaref1183012005-09-22 21:58:41 +0200209 if (read_write == I2C_SMBUS_READ)
210 outb_p(I2C_SMBUS_BLOCK_MAX, SMBHSTDAT0);
211 /* Fall through */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 case I2C_SMBUS_BLOCK_DATA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 outb_p(command, SMBHSTCMD);
214 if (read_write == I2C_SMBUS_WRITE) {
Jean Delvarec2f559d2005-09-22 22:01:07 +0200215 u8 len = data->block[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 if (len > I2C_SMBUS_BLOCK_MAX)
217 len = I2C_SMBUS_BLOCK_MAX;
218 outb_p(len, SMBHSTDAT0);
Jean Delvarec2f559d2005-09-22 22:01:07 +0200219 inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 for (i = 1; i <= len; i++)
221 outb_p(data->block[i], SMBBLKDAT);
222 }
Jean Delvaref1183012005-09-22 21:58:41 +0200223 size = (size == I2C_SMBUS_I2C_BLOCK_DATA) ?
224 VT596_I2C_BLOCK_DATA : VT596_BLOCK_DATA;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 break;
Jean Delvarec2f559d2005-09-22 22:01:07 +0200226 default:
227 goto exit_unsupported;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 }
229
Jean Delvarec2f559d2005-09-22 22:01:07 +0200230 outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD);
231 outb_p((size & 0x3C), SMBHSTCNT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
233 if (vt596_transaction()) /* Error in transaction */
234 return -1;
235
236 if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK))
237 return 0;
238
239 switch (size) {
240 case VT596_BYTE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 case VT596_BYTE_DATA:
242 data->byte = inb_p(SMBHSTDAT0);
243 break;
244 case VT596_WORD_DATA:
245 data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8);
246 break;
Jean Delvaref1183012005-09-22 21:58:41 +0200247 case VT596_I2C_BLOCK_DATA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 case VT596_BLOCK_DATA:
249 data->block[0] = inb_p(SMBHSTDAT0);
250 if (data->block[0] > I2C_SMBUS_BLOCK_MAX)
251 data->block[0] = I2C_SMBUS_BLOCK_MAX;
Jean Delvarec2f559d2005-09-22 22:01:07 +0200252 inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 for (i = 1; i <= data->block[0]; i++)
254 data->block[i] = inb_p(SMBBLKDAT);
255 break;
256 }
257 return 0;
Jean Delvarec2f559d2005-09-22 22:01:07 +0200258
259exit_unsupported:
260 dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n",
261 size);
262 return -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263}
264
265static u32 vt596_func(struct i2c_adapter *adapter)
266{
Jean Delvaref1183012005-09-22 21:58:41 +0200267 u32 func = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
269 I2C_FUNC_SMBUS_BLOCK_DATA;
Jean Delvaref1183012005-09-22 21:58:41 +0200270
271 if (vt596_features & FEATURE_I2CBLOCK)
272 func |= I2C_FUNC_SMBUS_I2C_BLOCK;
273 return func;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274}
275
276static struct i2c_algorithm smbus_algorithm = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 .smbus_xfer = vt596_access,
278 .functionality = vt596_func,
279};
280
281static struct i2c_adapter vt596_adapter = {
282 .owner = THIS_MODULE,
283 .class = I2C_CLASS_HWMON,
284 .algo = &smbus_algorithm,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285};
286
287static int __devinit vt596_probe(struct pci_dev *pdev,
288 const struct pci_device_id *id)
289{
290 unsigned char temp;
291 int error = -ENODEV;
Jean Delvare5f49ef82005-09-22 21:50:47 +0200292
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 /* Determine the address of the SMBus areas */
294 if (force_addr) {
295 vt596_smba = force_addr & 0xfff0;
296 force = 0;
297 goto found;
298 }
299
300 if ((pci_read_config_word(pdev, id->driver_data, &vt596_smba)) ||
Jean Delvarec2f559d2005-09-22 22:01:07 +0200301 !(vt596_smba & 0x0001)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 /* try 2nd address and config reg. for 596 */
303 if (id->device == PCI_DEVICE_ID_VIA_82C596_3 &&
304 !pci_read_config_word(pdev, SMBBA2, &vt596_smba) &&
Jean Delvarec2f559d2005-09-22 22:01:07 +0200305 (vt596_smba & 0x0001)) {
306 SMBHSTCFG = 0x84;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 } else {
308 /* no matches at all */
309 dev_err(&pdev->dev, "Cannot configure "
310 "SMBus I/O Base address\n");
311 return -ENODEV;
312 }
313 }
314
315 vt596_smba &= 0xfff0;
316 if (vt596_smba == 0) {
317 dev_err(&pdev->dev, "SMBus base address "
318 "uninitialized - upgrade BIOS or use "
319 "force_addr=0xaddr\n");
320 return -ENODEV;
321 }
322
Jean Delvare5f49ef82005-09-22 21:50:47 +0200323found:
Jean Delvarec2f559d2005-09-22 22:01:07 +0200324 if (!request_region(vt596_smba, 8, vt596_driver.name)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n",
Jean Delvare5f49ef82005-09-22 21:50:47 +0200326 vt596_smba);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 return -ENODEV;
328 }
329
330 pci_read_config_byte(pdev, SMBHSTCFG, &temp);
331 /* If force_addr is set, we program the new address here. Just to make
332 sure, we disable the VT596 first. */
333 if (force_addr) {
334 pci_write_config_byte(pdev, SMBHSTCFG, temp & 0xfe);
335 pci_write_config_word(pdev, id->driver_data, vt596_smba);
336 pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01);
337 dev_warn(&pdev->dev, "WARNING: SMBus interface set to new "
Jean Delvare5f49ef82005-09-22 21:50:47 +0200338 "address 0x%04x!\n", vt596_smba);
Jean Delvarec2f559d2005-09-22 22:01:07 +0200339 } else if (!(temp & 0x01)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 if (force) {
Jean Delvare5f49ef82005-09-22 21:50:47 +0200341 /* NOTE: This assumes I/O space and other allocations
342 * WERE done by the Bios! Don't complain if your
343 * hardware does weird things after enabling this.
344 * :') Check for Bios updates before resorting to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 * this.
346 */
Jean Delvarec2f559d2005-09-22 22:01:07 +0200347 pci_write_config_byte(pdev, SMBHSTCFG, temp | 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 dev_info(&pdev->dev, "Enabling SMBus device\n");
349 } else {
350 dev_err(&pdev->dev, "SMBUS: Error: Host SMBus "
351 "controller not enabled! - upgrade BIOS or "
352 "use force=1\n");
353 goto release_region;
354 }
355 }
356
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
358
Jean Delvaref1183012005-09-22 21:58:41 +0200359 switch (pdev->device) {
360 case PCI_DEVICE_ID_VIA_8237:
361 case PCI_DEVICE_ID_VIA_8235:
362 case PCI_DEVICE_ID_VIA_8233A:
363 case PCI_DEVICE_ID_VIA_8233_0:
364 vt596_features |= FEATURE_I2CBLOCK;
365 break;
366 case PCI_DEVICE_ID_VIA_82C686_4:
367 /* The VT82C686B (rev 0x40) does support I2C block
368 transactions, but the VT82C686A (rev 0x30) doesn't */
369 if (!pci_read_config_byte(pdev, PCI_REVISION_ID, &temp)
370 && temp >= 0x40)
371 vt596_features |= FEATURE_I2CBLOCK;
372 break;
373 }
374
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 vt596_adapter.dev.parent = &pdev->dev;
376 snprintf(vt596_adapter.name, I2C_NAME_SIZE,
Jean Delvare5f49ef82005-09-22 21:50:47 +0200377 "SMBus Via Pro adapter at %04x", vt596_smba);
378
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 vt596_pdev = pci_dev_get(pdev);
380 if (i2c_add_adapter(&vt596_adapter)) {
381 pci_dev_put(vt596_pdev);
382 vt596_pdev = NULL;
383 }
384
385 /* Always return failure here. This is to allow other drivers to bind
386 * to this pci device. We don't really want to have control over the
387 * pci device, we only wanted to read as few register values from it.
388 */
389 return -ENODEV;
390
Jean Delvare5f49ef82005-09-22 21:50:47 +0200391release_region:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 release_region(vt596_smba, 8);
393 return error;
394}
395
396static struct pci_device_id vt596_ids[] = {
397 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596_3),
398 .driver_data = SMBBA1 },
399 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596B_3),
400 .driver_data = SMBBA1 },
401 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4),
402 .driver_data = SMBBA1 },
403 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233_0),
404 .driver_data = SMBBA3 },
405 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233A),
406 .driver_data = SMBBA3 },
407 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235),
408 .driver_data = SMBBA3 },
409 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237),
410 .driver_data = SMBBA3 },
411 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4),
412 .driver_data = SMBBA1 },
413 { 0, }
414};
415
Jean Delvare5f49ef82005-09-22 21:50:47 +0200416MODULE_DEVICE_TABLE(pci, vt596_ids);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417
418static struct pci_driver vt596_driver = {
419 .name = "vt596_smbus",
420 .id_table = vt596_ids,
421 .probe = vt596_probe,
422};
423
424static int __init i2c_vt596_init(void)
425{
426 return pci_register_driver(&vt596_driver);
427}
428
429
430static void __exit i2c_vt596_exit(void)
431{
432 pci_unregister_driver(&vt596_driver);
433 if (vt596_pdev != NULL) {
434 i2c_del_adapter(&vt596_adapter);
435 release_region(vt596_smba, 8);
436 pci_dev_put(vt596_pdev);
437 vt596_pdev = NULL;
438 }
439}
440
441MODULE_AUTHOR(
442 "Frodo Looijaard <frodol@dds.nl> and "
443 "Philip Edelbrock <phil@netroedge.com>");
444MODULE_DESCRIPTION("vt82c596 SMBus driver");
445MODULE_LICENSE("GPL");
446
447module_init(i2c_vt596_init);
448module_exit(i2c_vt596_exit);