diff options
Diffstat (limited to 'drivers/mfd/ucb1x00-core.c')
-rw-r--r-- | drivers/mfd/ucb1x00-core.c | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c index b281217334e..91c4f25e0e5 100644 --- a/drivers/mfd/ucb1x00-core.c +++ b/drivers/mfd/ucb1x00-core.c | |||
@@ -36,6 +36,15 @@ static DEFINE_MUTEX(ucb1x00_mutex); | |||
36 | static LIST_HEAD(ucb1x00_drivers); | 36 | static LIST_HEAD(ucb1x00_drivers); |
37 | static LIST_HEAD(ucb1x00_devices); | 37 | static LIST_HEAD(ucb1x00_devices); |
38 | 38 | ||
39 | static struct mcp_device_id ucb1x00_id[] = { | ||
40 | { "ucb1x00", 0 }, /* auto-detection */ | ||
41 | { "ucb1200", UCB_ID_1200 }, | ||
42 | { "ucb1300", UCB_ID_1300 }, | ||
43 | { "tc35143", UCB_ID_TC35143 }, | ||
44 | { } | ||
45 | }; | ||
46 | MODULE_DEVICE_TABLE(mcp, ucb1x00_id); | ||
47 | |||
39 | /** | 48 | /** |
40 | * ucb1x00_io_set_dir - set IO direction | 49 | * ucb1x00_io_set_dir - set IO direction |
41 | * @ucb: UCB1x00 structure describing chip | 50 | * @ucb: UCB1x00 structure describing chip |
@@ -527,17 +536,33 @@ static struct class ucb1x00_class = { | |||
527 | 536 | ||
528 | static int ucb1x00_probe(struct mcp *mcp) | 537 | static int ucb1x00_probe(struct mcp *mcp) |
529 | { | 538 | { |
539 | const struct mcp_device_id *mid; | ||
530 | struct ucb1x00 *ucb; | 540 | struct ucb1x00 *ucb; |
531 | struct ucb1x00_driver *drv; | 541 | struct ucb1x00_driver *drv; |
542 | struct ucb1x00_plat_data *pdata; | ||
532 | unsigned int id; | 543 | unsigned int id; |
533 | int ret = -ENODEV; | 544 | int ret = -ENODEV; |
534 | int temp; | 545 | int temp; |
535 | 546 | ||
536 | mcp_enable(mcp); | 547 | mcp_enable(mcp); |
537 | id = mcp_reg_read(mcp, UCB_ID); | 548 | id = mcp_reg_read(mcp, UCB_ID); |
549 | mid = mcp_get_device_id(mcp); | ||
538 | 550 | ||
539 | if (id != UCB_ID_1200 && id != UCB_ID_1300 && id != UCB_ID_TC35143) { | 551 | if (mid && mid->driver_data) { |
540 | printk(KERN_WARNING "UCB1x00 ID not found: %04x\n", id); | 552 | if (id != mid->driver_data) { |
553 | printk(KERN_WARNING "%s wrong ID %04x found: %04x\n", | ||
554 | mid->name, (unsigned int) mid->driver_data, id); | ||
555 | goto err_disable; | ||
556 | } | ||
557 | } else { | ||
558 | mid = &ucb1x00_id[1]; | ||
559 | while (mid->driver_data) { | ||
560 | if (id == mid->driver_data) | ||
561 | break; | ||
562 | mid++; | ||
563 | } | ||
564 | printk(KERN_WARNING "%s ID not found: %04x\n", | ||
565 | ucb1x00_id[0].name, id); | ||
541 | goto err_disable; | 566 | goto err_disable; |
542 | } | 567 | } |
543 | 568 | ||
@@ -546,28 +571,28 @@ static int ucb1x00_probe(struct mcp *mcp) | |||
546 | if (!ucb) | 571 | if (!ucb) |
547 | goto err_disable; | 572 | goto err_disable; |
548 | 573 | ||
549 | 574 | pdata = mcp->attached_device.platform_data; | |
550 | ucb->dev.class = &ucb1x00_class; | 575 | ucb->dev.class = &ucb1x00_class; |
551 | ucb->dev.parent = &mcp->attached_device; | 576 | ucb->dev.parent = &mcp->attached_device; |
552 | dev_set_name(&ucb->dev, "ucb1x00"); | 577 | dev_set_name(&ucb->dev, mid->name); |
553 | 578 | ||
554 | spin_lock_init(&ucb->lock); | 579 | spin_lock_init(&ucb->lock); |
555 | spin_lock_init(&ucb->io_lock); | 580 | spin_lock_init(&ucb->io_lock); |
556 | sema_init(&ucb->adc_sem, 1); | 581 | sema_init(&ucb->adc_sem, 1); |
557 | 582 | ||
558 | ucb->id = id; | 583 | ucb->id = mid; |
559 | ucb->mcp = mcp; | 584 | ucb->mcp = mcp; |
560 | ucb->irq = ucb1x00_detect_irq(ucb); | 585 | ucb->irq = ucb1x00_detect_irq(ucb); |
561 | if (ucb->irq == NO_IRQ) { | 586 | if (ucb->irq == NO_IRQ) { |
562 | printk(KERN_ERR "UCB1x00: IRQ probe failed\n"); | 587 | printk(KERN_ERR "%s: IRQ probe failed\n", mid->name); |
563 | ret = -ENODEV; | 588 | ret = -ENODEV; |
564 | goto err_free; | 589 | goto err_free; |
565 | } | 590 | } |
566 | 591 | ||
567 | ucb->gpio.base = -1; | 592 | ucb->gpio.base = -1; |
568 | if (mcp->gpio_base != 0) { | 593 | if (pdata && (pdata->gpio_base >= 0)) { |
569 | ucb->gpio.label = dev_name(&ucb->dev); | 594 | ucb->gpio.label = dev_name(&ucb->dev); |
570 | ucb->gpio.base = mcp->gpio_base; | 595 | ucb->gpio.base = pdata->gpio_base; |
571 | ucb->gpio.ngpio = 10; | 596 | ucb->gpio.ngpio = 10; |
572 | ucb->gpio.set = ucb1x00_gpio_set; | 597 | ucb->gpio.set = ucb1x00_gpio_set; |
573 | ucb->gpio.get = ucb1x00_gpio_get; | 598 | ucb->gpio.get = ucb1x00_gpio_get; |
@@ -580,10 +605,10 @@ static int ucb1x00_probe(struct mcp *mcp) | |||
580 | dev_info(&ucb->dev, "gpio_base not set so no gpiolib support"); | 605 | dev_info(&ucb->dev, "gpio_base not set so no gpiolib support"); |
581 | 606 | ||
582 | ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING, | 607 | ret = request_irq(ucb->irq, ucb1x00_irq, IRQF_TRIGGER_RISING, |
583 | "UCB1x00", ucb); | 608 | mid->name, ucb); |
584 | if (ret) { | 609 | if (ret) { |
585 | printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n", | 610 | printk(KERN_ERR "%s: unable to grab irq%d: %d\n", |
586 | ucb->irq, ret); | 611 | mid->name, ucb->irq, ret); |
587 | goto err_gpio; | 612 | goto err_gpio; |
588 | } | 613 | } |
589 | 614 | ||
@@ -705,6 +730,7 @@ static struct mcp_driver ucb1x00_driver = { | |||
705 | .remove = ucb1x00_remove, | 730 | .remove = ucb1x00_remove, |
706 | .suspend = ucb1x00_suspend, | 731 | .suspend = ucb1x00_suspend, |
707 | .resume = ucb1x00_resume, | 732 | .resume = ucb1x00_resume, |
733 | .id_table = ucb1x00_id, | ||
708 | }; | 734 | }; |
709 | 735 | ||
710 | static int __init ucb1x00_init(void) | 736 | static int __init ucb1x00_init(void) |