Merge remote-tracking branches 'regulator/topic/anatop', 'regulator/topic/disable', 'regulator/topic/dummy' and 'regulator/topic/gpio' into regulator-next
This commit is contained in:
commit
af012d6278
|
@ -283,6 +283,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;
|
||||
}
|
||||
|
|
|
@ -260,6 +260,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
|
|||
ret = arizona_ldo1_of_get_pdata(arizona, &config);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
config.ena_gpio_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1978,9 +1978,18 @@ static int _regulator_disable(struct regulator_dev *rdev)
|
|||
|
||||
/* we are last user */
|
||||
if (_regulator_can_change_status(rdev)) {
|
||||
ret = _notifier_call_chain(rdev,
|
||||
REGULATOR_EVENT_PRE_DISABLE,
|
||||
NULL);
|
||||
if (ret & NOTIFY_STOP_MASK)
|
||||
return -EINVAL;
|
||||
|
||||
ret = _regulator_do_disable(rdev);
|
||||
if (ret < 0) {
|
||||
rdev_err(rdev, "failed to disable\n");
|
||||
_notifier_call_chain(rdev,
|
||||
REGULATOR_EVENT_ABORT_DISABLE,
|
||||
NULL);
|
||||
return ret;
|
||||
}
|
||||
_notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
|
||||
|
@ -2037,9 +2046,16 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
|
||||
REGULATOR_EVENT_PRE_DISABLE, NULL);
|
||||
if (ret & NOTIFY_STOP_MASK)
|
||||
return -EINVAL;
|
||||
|
||||
ret = _regulator_do_disable(rdev);
|
||||
if (ret < 0) {
|
||||
rdev_err(rdev, "failed to force disable\n");
|
||||
_notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
|
||||
REGULATOR_EVENT_ABORT_DISABLE, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -3652,7 +3668,8 @@ regulator_register(const struct regulator_desc *regulator_desc,
|
|||
|
||||
dev_set_drvdata(&rdev->dev, rdev);
|
||||
|
||||
if (config->ena_gpio && gpio_is_valid(config->ena_gpio)) {
|
||||
if ((config->ena_gpio || config->ena_gpio_initialized) &&
|
||||
gpio_is_valid(config->ena_gpio)) {
|
||||
ret = regulator_ena_gpio_request(rdev, config);
|
||||
if (ret != 0) {
|
||||
rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
|
||||
|
|
|
@ -33,7 +33,7 @@ static struct regulator_init_data dummy_initdata = {
|
|||
|
||||
static struct regulator_ops dummy_ops;
|
||||
|
||||
static struct regulator_desc dummy_desc = {
|
||||
static const struct regulator_desc dummy_desc = {
|
||||
.name = "regulator-dummy",
|
||||
.id = -1,
|
||||
.type = REGULATOR_VOLTAGE,
|
||||
|
|
|
@ -157,8 +157,11 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
|||
|
||||
drvdata->desc.fixed_uV = config->microvolts;
|
||||
|
||||
if (config->gpio >= 0)
|
||||
if (gpio_is_valid(config->gpio)) {
|
||||
cfg.ena_gpio = config->gpio;
|
||||
if (pdev->dev.of_node)
|
||||
cfg.ena_gpio_initialized = true;
|
||||
}
|
||||
cfg.ena_gpio_invert = !config->enable_high;
|
||||
if (config->enabled_at_boot) {
|
||||
if (config->enable_high)
|
||||
|
|
|
@ -162,34 +162,41 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
|
|||
|
||||
config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);
|
||||
|
||||
/* Fetch GPIOs. */
|
||||
config->nr_gpios = of_gpio_count(np);
|
||||
/* Fetch GPIOs. - optional property*/
|
||||
ret = of_gpio_count(np);
|
||||
if ((ret < 0) && (ret != -ENOENT))
|
||||
return ERR_PTR(ret);
|
||||
|
||||
config->gpios = devm_kzalloc(dev,
|
||||
sizeof(struct gpio) * config->nr_gpios,
|
||||
GFP_KERNEL);
|
||||
if (!config->gpios)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
if (ret > 0) {
|
||||
config->nr_gpios = ret;
|
||||
config->gpios = devm_kzalloc(dev,
|
||||
sizeof(struct gpio) * config->nr_gpios,
|
||||
GFP_KERNEL);
|
||||
if (!config->gpios)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
proplen = of_property_count_u32_elems(np, "gpios-states");
|
||||
/* optional property */
|
||||
if (proplen < 0)
|
||||
proplen = 0;
|
||||
proplen = of_property_count_u32_elems(np, "gpios-states");
|
||||
/* optional property */
|
||||
if (proplen < 0)
|
||||
proplen = 0;
|
||||
|
||||
if (proplen > 0 && proplen != config->nr_gpios) {
|
||||
dev_warn(dev, "gpios <-> gpios-states mismatch\n");
|
||||
proplen = 0;
|
||||
}
|
||||
if (proplen > 0 && proplen != config->nr_gpios) {
|
||||
dev_warn(dev, "gpios <-> gpios-states mismatch\n");
|
||||
proplen = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < config->nr_gpios; i++) {
|
||||
gpio = of_get_named_gpio(np, "gpios", i);
|
||||
if (gpio < 0)
|
||||
break;
|
||||
config->gpios[i].gpio = gpio;
|
||||
if (proplen > 0) {
|
||||
of_property_read_u32_index(np, "gpios-states", i, &ret);
|
||||
if (ret)
|
||||
config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
|
||||
for (i = 0; i < config->nr_gpios; i++) {
|
||||
gpio = of_get_named_gpio(np, "gpios", i);
|
||||
if (gpio < 0)
|
||||
break;
|
||||
config->gpios[i].gpio = gpio;
|
||||
if (proplen > 0) {
|
||||
of_property_read_u32_index(np, "gpios-states",
|
||||
i, &ret);
|
||||
if (ret)
|
||||
config->gpios[i].flags =
|
||||
GPIOF_OUT_INIT_HIGH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,13 +268,23 @@ static int gpio_regulator_probe(struct platform_device *pdev)
|
|||
goto err;
|
||||
}
|
||||
|
||||
drvdata->gpios = kmemdup(config->gpios,
|
||||
config->nr_gpios * sizeof(struct gpio),
|
||||
GFP_KERNEL);
|
||||
if (drvdata->gpios == NULL) {
|
||||
dev_err(&pdev->dev, "Failed to allocate gpio data\n");
|
||||
ret = -ENOMEM;
|
||||
goto err_name;
|
||||
if (config->nr_gpios != 0) {
|
||||
drvdata->gpios = kmemdup(config->gpios,
|
||||
config->nr_gpios * sizeof(struct gpio),
|
||||
GFP_KERNEL);
|
||||
if (drvdata->gpios == NULL) {
|
||||
dev_err(&pdev->dev, "Failed to allocate gpio data\n");
|
||||
ret = -ENOMEM;
|
||||
goto err_name;
|
||||
}
|
||||
|
||||
drvdata->nr_gpios = config->nr_gpios;
|
||||
ret = gpio_request_array(drvdata->gpios, drvdata->nr_gpios);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev,
|
||||
"Could not obtain regulator setting GPIOs: %d\n", ret);
|
||||
goto err_memstate;
|
||||
}
|
||||
}
|
||||
|
||||
drvdata->states = kmemdup(config->states,
|
||||
|
@ -301,14 +318,6 @@ static int gpio_regulator_probe(struct platform_device *pdev)
|
|||
goto err_memgpio;
|
||||
}
|
||||
|
||||
drvdata->nr_gpios = config->nr_gpios;
|
||||
ret = gpio_request_array(drvdata->gpios, drvdata->nr_gpios);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev,
|
||||
"Could not obtain regulator setting GPIOs: %d\n", ret);
|
||||
goto err_memstate;
|
||||
}
|
||||
|
||||
/* build initial state from gpio init data. */
|
||||
state = 0;
|
||||
for (ptr = 0; ptr < drvdata->nr_gpios; ptr++) {
|
||||
|
@ -322,8 +331,10 @@ static int gpio_regulator_probe(struct platform_device *pdev)
|
|||
cfg.driver_data = drvdata;
|
||||
cfg.of_node = np;
|
||||
|
||||
if (config->enable_gpio >= 0)
|
||||
if (gpio_is_valid(config->enable_gpio)) {
|
||||
cfg.ena_gpio = config->enable_gpio;
|
||||
cfg.ena_gpio_initialized = true;
|
||||
}
|
||||
cfg.ena_gpio_invert = !config->enable_high;
|
||||
if (config->enabled_at_boot) {
|
||||
if (config->enable_high)
|
||||
|
|
|
@ -225,6 +225,8 @@ static int max8952_pmic_probe(struct i2c_client *client,
|
|||
config.of_node = client->dev.of_node;
|
||||
|
||||
config.ena_gpio = pdata->gpio_en;
|
||||
if (client->dev.of_node)
|
||||
config.ena_gpio_initialized = true;
|
||||
if (pdata->reg_data->constraints.boot_on)
|
||||
config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
|
||||
|
||||
|
|
|
@ -886,6 +886,7 @@ common_reg:
|
|||
config.regmap = iodev->regmap_pmic;
|
||||
config.driver_data = s2mps11;
|
||||
config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
|
||||
config.ena_gpio_initialized = true;
|
||||
for (i = 0; i < s2mps11->rdev_num; i++) {
|
||||
struct regulator_dev *regulator;
|
||||
|
||||
|
|
|
@ -950,6 +950,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
|
|||
config.of_node = pdata->regulators[i].reg_node;
|
||||
config.ena_gpio = -EINVAL;
|
||||
config.ena_gpio_flags = 0;
|
||||
config.ena_gpio_initialized = true;
|
||||
if (gpio_is_valid(pdata->regulators[i].ext_control_gpio))
|
||||
s5m8767_regulator_config_ext_control(s5m8767,
|
||||
&pdata->regulators[i], &config);
|
||||
|
|
|
@ -312,7 +312,11 @@ static void tps65090_configure_regulator_config(
|
|||
gpio_flag = GPIOF_OUT_INIT_HIGH;
|
||||
|
||||
config->ena_gpio = tps_pdata->gpio;
|
||||
config->ena_gpio_initialized = true;
|
||||
config->ena_gpio_flags = gpio_flag;
|
||||
} else {
|
||||
config->ena_gpio = -EINVAL;
|
||||
config->ena_gpio_initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,10 +145,12 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
|
|||
config.driver_data = ldo;
|
||||
config.regmap = wm8994->regmap;
|
||||
config.init_data = &ldo->init_data;
|
||||
if (pdata)
|
||||
if (pdata) {
|
||||
config.ena_gpio = pdata->ldo[id].enable;
|
||||
else if (wm8994->dev->of_node)
|
||||
} else if (wm8994->dev->of_node) {
|
||||
config.ena_gpio = wm8994->pdata.ldo[id].enable;
|
||||
config.ena_gpio_initialized = true;
|
||||
}
|
||||
|
||||
/* Use default constraints if none set up */
|
||||
if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) {
|
||||
|
|
|
@ -101,6 +101,8 @@ struct regmap;
|
|||
* Data passed is "struct pre_voltage_change_data"
|
||||
* ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
|
||||
* Data passed is old voltage cast to (void *).
|
||||
* PRE_DISABLE Regulator is about to be disabled
|
||||
* ABORT_DISABLE Regulator disable failed for some reason
|
||||
*
|
||||
* NOTE: These events can be OR'ed together when passed into handler.
|
||||
*/
|
||||
|
@ -115,6 +117,8 @@ struct regmap;
|
|||
#define REGULATOR_EVENT_DISABLE 0x80
|
||||
#define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100
|
||||
#define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200
|
||||
#define REGULATOR_EVENT_PRE_DISABLE 0x400
|
||||
#define REGULATOR_EVENT_ABORT_DISABLE 0x800
|
||||
|
||||
/**
|
||||
* struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
|
||||
|
|
|
@ -301,6 +301,9 @@ struct regulator_desc {
|
|||
* NULL).
|
||||
* @regmap: regmap to use for core regmap helpers if dev_get_regulator() is
|
||||
* insufficient.
|
||||
* @ena_gpio_initialized: GPIO controlling regulator enable was properly
|
||||
* initialized, meaning that >= 0 is a valid gpio
|
||||
* identifier and < 0 is a non existent gpio.
|
||||
* @ena_gpio: GPIO controlling regulator enable.
|
||||
* @ena_gpio_invert: Sense for GPIO enable control.
|
||||
* @ena_gpio_flags: Flags to use when calling gpio_request_one()
|
||||
|
@ -312,6 +315,7 @@ struct regulator_config {
|
|||
struct device_node *of_node;
|
||||
struct regmap *regmap;
|
||||
|
||||
bool ena_gpio_initialized;
|
||||
int ena_gpio;
|
||||
unsigned int ena_gpio_invert:1;
|
||||
unsigned int ena_gpio_flags;
|
||||
|
|
Loading…
Reference in a new issue