| 1 | /* |
|---|
| 2 | * SMBus 2.0 driver for AMD-8111 IO-Hub. |
|---|
| 3 | * |
|---|
| 4 | * Copyright (c) 2002 Vojtech Pavlik |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation version 2. |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | #include <linux/module.h> |
|---|
| 12 | #include <linux/pci.h> |
|---|
| 13 | #include <linux/kernel.h> |
|---|
| 14 | #include <linux/stddef.h> |
|---|
| 15 | #include <linux/sched.h> |
|---|
| 16 | #include <linux/ioport.h> |
|---|
| 17 | #include <linux/init.h> |
|---|
| 18 | #include <linux/i2c.h> |
|---|
| 19 | #include <linux/delay.h> |
|---|
| 20 | #include <linux/slab.h> |
|---|
| 21 | #include <asm/io.h> |
|---|
| 22 | #include "version.h" |
|---|
| 23 | |
|---|
| 24 | #ifndef I2C_HW_SMBUS_AMD8111 |
|---|
| 25 | #error Your i2c is too old - i2c-2.7.0 or greater required! |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | MODULE_LICENSE("GPL"); |
|---|
| 29 | MODULE_AUTHOR ("Vojtech Pavlik <vojtech@suse.cz>"); |
|---|
| 30 | MODULE_DESCRIPTION("AMD8111 SMBus 2.0 driver"); |
|---|
| 31 | |
|---|
| 32 | struct amd_smbus { |
|---|
| 33 | struct pci_dev *dev; |
|---|
| 34 | struct i2c_adapter adapter; |
|---|
| 35 | int base; |
|---|
| 36 | int size; |
|---|
| 37 | }; |
|---|
| 38 | |
|---|
| 39 | /* |
|---|
| 40 | * AMD PCI control registers definitions. |
|---|
| 41 | */ |
|---|
| 42 | |
|---|
| 43 | #define AMD_PCI_MISC 0x48 |
|---|
| 44 | |
|---|
| 45 | #define AMD_PCI_MISC_SCI 0x04 /* deliver SCI */ |
|---|
| 46 | #define AMD_PCI_MISC_INT 0x02 /* deliver PCI IRQ */ |
|---|
| 47 | #define AMD_PCI_MISC_SPEEDUP 0x01 /* 16x clock speedup */ |
|---|
| 48 | |
|---|
| 49 | /* |
|---|
| 50 | * ACPI 2.0 chapter 13 PCI interface definitions. |
|---|
| 51 | */ |
|---|
| 52 | |
|---|
| 53 | #define AMD_EC_DATA 0x00 /* data register */ |
|---|
| 54 | #define AMD_EC_SC 0x04 /* status of controller */ |
|---|
| 55 | #define AMD_EC_CMD 0x04 /* command register */ |
|---|
| 56 | #define AMD_EC_ICR 0x08 /* interrupt control register */ |
|---|
| 57 | |
|---|
| 58 | #define AMD_EC_SC_SMI 0x04 /* smi event pending */ |
|---|
| 59 | #define AMD_EC_SC_SCI 0x02 /* sci event pending */ |
|---|
| 60 | #define AMD_EC_SC_BURST 0x01 /* burst mode enabled */ |
|---|
| 61 | #define AMD_EC_SC_CMD 0x08 /* byte in data reg is command */ |
|---|
| 62 | #define AMD_EC_SC_IBF 0x02 /* data ready for embedded controller */ |
|---|
| 63 | #define AMD_EC_SC_OBF 0x01 /* data ready for host */ |
|---|
| 64 | |
|---|
| 65 | #define AMD_EC_CMD_RD 0x80 /* read EC */ |
|---|
| 66 | #define AMD_EC_CMD_WR 0x81 /* write EC */ |
|---|
| 67 | #define AMD_EC_CMD_BE 0x82 /* enable burst mode */ |
|---|
| 68 | #define AMD_EC_CMD_BD 0x83 /* disable burst mode */ |
|---|
| 69 | #define AMD_EC_CMD_QR 0x84 /* query EC */ |
|---|
| 70 | |
|---|
| 71 | /* |
|---|
| 72 | * ACPI 2.0 chapter 13 access of registers of the EC |
|---|
| 73 | */ |
|---|
| 74 | |
|---|
| 75 | unsigned int amd_ec_wait_write(struct amd_smbus *smbus) |
|---|
| 76 | { |
|---|
| 77 | int timeout = 500; |
|---|
| 78 | |
|---|
| 79 | while (timeout-- && (inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_IBF)) |
|---|
| 80 | udelay(1); |
|---|
| 81 | |
|---|
| 82 | if (!timeout) { |
|---|
| 83 | printk(KERN_WARNING "i2c-amd8111.c: Timeout while waiting for IBF to clear\n"); |
|---|
| 84 | return -1; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | return 0; |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | unsigned int amd_ec_wait_read(struct amd_smbus *smbus) |
|---|
| 91 | { |
|---|
| 92 | int timeout = 500; |
|---|
| 93 | |
|---|
| 94 | while (timeout-- && (~inb(smbus->base + AMD_EC_SC) & AMD_EC_SC_OBF)) |
|---|
| 95 | udelay(1); |
|---|
| 96 | |
|---|
| 97 | if (!timeout) { |
|---|
| 98 | printk(KERN_WARNING "i2c-amd8111.c: Timeout while waiting for OBF to set\n"); |
|---|
| 99 | return -1; |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | return 0; |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, unsigned char *data) |
|---|
| 106 | { |
|---|
| 107 | if (amd_ec_wait_write(smbus)) |
|---|
| 108 | return -1; |
|---|
| 109 | outb(AMD_EC_CMD_RD, smbus->base + AMD_EC_CMD); |
|---|
| 110 | |
|---|
| 111 | if (amd_ec_wait_write(smbus)) |
|---|
| 112 | return -1; |
|---|
| 113 | outb(address, smbus->base + AMD_EC_DATA); |
|---|
| 114 | |
|---|
| 115 | if (amd_ec_wait_read(smbus)) |
|---|
| 116 | return -1; |
|---|
| 117 | *data = inb(smbus->base + AMD_EC_DATA); |
|---|
| 118 | |
|---|
| 119 | return 0; |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| 122 | unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, unsigned char data) |
|---|
| 123 | { |
|---|
| 124 | if (amd_ec_wait_write(smbus)) |
|---|
| 125 | return -1; |
|---|
| 126 | outb(AMD_EC_CMD_WR, smbus->base + AMD_EC_CMD); |
|---|
| 127 | |
|---|
| 128 | if (amd_ec_wait_write(smbus)) |
|---|
| 129 | return -1; |
|---|
| 130 | outb(address, smbus->base + AMD_EC_DATA); |
|---|
| 131 | |
|---|
| 132 | if (amd_ec_wait_write(smbus)) |
|---|
| 133 | return -1; |
|---|
| 134 | outb(data, smbus->base + AMD_EC_DATA); |
|---|
| 135 | |
|---|
| 136 | return 0; |
|---|
| 137 | } |
|---|
| 138 | |
|---|
| 139 | /* |
|---|
| 140 | * ACPI 2.0 chapter 13 SMBus 2.0 EC register model |
|---|
| 141 | */ |
|---|
| 142 | |
|---|
| 143 | #define AMD_SMB_PRTCL 0x00 /* protocol, PEC */ |
|---|
| 144 | #define AMD_SMB_STS 0x01 /* status */ |
|---|
| 145 | #define AMD_SMB_ADDR 0x02 /* address */ |
|---|
| 146 | #define AMD_SMB_CMD 0x03 /* command */ |
|---|
| 147 | #define AMD_SMB_DATA 0x04 /* 32 data registers */ |
|---|
| 148 | #define AMD_SMB_BCNT 0x24 /* number of data bytes */ |
|---|
| 149 | #define AMD_SMB_ALRM_A 0x25 /* alarm address */ |
|---|
| 150 | #define AMD_SMB_ALRM_D 0x26 /* 2 bytes alarm data */ |
|---|
| 151 | |
|---|
| 152 | #define AMD_SMB_STS_DONE 0x80 |
|---|
| 153 | #define AMD_SMB_STS_ALRM 0x40 |
|---|
| 154 | #define AMD_SMB_STS_RES 0x20 |
|---|
| 155 | #define AMD_SMB_STS_STATUS 0x1f |
|---|
| 156 | |
|---|
| 157 | #define AMD_SMB_STATUS_OK 0x00 |
|---|
| 158 | #define AMD_SMB_STATUS_FAIL 0x07 |
|---|
| 159 | #define AMD_SMB_STATUS_DNAK 0x10 |
|---|
| 160 | #define AMD_SMB_STATUS_DERR 0x11 |
|---|
| 161 | #define AMD_SMB_STATUS_CMD_DENY 0x12 |
|---|
| 162 | #define AMD_SMB_STATUS_UNKNOWN 0x13 |
|---|
| 163 | #define AMD_SMB_STATUS_ACC_DENY 0x17 |
|---|
| 164 | #define AMD_SMB_STATUS_TIMEOUT 0x18 |
|---|
| 165 | #define AMD_SMB_STATUS_NOTSUP 0x19 |
|---|
| 166 | #define AMD_SMB_STATUS_BUSY 0x1A |
|---|
| 167 | #define AMD_SMB_STATUS_PEC 0x1F |
|---|
| 168 | |
|---|
| 169 | #define AMD_SMB_PRTCL_WRITE 0x00 |
|---|
| 170 | #define AMD_SMB_PRTCL_READ 0x01 |
|---|
| 171 | #define AMD_SMB_PRTCL_QUICK 0x02 |
|---|
| 172 | #define AMD_SMB_PRTCL_BYTE 0x04 |
|---|
| 173 | #define AMD_SMB_PRTCL_BYTE_DATA 0x06 |
|---|
| 174 | #define AMD_SMB_PRTCL_WORD_DATA 0x08 |
|---|
| 175 | #define AMD_SMB_PRTCL_BLOCK_DATA 0x0a |
|---|
| 176 | #define AMD_SMB_PRTCL_PROC_CALL 0x0c |
|---|
| 177 | #define AMD_SMB_PRTCL_BLOCK_PROC_CALL 0x0d |
|---|
| 178 | #define AMD_SMB_PRTCL_I2C_BLOCK_DATA 0x4a |
|---|
| 179 | #define AMD_SMB_PRTCL_PEC 0x80 |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, |
|---|
| 183 | char read_write, u8 command, int size, union i2c_smbus_data * data) |
|---|
| 184 | { |
|---|
| 185 | struct amd_smbus *smbus = adap->algo_data; |
|---|
| 186 | unsigned char protocol, len, pec, temp[2]; |
|---|
| 187 | int i; |
|---|
| 188 | |
|---|
| 189 | protocol = (read_write == I2C_SMBUS_READ) ? AMD_SMB_PRTCL_READ : AMD_SMB_PRTCL_WRITE; |
|---|
| 190 | pec = (flags & I2C_CLIENT_PEC) ? AMD_SMB_PRTCL_PEC : 0; |
|---|
| 191 | |
|---|
| 192 | switch (size) { |
|---|
| 193 | |
|---|
| 194 | case I2C_SMBUS_QUICK: |
|---|
| 195 | protocol |= AMD_SMB_PRTCL_QUICK; |
|---|
| 196 | read_write = I2C_SMBUS_WRITE; |
|---|
| 197 | break; |
|---|
| 198 | |
|---|
| 199 | case I2C_SMBUS_BYTE: |
|---|
| 200 | if (read_write == I2C_SMBUS_WRITE) |
|---|
| 201 | amd_ec_write(smbus, AMD_SMB_DATA, data->byte); |
|---|
| 202 | protocol |= AMD_SMB_PRTCL_BYTE; |
|---|
| 203 | break; |
|---|
| 204 | |
|---|
| 205 | case I2C_SMBUS_BYTE_DATA: |
|---|
| 206 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
|---|
| 207 | if (read_write == I2C_SMBUS_WRITE) |
|---|
| 208 | amd_ec_write(smbus, AMD_SMB_DATA, data->byte); |
|---|
| 209 | protocol |= AMD_SMB_PRTCL_BYTE_DATA; |
|---|
| 210 | break; |
|---|
| 211 | |
|---|
| 212 | case I2C_SMBUS_WORD_DATA: |
|---|
| 213 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
|---|
| 214 | if (read_write == I2C_SMBUS_WRITE) { |
|---|
| 215 | amd_ec_write(smbus, AMD_SMB_DATA, data->word); |
|---|
| 216 | amd_ec_write(smbus, AMD_SMB_DATA + 1, data->word >> 8); |
|---|
| 217 | } |
|---|
| 218 | protocol |= AMD_SMB_PRTCL_WORD_DATA | pec; |
|---|
| 219 | break; |
|---|
| 220 | |
|---|
| 221 | case I2C_SMBUS_BLOCK_DATA: |
|---|
| 222 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
|---|
| 223 | if (read_write == I2C_SMBUS_WRITE) { |
|---|
| 224 | len = min_t(u8, data->block[0], 32); |
|---|
| 225 | amd_ec_write(smbus, AMD_SMB_BCNT, len); |
|---|
| 226 | for (i = 0; i < len; i++) |
|---|
| 227 | amd_ec_write(smbus, AMD_SMB_DATA + i, data->block[i + 1]); |
|---|
| 228 | } |
|---|
| 229 | protocol |= AMD_SMB_PRTCL_BLOCK_DATA | pec; |
|---|
| 230 | break; |
|---|
| 231 | |
|---|
| 232 | case I2C_SMBUS_I2C_BLOCK_DATA: |
|---|
| 233 | len = min_t(u8, data->block[0], 32); |
|---|
| 234 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
|---|
| 235 | amd_ec_write(smbus, AMD_SMB_BCNT, len); |
|---|
| 236 | if (read_write == I2C_SMBUS_WRITE) |
|---|
| 237 | for (i = 0; i < len; i++) |
|---|
| 238 | amd_ec_write(smbus, AMD_SMB_DATA + i, data->block[i + 1]); |
|---|
| 239 | protocol |= AMD_SMB_PRTCL_I2C_BLOCK_DATA; |
|---|
| 240 | break; |
|---|
| 241 | |
|---|
| 242 | case I2C_SMBUS_PROC_CALL: |
|---|
| 243 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
|---|
| 244 | amd_ec_write(smbus, AMD_SMB_DATA, data->word); |
|---|
| 245 | amd_ec_write(smbus, AMD_SMB_DATA + 1, data->word >> 8); |
|---|
| 246 | protocol = AMD_SMB_PRTCL_PROC_CALL | pec; |
|---|
| 247 | read_write = I2C_SMBUS_READ; |
|---|
| 248 | break; |
|---|
| 249 | |
|---|
| 250 | case I2C_SMBUS_BLOCK_PROC_CALL: |
|---|
| 251 | protocol |= pec; |
|---|
| 252 | len = min_t(u8, data->block[0], 31); |
|---|
| 253 | amd_ec_write(smbus, AMD_SMB_CMD, command); |
|---|
| 254 | amd_ec_write(smbus, AMD_SMB_BCNT, len); |
|---|
| 255 | for (i = 0; i < len; i++) |
|---|
| 256 | amd_ec_write(smbus, AMD_SMB_DATA + i, data->block[i + 1]); |
|---|
| 257 | protocol = AMD_SMB_PRTCL_BLOCK_PROC_CALL | pec; |
|---|
| 258 | read_write = I2C_SMBUS_READ; |
|---|
| 259 | break; |
|---|
| 260 | |
|---|
| 261 | case I2C_SMBUS_WORD_DATA_PEC: |
|---|
| 262 | case I2C_SMBUS_BLOCK_DATA_PEC: |
|---|
| 263 | case I2C_SMBUS_PROC_CALL_PEC: |
|---|
| 264 | case I2C_SMBUS_BLOCK_PROC_CALL_PEC: |
|---|
| 265 | printk(KERN_WARNING "i2c-amd8111.c: Unexpected software PEC transaction %d\n.", size); |
|---|
| 266 | return -1; |
|---|
| 267 | |
|---|
| 268 | default: |
|---|
| 269 | printk(KERN_WARNING "i2c-amd8111.c: Unsupported transaction %d\n", size); |
|---|
| 270 | return -1; |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | amd_ec_write(smbus, AMD_SMB_ADDR, addr << 1); |
|---|
| 274 | amd_ec_write(smbus, AMD_SMB_PRTCL, protocol); |
|---|
| 275 | |
|---|
| 276 | amd_ec_read(smbus, AMD_SMB_STS, temp + 0); |
|---|
| 277 | |
|---|
| 278 | if (~temp[0] & AMD_SMB_STS_DONE) { |
|---|
| 279 | udelay(500); |
|---|
| 280 | amd_ec_read(smbus, AMD_SMB_STS, temp + 0); |
|---|
| 281 | } |
|---|
| 282 | |
|---|
| 283 | if (~temp[0] & AMD_SMB_STS_DONE) { |
|---|
| 284 | i2c_delay(HZ/100); |
|---|
| 285 | amd_ec_read(smbus, AMD_SMB_STS, temp + 0); |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | if ((~temp[0] & AMD_SMB_STS_DONE) || (temp[0] & AMD_SMB_STS_STATUS)) |
|---|
| 289 | return -1; |
|---|
| 290 | |
|---|
| 291 | if (read_write == I2C_SMBUS_WRITE) |
|---|
| 292 | return 0; |
|---|
| 293 | |
|---|
| 294 | switch (size) { |
|---|
| 295 | |
|---|
| 296 | case I2C_SMBUS_BYTE: |
|---|
| 297 | case I2C_SMBUS_BYTE_DATA: |
|---|
| 298 | amd_ec_read(smbus, AMD_SMB_DATA, &data->byte); |
|---|
| 299 | break; |
|---|
| 300 | |
|---|
| 301 | case I2C_SMBUS_WORD_DATA: |
|---|
| 302 | case I2C_SMBUS_PROC_CALL: |
|---|
| 303 | amd_ec_read(smbus, AMD_SMB_DATA, temp + 0); |
|---|
| 304 | amd_ec_read(smbus, AMD_SMB_DATA + 1, temp + 1); |
|---|
| 305 | data->word = (temp[1] << 8) | temp[0]; |
|---|
| 306 | break; |
|---|
| 307 | |
|---|
| 308 | case I2C_SMBUS_BLOCK_DATA: |
|---|
| 309 | case I2C_SMBUS_BLOCK_PROC_CALL: |
|---|
| 310 | amd_ec_read(smbus, AMD_SMB_BCNT, &len); |
|---|
| 311 | len = min_t(u8, len, 32); |
|---|
| 312 | case I2C_SMBUS_I2C_BLOCK_DATA: |
|---|
| 313 | for (i = 0; i < len; i++) |
|---|
| 314 | amd_ec_read(smbus, AMD_SMB_DATA + i, data->block + i + 1); |
|---|
| 315 | data->block[0] = len; |
|---|
| 316 | break; |
|---|
| 317 | } |
|---|
| 318 | |
|---|
| 319 | return 0; |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | |
|---|
| 323 | u32 amd8111_func(struct i2c_adapter *adapter) |
|---|
| 324 | { |
|---|
| 325 | return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | |
|---|
| 326 | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA | |
|---|
| 327 | I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_BLOCK_PROC_CALL | |
|---|
| 328 | I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC; |
|---|
| 329 | } |
|---|
| 330 | |
|---|
| 331 | static struct i2c_algorithm smbus_algorithm = { |
|---|
| 332 | .name = "Non-I2C SMBus 2.0 adapter", |
|---|
| 333 | .id = I2C_ALGO_SMBUS, |
|---|
| 334 | .smbus_xfer = amd8111_access, |
|---|
| 335 | .functionality = amd8111_func, |
|---|
| 336 | }; |
|---|
| 337 | |
|---|
| 338 | |
|---|
| 339 | static struct pci_device_id amd8111_ids[] __devinitdata = { |
|---|
| 340 | { 0x1022, 0x746a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
|---|
| 341 | { 0, } |
|---|
| 342 | }; |
|---|
| 343 | |
|---|
| 344 | static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id) |
|---|
| 345 | { |
|---|
| 346 | struct amd_smbus *smbus; |
|---|
| 347 | int error; |
|---|
| 348 | |
|---|
| 349 | if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) |
|---|
| 350 | return -1; |
|---|
| 351 | |
|---|
| 352 | if (!(smbus = (void*)kmalloc(sizeof(struct amd_smbus), GFP_KERNEL))) |
|---|
| 353 | return -1; |
|---|
| 354 | memset(smbus, 0, sizeof(struct amd_smbus)); |
|---|
| 355 | |
|---|
| 356 | pci_set_drvdata(dev, smbus); |
|---|
| 357 | smbus->dev = dev; |
|---|
| 358 | smbus->base = pci_resource_start(dev, 0); |
|---|
| 359 | smbus->size = pci_resource_len(dev, 0); |
|---|
| 360 | |
|---|
| 361 | if (!request_region(smbus->base, smbus->size, "amd8111 SMBus 2.0")) { |
|---|
| 362 | kfree(smbus); |
|---|
| 363 | return -1; |
|---|
| 364 | } |
|---|
| 365 | |
|---|
| 366 | smbus->adapter.owner = THIS_MODULE; |
|---|
| 367 | sprintf(smbus->adapter.name, "SMBus2 AMD8111 adapter at %04x", smbus->base); |
|---|
| 368 | smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111; |
|---|
| 369 | smbus->adapter.algo = &smbus_algorithm; |
|---|
| 370 | smbus->adapter.algo_data = smbus; |
|---|
| 371 | |
|---|
| 372 | error = i2c_add_adapter(&smbus->adapter); |
|---|
| 373 | if (error) { |
|---|
| 374 | printk(KERN_WARNING "i2c-amd8111.c: Failed to register adapter.\n"); |
|---|
| 375 | release_region(smbus->base, smbus->size); |
|---|
| 376 | kfree(smbus); |
|---|
| 377 | return -1; |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | pci_write_config_dword(smbus->dev, AMD_PCI_MISC, 0); |
|---|
| 381 | |
|---|
| 382 | printk(KERN_INFO "i2c-amd8111.c: AMD8111 SMBus 2.0 adapter at %#x\n", smbus->base); |
|---|
| 383 | return 0; |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | static void __devexit amd8111_remove(struct pci_dev *dev) |
|---|
| 388 | { |
|---|
| 389 | struct amd_smbus *smbus = (void*) pci_get_drvdata(dev); |
|---|
| 390 | i2c_del_adapter(&smbus->adapter); |
|---|
| 391 | release_region(smbus->base, smbus->size); |
|---|
| 392 | kfree(smbus); |
|---|
| 393 | } |
|---|
| 394 | |
|---|
| 395 | static struct pci_driver amd8111_driver = { |
|---|
| 396 | .name = "amd8111 smbus 2.0", |
|---|
| 397 | .id_table = amd8111_ids, |
|---|
| 398 | .probe = amd8111_probe, |
|---|
| 399 | .remove = __devexit_p(amd8111_remove), |
|---|
| 400 | }; |
|---|
| 401 | |
|---|
| 402 | static int __init i2c_amd8111_init(void) |
|---|
| 403 | { |
|---|
| 404 | printk(KERN_INFO "i2c-amd8111.o version %s (%s)\n", LM_VERSION, LM_DATE); |
|---|
| 405 | return pci_module_init(&amd8111_driver); |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | |
|---|
| 409 | static void __exit i2c_amd8111_exit(void) |
|---|
| 410 | { |
|---|
| 411 | pci_unregister_driver(&amd8111_driver); |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | module_init(i2c_amd8111_init); |
|---|
| 415 | module_exit(i2c_amd8111_exit); |
|---|