Commit 52787e91 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'regulator-v4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator updates from Mark Brown:
 "This is quite a quiet release in terms of volume of patches but it
  includes a couple of really nice core changes - the work Sascha has
  done in particular is something I've wanted to get done for a long
  time but just never got round to myself.

  Highlights include:

   - Support from Sascha Hauer for setting the voltage of parent
     supplies based on requests from their children.  This is used both
     to allow set_voltage() to work through a dumb switch and to improve
     the efficiency of systems where DCDCs are used to supply LDOs by
     minimising the voltage drop over the LDOs.

   - Removal of regulator_list by Tomeu Vizoso, meaning we're not
     duplicating the device list maintained by the driver core.

   - Support for Wolfson/Cirrus WM8998 and WM1818"

* tag 'regulator-v4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (29 commits)
  regulator: Use regulator_lock_supply() for get_voltage() too
  regulator: arizona: Add regulator specific device tree binding document
  regulator: stw481x: compile on COMPILE_TEST
  regulator: qcom-smd: Correct set_load() unit
  regulator: core: Propagate voltage changes to supply regulators
  regulator: core: Factor out regulator_map_voltage
  regulator: i.MX anatop: Allow supply regulator
  regulator: introduce min_dropout_uV
  regulator: core: create unlocked version of regulator_set_voltage
  regulator: arizona-ldo1: Fix handling of GPIO 0
  regulator: da9053: Update regulator for DA9053 BC silicon support
  regulator: max77802: Separate sections for nodes and properties
  regulator: max77802: Add input supply properties to DT binding doc
  regulator: axp20x: set supply names for AXP22X DC1SW/DC5LDO internally
  regulator: axp20x: Drop AXP221 DC1SW and DC5LDO regulator supplies from bindings
  mfd: tps6105x: Use i2c regmap to access registers
  regulator: act8865: add DT binding for property "active-semi,vsel-high"
  regulator: act8865: support output voltage by VSET2[] bits
  regulator: arizona: add support for WM8998 and WM1814
  regulator: core: create unlocked version of regulator_list_voltage
  ...
