]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
Merge remote-tracking branch 'regulator/topic/tps516312' into regulator-next
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 10 Dec 2012 03:43:24 +0000 (12:43 +0900)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 10 Dec 2012 03:43:24 +0000 (12:43 +0900)
1  2 
drivers/regulator/tps51632-regulator.c

index 523b1e5e0b4c5137cb47bdebc6fa36992bb816cd,dc7023ebea87166f52e8ba030270954e91f6d12f..ab21133e6784dc43d5990de54427b4a64db9ca52
@@@ -106,23 -106,29 +106,23 @@@ static int tps51632_dcdc_get_voltage_se
        }
  
        vsel = data & TPS51632_VOUT_MASK;
 -
 -      if (vsel < TPS51632_MIN_VSEL)
 -              return 0;
 -      else
 -              return vsel - TPS51632_MIN_VSEL;
 +      return vsel;
  }
  
  static int tps51632_dcdc_set_voltage_sel(struct regulator_dev *rdev,
                unsigned selector)
  {
        struct tps51632_chip *tps = rdev_get_drvdata(rdev);
 -      int vsel;
        int ret;
        unsigned int reg = TPS51632_VOLTAGE_SELECT_REG;
  
        if (tps->enable_pwm_dvfs)
                reg = TPS51632_VOLTAGE_BASE_REG;
  
 -      vsel = selector + TPS51632_MIN_VSEL;
 -      if (vsel > TPS51632_MAX_VSEL)
 +      if (selector > TPS51632_MAX_VSEL)
                return -EINVAL;
  
 -      ret = regmap_write(tps->regmap, reg, vsel);
 +      ret = regmap_write(tps->regmap, reg, selector);
        if (ret < 0)
                dev_err(tps->dev, "reg write failed, err %d\n", ret);
        return ret;
@@@ -151,7 -157,7 +151,7 @@@ static struct regulator_ops tps51632_dc
        .set_ramp_delay         = tps51632_dcdc_set_ramp_delay,
  };
  
 -static int __devinit tps51632_init_dcdc(struct tps51632_chip *tps,
 +static int tps51632_init_dcdc(struct tps51632_chip *tps,
                struct tps51632_regulator_platform_data *pdata)
  {
        int ret;
@@@ -221,7 -227,7 +221,7 @@@ static const struct regmap_config tps51
        .cache_type             = REGCACHE_RBTREE,
  };
  
 -static int __devinit tps51632_probe(struct i2c_client *client,
 +static int tps51632_probe(struct i2c_client *client,
                                const struct i2c_device_id *id)
  {
        struct tps51632_regulator_platform_data *pdata;
                return -EINVAL;
        }
  
+       if (pdata->enable_pwm_dvfs) {
+               if ((pdata->base_voltage_uV < TPS51632_MIN_VOLATGE) ||
+                   (pdata->base_voltage_uV > TPS51632_MAX_VOLATGE)) {
+                       dev_err(&client->dev, "Invalid base_voltage_uV setting\n");
+                       return -EINVAL;
+               }
+               if ((pdata->max_voltage_uV) &&
+                   ((pdata->max_voltage_uV < TPS51632_MIN_VOLATGE) ||
+                    (pdata->max_voltage_uV > TPS51632_MAX_VOLATGE))) {
+                       dev_err(&client->dev, "Invalid max_voltage_uV setting\n");
+                       return -EINVAL;
+               }
+       }
        tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
        if (!tps) {
                dev_err(&client->dev, "Memory allocation failed\n");
        tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY;
        tps->desc.min_uV = TPS51632_MIN_VOLATGE;
        tps->desc.uV_step = TPS51632_VOLATGE_STEP_10mV;
 -      tps->desc.n_voltages = (TPS51632_MAX_VSEL - TPS51632_MIN_VSEL) + 1;
 +      tps->desc.linear_min_sel = TPS51632_MIN_VSEL;
 +      tps->desc.n_voltages = TPS51632_MAX_VSEL + 1;
        tps->desc.ops = &tps51632_dcdc_ops;
        tps->desc.type = REGULATOR_VOLTAGE;
        tps->desc.owner = THIS_MODULE;
        return 0;
  }
  
 -static int __devexit tps51632_remove(struct i2c_client *client)
 +static int tps51632_remove(struct i2c_client *client)
  {
        struct tps51632_chip *tps = i2c_get_clientdata(client);
  
@@@ -306,7 -326,7 +321,7 @@@ static struct i2c_driver tps51632_i2c_d
                .owner = THIS_MODULE,
        },
        .probe = tps51632_probe,
 -      .remove = __devexit_p(tps51632_remove),
 +      .remove = tps51632_remove,
        .id_table = tps51632_id,
  };