mfd: MAX77665: carry over platform data for each cell
Charlie Huang [Wed, 12 Sep 2012 02:03:15 +0000 (19:03 -0700)]
Add feature to transfer design specific platform data from board
file(s) to the cell device drivers.

Change-Id: I788082a1606bd07d72835d81e39ef7cd04e67c1c
Signed-off-by: Charlie Huang <chahuang@nvidia.com>
(cherry picked from commit e10e95036f2678aef17afe3b527fa4ec17866679)
Reviewed on http://git-master/r/139118
Reviewed-on: http://git-master/r/141852
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>

drivers/mfd/max77665.c
include/linux/mfd/max77665.h

index b66712b..12a046a 100644 (file)
@@ -57,10 +57,10 @@ static const struct max77665_irq_data max77665_irqs[] = {
 };
 
 static struct mfd_cell max77665s[] = {
-       {.name = "max77665-charger",},
-       {.name = "max77665-flash",},
-       {.name = "max77665-muic",},
-       {.name = "max77665-haptic",},
+       [MAX77665_CELL_CHARGER] = {.name = "max77665-charger",},
+       [MAX77665_CELL_FLASH]   = {.name = "max77665-flash",},
+       [MAX77665_CELL_MUIC]    = {.name = "max77665-muic",},
+       [MAX77665_CELL_HAPTIC]  = {.name = "max77665-haptic",},
 };
 
 static void max77665_irq_lock(struct irq_data *data)
@@ -271,7 +271,6 @@ static int __devinit max77665_i2c_probe(struct i2c_client *client,
        max77665->dev = &client->dev;
 
        for (i = 0; i < MAX77665_I2C_SLAVE_MAX; ++i) {
-               slv_client = max77665->client[i];
                if (i == 0)
                        slv_client = client;
                else
@@ -282,6 +281,7 @@ static int __devinit max77665_i2c_probe(struct i2c_client *client,
                        ret = -ENOMEM;
                        goto err_exit;
                }
+               max77665->client[i] = slv_client;
                i2c_set_clientdata(slv_client, max77665);
 
                max77665->regmap[i] = devm_regmap_init_i2c(slv_client,
@@ -297,6 +297,26 @@ static int __devinit max77665_i2c_probe(struct i2c_client *client,
        if (client->irq > 0)
                max77665_irq_init(max77665, client->irq, pdata->irq_base);
 
+       max77665s[MAX77665_CELL_CHARGER].platform_data =
+                                       pdata->charger_platform_data.pdata;
+       max77665s[MAX77665_CELL_CHARGER].pdata_size =
+                                       pdata->charger_platform_data.size;
+
+       max77665s[MAX77665_CELL_FLASH].platform_data =
+                                       pdata->flash_platform_data.pdata;
+       max77665s[MAX77665_CELL_FLASH].pdata_size =
+                                       pdata->flash_platform_data.size;
+
+       max77665s[MAX77665_CELL_MUIC].platform_data =
+                                       pdata->muic_platform_data.pdata;
+       max77665s[MAX77665_CELL_MUIC].pdata_size =
+                                       pdata->muic_platform_data.size;
+
+       max77665s[MAX77665_CELL_HAPTIC].platform_data =
+                                       pdata->haptic_platform_data.pdata;
+       max77665s[MAX77665_CELL_HAPTIC].pdata_size =
+                                       pdata->haptic_platform_data.size;
+
        ret = mfd_add_devices(max77665->dev, -1, max77665s,
                ARRAY_SIZE(max77665s), NULL, 0);
        if (ret) {
index 380a1a4..c592d25 100644 (file)
@@ -37,6 +37,14 @@ enum {
        MAX77665_I2C_SLAVE_MAX,
 };
 
+enum {
+       MAX77665_CELL_CHARGER,
+       MAX77665_CELL_FLASH,
+       MAX77665_CELL_MUIC,
+       MAX77665_CELL_HAPTIC,
+       MAX77665_CELL_MAX,
+};
+
 struct max77665 {
        struct device           *dev;
        struct i2c_client       *client[MAX77665_I2C_SLAVE_MAX];
@@ -46,8 +54,17 @@ struct max77665 {
        int                     irq_base;
 };
 
+struct max77665_cell_data {
+       void *pdata;
+       size_t size;
+};
+
 struct max77665_platform_data {
        int irq_base;
+       struct max77665_cell_data charger_platform_data;
+       struct max77665_cell_data flash_platform_data;
+       struct max77665_cell_data muic_platform_data;
+       struct max77665_cell_data haptic_platform_data;
 };
 
 static inline int max77665_write(struct device *dev, int slv_id,