]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/regulator/core.c
regulator: Support voltage offsets to compensate for drops in system
[mv-sheeva.git] / drivers / regulator / core.c
index a2728a498c3f4a31bceb99c390498daf5c173879..58452ac0f165fa0b54025252d34eb8c206e68719 100644 (file)
@@ -724,6 +724,10 @@ static void print_constraints(struct regulator_dev *rdev)
                        count += sprintf(buf + count, "at %d mV ", ret / 1000);
        }
 
+       if (constraints->uV_offset)
+               count += sprintf(buf, "%dmV offset ",
+                                constraints->uV_offset / 1000);
+
        if (constraints->min_uA && constraints->max_uA) {
                if (constraints->min_uA == constraints->max_uA)
                        count += sprintf(buf + count, "%d mA ",
@@ -1504,13 +1508,14 @@ static int _regulator_force_disable(struct regulator_dev *rdev,
  */
 int regulator_force_disable(struct regulator *regulator)
 {
+       struct regulator_dev *rdev = regulator->rdev;
        struct regulator_dev *supply_rdev = NULL;
        int ret;
 
-       mutex_lock(&regulator->rdev->mutex);
+       mutex_lock(&rdev->mutex);
        regulator->uA_load = 0;
-       ret = _regulator_force_disable(regulator->rdev, &supply_rdev);
-       mutex_unlock(&regulator->rdev->mutex);
+       ret = _regulator_force_disable(rdev, &supply_rdev);
+       mutex_unlock(&rdev->mutex);
 
        if (supply_rdev)
                regulator_disable(get_device_regulator(rdev_get_dev(supply_rdev)));
@@ -1640,6 +1645,9 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
 
        trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV);
 
+       min_uV += rdev->constraints->uV_offset;
+       max_uV += rdev->constraints->uV_offset;
+
        if (rdev->desc->ops->set_voltage) {
                ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV,
                                                   &selector);
@@ -1864,18 +1872,20 @@ EXPORT_SYMBOL_GPL(regulator_sync_voltage);
 
 static int _regulator_get_voltage(struct regulator_dev *rdev)
 {
-       int sel;
+       int sel, ret;
 
        if (rdev->desc->ops->get_voltage_sel) {
                sel = rdev->desc->ops->get_voltage_sel(rdev);
                if (sel < 0)
                        return sel;
-               return rdev->desc->ops->list_voltage(rdev, sel);
+               ret = rdev->desc->ops->list_voltage(rdev, sel);
        }
        if (rdev->desc->ops->get_voltage)
-               return rdev->desc->ops->get_voltage(rdev);
+               ret = rdev->desc->ops->get_voltage(rdev);
        else
                return -EINVAL;
+
+       return ret - rdev->constraints->uV_offset;
 }
 
 /**
@@ -2595,14 +2605,6 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
        if (ret < 0)
                goto scrub;
 
-       /* set supply regulator if it exists */
-       if (init_data->supply_regulator && init_data->supply_regulator_dev) {
-               dev_err(dev,
-                       "Supply regulator specified by both name and dev\n");
-               ret = -EINVAL;
-               goto scrub;
-       }
-
        if (init_data->supply_regulator) {
                struct regulator_dev *r;
                int found = 0;
@@ -2627,14 +2629,6 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
                        goto scrub;
        }
 
-       if (init_data->supply_regulator_dev) {
-               dev_warn(dev, "Uses supply_regulator_dev instead of regulator_supply\n");
-               ret = set_supply(rdev,
-                       dev_get_drvdata(init_data->supply_regulator_dev));
-               if (ret < 0)
-                       goto scrub;
-       }
-
        /* add consumers devices */
        for (i = 0; i < init_data->num_consumer_supplies; i++) {
                ret = set_consumer_device_supply(rdev,