diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/Kconfig | 7 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-i801.c | 2 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-ixp4xx.c | 3 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-pxa.c | 131 | ||||
-rw-r--r-- | drivers/i2c/busses/scx200_acb.c | 7 | ||||
-rw-r--r-- | drivers/i2c/chips/ds1374.c | 12 | ||||
-rw-r--r-- | drivers/i2c/chips/m41t00.c | 9 | ||||
-rw-r--r-- | drivers/i2c/i2c-dev.c | 26 |
8 files changed, 40 insertions, 157 deletions
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 510816c16da3..90f91d039ee2 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
@@ -125,6 +125,7 @@ config I2C_I801 | |||
125 | ICH7 | 125 | ICH7 |
126 | ESB2 | 126 | ESB2 |
127 | ICH8 | 127 | ICH8 |
128 | ICH9 | ||
128 | 129 | ||
129 | This driver can also be built as a module. If so, the module | 130 | This driver can also be built as a module. If so, the module |
130 | will be called i2c-i801. | 131 | will be called i2c-i801. |
@@ -195,11 +196,11 @@ config I2C_IBM_IIC | |||
195 | will be called i2c-ibm_iic. | 196 | will be called i2c-ibm_iic. |
196 | 197 | ||
197 | config I2C_IOP3XX | 198 | config I2C_IOP3XX |
198 | tristate "Intel IOP3xx and IXP4xx on-chip I2C interface" | 199 | tristate "Intel IOPx3xx and IXP4xx on-chip I2C interface" |
199 | depends on (ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX) && I2C | 200 | depends on (ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX || ARCH_IOP13XX) && I2C |
200 | help | 201 | help |
201 | Say Y here if you want to use the IIC bus controller on | 202 | Say Y here if you want to use the IIC bus controller on |
202 | the Intel IOP3xx I/O Processors or IXP4xx Network Processors. | 203 | the Intel IOPx3xx I/O Processors or IXP4xx Network Processors. |
203 | 204 | ||
204 | This driver can also be built as a module. If so, the module | 205 | This driver can also be built as a module. If so, the module |
205 | will be called i2c-iop3xx. | 206 | will be called i2c-iop3xx. |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index bbb2fbee836f..c7be2fdbd86b 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -33,6 +33,7 @@ | |||
33 | ICH7 27DA | 33 | ICH7 27DA |
34 | ESB2 269B | 34 | ESB2 269B |
35 | ICH8 283E | 35 | ICH8 283E |
36 | ICH9 2930 | ||
36 | This driver supports several versions of Intel's I/O Controller Hubs (ICH). | 37 | This driver supports several versions of Intel's I/O Controller Hubs (ICH). |
37 | For SMBus support, they are similar to the PIIX4 and are part | 38 | For SMBus support, they are similar to the PIIX4 and are part |
38 | of Intel's '810' and other chipsets. | 39 | of Intel's '810' and other chipsets. |
@@ -457,6 +458,7 @@ static struct pci_device_id i801_ids[] = { | |||
457 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) }, | 458 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) }, |
458 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) }, | 459 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) }, |
459 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) }, | 460 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) }, |
461 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_6) }, | ||
460 | { 0, } | 462 | { 0, } |
461 | }; | 463 | }; |
462 | 464 | ||
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c index 1ce01fb0ac09..68fe863f9d54 100644 --- a/drivers/i2c/busses/i2c-ixp4xx.c +++ b/drivers/i2c/busses/i2c-ixp4xx.c | |||
@@ -137,7 +137,8 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev) | |||
137 | gpio_line_set(gpio->scl_pin, 0); | 137 | gpio_line_set(gpio->scl_pin, 0); |
138 | gpio_line_set(gpio->sda_pin, 0); | 138 | gpio_line_set(gpio->sda_pin, 0); |
139 | 139 | ||
140 | if ((err = i2c_bit_add_bus(&drv_data->adapter) != 0)) { | 140 | err = i2c_bit_add_bus(&drv_data->adapter); |
141 | if (err) { | ||
141 | printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id); | 142 | printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id); |
142 | 143 | ||
143 | kfree(drv_data); | 144 | kfree(drv_data); |
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index c95a6c154165..c3b1567c852a 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c | |||
@@ -358,133 +358,6 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c) | |||
358 | 358 | ||
359 | #ifdef CONFIG_I2C_PXA_SLAVE | 359 | #ifdef CONFIG_I2C_PXA_SLAVE |
360 | /* | 360 | /* |
361 | * I2C EEPROM emulation. | ||
362 | */ | ||
363 | static struct i2c_eeprom_emu eeprom = { | ||
364 | .size = I2C_EEPROM_EMU_SIZE, | ||
365 | .watch = LIST_HEAD_INIT(eeprom.watch), | ||
366 | }; | ||
367 | |||
368 | struct i2c_eeprom_emu *i2c_pxa_get_eeprom(void) | ||
369 | { | ||
370 | return &eeprom; | ||
371 | } | ||
372 | |||
373 | int i2c_eeprom_emu_addwatcher(struct i2c_eeprom_emu *emu, void *data, | ||
374 | unsigned int addr, unsigned int size, | ||
375 | struct i2c_eeprom_emu_watcher *watcher) | ||
376 | { | ||
377 | struct i2c_eeprom_emu_watch *watch; | ||
378 | unsigned long flags; | ||
379 | |||
380 | if (addr + size > emu->size) | ||
381 | return -EINVAL; | ||
382 | |||
383 | watch = kmalloc(sizeof(struct i2c_eeprom_emu_watch), GFP_KERNEL); | ||
384 | if (watch) { | ||
385 | watch->start = addr; | ||
386 | watch->end = addr + size - 1; | ||
387 | watch->ops = watcher; | ||
388 | watch->data = data; | ||
389 | |||
390 | local_irq_save(flags); | ||
391 | list_add(&watch->node, &emu->watch); | ||
392 | local_irq_restore(flags); | ||
393 | } | ||
394 | |||
395 | return watch ? 0 : -ENOMEM; | ||
396 | } | ||
397 | |||
398 | void i2c_eeprom_emu_delwatcher(struct i2c_eeprom_emu *emu, void *data, | ||
399 | struct i2c_eeprom_emu_watcher *watcher) | ||
400 | { | ||
401 | struct i2c_eeprom_emu_watch *watch, *n; | ||
402 | unsigned long flags; | ||
403 | |||
404 | list_for_each_entry_safe(watch, n, &emu->watch, node) { | ||
405 | if (watch->ops == watcher && watch->data == data) { | ||
406 | local_irq_save(flags); | ||
407 | list_del(&watch->node); | ||
408 | local_irq_restore(flags); | ||
409 | kfree(watch); | ||
410 | } | ||
411 | } | ||
412 | } | ||
413 | |||
414 | static void i2c_eeprom_emu_event(void *ptr, i2c_slave_event_t event) | ||
415 | { | ||
416 | struct i2c_eeprom_emu *emu = ptr; | ||
417 | |||
418 | eedbg(3, "i2c_eeprom_emu_event: %d\n", event); | ||
419 | |||
420 | switch (event) { | ||
421 | case I2C_SLAVE_EVENT_START_WRITE: | ||
422 | emu->seen_start = 1; | ||
423 | eedbg(2, "i2c_eeprom: write initiated\n"); | ||
424 | break; | ||
425 | |||
426 | case I2C_SLAVE_EVENT_START_READ: | ||
427 | emu->seen_start = 0; | ||
428 | eedbg(2, "i2c_eeprom: read initiated\n"); | ||
429 | break; | ||
430 | |||
431 | case I2C_SLAVE_EVENT_STOP: | ||
432 | emu->seen_start = 0; | ||
433 | eedbg(2, "i2c_eeprom: received stop\n"); | ||
434 | break; | ||
435 | |||
436 | default: | ||
437 | eedbg(0, "i2c_eeprom: unhandled event\n"); | ||
438 | break; | ||
439 | } | ||
440 | } | ||
441 | |||
442 | static int i2c_eeprom_emu_read(void *ptr) | ||
443 | { | ||
444 | struct i2c_eeprom_emu *emu = ptr; | ||
445 | int ret; | ||
446 | |||
447 | ret = emu->bytes[emu->ptr]; | ||
448 | emu->ptr = (emu->ptr + 1) % emu->size; | ||
449 | |||
450 | return ret; | ||
451 | } | ||
452 | |||
453 | static void i2c_eeprom_emu_write(void *ptr, unsigned int val) | ||
454 | { | ||
455 | struct i2c_eeprom_emu *emu = ptr; | ||
456 | struct i2c_eeprom_emu_watch *watch; | ||
457 | |||
458 | if (emu->seen_start != 0) { | ||
459 | eedbg(2, "i2c_eeprom_emu_write: setting ptr %02x\n", val); | ||
460 | emu->ptr = val; | ||
461 | emu->seen_start = 0; | ||
462 | return; | ||
463 | } | ||
464 | |||
465 | emu->bytes[emu->ptr] = val; | ||
466 | |||
467 | eedbg(1, "i2c_eeprom_emu_write: ptr=0x%02x, val=0x%02x\n", | ||
468 | emu->ptr, val); | ||
469 | |||
470 | list_for_each_entry(watch, &emu->watch, node) { | ||
471 | if (!watch->ops || !watch->ops->write) | ||
472 | continue; | ||
473 | if (watch->start <= emu->ptr && watch->end >= emu->ptr) | ||
474 | watch->ops->write(watch->data, emu->ptr, val); | ||
475 | } | ||
476 | |||
477 | emu->ptr = (emu->ptr + 1) % emu->size; | ||
478 | } | ||
479 | |||
480 | struct i2c_slave_client eeprom_client = { | ||
481 | .data = &eeprom, | ||
482 | .event = i2c_eeprom_emu_event, | ||
483 | .read = i2c_eeprom_emu_read, | ||
484 | .write = i2c_eeprom_emu_write | ||
485 | }; | ||
486 | |||
487 | /* | ||
488 | * PXA I2C Slave mode | 361 | * PXA I2C Slave mode |
489 | */ | 362 | */ |
490 | 363 | ||
@@ -963,11 +836,9 @@ static int i2c_pxa_probe(struct platform_device *dev) | |||
963 | i2c->slave_addr = I2C_PXA_SLAVE_ADDR; | 836 | i2c->slave_addr = I2C_PXA_SLAVE_ADDR; |
964 | 837 | ||
965 | #ifdef CONFIG_I2C_PXA_SLAVE | 838 | #ifdef CONFIG_I2C_PXA_SLAVE |
966 | i2c->slave = &eeprom_client; | ||
967 | if (plat) { | 839 | if (plat) { |
968 | i2c->slave_addr = plat->slave_addr; | 840 | i2c->slave_addr = plat->slave_addr; |
969 | if (plat->slave) | 841 | i2c->slave = plat->slave; |
970 | i2c->slave = plat->slave; | ||
971 | } | 842 | } |
972 | #endif | 843 | #endif |
973 | 844 | ||
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 32aab0d34ee9..714bae780953 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -494,11 +494,12 @@ static __init int scx200_create_pci(const char *text, struct pci_dev *pdev, | |||
494 | iface->pdev = pdev; | 494 | iface->pdev = pdev; |
495 | iface->bar = bar; | 495 | iface->bar = bar; |
496 | 496 | ||
497 | pci_enable_device_bars(iface->pdev, 1 << iface->bar); | 497 | rc = pci_enable_device_bars(iface->pdev, 1 << iface->bar); |
498 | if (rc) | ||
499 | goto errout_free; | ||
498 | 500 | ||
499 | rc = pci_request_region(iface->pdev, iface->bar, iface->adapter.name); | 501 | rc = pci_request_region(iface->pdev, iface->bar, iface->adapter.name); |
500 | 502 | if (rc) { | |
501 | if (rc != 0) { | ||
502 | printk(KERN_ERR NAME ": can't allocate PCI BAR %d\n", | 503 | printk(KERN_ERR NAME ": can't allocate PCI BAR %d\n", |
503 | iface->bar); | 504 | iface->bar); |
504 | goto errout_free; | 505 | goto errout_free; |
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 4630f1969a09..15edf40828b4 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c | |||
@@ -140,12 +140,14 @@ ulong ds1374_get_rtc_time(void) | |||
140 | return t1; | 140 | return t1; |
141 | } | 141 | } |
142 | 142 | ||
143 | static void ds1374_set_work(void *arg) | 143 | static ulong new_time; |
144 | |||
145 | static void ds1374_set_work(struct work_struct *work) | ||
144 | { | 146 | { |
145 | ulong t1, t2; | 147 | ulong t1, t2; |
146 | int limit = 10; /* arbitrary retry limit */ | 148 | int limit = 10; /* arbitrary retry limit */ |
147 | 149 | ||
148 | t1 = *(ulong *) arg; | 150 | t1 = new_time; |
149 | 151 | ||
150 | mutex_lock(&ds1374_mutex); | 152 | mutex_lock(&ds1374_mutex); |
151 | 153 | ||
@@ -167,11 +169,9 @@ static void ds1374_set_work(void *arg) | |||
167 | "can't confirm time set from rtc chip\n"); | 169 | "can't confirm time set from rtc chip\n"); |
168 | } | 170 | } |
169 | 171 | ||
170 | static ulong new_time; | ||
171 | |||
172 | static struct workqueue_struct *ds1374_workqueue; | 172 | static struct workqueue_struct *ds1374_workqueue; |
173 | 173 | ||
174 | static DECLARE_WORK(ds1374_work, ds1374_set_work, &new_time); | 174 | static DECLARE_WORK(ds1374_work, ds1374_set_work); |
175 | 175 | ||
176 | int ds1374_set_rtc_time(ulong nowtime) | 176 | int ds1374_set_rtc_time(ulong nowtime) |
177 | { | 177 | { |
@@ -180,7 +180,7 @@ int ds1374_set_rtc_time(ulong nowtime) | |||
180 | if (in_interrupt()) | 180 | if (in_interrupt()) |
181 | queue_work(ds1374_workqueue, &ds1374_work); | 181 | queue_work(ds1374_workqueue, &ds1374_work); |
182 | else | 182 | else |
183 | ds1374_set_work(&new_time); | 183 | ds1374_set_work(NULL); |
184 | 184 | ||
185 | return 0; | 185 | return 0; |
186 | } | 186 | } |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 2dd0a34d9472..420377c86422 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -215,8 +215,15 @@ m41t00_set(void *arg) | |||
215 | } | 215 | } |
216 | 216 | ||
217 | static ulong new_time; | 217 | static ulong new_time; |
218 | /* well, isn't this API just _lovely_? */ | ||
219 | static void | ||
220 | m41t00_barf(struct work_struct *unusable) | ||
221 | { | ||
222 | m41t00_set(&new_time); | ||
223 | } | ||
224 | |||
218 | static struct workqueue_struct *m41t00_wq; | 225 | static struct workqueue_struct *m41t00_wq; |
219 | static DECLARE_WORK(m41t00_work, m41t00_set, &new_time); | 226 | static DECLARE_WORK(m41t00_work, m41t00_barf); |
220 | 227 | ||
221 | int | 228 | int |
222 | m41t00_set_rtc_time(ulong nowtime) | 229 | m41t00_set_rtc_time(ulong nowtime) |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 3f869033ed70..94a4e9a3013c 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -42,7 +42,7 @@ static struct i2c_driver i2cdev_driver; | |||
42 | struct i2c_dev { | 42 | struct i2c_dev { |
43 | struct list_head list; | 43 | struct list_head list; |
44 | struct i2c_adapter *adap; | 44 | struct i2c_adapter *adap; |
45 | struct class_device *class_dev; | 45 | struct device *dev; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #define I2C_MINORS 256 | 48 | #define I2C_MINORS 256 |
@@ -92,15 +92,16 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev) | |||
92 | spin_unlock(&i2c_dev_list_lock); | 92 | spin_unlock(&i2c_dev_list_lock); |
93 | } | 93 | } |
94 | 94 | ||
95 | static ssize_t show_adapter_name(struct class_device *class_dev, char *buf) | 95 | static ssize_t show_adapter_name(struct device *dev, |
96 | struct device_attribute *attr, char *buf) | ||
96 | { | 97 | { |
97 | struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(class_dev->devt)); | 98 | struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(dev->devt)); |
98 | 99 | ||
99 | if (!i2c_dev) | 100 | if (!i2c_dev) |
100 | return -ENODEV; | 101 | return -ENODEV; |
101 | return sprintf(buf, "%s\n", i2c_dev->adap->name); | 102 | return sprintf(buf, "%s\n", i2c_dev->adap->name); |
102 | } | 103 | } |
103 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); | 104 | static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); |
104 | 105 | ||
105 | static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count, | 106 | static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count, |
106 | loff_t *offset) | 107 | loff_t *offset) |
@@ -413,15 +414,14 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) | |||
413 | return PTR_ERR(i2c_dev); | 414 | return PTR_ERR(i2c_dev); |
414 | 415 | ||
415 | /* register this i2c device with the driver core */ | 416 | /* register this i2c device with the driver core */ |
416 | i2c_dev->class_dev = class_device_create(i2c_dev_class, NULL, | 417 | i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, |
417 | MKDEV(I2C_MAJOR, adap->nr), | 418 | MKDEV(I2C_MAJOR, adap->nr), |
418 | &adap->dev, "i2c-%d", | 419 | "i2c-%d", adap->nr); |
419 | adap->nr); | 420 | if (!i2c_dev->dev) { |
420 | if (!i2c_dev->class_dev) { | ||
421 | res = -ENODEV; | 421 | res = -ENODEV; |
422 | goto error; | 422 | goto error; |
423 | } | 423 | } |
424 | res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name); | 424 | res = device_create_file(i2c_dev->dev, &dev_attr_name); |
425 | if (res) | 425 | if (res) |
426 | goto error_destroy; | 426 | goto error_destroy; |
427 | 427 | ||
@@ -429,7 +429,7 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) | |||
429 | adap->name, adap->nr); | 429 | adap->name, adap->nr); |
430 | return 0; | 430 | return 0; |
431 | error_destroy: | 431 | error_destroy: |
432 | class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); | 432 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); |
433 | error: | 433 | error: |
434 | return_i2c_dev(i2c_dev); | 434 | return_i2c_dev(i2c_dev); |
435 | kfree(i2c_dev); | 435 | kfree(i2c_dev); |
@@ -444,9 +444,9 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) | |||
444 | if (!i2c_dev) /* attach_adapter must have failed */ | 444 | if (!i2c_dev) /* attach_adapter must have failed */ |
445 | return 0; | 445 | return 0; |
446 | 446 | ||
447 | class_device_remove_file(i2c_dev->class_dev, &class_device_attr_name); | 447 | device_remove_file(i2c_dev->dev, &dev_attr_name); |
448 | return_i2c_dev(i2c_dev); | 448 | return_i2c_dev(i2c_dev); |
449 | class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); | 449 | device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); |
450 | kfree(i2c_dev); | 450 | kfree(i2c_dev); |
451 | 451 | ||
452 | pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); | 452 | pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); |