Commit 8c96aefbe79becf940d27cd8ad2c5aba48322162

Authored by Linus Walleij
Committed by Samuel Ortiz
1 parent 2524468ee5

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>

Showing 2 changed files with 69 additions and 61 deletions Side-by-side Diff

... ... @@ -444,6 +444,7 @@
444 444 config AB3100_CORE
445 445 bool "ST-Ericsson AB3100 Mixed Signal Circuit core functions"
446 446 depends on I2C=y && ABX500_CORE
  447 + select MFD_CORE
447 448 default y if ARCH_U300
448 449 help
449 450 Select this to enable the AB3100 Mixed Signal IC core
drivers/mfd/ab3100-core.c
... ... @@ -19,6 +19,7 @@
19 19 #include <linux/debugfs.h>
20 20 #include <linux/seq_file.h>
21 21 #include <linux/uaccess.h>
  22 +#include <linux/mfd/core.h>
22 23 #include <linux/mfd/abx500.h>
23 24  
24 25 /* These are the only registers inside AB3100 used in this main file */
... ... @@ -146,7 +147,7 @@
146 147 }
147 148  
148 149 static int ab3100_get_register_interruptible(struct ab3100 *ab3100,
149   - u8 reg, u8 *regval)
  150 + u8 reg, u8 *regval)
150 151 {
151 152 int err;
152 153  
... ... @@ -202,7 +203,7 @@
202 203 }
203 204  
204 205 static int get_register_interruptible(struct device *dev, u8 bank, u8 reg,
205   - u8 *value)
  206 + u8 *value)
206 207 {
207 208 struct ab3100 *ab3100 = dev_get_drvdata(dev->parent);
208 209  
... ... @@ -743,52 +744,64 @@
743 744 return err;
744 745 }
745 746  
746   -/*
747   - * Here we define all the platform devices that appear
748   - * as children of the AB3100. These are regular platform
749   - * devices with the IORESOURCE_IO .start and .end set
750   - * to correspond to the internal AB3100 register range
751   - * mapping to the corresponding subdevice.
752   - */
753   -
754   -#define AB3100_DEVICE(devname, devid) \
755   -static struct platform_device ab3100_##devname##_device = { \
756   - .name = devid, \
757   - .id = -1, \
758   -}
759   -
760   -/* This lists all the subdevices */
761   -AB3100_DEVICE(dac, "ab3100-dac");
762   -AB3100_DEVICE(leds, "ab3100-leds");
763   -AB3100_DEVICE(power, "ab3100-power");
764   -AB3100_DEVICE(regulators, "ab3100-regulators");
765   -AB3100_DEVICE(sim, "ab3100-sim");
766   -AB3100_DEVICE(uart, "ab3100-uart");
767   -AB3100_DEVICE(rtc, "ab3100-rtc");
768   -AB3100_DEVICE(charger, "ab3100-charger");
769   -AB3100_DEVICE(boost, "ab3100-boost");
770   -AB3100_DEVICE(adc, "ab3100-adc");
771   -AB3100_DEVICE(fuelgauge, "ab3100-fuelgauge");
772   -AB3100_DEVICE(vibrator, "ab3100-vibrator");
773   -AB3100_DEVICE(otp, "ab3100-otp");
774   -AB3100_DEVICE(codec, "ab3100-codec");
775   -
776   -static struct platform_device *
777   -ab3100_platform_devs[] = {
778   - &ab3100_dac_device,
779   - &ab3100_leds_device,
780   - &ab3100_power_device,
781   - &ab3100_regulators_device,
782   - &ab3100_sim_device,
783   - &ab3100_uart_device,
784   - &ab3100_rtc_device,
785   - &ab3100_charger_device,
786   - &ab3100_boost_device,
787   - &ab3100_adc_device,
788   - &ab3100_fuelgauge_device,
789   - &ab3100_vibrator_device,
790   - &ab3100_otp_device,
791   - &ab3100_codec_device,
  747 +/* The subdevices of the AB3100 */
  748 +static struct mfd_cell ab3100_devs[] = {
  749 + {
  750 + .name = "ab3100-dac",
  751 + .id = -1,
  752 + },
  753 + {
  754 + .name = "ab3100-leds",
  755 + .id = -1,
  756 + },
  757 + {
  758 + .name = "ab3100-power",
  759 + .id = -1,
  760 + },
  761 + {
  762 + .name = "ab3100-regulators",
  763 + .id = -1,
  764 + },
  765 + {
  766 + .name = "ab3100-sim",
  767 + .id = -1,
  768 + },
  769 + {
  770 + .name = "ab3100-uart",
  771 + .id = -1,
  772 + },
  773 + {
  774 + .name = "ab3100-rtc",
  775 + .id = -1,
  776 + },
  777 + {
  778 + .name = "ab3100-charger",
  779 + .id = -1,
  780 + },
  781 + {
  782 + .name = "ab3100-boost",
  783 + .id = -1,
  784 + },
  785 + {
  786 + .name = "ab3100-adc",
  787 + .id = -1,
  788 + },
  789 + {
  790 + .name = "ab3100-fuelgauge",
  791 + .id = -1,
  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  
794 807 struct ab_family_id {
795 808  
... ... @@ -935,18 +948,14 @@
935 948 if (err)
936 949 goto exit_no_ops;
937 950  
938   - /* Set parent and a pointer back to the container in device data */
939   - for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++) {
940   - ab3100_platform_devs[i]->dev.parent =
941   - &client->dev;
942   - ab3100_platform_devs[i]->dev.platform_data =
943   - ab3100_plf_data;
944   - platform_set_drvdata(ab3100_platform_devs[i], ab3100);
  951 + /* Set up and register the platform devices. */
  952 + for (i = 0; i < ARRAY_SIZE(ab3100_devs); i++) {
  953 + ab3100_devs[i].platform_data = ab3100_plf_data;
  954 + ab3100_devs[i].data_size = sizeof(struct ab3100_platform_data);
945 955 }
946 956  
947   - /* Register the platform devices */
948   - platform_add_devices(ab3100_platform_devs,
949   - ARRAY_SIZE(ab3100_platform_devs));
  957 + err = mfd_add_devices(&client->dev, 0, ab3100_devs,
  958 + ARRAY_SIZE(ab3100_devs), NULL, 0);
950 959  
951 960 ab3100_setup_debugfs(ab3100);
952 961  
953 962  
... ... @@ -965,11 +974,9 @@
965 974 static int __devexit ab3100_remove(struct i2c_client *client)
966 975 {
967 976 struct ab3100 *ab3100 = i2c_get_clientdata(client);
968   - int i;
969 977  
970 978 /* Unregister subdevices */
971   - for (i = 0; i < ARRAY_SIZE(ab3100_platform_devs); i++)
972   - platform_device_unregister(ab3100_platform_devs[i]);
  979 + mfd_remove_devices(&client->dev);
973 980  
974 981 ab3100_remove_debugfs();
975 982 i2c_unregister_device(ab3100->testreg_client);