rk:act8846:support regulator_set_voltage_time, disable act8846 gpio3 when power on
author张晴 <zhangqing@rock-chips.com>
Thu, 24 Jan 2013 07:33:01 +0000 (15:33 +0800)
committer张晴 <zhangqing@rock-chips.com>
Thu, 24 Jan 2013 07:33:01 +0000 (15:33 +0800)
drivers/regulator/act8846.c

index 181a9b502ab928922c44f782f01625f51391002a..4775e1d5e32a517a9e4209e2aa1ec80387c135d8 100755 (executable)
@@ -430,6 +430,23 @@ static int act8846_dcdc_set_mode(struct regulator_dev *dev, unsigned int mode)
 
 
 }
+static int act8846_dcdc_set_voltage_time_sel(struct regulator_dev *dev,   unsigned int old_selector,
+                                    unsigned int new_selector)
+{
+       struct act8846 *act8846 = rdev_get_drvdata(dev);
+       int ret =0,old_volt, new_volt;
+       
+       old_volt = act8846_dcdc_list_voltage(dev, old_selector);
+       if (old_volt < 0)
+               return old_volt;
+       
+       new_volt = act8846_dcdc_list_voltage(dev, new_selector);
+       if (new_volt < 0)
+               return new_volt;
+
+       return DIV_ROUND_UP(abs(old_volt - new_volt)*2, 25000);
+}
+
 static struct regulator_ops act8846_dcdc_ops = { 
        .set_voltage = act8846_dcdc_set_voltage,
        .get_voltage = act8846_dcdc_get_voltage,
@@ -440,6 +457,7 @@ static struct regulator_ops act8846_dcdc_ops = {
        .get_mode = act8846_dcdc_get_mode,
        .set_mode = act8846_dcdc_set_mode,
        .set_suspend_voltage = act8846_dcdc_set_sleep_voltage,
+       .set_voltage_time_sel = act8846_dcdc_set_voltage_time_sel,
 };
 static struct regulator_desc regulators[] = {
 
@@ -726,6 +744,12 @@ static int __devinit act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_
                printk("The device is not act8846 \n");
                return 0;
        }
+
+       ret = act8846_set_bits(act8846, 0xf4,(0x1<<7),(0x0<<7));
+       if (ret < 0) {
+               printk("act8846 set 0xf4 error!\n");
+               goto err;
+       }
        
        if (pdata) {
                ret = setup_regulators(act8846, pdata);