parents f66477a0 62e544b9
......@@ -60,8 +60,8 @@ DCDC2 : DC-DC buck : vin2-supply
DCDC3 : DC-DC buck : vin3-supply
DCDC4 : DC-DC buck : vin4-supply
DCDC5 : DC-DC buck : vin5-supply
DC1SW : On/Off Switch : dcdc1-supply : DCDC1 secondary output
DC5LDO : LDO : dcdc5-supply : input from DCDC5
DC1SW : On/Off Switch : : DCDC1 secondary output
DC5LDO : LDO : : input from DCDC5
ALDO1 : LDO : aldoin-supply : shared supply
ALDO2 : LDO : aldoin-supply : shared supply
ALDO3 : LDO : aldoin-supply : shared supply
......
......@@ -8,6 +8,8 @@ Required properties:
Optional properties:
- system-power-controller: Telling whether or not this pmic is controlling
the system power. See Documentation/devicetree/bindings/power/power-controller.txt .
- active-semi,vsel-high: Indicates the VSEL pin is high.
If this property is missing, assume the VSEL pin is low(0).
Optional input supply properties:
- for act8600:
......@@ -49,6 +51,7 @@ Example:
pmic: act8865@5b {
compatible = "active-semi,act8865";
reg = <0x5b>;
active-semi,vsel-high;
status = "disabled";
regulators {
......
......@@ -13,6 +13,7 @@ Optional properties:
- anatop-delay-reg-offset: Anatop MFD step time register offset
- anatop-delay-bit-shift: Bit shift for the step time register
- anatop-delay-bit-width: Number of bits used in the step time register
- vin-supply: The supply for this regulator
Any property defined as part of the core regulator
binding, defined in regulator.txt, can also be used.
......
Cirrus Logic Arizona class audio SoCs
These devices are audio SoCs with extensive digital capabilities and a range
of analogue I/O.
This document lists regulator specific bindings, see the primary binding
document:
../mfd/arizona.txt
Optional properties:
- wlf,ldoena : GPIO specifier for the GPIO controlling LDOENA
Optional subnodes:
- ldo1 : Initial data for the LDO1 regulator, as covered in
Documentation/devicetree/bindings/regulator/regulator.txt
- micvdd : Initial data for the MICVDD regulator, as covered in
Documentation/devicetree/bindings/regulator/regulator.txt
......@@ -8,7 +8,28 @@ regulators that can be controlled over I2C.
Following properties should be present in main device node of the MFD chip.
Optional node:
Optional properties:
- inb1-supply: The input supply for BUCK1
- inb2-supply: The input supply for BUCK2
- inb3-supply: The input supply for BUCK3
- inb4-supply: The input supply for BUCK4
- inb5-supply: The input supply for BUCK5
- inb6-supply: The input supply for BUCK6
- inb7-supply: The input supply for BUCK7
- inb8-supply: The input supply for BUCK8
- inb9-supply: The input supply for BUCK9
- inb10-supply: The input supply for BUCK10
- inl1-supply: The input supply for LDO8 and LDO15
- inl2-supply: The input supply for LDO17, LDO27, LDO30 and LDO35
- inl3-supply: The input supply for LDO3, LDO5, LDO6 and LDO7
- inl4-supply: The input supply for LDO10, LDO11, LDO13 and LDO14
- inl5-supply: The input supply for LDO9 and LDO19
- inl6-supply: The input supply for LDO4, LDO21, LDO24 and LDO33
- inl7-supply: The input supply for LDO18, LDO20, LDO28 and LDO29
- inl9-supply: The input supply for LDO12, LDO23, LDO25, LDO26, LDO32 and LDO34
- inl10-supply: The input supply for LDO1 and LDO2
Optional nodes:
- regulators : The regulators of max77802 have to be instantiated
under subnode named "regulators" using the following format.
......@@ -58,6 +79,8 @@ Example:
#address-cells = <1>;
#size-cells = <0>;
inb1-supply = <&parent_reg>;
regulators {
ldo1_reg: LDO1 {
regulator-name = "vdd_1v0";
......
......@@ -11,6 +11,7 @@ Optional properties:
- regulator-always-on: boolean, regulator should never be disabled
- regulator-boot-on: bootloader/firmware enabled regulator
- regulator-allow-bypass: allow the regulator to go into bypass mode
- regulator-allow-set-load: allow the regulator performance level to be configured
- <name>-supply: phandle to the parent supply/regulator node
- regulator-ramp-delay: ramp delay for regulator(in uV/uS)
For hardware which supports disabling ramp rate, it should be explicitly
......
TPS65023 family of regulators
Required properties:
- compatible: Must be one of the following.
"ti,tps65020",
"ti,tps65021",
"ti,tps65023",
- reg: I2C slave address
- regulators: list of regulators provided by this controller, must be named
after their hardware counterparts: VDCDC[1-3] and LDO[1-2]
- regulators: This is the list of child nodes that specify the regulator
initialization data for defined regulators. The definition for each of
these nodes is defined using the standard binding for regulators found at
Documentation/devicetree/bindings/regulator/regulator.txt.
Each regulator is defined using the standard binding for regulators.
Example:
tps65023@48 {
compatible = "ti,tps65023";
reg = <0x48>;
regulators {
VDCDC1 {
regulator-name = "vdd_mpu";
regulator-always-on;
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1200000>;
};
VDCDC2 {
regulator-name = "vdd_core";
regulator-always-on;
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
VDCDC3 {
regulator-name = "vdd_io";
regulator-always-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
};
LDO1 {
regulator-name = "vdd_usb18";
regulator-always-on;
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
};
LDO2 {
regulator-name = "vdd_usb33";
regulator-always-on;
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
};
};
......@@ -16,7 +16,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/mutex.h>
#include <linux/regmap.h>
#include <linux/gpio.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
......@@ -25,73 +25,18 @@
#include <linux/mfd/core.h>
#include <linux/mfd/tps6105x.h>
int tps6105x_set(struct tps6105x *tps6105x, u8 reg, u8 value)
{
int ret;
ret = mutex_lock_interruptible(&tps6105x->lock);
if (ret)
return ret;
ret = i2c_smbus_write_byte_data(tps6105x->client, reg, value);
mutex_unlock(&tps6105x->lock);
if (ret < 0)
return ret;
return 0;
}
EXPORT_SYMBOL(tps6105x_set);
int tps6105x_get(struct tps6105x *tps6105x, u8 reg, u8 *buf)
{
int ret;
ret = mutex_lock_interruptible(&tps6105x->lock);
if (ret)
return ret;
ret = i2c_smbus_read_byte_data(tps6105x->client, reg);
mutex_unlock(&tps6105x->lock);
if (ret < 0)
return ret;
*buf = ret;
return 0;
}
EXPORT_SYMBOL(tps6105x_get);
/*
* Masks off the bits in the mask and sets the bits in the bitvalues
* parameter in one atomic operation
*/
int tps6105x_mask_and_set(struct tps6105x *tps6105x, u8 reg,
u8 bitmask, u8 bitvalues)
{
int ret;
u8 regval;
ret = mutex_lock_interruptible(&tps6105x->lock);
if (ret)
return ret;
ret = i2c_smbus_read_byte_data(tps6105x->client, reg);
if (ret < 0)
goto fail;
regval = ret;
regval = (~bitmask & regval) | (bitmask & bitvalues);
ret = i2c_smbus_write_byte_data(tps6105x->client, reg, regval);
fail:
mutex_unlock(&tps6105x->lock);
if (ret < 0)
return ret;
return 0;
}
EXPORT_SYMBOL(tps6105x_mask_and_set);
static struct regmap_config tps6105x_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = TPS6105X_REG_3,
};
static int tps6105x_startup(struct tps6105x *tps6105x)
{
int ret;
u8 regval;
unsigned int regval;
ret = tps6105x_get(tps6105x, TPS6105X_REG_0, &regval);
ret = regmap_read(tps6105x->regmap, TPS6105X_REG_0, &regval);
if (ret)
return ret;
switch (regval >> TPS6105X_REG0_MODE_SHIFT) {
......@@ -145,11 +90,14 @@ static int tps6105x_probe(struct i2c_client *client,
if (!tps6105x)
return -ENOMEM;
tps6105x->regmap = devm_regmap_init_i2c(client, &tps6105x_regmap_config);
if (IS_ERR(tps6105x->regmap))
return PTR_ERR(tps6105x->regmap);
i2c_set_clientdata(client, tps6105x);
tps6105x->client = client;
pdata = dev_get_platdata(&client->dev);
tps6105x->pdata = pdata;
mutex_init(&tps6105x->lock);
ret = tps6105x_startup(tps6105x);
if (ret) {
......@@ -198,7 +146,7 @@ static int tps6105x_remove(struct i2c_client *client)
mfd_remove_devices(&client->dev);
/* Put chip in shutdown mode */
tps6105x_mask_and_set(tps6105x, TPS6105X_REG_0,
regmap_update_bits(tps6105x->regmap, TPS6105X_REG_0,
TPS6105X_REG0_MODE_MASK,
TPS6105X_MODE_SHUTDOWN << TPS6105X_REG0_MODE_SHIFT);
......
......@@ -627,7 +627,7 @@ config REGULATOR_TI_ABB
config REGULATOR_STW481X_VMMC
bool "ST Microelectronics STW481X VMMC regulator"
depends on MFD_STW481X
depends on MFD_STW481X || COMPILE_TEST
default y if MFD_STW481X
help
This driver supports the internal VMMC regulator in the STw481x
......
......@@ -261,6 +261,16 @@ static const struct regulator_desc act8865_regulators[] = {
ACT88xx_REG("LDO_REG4", ACT8865, LDO4, VSET, "inl67"),
};
static const struct regulator_desc act8865_alt_regulators[] = {
ACT88xx_REG("DCDC_REG1", ACT8865, DCDC1, VSET2, "vp1"),
ACT88xx_REG("DCDC_REG2", ACT8865, DCDC2, VSET2, "vp2"),
ACT88xx_REG("DCDC_REG3", ACT8865, DCDC3, VSET2, "vp3"),
ACT88xx_REG("LDO_REG1", ACT8865, LDO1, VSET, "inl45"),
ACT88xx_REG("LDO_REG2", ACT8865, LDO2, VSET, "inl45"),
ACT88xx_REG("LDO_REG3", ACT8865, LDO3, VSET, "inl67"),
ACT88xx_REG("LDO_REG4", ACT8865, LDO4, VSET, "inl67"),
};
#ifdef CONFIG_OF
static const struct of_device_id act8865_dt_ids[] = {
{ .compatible = "active-semi,act8600", .data = (void *)ACT8600 },
......@@ -413,6 +423,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
struct act8865 *act8865;
unsigned long type;
int off_reg, off_mask;
int voltage_select = 0;
pdata = dev_get_platdata(dev);
......@@ -424,6 +435,10 @@ static int act8865_pmic_probe(struct i2c_client *client,
return -ENODEV;
type = (unsigned long) id->data;
voltage_select = !!of_get_property(dev->of_node,
"active-semi,vsel-high",
NULL);
} else {
type = i2c_id->driver_data;
}
......@@ -442,8 +457,13 @@ static int act8865_pmic_probe(struct i2c_client *client,
off_mask = ACT8846_OFF_SYSMASK;
break;
case ACT8865:
regulators = act8865_regulators;
num_regulators = ARRAY_SIZE(act8865_regulators);
if (voltage_select) {
regulators = act8865_alt_regulators;
num_regulators = ARRAY_SIZE(act8865_alt_regulators);
} else {
regulators = act8865_regulators;
num_regulators = ARRAY_SIZE(act8865_regulators);
}
off_reg = ACT8865_SYS_CTRL;
off_mask = ACT8865_MSTROFF;
break;
......
......@@ -30,6 +30,7 @@
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/machine.h>
#define LDO_RAMP_UP_UNIT_IN_CYCLES 64 /* 64 cycles per step */
#define LDO_RAMP_UP_FREQ_IN_MHZ 24 /* cycle based on 24M OSC */
......@@ -199,6 +200,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
rdesc->owner = THIS_MODULE;
initdata = of_get_regulator_init_data(dev, np, rdesc);
initdata->supply_regulator = "vin";
sreg->initdata = initdata;
anatop_np = of_get_parent(np);
......@@ -262,6 +264,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
rdesc->vsel_reg = sreg->control_reg;
rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) <<
sreg->vol_bit_shift;
rdesc->min_dropout_uV = 125000;
config.dev = &pdev->dev;
config.init_data = initdata;
......
......@@ -17,6 +17,7 @@
#include <linux/bitops.h>
#include <linux/err.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
......@@ -189,13 +190,22 @@ static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
{
struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_ldo1 *ldo1 = config->driver_data;
struct device_node *np = arizona->dev->of_node;
struct device_node *init_node, *dcvdd_node;
struct regulator_init_data *init_data;
pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true);
pdata->ldoena = of_get_named_gpio(np, "wlf,ldoena", 0);
if (pdata->ldoena < 0) {
dev_warn(arizona->dev,
"LDOENA GPIO property missing/malformed: %d\n",
pdata->ldoena);
pdata->ldoena = 0;
} else {
config->ena_gpio_initialized = true;
}
init_node = of_get_child_by_name(arizona->dev->of_node, "ldo1");
dcvdd_node = of_parse_phandle(arizona->dev->of_node, "DCVDD-supply", 0);
init_node = of_get_child_by_name(np, "ldo1");
dcvdd_node = of_parse_phandle(np, "DCVDD-supply", 0);
if (init_node) {
config->of_node = init_node;
......@@ -245,6 +255,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
switch (arizona->type) {
case WM5102:
case WM8997:
case WM8998:
case WM1814:
desc = &arizona_ldo1_hc;
ldo1->init_data = arizona_ldo1_dvfs;
break;
......@@ -272,8 +284,6 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
ret = arizona_ldo1_of_get_pdata(arizona, &config, desc);
if (ret < 0)
return ret;
config.ena_gpio_initialized = true;
}
}
......
......@@ -196,10 +196,10 @@ static const struct regulator_desc axp22x_regulators[] = {
AXP_DESC(AXP22X, DCDC5, "dcdc5", "vin5", 1000, 2550, 50,
AXP22X_DCDC5_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(5)),
/* secondary switchable output of DCDC1 */
AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", "dcdc1", 1600, 3400, 100,
AXP_DESC_SW(AXP22X, DC1SW, "dc1sw", NULL, 1600, 3400, 100,
AXP22X_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(7)),
/* LDO regulator internally chained to DCDC5 */
AXP_DESC(AXP22X, DC5LDO, "dc5ldo", "dcdc5", 700, 1400, 100,
AXP_DESC(AXP22X, DC5LDO, "dc5ldo", NULL, 700, 1400, 100,
AXP22X_DC5LDO_V_OUT, 0x7, AXP22X_PWR_OUT_CTRL1, BIT(0)),
AXP_DESC(AXP22X, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(6)),
......@@ -350,6 +350,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
};
int ret, i, nregulators;
u32 workmode;
const char *axp22x_dc1_name = axp22x_regulators[AXP22X_DCDC1].name;
const char *axp22x_dc5_name = axp22x_regulators[AXP22X_DCDC5].name;
switch (axp20x->variant) {
case AXP202_ID:
......@@ -371,8 +373,37 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
axp20x_regulator_parse_dt(pdev);
for (i = 0; i < nregulators; i++) {
rdev = devm_regulator_register(&pdev->dev, &regulators[i],
&config);
const struct regulator_desc *desc = &regulators[i];
struct regulator_desc *new_desc;
/*
* Regulators DC1SW and DC5LDO are connected internally,
* so we have to handle their supply names separately.
*
* We always register the regulators in proper sequence,
* so the supply names are correctly read. See the last
* part of this loop to see where we save the DT defined
* name.
*/
if (regulators == axp22x_regulators) {
if (i == AXP22X_DC1SW) {
new_desc = devm_kzalloc(&pdev->dev,
sizeof(*desc),
GFP_KERNEL);
*new_desc = regulators[i];
new_desc->supply_name = axp22x_dc1_name;
desc = new_desc;
} else if (i == AXP22X_DC5LDO) {
new_desc = devm_kzalloc(&pdev->dev,
sizeof(*desc),
GFP_KERNEL);
*new_desc = regulators[i];
new_desc->supply_name = axp22x_dc5_name;
desc = new_desc;
}
}
rdev = devm_regulator_register(&pdev->dev, desc, &config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "Failed to register %s\n",
regulators[i].name);
......@@ -388,6 +419,21 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Failed to set workmode on %s\n",
rdev->desc->name);
}
/*
* Save AXP22X DCDC1 / DCDC5 regulator names for later.
*/
if (regulators == axp22x_regulators) {
/* Can we use rdev->constraints->name instead? */
if (i == AXP22X_DCDC1)
of_property_read_string(rdev->dev.of_node,
"regulator-name",
&axp22x_dc1_name);
else if (i == AXP22X_DCDC5)
of_property_read_string(rdev->dev.of_node,
"regulator-name",
&axp22x_dc5_name);
}
}
return 0;
......
......@@ -244,7 +244,7 @@ static int bcm590xx_get_enable_register(int id)
break;
case BCM590XX_REG_VBUS:
reg = BCM590XX_OTG_CTRL;
};
}
return reg;
......
This diff is collapsed.
......@@ -381,6 +381,7 @@ static inline struct da9052_regulator_info *find_regulator_info(u8 chip_id,
case DA9053_AA:
case DA9053_BA:
case DA9053_BB:
case DA9053_BC:
for (i = 0; i < ARRAY_SIZE(da9053_regulator_info); i++) {
info = &da9053_regulator_info[i];
if (info->reg_desc.id == id)
......
......@@ -698,7 +698,7 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt(
rdata->initdata = da9063_matches[i].init_data;
n++;
};
}
*da9063_reg_matches = da9063_matches;
return pdata;
......
......@@ -76,6 +76,9 @@ static void of_get_regulation_constraints(struct device_node *np,
if (of_property_read_bool(np, "regulator-allow-bypass"))
constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS;
if (of_property_read_bool(np, "regulator-allow-set-load"))
constraints->valid_ops_mask |= REGULATOR_CHANGE_DRMS;
ret = of_property_read_u32(np, "regulator-ramp-delay", &pval);
if (!ret) {
if (pval)
......
......@@ -69,12 +69,6 @@ static int pwm_regulator_set_voltage_sel(struct regulator_dev *rdev,
drvdata->state = selector;
ret = pwm_enable(drvdata->pwm);
if (ret) {
dev_err(&rdev->dev, "Failed to enable PWM\n");
return ret;
}
return 0;
}
......@@ -89,6 +83,29 @@ static int pwm_regulator_list_voltage(struct regulator_dev *rdev,
return drvdata->duty_cycle_table[selector].uV;
}
static int pwm_regulator_enable(struct regulator_dev *dev)
{
struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
return pwm_enable(drvdata->pwm);
}
static int pwm_regulator_disable(struct regulator_dev *dev)
{
struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
pwm_disable(drvdata->pwm);
return 0;
}
static int pwm_regulator_is_enabled(struct regulator_dev *dev)
{
struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
return pwm_is_enabled(drvdata->pwm);
}
/**
* Continuous voltage call-backs
*/
......@@ -144,11 +161,17 @@ static struct regulator_ops pwm_regulator_voltage_table_ops = {
.get_voltage_sel = pwm_regulator_get_voltage_sel,
.list_voltage = pwm_regulator_list_voltage,
.map_voltage = regulator_map_voltage_iterate,
.enable = pwm_regulator_enable,
.disable = pwm_regulator_disable,
.is_enabled = pwm_regulator_is_enabled,
};
static struct regulator_ops pwm_regulator_voltage_continuous_ops = {
.get_voltage = pwm_regulator_get_voltage,
.set_voltage = pwm_regulator_set_voltage,
.enable = pwm_regulator_enable,
.disable = pwm_regulator_disable,
.is_enabled = pwm_regulator_is_enabled,
};
static struct regulator_desc pwm_regulator_desc = {
......
......@@ -36,9 +36,9 @@ struct qcom_rpm_reg {
};
struct rpm_regulator_req {
u32 key;
u32 nbytes;
u32 value;
__le32 key;
__le32 nbytes;
__le32 value;
};
#define RPM_KEY_SWEN 0x6e657773 /* "swen" */
......@@ -62,9 +62,9 @@ static int rpm_reg_enable(struct regulator_dev *rdev)
struct rpm_regulator_req req;
int ret;
req.key = RPM_KEY_SWEN;
req.nbytes = sizeof(u32);
req.value = 1;
req.key = cpu_to_le32(RPM_KEY_SWEN);
req.nbytes = cpu_to_le32(sizeof(u32));
req.value = cpu_to_le32(1);
ret = rpm_reg_write_active(vreg, &req, sizeof(req));
if (!ret)
......@@ -86,8 +86,8 @@ static int rpm_reg_disable(struct regulator_dev *rdev)
struct rpm_regulator_req req;
int ret;
req.key = RPM_KEY_SWEN;
req.nbytes = sizeof(u32);
req.key = cpu_to_le32(RPM_KEY_SWEN);
req.nbytes = cpu_to_le32(sizeof(u32));
req.value = 0;
ret = rpm_reg_write_active(vreg, &req, sizeof(req));
......@@ -113,9 +113,9 @@ static int rpm_reg_set_voltage(struct regulator_dev *rdev,
struct rpm_regulator_req req;
int ret = 0;
req.key = RPM_KEY_UV;
req.nbytes = sizeof(u32);
req.value = min_uV;
req.key = cpu_to_le32(RPM_KEY_UV);
req.nbytes = cpu_to_le32(sizeof(u32));
req.value = cpu_to_le32(min_uV);
ret = rpm_reg_write_active(vreg, &req, sizeof(req));
if (!ret)
......@@ -129,9 +129,9 @@ static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA)
struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev);
struct rpm_regulator_req req;
req.key = RPM_KEY_MA;
req.nbytes = sizeof(u32);
req.value = load_uA;
req.key = cpu_to_le32(RPM_KEY_MA);
req.nbytes = cpu_to_le32(sizeof(u32));
req.value = cpu_to_le32(load_uA / 1000);
return rpm_reg_write_active(vreg, &req, sizeof(req));
}
......
......@@ -14,7 +14,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/mfd/core.h>
......@@ -33,7 +33,7 @@ static int tps6105x_regulator_enable(struct regulator_dev *rdev)
int ret;
/* Activate voltage mode */
ret = tps6105x_mask_and_set(tps6105x, TPS6105X_REG_0,
ret = regmap_update_bits(tps6105x->regmap, TPS6105X_REG_0,
TPS6105X_REG0_MODE_MASK,
TPS6105X_REG0_MODE_VOLTAGE << TPS6105X_REG0_MODE_SHIFT);
if (ret)
......@@ -48,7 +48,7 @@ static int tps6105x_regulator_disable(struct regulator_dev *rdev)
int ret;
/* Set into shutdown mode */
ret = tps6105x_mask_and_set(tps6105x, TPS6105X_REG_0,
ret = regmap_update_bits(tps6105x->regmap, TPS6105X_REG_0,
TPS6105X_REG0_MODE_MASK,
TPS6105X_REG0_MODE_SHUTDOWN << TPS6105X_REG0_MODE_SHIFT);
if (ret)
......@@ -60,10 +60,10 @@ static int tps6105x_regulator_disable(struct regulator_dev *rdev)
static int tps6105x_regulator_is_enabled(struct regulator_dev *rdev)
{
struct tps6105x *tps6105x = rdev_get_drvdata(rdev);
u8 regval;
unsigned int regval;
int ret;
ret = tps6105x_get(tps6105x, TPS6105X_REG_0, &regval);
ret = regmap_read(tps6105x->regmap, TPS6105X_REG_0, &regval);
if (ret)
return ret;
regval &= TPS6105X_REG0_MODE_MASK;
......@@ -78,10 +78,10 @@ static int tps6105x_regulator_is_enabled(struct regulator_dev *rdev)
static int tps6105x_regulator_get_voltage_sel(struct regulator_dev *rdev)
{
struct tps6105x *tps6105x = rdev_get_drvdata(rdev);
u8 regval;
unsigned int regval;
int ret;
ret = tps6105x_get(tps6105x, TPS6105X_REG_0, &regval);
ret = regmap_read(tps6105x->regmap, TPS6105X_REG_0, &regval);
if (ret)
return ret;
......@@ -96,7 +96,7 @@ static int tps6105x_regulator_set_voltage_sel(struct regulator_dev *rdev,
struct tps6105x *tps6105x = rdev_get_drvdata(rdev);
int ret;
ret = tps6105x_mask_and_set(tps6105x, TPS6105X_REG_0,
ret = regmap_update_bits(tps6105x->regmap, TPS6105X_REG_0,
TPS6105X_REG0_VOLTAGE_MASK,
selector << TPS6105X_REG0_VOLTAGE_SHIFT);
if (ret)
......
This diff is collapsed.
......@@ -10,6 +10,7 @@
#define MFD_TPS6105X_H
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/regulator/machine.h>
/*
......@@ -82,20 +83,15 @@ struct tps6105x_platform_data {
/**
* struct tps6105x - state holder for the TPS6105x drivers
* @mutex: mutex to serialize I2C accesses
* @i2c_client: corresponding I2C client
* @regulator: regulator device if used in voltage mode
* @regmap: used for i2c communcation on accessing registers
*/
struct tps6105x {
struct tps6105x_platform_data *pdata;
struct mutex lock;
struct i2c_client *client;
struct regulator_dev *regulator;
struct regmap *regmap;
};
extern int tps6105x_set(struct tps6105x *tps6105x, u8 reg, u8 value);
extern int tps6105x_get(struct tps6105x *tps6105x, u8 reg, u8 *buf);
extern int tps6105x_mask_and_set(struct tps6105x *tps6105x, u8 reg,
u8 bitmask, u8 bitvalues);
#endif
......@@ -245,6 +245,7 @@ enum regulator_type {
* @linear_min_sel: Minimal selector for starting linear mapping
* @fixed_uV: Fixed voltage of rails.
* @ramp_delay: Time to settle down after voltage change (unit: uV/us)
* @min_dropout_uV: The minimum dropout voltage this regulator can handle
* @linear_ranges: A constant table of possible voltage ranges.
* @n_linear_ranges: Number of entries in the @linear_ranges table.
* @volt_table: Voltage mapping table (if table based mapping)
......@@ -292,6 +293,7 @@ struct regulator_desc {
unsigned int linear_min_sel;
int fixed_uV;
unsigned int ramp_delay;
int min_dropout_uV;
const struct regulator_linear_range *linear_ranges;
int n_linear_ranges;
......
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