Skip to content

Commit 8c96aef

Browse files
Linus WalleijSamuel Ortiz
authored andcommitted
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>
1 parent 2524468 commit 8c96aef

2 files changed

Lines changed: 69 additions & 61 deletions

File tree

‎drivers/mfd/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ config ABX500_CORE
444444
config AB3100_CORE
445445
bool "ST-Ericsson AB3100 Mixed Signal Circuit core functions"
446446
depends on I2C=y && ABX500_CORE
447+
select MFD_CORE
447448
default y if ARCH_U300
448449
help
449450
Select this to enable the AB3100 Mixed Signal IC core

‎drivers/mfd/ab3100-core.c‎

Lines changed: 68 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/debugfs.h>
2020
#include <linux/seq_file.h>
2121
#include <linux/uaccess.h>
22+
#include <linux/mfd/core.h>
2223
#include <linux/mfd/abx500.h>
2324

2425
/* 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,
146147
}
147148

148149
static int ab3100_get_register_interruptible(struct ab3100 *ab3100,
149-
u8 reg, u8 *regval)
150+
u8 reg, u8 *regval)
150151
{
151152
int err;
152153

@@ -202,7 +203,7 @@ static int ab3100_get_register_interruptible(struct ab3100 *ab3100,
202203
}
203204

204205
static int get_register_interruptible(struct device *dev, u8 bank, u8 reg,
205-
u8 *value)
206+
u8 *value)
206207
{
207208
struct ab3100 *ab3100 = dev_get_drvdata(dev->parent);
208209

@@ -743,52 +744,64 @@ static int __devinit ab3100_setup(struct ab3100 *ab3100)
743744
return err;
744745
}
745746

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+
},
792805
};
793806

794807
struct ab_family_id {
@@ -935,18 +948,14 @@ static int __devinit ab3100_probe(struct i2c_client *client,
935948
if (err)
936949
goto exit_no_ops;
937950

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);
945955
}
946956

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);
950959

951960
ab3100_setup_debugfs(ab3100);
952961

@@ -965,11 +974,9 @@ static int __devinit ab3100_probe(struct i2c_client *client,
965974
static int __devexit ab3100_remove(struct i2c_client *client)
966975
{
967976
struct ab3100 *ab3100 = i2c_get_clientdata(client);
968-
int i;
969977

970978
/* 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);
973980

974981
ab3100_remove_debugfs();
975982
i2c_unregister_device(ab3100->testreg_client);

0 commit comments

Comments
 (0)