Commit 22a80593 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6: (27 commits)
  regulator: wm831x_reg_read() failure unnoticed in wm831x_aldo_get_mode()
  twl-regulator: Fix reg_disable functionality for 4030 and 6030
  twl-regulator: Add turnon delay to reg_enable
  twl-regulator: Restore REMAP configuration in regulator probe
  twl-regulator: Add turnon-delay and REMAP config to twlreg_info struct
  twl-regulator: Define critical regulators as always_on
  twl-regulator: Add all twl4030 regulators to twlreg_info
  regulator: mc13783-regulator: correct the probing time.
  regulator: Fix unbalanced disables/enables in regulator_bulk_{enable,disable} error path
  regulator: core.c: Small coding style cleanup (indentation fixup)
  drivers/regulator: use PTR_ERR to get error code
  regulator: consumer.h - fix build when consumer.h is #included first.
  regulator/mc13783: various cleanups
  regulator/mc13783: rename source file to match other drivers
  Fix some AB3100 regulator issues
  regulator: keep index within bounds in da9034_get_ldo12_voltage()
  regulator: Ensure val is initialised in 88pm8607 choose_voltage()
  regulator: Remove duplicate consts from ab3100
  regulator: Handle regulators without suspend mode configuration
  regulator: Factor out regulator name pretty printing
  ...
