You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'topic/suspend' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-max77802
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
®ulator->info->reg_desc);
|
||||
config.of_node = np;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
|
||||
@@ -40,13 +40,15 @@ struct fixed_voltage_data {
|
||||
/**
|
||||
* of_get_fixed_voltage_config - extract fixed_voltage_config structure info
|
||||
* @dev: device requesting for fixed_voltage_config
|
||||
* @desc: regulator description
|
||||
*
|
||||
* Populates fixed_voltage_config structure by extracting data from device
|
||||
* tree node, returns a pointer to the populated structure of NULL if memory
|
||||
* alloc fails.
|
||||
*/
|
||||
static struct fixed_voltage_config *
|
||||
of_get_fixed_voltage_config(struct device *dev)
|
||||
of_get_fixed_voltage_config(struct device *dev,
|
||||
const struct regulator_desc *desc)
|
||||
{
|
||||
struct fixed_voltage_config *config;
|
||||
struct device_node *np = dev->of_node;
|
||||
@@ -57,7 +59,7 @@ of_get_fixed_voltage_config(struct device *dev)
|
||||
if (!config)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
config->init_data = of_get_regulator_init_data(dev, dev->of_node);
|
||||
config->init_data = of_get_regulator_init_data(dev, dev->of_node, desc);
|
||||
if (!config->init_data)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
@@ -112,8 +114,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
||||
struct regulator_config cfg = { };
|
||||
int ret;
|
||||
|
||||
drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),
|
||||
GFP_KERNEL);
|
||||
if (!drvdata)
|
||||
return -ENOMEM;
|
||||
|
||||
if (pdev->dev.of_node) {
|
||||
config = of_get_fixed_voltage_config(&pdev->dev);
|
||||
config = of_get_fixed_voltage_config(&pdev->dev,
|
||||
&drvdata->desc);
|
||||
if (IS_ERR(config))
|
||||
return PTR_ERR(config);
|
||||
} else {
|
||||
@@ -123,11 +131,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
||||
if (!config)
|
||||
return -ENOMEM;
|
||||
|
||||
drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),
|
||||
GFP_KERNEL);
|
||||
if (!drvdata)
|
||||
return -ENOMEM;
|
||||
|
||||
drvdata->desc.name = devm_kstrdup(&pdev->dev,
|
||||
config->supply_name,
|
||||
GFP_KERNEL);
|
||||
|
||||
@@ -133,7 +133,8 @@ static struct regulator_ops gpio_regulator_voltage_ops = {
|
||||
};
|
||||
|
||||
static struct gpio_regulator_config *
|
||||
of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
|
||||
of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
|
||||
const struct regulator_desc *desc)
|
||||
{
|
||||
struct gpio_regulator_config *config;
|
||||
const char *regtype;
|
||||
@@ -146,7 +147,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
|
||||
if (!config)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
config->init_data = of_get_regulator_init_data(dev, np);
|
||||
config->init_data = of_get_regulator_init_data(dev, np, desc);
|
||||
if (!config->init_data)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
@@ -243,17 +244,18 @@ static int gpio_regulator_probe(struct platform_device *pdev)
|
||||
struct regulator_config cfg = { };
|
||||
int ptr, ret, state;
|
||||
|
||||
if (np) {
|
||||
config = of_get_gpio_regulator_config(&pdev->dev, np);
|
||||
if (IS_ERR(config))
|
||||
return PTR_ERR(config);
|
||||
}
|
||||
|
||||
drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
|
||||
GFP_KERNEL);
|
||||
if (drvdata == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
if (np) {
|
||||
config = of_get_gpio_regulator_config(&pdev->dev, np,
|
||||
&drvdata->desc);
|
||||
if (IS_ERR(config))
|
||||
return PTR_ERR(config);
|
||||
}
|
||||
|
||||
drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
|
||||
if (drvdata->desc.name == NULL) {
|
||||
dev_err(&pdev->dev, "Failed to allocate supply name\n");
|
||||
|
||||
@@ -174,7 +174,7 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev)
|
||||
if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed))
|
||||
dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n");
|
||||
|
||||
pd->reg_data = of_get_regulator_init_data(dev, np);
|
||||
pd->reg_data = of_get_regulator_init_data(dev, np, ®ulator);
|
||||
if (!pd->reg_data) {
|
||||
dev_err(dev, "Failed to parse regulator init data\n");
|
||||
return NULL;
|
||||
|
||||
@@ -458,7 +458,8 @@ static int max8973_probe(struct i2c_client *client,
|
||||
|
||||
config.dev = &client->dev;
|
||||
config.init_data = pdata ? pdata->reg_init_data :
|
||||
of_get_regulator_init_data(&client->dev, client->dev.of_node);
|
||||
of_get_regulator_init_data(&client->dev, client->dev.of_node,
|
||||
&max->desc);
|
||||
config.driver_data = max;
|
||||
config.of_node = client->dev.of_node;
|
||||
config.regmap = max->regmap;
|
||||
|
||||
@@ -953,7 +953,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
|
||||
|
||||
rdata->id = i;
|
||||
rdata->initdata = of_get_regulator_init_data(&pdev->dev,
|
||||
reg_np);
|
||||
reg_np,
|
||||
®ulators[i]);
|
||||
rdata->reg_node = reg_np;
|
||||
rdata++;
|
||||
}
|
||||
|
||||
@@ -686,8 +686,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev,
|
||||
continue;
|
||||
|
||||
rdata->id = regulators[i].id;
|
||||
rdata->initdata = of_get_regulator_init_data(
|
||||
iodev->dev, reg_np);
|
||||
rdata->initdata = of_get_regulator_init_data(iodev->dev,
|
||||
reg_np,
|
||||
®ulators[i]);
|
||||
rdata->reg_node = reg_np;
|
||||
++rdata;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,8 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
|
||||
regulators[i].desc.name)) {
|
||||
p->id = i;
|
||||
p->init_data = of_get_regulator_init_data(
|
||||
&pdev->dev, child);
|
||||
&pdev->dev, child,
|
||||
®ulators[i].desc);
|
||||
p->node = child;
|
||||
p++;
|
||||
|
||||
|
||||
@@ -19,12 +19,20 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
static const char *const regulator_states[PM_SUSPEND_MAX + 1] = {
|
||||
[PM_SUSPEND_MEM] = "regulator-state-mem",
|
||||
[PM_SUSPEND_MAX] = "regulator-state-disk",
|
||||
};
|
||||
|
||||
static void of_get_regulation_constraints(struct device_node *np,
|
||||
struct regulator_init_data **init_data)
|
||||
struct regulator_init_data **init_data,
|
||||
const struct regulator_desc *desc)
|
||||
{
|
||||
const __be32 *min_uV, *max_uV;
|
||||
struct regulation_constraints *constraints = &(*init_data)->constraints;
|
||||
int ret;
|
||||
struct regulator_state *suspend_state;
|
||||
struct device_node *suspend_np;
|
||||
int ret, i;
|
||||
u32 pval;
|
||||
|
||||
constraints->name = of_get_property(np, "regulator-name", NULL);
|
||||
@@ -73,18 +81,84 @@ static void of_get_regulation_constraints(struct device_node *np,
|
||||
ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval);
|
||||
if (!ret)
|
||||
constraints->enable_time = pval;
|
||||
|
||||
if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) {
|
||||
if (desc && desc->of_map_mode) {
|
||||
ret = desc->of_map_mode(pval);
|
||||
if (ret == -EINVAL)
|
||||
pr_err("%s: invalid mode %u\n", np->name, pval);
|
||||
else
|
||||
constraints->initial_mode = ret;
|
||||
} else {
|
||||
pr_warn("%s: mapping for mode %d not defined\n",
|
||||
np->name, pval);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(regulator_states); i++) {
|
||||
switch (i) {
|
||||
case PM_SUSPEND_MEM:
|
||||
suspend_state = &constraints->state_mem;
|
||||
break;
|
||||
case PM_SUSPEND_MAX:
|
||||
suspend_state = &constraints->state_disk;
|
||||
break;
|
||||
case PM_SUSPEND_ON:
|
||||
case PM_SUSPEND_FREEZE:
|
||||
case PM_SUSPEND_STANDBY:
|
||||
default:
|
||||
continue;
|
||||
};
|
||||
|
||||
suspend_np = of_get_child_by_name(np, regulator_states[i]);
|
||||
if (!suspend_np || !suspend_state)
|
||||
continue;
|
||||
|
||||
if (!of_property_read_u32(suspend_np, "regulator-mode",
|
||||
&pval)) {
|
||||
if (desc && desc->of_map_mode) {
|
||||
ret = desc->of_map_mode(pval);
|
||||
if (ret == -EINVAL)
|
||||
pr_err("%s: invalid mode %u\n",
|
||||
np->name, pval);
|
||||
else
|
||||
suspend_state->mode = ret;
|
||||
} else {
|
||||
pr_warn("%s: mapping for mode %d not defined\n",
|
||||
np->name, pval);
|
||||
}
|
||||
}
|
||||
|
||||
if (of_property_read_bool(suspend_np,
|
||||
"regulator-on-in-suspend"))
|
||||
suspend_state->enabled = true;
|
||||
else if (of_property_read_bool(suspend_np,
|
||||
"regulator-off-in-suspend"))
|
||||
suspend_state->disabled = true;
|
||||
|
||||
if (!of_property_read_u32(suspend_np,
|
||||
"regulator-suspend-microvolt", &pval))
|
||||
suspend_state->uV = pval;
|
||||
|
||||
of_node_put(suspend_np);
|
||||
suspend_state = NULL;
|
||||
suspend_np = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* of_get_regulator_init_data - extract regulator_init_data structure info
|
||||
* @dev: device requesting for regulator_init_data
|
||||
* @node: regulator device node
|
||||
* @desc: regulator description
|
||||
*
|
||||
* Populates regulator_init_data structure by extracting data from device
|
||||
* tree node, returns a pointer to the populated struture or NULL if memory
|
||||
* alloc fails.
|
||||
*/
|
||||
struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
|
||||
struct device_node *node)
|
||||
struct device_node *node,
|
||||
const struct regulator_desc *desc)
|
||||
{
|
||||
struct regulator_init_data *init_data;
|
||||
|
||||
@@ -95,7 +169,7 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
|
||||
if (!init_data)
|
||||
return NULL; /* Out of memory? */
|
||||
|
||||
of_get_regulation_constraints(node, &init_data);
|
||||
of_get_regulation_constraints(node, &init_data, desc);
|
||||
return init_data;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_get_regulator_init_data);
|
||||
@@ -176,7 +250,8 @@ int of_regulator_match(struct device *dev, struct device_node *node,
|
||||
continue;
|
||||
|
||||
match->init_data =
|
||||
of_get_regulator_init_data(dev, child);
|
||||
of_get_regulator_init_data(dev, child,
|
||||
match->desc);
|
||||
if (!match->init_data) {
|
||||
dev_err(dev,
|
||||
"failed to parse DT for regulator %s\n",
|
||||
@@ -223,7 +298,7 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
|
||||
if (strcmp(desc->of_match, name))
|
||||
continue;
|
||||
|
||||
init_data = of_get_regulator_init_data(dev, child);
|
||||
init_data = of_get_regulator_init_data(dev, child, desc);
|
||||
if (!init_data) {
|
||||
dev_err(dev,
|
||||
"failed to parse DT for regulator %s\n",
|
||||
|
||||
@@ -149,7 +149,8 @@ static int pwm_regulator_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
config.init_data = of_get_regulator_init_data(&pdev->dev, np);
|
||||
config.init_data = of_get_regulator_init_data(&pdev->dev, np,
|
||||
&drvdata->desc);
|
||||
if (!config.init_data)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -643,10 +643,6 @@ static int rpm_reg_probe(struct platform_device *pdev)
|
||||
match = of_match_device(rpm_of_match, &pdev->dev);
|
||||
template = match->data;
|
||||
|
||||
initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node);
|
||||
if (!initdata)
|
||||
return -EINVAL;
|
||||
|
||||
vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
|
||||
if (!vreg) {
|
||||
dev_err(&pdev->dev, "failed to allocate vreg\n");
|
||||
@@ -666,6 +662,11 @@ static int rpm_reg_probe(struct platform_device *pdev)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
|
||||
&vreg->desc);
|
||||
if (!initdata)
|
||||
return -EINVAL;
|
||||
|
||||
key = "reg";
|
||||
ret = of_property_read_u32(pdev->dev.of_node, key, &val);
|
||||
if (ret) {
|
||||
|
||||
@@ -581,7 +581,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
|
||||
|
||||
rdata->id = i;
|
||||
rdata->initdata = of_get_regulator_init_data(
|
||||
&pdev->dev, reg_np);
|
||||
&pdev->dev, reg_np,
|
||||
®ulators[i]);
|
||||
rdata->reg_node = reg_np;
|
||||
rdata++;
|
||||
rmode->id = i;
|
||||
|
||||
@@ -76,7 +76,7 @@ static struct regulator_init_data *sky81452_reg_parse_dt(struct device *dev)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
init_data = of_get_regulator_init_data(dev, np);
|
||||
init_data = of_get_regulator_init_data(dev, np, &sky81452_reg);
|
||||
|
||||
of_node_put(np);
|
||||
return init_data;
|
||||
|
||||
@@ -72,7 +72,8 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev)
|
||||
config.regmap = stw481x->map;
|
||||
config.of_node = pdev->dev.of_node;
|
||||
config.init_data = of_get_regulator_init_data(&pdev->dev,
|
||||
pdev->dev.of_node);
|
||||
pdev->dev.of_node,
|
||||
&vmmc_regulator);
|
||||
|
||||
stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev,
|
||||
&vmmc_regulator, &config);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user