rk808:support dcdc1\2 raise voltage by step
author张晴 <zhangqing@rock-chips.com>
Mon, 22 Apr 2013 09:20:54 +0000 (17:20 +0800)
committer张晴 <zhangqing@rock-chips.com>
Mon, 22 Apr 2013 09:20:54 +0000 (17:20 +0800)
drivers/mfd/rk808.c

index 30bae3db1e7186ff3424735e098c6c9490a046a0..80b153126e8ae4ee14d1a049e6d68e30b7a1a6c5 100755 (executable)
@@ -39,6 +39,8 @@
 #define PM_CONTROL
 
 struct rk808 *g_rk808;
+#define DCDC_RAISE_VOL_BYSTEP 1
+#define DCDC_VOL_STEP 25000  //25mv
 
 static struct mfd_cell rk808s[] = {
        {
@@ -413,14 +415,34 @@ static int rk808_dcdc_set_voltage(struct regulator_dev *dev,
        struct rk808 *rk808 = rdev_get_drvdata(dev);
        int buck = rdev_get_id(dev) - RK808_DCDC1;
        u16 val;
-       int ret = 0;
+       int ret = 0,old_voltage =0,vol_temp =0;
 
        if (buck ==2){
-       return 0;
-       }else{
-       val = rk808_dcdc_select_min_voltage(dev,min_uV,max_uV,buck);
-       
-       ret = rk808_set_bits(rk808, rk808_BUCK_SET_VOL_REG(buck), BUCK_VOL_MASK, val);
+               return 0;
+       }else if (buck==3){
+               val = rk808_dcdc_select_min_voltage(dev,min_uV,max_uV,buck);    
+               ret = rk808_set_bits(rk808, rk808_BUCK_SET_VOL_REG(buck), BUCK_VOL_MASK, val);
+       }
+       else {
+#if defined(DCDC_RAISE_VOL_BYSTEP)
+               old_voltage = rk808_dcdc_get_voltage(dev);
+                       if (max_uV >old_voltage){
+                               vol_temp = old_voltage;
+                              do{
+                                       vol_temp +=   DCDC_VOL_STEP;
+                                       val = rk808_dcdc_select_min_voltage(dev,vol_temp,vol_temp,buck);
+                               //      printk("rk808_dcdc_set_voltage buck = %d vol_temp= %d old_voltage= %d min_uV =%d \n",buck,vol_temp,old_voltage,min_uV);
+                                       ret = rk808_set_bits(rk808, rk808_BUCK_SET_VOL_REG(buck), BUCK_VOL_MASK, val);  
+                               }while(vol_temp != max_uV);
+                       }
+                       else{
+                               val = rk808_dcdc_select_min_voltage(dev,min_uV,max_uV,buck);
+                               ret = rk808_set_bits(rk808, rk808_BUCK_SET_VOL_REG(buck), BUCK_VOL_MASK, val);
+                       }
+#else
+               val = rk808_dcdc_select_min_voltage(dev,min_uV,max_uV,buck);
+               ret = rk808_set_bits(rk808, rk808_BUCK_SET_VOL_REG(buck), BUCK_VOL_MASK, val);
+#endif
        }
        return ret;
 }