regulator: tps65090: add wait_timeout support for FETx
Yen Lin [Thu, 29 Nov 2012 22:39:44 +0000 (14:39 -0800)]
Add platform data for wait_timeout value for FETx.

bug 1178161

Signed-off-by: Yen Lin <yelin@nvidia.com>
Change-Id: I12eedd48dd4bfcabfe3fa9ae08afff6399e94abf
Reviewed-on: http://git-master/r/167476
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Allen Martin <amartin@nvidia.com>

drivers/regulator/tps65090-regulator.c
include/linux/mfd/tps65090.h
include/linux/regulator/tps65090-regulator.h

index 4d28dc1..0030240 100644 (file)
@@ -45,6 +45,7 @@ struct tps65090_regulator {
        bool                            enable_ext_control;
        int                             gpio;
        int                             gpio_state;
+       int                             wait_timeout_us;
 };
 
 static inline struct device *to_tps65090_dev(struct regulator_dev *rdev)
@@ -97,6 +98,27 @@ static int tps65090_reg_enable(struct regulator_dev *rdev)
                return 0;
        }
 
+       /* Setup wait_time for current limited timeout, WTFET[1:0]@bits[3:2] */
+       if (ri->wait_timeout_us > 0) {
+               int wait_timeout = ri->wait_timeout_us;
+               u8 en_reg = ri->rinfo->reg_en_reg;
+
+               if (wait_timeout <= 200)
+                       ret = tps65090_update_bits(parent, en_reg, 0xc, 0x0);
+               else if (wait_timeout <= 800)
+                       ret = tps65090_update_bits(parent, en_reg, 0xc, 0x4);
+               else if (wait_timeout <= 1600)
+                       ret = tps65090_update_bits(parent, en_reg, 0xc, 0x8);
+               else
+                       ret = tps65090_update_bits(parent, en_reg, 0xc, 0xc);
+
+               if (ret < 0) {
+                       dev_err(&rdev->dev, "Error updating reg 0x%x WTFET\n",
+                               en_reg);
+                       return ret;
+               }
+       }
+
        ret = tps65090_set_bits(parent, ri->rinfo->reg_en_reg,
                                ri->rinfo->en_bit);
        if (ret < 0)
@@ -289,6 +311,7 @@ static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
                ri = &pmic[num];
                ri->dev = &pdev->dev;
                ri->rinfo = rinfo;
+               ri->wait_timeout_us = tps_pdata->wait_timeout_us;
 
                if (is_dcdc(id)) {
                        ret = tps65090_regulator_preinit(id, ri, tps_pdata);
index 61352ea..ec0d7dc 100644 (file)
@@ -108,4 +108,12 @@ static inline int tps65090_clr_bits(struct device *dev, int reg,
        return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u);
 }
 
+static inline int tps65090_update_bits(struct device *dev, int reg,
+               uint8_t bit_mask, uint8_t val)
+{
+       struct tps65090 *tps = dev_get_drvdata(dev);
+
+       return regmap_update_bits(tps->rmap, reg, bit_mask, val);
+}
+
 #endif /*__LINUX_MFD_TPS65090_H */
index 785ca84..e8a94f3 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Regulator driver interface for TI TPS65090 PMIC family
  *
@@ -47,6 +48,11 @@ enum {
  *     DCDC1, DCDC2 and DCDC3.
  * @gpio: Gpio number if external control is enabled and controlled through
  *     gpio.
+ * @wait_timeout_us: wait timeout in microseconds;
+ *     >0 : specify minimum wait timeout in us for FETx, will update WTFET[1:0]
+ *          in FETx_CTRL reg;
+ *      0 : not to update WTFET[1:0] in FETx_CTRL reg for FETx;
+ *     -1 : for non-FETx.
  */
 
 struct tps65090_regulator_platform_data {
@@ -54,6 +60,7 @@ struct tps65090_regulator_platform_data {
        bool enable_ext_control;
        int gpio;
        struct regulator_init_data *reg_init_data;
+       int wait_timeout_us;
 };
 
 #endif /* __REGULATOR_TPS65090_H */