parents 5a865c06 6f17c652
This diff is collapsed.
......@@ -69,6 +69,13 @@ config REGULATOR_MAX1586
regulator via I2C bus. The provided regulator is suitable
for PXA27x chips to control VCC_CORE and VCC_USIM voltages.
config REGULATOR_MAX8660
tristate "Maxim 8660/8661 voltage regulator"
depends on I2C
help
This driver controls a Maxim 8660/8661 voltage output
regulator via I2C bus.
config REGULATOR_TWL4030
bool "TI TWL4030/TWL5030/TWL6030/TPS695x0 PMIC"
depends on TWL4030_CORE
......@@ -157,5 +164,11 @@ config REGULATOR_TPS6507X
three step-down converters and two general-purpose LDO voltage regulators.
It supports TI's software based Class-2 SmartReflex implementation.
config REGULATOR_88PM8607
bool "Marvell 88PM8607 Power regulators"
depends on MFD_88PM8607=y
help
This driver supports 88PM8607 voltage regulator chips.
endif
......@@ -12,6 +12,7 @@ obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
......@@ -20,10 +21,11 @@ obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_MC13783) += mc13783.o
obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o
obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o
obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
......@@ -81,7 +81,7 @@ static const u8 ab3100_reg_init_order[AB3100_NUM_REGULATORS+2] = {
#define LDO_C_VOLTAGE 2650000
#define LDO_D_VOLTAGE 2650000
static const int const ldo_e_buck_typ_voltages[] = {
static const int ldo_e_buck_typ_voltages[] = {
1800000,
1400000,
1300000,
......@@ -91,7 +91,7 @@ static const int const ldo_e_buck_typ_voltages[] = {
900000,
};
static const int const ldo_f_typ_voltages[] = {
static const int ldo_f_typ_voltages[] = {
1800000,
1400000,
1300000,
......@@ -102,21 +102,21 @@ static const int const ldo_f_typ_voltages[] = {
2650000,
};
static const int const ldo_g_typ_voltages[] = {
static const int ldo_g_typ_voltages[] = {
2850000,
2750000,
1800000,
1500000,
};
static const int const ldo_h_typ_voltages[] = {
static const int ldo_h_typ_voltages[] = {
2750000,
1800000,
1500000,
1200000,
};
static const int const ldo_k_typ_voltages[] = {
static const int ldo_k_typ_voltages[] = {
2750000,
1800000,
};
......@@ -241,24 +241,12 @@ static int ab3100_disable_regulator(struct regulator_dev *reg)
* LDO D is a special regulator. When it is disabled, the entire
* system is shut down. So this is handled specially.
*/
pr_info("Called ab3100_disable_regulator\n");
if (abreg->regreg == AB3100_LDO_D) {
int i;
dev_info(&reg->dev, "disabling LDO D - shut down system\n");
/*
* Set regulators to default values, ignore any errors,
* we're going DOWN
*/
for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) {
(void) ab3100_set_register_interruptible(abreg->ab3100,
ab3100_reg_init_order[i],
abreg->plfdata->reg_initvals[i]);
}
/* Setting LDO D to 0x00 cuts the power to the SoC */
return ab3100_set_register_interruptible(abreg->ab3100,
AB3100_LDO_D, 0x00U);
}
/*
......@@ -607,13 +595,6 @@ static int __init ab3100_regulators_probe(struct platform_device *pdev)
}
}
if (err) {
dev_err(&pdev->dev,
"LDO D regulator initialization failed with error %d\n",
err);
return err;
}
/* Register the regulators */
for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
struct ab3100_regulator *reg = &ab3100_regulators[i];
......@@ -688,7 +669,7 @@ static __init int ab3100_regulators_init(void)
static __exit void ab3100_regulators_exit(void)
{
platform_driver_register(&ab3100_regulators_driver);
platform_driver_unregister(&ab3100_regulators_driver);
}
subsys_initcall(ab3100_regulators_init);
......
This diff is collapsed.
......@@ -331,7 +331,7 @@ static int da9034_get_ldo12_voltage(struct regulator_dev *rdev)
static int da9034_list_ldo12_voltage(struct regulator_dev *rdev,
unsigned selector)
{
if (selector > ARRAY_SIZE(da9034_ldo12_data))
if (selector >= ARRAY_SIZE(da9034_ldo12_data))
return -EINVAL;
return da9034_ldo12_data[selector] * 1000;
}
......
......@@ -446,8 +446,8 @@ static int setup_regulators(struct lp3971 *lp3971,
lp3971->rdev[i] = regulator_register(&regulators[id],
lp3971->dev, pdata->regulators[i].initdata, lp3971);
err = IS_ERR(lp3971->rdev[i]);
if (err) {
if (IS_ERR(lp3971->rdev[i])) {
err = PTR_ERR(lp3971->rdev[i]);
dev_err(lp3971->dev, "regulator init failed: %d\n",
err);
goto error;
......
This diff is collapsed.
/*
* Regulator Driver for Freescale MC13783 PMIC
*
* Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/mfd/mc13783.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/driver.h>
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/err.h>
#define MC13783_REG_SWITCHERS4 28
#define MC13783_REG_SWITCHERS4_PLLEN (1 << 18)
#define MC13783_REG_SWITCHERS5 29
#define MC13783_REG_SWITCHERS5_SW3EN (1 << 20)
#define MC13783_REG_REGULATORMODE0 32
#define MC13783_REG_REGULATORMODE0_VAUDIOEN (1 << 0)
#define MC13783_REG_REGULATORMODE0_VIOHIEN (1 << 3)
#define MC13783_REG_REGULATORMODE0_VIOLOEN (1 << 6)
#define MC13783_REG_REGULATORMODE0_VDIGEN (1 << 9)
#define MC13783_REG_REGULATORMODE0_VGENEN (1 << 12)
#define MC13783_REG_REGULATORMODE0_VRFDIGEN (1 << 15)
#define MC13783_REG_REGULATORMODE0_VRFREFEN (1 << 18)
#define MC13783_REG_REGULATORMODE0_VRFCPEN (1 << 21)
#define MC13783_REG_REGULATORMODE1 33
#define MC13783_REG_REGULATORMODE1_VSIMEN (1 << 0)
#define MC13783_REG_REGULATORMODE1_VESIMEN (1 << 3)
#define MC13783_REG_REGULATORMODE1_VCAMEN (1 << 6)
#define MC13783_REG_REGULATORMODE1_VRFBGEN (1 << 9)
#define MC13783_REG_REGULATORMODE1_VVIBEN (1 << 11)
#define MC13783_REG_REGULATORMODE1_VRF1EN (1 << 12)
#define MC13783_REG_REGULATORMODE1_VRF2EN (1 << 15)
#define MC13783_REG_REGULATORMODE1_VMMC1EN (1 << 18)
#define MC13783_REG_REGULATORMODE1_VMMC2EN (1 << 21)
#define MC13783_REG_POWERMISC 34
#define MC13783_REG_POWERMISC_GPO1EN (1 << 6)
#define MC13783_REG_POWERMISC_GPO2EN (1 << 8)
#define MC13783_REG_POWERMISC_GPO3EN (1 << 10)
#define MC13783_REG_POWERMISC_GPO4EN (1 << 12)
struct mc13783_regulator {
struct regulator_desc desc;
int reg;
int enable_bit;
};
static struct regulator_ops mc13783_regulator_ops;
#define MC13783_DEFINE(prefix, _name, _reg) \
[MC13783_ ## prefix ## _ ## _name] = { \
.desc = { \
.name = #prefix "_" #_name, \
.ops = &mc13783_regulator_ops, \
.type = REGULATOR_VOLTAGE, \
.id = MC13783_ ## prefix ## _ ## _name, \
.owner = THIS_MODULE, \
}, \
.reg = MC13783_REG_ ## _reg, \
.enable_bit = MC13783_REG_ ## _reg ## _ ## _name ## EN, \
}
#define MC13783_DEFINE_SW(_name, _reg) MC13783_DEFINE(SW, _name, _reg)
#define MC13783_DEFINE_REGU(_name, _reg) MC13783_DEFINE(REGU, _name, _reg)
static struct mc13783_regulator mc13783_regulators[] = {
MC13783_DEFINE_SW(SW3, SWITCHERS5),
MC13783_DEFINE_SW(PLL, SWITCHERS4),
MC13783_DEFINE_REGU(VAUDIO, REGULATORMODE0),
MC13783_DEFINE_REGU(VIOHI, REGULATORMODE0),
MC13783_DEFINE_REGU(VIOLO, REGULATORMODE0),
MC13783_DEFINE_REGU(VDIG, REGULATORMODE0),
MC13783_DEFINE_REGU(VGEN, REGULATORMODE0),
MC13783_DEFINE_REGU(VRFDIG, REGULATORMODE0),
MC13783_DEFINE_REGU(VRFREF, REGULATORMODE0),
MC13783_DEFINE_REGU(VRFCP, REGULATORMODE0),
MC13783_DEFINE_REGU(VSIM, REGULATORMODE1),
MC13783_DEFINE_REGU(VESIM, REGULATORMODE1),
MC13783_DEFINE_REGU(VCAM, REGULATORMODE1),
MC13783_DEFINE_REGU(VRFBG, REGULATORMODE1),
MC13783_DEFINE_REGU(VVIB, REGULATORMODE1),
MC13783_DEFINE_REGU(VRF1, REGULATORMODE1),
MC13783_DEFINE_REGU(VRF2, REGULATORMODE1),
MC13783_DEFINE_REGU(VMMC1, REGULATORMODE1),
MC13783_DEFINE_REGU(VMMC2, REGULATORMODE1),
MC13783_DEFINE_REGU(GPO1, POWERMISC),
MC13783_DEFINE_REGU(GPO2, POWERMISC),
MC13783_DEFINE_REGU(GPO3, POWERMISC),
MC13783_DEFINE_REGU(GPO4, POWERMISC),
};
struct mc13783_regulator_priv {
struct mc13783 *mc13783;
struct regulator_dev *regulators[];
};
static int mc13783_regulator_enable(struct regulator_dev *rdev)
{
struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev);
int id = rdev_get_id(rdev);
int ret;
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
mc13783_lock(priv->mc13783);
ret = mc13783_reg_rmw(priv->mc13783, mc13783_regulators[id].reg,
mc13783_regulators[id].enable_bit,
mc13783_regulators[id].enable_bit);
mc13783_unlock(priv->mc13783);
return ret;
}
static int mc13783_regulator_disable(struct regulator_dev *rdev)
{
struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev);
int id = rdev_get_id(rdev);
int ret;
dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
mc13783_lock(priv->mc13783);
ret = mc13783_reg_rmw(priv->mc13783, mc13783_regulators[id].reg,
mc13783_regulators[id].enable_bit, 0);
mc13783_unlock(priv->mc13783);
return ret;
}
static int mc13783_regulator_is_enabled(struct regulator_dev *rdev)
{
struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev);
int ret, id = rdev_get_id(rdev);
unsigned int val;
mc13783_lock(priv->mc13783);
ret = mc13783_reg_read(priv->mc13783, mc13783_regulators[id].reg, &val);
mc13783_unlock(priv->mc13783);
if (ret)
return ret;
return (val & mc13783_regulators[id].enable_bit) != 0;
}
static struct regulator_ops mc13783_regulator_ops = {
.enable = mc13783_regulator_enable,
.disable = mc13783_regulator_disable,
.is_enabled = mc13783_regulator_is_enabled,
};
static int __devinit mc13783_regulator_probe(struct platform_device *pdev)
{
struct mc13783_regulator_priv *priv;
struct mc13783 *mc13783 = dev_get_drvdata(pdev->dev.parent);
struct mc13783_regulator_platform_data *pdata =
dev_get_platdata(&pdev->dev);
struct mc13783_regulator_init_data *init_data;
int i, ret;
dev_dbg(&pdev->dev, "mc13783_regulator_probe id %d\n", pdev->id);
priv = kzalloc(sizeof(*priv) +
pdata->num_regulators * sizeof(priv->regulators[0]),
GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->mc13783 = mc13783;
for (i = 0; i < pdata->num_regulators; i++) {
init_data = &pdata->regulators[i];
priv->regulators[i] = regulator_register(
&mc13783_regulators[init_data->id].desc,
&pdev->dev, init_data->init_data, priv);
if (IS_ERR(priv->regulators[i])) {
dev_err(&pdev->dev, "failed to register regulator %s\n",
mc13783_regulators[i].desc.name);
ret = PTR_ERR(priv->regulators[i]);
goto err;
}
}
platform_set_drvdata(pdev, priv);
return 0;
err:
while (--i >= 0)
regulator_unregister(priv->regulators[i]);
kfree(priv);
return ret;
}
static int __devexit mc13783_regulator_remove(struct platform_device *pdev)
{
struct mc13783_regulator_priv *priv = platform_get_drvdata(pdev);
struct mc13783_regulator_platform_data *pdata =
dev_get_platdata(&pdev->dev);
int i;
for (i = 0; i < pdata->num_regulators; i++)
regulator_unregister(priv->regulators[i]);
return 0;
}
static struct platform_driver mc13783_regulator_driver = {
.driver = {
.name = "mc13783-regulator",
.owner = THIS_MODULE,
},
.remove = __devexit_p(mc13783_regulator_remove),
.probe = mc13783_regulator_probe,
};
static int __init mc13783_regulator_init(void)
{
return platform_driver_register(&mc13783_regulator_driver);
}
subsys_initcall(mc13783_regulator_init);
static void __exit mc13783_regulator_exit(void)
{
platform_driver_unregister(&mc13783_regulator_driver);
}
module_exit(mc13783_regulator_exit);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de");
MODULE_DESCRIPTION("Regulator Driver for Freescale MC13783 PMIC");
MODULE_ALIAS("platform:mc13783-regulator");
This diff is collapsed.
......@@ -12,6 +12,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
......@@ -40,6 +41,12 @@ struct twlreg_info {
u8 table_len;
const u16 *table;
/* regulator specific turn-on delay */
u16 delay;
/* State REMAP default configuration */
u8 remap;
/* chip constraints on regulator behavior */
u16 min_mV;
......@@ -128,6 +135,7 @@ static int twlreg_enable(struct regulator_dev *rdev)
{
struct twlreg_info *info = rdev_get_drvdata(rdev);
int grp;
int ret;
grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
if (grp < 0)
......@@ -138,7 +146,11 @@ static int twlreg_enable(struct regulator_dev *rdev)
else
grp |= P1_GRP_6030;
return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
udelay(info->delay);
return ret;
}
static int twlreg_disable(struct regulator_dev *rdev)
......@@ -151,9 +163,9 @@ static int twlreg_disable(struct regulator_dev *rdev)
return grp;
if (twl_class_is_4030())
grp &= ~P1_GRP_4030;
grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030);
else
grp &= ~P1_GRP_6030;
grp &= ~(P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030);
return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
}
......@@ -294,6 +306,18 @@ static const u16 VSIM_VSEL_table[] = {
static const u16 VDAC_VSEL_table[] = {
1200, 1300, 1800, 1800,
};
static const u16 VDD1_VSEL_table[] = {
800, 1450,
};
static const u16 VDD2_VSEL_table[] = {
800, 1450, 1500,
};
static const u16 VIO_VSEL_table[] = {
1800, 1850,
};
static const u16 VINTANA2_VSEL_table[] = {
2500, 2750,
};
static const u16 VAUX1_6030_VSEL_table[] = {
1000, 1300, 1800, 2500,
2800, 2900, 3000, 3000,
......@@ -414,20 +438,30 @@ static struct regulator_ops twlfixed_ops = {
/*----------------------------------------------------------------------*/
#define TWL4030_ADJUSTABLE_LDO(label, offset, num) \
TWL_ADJUSTABLE_LDO(label, offset, num, TWL4030)
#define TWL4030_FIXED_LDO(label, offset, mVolts, num) \
TWL_FIXED_LDO(label, offset, mVolts, num, TWL4030)
#define TWL6030_ADJUSTABLE_LDO(label, offset, num) \
TWL_ADJUSTABLE_LDO(label, offset, num, TWL6030)
#define TWL6030_FIXED_LDO(label, offset, mVolts, num) \
TWL_FIXED_LDO(label, offset, mVolts, num, TWL6030)
#define TWL_ADJUSTABLE_LDO(label, offset, num, family) { \
#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \
TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \
remap_conf, TWL4030)
#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
remap_conf) \
TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
remap_conf, TWL4030)
#define TWL6030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \
remap_conf) \
TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \
remap_conf, TWL6030)
#define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
remap_conf) \
TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
remap_conf, TWL6030)
#define TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf, \
family) { \
.base = offset, \
.id = num, \
.table_len = ARRAY_SIZE(label##_VSEL_table), \
.table = label##_VSEL_table, \
.delay = turnon_delay, \
.remap = remap_conf, \
.desc = { \
.name = #label, \
.id = family##_REG_##label, \
......@@ -438,10 +472,13 @@ static struct regulator_ops twlfixed_ops = {
}, \
}
#define TWL_FIXED_LDO(label, offset, mVolts, num, family) { \
#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
family) { \
.base = offset, \
.id = num, \
.min_mV = mVolts, \
.delay = turnon_delay, \
.remap = remap_conf, \
.desc = { \
.name = #label, \
.id = family##_REG_##label, \
......@@ -457,43 +494,41 @@ static struct regulator_ops twlfixed_ops = {
* software control over them after boot.
*/
static struct twlreg_info twl_regs[] = {
TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1),
TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2),
TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2),
TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3),
TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4),
TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5),
TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6),
/*
TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7),
*/
TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8),
TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9),
TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10),
/*
TWL4030_ADJUSTABLE_LDO(VINTANA1, 0x3f, 11),
TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12),
TWL4030_ADJUSTABLE_LDO(VINTDIG, 0x47, 13),
TWL4030_SMPS(VIO, 0x4b, 14),
TWL4030_SMPS(VDD1, 0x55, 15),
TWL4030_SMPS(VDD2, 0x63, 16),
*/
TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17),
TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18),
TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19),
TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00),
TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00),
TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08),
TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08),
TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08),
TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08),
TWL4030_ADJUSTABLE_LDO(VDD1, 0x55, 15, 1000, 0x08),
TWL4030_ADJUSTABLE_LDO(VDD2, 0x63, 16, 1000, 0x08),
TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08),
TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08),
TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08),
/* VUSBCP is managed *only* by the USB subchip */
/* 6030 REG with base as PMC Slave Misc : 0x0030 */
TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1),
TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 2),
TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 3),
TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 4),
TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 5),
TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 7),
TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15),
TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16),
TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17),
TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18)
/* Turnon-delay and remap configuration values for 6030 are not
verified since the specification is not public */
TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1, 0, 0x08),
TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 2, 0, 0x08),
TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 3, 0, 0x08),
TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 4, 0, 0x08),
TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 5, 0, 0x08),
TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 7, 0, 0x08),
TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15, 0, 0x08),
TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16, 0, 0x08),
TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17, 0, 0x08),
TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18, 0, 0x08)
};
static int twlreg_probe(struct platform_device *pdev)
......@@ -525,6 +560,19 @@ static int twlreg_probe(struct platform_device *pdev)
c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
| REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS;
switch (pdev->id) {
case TWL4030_REG_VIO:
case TWL4030_REG_VDD1:
case TWL4030_REG_VDD2:
case TWL4030_REG_VPLL1:
case TWL4030_REG_VINTANA1:
case TWL4030_REG_VINTANA2:
case TWL4030_REG_VINTDIG:
c->always_on = true;
break;
default:
break;
}
rdev = regulator_register(&info->desc, &pdev->dev, initdata, info);
if (IS_ERR(rdev)) {
......@@ -534,6 +582,9 @@ static int twlreg_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, rdev);
twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP,
info->remap);
/* NOTE: many regulators support short-circuit IRQs (presentable
* as REGULATOR_OVER_CURRENT notifications?) configured via:
* - SC_CONFIG
......
......@@ -19,6 +19,8 @@
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/gpio.h>
#include <linux/mfd/wm831x/core.h>
#include <linux/mfd/wm831x/regulator.h>
......@@ -39,6 +41,7 @@
#define WM831X_DCDC_CONTROL_2 1
#define WM831X_DCDC_ON_CONFIG 2
#define WM831X_DCDC_SLEEP_CONTROL 3
#define WM831X_DCDC_DVS_CONTROL 4
/*
* Shared
......@@ -50,6 +53,10 @@ struct wm831x_dcdc {
int base;
struct wm831x *wm831x;
struct regulator_dev *regulator;
int dvs_gpio;
int dvs_gpio_state;
int on_vsel;
int dvs_vsel;
};
static int wm831x_dcdc_is_enabled(struct regulator_dev *rdev)
......@@ -240,11 +247,9 @@ static int wm831x_buckv_list_voltage(struct regulator_dev *rdev,
return -EINVAL;
}
static int wm831x_buckv_set_voltage_int(struct regulator_dev *rdev, int reg,
int min_uV, int max_uV)
static int wm831x_buckv_select_min_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
struct wm831x *wm831x = dcdc->wm831x;
u16 vsel;
if (min_uV < 600000)
......@@ -257,39 +262,126 @@ static int wm831x_buckv_set_voltage_int(struct regulator_dev *rdev, int reg,
if (wm831x_buckv_list_voltage(rdev, vsel) > max_uV)
return -EINVAL;
return wm831x_set_bits(wm831x, reg, WM831X_DC1_ON_VSEL_MASK, vsel);
return vsel;
}
static int wm831x_buckv_select_max_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
u16 vsel;
if (max_uV < 600000 || max_uV > 1800000)
return -EINVAL;
vsel = ((max_uV - 600000) / 12500) + 8;
if (wm831x_buckv_list_voltage(rdev, vsel) < min_uV ||
wm831x_buckv_list_voltage(rdev, vsel) < max_uV)
return -EINVAL;
return vsel;
}
static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state)
{
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
if (state == dcdc->dvs_gpio_state)
return 0;
dcdc->dvs_gpio_state = state;
gpio_set_value(dcdc->dvs_gpio, state);
/* Should wait for DVS state change to be asserted if we have
* a GPIO for it, for now assume the device is configured
* for the fastest possible transition.
*/
return 0;
}
static int wm831x_buckv_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
int min_uV, int max_uV)
{
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
struct wm831x *wm831x = dcdc->wm831x;
int on_reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
int dvs_reg = dcdc->base + WM831X_DCDC_DVS_CONTROL;
int vsel, ret;
vsel = wm831x_buckv_select_min_voltage(rdev, min_uV, max_uV);
if (vsel < 0)
return vsel;
/* If this value is already set then do a GPIO update if we can */
if (dcdc->dvs_gpio && dcdc->on_vsel == vsel)
return wm831x_buckv_set_dvs(rdev, 0);
if (dcdc->dvs_gpio && dcdc->dvs_vsel == vsel)
return wm831x_buckv_set_dvs(rdev, 1);
/* Always set the ON status to the minimum voltage */
ret = wm831x_set_bits(wm831x, on_reg, WM831X_DC1_ON_VSEL_MASK, vsel);
if (ret < 0)
return ret;
dcdc->on_vsel = vsel;
if (!dcdc->dvs_gpio)
return ret;
/* Kick the voltage transition now */
ret = wm831x_buckv_set_dvs(rdev, 0);
if (ret < 0)
return ret;
/* Set the high voltage as the DVS voltage. This is optimised
* for CPUfreq usage, most processors will keep the maximum
* voltage constant and lower the minimum with the frequency. */
vsel = wm831x_buckv_select_max_voltage(rdev, min_uV, max_uV);
if (vsel < 0) {
/* This should never happen - at worst the same vsel
* should be chosen */
WARN_ON(vsel < 0);
return 0;
}
/* Don't bother if it's the same VSEL we're already using */
if (vsel == dcdc->on_vsel)
return 0;
return wm831x_buckv_set_voltage_int(rdev, reg, min_uV, max_uV);
ret = wm831x_set_bits(wm831x, dvs_reg, WM831X_DC1_DVS_VSEL_MASK, vsel);
if (ret == 0)
dcdc->dvs_vsel = vsel;
else
dev_warn(wm831x->dev, "Failed to set DCDC DVS VSEL: %d\n",
ret);
return 0;
}
static int wm831x_buckv_set_suspend_voltage(struct regulator_dev *rdev,
int uV)
int uV)
{
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
struct wm831x *wm831x = dcdc->wm831x;
u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
int vsel;
vsel = wm831x_buckv_select_min_voltage(rdev, uV, uV);
if (vsel < 0)
return vsel;
return wm831x_buckv_set_voltage_int(rdev, reg, uV, uV);
return wm831x_set_bits(wm831x, reg, WM831X_DC1_SLP_VSEL_MASK, vsel);
}
static int wm831x_buckv_get_voltage(struct regulator_dev *rdev)
{
struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
struct wm831x *wm831x = dcdc->wm831x;
u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
int val;
val = wm831x_reg_read(wm831x, reg);
if (val < 0)
return val;
return wm831x_buckv_list_voltage(rdev, val & WM831X_DC1_ON_VSEL_MASK);
if (dcdc->dvs_gpio && dcdc->dvs_gpio_state)
return wm831x_buckv_list_voltage(rdev, dcdc->dvs_vsel);
else
return wm831x_buckv_list_voltage(rdev, dcdc->on_vsel);
}
/* Current limit options */
......@@ -346,6 +438,64 @@ static struct regulator_ops wm831x_buckv_ops = {
.set_suspend_mode = wm831x_dcdc_set_suspend_mode,
};
/*
* Set up DVS control. We just log errors since we can still run
* (with reduced performance) if we fail.
*/
static __devinit void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc,
struct wm831x_buckv_pdata *pdata)
{
struct wm831x *wm831x = dcdc->wm831x;
int ret;
u16 ctrl;
if (!pdata || !pdata->dvs_gpio)
return;
switch (pdata->dvs_control_src) {
case 1:
ctrl = 2 << WM831X_DC1_DVS_SRC_SHIFT;
break;
case 2:
ctrl = 3 << WM831X_DC1_DVS_SRC_SHIFT;
break;
default:
dev_err(wm831x->dev, "Invalid DVS control source %d for %s\n",
pdata->dvs_control_src, dcdc->name);
return;
}
ret = wm831x_set_bits(wm831x, dcdc->base + WM831X_DCDC_DVS_CONTROL,
WM831X_DC1_DVS_SRC_MASK, ctrl);
if (ret < 0) {
dev_err(wm831x->dev, "Failed to set %s DVS source: %d\n",
dcdc->name, ret);
return;
}
ret = gpio_request(pdata->dvs_gpio, "DCDC DVS");
if (ret < 0) {
dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n",
dcdc->name, ret);
return;
}
/* gpiolib won't let us read the GPIO status so pick the higher
* of the two existing voltages so we take it as platform data.
*/
dcdc->dvs_gpio_state = pdata->dvs_init_state;
ret = gpio_direction_output(pdata->dvs_gpio, dcdc->dvs_gpio_state);
if (ret < 0) {
dev_err(wm831x->dev, "Failed to enable %s DVS GPIO: %d\n",
dcdc->name, ret);
gpio_free(pdata->dvs_gpio);
return;
}
dcdc->dvs_gpio = pdata->dvs_gpio;
}
static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
......@@ -384,6 +534,23 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
dcdc->desc.ops = &wm831x_buckv_ops;
dcdc->desc.owner = THIS_MODULE;
ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG);
if (ret < 0) {
dev_err(wm831x->dev, "Failed to read ON VSEL: %d\n", ret);
goto err;
}
dcdc->on_vsel = ret & WM831X_DC1_ON_VSEL_MASK;
ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG);
if (ret < 0) {
dev_err(wm831x->dev, "Failed to read DVS VSEL: %d\n", ret);
goto err;
}
dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK;
if (pdata->dcdc[id])
wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data);
dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev,
pdata->dcdc[id], dcdc);
if (IS_ERR(dcdc->regulator)) {
......@@ -422,6 +589,8 @@ err_uv:
err_regulator:
regulator_unregister(dcdc->regulator);
err:
if (dcdc->dvs_gpio)
gpio_free(dcdc->dvs_gpio);
kfree(dcdc);
return ret;
}
......@@ -434,6 +603,8 @@ static __devexit int wm831x_buckv_remove(struct platform_device *pdev)
wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "HC"), dcdc);
wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc);
regulator_unregister(dcdc->regulator);
if (dcdc->dvs_gpio)
gpio_free(dcdc->dvs_gpio);
kfree(dcdc);
return 0;
......
......@@ -470,7 +470,7 @@ static unsigned int wm831x_aldo_get_mode(struct regulator_dev *rdev)
struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
struct wm831x *wm831x = ldo->wm831x;
int on_reg = ldo->base + WM831X_LDO_ON_CONTROL;
unsigned int ret;
int ret;
ret = wm831x_reg_read(wm831x, on_reg);
if (ret < 0)
......
......@@ -41,6 +41,23 @@ struct wm831x_battery_pdata {
int timeout; /** Charge cycle timeout, in minutes */
};
/**
* Configuration for the WM831x DC-DC BuckWise convertors. This
* should be passed as driver_data in the regulator_init_data.
*
* Currently all the configuration is for the fast DVS switching
* support of the devices. This allows MFPs on the device to be
* configured as an input to switch between two output voltages,
* allowing voltage transitions without the expense of an access over
* I2C or SPI buses.
*/
struct wm831x_buckv_pdata {
int dvs_gpio; /** CPU GPIO to use for DVS switching */
int dvs_control_src; /** Hardware DVS source to use (1 or 2) */
int dvs_init_state; /** DVS state to expect on startup */
int dvs_state_gpio; /** CPU GPIO to use for monitoring status */
};
/* Sources for status LED configuration. Values are register values
* plus 1 to allow for a zero default for preserve.
*/
......
......@@ -35,6 +35,8 @@
#ifndef __LINUX_REGULATOR_CONSUMER_H_
#define __LINUX_REGULATOR_CONSUMER_H_
#include <linux/device.h>
/*
* Regulator operating modes.
*
......
......@@ -43,16 +43,20 @@ struct regulator;
/**
* struct regulator_state - regulator state during low power system states
*
* This describes a regulators state during a system wide low power state.
* This describes a regulators state during a system wide low power
* state. One of enabled or disabled must be set for the
* configuration to be applied.
*
* @uV: Operating voltage during suspend.
* @mode: Operating mode during suspend.
* @enabled: Enabled during suspend.
* @disabled: Disabled during suspend.
*/
struct regulator_state {
int uV; /* suspend voltage */
unsigned int mode; /* suspend regulator operating mode */
int enabled; /* is regulator enabled in this suspend state */
int disabled; /* is the regulator disbled in this suspend state */
};
/**
......
/*
* max8660.h -- Voltage regulation for the Maxim 8660/8661
*
* Copyright (C) 2009 Wolfram Sang, Pengutronix e.K.
*
* 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; version 2 of the License.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LINUX_REGULATOR_MAX8660_H
#define __LINUX_REGULATOR_MAX8660_H
#include <linux/regulator/machine.h>
enum {
MAX8660_V3,
MAX8660_V4,
MAX8660_V5,
MAX8660_V6,
MAX8660_V7,
MAX8660_V_END,
};
/**
* max8660_subdev_data - regulator subdev data
* @id: regulator id
* @name: regulator name
* @platform_data: regulator init data
*/
struct max8660_subdev_data {
int id;
char *name;
struct regulator_init_data *platform_data;
};
/**
* max8660_platform_data - platform data for max8660
* @num_subdevs: number of regulators used
* @subdevs: pointer to regulators used
* @en34_is_high: if EN34 is driven high, regulators cannot be en-/disabled.
*/
struct max8660_platform_data {
int num_subdevs;
struct max8660_subdev_data *subdevs;
unsigned en34_is_high:1;
};
#endif
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