power: tps80031: battery-charger: register as mfd sub device
Laxman Dewangan [Wed, 1 Aug 2012 11:14:29 +0000 (16:14 +0530)]
Register battery charger driver of TPS80031 as mfd
sub driver in place of adding it as a sub devices.
This is inline with the mfd driver policy.

Change-Id: I8cff39f5c9b22434f7c5b9d4ed9f3865ff4c0001
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/121135
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>

arch/arm/mach-tegra/board-enterprise-power.c
drivers/mfd/tps80031.c
drivers/power/tps80031-charger.c
include/linux/mfd/tps80031.h

index b908edb..86f0bcd 100644 (file)
@@ -333,23 +333,16 @@ static struct tps80031_bg_platform_data battery_gauge_data = {
        .battery_present = 1,
 };
 
-#define TPS_BATTERY()                                  \
-       {                                               \
-               .name   = "tps80031-charger",           \
-               .platform_data = &bcharger_pdata,       \
-       }
 #define TPS_GPADC()                                    \
        {                                               \
                .name   = "tps80031-gpadc",             \
        }
 
 #define TPS80031_DEVS_COMMON           \
-       TPS_BATTERY(),                  \
        TPS_GPADC()
 
 
 static struct tps80031_subdev_info tps80031_devs[] = {
-       TPS_BATTERY(),
        TPS_GPADC()
 };
 
@@ -437,6 +430,7 @@ static struct tps80031_platform_data tps_platform = {
        .use_power_off  = true,
        .rtc_pdata = &rtc_data,
        .bg_pdata = &battery_gauge_data,
+       .battery_charger_pdata = &bcharger_pdata,
 };
 
 static struct i2c_board_info __initdata enterprise_regulators[] = {
index f9f3f09..f496c36 100644 (file)
@@ -308,6 +308,9 @@ static struct mfd_cell tps80031_cell[] = {
        {
                .name = "tps80031-battery-gauge",
        },
+       {
+               .name = "tps80031-charger",
+       },
 };
 
 
index 70a3657..edbcfcc 100644 (file)
@@ -353,10 +353,18 @@ static int tps80031_charger_probe(struct platform_device *pdev)
        int ret = 0;
        struct device *dev = &pdev->dev;
        struct tps80031_charger *charger;
-       struct tps80031_charger_platform_data *pdata = pdev->dev.platform_data;
+       struct tps80031_platform_data *tps80031_pdata;
+       struct tps80031_charger_platform_data *pdata;
 
        dev_info(dev, "%s()\n", __func__);
 
+       tps80031_pdata = dev_get_platdata(pdev->dev.parent);
+       if (!tps80031_pdata) {
+               dev_err(&pdev->dev, "no tps80031 platform_data specified\n");
+               return -EINVAL;
+       }
+
+       pdata = tps80031_pdata->battery_charger_pdata;
        if (!pdata) {
                dev_err(dev, "%s() No platform data, exiting..\n", __func__);
                return -ENODEV;
index d3371a7..573c8a5 100644 (file)
@@ -206,6 +206,7 @@ struct tps80031_platform_data {
        int num_regulator_pdata;
        struct tps80031_rtc_platform_data *rtc_pdata;
        struct tps80031_bg_platform_data *bg_pdata;
+       struct tps80031_charger_platform_data *battery_charger_pdata;
 };