Skip to content

Commit

Permalink
Merge tag 'regulator-v3.19' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/broonie/regulator

Pull regulator updates from Mark Brown:
 "The main thing this time around is support for suspend mode
  configuration from DT which will enable some very useful power savings
  on systems where we can't rely on the bootloader configuration.  We
  still don't really support dynamic configuration of this at runtime,
  that may come later if there is any demand.

  Summary:
   - Support for specifying the target regulation mode and voltage
     during system suspend via DT, enabling power savings in that mode.
   - Reduce the default verbosity of the logging on boot, improving boot
     times especially for systems with very large numbers of regulators.
   - Lots of cleanups and fixes for Maxim PMIC drivers.
   - New driver for Richtek RT5033"

* tag 'regulator-v3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (62 commits)
  regulator: core: Fix regualtor_ena_gpio_free not to access pin after freeing
  regulator: sky81452: Modify Device Tree structure
  regulator: sky81452: Modify Device Tree structure
  dt-bindings: Update documentation for "system-power-controller" and fix misspellings
  of: Rename "poweroff-source" property to "system-power-controller"
  regulator: max77686: Remove support for board files
  regulator: max77802: Remove support for board files
  regulator: max77802: Fill regulator modes translation callback
  regulator: max77802: Document binding for regulator operating modes
  regulator: of: Add support for parsing initial and suspend modes
  regulator: of: Pass the regulator description in the match table
  regulator: of: Add regulator desc param to of_get_regulator_init_data()
  regulator: Add mode mapping function to struct regulator_desc
  regulator: Document binding for initial and suspend modes
  regulator: core: Add PRE_DISABLE notification
  regulator: gpio: fix parsing of gpio list
  regulator: rpm: add support for RPM-controller SMB208
  regulator: da9063: Do not transform local IRQ to virtual
  regulator: sky81452: Modify dependent Kconfig symbol
  regulator: rt5033: Add RT5033 Regulator device driver
  ...
  • Loading branch information
torvalds committed Dec 9, 2014
2 parents de74038 + 176488f commit f94784b
Show file tree
Hide file tree
Showing 53 changed files with 911 additions and 467 deletions.
18 changes: 18 additions & 0 deletions Documentation/devicetree/bindings/power/power-controller.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
* Generic system power control capability

Power-management integrated circuits or miscellaneous hardware components are
sometimes able to control the system power. The device driver associated with these
components might need to define this capability, which tells the kernel that
it can be used to switch off the system. The corresponding device must have the
standard property "system-power-controller" in its device node. This property
marks the device as able to control the system power. In order to test if this
property is found programmatically, use the helper function
"of_device_is_system_power_controller" from of.h .

Example:

