Skip to content

Commit

Permalink
Merge remote-tracking branches 'regulator/topic/max77686', 'regulator…
Browse files Browse the repository at this point in the history
…/topic/max77693', 'regulator/topic/max77802', 'regulator/topic/power-off' and 'regulator/topic/rk808' into regulator-next
  • Loading branch information
broonie committed Dec 5, 2014
6 parents af012d6 + 0480395 + 2515b24 + ff633be + 0ce5b30 + 251ce31 commit 92d07a8
Show file tree
Hide file tree
Showing 40 changed files with 623 additions and 313 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
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
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
5 changes: 3 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
8 changes: 5 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,7 +259,7 @@ 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;

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
3 changes: 2 additions & 1 deletion drivers/regulator/da9052-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ static int da9052_regulator_probe(struct platform_device *pdev)
if (!of_node_cmp(np->name,
regulator->info->reg_desc.name)) {
config.init_data = of_get_regulator_init_data(
&pdev->dev, np);
&pdev->dev, np,
&regulator->info->reg_desc);
config.of_node = np;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/regulator/da9210-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static int da9210_i2c_probe(struct i2c_client *i2c,

config.dev = &i2c->dev;
config.init_data = pdata ? &pdata->da9210_constraints :
of_get_regulator_init_data(dev, dev->of_node);
of_get_regulator_init_data(dev, dev->of_node, &da9210_reg);
config.driver_data = chip;
config.regmap = chip->regmap;
config.of_node = dev->of_node;
Expand Down
17 changes: 9 additions & 8 deletions drivers/regulator/fan53555.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ static struct regmap_config fan53555_regmap_config = {
};

static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
struct device_node *np)
struct device_node *np,
const struct regulator_desc *desc)
{
struct fan53555_platform_data *pdata;
int ret;
Expand All @@ -312,7 +313,7 @@ static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
if (!pdata)
return NULL;

pdata->regulator = of_get_regulator_init_data(dev, np);
pdata->regulator = of_get_regulator_init_data(dev, np, desc);

ret = of_property_read_u32(np, "fcs,suspend-voltage-selector",
&tmp);
Expand Down Expand Up @@ -347,20 +348,20 @@ static int fan53555_regulator_probe(struct i2c_client *client,
unsigned int val;
int ret;

di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info),
GFP_KERNEL);
if (!di)
return -ENOMEM;

pdata = dev_get_platdata(&client->dev);
if (!pdata)
pdata = fan53555_parse_dt(&client->dev, np);
pdata = fan53555_parse_dt(&client->dev, np, &di->desc);

if (!pdata || !pdata->regulator) {
dev_err(&client->dev, "Platform data not found!\n");
return -ENODEV;
}

di = devm_kzalloc(&client->dev, sizeof(struct fan53555_device_info),
GFP_KERNEL);
if (!di)
return -ENOMEM;

di->regulator = pdata->regulator;
if (client->dev.of_node) {
const struct of_device_id *match;
Expand Down
Loading

0 comments on commit 92d07a8

Please sign in to comment.