i2c-piix4.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /*
  2. Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl> and
  3. Philip Edelbrock <phil@netroedge.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. /*
  17. Supports:
  18. Intel PIIX4, 440MX
  19. Serverworks OSB4, CSB5, CSB6, HT-1000, HT-1100
  20. ATI IXP200, IXP300, IXP400, SB600, SB700, SB800
  21. SMSC Victory66
  22. Note: we assume there can only be one device, with one SMBus interface.
  23. */
  24. #include <linux/module.h>
  25. #include <linux/moduleparam.h>
  26. #include <linux/pci.h>
  27. #include <linux/kernel.h>
  28. #include <linux/delay.h>
  29. #include <linux/stddef.h>
  30. #include <linux/ioport.h>
  31. #include <linux/i2c.h>
  32. #include <linux/init.h>
  33. #include <linux/dmi.h>
  34. #include <linux/acpi.h>
  35. #include <asm/io.h>
  36. /* PIIX4 SMBus address offsets */
  37. #define SMBHSTSTS (0 + piix4_smba)
  38. #define SMBHSLVSTS (1 + piix4_smba)
  39. #define SMBHSTCNT (2 + piix4_smba)
  40. #define SMBHSTCMD (3 + piix4_smba)
  41. #define SMBHSTADD (4 + piix4_smba)
  42. #define SMBHSTDAT0 (5 + piix4_smba)
  43. #define SMBHSTDAT1 (6 + piix4_smba)
  44. #define SMBBLKDAT (7 + piix4_smba)
  45. #define SMBSLVCNT (8 + piix4_smba)
  46. #define SMBSHDWCMD (9 + piix4_smba)
  47. #define SMBSLVEVT (0xA + piix4_smba)
  48. #define SMBSLVDAT (0xC + piix4_smba)
  49. /* count for request_region */
  50. #define SMBIOSIZE 8
  51. /* PCI Address Constants */
  52. #define SMBBA 0x090
  53. #define SMBHSTCFG 0x0D2
  54. #define SMBSLVC 0x0D3
  55. #define SMBSHDW1 0x0D4
  56. #define SMBSHDW2 0x0D5
  57. #define SMBREV 0x0D6
  58. /* Other settings */
  59. #define MAX_TIMEOUT 500
  60. #define ENABLE_INT9 0
  61. /* PIIX4 constants */
  62. #define PIIX4_QUICK 0x00
  63. #define PIIX4_BYTE 0x04
  64. #define PIIX4_BYTE_DATA 0x08
  65. #define PIIX4_WORD_DATA 0x0C
  66. #define PIIX4_BLOCK_DATA 0x14
  67. /* insmod parameters */
  68. /* If force is set to anything different from 0, we forcibly enable the
  69. PIIX4. DANGEROUS! */
  70. static int force;
  71. module_param (force, int, 0);
  72. MODULE_PARM_DESC(force, "Forcibly enable the PIIX4. DANGEROUS!");
  73. /* If force_addr is set to anything different from 0, we forcibly enable
  74. the PIIX4 at the given address. VERY DANGEROUS! */
  75. static int force_addr;
  76. module_param (force_addr, int, 0);
  77. MODULE_PARM_DESC(force_addr,
  78. "Forcibly enable the PIIX4 at the given address. "
  79. "EXTREMELY DANGEROUS!");
  80. static unsigned short piix4_smba;
  81. static int srvrworks_csb5_delay;
  82. static struct pci_driver piix4_driver;
  83. static struct i2c_adapter piix4_adapter;
  84. static struct dmi_system_id __devinitdata piix4_dmi_blacklist[] = {
  85. {
  86. .ident = "Sapphire AM2RD790",
  87. .matches = {
  88. DMI_MATCH(DMI_BOARD_VENDOR, "SAPPHIRE Inc."),
  89. DMI_MATCH(DMI_BOARD_NAME, "PC-AM2RD790"),
  90. },
  91. },
  92. {
  93. .ident = "DFI Lanparty UT 790FX",
  94. .matches = {
  95. DMI_MATCH(DMI_BOARD_VENDOR, "DFI Inc."),
  96. DMI_MATCH(DMI_BOARD_NAME, "LP UT 790FX"),
  97. },
  98. },
  99. { }
  100. };
  101. /* The IBM entry is in a separate table because we only check it
  102. on Intel-based systems */
  103. static struct dmi_system_id __devinitdata piix4_dmi_ibm[] = {
  104. {
  105. .ident = "IBM",
  106. .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), },
  107. },
  108. { },
  109. };
  110. static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
  111. const struct pci_device_id *id)
  112. {
  113. unsigned char temp;
  114. if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) &&
  115. (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5))
  116. srvrworks_csb5_delay = 1;
  117. /* On some motherboards, it was reported that accessing the SMBus
  118. caused severe hardware problems */
  119. if (dmi_check_system(piix4_dmi_blacklist)) {
  120. dev_err(&PIIX4_dev->dev,
  121. "Accessing the SMBus on this system is unsafe!\n");
  122. return -EPERM;
  123. }
  124. /* Don't access SMBus on IBM systems which get corrupted eeproms */
  125. if (dmi_check_system(piix4_dmi_ibm) &&
  126. PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) {
  127. dev_err(&PIIX4_dev->dev, "IBM system detected; this module "
  128. "may corrupt your serial eeprom! Refusing to load "
  129. "module!\n");
  130. return -EPERM;
  131. }
  132. /* Determine the address of the SMBus areas */
  133. if (force_addr) {
  134. piix4_smba = force_addr & 0xfff0;
  135. force = 0;
  136. } else {
  137. pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba);
  138. piix4_smba &= 0xfff0;
  139. if(piix4_smba == 0) {
  140. dev_err(&PIIX4_dev->dev, "SMBus base address "
  141. "uninitialized - upgrade BIOS or use "
  142. "force_addr=0xaddr\n");
  143. return -ENODEV;
  144. }
  145. }
  146. if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name))
  147. return -EBUSY;
  148. if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) {
  149. dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n",
  150. piix4_smba);
  151. return -EBUSY;
  152. }
  153. pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp);
  154. /* If force_addr is set, we program the new address here. Just to make
  155. sure, we disable the PIIX4 first. */
  156. if (force_addr) {
  157. pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp & 0xfe);
  158. pci_write_config_word(PIIX4_dev, SMBBA, piix4_smba);
  159. pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 0x01);
  160. dev_info(&PIIX4_dev->dev, "WARNING: SMBus interface set to "
  161. "new address %04x!\n", piix4_smba);
  162. } else if ((temp & 1) == 0) {
  163. if (force) {
  164. /* This should never need to be done, but has been
  165. * noted that many Dell machines have the SMBus
  166. * interface on the PIIX4 disabled!? NOTE: This assumes
  167. * I/O space and other allocations WERE done by the
  168. * Bios! Don't complain if your hardware does weird
  169. * things after enabling this. :') Check for Bios
  170. * updates before resorting to this.
  171. */
  172. pci_write_config_byte(PIIX4_dev, SMBHSTCFG,
  173. temp | 1);
  174. dev_printk(KERN_NOTICE, &PIIX4_dev->dev,
  175. "WARNING: SMBus interface has been "
  176. "FORCEFULLY ENABLED!\n");
  177. } else {
  178. dev_err(&PIIX4_dev->dev,
  179. "Host SMBus controller not enabled!\n");
  180. release_region(piix4_smba, SMBIOSIZE);
  181. piix4_smba = 0;
  182. return -ENODEV;
  183. }
  184. }
  185. if (((temp & 0x0E) == 8) || ((temp & 0x0E) == 2))
  186. dev_dbg(&PIIX4_dev->dev, "Using Interrupt 9 for SMBus.\n");
  187. else if ((temp & 0x0E) == 0)
  188. dev_dbg(&PIIX4_dev->dev, "Using Interrupt SMI# for SMBus.\n");
  189. else
  190. dev_err(&PIIX4_dev->dev, "Illegal Interrupt configuration "
  191. "(or code out of date)!\n");
  192. pci_read_config_byte(PIIX4_dev, SMBREV, &temp);
  193. dev_info(&PIIX4_dev->dev,
  194. "SMBus Host Controller at 0x%x, revision %d\n",
  195. piix4_smba, temp);
  196. return 0;
  197. }
  198. static int __devinit piix4_setup_sb800(struct pci_dev *PIIX4_dev,
  199. const struct pci_device_id *id)
  200. {
  201. unsigned short smba_idx = 0xcd6;
  202. u8 smba_en_lo, smba_en_hi, i2ccfg, i2ccfg_offset = 0x10, smb_en = 0x2c;
  203. /* SB800 SMBus does not support forcing address */
  204. if (force || force_addr) {
  205. dev_err(&PIIX4_dev->dev, "SB800 SMBus does not support "
  206. "forcing address!\n");
  207. return -EINVAL;
  208. }
  209. /* Determine the address of the SMBus areas */
  210. if (!request_region(smba_idx, 2, "smba_idx")) {
  211. dev_err(&PIIX4_dev->dev, "SMBus base address index region "
  212. "0x%x already in use!\n", smba_idx);
  213. return -EBUSY;
  214. }
  215. outb_p(smb_en, smba_idx);
  216. smba_en_lo = inb_p(smba_idx + 1);
  217. outb_p(smb_en + 1, smba_idx);
  218. smba_en_hi = inb_p(smba_idx + 1);
  219. release_region(smba_idx, 2);
  220. if ((smba_en_lo & 1) == 0) {
  221. dev_err(&PIIX4_dev->dev,
  222. "Host SMBus controller not enabled!\n");
  223. return -ENODEV;
  224. }
  225. piix4_smba = ((smba_en_hi << 8) | smba_en_lo) & 0xffe0;
  226. if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name))
  227. return -EBUSY;
  228. if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) {
  229. dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n",
  230. piix4_smba);
  231. return -EBUSY;
  232. }
  233. /* Request the SMBus I2C bus config region */
  234. if (!request_region(piix4_smba + i2ccfg_offset, 1, "i2ccfg")) {
  235. dev_err(&PIIX4_dev->dev, "SMBus I2C bus config region "
  236. "0x%x already in use!\n", piix4_smba + i2ccfg_offset);
  237. release_region(piix4_smba, SMBIOSIZE);
  238. piix4_smba = 0;
  239. return -EBUSY;
  240. }
  241. i2ccfg = inb_p(piix4_smba + i2ccfg_offset);
  242. release_region(piix4_smba + i2ccfg_offset, 1);
  243. if (i2ccfg & 1)
  244. dev_dbg(&PIIX4_dev->dev, "Using IRQ for SMBus.\n");
  245. else
  246. dev_dbg(&PIIX4_dev->dev, "Using SMI# for SMBus.\n");
  247. dev_info(&PIIX4_dev->dev,
  248. "SMBus Host Controller at 0x%x, revision %d\n",
  249. piix4_smba, i2ccfg >> 4);
  250. return 0;
  251. }
  252. static int piix4_transaction(void)
  253. {
  254. int temp;
  255. int result = 0;
  256. int timeout = 0;
  257. dev_dbg(&piix4_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
  258. "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
  259. inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
  260. inb_p(SMBHSTDAT1));
  261. /* Make sure the SMBus host is ready to start transmitting */
  262. if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
  263. dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). "
  264. "Resetting...\n", temp);
  265. outb_p(temp, SMBHSTSTS);
  266. if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
  267. dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
  268. return -EBUSY;
  269. } else {
  270. dev_dbg(&piix4_adapter.dev, "Successful!\n");
  271. }
  272. }
  273. /* start the transaction by setting bit 6 */
  274. outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT);
  275. /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */
  276. if (srvrworks_csb5_delay) /* Extra delay for SERVERWORKS_CSB5 */
  277. msleep(2);
  278. else
  279. msleep(1);
  280. while ((timeout++ < MAX_TIMEOUT) &&
  281. ((temp = inb_p(SMBHSTSTS)) & 0x01))
  282. msleep(1);
  283. /* If the SMBus is still busy, we give up */
  284. if (timeout >= MAX_TIMEOUT) {
  285. dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
  286. result = -ETIMEDOUT;
  287. }
  288. if (temp & 0x10) {
  289. result = -EIO;
  290. dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n");
  291. }
  292. if (temp & 0x08) {
  293. result = -EIO;
  294. dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be "
  295. "locked until next hard reset. (sorry!)\n");
  296. /* Clock stops and slave is stuck in mid-transmission */
  297. }
  298. if (temp & 0x04) {
  299. result = -ENXIO;
  300. dev_dbg(&piix4_adapter.dev, "Error: no response!\n");
  301. }
  302. if (inb_p(SMBHSTSTS) != 0x00)
  303. outb_p(inb(SMBHSTSTS), SMBHSTSTS);
  304. if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
  305. dev_err(&piix4_adapter.dev, "Failed reset at end of "
  306. "transaction (%02x)\n", temp);
  307. }
  308. dev_dbg(&piix4_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, "
  309. "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
  310. inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
  311. inb_p(SMBHSTDAT1));
  312. return result;
  313. }
  314. /* Return negative errno on error. */
  315. static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
  316. unsigned short flags, char read_write,
  317. u8 command, int size, union i2c_smbus_data * data)
  318. {
  319. int i, len;
  320. int status;
  321. switch (size) {
  322. case I2C_SMBUS_QUICK:
  323. outb_p((addr << 1) | read_write,
  324. SMBHSTADD);
  325. size = PIIX4_QUICK;
  326. break;
  327. case I2C_SMBUS_BYTE:
  328. outb_p((addr << 1) | read_write,
  329. SMBHSTADD);
  330. if (read_write == I2C_SMBUS_WRITE)
  331. outb_p(command, SMBHSTCMD);
  332. size = PIIX4_BYTE;
  333. break;
  334. case I2C_SMBUS_BYTE_DATA:
  335. outb_p((addr << 1) | read_write,
  336. SMBHSTADD);
  337. outb_p(command, SMBHSTCMD);
  338. if (read_write == I2C_SMBUS_WRITE)
  339. outb_p(data->byte, SMBHSTDAT0);
  340. size = PIIX4_BYTE_DATA;
  341. break;
  342. case I2C_SMBUS_WORD_DATA:
  343. outb_p((addr << 1) | read_write,
  344. SMBHSTADD);
  345. outb_p(command, SMBHSTCMD);
  346. if (read_write == I2C_SMBUS_WRITE) {
  347. outb_p(data->word & 0xff, SMBHSTDAT0);
  348. outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1);
  349. }
  350. size = PIIX4_WORD_DATA;
  351. break;
  352. case I2C_SMBUS_BLOCK_DATA:
  353. outb_p((addr << 1) | read_write,
  354. SMBHSTADD);
  355. outb_p(command, SMBHSTCMD);
  356. if (read_write == I2C_SMBUS_WRITE) {
  357. len = data->block[0];
  358. if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
  359. return -EINVAL;
  360. outb_p(len, SMBHSTDAT0);
  361. i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
  362. for (i = 1; i <= len; i++)
  363. outb_p(data->block[i], SMBBLKDAT);
  364. }
  365. size = PIIX4_BLOCK_DATA;
  366. break;
  367. default:
  368. dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
  369. return -EOPNOTSUPP;
  370. }
  371. outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);
  372. status = piix4_transaction();
  373. if (status)
  374. return status;
  375. if ((read_write == I2C_SMBUS_WRITE) || (size == PIIX4_QUICK))
  376. return 0;
  377. switch (size) {
  378. case PIIX4_BYTE:
  379. case PIIX4_BYTE_DATA:
  380. data->byte = inb_p(SMBHSTDAT0);
  381. break;
  382. case PIIX4_WORD_DATA:
  383. data->word = inb_p(SMBHSTDAT0) + (inb_p(SMBHSTDAT1) << 8);
  384. break;
  385. case PIIX4_BLOCK_DATA:
  386. data->block[0] = inb_p(SMBHSTDAT0);
  387. if (data->block[0] == 0 || data->block[0] > I2C_SMBUS_BLOCK_MAX)
  388. return -EPROTO;
  389. i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
  390. for (i = 1; i <= data->block[0]; i++)
  391. data->block[i] = inb_p(SMBBLKDAT);
  392. break;
  393. }
  394. return 0;
  395. }
  396. static u32 piix4_func(struct i2c_adapter *adapter)
  397. {
  398. return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
  399. I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
  400. I2C_FUNC_SMBUS_BLOCK_DATA;
  401. }
  402. static const struct i2c_algorithm smbus_algorithm = {
  403. .smbus_xfer = piix4_access,
  404. .functionality = piix4_func,
  405. };
  406. static struct i2c_adapter piix4_adapter = {
  407. .owner = THIS_MODULE,
  408. .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
  409. .algo = &smbus_algorithm,
  410. };
  411. static struct pci_device_id piix4_ids[] = {
  412. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) },
  413. { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3) },
  414. { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3) },
  415. { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP200_SMBUS) },
  416. { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP300_SMBUS) },
  417. { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS) },
  418. { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS) },
  419. { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
  420. PCI_DEVICE_ID_SERVERWORKS_OSB4) },
  421. { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
  422. PCI_DEVICE_ID_SERVERWORKS_CSB5) },
  423. { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
  424. PCI_DEVICE_ID_SERVERWORKS_CSB6) },
  425. { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
  426. PCI_DEVICE_ID_SERVERWORKS_HT1000SB) },
  427. { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS,
  428. PCI_DEVICE_ID_SERVERWORKS_HT1100LD) },
  429. { 0, }
  430. };
  431. MODULE_DEVICE_TABLE (pci, piix4_ids);
  432. static int __devinit piix4_probe(struct pci_dev *dev,
  433. const struct pci_device_id *id)
  434. {
  435. int retval;
  436. if ((dev->vendor == PCI_VENDOR_ID_ATI) &&
  437. (dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS) &&
  438. (dev->revision >= 0x40))
  439. /* base address location etc changed in SB800 */
  440. retval = piix4_setup_sb800(dev, id);
  441. else
  442. retval = piix4_setup(dev, id);
  443. if (retval)
  444. return retval;
  445. /* set up the sysfs linkage to our parent device */
  446. piix4_adapter.dev.parent = &dev->dev;
  447. snprintf(piix4_adapter.name, sizeof(piix4_adapter.name),
  448. "SMBus PIIX4 adapter at %04x", piix4_smba);
  449. if ((retval = i2c_add_adapter(&piix4_adapter))) {
  450. dev_err(&dev->dev, "Couldn't register adapter!\n");
  451. release_region(piix4_smba, SMBIOSIZE);
  452. piix4_smba = 0;
  453. }
  454. return retval;
  455. }
  456. static void __devexit piix4_remove(struct pci_dev *dev)
  457. {
  458. if (piix4_smba) {
  459. i2c_del_adapter(&piix4_adapter);
  460. release_region(piix4_smba, SMBIOSIZE);
  461. piix4_smba = 0;
  462. }
  463. }
  464. static struct pci_driver piix4_driver = {
  465. .name = "piix4_smbus",
  466. .id_table = piix4_ids,
  467. .probe = piix4_probe,
  468. .remove = __devexit_p(piix4_remove),
  469. };
  470. static int __init i2c_piix4_init(void)
  471. {
  472. return pci_register_driver(&piix4_driver);
  473. }
  474. static void __exit i2c_piix4_exit(void)
  475. {
  476. pci_unregister_driver(&piix4_driver);
  477. }
  478. MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and "
  479. "Philip Edelbrock <phil@netroedge.com>");
  480. MODULE_DESCRIPTION("PIIX4 SMBus driver");
  481. MODULE_LICENSE("GPL");
  482. module_init(i2c_piix4_init);
  483. module_exit(i2c_piix4_exit);