aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@stericsson.com>2010-08-20 04:27:12 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2010-10-28 18:28:42 -0400
commit8c96aefbe79becf940d27cd8ad2c5aba48322162 (patch)
treedc073c93d95ebecfd44e2c404ba137170aeca631 /drivers/mfd
parent2524468ee586e7ba25bd5a0551acf1fea7e9a0b3 (diff)
mfd: Switch AB3100 to use MFD cells
This switches the AB3100 core driver to using MFD cells for subdevices instead of spawning common platform devices. Signed-off-by: Linus Walleij <linus.walleij@stericsson.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/Kconfig1
-rw-r--r--drivers/mfd/ab3100-core.c129
2 files changed, 69 insertions, 61 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index db51ea1c6082..b3aedaaa7092 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -444,6 +444,7 @@ config ABX500_CORE
444config AB3100_CORE 444config AB3100_CORE
445 bool "ST-Ericsson AB3100 Mixed Signal Circuit core functions" 445 bool "ST-Ericsson AB3100 Mixed Signal Circuit core functions"
446 depends on I2C=y && ABX500_CORE 446 depends on I2C=y && ABX500_CORE
447 select MFD_CORE
447 default y if ARCH_U300 448 default y if ARCH_U300
448 help 449 help
449 Select this to enable the AB3100 Mixed Signal IC core 450 Select this to enable the AB3100 Mixed Signal IC core
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 6733d56cbb52..4193af5f2743 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
148static int ab3100_get_register_interruptible(struct ab3100 *ab3100, 149static 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
204static int get_register_interruptible(struct device *dev, u8 bank, u8 reg, 205static 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
@@ -743,52 +744,64 @@ static int __devinit ab3100_setup(struct ab3100 *ab3100)
743 return err; 744 return err;
744} 745}
745 746
746/* 747/* The subdevices of the AB3100 */
747 * Here we define all the platform devices that appear 748static struct mfd_cell ab3100_devs[] = {
748 * as children of the AB3100. These are regular platform 749 {
749 * devices with the IORESOURCE_IO .start and .end set 750 .name = "ab3100-dac",
750 * to correspond to the internal AB3100 register range 751 .id = -1,
751 * mapping to the corresponding subdevice. 752 },
752 */ 753 {
753 754 .name = "ab3100-leds",
754#define AB3100_DEVICE(devname, devid) \ 755 .id = -1,
755static struct platform_device ab3100_##devname##_device = { \ 756 },
756 .name = devid, \ 757 {
757 .id = -1, \ 758 .name = "ab3100-power",
758} 759 .id = -1,
759 760 },
760/* This lists all the subdevices */ 761 {
761AB3100_DEVICE(dac, "ab3100-dac"); 762 .name = "ab3100-regulators",
762AB3100_DEVICE(leds, "ab3100-leds"); 763 .id = -1,
763AB3100_DEVICE(power, "ab3100-power"); 764 },
764AB3100_DEVICE(regulators, "ab3100-regulators"); 765 {
765AB3100_DEVICE(sim, "ab3100-sim"); 766 .name = "ab3100-sim",
766AB3100_DEVICE(uart, "ab3100-uart"); 767 .id = -1,
767AB3100_DEVICE(rtc, "ab3100-rtc"); 768 },
768AB3100_DEVICE(charger, "ab3100-charger"); 769 {
769AB3100_DEVICE(boost, "ab3100-boost"); 770 .name = "ab3100-uart",
770AB3100_DEVICE(adc, "ab3100-adc"); 771 .id = -1,
771AB3100_DEVICE(fuelgauge, "ab3100-fuelgauge"); 772 },
772AB3100_DEVICE(vibrator, "ab3100-vibrator"); 773 {
773AB3100_DEVICE(otp, "ab3100-otp"); 774 .name = "ab3100-rtc",
774AB3100_DEVICE(codec, "ab3100-codec"); 775 .id = -1,
775 776 },
776static struct platform_device * 777 {
777ab3100_platform_devs[] = { 778 .name = "ab3100-charger",
778 &ab3100_dac_device, 779 .id = -1,
779 &ab3100_leds_device, 780 },
780 &ab3100_power_device, 781 {
781 &ab3100_regulators_device, 782 .name = "ab3100-boost",
782 &ab3100_sim_device, 783 .id = -1,
783 &ab3100_uart_device, 784 },
784 &ab3100_rtc_device, 785 {
785 &ab3100_charger_device, 786 .name = "ab3100-adc",
786 &ab3100_boost_device, 787 .id = -1,
787 &ab3100_adc_device, 788 },
788 &ab3100_fuelgauge_device, 789 {
789 &ab3100_vibrator_device, 790 .name = "ab3100-fuelgauge",
790 &ab3100_otp_device, 791 .id = -1,
791 &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 },
792}; 805};
793 806
794struct ab_family_id { 807struct ab_family_id {
@@ -935,18 +948,14 @@ static int __devinit ab3100_probe(struct i2c_client *client,
935 if (err) 948 if (err)
936 goto exit_no_ops; 949 goto exit_no_ops;
937 950
938 /* Set parent and a pointer back to the container in device data */ 951 /* Set up and register the platform devices. */
939 for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) { 952 for (i = 0; i < ARRAY_SIZE(ab3100_devs); i++) {
940 ab3100_platform_devs[i]->dev.parent = 953 ab3100_devs[i].platform_data = ab3100_plf_data;
941 &client->dev; 954 ab3100_devs[i].data_size = sizeof(struct ab3100_platform_data);
942 ab3100_platform_devs[i]->dev.platform_data =
943 ab3100_plf_data;
944 platform_set_drvdata(ab3100_platform_devs[i], ab3100);
945 } 955 }
946 956
947 /* Register the platform devices */ 957 err = mfd_add_devices(&client->dev, 0, ab3100_devs,
948 platform_add_devices(ab3100_platform_devs, 958 ARRAY_SIZE(ab3100_devs), NULL, 0);
949 ARRAY_SIZE(ab3100_platform_devs));
950 959
951 ab3100_setup_debugfs(ab3100); 960 ab3100_setup_debugfs(ab3100);
952 961
@@ -965,11 +974,9 @@ static int __devinit ab3100_probe(struct i2c_client *client,
965static int __devexit ab3100_remove(struct i2c_client *client) 974static int __devexit ab3100_remove(struct i2c_client *client)
966{ 975{
967 struct ab3100 *ab3100 = i2c_get_clientdata(client); 976 struct ab3100 *ab3100 = i2c_get_clientdata(client);
968 int i;
969 977
970 /* Unregister subdevices */ 978 /* Unregister subdevices */
971 for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) 979 mfd_remove_devices(&client->dev);
972 platform_device_unregister(ab3100_platform_devs[i]);
973 980
974 ab3100_remove_debugfs(); 981 ab3100_remove_debugfs();
975 i2c_unregister_device(ab3100->testreg_client); 982 i2c_unregister_device(ab3100->testreg_client);