diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-i801.c | 6 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-mpc.c | 188 | ||||
-rw-r--r-- | drivers/i2c/chips/ds1337.c | 6 | ||||
-rw-r--r-- | drivers/i2c/chips/eeprom.c | 8 | ||||
-rw-r--r-- | drivers/i2c/chips/max6875.c | 8 | ||||
-rw-r--r-- | drivers/i2c/i2c-core.c | 8 |
6 files changed, 208 insertions, 16 deletions
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 0ab7e37f5b00..1ab41313ce51 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -137,7 +137,7 @@ static int i801_setup(struct pci_dev *dev) | |||
137 | pci_read_config_word(I801_dev, SMBBA, &i801_smba); | 137 | pci_read_config_word(I801_dev, SMBBA, &i801_smba); |
138 | i801_smba &= 0xfff0; | 138 | i801_smba &= 0xfff0; |
139 | if(i801_smba == 0) { | 139 | if(i801_smba == 0) { |
140 | dev_err(&dev->dev, "SMB base address uninitialized" | 140 | dev_err(&dev->dev, "SMB base address uninitialized " |
141 | "- upgrade BIOS or use force_addr=0xaddr\n"); | 141 | "- upgrade BIOS or use force_addr=0xaddr\n"); |
142 | return -ENODEV; | 142 | return -ENODEV; |
143 | } | 143 | } |
@@ -186,7 +186,7 @@ static int i801_transaction(void) | |||
186 | int result = 0; | 186 | int result = 0; |
187 | int timeout = 0; | 187 | int timeout = 0; |
188 | 188 | ||
189 | dev_dbg(&I801_dev->dev, "Transaction (pre): CNT=%02x, CMD=%02x," | 189 | dev_dbg(&I801_dev->dev, "Transaction (pre): CNT=%02x, CMD=%02x, " |
190 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), | 190 | "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), |
191 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), | 191 | inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), |
192 | inb_p(SMBHSTDAT1)); | 192 | inb_p(SMBHSTDAT1)); |
@@ -240,7 +240,7 @@ static int i801_transaction(void) | |||
240 | outb_p(inb(SMBHSTSTS), SMBHSTSTS); | 240 | outb_p(inb(SMBHSTSTS), SMBHSTSTS); |
241 | 241 | ||
242 | if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { | 242 | if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { |
243 | dev_dbg(&I801_dev->dev, "Failed reset at end of transaction" | 243 | dev_dbg(&I801_dev->dev, "Failed reset at end of transaction " |
244 | "(%02x)\n", temp); | 244 | "(%02x)\n", temp); |
245 | } | 245 | } |
246 | dev_dbg(&I801_dev->dev, "Transaction (post): CNT=%02x, CMD=%02x, " | 246 | dev_dbg(&I801_dev->dev, "Transaction (post): CNT=%02x, CMD=%02x, " |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 03c23ce98edb..04adde62a003 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
@@ -288,6 +288,194 @@ static struct i2c_adapter mpc_ops = { | |||
288 | .retries = 1 | 288 | .retries = 1 |
289 | }; | 289 | }; |
290 | 290 | ||
291 | static int fsl_i2c_probe(struct device *device) | ||
292 | { | ||
293 | int result = 0; | ||
294 | struct mpc_i2c *i2c; | ||
295 | struct platform_device *pdev = to_platform_device(device); | ||
296 | struct fsl_i2c_platform_data *pdata; | ||
297 | struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
298 | |||
299 | pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; | ||
300 | |||
301 | if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { | ||
302 | return -ENOMEM; | ||
303 | } | ||
304 | memset(i2c, 0, sizeof(*i2c)); | ||
305 | |||
306 | i2c->irq = platform_get_irq(pdev, 0); | ||
307 | i2c->flags = pdata->device_flags; | ||
308 | init_waitqueue_head(&i2c->queue); | ||
309 | |||
310 | i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION); | ||
311 | |||
312 | if (!i2c->base) { | ||
313 | printk(KERN_ERR "i2c-mpc - failed to map controller\n"); | ||
314 | result = -ENOMEM; | ||
315 | goto fail_map; | ||
316 | } | ||
317 | |||
318 | if (i2c->irq != 0) | ||
319 | if ((result = request_irq(i2c->irq, mpc_i2c_isr, | ||
320 | SA_SHIRQ, "i2c-mpc", i2c)) < 0) { | ||
321 | printk(KERN_ERR | ||
322 | "i2c-mpc - failed to attach interrupt\n"); | ||
323 | goto fail_irq; | ||
324 | } | ||
325 | |||
326 | mpc_i2c_setclock(i2c); | ||
327 | dev_set_drvdata(device, i2c); | ||
328 | |||
329 | i2c->adap = mpc_ops; | ||
330 | i2c_set_adapdata(&i2c->adap, i2c); | ||
331 | i2c->adap.dev.parent = &pdev->dev; | ||
332 | if ((result = i2c_add_adapter(&i2c->adap)) < 0) { | ||
333 | printk(KERN_ERR "i2c-mpc - failed to add adapter\n"); | ||
334 | goto fail_add; | ||
335 | } | ||
336 | |||
337 | return result; | ||
338 | |||
339 | fail_add: | ||
340 | if (i2c->irq != 0) | ||
341 | free_irq(i2c->irq, NULL); | ||
342 | fail_irq: | ||
343 | iounmap(i2c->base); | ||
344 | fail_map: | ||
345 | kfree(i2c); | ||
346 | return result; | ||
347 | }; | ||
348 | |||
349 | static int fsl_i2c_remove(struct device *device) | ||
350 | { | ||
351 | struct mpc_i2c *i2c = dev_get_drvdata(device); | ||
352 | |||
353 | i2c_del_adapter(&i2c->adap); | ||
354 | dev_set_drvdata(device, NULL); | ||
355 | |||
356 | if (i2c->irq != 0) | ||
357 | free_irq(i2c->irq, i2c); | ||
358 | |||
359 | iounmap(i2c->base); | ||
360 | kfree(i2c); | ||
361 | return 0; | ||
362 | }; | ||
363 | |||
364 | /* Structure for a device driver */ | ||
365 | static struct device_driver fsl_i2c_driver = { | ||
366 | .name = "fsl-i2c", | ||
367 | .bus = &platform_bus_type, | ||
368 | .probe = fsl_i2c_probe, | ||
369 | .remove = fsl_i2c_remove, | ||
370 | }; | ||
371 | |||
372 | static int __init fsl_i2c_init(void) | ||
373 | { | ||
374 | return driver_register(&fsl_i2c_driver); | ||
375 | } | ||
376 | |||
377 | static void __exit fsl_i2c_exit(void) | ||
378 | { | ||
379 | driver_unregister(&fsl_i2c_driver); | ||
380 | } | ||
381 | |||
382 | module_init(fsl_i2c_init); | ||
383 | module_exit(fsl_i2c_exit); | ||
384 | |||
385 | static int fsl_i2c_probe(struct device *device) | ||
386 | { | ||
387 | int result = 0; | ||
388 | struct mpc_i2c *i2c; | ||
389 | struct platform_device *pdev = to_platform_device(device); | ||
390 | struct fsl_i2c_platform_data *pdata; | ||
391 | struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
392 | |||
393 | pdata = (struct fsl_i2c_platform_data *) pdev->dev.platform_data; | ||
394 | |||
395 | if (!(i2c = kmalloc(sizeof(*i2c), GFP_KERNEL))) { | ||
396 | return -ENOMEM; | ||
397 | } | ||
398 | memset(i2c, 0, sizeof(*i2c)); | ||
399 | |||
400 | i2c->irq = platform_get_irq(pdev, 0); | ||
401 | i2c->flags = pdata->device_flags; | ||
402 | init_waitqueue_head(&i2c->queue); | ||
403 | |||
404 | i2c->base = ioremap((phys_addr_t)r->start, MPC_I2C_REGION); | ||
405 | |||
406 | if (!i2c->base) { | ||
407 | printk(KERN_ERR "i2c-mpc - failed to map controller\n"); | ||
408 | result = -ENOMEM; | ||
409 | goto fail_map; | ||
410 | } | ||
411 | |||
412 | if (i2c->irq != 0) | ||
413 | if ((result = request_irq(i2c->irq, mpc_i2c_isr, | ||
414 | SA_SHIRQ, "i2c-mpc", i2c)) < 0) { | ||
415 | printk(KERN_ERR | ||
416 | "i2c-mpc - failed to attach interrupt\n"); | ||
417 | goto fail_irq; | ||
418 | } | ||
419 | |||
420 | mpc_i2c_setclock(i2c); | ||
421 | dev_set_drvdata(device, i2c); | ||
422 | |||
423 | i2c->adap = mpc_ops; | ||
424 | i2c_set_adapdata(&i2c->adap, i2c); | ||
425 | i2c->adap.dev.parent = &pdev->dev; | ||
426 | if ((result = i2c_add_adapter(&i2c->adap)) < 0) { | ||
427 | printk(KERN_ERR "i2c-mpc - failed to add adapter\n"); | ||
428 | goto fail_add; | ||
429 | } | ||
430 | |||
431 | return result; | ||
432 | |||
433 | fail_add: | ||
434 | if (i2c->irq != 0) | ||
435 | free_irq(i2c->irq, NULL); | ||
436 | fail_irq: | ||
437 | iounmap(i2c->base); | ||
438 | fail_map: | ||
439 | kfree(i2c); | ||
440 | return result; | ||
441 | }; | ||
442 | |||
443 | static int fsl_i2c_remove(struct device *device) | ||
444 | { | ||
445 | struct mpc_i2c *i2c = dev_get_drvdata(device); | ||
446 | |||
447 | i2c_del_adapter(&i2c->adap); | ||
448 | dev_set_drvdata(device, NULL); | ||
449 | |||
450 | if (i2c->irq != 0) | ||
451 | free_irq(i2c->irq, i2c); | ||
452 | |||
453 | iounmap(i2c->base); | ||
454 | kfree(i2c); | ||
455 | return 0; | ||
456 | }; | ||
457 | |||
458 | /* Structure for a device driver */ | ||
459 | static struct device_driver fsl_i2c_driver = { | ||
460 | .name = "fsl-i2c", | ||
461 | .bus = &platform_bus_type, | ||
462 | .probe = fsl_i2c_probe, | ||
463 | .remove = fsl_i2c_remove, | ||
464 | }; | ||
465 | |||
466 | static int __init fsl_i2c_init(void) | ||
467 | { | ||
468 | return driver_register(&fsl_i2c_driver); | ||
469 | } | ||
470 | |||
471 | static void __exit fsl_i2c_exit(void) | ||
472 | { | ||
473 | driver_unregister(&fsl_i2c_driver); | ||
474 | } | ||
475 | |||
476 | module_init(fsl_i2c_init); | ||
477 | module_exit(fsl_i2c_exit); | ||
478 | |||
291 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); | 479 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); |
292 | MODULE_DESCRIPTION | 480 | MODULE_DESCRIPTION |
293 | ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); | 481 | ("I2C-Bus adapter for MPC107 bridge and MPC824x/85xx/52xx processors"); |
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 74ece8ac1c23..82cf959989fd 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c | |||
@@ -165,7 +165,7 @@ static int ds1337_set_datetime(struct i2c_client *client, struct rtc_time *dt) | |||
165 | buf[0] = 0; /* reg offset */ | 165 | buf[0] = 0; /* reg offset */ |
166 | buf[1] = BIN2BCD(dt->tm_sec); | 166 | buf[1] = BIN2BCD(dt->tm_sec); |
167 | buf[2] = BIN2BCD(dt->tm_min); | 167 | buf[2] = BIN2BCD(dt->tm_min); |
168 | buf[3] = BIN2BCD(dt->tm_hour) | (1 << 6); | 168 | buf[3] = BIN2BCD(dt->tm_hour); |
169 | buf[4] = BIN2BCD(dt->tm_wday) + 1; | 169 | buf[4] = BIN2BCD(dt->tm_wday) + 1; |
170 | buf[5] = BIN2BCD(dt->tm_mday); | 170 | buf[5] = BIN2BCD(dt->tm_mday); |
171 | buf[6] = BIN2BCD(dt->tm_mon) + 1; | 171 | buf[6] = BIN2BCD(dt->tm_mon) + 1; |
@@ -344,9 +344,9 @@ static void ds1337_init_client(struct i2c_client *client) | |||
344 | 344 | ||
345 | /* Ensure that device is set in 24-hour mode */ | 345 | /* Ensure that device is set in 24-hour mode */ |
346 | val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR); | 346 | val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR); |
347 | if ((val >= 0) && (val & (1 << 6)) == 0) | 347 | if ((val >= 0) && (val & (1 << 6))) |
348 | i2c_smbus_write_byte_data(client, DS1337_REG_HOUR, | 348 | i2c_smbus_write_byte_data(client, DS1337_REG_HOUR, |
349 | val | (1 << 6)); | 349 | val & 0x3f); |
350 | } | 350 | } |
351 | 351 | ||
352 | static int ds1337_detach_client(struct i2c_client *client) | 352 | static int ds1337_detach_client(struct i2c_client *client) |
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 6ea413f6d5e5..a2da31b0dd7b 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c | |||
@@ -163,6 +163,11 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | |||
163 | struct eeprom_data *data; | 163 | struct eeprom_data *data; |
164 | int err = 0; | 164 | int err = 0; |
165 | 165 | ||
166 | /* prevent 24RF08 corruption */ | ||
167 | if (kind < 0) | ||
168 | i2c_smbus_xfer(adapter, address, 0, 0, 0, | ||
169 | I2C_SMBUS_QUICK, NULL); | ||
170 | |||
166 | /* There are three ways we can read the EEPROM data: | 171 | /* There are three ways we can read the EEPROM data: |
167 | (1) I2C block reads (faster, but unsupported by most adapters) | 172 | (1) I2C block reads (faster, but unsupported by most adapters) |
168 | (2) Consecutive byte reads (100% overhead) | 173 | (2) Consecutive byte reads (100% overhead) |
@@ -187,9 +192,6 @@ int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) | |||
187 | new_client->driver = &eeprom_driver; | 192 | new_client->driver = &eeprom_driver; |
188 | new_client->flags = 0; | 193 | new_client->flags = 0; |
189 | 194 | ||
190 | /* prevent 24RF08 corruption */ | ||
191 | i2c_smbus_write_quick(new_client, 0); | ||
192 | |||
193 | /* Fill in the remaining client fields */ | 195 | /* Fill in the remaining client fields */ |
194 | strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); | 196 | strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); |
195 | data->valid = 0; | 197 | data->valid = 0; |
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index c4f14d9623c4..0230375f72e5 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c | |||
@@ -343,6 +343,11 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | |||
343 | struct max6875_data *data; | 343 | struct max6875_data *data; |
344 | int err = 0; | 344 | int err = 0; |
345 | 345 | ||
346 | /* Prevent 24RF08 corruption (in case of user error) */ | ||
347 | if (kind < 0) | ||
348 | i2c_smbus_xfer(adapter, address, 0, 0, 0, | ||
349 | I2C_SMBUS_QUICK, NULL); | ||
350 | |||
346 | /* There are three ways we can read the EEPROM data: | 351 | /* There are three ways we can read the EEPROM data: |
347 | (1) I2C block reads (faster, but unsupported by most adapters) | 352 | (1) I2C block reads (faster, but unsupported by most adapters) |
348 | (2) Consecutive byte reads (100% overhead) | 353 | (2) Consecutive byte reads (100% overhead) |
@@ -370,9 +375,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind) | |||
370 | new_client->driver = &max6875_driver; | 375 | new_client->driver = &max6875_driver; |
371 | new_client->flags = 0; | 376 | new_client->flags = 0; |
372 | 377 | ||
373 | /* Prevent 24RF08 corruption */ | ||
374 | i2c_smbus_write_quick(new_client, 0); | ||
375 | |||
376 | /* Setup the user section */ | 378 | /* Setup the user section */ |
377 | data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; | 379 | data->blocks[max6875_eeprom_user].type = max6875_eeprom_user; |
378 | data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; | 380 | data->blocks[max6875_eeprom_user].slices = USER_EEPROM_SLICES; |
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 4fd4f52c8e9b..4a9ead277596 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -231,8 +231,8 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
231 | if (driver->detach_adapter) | 231 | if (driver->detach_adapter) |
232 | if ((res = driver->detach_adapter(adap))) { | 232 | if ((res = driver->detach_adapter(adap))) { |
233 | dev_warn(&adap->dev, "can't detach adapter " | 233 | dev_warn(&adap->dev, "can't detach adapter " |
234 | "while detaching driver %s: driver not " | 234 | "while detaching driver %s: driver " |
235 | "detached!", driver->name); | 235 | "not detached!\n", driver->name); |
236 | goto out_unlock; | 236 | goto out_unlock; |
237 | } | 237 | } |
238 | } | 238 | } |
@@ -456,8 +456,8 @@ int i2c_detach_client(struct i2c_client *client) | |||
456 | res = adapter->client_unregister(client); | 456 | res = adapter->client_unregister(client); |
457 | if (res) { | 457 | if (res) { |
458 | dev_err(&client->dev, | 458 | dev_err(&client->dev, |
459 | "client_unregister [%s] failed, " | 459 | "client_unregister [%s] failed, " |
460 | "client not detached", client->name); | 460 | "client not detached\n", client->name); |
461 | goto out; | 461 | goto out; |
462 | } | 462 | } |
463 | } | 463 | } |