regulator: as3722 : SD0 init val based on boardid
Prabhu Kuttiyam [Thu, 19 Dec 2013 00:07:03 +0000 (16:07 -0800)]
Decide the PMIC version based on board id as
AMS PMIC rev id is not correct in silicon.
Add DT support also.

Bug 1425474

Change-Id: Ia51462980da582c958a26e156b48a1e5d655559f
Signed-off-by: Prabhu Kuttiyam <pkuttiyam@nvidia.com>
Reviewed-on: http://git-master/r/347241
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Tested-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>

drivers/mfd/as3722.c
drivers/regulator/as3722-regulator.c
include/linux/mfd/as3722-plat.h
include/linux/mfd/as3722.h

index 3c55238..46329eb 100644 (file)
@@ -370,6 +370,8 @@ static int as3722_i2c_of_probe(struct i2c_client *i2c,
                                        "ams,enable-internal-i2c-pullup");
        as3722->irq_flags = irqd_get_trigger_type(irq_data);
        as3722->irq_base = -1;
+       of_property_read_u32(np, "ams,major-rev", &as3722->major_rev);
+       of_property_read_u32(np, "ams,minor-rev", &as3722->minor_rev);
        dev_dbg(&i2c->dev, "IRQ flags are 0x%08lx\n", as3722->irq_flags);
        return 0;
 }
@@ -386,6 +388,8 @@ static int as3722_i2c_non_of_probe(struct i2c_client *i2c,
        as3722->irq_base = pdata->irq_base;
        as3722->en_intern_i2c_pullup = pdata->use_internal_i2c_pullup;
        as3722->en_intern_int_pullup = pdata->use_internal_int_pullup;
+       as3722->major_rev = pdata->major_rev;
+       as3722->minor_rev = pdata->minor_rev;
        return 0;
 }
 
index 83a4276..f63a842 100644 (file)
@@ -785,7 +785,6 @@ static int as3722_regulator_probe(struct platform_device *pdev)
        struct regulator_ops *ops;
        int id;
        int ret;
-       u32 val;
 
        as3722_regs = devm_kzalloc(&pdev->dev, sizeof(*as3722_regs),
                                GFP_KERNEL);
@@ -863,11 +862,14 @@ static int as3722_regulator_probe(struct platform_device *pdev)
                        else
                                ops = &as3722_sd016_ops;
                        if (id == AS3722_REGULATOR_ID_SD0) {
-                               as3722_read(as3722, AS3722_FUSE15, &val);
-                               if ((val & AS3722_NCELL_MASK) == 1)
-                                       as3722_regs->desc[id].min_uV = 610000;
-                               else if ((val & AS3722_NCELL_MASK) == 2)
+                               /* AMS version revision id is wrong in silicon
+                                * and therefore this woraround to decide based
+                                * on boardID
+                                */
+                               if (as3722_device_rev(as3722, 1, 2))
                                        as3722_regs->desc[id].min_uV = 410000;
+                               else
+                                       as3722_regs->desc[id].min_uV = 610000;
                        } else
                                as3722_regs->desc[id].min_uV = 610000;
                        as3722_regs->desc[id].uV_step = 10000;
index 9c6aa34..7a50838 100644 (file)
@@ -156,6 +156,8 @@ struct as3722_platform_data {
        struct as3722_adc_extcon_platform_data *extcon_pdata;
        int watchdog_timer_initial_period;
        int watchdog_timer_mode;
+       u32 major_rev;
+       u32 minor_rev;
        bool enable_clk32k_out;
 };
 
index dc79030..ad51056 100644 (file)
@@ -405,6 +405,8 @@ struct as3722 {
        bool en_intern_int_pullup;
        bool en_intern_i2c_pullup;
        struct regmap_irq_chip_data *irq_data;
+       u32 major_rev;
+       u32 minor_rev;
 };
 
 static inline int as3722_read(struct as3722 *as3722, u32 reg, u32 *dest)
@@ -440,4 +442,14 @@ static inline int as3722_irq_get_virq(struct as3722 *as3722, int irq)
        return regmap_irq_get_virq(as3722->irq_data, irq);
 }
 
+static inline bool as3722_device_rev(struct as3722 *as3722, u32 major_rev,
+               u32 minor_rev)
+{
+
+       if ((as3722->major_rev == major_rev) &&
+                       (as3722->minor_rev == minor_rev))
+               return true;
+       else
+               return false;
+}
 #endif