diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/mfd/ab3100-core.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/mfd/ab3100-core.c')
-rw-r--r-- | drivers/mfd/ab3100-core.c | 148 |
1 files changed, 78 insertions, 70 deletions
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c index 66379b413906..a20e1c41bed2 100644 --- a/drivers/mfd/ab3100-core.c +++ b/drivers/mfd/ab3100-core.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/debugfs.h> | 19 | #include <linux/debugfs.h> |
20 | #include <linux/seq_file.h> | 20 | #include <linux/seq_file.h> |
21 | #include <linux/uaccess.h> | 21 | #include <linux/uaccess.h> |
22 | #include <linux/mfd/core.h> | ||
22 | #include <linux/mfd/abx500.h> | 23 | #include <linux/mfd/abx500.h> |
23 | 24 | ||
24 | /* These are the only registers inside AB3100 used in this main file */ | 25 | /* These are the only registers inside AB3100 used in this main file */ |
@@ -146,7 +147,7 @@ static int ab3100_set_test_register_interruptible(struct ab3100 *ab3100, | |||
146 | } | 147 | } |
147 | 148 | ||
148 | static int ab3100_get_register_interruptible(struct ab3100 *ab3100, | 149 | static int ab3100_get_register_interruptible(struct ab3100 *ab3100, |
149 | u8 reg, u8 *regval) | 150 | u8 reg, u8 *regval) |
150 | { | 151 | { |
151 | int err; | 152 | int err; |
152 | 153 | ||
@@ -202,7 +203,7 @@ static int ab3100_get_register_interruptible(struct ab3100 *ab3100, | |||
202 | } | 203 | } |
203 | 204 | ||
204 | static int get_register_interruptible(struct device *dev, u8 bank, u8 reg, | 205 | static int get_register_interruptible(struct device *dev, u8 bank, u8 reg, |
205 | u8 *value) | 206 | u8 *value) |
206 | { | 207 | { |
207 | struct ab3100 *ab3100 = dev_get_drvdata(dev->parent); | 208 | struct ab3100 *ab3100 = dev_get_drvdata(dev->parent); |
208 | 209 | ||
@@ -583,6 +584,7 @@ static ssize_t ab3100_get_set_reg(struct file *file, | |||
583 | static const struct file_operations ab3100_get_set_reg_fops = { | 584 | static const struct file_operations ab3100_get_set_reg_fops = { |
584 | .open = ab3100_get_set_reg_open_file, | 585 | .open = ab3100_get_set_reg_open_file, |
585 | .write = ab3100_get_set_reg, | 586 | .write = ab3100_get_set_reg, |
587 | .llseek = noop_llseek, | ||
586 | }; | 588 | }; |
587 | 589 | ||
588 | static struct dentry *ab3100_dir; | 590 | static struct dentry *ab3100_dir; |
@@ -611,7 +613,7 @@ static void ab3100_setup_debugfs(struct ab3100 *ab3100) | |||
611 | ab3100_get_priv.ab3100 = ab3100; | 613 | ab3100_get_priv.ab3100 = ab3100; |
612 | ab3100_get_priv.mode = false; | 614 | ab3100_get_priv.mode = false; |
613 | ab3100_get_reg_file = debugfs_create_file("get_reg", | 615 | ab3100_get_reg_file = debugfs_create_file("get_reg", |
614 | S_IWUGO, ab3100_dir, &ab3100_get_priv, | 616 | S_IWUSR, ab3100_dir, &ab3100_get_priv, |
615 | &ab3100_get_set_reg_fops); | 617 | &ab3100_get_set_reg_fops); |
616 | if (!ab3100_get_reg_file) { | 618 | if (!ab3100_get_reg_file) { |
617 | err = -ENOMEM; | 619 | err = -ENOMEM; |
@@ -621,7 +623,7 @@ static void ab3100_setup_debugfs(struct ab3100 *ab3100) | |||
621 | ab3100_set_priv.ab3100 = ab3100; | 623 | ab3100_set_priv.ab3100 = ab3100; |
622 | ab3100_set_priv.mode = true; | 624 | ab3100_set_priv.mode = true; |
623 | ab3100_set_reg_file = debugfs_create_file("set_reg", | 625 | ab3100_set_reg_file = debugfs_create_file("set_reg", |
624 | S_IWUGO, ab3100_dir, &ab3100_set_priv, | 626 | S_IWUSR, ab3100_dir, &ab3100_set_priv, |
625 | &ab3100_get_set_reg_fops); | 627 | &ab3100_get_set_reg_fops); |
626 | if (!ab3100_set_reg_file) { | 628 | if (!ab3100_set_reg_file) { |
627 | err = -ENOMEM; | 629 | err = -ENOMEM; |
@@ -665,7 +667,7 @@ struct ab3100_init_setting { | |||
665 | u8 setting; | 667 | u8 setting; |
666 | }; | 668 | }; |
667 | 669 | ||
668 | static const struct ab3100_init_setting __initconst | 670 | static const struct ab3100_init_setting __devinitconst |
669 | ab3100_init_settings[] = { | 671 | ab3100_init_settings[] = { |
670 | { | 672 | { |
671 | .abreg = AB3100_MCA, | 673 | .abreg = AB3100_MCA, |
@@ -712,7 +714,7 @@ ab3100_init_settings[] = { | |||
712 | }, | 714 | }, |
713 | }; | 715 | }; |
714 | 716 | ||
715 | static int __init ab3100_setup(struct ab3100 *ab3100) | 717 | static int __devinit ab3100_setup(struct ab3100 *ab3100) |
716 | { | 718 | { |
717 | int err = 0; | 719 | int err = 0; |
718 | int i; | 720 | int i; |
@@ -742,52 +744,64 @@ static int __init ab3100_setup(struct ab3100 *ab3100) | |||
742 | return err; | 744 | return err; |
743 | } | 745 | } |
744 | 746 | ||
745 | /* | 747 | /* The subdevices of the AB3100 */ |
746 | * Here we define all the platform devices that appear | 748 | static struct mfd_cell ab3100_devs[] = { |
747 | * as children of the AB3100. These are regular platform | 749 | { |
748 | * devices with the IORESOURCE_IO .start and .end set | 750 | .name = "ab3100-dac", |
749 | * to correspond to the internal AB3100 register range | 751 | .id = -1, |
750 | * mapping to the corresponding subdevice. | 752 | }, |
751 | */ | 753 | { |
752 | 754 | .name = "ab3100-leds", | |
753 | #define AB3100_DEVICE(devname, devid) \ | 755 | .id = -1, |
754 | static struct platform_device ab3100_##devname##_device = { \ | 756 | }, |
755 | .name = devid, \ | 757 | { |
756 | .id = -1, \ | 758 | .name = "ab3100-power", |
757 | } | 759 | .id = -1, |
758 | 760 | }, | |
759 | /* This lists all the subdevices */ | 761 | { |
760 | AB3100_DEVICE(dac, "ab3100-dac"); | 762 | .name = "ab3100-regulators", |
761 | AB3100_DEVICE(leds, "ab3100-leds"); | 763 | .id = -1, |
762 | AB3100_DEVICE(power, "ab3100-power"); | 764 | }, |
763 | AB3100_DEVICE(regulators, "ab3100-regulators"); | 765 | { |
764 | AB3100_DEVICE(sim, "ab3100-sim"); | 766 | .name = "ab3100-sim", |
765 | AB3100_DEVICE(uart, "ab3100-uart"); | 767 | .id = -1, |
766 | AB3100_DEVICE(rtc, "ab3100-rtc"); | 768 | }, |
767 | AB3100_DEVICE(charger, "ab3100-charger"); | 769 | { |
768 | AB3100_DEVICE(boost, "ab3100-boost"); | 770 | .name = "ab3100-uart", |
769 | AB3100_DEVICE(adc, "ab3100-adc"); | 771 | .id = -1, |
770 | AB3100_DEVICE(fuelgauge, "ab3100-fuelgauge"); | 772 | }, |
771 | AB3100_DEVICE(vibrator, "ab3100-vibrator"); | 773 | { |
772 | AB3100_DEVICE(otp, "ab3100-otp"); | 774 | .name = "ab3100-rtc", |
773 | AB3100_DEVICE(codec, "ab3100-codec"); | 775 | .id = -1, |
774 | 776 | }, | |
775 | static struct platform_device * | 777 | { |
776 | ab3100_platform_devs[] = { | 778 | .name = "ab3100-charger", |
777 | &ab3100_dac_device, | 779 | .id = -1, |
778 | &ab3100_leds_device, | 780 | }, |
779 | &ab3100_power_device, | 781 | { |
780 | &ab3100_regulators_device, | 782 | .name = "ab3100-boost", |
781 | &ab3100_sim_device, | 783 | .id = -1, |
782 | &ab3100_uart_device, | 784 | }, |
783 | &ab3100_rtc_device, | 785 | { |
784 | &ab3100_charger_device, | 786 | .name = "ab3100-adc", |
785 | &ab3100_boost_device, | 787 | .id = -1, |
786 | &ab3100_adc_device, | 788 | }, |
787 | &ab3100_fuelgauge_device, | 789 | { |
788 | &ab3100_vibrator_device, | 790 | .name = "ab3100-fuelgauge", |
789 | &ab3100_otp_device, | 791 | .id = -1, |
790 | &ab3100_codec_device, | 792 | }, |
793 | { | ||
794 | .name = "ab3100-vibrator", | ||
795 | .id = -1, | ||
796 | }, | ||
797 | { | ||
798 | .name = "ab3100-otp", | ||
799 | .id = -1, | ||
800 | }, | ||
801 | { | ||
802 | .name = "ab3100-codec", | ||
803 | .id = -1, | ||
804 | }, | ||
791 | }; | 805 | }; |
792 | 806 | ||
793 | struct ab_family_id { | 807 | struct ab_family_id { |
@@ -795,7 +809,7 @@ struct ab_family_id { | |||
795 | char *name; | 809 | char *name; |
796 | }; | 810 | }; |
797 | 811 | ||
798 | static const struct ab_family_id ids[] __initdata = { | 812 | static const struct ab_family_id ids[] __devinitdata = { |
799 | /* AB3100 */ | 813 | /* AB3100 */ |
800 | { | 814 | { |
801 | .id = 0xc0, | 815 | .id = 0xc0, |
@@ -849,8 +863,8 @@ static const struct ab_family_id ids[] __initdata = { | |||
849 | }, | 863 | }, |
850 | }; | 864 | }; |
851 | 865 | ||
852 | static int __init ab3100_probe(struct i2c_client *client, | 866 | static int __devinit ab3100_probe(struct i2c_client *client, |
853 | const struct i2c_device_id *id) | 867 | const struct i2c_device_id *id) |
854 | { | 868 | { |
855 | struct ab3100 *ab3100; | 869 | struct ab3100 *ab3100; |
856 | struct ab3100_platform_data *ab3100_plf_data = | 870 | struct ab3100_platform_data *ab3100_plf_data = |
@@ -934,18 +948,14 @@ static int __init ab3100_probe(struct i2c_client *client, | |||
934 | if (err) | 948 | if (err) |
935 | goto exit_no_ops; | 949 | goto exit_no_ops; |
936 | 950 | ||
937 | /* Set parent and a pointer back to the container in device data */ | 951 | /* Set up and register the platform devices. */ |
938 | for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) { | 952 | for (i = 0; i < ARRAY_SIZE(ab3100_devs); i++) { |
939 | ab3100_platform_devs[i]->dev.parent = | 953 | ab3100_devs[i].platform_data = ab3100_plf_data; |
940 | &client->dev; | 954 | ab3100_devs[i].pdata_size = sizeof(struct ab3100_platform_data); |
941 | ab3100_platform_devs[i]->dev.platform_data = | ||
942 | ab3100_plf_data; | ||
943 | platform_set_drvdata(ab3100_platform_devs[i], ab3100); | ||
944 | } | 955 | } |
945 | 956 | ||
946 | /* Register the platform devices */ | 957 | err = mfd_add_devices(&client->dev, 0, ab3100_devs, |
947 | platform_add_devices(ab3100_platform_devs, | 958 | ARRAY_SIZE(ab3100_devs), NULL, 0); |
948 | ARRAY_SIZE(ab3100_platform_devs)); | ||
949 | 959 | ||
950 | ab3100_setup_debugfs(ab3100); | 960 | ab3100_setup_debugfs(ab3100); |
951 | 961 | ||
@@ -961,14 +971,12 @@ static int __init ab3100_probe(struct i2c_client *client, | |||
961 | return err; | 971 | return err; |
962 | } | 972 | } |
963 | 973 | ||
964 | static int __exit ab3100_remove(struct i2c_client *client) | 974 | static int __devexit ab3100_remove(struct i2c_client *client) |
965 | { | 975 | { |
966 | struct ab3100 *ab3100 = i2c_get_clientdata(client); | 976 | struct ab3100 *ab3100 = i2c_get_clientdata(client); |
967 | int i; | ||
968 | 977 | ||
969 | /* Unregister subdevices */ | 978 | /* Unregister subdevices */ |
970 | for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) | 979 | mfd_remove_devices(&client->dev); |
971 | platform_device_unregister(ab3100_platform_devs[i]); | ||
972 | 980 | ||
973 | ab3100_remove_debugfs(); | 981 | ab3100_remove_debugfs(); |
974 | i2c_unregister_device(ab3100->testreg_client); | 982 | i2c_unregister_device(ab3100->testreg_client); |
@@ -995,7 +1003,7 @@ static struct i2c_driver ab3100_driver = { | |||
995 | }, | 1003 | }, |
996 | .id_table = ab3100_id, | 1004 | .id_table = ab3100_id, |
997 | .probe = ab3100_probe, | 1005 | .probe = ab3100_probe, |
998 | .remove = __exit_p(ab3100_remove), | 1006 | .remove = __devexit_p(ab3100_remove), |
999 | }; | 1007 | }; |
1000 | 1008 | ||
1001 | static int __init ab3100_i2c_init(void) | 1009 | static int __init ab3100_i2c_init(void) |