aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/Kconfig13
-rw-r--r--drivers/i2c/busses/Makefile1
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c2
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c58
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c2
-rw-r--r--drivers/i2c/busses/i2c-amd756-s4882.c2
-rw-r--r--drivers/i2c/busses/i2c-amd756.c2
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c72
-rw-r--r--drivers/i2c/busses/i2c-i801.c4
-rw-r--r--drivers/i2c/busses/i2c-i810.c2
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c1
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c1
-rw-r--r--drivers/i2c/busses/i2c-isa.c1
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c1
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c4
-rw-r--r--drivers/i2c/busses/i2c-ocores.c1
-rw-r--r--drivers/i2c/busses/i2c-parport.h8
-rw-r--r--drivers/i2c/busses/i2c-pasemi.c426
-rw-r--r--drivers/i2c/busses/i2c-piix4.c5
-rw-r--r--drivers/i2c/busses/i2c-powermac.c1
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c1
-rw-r--r--drivers/i2c/busses/i2c-savage4.c1
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c1
-rw-r--r--drivers/i2c/busses/i2c-sis630.c1
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c2
-rw-r--r--drivers/i2c/busses/i2c-via.c1
-rw-r--r--drivers/i2c/busses/i2c-viapro.c7
-rw-r--r--drivers/i2c/busses/i2c-voodoo3.c2
-rw-r--r--drivers/i2c/busses/scx200_acb.c7
-rw-r--r--drivers/i2c/busses/scx200_i2c.c1
-rw-r--r--drivers/i2c/chips/eeprom.c1
-rw-r--r--drivers/i2c/i2c-core.c71
32 files changed, 601 insertions, 102 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 9367c4cfe936..4d44a2db29dd 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -183,6 +183,7 @@ config I2C_PIIX4
183 ATI IXP200 183 ATI IXP200
184 ATI IXP300 184 ATI IXP300
185 ATI IXP400 185 ATI IXP400
186 ATI SB600
186 Serverworks OSB4 187 Serverworks OSB4
187 Serverworks CSB5 188 Serverworks CSB5
188 Serverworks CSB6 189 Serverworks CSB6
@@ -341,6 +342,13 @@ config I2C_PARPORT_LIGHT
341 This support is also available as a module. If so, the module 342 This support is also available as a module. If so, the module
342 will be called i2c-parport-light. 343 will be called i2c-parport-light.
343 344
345config I2C_PASEMI
346 tristate "PA Semi SMBus interface"
347# depends on PPC_PASEMI && I2C && PCI
348 depends on I2C && PCI
349 help
350 Supports the PA Semi PWRficient on-chip SMBus interfaces.
351
344config I2C_PROSAVAGE 352config I2C_PROSAVAGE
345 tristate "S3/VIA (Pro)Savage" 353 tristate "S3/VIA (Pro)Savage"
346 depends on I2C && PCI 354 depends on I2C && PCI
@@ -499,11 +507,11 @@ config I2C_VIA
499 will be called i2c-via. 507 will be called i2c-via.
500 508
501config I2C_VIAPRO 509config I2C_VIAPRO
502 tristate "VIA 82C596/82C686/82xx" 510 tristate "VIA VT82C596/82C686/82xx and CX700"
503 depends on I2C && PCI 511 depends on I2C && PCI
504 help 512 help
505 If you say yes to this option, support will be included for the VIA 513 If you say yes to this option, support will be included for the VIA
506 82C596/82C686/82xx I2C interfaces. Specifically, the following 514 VT82C596 and later SMBus interface. Specifically, the following
507 chipsets are supported: 515 chipsets are supported:
508 VT82C596A/B 516 VT82C596A/B
509 VT82C686A/B 517 VT82C686A/B
@@ -512,6 +520,7 @@ config I2C_VIAPRO
512 VT8235 520 VT8235
513 VT8237R/A 521 VT8237R/A
514 VT8251 522 VT8251
523 CX700
515 524
516 This driver can also be built as a module. If so, the module 525 This driver can also be built as a module. If so, the module
517 will be called i2c-viapro. 526 will be called i2c-viapro.
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 37196c1d0794..03505aa44bbf 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_I2C_OCORES) += i2c-ocores.o
27obj-$(CONFIG_I2C_OMAP) += i2c-omap.o 27obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
28obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o 28obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o
29obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o 29obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
30obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o
30obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o 31obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
31obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o 32obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o
32obj-$(CONFIG_I2C_PNX) += i2c-pnx.o 33obj-$(CONFIG_I2C_PNX) += i2c-pnx.o
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index e75d339a3481..6fd8ad7faa06 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -57,7 +57,6 @@
57#include <linux/pci.h> 57#include <linux/pci.h>
58#include <linux/kernel.h> 58#include <linux/kernel.h>
59#include <linux/stddef.h> 59#include <linux/stddef.h>
60#include <linux/sched.h>
61#include <linux/delay.h> 60#include <linux/delay.h>
62#include <linux/ioport.h> 61#include <linux/ioport.h>
63#include <linux/i2c.h> 62#include <linux/i2c.h>
@@ -475,6 +474,7 @@ static const struct i2c_algorithm smbus_algorithm = {
475 474
476static struct i2c_adapter ali1535_adapter = { 475static struct i2c_adapter ali1535_adapter = {
477 .owner = THIS_MODULE, 476 .owner = THIS_MODULE,
477 .id = I2C_HW_SMBUS_ALI1535,
478 .class = I2C_CLASS_HWMON, 478 .class = I2C_CLASS_HWMON,
479 .algo = &smbus_algorithm, 479 .algo = &smbus_algorithm,
480}; 480};
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 8e1e3f8e40a4..6b68074e518a 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -314,35 +314,11 @@ static u32 ali1563_func(struct i2c_adapter * a)
314} 314}
315 315
316 316
317static void ali1563_enable(struct pci_dev * dev)
318{
319 u16 ctrl;
320
321 pci_read_config_word(dev,ALI1563_SMBBA,&ctrl);
322 ctrl |= 0x7;
323 pci_write_config_word(dev,ALI1563_SMBBA,ctrl);
324}
325
326static int __devinit ali1563_setup(struct pci_dev * dev) 317static int __devinit ali1563_setup(struct pci_dev * dev)
327{ 318{
328 u16 ctrl; 319 u16 ctrl;
329 320
330 pci_read_config_word(dev,ALI1563_SMBBA,&ctrl); 321 pci_read_config_word(dev,ALI1563_SMBBA,&ctrl);
331 printk("ali1563: SMBus control = %04x\n",ctrl);
332
333 /* Check if device is even enabled first */
334 if (!(ctrl & ALI1563_SMB_IOEN)) {
335 dev_warn(&dev->dev,"I/O space not enabled, trying manually\n");
336 ali1563_enable(dev);
337 }
338 if (!(ctrl & ALI1563_SMB_IOEN)) {
339 dev_warn(&dev->dev,"I/O space still not enabled, giving up\n");
340 goto Err;
341 }
342 if (!(ctrl & ALI1563_SMB_HOSTEN)) {
343 dev_warn(&dev->dev,"Host Controller not enabled\n");
344 goto Err;
345 }
346 322
347 /* SMB I/O Base in high 12 bits and must be aligned with the 323 /* SMB I/O Base in high 12 bits and must be aligned with the
348 * size of the I/O space. */ 324 * size of the I/O space. */
@@ -351,11 +327,31 @@ static int __devinit ali1563_setup(struct pci_dev * dev)
351 dev_warn(&dev->dev,"ali1563_smba Uninitialized\n"); 327 dev_warn(&dev->dev,"ali1563_smba Uninitialized\n");
352 goto Err; 328 goto Err;
353 } 329 }
330
331 /* Check if device is enabled */
332 if (!(ctrl & ALI1563_SMB_HOSTEN)) {
333 dev_warn(&dev->dev, "Host Controller not enabled\n");
334 goto Err;
335 }
336 if (!(ctrl & ALI1563_SMB_IOEN)) {
337 dev_warn(&dev->dev, "I/O space not enabled, trying manually\n");
338 pci_write_config_word(dev, ALI1563_SMBBA,
339 ctrl | ALI1563_SMB_IOEN);
340 pci_read_config_word(dev, ALI1563_SMBBA, &ctrl);
341 if (!(ctrl & ALI1563_SMB_IOEN)) {
342 dev_err(&dev->dev, "I/O space still not enabled, "
343 "giving up\n");
344 goto Err;
345 }
346 }
347
354 if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, 348 if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE,
355 ali1563_pci_driver.name)) { 349 ali1563_pci_driver.name)) {
356 dev_warn(&dev->dev,"Could not allocate I/O space"); 350 dev_err(&dev->dev, "Could not allocate I/O space at 0x%04x\n",
351 ali1563_smba);
357 goto Err; 352 goto Err;
358 } 353 }
354 dev_info(&dev->dev, "Found ALi1563 SMBus at 0x%04x\n", ali1563_smba);
359 355
360 return 0; 356 return 0;
361Err: 357Err:
@@ -374,6 +370,7 @@ static const struct i2c_algorithm ali1563_algorithm = {
374 370
375static struct i2c_adapter ali1563_adapter = { 371static struct i2c_adapter ali1563_adapter = {
376 .owner = THIS_MODULE, 372 .owner = THIS_MODULE,
373 .id = I2C_HW_SMBUS_ALI1563,
377 .class = I2C_CLASS_HWMON, 374 .class = I2C_CLASS_HWMON,
378 .algo = &ali1563_algorithm, 375 .algo = &ali1563_algorithm,
379}; 376};
@@ -384,13 +381,18 @@ static int __devinit ali1563_probe(struct pci_dev * dev,
384 int error; 381 int error;
385 382
386 if ((error = ali1563_setup(dev))) 383 if ((error = ali1563_setup(dev)))
387 return error; 384 goto exit;
388 ali1563_adapter.dev.parent = &dev->dev; 385 ali1563_adapter.dev.parent = &dev->dev;
389 sprintf(ali1563_adapter.name,"SMBus ALi 1563 Adapter @ %04x", 386 sprintf(ali1563_adapter.name,"SMBus ALi 1563 Adapter @ %04x",
390 ali1563_smba); 387 ali1563_smba);
391 if ((error = i2c_add_adapter(&ali1563_adapter))) 388 if ((error = i2c_add_adapter(&ali1563_adapter)))
392 ali1563_shutdown(dev); 389 goto exit_shutdown;
393 printk("%s: Returning %d\n",__FUNCTION__,error); 390 return 0;
391
392exit_shutdown:
393 ali1563_shutdown(dev);
394exit:
395 dev_warn(&dev->dev, "ALi1563 SMBus probe failed (%d)\n", error);
394 return error; 396 return error;
395} 397}
396 398
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 3f11b6e1a341..e4e0df106812 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -64,7 +64,6 @@
64#include <linux/pci.h> 64#include <linux/pci.h>
65#include <linux/kernel.h> 65#include <linux/kernel.h>
66#include <linux/stddef.h> 66#include <linux/stddef.h>
67#include <linux/sched.h>
68#include <linux/ioport.h> 67#include <linux/ioport.h>
69#include <linux/delay.h> 68#include <linux/delay.h>
70#include <linux/i2c.h> 69#include <linux/i2c.h>
@@ -470,6 +469,7 @@ static const struct i2c_algorithm smbus_algorithm = {
470 469
471static struct i2c_adapter ali15x3_adapter = { 470static struct i2c_adapter ali15x3_adapter = {
472 .owner = THIS_MODULE, 471 .owner = THIS_MODULE,
472 .id = I2C_HW_SMBUS_ALI15X3,
473 .class = I2C_CLASS_HWMON, 473 .class = I2C_CLASS_HWMON,
474 .algo = &smbus_algorithm, 474 .algo = &smbus_algorithm,
475}; 475};
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index 08e915730caf..e5e96c817566 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -184,12 +184,14 @@ static int __init amd756_s4882_init(void)
184 s4882_algo[0].smbus_xfer = amd756_access_virt0; 184 s4882_algo[0].smbus_xfer = amd756_access_virt0;
185 s4882_adapter[0] = amd756_smbus; 185 s4882_adapter[0] = amd756_smbus;
186 s4882_adapter[0].algo = s4882_algo; 186 s4882_adapter[0].algo = s4882_algo;
187 s4882_adapter[0].dev.parent = amd756_smbus.dev.parent;
187 for (i = 1; i < 5; i++) { 188 for (i = 1; i < 5; i++) {
188 s4882_algo[i] = *(amd756_smbus.algo); 189 s4882_algo[i] = *(amd756_smbus.algo);
189 s4882_adapter[i] = amd756_smbus; 190 s4882_adapter[i] = amd756_smbus;
190 sprintf(s4882_adapter[i].name, 191 sprintf(s4882_adapter[i].name,
191 "SMBus 8111 adapter (CPU%d)", i-1); 192 "SMBus 8111 adapter (CPU%d)", i-1);
192 s4882_adapter[i].algo = s4882_algo+i; 193 s4882_adapter[i].algo = s4882_algo+i;
194 s4882_adapter[i].dev.parent = amd756_smbus.dev.parent;
193 } 195 }
194 s4882_algo[1].smbus_xfer = amd756_access_virt1; 196 s4882_algo[1].smbus_xfer = amd756_access_virt1;
195 s4882_algo[2].smbus_xfer = amd756_access_virt2; 197 s4882_algo[2].smbus_xfer = amd756_access_virt2;
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 2d21afdc5b1c..fa6155a54cc3 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -42,7 +42,6 @@
42#include <linux/kernel.h> 42#include <linux/kernel.h>
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/stddef.h> 44#include <linux/stddef.h>
45#include <linux/sched.h>
46#include <linux/ioport.h> 45#include <linux/ioport.h>
47#include <linux/i2c.h> 46#include <linux/i2c.h>
48#include <linux/init.h> 47#include <linux/init.h>
@@ -301,6 +300,7 @@ static const struct i2c_algorithm smbus_algorithm = {
301 300
302struct i2c_adapter amd756_smbus = { 301struct i2c_adapter amd756_smbus = {
303 .owner = THIS_MODULE, 302 .owner = THIS_MODULE,
303 .id = I2C_HW_SMBUS_AMD756,
304 .class = I2C_CLASS_HWMON, 304 .class = I2C_CLASS_HWMON,
305 .algo = &smbus_algorithm, 305 .algo = &smbus_algorithm,
306}; 306};
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index 0fbc7186c91a..5bba3fb50d71 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -12,7 +12,6 @@
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/stddef.h> 14#include <linux/stddef.h>
15#include <linux/sched.h>
16#include <linux/ioport.h> 15#include <linux/ioport.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/i2c.h> 17#include <linux/i2c.h>
@@ -76,7 +75,8 @@ static unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
76 udelay(1); 75 udelay(1);
77 76
78 if (!timeout) { 77 if (!timeout) {
79 dev_warn(&smbus->dev->dev, "Timeout while waiting for IBF to clear\n"); 78 dev_warn(&smbus->dev->dev,
79 "Timeout while waiting for IBF to clear\n");
80 return -1; 80 return -1;
81 } 81 }
82 82
@@ -91,14 +91,16 @@ static unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
91 udelay(1); 91 udelay(1);
92 92
93 if (!timeout) { 93 if (!timeout) {
94 dev_warn(&smbus->dev->dev, "Timeout while waiting for OBF to set\n"); 94 dev_warn(&smbus->dev->dev,
95 "Timeout while waiting for OBF to set\n");
95 return -1; 96 return -1;
96 } 97 }
97 98
98 return 0; 99 return 0;
99} 100}
100 101
101static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, unsigned char *data) 102static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address,
103 unsigned char *data)
102{ 104{
103 if (amd_ec_wait_write(smbus)) 105 if (amd_ec_wait_write(smbus))
104 return -1; 106 return -1;
@@ -115,7 +117,8 @@ static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address,
115 return 0; 117 return 0;
116} 118}
117 119
118static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, unsigned char data) 120static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address,
121 unsigned char data)
119{ 122{
120 if (amd_ec_wait_write(smbus)) 123 if (amd_ec_wait_write(smbus))
121 return -1; 124 return -1;
@@ -175,18 +178,19 @@ static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address,
175#define AMD_SMB_PRTCL_PEC 0x80 178#define AMD_SMB_PRTCL_PEC 0x80
176 179
177 180
178static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, 181static s32 amd8111_access(struct i2c_adapter * adap, u16 addr,
179 char read_write, u8 command, int size, union i2c_smbus_data * data) 182 unsigned short flags, char read_write, u8 command, int size,
183 union i2c_smbus_data * data)
180{ 184{
181 struct amd_smbus *smbus = adap->algo_data; 185 struct amd_smbus *smbus = adap->algo_data;
182 unsigned char protocol, len, pec, temp[2]; 186 unsigned char protocol, len, pec, temp[2];
183 int i; 187 int i;
184 188
185 protocol = (read_write == I2C_SMBUS_READ) ? AMD_SMB_PRTCL_READ : AMD_SMB_PRTCL_WRITE; 189 protocol = (read_write == I2C_SMBUS_READ) ? AMD_SMB_PRTCL_READ
190 : AMD_SMB_PRTCL_WRITE;
186 pec = (flags & I2C_CLIENT_PEC) ? AMD_SMB_PRTCL_PEC : 0; 191 pec = (flags & I2C_CLIENT_PEC) ? AMD_SMB_PRTCL_PEC : 0;
187 192
188 switch (size) { 193 switch (size) {
189
190 case I2C_SMBUS_QUICK: 194 case I2C_SMBUS_QUICK:
191 protocol |= AMD_SMB_PRTCL_QUICK; 195 protocol |= AMD_SMB_PRTCL_QUICK;
192 read_write = I2C_SMBUS_WRITE; 196 read_write = I2C_SMBUS_WRITE;
@@ -208,8 +212,10 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl
208 case I2C_SMBUS_WORD_DATA: 212 case I2C_SMBUS_WORD_DATA:
209 amd_ec_write(smbus, AMD_SMB_CMD, command); 213 amd_ec_write(smbus, AMD_SMB_CMD, command);
210 if (read_write == I2C_SMBUS_WRITE) { 214 if (read_write == I2C_SMBUS_WRITE) {
211 amd_ec_write(smbus, AMD_SMB_DATA, data->word); 215 amd_ec_write(smbus, AMD_SMB_DATA,
212 amd_ec_write(smbus, AMD_SMB_DATA + 1, data->word >> 8); 216 data->word & 0xff);
217 amd_ec_write(smbus, AMD_SMB_DATA + 1,
218 data->word >> 8);
213 } 219 }
214 protocol |= AMD_SMB_PRTCL_WORD_DATA | pec; 220 protocol |= AMD_SMB_PRTCL_WORD_DATA | pec;
215 break; 221 break;
@@ -217,27 +223,31 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl
217 case I2C_SMBUS_BLOCK_DATA: 223 case I2C_SMBUS_BLOCK_DATA:
218 amd_ec_write(smbus, AMD_SMB_CMD, command); 224 amd_ec_write(smbus, AMD_SMB_CMD, command);
219 if (read_write == I2C_SMBUS_WRITE) { 225 if (read_write == I2C_SMBUS_WRITE) {
220 len = min_t(u8, data->block[0], 32); 226 len = min_t(u8, data->block[0],
227 I2C_SMBUS_BLOCK_MAX);
221 amd_ec_write(smbus, AMD_SMB_BCNT, len); 228 amd_ec_write(smbus, AMD_SMB_BCNT, len);
222 for (i = 0; i < len; i++) 229 for (i = 0; i < len; i++)
223 amd_ec_write(smbus, AMD_SMB_DATA + i, data->block[i + 1]); 230 amd_ec_write(smbus, AMD_SMB_DATA + i,
231 data->block[i + 1]);
224 } 232 }
225 protocol |= AMD_SMB_PRTCL_BLOCK_DATA | pec; 233 protocol |= AMD_SMB_PRTCL_BLOCK_DATA | pec;
226 break; 234 break;
227 235
228 case I2C_SMBUS_I2C_BLOCK_DATA: 236 case I2C_SMBUS_I2C_BLOCK_DATA:
229 len = min_t(u8, data->block[0], 32); 237 len = min_t(u8, data->block[0],
238 I2C_SMBUS_BLOCK_MAX);
230 amd_ec_write(smbus, AMD_SMB_CMD, command); 239 amd_ec_write(smbus, AMD_SMB_CMD, command);
231 amd_ec_write(smbus, AMD_SMB_BCNT, len); 240 amd_ec_write(smbus, AMD_SMB_BCNT, len);
232 if (read_write == I2C_SMBUS_WRITE) 241 if (read_write == I2C_SMBUS_WRITE)
233 for (i = 0; i < len; i++) 242 for (i = 0; i < len; i++)
234 amd_ec_write(smbus, AMD_SMB_DATA + i, data->block[i + 1]); 243 amd_ec_write(smbus, AMD_SMB_DATA + i,
244 data->block[i + 1]);
235 protocol |= AMD_SMB_PRTCL_I2C_BLOCK_DATA; 245 protocol |= AMD_SMB_PRTCL_I2C_BLOCK_DATA;
236 break; 246 break;
237 247
238 case I2C_SMBUS_PROC_CALL: 248 case I2C_SMBUS_PROC_CALL:
239 amd_ec_write(smbus, AMD_SMB_CMD, command); 249 amd_ec_write(smbus, AMD_SMB_CMD, command);
240 amd_ec_write(smbus, AMD_SMB_DATA, data->word); 250 amd_ec_write(smbus, AMD_SMB_DATA, data->word & 0xff);
241 amd_ec_write(smbus, AMD_SMB_DATA + 1, data->word >> 8); 251 amd_ec_write(smbus, AMD_SMB_DATA + 1, data->word >> 8);
242 protocol = AMD_SMB_PRTCL_PROC_CALL | pec; 252 protocol = AMD_SMB_PRTCL_PROC_CALL | pec;
243 read_write = I2C_SMBUS_READ; 253 read_write = I2C_SMBUS_READ;
@@ -248,7 +258,8 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl
248 amd_ec_write(smbus, AMD_SMB_CMD, command); 258 amd_ec_write(smbus, AMD_SMB_CMD, command);
249 amd_ec_write(smbus, AMD_SMB_BCNT, len); 259 amd_ec_write(smbus, AMD_SMB_BCNT, len);
250 for (i = 0; i < len; i++) 260 for (i = 0; i < len; i++)
251 amd_ec_write(smbus, AMD_SMB_DATA + i, data->block[i + 1]); 261 amd_ec_write(smbus, AMD_SMB_DATA + i,
262 data->block[i + 1]);
252 protocol = AMD_SMB_PRTCL_BLOCK_PROC_CALL | pec; 263 protocol = AMD_SMB_PRTCL_BLOCK_PROC_CALL | pec;
253 read_write = I2C_SMBUS_READ; 264 read_write = I2C_SMBUS_READ;
254 break; 265 break;
@@ -280,7 +291,6 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl
280 return 0; 291 return 0;
281 292
282 switch (size) { 293 switch (size) {
283
284 case I2C_SMBUS_BYTE: 294 case I2C_SMBUS_BYTE:
285 case I2C_SMBUS_BYTE_DATA: 295 case I2C_SMBUS_BYTE_DATA:
286 amd_ec_read(smbus, AMD_SMB_DATA, &data->byte); 296 amd_ec_read(smbus, AMD_SMB_DATA, &data->byte);
@@ -296,10 +306,11 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl
296 case I2C_SMBUS_BLOCK_DATA: 306 case I2C_SMBUS_BLOCK_DATA:
297 case I2C_SMBUS_BLOCK_PROC_CALL: 307 case I2C_SMBUS_BLOCK_PROC_CALL:
298 amd_ec_read(smbus, AMD_SMB_BCNT, &len); 308 amd_ec_read(smbus, AMD_SMB_BCNT, &len);
299 len = min_t(u8, len, 32); 309 len = min_t(u8, len, I2C_SMBUS_BLOCK_MAX);
300 case I2C_SMBUS_I2C_BLOCK_DATA: 310 case I2C_SMBUS_I2C_BLOCK_DATA:
301 for (i = 0; i < len; i++) 311 for (i = 0; i < len; i++)
302 amd_ec_read(smbus, AMD_SMB_DATA + i, data->block + i + 1); 312 amd_ec_read(smbus, AMD_SMB_DATA + i,
313 data->block + i + 1);
303 data->block[0] = len; 314 data->block[0] = len;
304 break; 315 break;
305 } 316 }
@@ -310,7 +321,8 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr, unsigned short fl
310 321
311static u32 amd8111_func(struct i2c_adapter *adapter) 322static u32 amd8111_func(struct i2c_adapter *adapter)
312{ 323{
313 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | 324 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
325 I2C_FUNC_SMBUS_BYTE_DATA |
314 I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA | 326 I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA |
315 I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_BLOCK_PROC_CALL | 327 I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
316 I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC; 328 I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC;
@@ -329,12 +341,13 @@ static struct pci_device_id amd8111_ids[] = {
329 341
330MODULE_DEVICE_TABLE (pci, amd8111_ids); 342MODULE_DEVICE_TABLE (pci, amd8111_ids);
331 343
332static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_id *id) 344static int __devinit amd8111_probe(struct pci_dev *dev,
345 const struct pci_device_id *id)
333{ 346{
334 struct amd_smbus *smbus; 347 struct amd_smbus *smbus;
335 int error = -ENODEV; 348 int error;
336 349
337 if (~pci_resource_flags(dev, 0) & IORESOURCE_IO) 350 if (!(pci_resource_flags(dev, 0) & IORESOURCE_IO))
338 return -ENODEV; 351 return -ENODEV;
339 352
340 smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL); 353 smbus = kzalloc(sizeof(struct amd_smbus), GFP_KERNEL);
@@ -345,12 +358,15 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
345 smbus->base = pci_resource_start(dev, 0); 358 smbus->base = pci_resource_start(dev, 0);
346 smbus->size = pci_resource_len(dev, 0); 359 smbus->size = pci_resource_len(dev, 0);
347 360
348 if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) 361 if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) {
362 error = -EBUSY;
349 goto out_kfree; 363 goto out_kfree;
364 }
350 365
351 smbus->adapter.owner = THIS_MODULE; 366 smbus->adapter.owner = THIS_MODULE;
352 snprintf(smbus->adapter.name, I2C_NAME_SIZE, 367 snprintf(smbus->adapter.name, I2C_NAME_SIZE,
353 "SMBus2 AMD8111 adapter at %04x", smbus->base); 368 "SMBus2 AMD8111 adapter at %04x", smbus->base);
369 smbus->adapter.id = I2C_HW_SMBUS_AMD8111;
354 smbus->adapter.class = I2C_CLASS_HWMON; 370 smbus->adapter.class = I2C_CLASS_HWMON;
355 smbus->adapter.algo = &smbus_algorithm; 371 smbus->adapter.algo = &smbus_algorithm;
356 smbus->adapter.algo_data = smbus; 372 smbus->adapter.algo_data = smbus;
@@ -358,11 +374,11 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
358 /* set up the driverfs linkage to our parent device */ 374 /* set up the driverfs linkage to our parent device */
359 smbus->adapter.dev.parent = &dev->dev; 375 smbus->adapter.dev.parent = &dev->dev;
360 376
377 pci_write_config_dword(smbus->dev, AMD_PCI_MISC, 0);
361 error = i2c_add_adapter(&smbus->adapter); 378 error = i2c_add_adapter(&smbus->adapter);
362 if (error) 379 if (error)
363 goto out_release_region; 380 goto out_release_region;
364 381
365 pci_write_config_dword(smbus->dev, AMD_PCI_MISC, 0);
366 pci_set_drvdata(dev, smbus); 382 pci_set_drvdata(dev, smbus);
367 return 0; 383 return 0;
368 384
@@ -370,10 +386,9 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
370 release_region(smbus->base, smbus->size); 386 release_region(smbus->base, smbus->size);
371 out_kfree: 387 out_kfree:
372 kfree(smbus); 388 kfree(smbus);
373 return -1; 389 return error;
374} 390}
375 391
376
377static void __devexit amd8111_remove(struct pci_dev *dev) 392static void __devexit amd8111_remove(struct pci_dev *dev)
378{ 393{
379 struct amd_smbus *smbus = pci_get_drvdata(dev); 394 struct amd_smbus *smbus = pci_get_drvdata(dev);
@@ -395,7 +410,6 @@ static int __init i2c_amd8111_init(void)
395 return pci_register_driver(&amd8111_driver); 410 return pci_register_driver(&amd8111_driver);
396} 411}
397 412
398
399static void __exit i2c_amd8111_exit(void) 413static void __exit i2c_amd8111_exit(void)
400{ 414{
401 pci_unregister_driver(&amd8111_driver); 415 pci_unregister_driver(&amd8111_driver);
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index ae625b854470..21f2671f7220 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -48,7 +48,6 @@
48#include <linux/kernel.h> 48#include <linux/kernel.h>
49#include <linux/stddef.h> 49#include <linux/stddef.h>
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/sched.h>
52#include <linux/ioport.h> 51#include <linux/ioport.h>
53#include <linux/init.h> 52#include <linux/init.h>
54#include <linux/i2c.h> 53#include <linux/i2c.h>
@@ -123,7 +122,7 @@ static int i801_transaction(void)
123 dev_dbg(&I801_dev->dev, "Failed! (%02x)\n", temp); 122 dev_dbg(&I801_dev->dev, "Failed! (%02x)\n", temp);
124 return -1; 123 return -1;
125 } else { 124 } else {
126 dev_dbg(&I801_dev->dev, "Successfull!\n"); 125 dev_dbg(&I801_dev->dev, "Successful!\n");
127 } 126 }
128 } 127 }
129 128
@@ -442,6 +441,7 @@ static const struct i2c_algorithm smbus_algorithm = {
442 441
443static struct i2c_adapter i801_adapter = { 442static struct i2c_adapter i801_adapter = {
444 .owner = THIS_MODULE, 443 .owner = THIS_MODULE,
444 .id = I2C_HW_SMBUS_I801,
445 .class = I2C_CLASS_HWMON, 445 .class = I2C_CLASS_HWMON,
446 .algo = &smbus_algorithm, 446 .algo = &smbus_algorithm,
447}; 447};
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c
index 10c98bc88aa6..42e8d94c276f 100644
--- a/drivers/i2c/busses/i2c-i810.c
+++ b/drivers/i2c/busses/i2c-i810.c
@@ -171,6 +171,7 @@ static struct i2c_algo_bit_data i810_i2c_bit_data = {
171 171
172static struct i2c_adapter i810_i2c_adapter = { 172static struct i2c_adapter i810_i2c_adapter = {
173 .owner = THIS_MODULE, 173 .owner = THIS_MODULE,
174 .id = I2C_HW_B_I810,
174 .name = "I810/I815 I2C Adapter", 175 .name = "I810/I815 I2C Adapter",
175 .algo_data = &i810_i2c_bit_data, 176 .algo_data = &i810_i2c_bit_data,
176}; 177};
@@ -186,6 +187,7 @@ static struct i2c_algo_bit_data i810_ddc_bit_data = {
186 187
187static struct i2c_adapter i810_ddc_adapter = { 188static struct i2c_adapter i810_ddc_adapter = {
188 .owner = THIS_MODULE, 189 .owner = THIS_MODULE,
190 .id = I2C_HW_B_I810,
189 .name = "I810/I815 DDC Adapter", 191 .name = "I810/I815 DDC Adapter",
190 .algo_data = &i810_ddc_bit_data, 192 .algo_data = &i810_ddc_bit_data,
191}; 193};
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 1898e9987021..8b14d14e60ca 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -727,6 +727,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
727 727
728 /* Register it with i2c layer */ 728 /* Register it with i2c layer */
729 adap = &dev->adap; 729 adap = &dev->adap;
730 adap->dev.parent = &ocp->dev;
730 strcpy(adap->name, "IBM IIC"); 731 strcpy(adap->name, "IBM IIC");
731 i2c_set_adapdata(adap, dev); 732 i2c_set_adapdata(adap, dev);
732 adap->id = I2C_HW_OCP; 733 adap->id = I2C_HW_OCP;
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index d108ab4974cc..20ee4f7c53a0 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -36,7 +36,6 @@
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/errno.h> 38#include <linux/errno.h>
39#include <linux/sched.h>
40#include <linux/platform_device.h> 39#include <linux/platform_device.h>
41#include <linux/i2c.h> 40#include <linux/i2c.h>
42 41
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 8ed59a2dff53..5f33bc9c1e02 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -39,6 +39,7 @@
39#include <linux/i2c.h> 39#include <linux/i2c.h>
40#include <linux/i2c-isa.h> 40#include <linux/i2c-isa.h>
41#include <linux/platform_device.h> 41#include <linux/platform_device.h>
42#include <linux/completion.h>
42 43
43static u32 isa_func(struct i2c_adapter *adapter); 44static u32 isa_func(struct i2c_adapter *adapter);
44 45
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 490173611d6b..a3283b907eb8 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -520,6 +520,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
520 rc = -ENXIO; 520 rc = -ENXIO;
521 goto exit_unmap_regs; 521 goto exit_unmap_regs;
522 } 522 }
523 drv_data->adapter.dev.parent = &pd->dev;
523 drv_data->adapter.id = I2C_HW_MV64XXX; 524 drv_data->adapter.id = I2C_HW_MV64XXX;
524 drv_data->adapter.algo = &mv64xxx_i2c_algo; 525 drv_data->adapter.algo = &mv64xxx_i2c_algo;
525 drv_data->adapter.owner = THIS_MODULE; 526 drv_data->adapter.owner = THIS_MODULE;
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index ad37c10e7fec..1514ec5b77f8 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -44,7 +44,6 @@
44#include <linux/pci.h> 44#include <linux/pci.h>
45#include <linux/kernel.h> 45#include <linux/kernel.h>
46#include <linux/stddef.h> 46#include <linux/stddef.h>
47#include <linux/sched.h>
48#include <linux/ioport.h> 47#include <linux/ioport.h>
49#include <linux/init.h> 48#include <linux/init.h>
50#include <linux/i2c.h> 49#include <linux/i2c.h>
@@ -57,7 +56,6 @@ MODULE_DESCRIPTION("nForce2/3/4/5xx SMBus driver");
57 56
58 57
59struct nforce2_smbus { 58struct nforce2_smbus {
60 struct pci_dev *dev;
61 struct i2c_adapter adapter; 59 struct i2c_adapter adapter;
62 int base; 60 int base;
63 int size; 61 int size;
@@ -230,7 +228,6 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
230 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; 228 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK;
231 smbus->size = 64; 229 smbus->size = 64;
232 } 230 }
233 smbus->dev = dev;
234 231
235 if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { 232 if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) {
236 dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", 233 dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n",
@@ -238,6 +235,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
238 return -1; 235 return -1;
239 } 236 }
240 smbus->adapter.owner = THIS_MODULE; 237 smbus->adapter.owner = THIS_MODULE;
238 smbus->adapter.id = I2C_HW_SMBUS_NFORCE2;
241 smbus->adapter.class = I2C_CLASS_HWMON; 239 smbus->adapter.class = I2C_CLASS_HWMON;
242 smbus->adapter.algo = &smbus_algorithm; 240 smbus->adapter.algo = &smbus_algorithm;
243 smbus->adapter.algo_data = smbus; 241 smbus->adapter.algo_data = smbus;
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index f28a76d1c0af..e417c2c3ca22 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -11,7 +11,6 @@
11 11
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/sched.h>
15#include <linux/init.h> 14#include <linux/init.h>
16#include <linux/errno.h> 15#include <linux/errno.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
diff --git a/drivers/i2c/busses/i2c-parport.h b/drivers/i2c/busses/i2c-parport.h
index 9ddd816d5d0f..ed69d846cb95 100644
--- a/drivers/i2c/busses/i2c-parport.h
+++ b/drivers/i2c/busses/i2c-parport.h
@@ -88,6 +88,13 @@ static struct adapter_parm adapter_parm[] = {
88 .getscl = { 0x40, STAT, 0 }, 88 .getscl = { 0x40, STAT, 0 },
89 .init = { 0xfc, DATA, 0 }, 89 .init = { 0xfc, DATA, 0 },
90 }, 90 },
91 /* type 7: One For All JP1 parallel port adapter */
92 {
93 .setsda = { 0x01, DATA, 0 },
94 .setscl = { 0x02, DATA, 0 },
95 .getsda = { 0x80, STAT, 1 },
96 .init = { 0x04, DATA, 1 },
97 },
91}; 98};
92 99
93static int type = -1; 100static int type = -1;
@@ -101,4 +108,5 @@ MODULE_PARM_DESC(type,
101 " 4 = ADM1032 evaluation board\n" 108 " 4 = ADM1032 evaluation board\n"
102 " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n" 109 " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n"
103 " 6 = Barco LPT->DVI (K5800236) adapter\n" 110 " 6 = Barco LPT->DVI (K5800236) adapter\n"
111 " 7 = One For All JP1 parallel port adapter\n"
104); 112);
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c
new file mode 100644
index 000000000000..f54fb5d65cc4
--- /dev/null
+++ b/drivers/i2c/busses/i2c-pasemi.c
@@ -0,0 +1,426 @@
1/*
2 * Copyright (C) 2006-2007 PA Semi, Inc
3 *
4 * SMBus host driver for PA Semi PWRficient
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 version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/module.h>
21#include <linux/pci.h>
22#include <linux/kernel.h>
23#include <linux/stddef.h>
24#include <linux/sched.h>
25#include <linux/i2c.h>
26#include <linux/delay.h>
27#include <asm/io.h>
28
29static struct pci_driver pasemi_smb_driver;
30
31struct pasemi_smbus {
32 struct pci_dev *dev;
33 struct i2c_adapter adapter;
34 unsigned long base;
35 int size;
36};
37
38/* Register offsets */
39#define REG_MTXFIFO 0x00
40#define REG_MRXFIFO 0x04
41#define REG_SMSTA 0x14
42#define REG_CTL 0x1c
43
44/* Register defs */
45#define MTXFIFO_READ 0x00000400
46#define MTXFIFO_STOP 0x00000200
47#define MTXFIFO_START 0x00000100
48#define MTXFIFO_DATA_M 0x000000ff
49
50#define MRXFIFO_EMPTY 0x00000100
51#define MRXFIFO_DATA_M 0x000000ff
52
53#define SMSTA_XEN 0x08000000
54
55#define CTL_MRR 0x00000400
56#define CTL_MTR 0x00000200
57#define CTL_CLK_M 0x000000ff
58
59#define CLK_100K_DIV 84
60#define CLK_400K_DIV 21
61
62static inline void reg_write(struct pasemi_smbus *smbus, int reg, int val)
63{
64 dev_dbg(&smbus->dev->dev, "smbus write reg %lx val %08x\n",
65 smbus->base + reg, val);
66 outl(val, smbus->base + reg);
67}
68
69static inline int reg_read(struct pasemi_smbus *smbus, int reg)
70{
71 int ret;
72 ret = inl(smbus->base + reg);
73 dev_dbg(&smbus->dev->dev, "smbus read reg %lx val %08x\n",
74 smbus->base + reg, ret);
75 return ret;
76}
77
78#define TXFIFO_WR(smbus, reg) reg_write((smbus), REG_MTXFIFO, (reg))
79#define RXFIFO_RD(smbus) reg_read((smbus), REG_MRXFIFO)
80
81static void pasemi_smb_clear(struct pasemi_smbus *smbus)
82{
83 unsigned int status;
84
85 status = reg_read(smbus, REG_SMSTA);
86 reg_write(smbus, REG_SMSTA, status);
87}
88
89static unsigned int pasemi_smb_waitready(struct pasemi_smbus *smbus)
90{
91 int timeout = 10;
92 unsigned int status;
93
94 status = reg_read(smbus, REG_SMSTA);
95
96 while (!(status & SMSTA_XEN) && timeout--) {
97 msleep(1);
98 status = reg_read(smbus, REG_SMSTA);
99 }
100
101 if (timeout < 0) {
102 dev_warn(&smbus->dev->dev, "Timeout, status 0x%08x\n", status);
103 reg_write(smbus, REG_SMSTA, status);
104 return -ETIME;
105 }
106
107 /* Clear XEN */
108 reg_write(smbus, REG_SMSTA, SMSTA_XEN);
109
110 return 0;
111}
112
113static int pasemi_i2c_xfer_msg(struct i2c_adapter *adapter,
114 struct i2c_msg *msg, int stop)
115{
116 struct pasemi_smbus *smbus = adapter->algo_data;
117 int read, i, err;
118 u32 rd;
119
120 read = msg->flags & I2C_M_RD ? 1 : 0;
121
122 TXFIFO_WR(smbus, MTXFIFO_START | (msg->addr << 1) | read);
123
124 if (read) {
125 TXFIFO_WR(smbus, msg->len | MTXFIFO_READ |
126 (stop ? MTXFIFO_STOP : 0));
127
128 err = pasemi_smb_waitready(smbus);
129 if (err)
130 goto reset_out;
131
132 for (i = 0; i < msg->len; i++) {
133 rd = RXFIFO_RD(smbus);
134 if (rd & MRXFIFO_EMPTY) {
135 err = -ENODATA;
136 goto reset_out;
137 }
138 msg->buf[i] = rd & MRXFIFO_DATA_M;
139 }
140 } else {
141 for (i = 0; i < msg->len - 1; i++)
142 TXFIFO_WR(smbus, msg->buf[i]);
143
144 TXFIFO_WR(smbus, msg->buf[msg->len] |
145 (stop ? MTXFIFO_STOP : 0));
146 }
147
148 return 0;
149
150 reset_out:
151 reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR |
152 (CLK_100K_DIV & CTL_CLK_M)));
153 return err;
154}
155
156static int pasemi_i2c_xfer(struct i2c_adapter *adapter,
157 struct i2c_msg *msgs, int num)
158{
159 struct pasemi_smbus *smbus = adapter->algo_data;
160 int ret, i;
161
162 pasemi_smb_clear(smbus);
163
164 ret = 0;
165
166 for (i = 0; i < num && !ret; i++)
167 ret = pasemi_i2c_xfer_msg(adapter, &msgs[i], (i == (num - 1)));
168
169 return ret ? ret : num;
170}
171
172static int pasemi_smb_xfer(struct i2c_adapter *adapter,
173 u16 addr, unsigned short flags, char read_write, u8 command,
174 int size, union i2c_smbus_data *data)
175{
176 struct pasemi_smbus *smbus = adapter->algo_data;
177 unsigned int rd;
178 int read_flag, err;
179 int len = 0, i;
180
181 /* All our ops take 8-bit shifted addresses */
182 addr <<= 1;
183 read_flag = read_write == I2C_SMBUS_READ;
184
185 pasemi_smb_clear(smbus);
186
187 switch (size) {
188 case I2C_SMBUS_QUICK:
189 TXFIFO_WR(smbus, addr | read_flag | MTXFIFO_START |
190 MTXFIFO_STOP);
191 break;
192 case I2C_SMBUS_BYTE:
193 TXFIFO_WR(smbus, addr | read_flag | MTXFIFO_START);
194 if (read_write)
195 TXFIFO_WR(smbus, 1 | MTXFIFO_STOP | MTXFIFO_READ);
196 else
197 TXFIFO_WR(smbus, MTXFIFO_STOP | command);
198 break;
199 case I2C_SMBUS_BYTE_DATA:
200 TXFIFO_WR(smbus, addr | MTXFIFO_START);
201 TXFIFO_WR(smbus, command);
202 if (read_write) {
203 TXFIFO_WR(smbus, addr | I2C_SMBUS_READ | MTXFIFO_START);
204 TXFIFO_WR(smbus, 1 | MTXFIFO_READ | MTXFIFO_STOP);
205 } else {
206 TXFIFO_WR(smbus, MTXFIFO_STOP | data->byte);
207 }
208 break;
209 case I2C_SMBUS_WORD_DATA:
210 TXFIFO_WR(smbus, addr | MTXFIFO_START);
211 TXFIFO_WR(smbus, command);
212 if (read_write) {
213 TXFIFO_WR(smbus, addr | I2C_SMBUS_READ | MTXFIFO_START);
214 TXFIFO_WR(smbus, 2 | MTXFIFO_READ | MTXFIFO_STOP);
215 } else {
216 TXFIFO_WR(smbus, data->word & MTXFIFO_DATA_M);
217 TXFIFO_WR(smbus, MTXFIFO_STOP | (data->word >> 8));
218 }
219 break;
220 case I2C_SMBUS_BLOCK_DATA:
221 TXFIFO_WR(smbus, addr | MTXFIFO_START);
222 TXFIFO_WR(smbus, command);
223 if (read_write) {
224 TXFIFO_WR(smbus, addr | I2C_SMBUS_READ | MTXFIFO_START);
225 TXFIFO_WR(smbus, 1 | MTXFIFO_READ);
226 rd = RXFIFO_RD(smbus);
227 len = min_t(u8, (rd & MRXFIFO_DATA_M),
228 I2C_SMBUS_BLOCK_MAX);
229 TXFIFO_WR(smbus, (len + 1) | MTXFIFO_READ |
230 MTXFIFO_STOP);
231 } else {
232 len = min_t(u8, data->block[0], I2C_SMBUS_BLOCK_MAX);
233 TXFIFO_WR(smbus, len);
234 for (i = 1; i < len; i++)
235 TXFIFO_WR(smbus, data->block[i]);
236 TXFIFO_WR(smbus, data->block[len] | MTXFIFO_STOP);
237 }
238 break;
239 case I2C_SMBUS_PROC_CALL:
240 read_write = I2C_SMBUS_READ;
241 TXFIFO_WR(smbus, addr | MTXFIFO_START);
242 TXFIFO_WR(smbus, command);
243 TXFIFO_WR(smbus, data->word & MTXFIFO_DATA_M);
244 TXFIFO_WR(smbus, (data->word >> 8) & MTXFIFO_DATA_M);
245 TXFIFO_WR(smbus, addr | I2C_SMBUS_READ | MTXFIFO_START);
246 TXFIFO_WR(smbus, 2 | MTXFIFO_STOP | MTXFIFO_READ);
247 break;
248 case I2C_SMBUS_BLOCK_PROC_CALL:
249 len = min_t(u8, data->block[0], I2C_SMBUS_BLOCK_MAX - 1);
250 read_write = I2C_SMBUS_READ;
251 TXFIFO_WR(smbus, addr | MTXFIFO_START);
252 TXFIFO_WR(smbus, command);
253 TXFIFO_WR(smbus, len);
254 for (i = 1; i <= len; i++)
255 TXFIFO_WR(smbus, data->block[i]);
256 TXFIFO_WR(smbus, addr | I2C_SMBUS_READ);
257 TXFIFO_WR(smbus, MTXFIFO_READ | 1);
258 rd = RXFIFO_RD(smbus);
259 len = min_t(u8, (rd & MRXFIFO_DATA_M),
260 I2C_SMBUS_BLOCK_MAX - len);
261 TXFIFO_WR(smbus, (len + 1) | MTXFIFO_READ | MTXFIFO_STOP);
262 break;
263
264 default:
265 dev_warn(&adapter->dev, "Unsupported transaction %d\n", size);
266 return -EINVAL;
267 }
268
269 err = pasemi_smb_waitready(smbus);
270 if (err)
271 goto reset_out;
272
273 if (read_write == I2C_SMBUS_WRITE)
274 return 0;
275
276 switch (size) {
277 case I2C_SMBUS_BYTE:
278 case I2C_SMBUS_BYTE_DATA:
279 rd = RXFIFO_RD(smbus);
280 if (rd & MRXFIFO_EMPTY) {
281 err = -ENODATA;
282 goto reset_out;
283 }
284 data->byte = rd & MRXFIFO_DATA_M;
285 break;
286 case I2C_SMBUS_WORD_DATA:
287 case I2C_SMBUS_PROC_CALL:
288 rd = RXFIFO_RD(smbus);
289 if (rd & MRXFIFO_EMPTY) {
290 err = -ENODATA;
291 goto reset_out;
292 }
293 data->word = rd & MRXFIFO_DATA_M;
294 rd = RXFIFO_RD(smbus);
295 if (rd & MRXFIFO_EMPTY) {
296 err = -ENODATA;
297 goto reset_out;
298 }
299 data->word |= (rd & MRXFIFO_DATA_M) << 8;
300 break;
301 case I2C_SMBUS_BLOCK_DATA:
302 case I2C_SMBUS_BLOCK_PROC_CALL:
303 data->block[0] = len;
304 for (i = 1; i <= len; i ++) {
305 rd = RXFIFO_RD(smbus);
306 if (rd & MRXFIFO_EMPTY) {
307 err = -ENODATA;
308 goto reset_out;
309 }
310 data->block[i] = rd & MRXFIFO_DATA_M;
311 }
312 break;
313 }
314
315 return 0;
316
317 reset_out:
318 reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR |
319 (CLK_100K_DIV & CTL_CLK_M)));
320 return err;
321}
322
323static u32 pasemi_smb_func(struct i2c_adapter *adapter)
324{
325 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
326 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
327 I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL |
328 I2C_FUNC_SMBUS_BLOCK_PROC_CALL | I2C_FUNC_I2C;
329}
330
331static const struct i2c_algorithm smbus_algorithm = {
332 .master_xfer = pasemi_i2c_xfer,
333 .smbus_xfer = pasemi_smb_xfer,
334 .functionality = pasemi_smb_func,
335};
336
337static int __devinit pasemi_smb_probe(struct pci_dev *dev,
338 const struct pci_device_id *id)
339{
340 struct pasemi_smbus *smbus;
341 int error;
342
343 if (!(pci_resource_flags(dev, 0) & IORESOURCE_IO))
344 return -ENODEV;
345
346 smbus = kzalloc(sizeof(struct pasemi_smbus), GFP_KERNEL);
347 if (!smbus)
348 return -ENOMEM;
349
350 smbus->dev = dev;
351 smbus->base = pci_resource_start(dev, 0);
352 smbus->size = pci_resource_len(dev, 0);
353
354 if (!request_region(smbus->base, smbus->size,
355 pasemi_smb_driver.name)) {
356 error = -EBUSY;
357 goto out_kfree;
358 }
359
360 smbus->adapter.owner = THIS_MODULE;
361 snprintf(smbus->adapter.name, I2C_NAME_SIZE,
362 "PA Semi SMBus adapter at 0x%lx", smbus->base);
363 smbus->adapter.class = I2C_CLASS_HWMON;
364 smbus->adapter.algo = &smbus_algorithm;
365 smbus->adapter.algo_data = smbus;
366
367 /* set up the driverfs linkage to our parent device */
368 smbus->adapter.dev.parent = &dev->dev;
369
370 reg_write(smbus, REG_CTL, (CTL_MTR | CTL_MRR |
371 (CLK_100K_DIV & CTL_CLK_M)));
372
373 error = i2c_add_adapter(&smbus->adapter);
374 if (error)
375 goto out_release_region;
376
377 pci_set_drvdata(dev, smbus);
378
379 return 0;
380
381 out_release_region:
382 release_region(smbus->base, smbus->size);
383 out_kfree:
384 kfree(smbus);
385 return error;
386}
387
388static void __devexit pasemi_smb_remove(struct pci_dev *dev)
389{
390 struct pasemi_smbus *smbus = pci_get_drvdata(dev);
391
392 i2c_del_adapter(&smbus->adapter);
393 release_region(smbus->base, smbus->size);
394 kfree(smbus);
395}
396
397static struct pci_device_id pasemi_smb_ids[] = {
398 { PCI_DEVICE(0x1959, 0xa003) },
399 { 0, }
400};
401
402MODULE_DEVICE_TABLE(pci, pasemi_smb_ids);
403
404static struct pci_driver pasemi_smb_driver = {
405 .name = "i2c-pasemi",
406 .id_table = pasemi_smb_ids,
407 .probe = pasemi_smb_probe,
408 .remove = __devexit_p(pasemi_smb_remove),
409};
410
411static int __init pasemi_smb_init(void)
412{
413 return pci_register_driver(&pasemi_smb_driver);
414}
415
416static void __exit pasemi_smb_exit(void)
417{
418 pci_unregister_driver(&pasemi_smb_driver);
419}
420
421MODULE_LICENSE("GPL");
422MODULE_AUTHOR ("Olof Johansson <olof@lixom.net>");
423MODULE_DESCRIPTION("PA Semi PWRficient SMBus driver");
424
425module_init(pasemi_smb_init);
426module_exit(pasemi_smb_exit);
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 30c7a1b38cbd..d888293c1a9c 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -23,6 +23,7 @@
23 Supports: 23 Supports:
24 Intel PIIX4, 440MX 24 Intel PIIX4, 440MX
25 Serverworks OSB4, CSB5, CSB6, HT-1000 25 Serverworks OSB4, CSB5, CSB6, HT-1000
26 ATI IXP200, IXP300, IXP400, SB600
26 SMSC Victory66 27 SMSC Victory66
27 28
28 Note: we assume there can only be one device, with one SMBus interface. 29 Note: we assume there can only be one device, with one SMBus interface.
@@ -34,7 +35,6 @@
34#include <linux/kernel.h> 35#include <linux/kernel.h>
35#include <linux/delay.h> 36#include <linux/delay.h>
36#include <linux/stddef.h> 37#include <linux/stddef.h>
37#include <linux/sched.h>
38#include <linux/ioport.h> 38#include <linux/ioport.h>
39#include <linux/i2c.h> 39#include <linux/i2c.h>
40#include <linux/init.h> 40#include <linux/init.h>
@@ -383,6 +383,7 @@ static const struct i2c_algorithm smbus_algorithm = {
383 383
384static struct i2c_adapter piix4_adapter = { 384static struct i2c_adapter piix4_adapter = {
385 .owner = THIS_MODULE, 385 .owner = THIS_MODULE,
386 .id = I2C_HW_SMBUS_PIIX4,
386 .class = I2C_CLASS_HWMON, 387 .class = I2C_CLASS_HWMON,
387 .algo = &smbus_algorithm, 388 .algo = &smbus_algorithm,
388}; 389};
@@ -396,6 +397,8 @@ static struct pci_device_id piix4_ids[] = {
396 .driver_data = 0 }, 397 .driver_data = 0 },
397 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS), 398 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS),
398 .driver_data = 0 }, 399 .driver_data = 0 },
400 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SMBUS),
401 .driver_data = 0 },
399 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4), 402 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4),
400 .driver_data = 0 }, 403 .driver_data = 0 },
401 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5), 404 { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5),
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index 648d55533d87..1425d2245c82 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -25,7 +25,6 @@
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/i2c.h> 26#include <linux/i2c.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/completion.h>
29#include <linux/device.h> 28#include <linux/device.h>
30#include <linux/platform_device.h> 29#include <linux/platform_device.h>
31#include <asm/prom.h> 30#include <asm/prom.h>
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 4ca6de209b8b..556f244aae76 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -28,7 +28,6 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/time.h> 29#include <linux/time.h>
30#include <linux/interrupt.h> 30#include <linux/interrupt.h>
31#include <linux/sched.h>
32#include <linux/delay.h> 31#include <linux/delay.h>
33#include <linux/errno.h> 32#include <linux/errno.h>
34#include <linux/err.h> 33#include <linux/err.h>
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c
index 844b4ff90893..b7fb65c30112 100644
--- a/drivers/i2c/busses/i2c-savage4.c
+++ b/drivers/i2c/busses/i2c-savage4.c
@@ -145,6 +145,7 @@ static struct i2c_algo_bit_data sav_i2c_bit_data = {
145 145
146static struct i2c_adapter savage4_i2c_adapter = { 146static struct i2c_adapter savage4_i2c_adapter = {
147 .owner = THIS_MODULE, 147 .owner = THIS_MODULE,
148 .id = I2C_HW_B_SAVAGE,
148 .name = "I2C Savage4 adapter", 149 .name = "I2C Savage4 adapter",
149 .algo_data = &sav_i2c_bit_data, 150 .algo_data = &sav_i2c_bit_data,
150}; 151};
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 38bbfd840b6b..d333babe4ad3 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -365,6 +365,7 @@ static const struct i2c_algorithm smbus_algorithm = {
365 365
366static struct i2c_adapter sis5595_adapter = { 366static struct i2c_adapter sis5595_adapter = {
367 .owner = THIS_MODULE, 367 .owner = THIS_MODULE,
368 .id = I2C_HW_SMBUS_SIS5595,
368 .class = I2C_CLASS_HWMON, 369 .class = I2C_CLASS_HWMON,
369 .algo = &smbus_algorithm, 370 .algo = &smbus_algorithm,
370}; 371};
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index dec0bafb52ab..172bacf932a6 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -457,6 +457,7 @@ static const struct i2c_algorithm smbus_algorithm = {
457 457
458static struct i2c_adapter sis630_adapter = { 458static struct i2c_adapter sis630_adapter = {
459 .owner = THIS_MODULE, 459 .owner = THIS_MODULE,
460 .id = I2C_HW_SMBUS_SIS630,
460 .class = I2C_CLASS_HWMON, 461 .class = I2C_CLASS_HWMON,
461 .algo = &smbus_algorithm, 462 .algo = &smbus_algorithm,
462}; 463};
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 7fd07fbac336..73dae449fb23 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -37,7 +37,6 @@
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/stddef.h> 39#include <linux/stddef.h>
40#include <linux/sched.h>
41#include <linux/ioport.h> 40#include <linux/ioport.h>
42#include <linux/i2c.h> 41#include <linux/i2c.h>
43#include <linux/init.h> 42#include <linux/init.h>
@@ -249,6 +248,7 @@ static const struct i2c_algorithm smbus_algorithm = {
249 248
250static struct i2c_adapter sis96x_adapter = { 249static struct i2c_adapter sis96x_adapter = {
251 .owner = THIS_MODULE, 250 .owner = THIS_MODULE,
251 .id = I2C_HW_SMBUS_SIS96X,
252 .class = I2C_CLASS_HWMON, 252 .class = I2C_CLASS_HWMON,
253 .algo = &smbus_algorithm, 253 .algo = &smbus_algorithm,
254}; 254};
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
index 15d7e00e47e6..bbcc62151f7c 100644
--- a/drivers/i2c/busses/i2c-via.c
+++ b/drivers/i2c/busses/i2c-via.c
@@ -86,6 +86,7 @@ static struct i2c_algo_bit_data bit_data = {
86 86
87static struct i2c_adapter vt586b_adapter = { 87static struct i2c_adapter vt586b_adapter = {
88 .owner = THIS_MODULE, 88 .owner = THIS_MODULE,
89 .id = I2C_HW_B_VIA,
89 .class = I2C_CLASS_HWMON, 90 .class = I2C_CLASS_HWMON,
90 .name = "VIA i2c", 91 .name = "VIA i2c",
91 .algo_data = &bit_data, 92 .algo_data = &bit_data,
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index efc6bbf0cc0a..03c5fc868548 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -4,7 +4,7 @@
4 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, 4 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>, 5 Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>,
6 Mark D. Studebaker <mdsxyz123@yahoo.com> 6 Mark D. Studebaker <mdsxyz123@yahoo.com>
7 Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> 7 Copyright (C) 2005 - 2007 Jean Delvare <khali@linux-fr.org>
8 8
9 This program is free software; you can redistribute it and/or modify 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 10 it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@
36 VT8237R 0x3227 yes 36 VT8237R 0x3227 yes
37 VT8237A 0x3337 yes 37 VT8237A 0x3337 yes
38 VT8251 0x3287 yes 38 VT8251 0x3287 yes
39 CX700 0x8324 yes
39 40
40 Note: we assume there can only be one device, with one SMBus interface. 41 Note: we assume there can only be one device, with one SMBus interface.
41*/ 42*/
@@ -306,6 +307,7 @@ static const struct i2c_algorithm smbus_algorithm = {
306 307
307static struct i2c_adapter vt596_adapter = { 308static struct i2c_adapter vt596_adapter = {
308 .owner = THIS_MODULE, 309 .owner = THIS_MODULE,
310 .id = I2C_HW_SMBUS_VIA2,
309 .class = I2C_CLASS_HWMON, 311 .class = I2C_CLASS_HWMON,
310 .algo = &smbus_algorithm, 312 .algo = &smbus_algorithm,
311}; 313};
@@ -383,6 +385,7 @@ found:
383 dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); 385 dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
384 386
385 switch (pdev->device) { 387 switch (pdev->device) {
388 case PCI_DEVICE_ID_VIA_CX700:
386 case PCI_DEVICE_ID_VIA_8251: 389 case PCI_DEVICE_ID_VIA_8251:
387 case PCI_DEVICE_ID_VIA_8237: 390 case PCI_DEVICE_ID_VIA_8237:
388 case PCI_DEVICE_ID_VIA_8237A: 391 case PCI_DEVICE_ID_VIA_8237A:
@@ -442,6 +445,8 @@ static struct pci_device_id vt596_ids[] = {
442 .driver_data = SMBBA1 }, 445 .driver_data = SMBBA1 },
443 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8251), 446 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8251),
444 .driver_data = SMBBA3 }, 447 .driver_data = SMBBA3 },
448 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700),
449 .driver_data = SMBBA3 },
445 { 0, } 450 { 0, }
446}; 451};
447 452
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c
index b0377b81744b..88a3447e11e1 100644
--- a/drivers/i2c/busses/i2c-voodoo3.c
+++ b/drivers/i2c/busses/i2c-voodoo3.c
@@ -165,6 +165,7 @@ static struct i2c_algo_bit_data voo_i2c_bit_data = {
165 165
166static struct i2c_adapter voodoo3_i2c_adapter = { 166static struct i2c_adapter voodoo3_i2c_adapter = {
167 .owner = THIS_MODULE, 167 .owner = THIS_MODULE,
168 .id = I2C_HW_B_VOO,
168 .class = I2C_CLASS_TV_ANALOG, 169 .class = I2C_CLASS_TV_ANALOG,
169 .name = "I2C Voodoo3/Banshee adapter", 170 .name = "I2C Voodoo3/Banshee adapter",
170 .algo_data = &voo_i2c_bit_data, 171 .algo_data = &voo_i2c_bit_data,
@@ -181,6 +182,7 @@ static struct i2c_algo_bit_data voo_ddc_bit_data = {
181 182
182static struct i2c_adapter voodoo3_ddc_adapter = { 183static struct i2c_adapter voodoo3_ddc_adapter = {
183 .owner = THIS_MODULE, 184 .owner = THIS_MODULE,
185 .id = I2C_HW_B_VOO,
184 .class = I2C_CLASS_DDC, 186 .class = I2C_CLASS_DDC,
185 .name = "DDC Voodoo3/Banshee adapter", 187 .name = "DDC Voodoo3/Banshee adapter",
186 .algo_data = &voo_ddc_bit_data, 188 .algo_data = &voo_ddc_bit_data,
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 714bae780953..0b082c5a0195 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -428,7 +428,7 @@ static __init int scx200_acb_probe(struct scx200_acb_iface *iface)
428} 428}
429 429
430static __init struct scx200_acb_iface *scx200_create_iface(const char *text, 430static __init struct scx200_acb_iface *scx200_create_iface(const char *text,
431 int index) 431 struct device *dev, int index)
432{ 432{
433 struct scx200_acb_iface *iface; 433 struct scx200_acb_iface *iface;
434 struct i2c_adapter *adapter; 434 struct i2c_adapter *adapter;
@@ -446,6 +446,7 @@ static __init struct scx200_acb_iface *scx200_create_iface(const char *text,
446 adapter->id = I2C_HW_SMBUS_SCX200; 446 adapter->id = I2C_HW_SMBUS_SCX200;
447 adapter->algo = &scx200_acb_algorithm; 447 adapter->algo = &scx200_acb_algorithm;
448 adapter->class = I2C_CLASS_HWMON; 448 adapter->class = I2C_CLASS_HWMON;
449 adapter->dev.parent = dev;
449 450
450 mutex_init(&iface->mutex); 451 mutex_init(&iface->mutex);
451 452
@@ -486,7 +487,7 @@ static __init int scx200_create_pci(const char *text, struct pci_dev *pdev,
486 struct scx200_acb_iface *iface; 487 struct scx200_acb_iface *iface;
487 int rc; 488 int rc;
488 489
489 iface = scx200_create_iface(text, 0); 490 iface = scx200_create_iface(text, &pdev->dev, 0);
490 491
491 if (iface == NULL) 492 if (iface == NULL)
492 return -ENOMEM; 493 return -ENOMEM;
@@ -524,7 +525,7 @@ static int __init scx200_create_isa(const char *text, unsigned long base,
524 struct scx200_acb_iface *iface; 525 struct scx200_acb_iface *iface;
525 int rc; 526 int rc;
526 527
527 iface = scx200_create_iface(text, index); 528 iface = scx200_create_iface(text, NULL, index);
528 529
529 if (iface == NULL) 530 if (iface == NULL)
530 return -ENOMEM; 531 return -ENOMEM;
diff --git a/drivers/i2c/busses/scx200_i2c.c b/drivers/i2c/busses/scx200_i2c.c
index 6cd96e43aa72..c3022a023449 100644
--- a/drivers/i2c/busses/scx200_i2c.c
+++ b/drivers/i2c/busses/scx200_i2c.c
@@ -81,6 +81,7 @@ static struct i2c_algo_bit_data scx200_i2c_data = {
81 81
82static struct i2c_adapter scx200_i2c_ops = { 82static struct i2c_adapter scx200_i2c_ops = {
83 .owner = THIS_MODULE, 83 .owner = THIS_MODULE,
84 .id = I2C_HW_B_SCX200,
84 .algo_data = &scx200_i2c_data, 85 .algo_data = &scx200_i2c_data,
85 .name = "NatSemi SCx200 I2C", 86 .name = "NatSemi SCx200 I2C",
86}; 87};
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index cec3a0c3894d..bfce13c8f1ff 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -30,7 +30,6 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/sched.h>
34#include <linux/jiffies.h> 33#include <linux/jiffies.h>
35#include <linux/i2c.h> 34#include <linux/i2c.h>
36#include <linux/mutex.h> 35#include <linux/mutex.h>
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b05378a3d673..21fe1406c8b4 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -32,6 +32,7 @@
32#include <linux/seq_file.h> 32#include <linux/seq_file.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/completion.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
36 37
37 38
@@ -40,49 +41,72 @@ static LIST_HEAD(drivers);
40static DEFINE_MUTEX(core_lists); 41static DEFINE_MUTEX(core_lists);
41static DEFINE_IDR(i2c_adapter_idr); 42static DEFINE_IDR(i2c_adapter_idr);
42 43
44
45/* ------------------------------------------------------------------------- */
46
43/* match always succeeds, as we want the probe() to tell if we really accept this match */ 47/* match always succeeds, as we want the probe() to tell if we really accept this match */
44static int i2c_device_match(struct device *dev, struct device_driver *drv) 48static int i2c_device_match(struct device *dev, struct device_driver *drv)
45{ 49{
46 return 1; 50 return 1;
47} 51}
48 52
49static int i2c_bus_suspend(struct device * dev, pm_message_t state) 53static int i2c_device_probe(struct device *dev)
50{ 54{
51 int rc = 0; 55 return -ENODEV;
56}
52 57
53 if (dev->driver && dev->driver->suspend) 58static int i2c_device_remove(struct device *dev)
54 rc = dev->driver->suspend(dev, state); 59{
55 return rc; 60 return 0;
56} 61}
57 62
58static int i2c_bus_resume(struct device * dev) 63static void i2c_device_shutdown(struct device *dev)
59{ 64{
60 int rc = 0; 65 struct i2c_driver *driver;
61 66
62 if (dev->driver && dev->driver->resume) 67 if (!dev->driver)
63 rc = dev->driver->resume(dev); 68 return;
64 return rc; 69 driver = to_i2c_driver(dev->driver);
70 if (driver->shutdown)
71 driver->shutdown(to_i2c_client(dev));
65} 72}
66 73
67static int i2c_device_probe(struct device *dev) 74static int i2c_device_suspend(struct device * dev, pm_message_t mesg)
68{ 75{
69 return -ENODEV; 76 struct i2c_driver *driver;
77
78 if (!dev->driver)
79 return 0;
80 driver = to_i2c_driver(dev->driver);
81 if (!driver->suspend)
82 return 0;
83 return driver->suspend(to_i2c_client(dev), mesg);
70} 84}
71 85
72static int i2c_device_remove(struct device *dev) 86static int i2c_device_resume(struct device * dev)
73{ 87{
74 return 0; 88 struct i2c_driver *driver;
89
90 if (!dev->driver)
91 return 0;
92 driver = to_i2c_driver(dev->driver);
93 if (!driver->resume)
94 return 0;
95 return driver->resume(to_i2c_client(dev));
75} 96}
76 97
77struct bus_type i2c_bus_type = { 98struct bus_type i2c_bus_type = {
78 .name = "i2c", 99 .name = "i2c",
79 .match = i2c_device_match, 100 .match = i2c_device_match,
80 .probe = i2c_device_probe, 101 .probe = i2c_device_probe,
81 .remove = i2c_device_remove, 102 .remove = i2c_device_remove,
82 .suspend = i2c_bus_suspend, 103 .shutdown = i2c_device_shutdown,
83 .resume = i2c_bus_resume, 104 .suspend = i2c_device_suspend,
105 .resume = i2c_device_resume,
84}; 106};
85 107
108/* ------------------------------------------------------------------------- */
109
86void i2c_adapter_dev_release(struct device *dev) 110void i2c_adapter_dev_release(struct device *dev)
87{ 111{
88 struct i2c_adapter *adap = dev_to_i2c_adapter(dev); 112 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
@@ -193,9 +217,8 @@ int i2c_add_adapter(struct i2c_adapter *adap)
193 */ 217 */
194 if (adap->dev.parent == NULL) { 218 if (adap->dev.parent == NULL) {
195 adap->dev.parent = &platform_bus; 219 adap->dev.parent = &platform_bus;
196 printk(KERN_WARNING "**WARNING** I2C adapter driver [%s] " 220 pr_debug("I2C adapter driver [%s] forgot to specify "
197 "forgot to specify physical device; fix it!\n", 221 "physical device\n", adap->name);
198 adap->name);
199 } 222 }
200 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); 223 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr);
201 adap->dev.driver = &i2c_adapter_driver; 224 adap->dev.driver = &i2c_adapter_driver;