aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-amd756.c2
-rw-r--r--drivers/i2c/busses/i2c-au1550.c2
-rw-r--r--drivers/i2c/busses/i2c-mpc.c16
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c28
-rw-r--r--drivers/i2c/busses/i2c-piix4.c47
-rw-r--r--drivers/i2c/busses/i2c-sibyte.c6
-rw-r--r--drivers/i2c/chips/max6875.c3
-rw-r--r--drivers/i2c/i2c-core.c36
8 files changed, 91 insertions, 49 deletions
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 2fa43183d37..43508d61eb7 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -290,7 +290,7 @@ static u32 amd756_func(struct i2c_adapter *adapter)
290{ 290{
291 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 291 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
292 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | 292 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
293 I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL; 293 I2C_FUNC_SMBUS_BLOCK_DATA;
294} 294}
295 295
296static const struct i2c_algorithm smbus_algorithm = { 296static const struct i2c_algorithm smbus_algorithm = {
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index 491718fe46b..cae9dc89d88 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -335,7 +335,7 @@ i2c_au1550_probe(struct platform_device *pdev)
335 goto out_mem; 335 goto out_mem;
336 } 336 }
337 337
338 priv->psc_base = r->start; 338 priv->psc_base = CKSEG1ADDR(r->start);
339 priv->xfer_timeout = 200; 339 priv->xfer_timeout = 200;
340 priv->ack_timeout = 200; 340 priv->ack_timeout = 200;
341 341
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 18beb0ad7bf..a076129de7e 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -99,7 +99,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
99 u32 x; 99 u32 x;
100 int result = 0; 100 int result = 0;
101 101
102 if (i2c->irq == 0) 102 if (i2c->irq == NO_IRQ)
103 { 103 {
104 while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) { 104 while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
105 schedule(); 105 schedule();
@@ -329,10 +329,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
329 return -ENOMEM; 329 return -ENOMEM;
330 330
331 i2c->irq = platform_get_irq(pdev, 0); 331 i2c->irq = platform_get_irq(pdev, 0);
332 if (i2c->irq < 0) { 332 if (i2c->irq < 0)
333 result = -ENXIO; 333 i2c->irq = NO_IRQ; /* Use polling */
334 goto fail_get_irq; 334
335 }
336 i2c->flags = pdata->device_flags; 335 i2c->flags = pdata->device_flags;
337 init_waitqueue_head(&i2c->queue); 336 init_waitqueue_head(&i2c->queue);
338 337
@@ -344,7 +343,7 @@ static int fsl_i2c_probe(struct platform_device *pdev)
344 goto fail_map; 343 goto fail_map;
345 } 344 }
346 345
347 if (i2c->irq != 0) 346 if (i2c->irq != NO_IRQ)
348 if ((result = request_irq(i2c->irq, mpc_i2c_isr, 347 if ((result = request_irq(i2c->irq, mpc_i2c_isr,
349 IRQF_SHARED, "i2c-mpc", i2c)) < 0) { 348 IRQF_SHARED, "i2c-mpc", i2c)) < 0) {
350 printk(KERN_ERR 349 printk(KERN_ERR
@@ -367,12 +366,11 @@ static int fsl_i2c_probe(struct platform_device *pdev)
367 return result; 366 return result;
368 367
369 fail_add: 368 fail_add:
370 if (i2c->irq != 0) 369 if (i2c->irq != NO_IRQ)
371 free_irq(i2c->irq, i2c); 370 free_irq(i2c->irq, i2c);
372 fail_irq: 371 fail_irq:
373 iounmap(i2c->base); 372 iounmap(i2c->base);
374 fail_map: 373 fail_map:
375 fail_get_irq:
376 kfree(i2c); 374 kfree(i2c);
377 return result; 375 return result;
378}; 376};
@@ -384,7 +382,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
384 i2c_del_adapter(&i2c->adap); 382 i2c_del_adapter(&i2c->adap);
385 platform_set_drvdata(pdev, NULL); 383 platform_set_drvdata(pdev, NULL);
386 384
387 if (i2c->irq != 0) 385 if (i2c->irq != NO_IRQ)
388 free_irq(i2c->irq, i2c); 386 free_irq(i2c->irq, i2c);
389 387
390 iounmap(i2c->base); 388 iounmap(i2c->base);
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 3dac920e53e..43c9f8df950 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -50,6 +50,7 @@
50#include <linux/init.h> 50#include <linux/init.h>
51#include <linux/i2c.h> 51#include <linux/i2c.h>
52#include <linux/delay.h> 52#include <linux/delay.h>
53#include <linux/dmi.h>
53#include <asm/io.h> 54#include <asm/io.h>
54 55
55MODULE_LICENSE("GPL"); 56MODULE_LICENSE("GPL");
@@ -109,6 +110,18 @@ struct nforce2_smbus {
109/* Misc definitions */ 110/* Misc definitions */
110#define MAX_TIMEOUT 100 111#define MAX_TIMEOUT 100
111 112
113/* We disable the second SMBus channel on these boards */
114static struct dmi_system_id __devinitdata nforce2_dmi_blacklist2[] = {
115 {
116 .ident = "DFI Lanparty NF4 Expert",
117 .matches = {
118 DMI_MATCH(DMI_BOARD_VENDOR, "DFI Corp,LTD"),
119 DMI_MATCH(DMI_BOARD_NAME, "LP UT NF4 Expert"),
120 },
121 },
122 { }
123};
124
112static struct pci_driver nforce2_driver; 125static struct pci_driver nforce2_driver;
113 126
114static void nforce2_abort(struct i2c_adapter *adap) 127static void nforce2_abort(struct i2c_adapter *adap)
@@ -367,10 +380,17 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_
367 smbuses[0].base = 0; /* to have a check value */ 380 smbuses[0].base = 0; /* to have a check value */
368 } 381 }
369 /* SMBus adapter 2 */ 382 /* SMBus adapter 2 */
370 res2 = nforce2_probe_smb(dev, 5, NFORCE_PCI_SMB2, &smbuses[1], "SMB2"); 383 if (dmi_check_system(nforce2_dmi_blacklist2)) {
371 if (res2 < 0) { 384 dev_err(&dev->dev, "Disabling SMB2 for safety reasons.\n");
372 dev_err(&dev->dev, "Error probing SMB2.\n"); 385 res2 = -EPERM;
373 smbuses[1].base = 0; /* to have a check value */ 386 smbuses[1].base = 0;
387 } else {
388 res2 = nforce2_probe_smb(dev, 5, NFORCE_PCI_SMB2, &smbuses[1],
389 "SMB2");
390 if (res2 < 0) {
391 dev_err(&dev->dev, "Error probing SMB2.\n");
392 smbuses[1].base = 0; /* to have a check value */
393 }
374 } 394 }
375 if ((res1 < 0) && (res2 < 0)) { 395 if ((res1 < 0) && (res2 < 0)) {
376 /* we did not find even one of the SMBuses, so we give up */ 396 /* we did not find even one of the SMBuses, so we give up */
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index fdc9ad805e3..ac916596858 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -104,10 +104,31 @@ MODULE_PARM_DESC(force_addr,
104static int piix4_transaction(void); 104static int piix4_transaction(void);
105 105
106static unsigned short piix4_smba; 106static unsigned short piix4_smba;
107static int srvrworks_csb5_delay;
107static struct pci_driver piix4_driver; 108static struct pci_driver piix4_driver;
108static struct i2c_adapter piix4_adapter; 109static struct i2c_adapter piix4_adapter;
109 110
110static struct dmi_system_id __devinitdata piix4_dmi_table[] = { 111static struct dmi_system_id __devinitdata piix4_dmi_blacklist[] = {
112 {
113 .ident = "Sapphire AM2RD790",
114 .matches = {
115 DMI_MATCH(DMI_BOARD_VENDOR, "SAPPHIRE Inc."),
116 DMI_MATCH(DMI_BOARD_NAME, "PC-AM2RD790"),
117 },
118 },
119 {
120 .ident = "DFI Lanparty UT 790FX",
121 .matches = {
122 DMI_MATCH(DMI_BOARD_VENDOR, "DFI Inc."),
123 DMI_MATCH(DMI_BOARD_NAME, "LP UT 790FX"),
124 },
125 },
126 { }
127};
128
129/* The IBM entry is in a separate table because we only check it
130 on Intel-based systems */
131static struct dmi_system_id __devinitdata piix4_dmi_ibm[] = {
111 { 132 {
112 .ident = "IBM", 133 .ident = "IBM",
113 .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), }, 134 .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), },
@@ -122,8 +143,20 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
122 143
123 dev_info(&PIIX4_dev->dev, "Found %s device\n", pci_name(PIIX4_dev)); 144 dev_info(&PIIX4_dev->dev, "Found %s device\n", pci_name(PIIX4_dev));
124 145
146 if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) &&
147 (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5))
148 srvrworks_csb5_delay = 1;
149
150 /* On some motherboards, it was reported that accessing the SMBus
151 caused severe hardware problems */
152 if (dmi_check_system(piix4_dmi_blacklist)) {
153 dev_err(&PIIX4_dev->dev,
154 "Accessing the SMBus on this system is unsafe!\n");
155 return -EPERM;
156 }
157
125 /* Don't access SMBus on IBM systems which get corrupted eeproms */ 158 /* Don't access SMBus on IBM systems which get corrupted eeproms */
126 if (dmi_check_system(piix4_dmi_table) && 159 if (dmi_check_system(piix4_dmi_ibm) &&
127 PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) { 160 PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) {
128 dev_err(&PIIX4_dev->dev, "IBM system detected; this module " 161 dev_err(&PIIX4_dev->dev, "IBM system detected; this module "
129 "may corrupt your serial eeprom! Refusing to load " 162 "may corrupt your serial eeprom! Refusing to load "
@@ -230,10 +263,14 @@ static int piix4_transaction(void)
230 outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); 263 outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT);
231 264
232 /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */ 265 /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */
233 do { 266 if (srvrworks_csb5_delay) /* Extra delay for SERVERWORKS_CSB5 */
267 msleep(2);
268 else
269 msleep(1);
270
271 while ((timeout++ < MAX_TIMEOUT) &&
272 ((temp = inb_p(SMBHSTSTS)) & 0x01))
234 msleep(1); 273 msleep(1);
235 temp = inb_p(SMBHSTSTS);
236 } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
237 274
238 /* If the SMBus is still busy, we give up */ 275 /* If the SMBus is still busy, we give up */
239 if (timeout >= MAX_TIMEOUT) { 276 if (timeout >= MAX_TIMEOUT) {
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
index 8fbbdb4c2f3..114634da6c6 100644
--- a/drivers/i2c/busses/i2c-sibyte.c
+++ b/drivers/i2c/busses/i2c-sibyte.c
@@ -132,14 +132,14 @@ static const struct i2c_algorithm i2c_sibyte_algo = {
132/* 132/*
133 * registering functions to load algorithms at runtime 133 * registering functions to load algorithms at runtime
134 */ 134 */
135int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed) 135static int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
136{ 136{
137 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data; 137 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
138 138
139 /* register new adapter to i2c module... */ 139 /* Register new adapter to i2c module... */
140 i2c_adap->algo = &i2c_sibyte_algo; 140 i2c_adap->algo = &i2c_sibyte_algo;
141 141
142 /* Set the frequency to 100 kHz */ 142 /* Set the requested frequency. */
143 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ)); 143 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ));
144 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL)); 144 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL));
145 145
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index fb7ea5637ec..cf507b3f60f 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -207,9 +207,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
207 fake_client->flags = 0; 207 fake_client->flags = 0;
208 strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE); 208 strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE);
209 209
210 /* Prevent 24RF08 corruption (in case of user error) */
211 i2c_smbus_write_quick(real_client, 0);
212
213 if ((err = i2c_attach_client(real_client)) != 0) 210 if ((err = i2c_attach_client(real_client)) != 0)
214 goto exit_kfree2; 211 goto exit_kfree2;
215 212
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 26384daccb9..d0175f4f8fc 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -74,10 +74,7 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)
74 if (driver->id_table) 74 if (driver->id_table)
75 return i2c_match_id(driver->id_table, client) != NULL; 75 return i2c_match_id(driver->id_table, client) != NULL;
76 76
77 /* new style drivers use the same kind of driver matching policy 77 return 0;
78 * as platform devices or SPI: compare device and driver IDs.
79 */
80 return strcmp(client->driver_name, drv->name) == 0;
81} 78}
82 79
83#ifdef CONFIG_HOTPLUG 80#ifdef CONFIG_HOTPLUG
@@ -91,14 +88,9 @@ static int i2c_device_uevent(struct device *dev, struct kobj_uevent_env *env)
91 if (dev->driver) 88 if (dev->driver)
92 return 0; 89 return 0;
93 90
94 if (client->driver_name[0]) { 91 if (add_uevent_var(env, "MODALIAS=%s%s",
95 if (add_uevent_var(env, "MODALIAS=%s", client->driver_name)) 92 I2C_MODULE_PREFIX, client->name))
96 return -ENOMEM; 93 return -ENOMEM;
97 } else {
98 if (add_uevent_var(env, "MODALIAS=%s%s",
99 I2C_MODULE_PREFIX, client->name))
100 return -ENOMEM;
101 }
102 dev_dbg(dev, "uevent\n"); 94 dev_dbg(dev, "uevent\n");
103 return 0; 95 return 0;
104} 96}
@@ -206,9 +198,7 @@ static ssize_t show_client_name(struct device *dev, struct device_attribute *att
206static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf) 198static ssize_t show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
207{ 199{
208 struct i2c_client *client = to_i2c_client(dev); 200 struct i2c_client *client = to_i2c_client(dev);
209 return client->driver_name[0] 201 return sprintf(buf, "%s%s\n", I2C_MODULE_PREFIX, client->name);
210 ? sprintf(buf, "%s\n", client->driver_name)
211 : sprintf(buf, "%s%s\n", I2C_MODULE_PREFIX, client->name);
212} 202}
213 203
214static struct device_attribute i2c_dev_attrs[] = { 204static struct device_attribute i2c_dev_attrs[] = {
@@ -282,8 +272,6 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
282 client->addr = info->addr; 272 client->addr = info->addr;
283 client->irq = info->irq; 273 client->irq = info->irq;
284 274
285 strlcpy(client->driver_name, info->driver_name,
286 sizeof(client->driver_name));
287 strlcpy(client->name, info->type, sizeof(client->name)); 275 strlcpy(client->name, info->type, sizeof(client->name));
288 276
289 /* a new style driver may be bound to this device when we 277 /* a new style driver may be bound to this device when we
@@ -327,6 +315,11 @@ void i2c_unregister_device(struct i2c_client *client)
327EXPORT_SYMBOL_GPL(i2c_unregister_device); 315EXPORT_SYMBOL_GPL(i2c_unregister_device);
328 316
329 317
318static const struct i2c_device_id dummy_id[] = {
319 { "dummy", 0 },
320 { },
321};
322
330static int dummy_probe(struct i2c_client *client, 323static int dummy_probe(struct i2c_client *client,
331 const struct i2c_device_id *id) 324 const struct i2c_device_id *id)
332{ 325{
@@ -342,13 +335,13 @@ static struct i2c_driver dummy_driver = {
342 .driver.name = "dummy", 335 .driver.name = "dummy",
343 .probe = dummy_probe, 336 .probe = dummy_probe,
344 .remove = dummy_remove, 337 .remove = dummy_remove,
338 .id_table = dummy_id,
345}; 339};
346 340
347/** 341/**
348 * i2c_new_dummy - return a new i2c device bound to a dummy driver 342 * i2c_new_dummy - return a new i2c device bound to a dummy driver
349 * @adapter: the adapter managing the device 343 * @adapter: the adapter managing the device
350 * @address: seven bit address to be used 344 * @address: seven bit address to be used
351 * @type: optional label used for i2c_client.name
352 * Context: can sleep 345 * Context: can sleep
353 * 346 *
354 * This returns an I2C client bound to the "dummy" driver, intended for use 347 * This returns an I2C client bound to the "dummy" driver, intended for use
@@ -364,15 +357,12 @@ static struct i2c_driver dummy_driver = {
364 * i2c_unregister_device(); or NULL to indicate an error. 357 * i2c_unregister_device(); or NULL to indicate an error.
365 */ 358 */
366struct i2c_client * 359struct i2c_client *
367i2c_new_dummy(struct i2c_adapter *adapter, u16 address, const char *type) 360i2c_new_dummy(struct i2c_adapter *adapter, u16 address)
368{ 361{
369 struct i2c_board_info info = { 362 struct i2c_board_info info = {
370 .driver_name = "dummy", 363 I2C_BOARD_INFO("dummy", address),
371 .addr = address,
372 }; 364 };
373 365
374 if (type)
375 strlcpy(info.type, type, sizeof info.type);
376 return i2c_new_device(adapter, &info); 366 return i2c_new_device(adapter, &info);
377} 367}
378EXPORT_SYMBOL_GPL(i2c_new_dummy); 368EXPORT_SYMBOL_GPL(i2c_new_dummy);