act8846: act8846@5 {
compatible = "active-semi,act8846";
status = "okay";
system-power-controller;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Required properties:
- compatible: "active-semi,act8846" or "active-semi,act8865"
- reg: I2C slave address

Optional properties:
- system-power-controller: Telling whether or not this pmic is controlling
the system power. See Documentation/devicetree/bindings/power/power-controller.txt .

Any standard regulator properties can be used to configure the single regulator.

The valid names for regulators are:
Expand Down
35 changes: 35 additions & 0 deletions Documentation/devicetree/bindings/regulator/max77802.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@ with their hardware counterparts as follow. The valid names are:
example: LDO1, LDO2, LDO35.
-BUCKn : for BUCKs, where n can lie in range 1 to 10.
example: BUCK1, BUCK5, BUCK10.

The max77802 regulator supports two different operating modes: Normal and Low
Power Mode. Some regulators support the modes to be changed at startup or by
the consumers during normal operation while others only support to change the
mode during system suspend. The standard regulator suspend states binding can
be used to configure the regulator operating mode.

The regulators that support the standard "regulator-initial-mode" property,
changing their mode during normal operation are: LDOs 1, 3, 20 and 21.

The possible values for "regulator-initial-mode" and "regulator-mode" are:
1: Normal regulator voltage output mode.
3: Low Power which reduces the quiescent current down to only 1uA

The list of valid modes are defined in the dt-bindings/clock/maxim,max77802.h
header and can be included by device tree source files.

The standard "regulator-mode" property can only be used for regulators that
support changing their mode to Low Power Mode during suspend. These regulators
are: BUCKs 2-4 and LDOs 1-35. Also, it only takes effect if the regulator has
been enabled for the given suspend state using "regulator-on-in-suspend" and
has not been disabled for that state using "regulator-off-in-suspend".

Example:

max77802@09 {
Expand All @@ -36,11 +59,23 @@ Example:
#size-cells = <0>;

regulators {
ldo1_reg: LDO1 {
regulator-name = "vdd_1v0";
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <1000000>;
regulator-always-on;
regulator-initial-mode = <MAX77802_OPMODE_LP>;
};

ldo11_reg: LDO11 {
regulator-name = "vdd_ldo11";
regulator-min-microvolt = <1900000>;
regulator-max-microvolt = <1900000>;
regulator-always-on;
regulator-state-mem {
regulator-on-in-suspend;
regulator-mode = <MAX77802_OPMODE_LP>;
};
};

buck1_reg: BUCK1 {
Expand Down
22 changes: 22 additions & 0 deletions Documentation/devicetree/bindings/regulator/regulator.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ Optional properties:
design requires. This property describes the total system ramp time
required due to the combination of internal ramping of the regulator itself,
and board design issues such as trace capacitance and load on the supply.
- regulator-state-mem sub-root node for Suspend-to-RAM mode
: suspend to memory, the device goes to sleep, but all data stored in memory,
only some external interrupt can wake the device.
- regulator-state-disk sub-root node for Suspend-to-DISK mode
: suspend to disk, this state operates similarly to Suspend-to-RAM,
but includes a final step of writing memory contents to disk.
- regulator-state-[mem/disk] node has following common properties:
- regulator-on-in-suspend: regulator should be on in suspend state.
- regulator-off-in-suspend: regulator should be off in suspend state.
- regulator-suspend-microvolt: regulator should be set to this voltage
in suspend.
- regulator-mode: operating mode in the given suspend state.
The set of possible operating modes depends on the capabilities of
every hardware so the valid modes are documented on each regulator
device tree binding document.
- regulator-initial-mode: initial operating mode. The set of possible operating
modes depends on the capabilities of every hardware so each device binding
documentation explains which values the regulator supports.

Deprecated properties:
- regulator-compatible: If a regulator chip contains multiple
Expand All @@ -34,6 +52,10 @@ Example:
regulator-max-microvolt = <2500000>;
regulator-always-on;
vin-supply = <&vin>;

regulator-state-mem {
regulator-on-in-suspend;
};
};

Regulator Consumers:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
SKY81452 voltage regulator

Required properties:
- regulator node named lout.
- any required generic properties defined in regulator.txt

Optional properties:
Expand All @@ -9,8 +10,9 @@ Optional properties:
Example:

regulator {
/* generic regulator properties */
regulator-name = "touch_en";
regulator-min-microvolt = <4500000>;
regulator-max-microvolt = <8000000>;
lout {
regulator-name = "sky81452-lout";
regulator-min-microvolt = <4500000>;
regulator-max-microvolt = <8000000>;
};
};
3 changes: 2 additions & 1 deletion drivers/regulator/88pm8607.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ static int pm8607_regulator_dt_init(struct platform_device *pdev,
for_each_child_of_node(nproot, np) {
if (!of_node_cmp(np->name, info->desc.name)) {
config->init_data =
of_get_regulator_init_data(&pdev->dev, np);
of_get_regulator_init_data(&pdev->dev, np,
&info->desc);
config->of_node = np;
break;
}
Expand Down
10 changes: 9 additions & 1 deletion drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,14 @@ config REGULATOR_RN5T618
help
Say y here to support the regulators found on Ricoh RN5T618 PMIC.

config REGULATOR_RT5033
tristate "Richtek RT5033 Regulators"
depends on MFD_RT5033
help
This adds support for voltage and current regulators in Richtek
RT5033 PMIC. The device supports multiple regulators like
current source, LDO and Buck.

config REGULATOR_S2MPA01
tristate "Samsung S2MPA01 voltage regulator"
depends on MFD_SEC_CORE
Expand All @@ -547,7 +555,7 @@ config REGULATOR_S5M8767

config REGULATOR_SKY81452
tristate "Skyworks Solutions SKY81452 voltage regulator"
depends on SKY81452
depends on MFD_SKY81452
help
This driver supports Skyworks SKY81452 voltage output regulator
via I2C bus. SKY81452 has one voltage linear regulator can be
Expand Down
1 change: 1 addition & 0 deletions drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o
obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o
obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o
obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
Expand Down
31 changes: 31 additions & 0 deletions drivers/regulator/act8865-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
#define ACT8846_REG12_VSET 0xa0
#define ACT8846_REG12_CTRL 0xa1
#define ACT8846_REG13_CTRL 0xb1
#define ACT8846_GLB_OFF_CTRL 0xc3
#define ACT8846_OFF_SYSMASK 0x18

/*
* ACT8865 Global Register Map.
Expand All @@ -84,6 +86,7 @@
#define ACT8865_LDO3_CTRL 0x61
#define ACT8865_LDO4_VSET 0x64
#define ACT8865_LDO4_CTRL 0x65
#define ACT8865_MSTROFF 0x20

/*
* Field Definitions.
Expand All @@ -98,6 +101,8 @@

struct act8865 {
struct regmap *regmap;
int off_reg;
int off_mask;
};

static const struct regmap_config act8865_regmap_config = {
Expand Down Expand Up @@ -275,6 +280,16 @@ static struct regulator_init_data
return NULL;
}

static struct i2c_client *act8865_i2c_client;
static void act8865_power_off(void)
{
struct act8865 *act8865;

act8865 = i2c_get_clientdata(act8865_i2c_client);
regmap_write(act8865->regmap, act8865->off_reg, act8865->off_mask);
while (1);
}

static int act8865_pmic_probe(struct i2c_client *client,
const struct i2c_device_id *i2c_id)
{
Expand All @@ -285,6 +300,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
int i, ret, num_regulators;
struct act8865 *act8865;
unsigned long type;
int off_reg, off_mask;

pdata = dev_get_platdata(dev);

Expand All @@ -304,10 +320,14 @@ static int act8865_pmic_probe(struct i2c_client *client,
case ACT8846:
regulators = act8846_regulators;
num_regulators = ARRAY_SIZE(act8846_regulators);
off_reg = ACT8846_GLB_OFF_CTRL;
off_mask = ACT8846_OFF_SYSMASK;
break;
case ACT8865:
regulators = act8865_regulators;
num_regulators = ARRAY_SIZE(act8865_regulators);
off_reg = ACT8865_SYS_CTRL;
off_mask = ACT8865_MSTROFF;
break;
default:
dev_err(dev, "invalid device id %lu\n", type);
Expand Down Expand Up @@ -345,6 +365,17 @@ static int act8865_pmic_probe(struct i2c_client *client,
return ret;
}

if (of_device_is_system_power_controller(dev->of_node)) {
if (!pm_power_off) {
act8865_i2c_client = client;
act8865->off_reg = off_reg;
act8865->off_mask = off_mask;
pm_power_off = act8865_power_off;
} else {
dev_err(dev, "Failed to set poweroff capability, already defined\n");
}
}

/* Finally register devices */
for (i = 0; i < num_regulators; i++) {
const struct regulator_desc *desc = &regulators[i];
Expand Down
18 changes: 16 additions & 2 deletions drivers/regulator/anatop-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,18 @@ static int anatop_regulator_probe(struct platform_device *pdev)
int ret = 0;
u32 val;

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 = of_get_property(np, "regulator-name", NULL);
rdesc = &sreg->rdesc;
rdesc->name = sreg->name;
rdesc->type = REGULATOR_VOLTAGE;
rdesc->owner = THIS_MODULE;

initdata = of_get_regulator_init_data(dev, np, rdesc);
sreg->initdata = initdata;

anatop_np = of_get_parent(np);
if (!anatop_np)
return -ENODEV;
Expand Down Expand Up @@ -283,6 +284,19 @@ static int anatop_regulator_probe(struct platform_device *pdev)
sreg->sel = 0;
sreg->bypass = true;
}

/*
* In case vddpu was disabled by the bootloader, we need to set
* a sane default until imx6-cpufreq was probed and changes the
* voltage to the correct value. In this case we set 1.25V.
*/
if (!sreg->sel && !strcmp(sreg->name, "vddpu"))
sreg->sel = 22;

if (!sreg->sel) {
dev_err(&pdev->dev, "Failed to read a valid default voltage selector.\n");
return -EINVAL;
}
} else {
rdesc->ops = &anatop_rops;
}
Expand Down
10 changes: 7 additions & 3 deletions drivers/regulator/arizona-ldo1.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ static const struct regulator_init_data arizona_ldo1_default = {
};

static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
struct regulator_config *config)
struct regulator_config *config,
const struct regulator_desc *desc)
{
struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_ldo1 *ldo1 = config->driver_data;
Expand All @@ -194,7 +195,8 @@ static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
if (init_node) {
config->of_node = init_node;

init_data = of_get_regulator_init_data(arizona->dev, init_node);
init_data = of_get_regulator_init_data(arizona->dev, init_node,
desc);

if (init_data) {
init_data->consumer_supplies = &ldo1->supply;
Expand Down Expand Up @@ -257,9 +259,11 @@ static int arizona_ldo1_probe(struct platform_device *pdev)

if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) {
ret = arizona_ldo1_of_get_pdata(arizona, &config);
ret = arizona_ldo1_of_get_pdata(arizona, &config, desc);
if (ret < 0)
return ret;

config.ena_gpio_initialized = true;
}
}

Expand Down
8 changes: 5 additions & 3 deletions drivers/regulator/arizona-micsupp.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
};

static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
struct regulator_config *config)
struct regulator_config *config,
const struct regulator_desc *desc)
{
struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_micsupp *micsupp = config->driver_data;
Expand All @@ -210,7 +211,7 @@ static int arizona_micsupp_of_get_pdata(struct arizona *arizona,
if (np) {
config->of_node = np;

init_data = of_get_regulator_init_data(arizona->dev, np);
init_data = of_get_regulator_init_data(arizona->dev, np, desc);

if (init_data) {
init_data->consumer_supplies = &micsupp->supply;
Expand Down Expand Up @@ -264,7 +265,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev)

if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) {
ret = arizona_micsupp_of_get_pdata(arizona, &config);
ret = arizona_micsupp_of_get_pdata(arizona, &config,
desc);
if (ret < 0)
return ret;
}
Expand Down
Loading

0 comments on commit f94784b

Please sign in to comment.