diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/chips/Kconfig | 1 | ||||
-rw-r--r-- | drivers/i2c/chips/tps65010.c | 59 |
2 files changed, 28 insertions, 32 deletions
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig index a0982da09803..b28964b08006 100644 --- a/drivers/i2c/chips/Kconfig +++ b/drivers/i2c/chips/Kconfig | |||
@@ -509,7 +509,6 @@ config TPS65010 | |||
509 | This driver can also be built as a module. If so, the module | 509 | This driver can also be built as a module. If so, the module |
510 | will be called tps65010. | 510 | will be called tps65010. |
511 | 511 | ||
512 | |||
513 | config SENSORS_M41T00 | 512 | config SENSORS_M41T00 |
514 | tristate "ST M41T00 RTC chip" | 513 | tristate "ST M41T00 RTC chip" |
515 | depends on I2C && PPC32 | 514 | depends on I2C && PPC32 |
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index c0ac01b60039..280e9638c0f8 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c | |||
@@ -18,7 +18,6 @@ | |||
18 | * along with this program; if not, write to the Free Software | 18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | #undef DEBUG | ||
22 | 21 | ||
23 | #include <linux/config.h> | 22 | #include <linux/config.h> |
24 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
@@ -49,11 +48,7 @@ | |||
49 | MODULE_DESCRIPTION("TPS6501x Power Management Driver"); | 48 | MODULE_DESCRIPTION("TPS6501x Power Management Driver"); |
50 | MODULE_LICENSE("GPL"); | 49 | MODULE_LICENSE("GPL"); |
51 | 50 | ||
52 | /* only two addresses possible */ | 51 | static unsigned short normal_i2c[] = { 0x48, /* 0x49, */ I2C_CLIENT_END }; |
53 | #define TPS_BASE 0x48 | ||
54 | static unsigned short normal_i2c[] = { | ||
55 | TPS_BASE, | ||
56 | I2C_CLIENT_END }; | ||
57 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; | 52 | static unsigned short normal_i2c_range[] = { I2C_CLIENT_END }; |
58 | 53 | ||
59 | I2C_CLIENT_INSMOD; | 54 | I2C_CLIENT_INSMOD; |
@@ -102,7 +97,7 @@ struct tps65010 { | |||
102 | u8 chgstatus, regstatus, chgconf; | 97 | u8 chgstatus, regstatus, chgconf; |
103 | u8 nmask1, nmask2; | 98 | u8 nmask1, nmask2; |
104 | 99 | ||
105 | /* plus four GPIOs, probably used to switch power */ | 100 | /* not currently tracking GPIO state */ |
106 | }; | 101 | }; |
107 | 102 | ||
108 | #define POWER_POLL_DELAY msecs_to_jiffies(800) | 103 | #define POWER_POLL_DELAY msecs_to_jiffies(800) |
@@ -135,7 +130,7 @@ static void dbg_regstat(char *buf, size_t len, u8 regstatus) | |||
135 | (regstatus & TPS_REG_COVER) ? " uncover" : "", | 130 | (regstatus & TPS_REG_COVER) ? " uncover" : "", |
136 | (regstatus & TPS_REG_UVLO) ? " UVLO" : "", | 131 | (regstatus & TPS_REG_UVLO) ? " UVLO" : "", |
137 | (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "", | 132 | (regstatus & TPS_REG_NO_CHG) ? " NO_CHG" : "", |
138 | (regstatus & TPS_REG_PG_LD02) ? " ld01_bad" : "", | 133 | (regstatus & TPS_REG_PG_LD02) ? " ld02_bad" : "", |
139 | (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "", | 134 | (regstatus & TPS_REG_PG_LD01) ? " ld01_bad" : "", |
140 | (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "", | 135 | (regstatus & TPS_REG_PG_MAIN) ? " main_bad" : "", |
141 | (regstatus & TPS_REG_PG_CORE) ? " core_bad" : ""); | 136 | (regstatus & TPS_REG_PG_CORE) ? " core_bad" : ""); |
@@ -143,7 +138,7 @@ static void dbg_regstat(char *buf, size_t len, u8 regstatus) | |||
143 | 138 | ||
144 | static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig) | 139 | static void dbg_chgconf(int por, char *buf, size_t len, u8 chgconfig) |
145 | { | 140 | { |
146 | char *hibit; | 141 | const char *hibit; |
147 | 142 | ||
148 | if (por) | 143 | if (por) |
149 | hibit = (chgconfig & TPS_CHARGE_POR) | 144 | hibit = (chgconfig & TPS_CHARGE_POR) |
@@ -295,7 +290,7 @@ static int dbg_show(struct seq_file *s, void *_) | |||
295 | seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2); | 290 | seq_printf(s, "defgpio %02x mask3 %02x\n", value, v2); |
296 | 291 | ||
297 | for (i = 0; i < 4; i++) { | 292 | for (i = 0; i < 4; i++) { |
298 | if (value & (1 << (4 +i))) | 293 | if (value & (1 << (4 + i))) |
299 | seq_printf(s, " gpio%d-out %s\n", i + 1, | 294 | seq_printf(s, " gpio%d-out %s\n", i + 1, |
300 | (value & (1 << i)) ? "low" : "hi "); | 295 | (value & (1 << i)) ? "low" : "hi "); |
301 | else | 296 | else |
@@ -481,7 +476,7 @@ static int __exit tps65010_detach_client(struct i2c_client *client) | |||
481 | debugfs_remove(tps->file); | 476 | debugfs_remove(tps->file); |
482 | if (i2c_detach_client(client) == 0) | 477 | if (i2c_detach_client(client) == 0) |
483 | kfree(tps); | 478 | kfree(tps); |
484 | the_tps = 0; | 479 | the_tps = NULL; |
485 | return 0; | 480 | return 0; |
486 | } | 481 | } |
487 | 482 | ||
@@ -514,7 +509,6 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) | |||
514 | INIT_WORK(&tps->work, tps65010_work, tps); | 509 | INIT_WORK(&tps->work, tps65010_work, tps); |
515 | tps->irq = -1; | 510 | tps->irq = -1; |
516 | tps->client.addr = address; | 511 | tps->client.addr = address; |
517 | i2c_set_clientdata(&tps->client, tps); | ||
518 | tps->client.adapter = bus; | 512 | tps->client.adapter = bus; |
519 | tps->client.driver = &tps65010_driver; | 513 | tps->client.driver = &tps65010_driver; |
520 | strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE); | 514 | strlcpy(tps->client.name, DRIVER_NAME, I2C_NAME_SIZE); |
@@ -523,9 +517,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind) | |||
523 | if (status < 0) { | 517 | if (status < 0) { |
524 | dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", | 518 | dev_dbg(&bus->dev, "can't attach %s to device %d, err %d\n", |
525 | DRIVER_NAME, address, status); | 519 | DRIVER_NAME, address, status); |
526 | fail1: | 520 | goto fail1; |
527 | kfree(tps); | ||
528 | return 0; | ||
529 | } | 521 | } |
530 | 522 | ||
531 | #ifdef CONFIG_ARM | 523 | #ifdef CONFIG_ARM |
@@ -535,7 +527,7 @@ fail1: | |||
535 | tps->irq = OMAP_GPIO_IRQ(58); | 527 | tps->irq = OMAP_GPIO_IRQ(58); |
536 | omap_request_gpio(58); | 528 | omap_request_gpio(58); |
537 | omap_set_gpio_direction(58, 1); | 529 | omap_set_gpio_direction(58, 1); |
538 | omap_set_gpio_edge_ctrl(58, OMAP_GPIO_FALLING_EDGE); | 530 | set_irq_type(tps->irq, IRQT_FALLING); |
539 | } | 531 | } |
540 | if (machine_is_omap_osk()) { | 532 | if (machine_is_omap_osk()) { |
541 | tps->model = TPS65010; | 533 | tps->model = TPS65010; |
@@ -543,7 +535,7 @@ fail1: | |||
543 | tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)); | 535 | tps->irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)); |
544 | omap_request_gpio(OMAP_MPUIO(1)); | 536 | omap_request_gpio(OMAP_MPUIO(1)); |
545 | omap_set_gpio_direction(OMAP_MPUIO(1), 1); | 537 | omap_set_gpio_direction(OMAP_MPUIO(1), 1); |
546 | omap_set_gpio_edge_ctrl(OMAP_MPUIO(1), OMAP_GPIO_FALLING_EDGE); | 538 | set_irq_type(tps->irq, IRQT_FALLING); |
547 | } | 539 | } |
548 | if (machine_is_omap_h3()) { | 540 | if (machine_is_omap_h3()) { |
549 | tps->model = TPS65013; | 541 | tps->model = TPS65013; |
@@ -633,6 +625,9 @@ fail1: | |||
633 | tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, | 625 | tps->file = debugfs_create_file(DRIVER_NAME, S_IRUGO, NULL, |
634 | tps, DEBUG_FOPS); | 626 | tps, DEBUG_FOPS); |
635 | return 0; | 627 | return 0; |
628 | fail1: | ||
629 | kfree(tps); | ||
630 | return 0; | ||
636 | } | 631 | } |
637 | 632 | ||
638 | static int __init tps65010_scan_bus(struct i2c_adapter *bus) | 633 | static int __init tps65010_scan_bus(struct i2c_adapter *bus) |
@@ -645,7 +640,6 @@ static int __init tps65010_scan_bus(struct i2c_adapter *bus) | |||
645 | static struct i2c_driver tps65010_driver = { | 640 | static struct i2c_driver tps65010_driver = { |
646 | .owner = THIS_MODULE, | 641 | .owner = THIS_MODULE, |
647 | .name = "tps65010", | 642 | .name = "tps65010", |
648 | .id = 888, /* FIXME assign "official" value */ | ||
649 | .flags = I2C_DF_NOTIFY, | 643 | .flags = I2C_DF_NOTIFY, |
650 | .attach_adapter = tps65010_scan_bus, | 644 | .attach_adapter = tps65010_scan_bus, |
651 | .detach_client = __exit_p(tps65010_detach_client), | 645 | .detach_client = __exit_p(tps65010_detach_client), |
@@ -744,7 +738,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
744 | if (!the_tps) | 738 | if (!the_tps) |
745 | return -ENODEV; | 739 | return -ENODEV; |
746 | 740 | ||
747 | if(led == LED1) | 741 | if (led == LED1) |
748 | offs = 0; | 742 | offs = 0; |
749 | else { | 743 | else { |
750 | offs = 2; | 744 | offs = 2; |
@@ -753,11 +747,13 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
753 | 747 | ||
754 | down(&the_tps->lock); | 748 | down(&the_tps->lock); |
755 | 749 | ||
756 | dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, | 750 | pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, |
757 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); | 751 | i2c_smbus_read_byte_data(&the_tps->client, |
752 | TPS_LED1_ON + offs)); | ||
758 | 753 | ||
759 | dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, | 754 | pr_debug("%s: led%i_per 0x%02x\n", DRIVER_NAME, led, |
760 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); | 755 | i2c_smbus_read_byte_data(&the_tps->client, |
756 | TPS_LED1_PER + offs)); | ||
761 | 757 | ||
762 | switch (mode) { | 758 | switch (mode) { |
763 | case OFF: | 759 | case OFF: |
@@ -773,7 +769,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
773 | led_per = 0x08 | (1 << 7); | 769 | led_per = 0x08 | (1 << 7); |
774 | break; | 770 | break; |
775 | default: | 771 | default: |
776 | printk(KERN_ERR "%s: Wrong mode parameter for tps65010_set_led()\n", | 772 | printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n", |
777 | DRIVER_NAME); | 773 | DRIVER_NAME); |
778 | up(&the_tps->lock); | 774 | up(&the_tps->lock); |
779 | return -EINVAL; | 775 | return -EINVAL; |
@@ -789,7 +785,7 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
789 | return status; | 785 | return status; |
790 | } | 786 | } |
791 | 787 | ||
792 | dev_dbg (&the_tps->client.dev, "led%i_on 0x%02x\n", led, | 788 | pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led, |
793 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); | 789 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_ON + offs)); |
794 | 790 | ||
795 | status = i2c_smbus_write_byte_data(&the_tps->client, | 791 | status = i2c_smbus_write_byte_data(&the_tps->client, |
@@ -802,8 +798,9 @@ int tps65010_set_led(unsigned led, unsigned mode) | |||
802 | return status; | 798 | return status; |
803 | } | 799 | } |
804 | 800 | ||
805 | dev_dbg (&the_tps->client.dev, "led%i_per 0x%02x\n", led, | 801 | pr_debug("%s: led%i_per 0x%02x\n", DRIVER_NAME, led, |
806 | i2c_smbus_read_byte_data(&the_tps->client, TPS_LED1_PER + offs)); | 802 | i2c_smbus_read_byte_data(&the_tps->client, |
803 | TPS_LED1_PER + offs)); | ||
807 | 804 | ||
808 | up(&the_tps->lock); | 805 | up(&the_tps->lock); |
809 | 806 | ||
@@ -874,7 +871,7 @@ int tps65010_set_low_pwr(unsigned mode) | |||
874 | 871 | ||
875 | if (status != 0) | 872 | if (status != 0) |
876 | printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", | 873 | printk(KERN_ERR "%s: Failed to write vdcdc1 register\n", |
877 | DRIVER_NAME); | 874 | DRIVER_NAME); |
878 | else | 875 | else |
879 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, | 876 | pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME, |
880 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); | 877 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1)); |
@@ -900,14 +897,14 @@ int tps65010_config_vregs1(unsigned value) | |||
900 | down(&the_tps->lock); | 897 | down(&the_tps->lock); |
901 | 898 | ||
902 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | 899 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, |
903 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | 900 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); |
904 | 901 | ||
905 | status = i2c_smbus_write_byte_data(&the_tps->client, | 902 | status = i2c_smbus_write_byte_data(&the_tps->client, |
906 | TPS_VREGS1, value); | 903 | TPS_VREGS1, value); |
907 | 904 | ||
908 | if (status != 0) | 905 | if (status != 0) |
909 | printk(KERN_ERR "%s: Failed to write vregs1 register\n", | 906 | printk(KERN_ERR "%s: Failed to write vregs1 register\n", |
910 | DRIVER_NAME); | 907 | DRIVER_NAME); |
911 | else | 908 | else |
912 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, | 909 | pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME, |
913 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); | 910 | i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1)); |
@@ -1009,7 +1006,7 @@ static int __init tps_init(void) | |||
1009 | msleep(10); | 1006 | msleep(10); |
1010 | } | 1007 | } |
1011 | 1008 | ||
1012 | #if defined(CONFIG_ARM) | 1009 | #ifdef CONFIG_ARM |
1013 | if (machine_is_omap_osk()) { | 1010 | if (machine_is_omap_osk()) { |
1014 | 1011 | ||
1015 | // FIXME: More should be placed in the initialization code | 1012 | // FIXME: More should be placed in the initialization code |