i2c-i801.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. /*
  2. i801.c - Part of lm_sensors, Linux kernel modules for hardware
  3. monitoring
  4. Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
  5. Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker
  6. <mdsxyz123@yahoo.com>
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. /*
  20. SUPPORTED DEVICES PCI ID
  21. 82801AA 2413
  22. 82801AB 2423
  23. 82801BA 2443
  24. 82801CA/CAM 2483
  25. 82801DB 24C3 (HW PEC supported, 32 byte buffer not supported)
  26. 82801EB 24D3 (HW PEC supported, 32 byte buffer not supported)
  27. 6300ESB 25A4
  28. ICH6 266A
  29. ICH7 27DA
  30. ESB2 269B
  31. ICH8 283E
  32. This driver supports several versions of Intel's I/O Controller Hubs (ICH).
  33. For SMBus support, they are similar to the PIIX4 and are part
  34. of Intel's '810' and other chipsets.
  35. See the doc/busses/i2c-i801 file for details.
  36. I2C Block Read and Process Call are not supported.
  37. */
  38. /* Note: we assume there can only be one I801, with one SMBus interface */
  39. #include <linux/module.h>
  40. #include <linux/pci.h>
  41. #include <linux/kernel.h>
  42. #include <linux/stddef.h>
  43. #include <linux/delay.h>
  44. #include <linux/sched.h>
  45. #include <linux/ioport.h>
  46. #include <linux/init.h>
  47. #include <linux/i2c.h>
  48. #include <asm/io.h>
  49. /* I801 SMBus address offsets */
  50. #define SMBHSTSTS (0 + i801_smba)
  51. #define SMBHSTCNT (2 + i801_smba)
  52. #define SMBHSTCMD (3 + i801_smba)
  53. #define SMBHSTADD (4 + i801_smba)
  54. #define SMBHSTDAT0 (5 + i801_smba)
  55. #define SMBHSTDAT1 (6 + i801_smba)
  56. #define SMBBLKDAT (7 + i801_smba)
  57. #define SMBPEC (8 + i801_smba) /* ICH4 only */
  58. #define SMBAUXSTS (12 + i801_smba) /* ICH4 only */
  59. #define SMBAUXCTL (13 + i801_smba) /* ICH4 only */
  60. /* PCI Address Constants */
  61. #define SMBBA 0x020
  62. #define SMBHSTCFG 0x040
  63. #define SMBREV 0x008
  64. /* Host configuration bits for SMBHSTCFG */
  65. #define SMBHSTCFG_HST_EN 1
  66. #define SMBHSTCFG_SMB_SMI_EN 2
  67. #define SMBHSTCFG_I2C_EN 4
  68. /* Other settings */
  69. #define MAX_TIMEOUT 100
  70. #define ENABLE_INT9 0 /* set to 0x01 to enable - untested */
  71. /* I801 command constants */
  72. #define I801_QUICK 0x00
  73. #define I801_BYTE 0x04
  74. #define I801_BYTE_DATA 0x08
  75. #define I801_WORD_DATA 0x0C
  76. #define I801_PROC_CALL 0x10 /* later chips only, unimplemented */
  77. #define I801_BLOCK_DATA 0x14
  78. #define I801_I2C_BLOCK_DATA 0x18 /* unimplemented */
  79. #define I801_BLOCK_LAST 0x34
  80. #define I801_I2C_BLOCK_LAST 0x38 /* unimplemented */
  81. #define I801_START 0x40
  82. #define I801_PEC_EN 0x80 /* ICH4 only */
  83. /* insmod parameters */
  84. /* If force_addr is set to anything different from 0, we forcibly enable
  85. the I801 at the given address. VERY DANGEROUS! */
  86. static u16 force_addr;
  87. module_param(force_addr, ushort, 0);
  88. MODULE_PARM_DESC(force_addr,
  89. "Forcibly enable the I801 at the given address. "
  90. "EXTREMELY DANGEROUS!");
  91. static int i801_transaction(void);
  92. static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
  93. int command, int hwpec);
  94. static unsigned short i801_smba;
  95. static struct pci_driver i801_driver;
  96. static struct pci_dev *I801_dev;
  97. static int isich4;
  98. static int i801_setup(struct pci_dev *dev)
  99. {
  100. int error_return = 0;
  101. unsigned char temp;
  102. /* Note: we keep on searching until we have found 'function 3' */
  103. if(PCI_FUNC(dev->devfn) != 3)
  104. return -ENODEV;
  105. I801_dev = dev;
  106. if ((dev->device == PCI_DEVICE_ID_INTEL_82801DB_3) ||
  107. (dev->device == PCI_DEVICE_ID_INTEL_82801EB_3) ||
  108. (dev->device == PCI_DEVICE_ID_INTEL_ESB_4))
  109. isich4 = 1;
  110. else
  111. isich4 = 0;
  112. /* Determine the address of the SMBus areas */
  113. if (force_addr) {
  114. i801_smba = force_addr & 0xfff0;
  115. } else {
  116. pci_read_config_word(I801_dev, SMBBA, &i801_smba);
  117. i801_smba &= 0xfff0;
  118. if(i801_smba == 0) {
  119. dev_err(&dev->dev, "SMB base address uninitialized "
  120. "- upgrade BIOS or use force_addr=0xaddr\n");
  121. return -ENODEV;
  122. }
  123. }
  124. if (!request_region(i801_smba, (isich4 ? 16 : 8), i801_driver.name)) {
  125. dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n",
  126. i801_smba);
  127. error_return = -EBUSY;
  128. goto END;
  129. }
  130. pci_read_config_byte(I801_dev, SMBHSTCFG, &temp);
  131. temp &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */
  132. pci_write_config_byte(I801_dev, SMBHSTCFG, temp);
  133. /* If force_addr is set, we program the new address here. Just to make
  134. sure, we disable the device first. */
  135. if (force_addr) {
  136. pci_write_config_byte(I801_dev, SMBHSTCFG, temp & 0xfe);
  137. pci_write_config_word(I801_dev, SMBBA, i801_smba);
  138. pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 0x01);
  139. dev_warn(&dev->dev, "WARNING: I801 SMBus interface set to "
  140. "new address %04x!\n", i801_smba);
  141. } else if ((temp & 1) == 0) {
  142. pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 1);
  143. dev_warn(&dev->dev, "enabling SMBus device\n");
  144. }
  145. if (temp & 0x02)
  146. dev_dbg(&dev->dev, "I801 using Interrupt SMI# for SMBus.\n");
  147. else
  148. dev_dbg(&dev->dev, "I801 using PCI Interrupt for SMBus.\n");
  149. pci_read_config_byte(I801_dev, SMBREV, &temp);
  150. dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp);
  151. dev_dbg(&dev->dev, "I801_smba = 0x%X\n", i801_smba);
  152. END:
  153. return error_return;
  154. }
  155. static int i801_transaction(void)
  156. {
  157. int temp;
  158. int result = 0;
  159. int timeout = 0;
  160. dev_dbg(&I801_dev->dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
  161. "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
  162. inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
  163. inb_p(SMBHSTDAT1));
  164. /* Make sure the SMBus host is ready to start transmitting */
  165. /* 0x1f = Failed, Bus_Err, Dev_Err, Intr, Host_Busy */
  166. if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) {
  167. dev_dbg(&I801_dev->dev, "SMBus busy (%02x). Resetting...\n",
  168. temp);
  169. outb_p(temp, SMBHSTSTS);
  170. if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) {
  171. dev_dbg(&I801_dev->dev, "Failed! (%02x)\n", temp);
  172. return -1;
  173. } else {
  174. dev_dbg(&I801_dev->dev, "Successfull!\n");
  175. }
  176. }
  177. outb_p(inb(SMBHSTCNT) | I801_START, SMBHSTCNT);
  178. /* We will always wait for a fraction of a second! */
  179. do {
  180. msleep(1);
  181. temp = inb_p(SMBHSTSTS);
  182. } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
  183. /* If the SMBus is still busy, we give up */
  184. if (timeout >= MAX_TIMEOUT) {
  185. dev_dbg(&I801_dev->dev, "SMBus Timeout!\n");
  186. result = -1;
  187. }
  188. if (temp & 0x10) {
  189. result = -1;
  190. dev_dbg(&I801_dev->dev, "Error: Failed bus transaction\n");
  191. }
  192. if (temp & 0x08) {
  193. result = -1;
  194. dev_err(&I801_dev->dev, "Bus collision! SMBus may be locked "
  195. "until next hard reset. (sorry!)\n");
  196. /* Clock stops and slave is stuck in mid-transmission */
  197. }
  198. if (temp & 0x04) {
  199. result = -1;
  200. dev_dbg(&I801_dev->dev, "Error: no response!\n");
  201. }
  202. if ((inb_p(SMBHSTSTS) & 0x1f) != 0x00)
  203. outb_p(inb(SMBHSTSTS), SMBHSTSTS);
  204. if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) {
  205. dev_dbg(&I801_dev->dev, "Failed reset at end of transaction "
  206. "(%02x)\n", temp);
  207. }
  208. dev_dbg(&I801_dev->dev, "Transaction (post): CNT=%02x, CMD=%02x, "
  209. "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
  210. inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
  211. inb_p(SMBHSTDAT1));
  212. return result;
  213. }
  214. /* All-inclusive block transaction function */
  215. static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
  216. int command, int hwpec)
  217. {
  218. int i, len;
  219. int smbcmd;
  220. int temp;
  221. int result = 0;
  222. int timeout;
  223. unsigned char hostc, errmask;
  224. if (command == I2C_SMBUS_I2C_BLOCK_DATA) {
  225. if (read_write == I2C_SMBUS_WRITE) {
  226. /* set I2C_EN bit in configuration register */
  227. pci_read_config_byte(I801_dev, SMBHSTCFG, &hostc);
  228. pci_write_config_byte(I801_dev, SMBHSTCFG,
  229. hostc | SMBHSTCFG_I2C_EN);
  230. } else {
  231. dev_err(&I801_dev->dev,
  232. "I2C_SMBUS_I2C_BLOCK_READ not DB!\n");
  233. return -1;
  234. }
  235. }
  236. if (read_write == I2C_SMBUS_WRITE) {
  237. len = data->block[0];
  238. if (len < 1)
  239. len = 1;
  240. if (len > 32)
  241. len = 32;
  242. outb_p(len, SMBHSTDAT0);
  243. outb_p(data->block[1], SMBBLKDAT);
  244. } else {
  245. len = 32; /* max for reads */
  246. }
  247. if(isich4 && command != I2C_SMBUS_I2C_BLOCK_DATA) {
  248. /* set 32 byte buffer */
  249. }
  250. for (i = 1; i <= len; i++) {
  251. if (i == len && read_write == I2C_SMBUS_READ)
  252. smbcmd = I801_BLOCK_LAST;
  253. else
  254. smbcmd = I801_BLOCK_DATA;
  255. outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT);
  256. dev_dbg(&I801_dev->dev, "Block (pre %d): CNT=%02x, CMD=%02x, "
  257. "ADD=%02x, DAT0=%02x, BLKDAT=%02x\n", i,
  258. inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
  259. inb_p(SMBHSTDAT0), inb_p(SMBBLKDAT));
  260. /* Make sure the SMBus host is ready to start transmitting */
  261. temp = inb_p(SMBHSTSTS);
  262. if (i == 1) {
  263. /* Erronenous conditions before transaction:
  264. * Byte_Done, Failed, Bus_Err, Dev_Err, Intr, Host_Busy */
  265. errmask=0x9f;
  266. } else {
  267. /* Erronenous conditions during transaction:
  268. * Failed, Bus_Err, Dev_Err, Intr */
  269. errmask=0x1e;
  270. }
  271. if (temp & errmask) {
  272. dev_dbg(&I801_dev->dev, "SMBus busy (%02x). "
  273. "Resetting...\n", temp);
  274. outb_p(temp, SMBHSTSTS);
  275. if (((temp = inb_p(SMBHSTSTS)) & errmask) != 0x00) {
  276. dev_err(&I801_dev->dev,
  277. "Reset failed! (%02x)\n", temp);
  278. result = -1;
  279. goto END;
  280. }
  281. if (i != 1) {
  282. /* if die in middle of block transaction, fail */
  283. result = -1;
  284. goto END;
  285. }
  286. }
  287. if (i == 1)
  288. outb_p(inb(SMBHSTCNT) | I801_START, SMBHSTCNT);
  289. /* We will always wait for a fraction of a second! */
  290. timeout = 0;
  291. do {
  292. temp = inb_p(SMBHSTSTS);
  293. msleep(1);
  294. }
  295. while ((!(temp & 0x80))
  296. && (timeout++ < MAX_TIMEOUT));
  297. /* If the SMBus is still busy, we give up */
  298. if (timeout >= MAX_TIMEOUT) {
  299. result = -1;
  300. dev_dbg(&I801_dev->dev, "SMBus Timeout!\n");
  301. }
  302. if (temp & 0x10) {
  303. result = -1;
  304. dev_dbg(&I801_dev->dev,
  305. "Error: Failed bus transaction\n");
  306. } else if (temp & 0x08) {
  307. result = -1;
  308. dev_err(&I801_dev->dev, "Bus collision!\n");
  309. } else if (temp & 0x04) {
  310. result = -1;
  311. dev_dbg(&I801_dev->dev, "Error: no response!\n");
  312. }
  313. if (i == 1 && read_write == I2C_SMBUS_READ) {
  314. len = inb_p(SMBHSTDAT0);
  315. if (len < 1)
  316. len = 1;
  317. if (len > 32)
  318. len = 32;
  319. data->block[0] = len;
  320. }
  321. /* Retrieve/store value in SMBBLKDAT */
  322. if (read_write == I2C_SMBUS_READ)
  323. data->block[i] = inb_p(SMBBLKDAT);
  324. if (read_write == I2C_SMBUS_WRITE && i+1 <= len)
  325. outb_p(data->block[i+1], SMBBLKDAT);
  326. if ((temp & 0x9e) != 0x00)
  327. outb_p(temp, SMBHSTSTS); /* signals SMBBLKDAT ready */
  328. if ((temp = (0x1e & inb_p(SMBHSTSTS))) != 0x00) {
  329. dev_dbg(&I801_dev->dev,
  330. "Bad status (%02x) at end of transaction\n",
  331. temp);
  332. }
  333. dev_dbg(&I801_dev->dev, "Block (post %d): CNT=%02x, CMD=%02x, "
  334. "ADD=%02x, DAT0=%02x, BLKDAT=%02x\n", i,
  335. inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
  336. inb_p(SMBHSTDAT0), inb_p(SMBBLKDAT));
  337. if (result < 0)
  338. goto END;
  339. }
  340. if (hwpec) {
  341. /* wait for INTR bit as advised by Intel */
  342. timeout = 0;
  343. do {
  344. temp = inb_p(SMBHSTSTS);
  345. msleep(1);
  346. } while ((!(temp & 0x02))
  347. && (timeout++ < MAX_TIMEOUT));
  348. if (timeout >= MAX_TIMEOUT) {
  349. dev_dbg(&I801_dev->dev, "PEC Timeout!\n");
  350. }
  351. outb_p(temp, SMBHSTSTS);
  352. }
  353. result = 0;
  354. END:
  355. if (command == I2C_SMBUS_I2C_BLOCK_DATA) {
  356. /* restore saved configuration register value */
  357. pci_write_config_byte(I801_dev, SMBHSTCFG, hostc);
  358. }
  359. return result;
  360. }
  361. /* Return -1 on error. */
  362. static s32 i801_access(struct i2c_adapter * adap, u16 addr,
  363. unsigned short flags, char read_write, u8 command,
  364. int size, union i2c_smbus_data * data)
  365. {
  366. int hwpec;
  367. int block = 0;
  368. int ret, xact = 0;
  369. hwpec = isich4 && (flags & I2C_CLIENT_PEC)
  370. && size != I2C_SMBUS_QUICK
  371. && size != I2C_SMBUS_I2C_BLOCK_DATA;
  372. switch (size) {
  373. case I2C_SMBUS_QUICK:
  374. outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
  375. SMBHSTADD);
  376. xact = I801_QUICK;
  377. break;
  378. case I2C_SMBUS_BYTE:
  379. outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
  380. SMBHSTADD);
  381. if (read_write == I2C_SMBUS_WRITE)
  382. outb_p(command, SMBHSTCMD);
  383. xact = I801_BYTE;
  384. break;
  385. case I2C_SMBUS_BYTE_DATA:
  386. outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
  387. SMBHSTADD);
  388. outb_p(command, SMBHSTCMD);
  389. if (read_write == I2C_SMBUS_WRITE)
  390. outb_p(data->byte, SMBHSTDAT0);
  391. xact = I801_BYTE_DATA;
  392. break;
  393. case I2C_SMBUS_WORD_DATA:
  394. outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
  395. SMBHSTADD);
  396. outb_p(command, SMBHSTCMD);
  397. if (read_write == I2C_SMBUS_WRITE) {
  398. outb_p(data->word & 0xff, SMBHSTDAT0);
  399. outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1);
  400. }
  401. xact = I801_WORD_DATA;
  402. break;
  403. case I2C_SMBUS_BLOCK_DATA:
  404. case I2C_SMBUS_I2C_BLOCK_DATA:
  405. outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
  406. SMBHSTADD);
  407. outb_p(command, SMBHSTCMD);
  408. block = 1;
  409. break;
  410. case I2C_SMBUS_PROC_CALL:
  411. default:
  412. dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size);
  413. return -1;
  414. }
  415. outb_p(hwpec, SMBAUXCTL); /* enable/disable hardware PEC */
  416. if(block)
  417. ret = i801_block_transaction(data, read_write, size, hwpec);
  418. else {
  419. outb_p(xact | ENABLE_INT9, SMBHSTCNT);
  420. ret = i801_transaction();
  421. }
  422. if(block)
  423. return ret;
  424. if(ret)
  425. return -1;
  426. if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK))
  427. return 0;
  428. switch (xact & 0x7f) {
  429. case I801_BYTE: /* Result put in SMBHSTDAT0 */
  430. case I801_BYTE_DATA:
  431. data->byte = inb_p(SMBHSTDAT0);
  432. break;
  433. case I801_WORD_DATA:
  434. data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8);
  435. break;
  436. }
  437. return 0;
  438. }
  439. static u32 i801_func(struct i2c_adapter *adapter)
  440. {
  441. return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
  442. I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
  443. I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK
  444. | (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0);
  445. }
  446. static struct i2c_algorithm smbus_algorithm = {
  447. .smbus_xfer = i801_access,
  448. .functionality = i801_func,
  449. };
  450. static struct i2c_adapter i801_adapter = {
  451. .owner = THIS_MODULE,
  452. .class = I2C_CLASS_HWMON,
  453. .algo = &smbus_algorithm,
  454. };
  455. static struct pci_device_id i801_ids[] = {
  456. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_3) },
  457. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_3) },
  458. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_2) },
  459. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_3) },
  460. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_3) },
  461. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_3) },
  462. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_4) },
  463. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_16) },
  464. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) },
  465. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) },
  466. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) },
  467. { 0, }
  468. };
  469. MODULE_DEVICE_TABLE (pci, i801_ids);
  470. static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
  471. {
  472. if (i801_setup(dev)) {
  473. dev_warn(&dev->dev,
  474. "I801 not detected, module not inserted.\n");
  475. return -ENODEV;
  476. }
  477. /* set up the driverfs linkage to our parent device */
  478. i801_adapter.dev.parent = &dev->dev;
  479. snprintf(i801_adapter.name, I2C_NAME_SIZE,
  480. "SMBus I801 adapter at %04x", i801_smba);
  481. return i2c_add_adapter(&i801_adapter);
  482. }
  483. static void __devexit i801_remove(struct pci_dev *dev)
  484. {
  485. i2c_del_adapter(&i801_adapter);
  486. release_region(i801_smba, (isich4 ? 16 : 8));
  487. }
  488. static struct pci_driver i801_driver = {
  489. .name = "i801_smbus",
  490. .id_table = i801_ids,
  491. .probe = i801_probe,
  492. .remove = __devexit_p(i801_remove),
  493. };
  494. static int __init i2c_i801_init(void)
  495. {
  496. return pci_register_driver(&i801_driver);
  497. }
  498. static void __exit i2c_i801_exit(void)
  499. {
  500. pci_unregister_driver(&i801_driver);
  501. }
  502. MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl>, "
  503. "Philip Edelbrock <phil@netroedge.com>, "
  504. "and Mark D. Studebaker <mdsxyz123@yahoo.com>");
  505. MODULE_DESCRIPTION("I801 SMBus driver");
  506. MODULE_LICENSE("GPL");
  507. module_init(i2c_i801_init);
  508. module_exit(i2c_i801_exit);