Commit 63236f40 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'regulator/topic/drivers' into regulator-next

parents 16fbcc3b ca61a7bf
This diff is collapsed.
...@@ -10,43 +10,49 @@ obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o ...@@ -10,43 +10,49 @@ obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o
obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o
obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o
obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o obj-$(CONFIG_REGULATOR_MAX8925) += max8925-regulator.o
obj-$(CONFIG_REGULATOR_MAX8952) += max8952.o obj-$(CONFIG_REGULATOR_MAX8952) += max8952.o
obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o
obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o
obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o
obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o
obj-$(CONFIG_REGULATOR_TPS65217) += tps65217-regulator.o
obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o
obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o
obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <linux/mfd/aat2870.h> #include <linux/mfd/aat2870.h>
struct aat2870_regulator { struct aat2870_regulator {
struct platform_device *pdev; struct aat2870_data *aat2870;
struct regulator_desc desc; struct regulator_desc desc;
const int *voltages; /* uV */ const int *voltages; /* uV */
...@@ -60,7 +60,7 @@ static int aat2870_ldo_set_voltage_sel(struct regulator_dev *rdev, ...@@ -60,7 +60,7 @@ static int aat2870_ldo_set_voltage_sel(struct regulator_dev *rdev,
unsigned selector) unsigned selector)
{ {
struct aat2870_regulator *ri = rdev_get_drvdata(rdev); struct aat2870_regulator *ri = rdev_get_drvdata(rdev);
struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); struct aat2870_data *aat2870 = ri->aat2870;
return aat2870->update(aat2870, ri->voltage_addr, ri->voltage_mask, return aat2870->update(aat2870, ri->voltage_addr, ri->voltage_mask,
selector << ri->voltage_shift); selector << ri->voltage_shift);
...@@ -69,7 +69,7 @@ static int aat2870_ldo_set_voltage_sel(struct regulator_dev *rdev, ...@@ -69,7 +69,7 @@ static int aat2870_ldo_set_voltage_sel(struct regulator_dev *rdev,
static int aat2870_ldo_get_voltage_sel(struct regulator_dev *rdev) static int aat2870_ldo_get_voltage_sel(struct regulator_dev *rdev)
{ {
struct aat2870_regulator *ri = rdev_get_drvdata(rdev); struct aat2870_regulator *ri = rdev_get_drvdata(rdev);
struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); struct aat2870_data *aat2870 = ri->aat2870;
u8 val; u8 val;
int ret; int ret;
...@@ -83,7 +83,7 @@ static int aat2870_ldo_get_voltage_sel(struct regulator_dev *rdev) ...@@ -83,7 +83,7 @@ static int aat2870_ldo_get_voltage_sel(struct regulator_dev *rdev)
static int aat2870_ldo_enable(struct regulator_dev *rdev) static int aat2870_ldo_enable(struct regulator_dev *rdev)
{ {
struct aat2870_regulator *ri = rdev_get_drvdata(rdev); struct aat2870_regulator *ri = rdev_get_drvdata(rdev);
struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); struct aat2870_data *aat2870 = ri->aat2870;
return aat2870->update(aat2870, ri->enable_addr, ri->enable_mask, return aat2870->update(aat2870, ri->enable_addr, ri->enable_mask,
ri->enable_mask); ri->enable_mask);
...@@ -92,7 +92,7 @@ static int aat2870_ldo_enable(struct regulator_dev *rdev) ...@@ -92,7 +92,7 @@ static int aat2870_ldo_enable(struct regulator_dev *rdev)
static int aat2870_ldo_disable(struct regulator_dev *rdev) static int aat2870_ldo_disable(struct regulator_dev *rdev)
{ {
struct aat2870_regulator *ri = rdev_get_drvdata(rdev); struct aat2870_regulator *ri = rdev_get_drvdata(rdev);
struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); struct aat2870_data *aat2870 = ri->aat2870;
return aat2870->update(aat2870, ri->enable_addr, ri->enable_mask, 0); return aat2870->update(aat2870, ri->enable_addr, ri->enable_mask, 0);
} }
...@@ -100,7 +100,7 @@ static int aat2870_ldo_disable(struct regulator_dev *rdev) ...@@ -100,7 +100,7 @@ static int aat2870_ldo_disable(struct regulator_dev *rdev)
static int aat2870_ldo_is_enabled(struct regulator_dev *rdev) static int aat2870_ldo_is_enabled(struct regulator_dev *rdev)
{ {
struct aat2870_regulator *ri = rdev_get_drvdata(rdev); struct aat2870_regulator *ri = rdev_get_drvdata(rdev);
struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); struct aat2870_data *aat2870 = ri->aat2870;
u8 val; u8 val;
int ret; int ret;
...@@ -185,7 +185,7 @@ static int aat2870_regulator_probe(struct platform_device *pdev) ...@@ -185,7 +185,7 @@ static int aat2870_regulator_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Invalid device ID, %d\n", pdev->id); dev_err(&pdev->dev, "Invalid device ID, %d\n", pdev->id);
return -EINVAL; return -EINVAL;
} }
ri->pdev = pdev; ri->aat2870 = dev_get_drvdata(pdev->dev.parent);
rdev = regulator_register(&ri->desc, &pdev->dev, rdev = regulator_register(&ri->desc, &pdev->dev,
pdev->dev.platform_data, ri, NULL); pdev->dev.platform_data, ri, NULL);
......
...@@ -201,7 +201,7 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector) ...@@ -201,7 +201,7 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)
return info->voltages[selector]; return info->voltages[selector];
} }
static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
{ {
int ret, val; int ret, val;
struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
...@@ -229,11 +229,9 @@ static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) ...@@ -229,11 +229,9 @@ static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)
/* vintcore has a different layout */ /* vintcore has a different layout */
val = regval & info->voltage_mask; val = regval & info->voltage_mask;
if (info->desc.id == AB8500_LDO_INTCORE) if (info->desc.id == AB8500_LDO_INTCORE)
ret = info->voltages[val >> 0x3]; return val >> 0x3;
else else
ret = info->voltages[val]; return val;
return ret;
} }
static int ab8500_get_best_voltage_index(struct regulator_dev *rdev, static int ab8500_get_best_voltage_index(struct regulator_dev *rdev,
...@@ -320,7 +318,7 @@ static struct regulator_ops ab8500_regulator_ops = { ...@@ -320,7 +318,7 @@ static struct regulator_ops ab8500_regulator_ops = {
.enable = ab8500_regulator_enable, .enable = ab8500_regulator_enable,
.disable = ab8500_regulator_disable, .disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled, .is_enabled = ab8500_regulator_is_enabled,
.get_voltage = ab8500_regulator_get_voltage, .get_voltage_sel = ab8500_regulator_get_voltage_sel,
.set_voltage = ab8500_regulator_set_voltage, .set_voltage = ab8500_regulator_set_voltage,
.list_voltage = ab8500_list_voltage, .list_voltage = ab8500_list_voltage,
.enable_time = ab8500_regulator_enable_time, .enable_time = ab8500_regulator_enable_time,
......
...@@ -94,8 +94,8 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int ...@@ -94,8 +94,8 @@ static int ad5398_set_current_limit(struct regulator_dev *rdev, int min_uA, int
if (max_uA > chip->max_uA || max_uA < chip->min_uA) if (max_uA > chip->max_uA || max_uA < chip->min_uA)
return -EINVAL; return -EINVAL;
selector = ((min_uA - chip->min_uA) * chip->current_level + selector = DIV_ROUND_UP((min_uA - chip->min_uA) * chip->current_level,
range_uA - 1) / range_uA; range_uA);
if (ad5398_calc_current(chip, selector) > max_uA) if (ad5398_calc_current(chip, selector) > max_uA)
return -EINVAL; return -EINVAL;
......
/*
* Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
*/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/mfd/anatop.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
struct anatop_regulator {
const char *name;
u32 control_reg;
struct anatop *mfd;
int vol_bit_shift;
int vol_bit_width;
int min_bit_val;
int min_voltage;
int max_voltage;
struct regulator_desc rdesc;
struct regulator_init_data *initdata;
};
static int anatop_set_voltage(struct regulator_dev *reg, int min_uV,
int max_uV, unsigned *selector)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
u32 val, sel;
int uv;
uv = min_uV;
dev_dbg(&reg->dev, "%s: uv %d, min %d, max %d\n", __func__,
uv, anatop_reg->min_voltage,
anatop_reg->max_voltage);
if (uv < anatop_reg->min_voltage) {
if (max_uV > anatop_reg->min_voltage)
uv = anatop_reg->min_voltage;
else
return -EINVAL;
}
if (!anatop_reg->control_reg)
return -ENOTSUPP;
sel = DIV_ROUND_UP(uv - anatop_reg->min_voltage, 25000);
if (sel * 25000 + anatop_reg->min_voltage > anatop_reg->max_voltage)
return -EINVAL;
val = anatop_reg->min_bit_val + sel;
*selector = sel;
dev_dbg(&reg->dev, "%s: calculated val %d\n", __func__, val);
anatop_set_bits(anatop_reg->mfd,
anatop_reg->control_reg,
anatop_reg->vol_bit_shift,
anatop_reg->vol_bit_width,
val);
return 0;
}
static int anatop_get_voltage_sel(struct regulator_dev *reg)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
u32 val;
if (!anatop_reg->control_reg)
return -ENOTSUPP;
val = anatop_get_bits(anatop_reg->mfd,
anatop_reg->control_reg,
anatop_reg->vol_bit_shift,
anatop_reg->vol_bit_width);
return val - anatop_reg->min_bit_val;
}
static int anatop_list_voltage(struct regulator_dev *reg, unsigned selector)
{
struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
int uv;
uv = anatop_reg->min_voltage + selector * 25000;
dev_dbg(&reg->dev, "vddio = %d, selector = %u\n", uv, selector);
return uv;
}
static struct regulator_ops anatop_rops = {
.set_voltage = anatop_set_voltage,
.get_voltage_sel = anatop_get_voltage_sel,
.list_voltage = anatop_list_voltage,
};
static int __devinit anatop_regulator_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct regulator_desc *rdesc;
struct regulator_dev *rdev;
struct anatop_regulator *sreg;
struct regulator_init_data *initdata;
struct anatop *anatopmfd = dev_get_drvdata(pdev->dev.parent);
int ret = 0;
initdata = of_get_regulator_init_data(dev, np);
sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL);
if (!sreg)
return -ENOMEM;
sreg->initdata = initdata;
sreg->name = kstrdup(of_get_property(np, "regulator-name", NULL),
GFP_KERNEL);
rdesc = &sreg->rdesc;
memset(rdesc, 0, sizeof(*rdesc));
rdesc->name = sreg->name;
rdesc->ops = &anatop_rops;
rdesc->type = REGULATOR_VOLTAGE;
rdesc->owner = THIS_MODULE;
sreg->mfd = anatopmfd;
ret = of_property_read_u32(np, "reg", &sreg->control_reg);
if (ret) {
dev_err(dev, "no reg property set\n");
goto anatop_probe_end;
}
ret = of_property_read_u32(np, "anatop-vol-bit-width",
&sreg->vol_bit_width);
if (ret) {
dev_err(dev, "no anatop-vol-bit-width property set\n");
goto anatop_probe_end;
}
ret = of_property_read_u32(np, "anatop-vol-bit-shift",
&sreg->vol_bit_shift);
if (ret) {
dev_err(dev, "no anatop-vol-bit-shift property set\n");
goto anatop_probe_end;
}
ret = of_property_read_u32(np, "anatop-min-bit-val",
&sreg->min_bit_val);
if (ret) {
dev_err(dev, "no anatop-min-bit-val property set\n");
goto anatop_probe_end;
}
ret = of_property_read_u32(np, "anatop-min-voltage",
&sreg->min_voltage);
if (ret) {
dev_err(dev, "no anatop-min-voltage property set\n");
goto anatop_probe_end;
}
ret = of_property_read_u32(np, "anatop-max-voltage",
&sreg->max_voltage);
if (ret) {
dev_err(dev, "no anatop-max-voltage property set\n");
goto anatop_probe_end;
}
rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage)
/ 25000 + 1;
/* register regulator */
rdev = regulator_register(rdesc, dev,
initdata, sreg, pdev->dev.of_node);
if (IS_ERR(rdev)) {
dev_err(dev, "failed to register %s\n",
rdesc->name);
ret = PTR_ERR(rdev);
goto anatop_probe_end;
}
platform_set_drvdata(pdev, rdev);
anatop_probe_end:
if (ret)
kfree(sreg->name);
return ret;
}
static int __devexit anatop_regulator_remove(struct platform_device *pdev)
{
struct regulator_dev *rdev = platform_get_drvdata(pdev);
struct anatop_regulator *sreg = rdev_get_drvdata(rdev);
const char *name = sreg->name;
regulator_unregister(rdev);
kfree(name);
return 0;
}
static struct of_device_id __devinitdata of_anatop_regulator_match_tbl[] = {
{ .compatible = "fsl,anatop-regulator", },
{ /* end */ }
};
static struct platform_driver anatop_regulator = {
.driver = {
.name = "anatop_regulator",
.owner = THIS_MODULE,
.of_match_table = of_anatop_regulator_match_tbl,
},
.probe = anatop_regulator_probe,
.remove = anatop_regulator_remove,
};
static int __init anatop_regulator_init(void)
{
return platform_driver_register(&anatop_regulator);
}
postcore_initcall(anatop_regulator_init);
static void __exit anatop_regulator_exit(void)
{
platform_driver_unregister(&anatop_regulator);
}
module_exit(anatop_regulator_exit);
MODULE_AUTHOR("Nancy Chen <Nancy.Chen@freescale.com>, "
"Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>");
MODULE_DESCRIPTION("ANATOP Regulator driver");
MODULE_LICENSE("GPL v2");
...@@ -119,7 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev, ...@@ -119,7 +119,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
*selector = val; *selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -202,7 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev, ...@@ -202,7 +202,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
*selector = val; *selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -233,10 +233,10 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev, ...@@ -233,10 +233,10 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
thresh = (info->max_uV + info->min_uV) / 2; thresh = (info->max_uV + info->min_uV) / 2;
if (min_uV < thresh) { if (min_uV < thresh) {
val = (thresh - min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(thresh - min_uV, info->step_uV);
val |= 0x4; val |= 0x4;
} else { } else {
val = (min_uV - thresh + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - thresh, info->step_uV);
} }
*selector = val; *selector = val;
...@@ -281,7 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev, ...@@ -281,7 +281,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
*selector = val; *selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -307,7 +307,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev, ...@@ -307,7 +307,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
val = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; val = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val); val = (val >= 20) ? val - 12 : ((val > 7) ? 8 : val);
*selector = val; *selector = val;
val <<= info->vol_shift; val <<= info->vol_shift;
......
...@@ -18,74 +18,11 @@ ...@@ -18,74 +18,11 @@
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/regulator/db8500-prcmu.h> #include <linux/regulator/db8500-prcmu.h>
#include <linux/module.h> #include <linux/module.h>
#include "dbx500-prcmu.h"
/*
* power state reference count
*/
static int power_state_active_cnt; /* will initialize to zero */
static DEFINE_SPINLOCK(power_state_active_lock);
static void power_state_active_enable(void)
{
unsigned long flags;
spin_lock_irqsave(&power_state_active_lock, flags);
power_state_active_cnt++;
spin_unlock_irqrestore(&power_state_active_lock, flags);
}
static int power_state_active_disable(void)
{
int ret = 0;
unsigned long flags;
spin_lock_irqsave(&power_state_active_lock, flags);
if (power_state_active_cnt <= 0) {
pr_err("power state: unbalanced enable/disable calls\n");
ret = -EINVAL;
goto out;
}
power_state_active_cnt--;
out:
spin_unlock_irqrestore(&power_state_active_lock, flags);
return ret;
}
/*
* Exported interface for CPUIdle only. This function is called when interrupts
* are turned off. Hence, no locking.
*/
int power_state_active_is_enabled(void)
{
return (power_state_active_cnt > 0);
}
/**
* struct db8500_regulator_info - db8500 regulator information
* @dev: device pointer
* @desc: regulator description
* @rdev: regulator device pointer
* @is_enabled: status of the regulator
* @epod_id: id for EPOD (power domain)
* @is_ramret: RAM retention switch for EPOD (power domain)
* @operating_point: operating point (only for vape, to be removed)
*
*/
struct db8500_regulator_info {
struct device *dev;
struct regulator_desc desc;
struct regulator_dev *rdev;
bool is_enabled;
u16 epod_id;
bool is_ramret;
bool exclude_from_power_state;
unsigned int operating_point;
};
static int db8500_regulator_enable(struct regulator_dev *rdev) static int db8500_regulator_enable(struct regulator_dev *rdev)
{ {
struct db8500_regulator_info *info = rdev_get_drvdata(rdev); struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
if (info == NULL) if (info == NULL)
return -EINVAL; return -EINVAL;
...@@ -93,16 +30,18 @@ static int db8500_regulator_enable(struct regulator_dev *rdev) ...@@ -93,16 +30,18 @@ static int db8500_regulator_enable(struct regulator_dev *rdev)
dev_vdbg(rdev_get_dev(rdev), "regulator-%s-enable\n", dev_vdbg(rdev_get_dev(rdev), "regulator-%s-enable\n",
info->desc.name); info->desc.name);
if (!info->is_enabled) {
info->is_enabled = true; info->is_enabled = true;
if (!info->exclude_from_power_state) if (!info->exclude_from_power_state)
power_state_active_enable(); power_state_active_enable();
}
return 0; return 0;
} }
static int db8500_regulator_disable(struct regulator_dev *rdev) static int db8500_regulator_disable(struct regulator_dev *rdev)
{ {
struct db8500_regulator_info *info = rdev_get_drvdata(rdev); struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
int ret = 0; int ret = 0;
if (info == NULL) if (info == NULL)
...@@ -111,16 +50,18 @@ static int db8500_regulator_disable(struct regulator_dev *rdev) ...@@ -111,16 +50,18 @@ static int db8500_regulator_disable(struct regulator_dev *rdev)
dev_vdbg(rdev_get_dev(rdev), "regulator-%s-disable\n", dev_vdbg(rdev_get_dev(rdev), "regulator-%s-disable\n",
info->desc.name); info->desc.name);
if (info->is_enabled) {
info->is_enabled = false; info->is_enabled = false;
if (!info->exclude_from_power_state) if (!info->exclude_from_power_state)
ret = power_state_active_disable(); ret = power_state_active_disable();
}
return ret; return ret;
} }
static int db8500_regulator_is_enabled(struct regulator_dev *rdev) static int db8500_regulator_is_enabled(struct regulator_dev *rdev)
{ {
struct db8500_regulator_info *info = rdev_get_drvdata(rdev); struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
if (info == NULL) if (info == NULL)
return -EINVAL; return -EINVAL;
...@@ -197,7 +138,7 @@ static int disable_epod(u16 epod_id, bool ramret) ...@@ -197,7 +138,7 @@ static int disable_epod(u16 epod_id, bool ramret)
*/ */
static int db8500_regulator_switch_enable(struct regulator_dev *rdev) static int db8500_regulator_switch_enable(struct regulator_dev *rdev)
{ {
struct db8500_regulator_info *info = rdev_get_drvdata(rdev); struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
int ret; int ret;
if (info == NULL) if (info == NULL)
...@@ -221,7 +162,7 @@ static int db8500_regulator_switch_enable(struct regulator_dev *rdev) ...@@ -221,7 +162,7 @@ static int db8500_regulator_switch_enable(struct regulator_dev *rdev)
static int db8500_regulator_switch_disable(struct regulator_dev *rdev) static int db8500_regulator_switch_disable(struct regulator_dev *rdev)
{ {
struct db8500_regulator_info *info = rdev_get_drvdata(rdev); struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
int ret; int ret;
if (info == NULL) if (info == NULL)
...@@ -245,7 +186,7 @@ static int db8500_regulator_switch_disable(struct regulator_dev *rdev) ...@@ -245,7 +186,7 @@ static int db8500_regulator_switch_disable(struct regulator_dev *rdev)
static int db8500_regulator_switch_is_enabled(struct regulator_dev *rdev) static int db8500_regulator_switch_is_enabled(struct regulator_dev *rdev)
{ {
struct db8500_regulator_info *info = rdev_get_drvdata(rdev); struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
if (info == NULL) if (info == NULL)
return -EINVAL; return -EINVAL;
...@@ -266,8 +207,8 @@ static struct regulator_ops db8500_regulator_switch_ops = { ...@@ -266,8 +207,8 @@ static struct regulator_ops db8500_regulator_switch_ops = {
/* /*
* Regulator information * Regulator information
*/ */
static struct db8500_regulator_info static struct dbx500_regulator_info
db8500_regulator_info[DB8500_NUM_REGULATORS] = { dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
[DB8500_REGULATOR_VAPE] = { [DB8500_REGULATOR_VAPE] = {
.desc = { .desc = {
.name = "db8500-vape", .name = "db8500-vape",
...@@ -476,12 +417,12 @@ static int __devinit db8500_regulator_probe(struct platform_device *pdev) ...@@ -476,12 +417,12 @@ static int __devinit db8500_regulator_probe(struct platform_device *pdev)
int i, err; int i, err;
/* register all regulators */ /* register all regulators */
for (i = 0; i < ARRAY_SIZE(db8500_regulator_info); i++) { for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
struct db8500_regulator_info *info; struct dbx500_regulator_info *info;
struct regulator_init_data *init_data = &db8500_init_data[i]; struct regulator_init_data *init_data = &db8500_init_data[i];
/* assign per-regulator data */ /* assign per-regulator data */
info = &db8500_regulator_info[i]; info = &dbx500_regulator_info[i];
info->dev = &pdev->dev; info->dev = &pdev->dev;
/* register with the regulator framework */ /* register with the regulator framework */
...@@ -494,7 +435,7 @@ static int __devinit db8500_regulator_probe(struct platform_device *pdev) ...@@ -494,7 +435,7 @@ static int __devinit db8500_regulator_probe(struct platform_device *pdev)
/* if failing, unregister all earlier regulators */ /* if failing, unregister all earlier regulators */
while (--i >= 0) { while (--i >= 0) {
info = &db8500_regulator_info[i]; info = &dbx500_regulator_info[i];
regulator_unregister(info->rdev); regulator_unregister(info->rdev);
} }
return err; return err;
...@@ -503,17 +444,22 @@ static int __devinit db8500_regulator_probe(struct platform_device *pdev) ...@@ -503,17 +444,22 @@ static int __devinit db8500_regulator_probe(struct platform_device *pdev)
dev_dbg(rdev_get_dev(info->rdev), dev_dbg(rdev_get_dev(info->rdev),
"regulator-%s-probed\n", info->desc.name); "regulator-%s-probed\n", info->desc.name);
} }
err = ux500_regulator_debug_init(pdev,
dbx500_regulator_info,
ARRAY_SIZE(dbx500_regulator_info));
return 0; return err;
} }
static int __exit db8500_regulator_remove(struct platform_device *pdev) static int __exit db8500_regulator_remove(struct platform_device *pdev)
{ {
int i; int i;
for (i = 0; i < ARRAY_SIZE(db8500_regulator_info); i++) { ux500_regulator_debug_exit();
struct db8500_regulator_info *info;
info = &db8500_regulator_info[i]; for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
struct dbx500_regulator_info *info;
info = &dbx500_regulator_info[i];
dev_vdbg(rdev_get_dev(info->rdev), dev_vdbg(rdev_get_dev(info->rdev),
"regulator-%s-remove\n", info->desc.name); "regulator-%s-remove\n", info->desc.name);
......
/*
* Copyright (C) ST-Ericsson SA 2010
*
* License Terms: GNU General Public License v2
* Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
* Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
*
* UX500 common part of Power domain regulators
*/
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/regulator/driver.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include "dbx500-prcmu.h"
/*
* power state reference count
*/
static int power_state_active_cnt; /* will initialize to zero */
static DEFINE_SPINLOCK(power_state_active_lock);
int power_state_active_get(void)
{
unsigned long flags;
int cnt;
spin_lock_irqsave(&power_state_active_lock, flags);
cnt = power_state_active_cnt;
spin_unlock_irqrestore(&power_state_active_lock, flags);
return cnt;
}
void power_state_active_enable(void)
{
unsigned long flags;
spin_lock_irqsave(&power_state_active_lock, flags);
power_state_active_cnt++;
spin_unlock_irqrestore(&power_state_active_lock, flags);
}
int power_state_active_disable(void)
{
int ret = 0;
unsigned long flags;
spin_lock_irqsave(&power_state_active_lock, flags);
if (power_state_active_cnt <= 0) {
pr_err("power state: unbalanced enable/disable calls\n");
ret = -EINVAL;
goto out;
}
power_state_active_cnt--;
out:
spin_unlock_irqrestore(&power_state_active_lock, flags);
return ret;
}
#ifdef CONFIG_REGULATOR_DEBUG
static struct ux500_regulator_debug {
struct dentry *dir;
struct dentry *status_file;
struct dentry *power_state_cnt_file;
struct dbx500_regulator_info *regulator_array;
int num_regulators;
u8 *state_before_suspend;
u8 *state_after_suspend;
} rdebug;
void ux500_regulator_suspend_debug(void)
{
int i;
for (i = 0; i < rdebug.num_regulators; i++)
rdebug.state_before_suspend[i] =
rdebug.regulator_array[i].is_enabled;
}
void ux500_regulator_resume_debug(void)
{
int i;
for (i = 0; i < rdebug.num_regulators; i++)
rdebug.state_after_suspend[i] =
rdebug.regulator_array[i].is_enabled;
}
static int ux500_regulator_power_state_cnt_print(struct seq_file *s, void *p)
{
struct device *dev = s->private;
int err;
/* print power state count */
err = seq_printf(s, "ux500-regulator power state count: %i\n",
power_state_active_get());
if (err < 0)
dev_err(dev, "seq_printf overflow\n");
return 0;
}
static int ux500_regulator_power_state_cnt_open(struct inode *inode,
struct file *file)
{
return single_open(file, ux500_regulator_power_state_cnt_print,
inode->i_private);
}
static const struct file_operations ux500_regulator_power_state_cnt_fops = {
.open = ux500_regulator_power_state_cnt_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};
static int ux500_regulator_status_print(struct seq_file *s, void *p)
{
struct device *dev = s->private;
int err;
int i;
/* print dump header */
err = seq_printf(s, "ux500-regulator status:\n");
if (err < 0)
dev_err(dev, "seq_printf overflow\n");
err = seq_printf(s, "%31s : %8s : %8s\n", "current",
"before", "after");
if (err < 0)
dev_err(dev, "seq_printf overflow\n");
for (i = 0; i < rdebug.num_regulators; i++) {
struct dbx500_regulator_info *info;
/* Access per-regulator data */
info = &rdebug.regulator_array[i];
/* print status */
err = seq_printf(s, "%20s : %8s : %8s : %8s\n", info->desc.name,
info->is_enabled ? "enabled" : "disabled",
rdebug.state_before_suspend[i] ? "enabled" : "disabled",
rdebug.state_after_suspend[i] ? "enabled" : "disabled");
if (err < 0)
dev_err(dev, "seq_printf overflow\n");
}
return 0;
}
static int ux500_regulator_status_open(struct inode *inode, struct file *file)
{
return single_open(file, ux500_regulator_status_print,
inode->i_private);
}
static const struct file_operations ux500_regulator_status_fops = {
.open = ux500_regulator_status_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};
int __attribute__((weak)) dbx500_regulator_testcase(
struct dbx500_regulator_info *regulator_info,
int num_regulators)
{
return 0;
}
int __devinit
ux500_regulator_debug_init(struct platform_device *pdev,
struct dbx500_regulator_info *regulator_info,
int num_regulators)
{
/* create directory */
rdebug.dir = debugfs_create_dir("ux500-regulator", NULL);
if (!rdebug.dir)
goto exit_no_debugfs;
/* create "status" file */
rdebug.status_file = debugfs_create_file("status",
S_IRUGO, rdebug.dir, &pdev->dev,
&ux500_regulator_status_fops);
if (!rdebug.status_file)
goto exit_destroy_dir;
/* create "power-state-count" file */
rdebug.power_state_cnt_file = debugfs_create_file("power-state-count",
S_IRUGO, rdebug.dir, &pdev->dev,
&ux500_regulator_power_state_cnt_fops);
if (!rdebug.power_state_cnt_file)
goto exit_destroy_status;
rdebug.regulator_array = regulator_info;
rdebug.num_regulators = num_regulators;
rdebug.state_before_suspend = kzalloc(num_regulators, GFP_KERNEL);
if (!rdebug.state_before_suspend) {
dev_err(&pdev->dev,
"could not allocate memory for saving state\n");
goto exit_destroy_power_state;
}
rdebug.state_after_suspend = kzalloc(num_regulators, GFP_KERNEL);
if (!rdebug.state_after_suspend) {
dev_err(&pdev->dev,
"could not allocate memory for saving state\n");
goto exit_free;
}
dbx500_regulator_testcase(regulator_info, num_regulators);
return 0;
exit_free:
kfree(rdebug.state_before_suspend);
exit_destroy_power_state:
debugfs_remove(rdebug.power_state_cnt_file);
exit_destroy_status:
debugfs_remove(rdebug.status_file);
exit_destroy_dir:
debugfs_remove(rdebug.dir);
exit_no_debugfs:
dev_err(&pdev->dev, "failed to create debugfs entries.\n");
return -ENOMEM;
}
int __devexit ux500_regulator_debug_exit(void)
{
debugfs_remove_recursive(rdebug.dir);
kfree(rdebug.state_after_suspend);
kfree(rdebug.state_before_suspend);
return 0;
}
#endif
/*
* Copyright (C) ST-Ericsson SA 2010
*
* Author: Bengt Jonsson <bengt.jonsson@stericsson.com> for ST-Ericsson,
* Jonas Aaberg <jonas.aberg@stericsson.com> for ST-Ericsson
*
* License Terms: GNU General Public License v2
*
*/
#ifndef DBX500_REGULATOR_H
#define DBX500_REGULATOR_H
#include <linux/platform_device.h>
/**
* struct dbx500_regulator_info - dbx500 regulator information
* @dev: device pointer
* @desc: regulator description
* @rdev: regulator device pointer
* @is_enabled: status of the regulator
* @epod_id: id for EPOD (power domain)
* @is_ramret: RAM retention switch for EPOD (power domain)
* @operating_point: operating point (only for vape, to be removed)
*
*/
struct dbx500_regulator_info {
struct device *dev;
struct regulator_desc desc;
struct regulator_dev *rdev;
bool is_enabled;
u16 epod_id;
bool is_ramret;
bool exclude_from_power_state;
unsigned int operating_point;
};
void power_state_active_enable(void);
int power_state_active_disable(void);
#ifdef CONFIG_REGULATOR_DEBUG
int ux500_regulator_debug_init(struct platform_device *pdev,
struct dbx500_regulator_info *regulator_info,
int num_regulators);
int ux500_regulator_debug_exit(void);
#else
static inline int ux500_regulator_debug_init(struct platform_device *pdev,
struct dbx500_regulator_info *regulator_info,
int num_regulators)
{
return 0;
}
static inline int ux500_regulator_debug_exit(void)
{
return 0;
}
#endif
#endif
...@@ -192,6 +192,8 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) ...@@ -192,6 +192,8 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev)
drvdata->desc.type = REGULATOR_VOLTAGE; drvdata->desc.type = REGULATOR_VOLTAGE;
drvdata->desc.owner = THIS_MODULE; drvdata->desc.owner = THIS_MODULE;
drvdata->desc.ops = &fixed_voltage_ops; drvdata->desc.ops = &fixed_voltage_ops;
if (config->microvolts)
drvdata->desc.n_voltages = 1; drvdata->desc.n_voltages = 1;
drvdata->microvolts = config->microvolts; drvdata->microvolts = config->microvolts;
......
...@@ -63,23 +63,15 @@ static int isl6271a_set_voltage(struct regulator_dev *dev, ...@@ -63,23 +63,15 @@ static int isl6271a_set_voltage(struct regulator_dev *dev,
unsigned *selector) unsigned *selector)
{ {
struct isl_pmic *pmic = rdev_get_drvdata(dev); struct isl_pmic *pmic = rdev_get_drvdata(dev);
int vsel, err, data; int err, data;
if (minuV < ISL6271A_VOLTAGE_MIN || minuV > ISL6271A_VOLTAGE_MAX) if (minuV < ISL6271A_VOLTAGE_MIN || minuV > ISL6271A_VOLTAGE_MAX)
return -EINVAL; return -EINVAL;
if (maxuV < ISL6271A_VOLTAGE_MIN || maxuV > ISL6271A_VOLTAGE_MAX) if (maxuV < ISL6271A_VOLTAGE_MIN || maxuV > ISL6271A_VOLTAGE_MAX)
return -EINVAL; return -EINVAL;
/* Align to 50000 mV */ data = DIV_ROUND_UP(minuV - ISL6271A_VOLTAGE_MIN,
vsel = minuV - (minuV % ISL6271A_VOLTAGE_STEP); ISL6271A_VOLTAGE_STEP);
/* If the result fell out of [minuV,maxuV] range, put it back */
if (vsel < minuV)
vsel += ISL6271A_VOLTAGE_STEP;
/* Convert the microvolts to data for the chip */
data = (vsel - ISL6271A_VOLTAGE_MIN) / ISL6271A_VOLTAGE_STEP;
*selector = data; *selector = data;
mutex_lock(&pmic->mtx); mutex_lock(&pmic->mtx);
......
...@@ -76,8 +76,8 @@ static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV, ...@@ -76,8 +76,8 @@ static int max1586_v3_set(struct regulator_dev *rdev, int min_uV, int max_uV,
if (min_uV < max1586->min_uV) if (min_uV < max1586->min_uV)
min_uV = max1586->min_uV; min_uV = max1586->min_uV;
*selector = ((min_uV - max1586->min_uV) * MAX1586_V3_MAX_VSEL + *selector = DIV_ROUND_UP((min_uV - max1586->min_uV) *
range_uV - 1) / range_uV; MAX1586_V3_MAX_VSEL, range_uV);
if (max1586_v3_calc_voltage(max1586, *selector) > max_uV) if (max1586_v3_calc_voltage(max1586, *selector) > max_uV)
return -EINVAL; return -EINVAL;
......
...@@ -101,8 +101,7 @@ static int max8649_set_voltage(struct regulator_dev *rdev, ...@@ -101,8 +101,7 @@ static int max8649_set_voltage(struct regulator_dev *rdev,
min_uV, max_uV); min_uV, max_uV);
return -EINVAL; return -EINVAL;
} }
data = (min_uV - MAX8649_DCDC_VMIN + MAX8649_DCDC_STEP - 1) data = DIV_ROUND_UP(min_uV - MAX8649_DCDC_VMIN, MAX8649_DCDC_STEP);
/ MAX8649_DCDC_STEP;
mask = MAX8649_VOL_MASK; mask = MAX8649_VOL_MASK;
*selector = data & mask; *selector = data & mask;
...@@ -270,7 +269,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client, ...@@ -270,7 +269,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
ret); ret);
goto out; goto out;
} }
dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", ret); dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", val);
/* enable VID0 & VID1 */ /* enable VID0 & VID1 */
regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_VID_MASK, 0); regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_VID_MASK, 0);
......
...@@ -153,14 +153,15 @@ static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV, ...@@ -153,14 +153,15 @@ static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV,
if (max_uV < MAX8660_DCDC_MIN_UV || max_uV > MAX8660_DCDC_MAX_UV) if (max_uV < MAX8660_DCDC_MIN_UV || max_uV > MAX8660_DCDC_MAX_UV)
return -EINVAL; return -EINVAL;
selector = (min_uV - (MAX8660_DCDC_MIN_UV - MAX8660_DCDC_STEP + 1)) selector = DIV_ROUND_UP(min_uV - MAX8660_DCDC_MIN_UV,
/ MAX8660_DCDC_STEP; MAX8660_DCDC_STEP);
*s = selector;
ret = max8660_dcdc_list(rdev, selector); ret = max8660_dcdc_list(rdev, selector);
if (ret < 0 || ret > max_uV) if (ret < 0 || ret > max_uV)
return -EINVAL; return -EINVAL;
*s = selector;
reg = (rdev_get_id(rdev) == MAX8660_V3) ? MAX8660_ADTV2 : MAX8660_SDTV2; reg = (rdev_get_id(rdev) == MAX8660_V3) ? MAX8660_ADTV2 : MAX8660_SDTV2;
ret = max8660_write(max8660, reg, 0, selector); ret = max8660_write(max8660, reg, 0, selector);
if (ret) if (ret)
...@@ -210,8 +211,9 @@ static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV, ...@@ -210,8 +211,9 @@ static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV,
if (max_uV < MAX8660_LDO5_MIN_UV || max_uV > MAX8660_LDO5_MAX_UV) if (max_uV < MAX8660_LDO5_MIN_UV || max_uV > MAX8660_LDO5_MAX_UV)
return -EINVAL; return -EINVAL;
selector = (min_uV - (MAX8660_LDO5_MIN_UV - MAX8660_LDO5_STEP + 1)) selector = DIV_ROUND_UP(min_uV - MAX8660_LDO5_MIN_UV,
/ MAX8660_LDO5_STEP; MAX8660_LDO5_STEP);
ret = max8660_ldo5_list(rdev, selector); ret = max8660_ldo5_list(rdev, selector);
if (ret < 0 || ret > max_uV) if (ret < 0 || ret > max_uV)
return -EINVAL; return -EINVAL;
...@@ -287,8 +289,8 @@ static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV, ...@@ -287,8 +289,8 @@ static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV,
if (max_uV < MAX8660_LDO67_MIN_UV || max_uV > MAX8660_LDO67_MAX_UV) if (max_uV < MAX8660_LDO67_MIN_UV || max_uV > MAX8660_LDO67_MAX_UV)
return -EINVAL; return -EINVAL;
selector = (min_uV - (MAX8660_LDO67_MIN_UV - MAX8660_LDO67_STEP + 1)) selector = DIV_ROUND_UP(min_uV - MAX8660_LDO67_MIN_UV,
/ MAX8660_LDO67_STEP; MAX8660_LDO67_STEP);
ret = max8660_ldo67_list(rdev, selector); ret = max8660_ldo67_list(rdev, selector);
if (ret < 0 || ret > max_uV) if (ret < 0 || ret > max_uV)
......
...@@ -73,7 +73,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev, ...@@ -73,7 +73,7 @@ static int max8925_set_voltage(struct regulator_dev *rdev,
min_uV, max_uV); min_uV, max_uV);
return -EINVAL; return -EINVAL;
} }
data = (min_uV - info->min_uV + info->step_uV - 1) / info->step_uV; data = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
*selector = data; *selector = data;
data <<= info->vol_shift; data <<= info->vol_shift;
mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift;
...@@ -140,7 +140,7 @@ static int max8925_set_dvm_voltage(struct regulator_dev *rdev, int uV) ...@@ -140,7 +140,7 @@ static int max8925_set_dvm_voltage(struct regulator_dev *rdev, int uV)
if (uV < SD1_DVM_VMIN || uV > SD1_DVM_VMAX) if (uV < SD1_DVM_VMIN || uV > SD1_DVM_VMAX)
return -EINVAL; return -EINVAL;
data = (uV - SD1_DVM_VMIN + SD1_DVM_STEP - 1) / SD1_DVM_STEP; data = DIV_ROUND_UP(uV - SD1_DVM_VMIN, SD1_DVM_STEP);
data <<= SD1_DVM_SHIFT; data <<= SD1_DVM_SHIFT;
mask = 3 << SD1_DVM_SHIFT; mask = 3 << SD1_DVM_SHIFT;
......
...@@ -130,15 +130,10 @@ static const struct voltage_map_desc *reg_voltage_map[] = { ...@@ -130,15 +130,10 @@ static const struct voltage_map_desc *reg_voltage_map[] = {
[MAX8997_CHARGER_TOPOFF] = &topoff_current_map_desc, [MAX8997_CHARGER_TOPOFF] = &topoff_current_map_desc,
}; };
static inline int max8997_get_rid(struct regulator_dev *rdev)
{
return rdev_get_id(rdev);
}
static int max8997_list_voltage_safeout(struct regulator_dev *rdev, static int max8997_list_voltage_safeout(struct regulator_dev *rdev,
unsigned int selector) unsigned int selector)
{ {
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
if (rid == MAX8997_ESAFEOUT1 || rid == MAX8997_ESAFEOUT2) { if (rid == MAX8997_ESAFEOUT1 || rid == MAX8997_ESAFEOUT2) {
switch (selector) { switch (selector) {
...@@ -161,7 +156,7 @@ static int max8997_list_voltage_safeout(struct regulator_dev *rdev, ...@@ -161,7 +156,7 @@ static int max8997_list_voltage_safeout(struct regulator_dev *rdev,
static int max8997_list_voltage_charger_cv(struct regulator_dev *rdev, static int max8997_list_voltage_charger_cv(struct regulator_dev *rdev,
unsigned int selector) unsigned int selector)
{ {
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
if (rid != MAX8997_CHARGER_CV) if (rid != MAX8997_CHARGER_CV)
goto err; goto err;
...@@ -184,7 +179,7 @@ static int max8997_list_voltage(struct regulator_dev *rdev, ...@@ -184,7 +179,7 @@ static int max8997_list_voltage(struct regulator_dev *rdev,
unsigned int selector) unsigned int selector)
{ {
const struct voltage_map_desc *desc; const struct voltage_map_desc *desc;
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
int val; int val;
if (rid >= ARRAY_SIZE(reg_voltage_map) || if (rid >= ARRAY_SIZE(reg_voltage_map) ||
...@@ -205,7 +200,7 @@ static int max8997_list_voltage(struct regulator_dev *rdev, ...@@ -205,7 +200,7 @@ static int max8997_list_voltage(struct regulator_dev *rdev,
static int max8997_get_enable_register(struct regulator_dev *rdev, static int max8997_get_enable_register(struct regulator_dev *rdev,
int *reg, int *mask, int *pattern) int *reg, int *mask, int *pattern)
{ {
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
switch (rid) { switch (rid) {
case MAX8997_LDO1 ... MAX8997_LDO21: case MAX8997_LDO1 ... MAX8997_LDO21:
...@@ -325,7 +320,7 @@ static int max8997_reg_disable(struct regulator_dev *rdev) ...@@ -325,7 +320,7 @@ static int max8997_reg_disable(struct regulator_dev *rdev)
static int max8997_get_voltage_register(struct regulator_dev *rdev, static int max8997_get_voltage_register(struct regulator_dev *rdev,
int *_reg, int *_shift, int *_mask) int *_reg, int *_shift, int *_mask)
{ {
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
int reg, shift = 0, mask = 0x3f; int reg, shift = 0, mask = 0x3f;
switch (rid) { switch (rid) {
...@@ -386,7 +381,7 @@ static int max8997_get_voltage(struct regulator_dev *rdev) ...@@ -386,7 +381,7 @@ static int max8997_get_voltage(struct regulator_dev *rdev)
struct max8997_data *max8997 = rdev_get_drvdata(rdev); struct max8997_data *max8997 = rdev_get_drvdata(rdev);
struct i2c_client *i2c = max8997->iodev->i2c; struct i2c_client *i2c = max8997->iodev->i2c;
int reg, shift, mask, ret; int reg, shift, mask, ret;
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
u8 val; u8 val;
ret = max8997_get_voltage_register(rdev, &reg, &shift, &mask); ret = max8997_get_voltage_register(rdev, &reg, &shift, &mask);
...@@ -446,7 +441,7 @@ static int max8997_set_voltage_charger_cv(struct regulator_dev *rdev, ...@@ -446,7 +441,7 @@ static int max8997_set_voltage_charger_cv(struct regulator_dev *rdev,
{ {
struct max8997_data *max8997 = rdev_get_drvdata(rdev); struct max8997_data *max8997 = rdev_get_drvdata(rdev);
struct i2c_client *i2c = max8997->iodev->i2c; struct i2c_client *i2c = max8997->iodev->i2c;
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
int lb, ub; int lb, ub;
int reg, shift = 0, mask, ret = 0; int reg, shift = 0, mask, ret = 0;
u8 val = 0x0; u8 val = 0x0;
...@@ -503,7 +498,7 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev, ...@@ -503,7 +498,7 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev,
struct i2c_client *i2c = max8997->iodev->i2c; struct i2c_client *i2c = max8997->iodev->i2c;
int min_vol = min_uV / 1000, max_vol = max_uV / 1000; int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
const struct voltage_map_desc *desc; const struct voltage_map_desc *desc;
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
int reg, shift = 0, mask, ret; int reg, shift = 0, mask, ret;
int i; int i;
u8 org; u8 org;
...@@ -564,7 +559,7 @@ static int max8997_assess_side_effect(struct regulator_dev *rdev, ...@@ -564,7 +559,7 @@ static int max8997_assess_side_effect(struct regulator_dev *rdev,
u8 new_val, int *best) u8 new_val, int *best)
{ {
struct max8997_data *max8997 = rdev_get_drvdata(rdev); struct max8997_data *max8997 = rdev_get_drvdata(rdev);
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
u8 *buckx_val[3]; u8 *buckx_val[3];
bool buckx_gpiodvs[3]; bool buckx_gpiodvs[3];
int side_effect[8]; int side_effect[8];
...@@ -641,7 +636,7 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev, ...@@ -641,7 +636,7 @@ static int max8997_set_voltage_buck(struct regulator_dev *rdev,
int min_uV, int max_uV, unsigned *selector) int min_uV, int max_uV, unsigned *selector)
{ {
struct max8997_data *max8997 = rdev_get_drvdata(rdev); struct max8997_data *max8997 = rdev_get_drvdata(rdev);
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
const struct voltage_map_desc *desc; const struct voltage_map_desc *desc;
int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg; int new_val, new_idx, damage, tmp_val, tmp_idx, tmp_dmg;
bool gpio_dvs_mode = false; bool gpio_dvs_mode = false;
...@@ -724,7 +719,7 @@ static int max8997_set_voltage_safeout(struct regulator_dev *rdev, ...@@ -724,7 +719,7 @@ static int max8997_set_voltage_safeout(struct regulator_dev *rdev,
{ {
struct max8997_data *max8997 = rdev_get_drvdata(rdev); struct max8997_data *max8997 = rdev_get_drvdata(rdev);
struct i2c_client *i2c = max8997->iodev->i2c; struct i2c_client *i2c = max8997->iodev->i2c;
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
int reg, shift = 0, mask, ret; int reg, shift = 0, mask, ret;
int i = 0; int i = 0;
u8 val; u8 val;
...@@ -766,7 +761,7 @@ static int max8997_reg_disable_suspend(struct regulator_dev *rdev) ...@@ -766,7 +761,7 @@ static int max8997_reg_disable_suspend(struct regulator_dev *rdev)
struct max8997_data *max8997 = rdev_get_drvdata(rdev); struct max8997_data *max8997 = rdev_get_drvdata(rdev);
struct i2c_client *i2c = max8997->iodev->i2c; struct i2c_client *i2c = max8997->iodev->i2c;
int ret, reg, mask, pattern; int ret, reg, mask, pattern;
int rid = max8997_get_rid(rdev); int rid = rdev_get_id(rdev);
ret = max8997_get_enable_register(rdev, &reg, &mask, &pattern); ret = max8997_get_enable_register(rdev, &reg, &mask, &pattern);
if (ret) if (ret)
...@@ -908,13 +903,13 @@ static struct regulator_desc regulators[] = { ...@@ -908,13 +903,13 @@ static struct regulator_desc regulators[] = {
}, },
regulator_desc_buck(7), regulator_desc_buck(7),
{ {
.name = "EN32KHz AP", .name = "EN32KHz_AP",
.id = MAX8997_EN32KHZ_AP, .id = MAX8997_EN32KHZ_AP,
.ops = &max8997_fixedvolt_ops, .ops = &max8997_fixedvolt_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, { }, {
.name = "EN32KHz CP", .name = "EN32KHz_CP",
.id = MAX8997_EN32KHZ_CP, .id = MAX8997_EN32KHZ_CP,
.ops = &max8997_fixedvolt_ops, .ops = &max8997_fixedvolt_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
...@@ -938,7 +933,7 @@ static struct regulator_desc regulators[] = { ...@@ -938,7 +933,7 @@ static struct regulator_desc regulators[] = {
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, { }, {
.name = "CHARGER CV", .name = "CHARGER_CV",
.id = MAX8997_CHARGER_CV, .id = MAX8997_CHARGER_CV,
.ops = &max8997_fixedstate_ops, .ops = &max8997_fixedstate_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
...@@ -950,7 +945,7 @@ static struct regulator_desc regulators[] = { ...@@ -950,7 +945,7 @@ static struct regulator_desc regulators[] = {
.type = REGULATOR_CURRENT, .type = REGULATOR_CURRENT,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, { }, {
.name = "CHARGER TOPOFF", .name = "CHARGER_TOPOFF",
.id = MAX8997_CHARGER_TOPOFF, .id = MAX8997_CHARGER_TOPOFF,
.ops = &max8997_charger_fixedstate_ops, .ops = &max8997_charger_fixedstate_ops,
.type = REGULATOR_CURRENT, .type = REGULATOR_CURRENT,
......
...@@ -112,16 +112,11 @@ static const struct voltage_map_desc *ldo_voltage_map[] = { ...@@ -112,16 +112,11 @@ static const struct voltage_map_desc *ldo_voltage_map[] = {
&buck4_voltage_map_desc, /* BUCK4 */ &buck4_voltage_map_desc, /* BUCK4 */
}; };
static inline int max8998_get_ldo(struct regulator_dev *rdev)
{
return rdev_get_id(rdev);
}
static int max8998_list_voltage(struct regulator_dev *rdev, static int max8998_list_voltage(struct regulator_dev *rdev,
unsigned int selector) unsigned int selector)
{ {
const struct voltage_map_desc *desc; const struct voltage_map_desc *desc;
int ldo = max8998_get_ldo(rdev); int ldo = rdev_get_id(rdev);
int val; int val;
if (ldo >= ARRAY_SIZE(ldo_voltage_map)) if (ldo >= ARRAY_SIZE(ldo_voltage_map))
...@@ -141,7 +136,7 @@ static int max8998_list_voltage(struct regulator_dev *rdev, ...@@ -141,7 +136,7 @@ static int max8998_list_voltage(struct regulator_dev *rdev,
static int max8998_get_enable_register(struct regulator_dev *rdev, static int max8998_get_enable_register(struct regulator_dev *rdev,
int *reg, int *shift) int *reg, int *shift)
{ {
int ldo = max8998_get_ldo(rdev); int ldo = rdev_get_id(rdev);
switch (ldo) { switch (ldo) {
case MAX8998_LDO2 ... MAX8998_LDO5: case MAX8998_LDO2 ... MAX8998_LDO5:
...@@ -222,7 +217,7 @@ static int max8998_ldo_disable(struct regulator_dev *rdev) ...@@ -222,7 +217,7 @@ static int max8998_ldo_disable(struct regulator_dev *rdev)
static int max8998_get_voltage_register(struct regulator_dev *rdev, static int max8998_get_voltage_register(struct regulator_dev *rdev,
int *_reg, int *_shift, int *_mask) int *_reg, int *_shift, int *_mask)
{ {
int ldo = max8998_get_ldo(rdev); int ldo = rdev_get_id(rdev);
struct max8998_data *max8998 = rdev_get_drvdata(rdev); struct max8998_data *max8998 = rdev_get_drvdata(rdev);
int reg, shift = 0, mask = 0xff; int reg, shift = 0, mask = 0xff;
...@@ -310,7 +305,7 @@ static int max8998_set_voltage_ldo(struct regulator_dev *rdev, ...@@ -310,7 +305,7 @@ static int max8998_set_voltage_ldo(struct regulator_dev *rdev,
struct i2c_client *i2c = max8998->iodev->i2c; struct i2c_client *i2c = max8998->iodev->i2c;
int min_vol = min_uV / 1000, max_vol = max_uV / 1000; int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
const struct voltage_map_desc *desc; const struct voltage_map_desc *desc;
int ldo = max8998_get_ldo(rdev); int ldo = rdev_get_id(rdev);
int reg, shift = 0, mask, ret; int reg, shift = 0, mask, ret;
int i = 0; int i = 0;
...@@ -362,7 +357,7 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev, ...@@ -362,7 +357,7 @@ static int max8998_set_voltage_buck(struct regulator_dev *rdev,
struct i2c_client *i2c = max8998->iodev->i2c; struct i2c_client *i2c = max8998->iodev->i2c;
int min_vol = min_uV / 1000, max_vol = max_uV / 1000; int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
const struct voltage_map_desc *desc; const struct voltage_map_desc *desc;
int buck = max8998_get_ldo(rdev); int buck = rdev_get_id(rdev);
int reg, shift = 0, mask, ret; int reg, shift = 0, mask, ret;
int difference = 0, i = 0, j = 0, previous_vol = 0; int difference = 0, i = 0, j = 0, previous_vol = 0;
u8 val = 0; u8 val = 0;
...@@ -829,7 +824,6 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) ...@@ -829,7 +824,6 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
buck12_voltage_map_desc.step*i buck12_voltage_map_desc.step*i
< (pdata->buck2_voltage2 / 1000)) < (pdata->buck2_voltage2 / 1000))
i++; i++;
printk(KERN_ERR "i2:%d, buck2_idx:%d\n", i, max8998->buck2_idx);
max8998->buck2_vol[1] = i; max8998->buck2_vol[1] = i;
ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i); ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
if (ret) if (ret)
......
...@@ -344,6 +344,9 @@ static int __devinit mc13783_regulator_probe(struct platform_device *pdev) ...@@ -344,6 +344,9 @@ static int __devinit mc13783_regulator_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "%s id %d\n", __func__, pdev->id); dev_dbg(&pdev->dev, "%s id %d\n", __func__, pdev->id);
if (!pdata)
return -EINVAL;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv) + priv = devm_kzalloc(&pdev->dev, sizeof(*priv) +
pdata->num_regulators * sizeof(priv->regulators[0]), pdata->num_regulators * sizeof(priv->regulators[0]),
GFP_KERNEL); GFP_KERNEL);
......
...@@ -254,6 +254,7 @@ int __devinit mc13xxx_get_num_regulators_dt(struct platform_device *pdev) ...@@ -254,6 +254,7 @@ int __devinit mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
return num; return num;
} }
EXPORT_SYMBOL_GPL(mc13xxx_get_num_regulators_dt);
struct mc13xxx_regulator_init_data * __devinit mc13xxx_parse_regulators_dt( struct mc13xxx_regulator_init_data * __devinit mc13xxx_parse_regulators_dt(
struct platform_device *pdev, struct mc13xxx_regulator *regulators, struct platform_device *pdev, struct mc13xxx_regulator *regulators,
...@@ -291,6 +292,7 @@ struct mc13xxx_regulator_init_data * __devinit mc13xxx_parse_regulators_dt( ...@@ -291,6 +292,7 @@ struct mc13xxx_regulator_init_data * __devinit mc13xxx_parse_regulators_dt(
return data; return data;
} }
EXPORT_SYMBOL_GPL(mc13xxx_parse_regulators_dt);
#endif #endif
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
......
...@@ -142,6 +142,7 @@ static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev, ...@@ -142,6 +142,7 @@ static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev,
case PCF50633_REGULATOR_LDO5: case PCF50633_REGULATOR_LDO5:
case PCF50633_REGULATOR_LDO6: case PCF50633_REGULATOR_LDO6:
case PCF50633_REGULATOR_HCLDO: case PCF50633_REGULATOR_HCLDO:
case PCF50633_REGULATOR_MEMLDO:
volt_bits = ldo_voltage_bits(millivolts); volt_bits = ldo_voltage_bits(millivolts);
break; break;
default: default:
...@@ -175,6 +176,7 @@ static int pcf50633_regulator_voltage_value(enum pcf50633_regulator_id id, ...@@ -175,6 +176,7 @@ static int pcf50633_regulator_voltage_value(enum pcf50633_regulator_id id,
case PCF50633_REGULATOR_LDO5: case PCF50633_REGULATOR_LDO5:
case PCF50633_REGULATOR_LDO6: case PCF50633_REGULATOR_LDO6:
case PCF50633_REGULATOR_HCLDO: case PCF50633_REGULATOR_HCLDO:
case PCF50633_REGULATOR_MEMLDO:
millivolts = ldo_voltage_value(bits); millivolts = ldo_voltage_value(bits);
break; break;
default: default:
...@@ -217,9 +219,6 @@ static int pcf50633_regulator_list_voltage(struct regulator_dev *rdev, ...@@ -217,9 +219,6 @@ static int pcf50633_regulator_list_voltage(struct regulator_dev *rdev,
case PCF50633_REGULATOR_AUTO: case PCF50633_REGULATOR_AUTO:
index += 0x2f; index += 0x2f;
break; break;
case PCF50633_REGULATOR_HCLDO:
index += 0x01;
break;
default: default:
break; break;
} }
...@@ -288,27 +287,27 @@ static struct regulator_ops pcf50633_regulator_ops = { ...@@ -288,27 +287,27 @@ static struct regulator_ops pcf50633_regulator_ops = {
static struct regulator_desc regulators[] = { static struct regulator_desc regulators[] = {
[PCF50633_REGULATOR_AUTO] = [PCF50633_REGULATOR_AUTO] =
PCF50633_REGULATOR("auto", PCF50633_REGULATOR_AUTO, 80), PCF50633_REGULATOR("auto", PCF50633_REGULATOR_AUTO, 81),
[PCF50633_REGULATOR_DOWN1] = [PCF50633_REGULATOR_DOWN1] =
PCF50633_REGULATOR("down1", PCF50633_REGULATOR_DOWN1, 95), PCF50633_REGULATOR("down1", PCF50633_REGULATOR_DOWN1, 96),
[PCF50633_REGULATOR_DOWN2] = [PCF50633_REGULATOR_DOWN2] =
PCF50633_REGULATOR("down2", PCF50633_REGULATOR_DOWN2, 95), PCF50633_REGULATOR("down2", PCF50633_REGULATOR_DOWN2, 96),
[PCF50633_REGULATOR_LDO1] = [PCF50633_REGULATOR_LDO1] =
PCF50633_REGULATOR("ldo1", PCF50633_REGULATOR_LDO1, 27), PCF50633_REGULATOR("ldo1", PCF50633_REGULATOR_LDO1, 28),
[PCF50633_REGULATOR_LDO2] = [PCF50633_REGULATOR_LDO2] =
PCF50633_REGULATOR("ldo2", PCF50633_REGULATOR_LDO2, 27), PCF50633_REGULATOR("ldo2", PCF50633_REGULATOR_LDO2, 28),
[PCF50633_REGULATOR_LDO3] = [PCF50633_REGULATOR_LDO3] =
PCF50633_REGULATOR("ldo3", PCF50633_REGULATOR_LDO3, 27), PCF50633_REGULATOR("ldo3", PCF50633_REGULATOR_LDO3, 28),
[PCF50633_REGULATOR_LDO4] = [PCF50633_REGULATOR_LDO4] =
PCF50633_REGULATOR("ldo4", PCF50633_REGULATOR_LDO4, 27), PCF50633_REGULATOR("ldo4", PCF50633_REGULATOR_LDO4, 28),
[PCF50633_REGULATOR_LDO5] = [PCF50633_REGULATOR_LDO5] =
PCF50633_REGULATOR("ldo5", PCF50633_REGULATOR_LDO5, 27), PCF50633_REGULATOR("ldo5", PCF50633_REGULATOR_LDO5, 28),
[PCF50633_REGULATOR_LDO6] = [PCF50633_REGULATOR_LDO6] =
PCF50633_REGULATOR("ldo6", PCF50633_REGULATOR_LDO6, 27), PCF50633_REGULATOR("ldo6", PCF50633_REGULATOR_LDO6, 28),
[PCF50633_REGULATOR_HCLDO] = [PCF50633_REGULATOR_HCLDO] =
PCF50633_REGULATOR("hcldo", PCF50633_REGULATOR_HCLDO, 26), PCF50633_REGULATOR("hcldo", PCF50633_REGULATOR_HCLDO, 28),
[PCF50633_REGULATOR_MEMLDO] = [PCF50633_REGULATOR_MEMLDO] =
PCF50633_REGULATOR("memldo", PCF50633_REGULATOR_MEMLDO, 0), PCF50633_REGULATOR("memldo", PCF50633_REGULATOR_MEMLDO, 28),
}; };
static int __devinit pcf50633_regulator_probe(struct platform_device *pdev) static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
......
This diff is collapsed.
This diff is collapsed.
...@@ -487,10 +487,6 @@ static int __devinit tps_65023_probe(struct i2c_client *client, ...@@ -487,10 +487,6 @@ static int __devinit tps_65023_probe(struct i2c_client *client,
i2c_set_clientdata(client, tps); i2c_set_clientdata(client, tps);
/* Enable setting output voltage by I2C */
regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ);
/* Enable setting output voltage by I2C */ /* Enable setting output voltage by I2C */
regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2, regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ); TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ);
......
This diff is collapsed.
This diff is collapsed.
...@@ -108,9 +108,7 @@ ...@@ -108,9 +108,7 @@
#define N_DCDC 3 #define N_DCDC 3
#define N_LDO 2 #define N_LDO 2
#define N_SWITCH 2 #define N_SWITCH 2
#define N_REGULATORS (3 /* DCDC */ + \ #define N_REGULATORS (N_DCDC + N_LDO + N_SWITCH)
2 /* LDO */ + \
2 /* switch */)
#define FIXED_ILIMSEL BIT(0) #define FIXED_ILIMSEL BIT(0)
#define FIXED_VOLTAGE BIT(1) #define FIXED_VOLTAGE BIT(1)
......
...@@ -383,7 +383,7 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev) ...@@ -383,7 +383,7 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev)
int id = pdev->id; int id = pdev->id;
int err; int err;
dev_dbg(&pdev->dev, "Probing reulator %d\n", id); dev_dbg(&pdev->dev, "Probing regulator %d\n", id);
ri = find_regulator_info(id); ri = find_regulator_info(id);
if (ri == NULL) { if (ri == NULL) {
......
This diff is collapsed.
This diff is collapsed.
...@@ -186,7 +186,7 @@ static int wm8350_isink_get_current(struct regulator_dev *rdev) ...@@ -186,7 +186,7 @@ static int wm8350_isink_get_current(struct regulator_dev *rdev)
return 0; return 0;
} }
return (isink_cur[val] + 50) / 100; return DIV_ROUND_CLOSEST(isink_cur[val], 100);
} }
/* turn on ISINK followed by DCDC */ /* turn on ISINK followed by DCDC */
...@@ -1544,7 +1544,7 @@ int wm8350_register_led(struct wm8350 *wm8350, int lednum, int dcdc, int isink, ...@@ -1544,7 +1544,7 @@ int wm8350_register_led(struct wm8350 *wm8350, int lednum, int dcdc, int isink,
return -ENOMEM; return -ENOMEM;
} }
led->isink_consumer.dev = &pdev->dev; led->isink_consumer.dev_name = dev_name(&pdev->dev);
led->isink_consumer.supply = "led_isink"; led->isink_consumer.supply = "led_isink";
led->isink_init.num_consumer_supplies = 1; led->isink_init.num_consumer_supplies = 1;
led->isink_init.consumer_supplies = &led->isink_consumer; led->isink_init.consumer_supplies = &led->isink_consumer;
...@@ -1559,7 +1559,7 @@ int wm8350_register_led(struct wm8350 *wm8350, int lednum, int dcdc, int isink, ...@@ -1559,7 +1559,7 @@ int wm8350_register_led(struct wm8350 *wm8350, int lednum, int dcdc, int isink,
return ret; return ret;
} }
led->dcdc_consumer.dev = &pdev->dev; led->dcdc_consumer.dev_name = dev_name(&pdev->dev);
led->dcdc_consumer.supply = "led_vcc"; led->dcdc_consumer.supply = "led_vcc";
led->dcdc_init.num_consumer_supplies = 1; led->dcdc_init.num_consumer_supplies = 1;
led->dcdc_init.consumer_supplies = &led->dcdc_consumer; led->dcdc_init.consumer_supplies = &led->dcdc_consumer;
......
...@@ -78,14 +78,14 @@ static int wm8400_ldo_set_voltage(struct regulator_dev *dev, ...@@ -78,14 +78,14 @@ static int wm8400_ldo_set_voltage(struct regulator_dev *dev,
if (min_uV < 1700000) { if (min_uV < 1700000) {
/* Steps of 50mV from 900mV; */ /* Steps of 50mV from 900mV; */
val = (min_uV - 850001) / 50000; val = DIV_ROUND_UP(min_uV - 900000, 50000);
if ((val * 50000) + 900000 > max_uV) if ((val * 50000) + 900000 > max_uV)
return -EINVAL; return -EINVAL;
BUG_ON((val * 50000) + 900000 < min_uV); BUG_ON((val * 50000) + 900000 < min_uV);
} else { } else {
/* Steps of 100mV from 1700mV */ /* Steps of 100mV from 1700mV */
val = ((min_uV - 1600001) / 100000); val = DIV_ROUND_UP(min_uV - 1700000, 100000);
if ((val * 100000) + 1700000 > max_uV) if ((val * 100000) + 1700000 > max_uV)
return -EINVAL; return -EINVAL;
...@@ -168,7 +168,7 @@ static int wm8400_dcdc_set_voltage(struct regulator_dev *dev, ...@@ -168,7 +168,7 @@ static int wm8400_dcdc_set_voltage(struct regulator_dev *dev,
if (min_uV < 850000) if (min_uV < 850000)
return -EINVAL; return -EINVAL;
val = (min_uV - 825001) / 25000; val = DIV_ROUND_UP(min_uV - 850000, 25000);
if (850000 + (25000 * val) > max_uV) if (850000 + (25000 * val) > max_uV)
return -EINVAL; return -EINVAL;
......
...@@ -241,7 +241,7 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev) ...@@ -241,7 +241,7 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev)
if (!pdata) if (!pdata)
return -ENODEV; return -ENODEV;
ldo = kzalloc(sizeof(struct wm8994_ldo), GFP_KERNEL); ldo = devm_kzalloc(&pdev->dev, sizeof(struct wm8994_ldo), GFP_KERNEL);
if (ldo == NULL) { if (ldo == NULL) {
dev_err(&pdev->dev, "Unable to allocate private data\n"); dev_err(&pdev->dev, "Unable to allocate private data\n");
return -ENOMEM; return -ENOMEM;
...@@ -285,7 +285,6 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev) ...@@ -285,7 +285,6 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev)
if (gpio_is_valid(ldo->enable)) if (gpio_is_valid(ldo->enable))
gpio_free(ldo->enable); gpio_free(ldo->enable);
err: err:
kfree(ldo);
return ret; return ret;
} }
...@@ -298,7 +297,6 @@ static __devexit int wm8994_ldo_remove(struct platform_device *pdev) ...@@ -298,7 +297,6 @@ static __devexit int wm8994_ldo_remove(struct platform_device *pdev)
regulator_unregister(ldo->regulator); regulator_unregister(ldo->regulator);
if (gpio_is_valid(ldo->enable)) if (gpio_is_valid(ldo->enable))
gpio_free(ldo->enable); gpio_free(ldo->enable);
kfree(ldo);
return 0; return 0;
} }
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment