Skip to content

Commit

Permalink
Merge remote-tracking branches 'regulator/topic/mode', 'regulator/top…
Browse files Browse the repository at this point in the history
…ic/notifier', 'regulator/topic/palmas', 'regulator/topic/qcom' and 'regulator/topic/stw481x' into regulator-next
  • Loading branch information
Mark Brown committed Apr 10, 2015
6 parents 3984c9d + 7e476c7 + 046db76 + e999c72 + ce8ae17 + 14aef29 commit bea3672
Show file tree
Hide file tree
Showing 14 changed files with 334 additions and 152 deletions.
2 changes: 1 addition & 1 deletion Documentation/power/regulator/consumer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Indirect operating mode control.
Consumer drivers can request a change in their supply regulator operating mode
by calling :-

int regulator_set_optimum_mode(struct regulator *regulator, int load_uA);
int regulator_set_load(struct regulator *regulator, int load_uA);

This will cause the core to recalculate the total load on the regulator (based
on all its consumers) and change operating mode (if necessary and permitted)
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/msm/edp/edp_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static int edp_regulator_enable(struct edp_ctrl *ctrl)
goto vdda_set_fail;
}

ret = regulator_set_optimum_mode(ctrl->vdda_vreg, VDDA_UA_ON_LOAD);
ret = regulator_set_load(ctrl->vdda_vreg, VDDA_UA_ON_LOAD);
if (ret < 0) {
pr_err("%s: vdda_vreg set regulator mode failed.\n", __func__);
goto vdda_set_fail;
Expand All @@ -356,7 +356,7 @@ static int edp_regulator_enable(struct edp_ctrl *ctrl)
lvl_enable_fail:
regulator_disable(ctrl->vdda_vreg);
vdda_enable_fail:
regulator_set_optimum_mode(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);
regulator_set_load(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);
vdda_set_fail:
return ret;
}
Expand All @@ -365,7 +365,7 @@ static void edp_regulator_disable(struct edp_ctrl *ctrl)
{
regulator_disable(ctrl->lvl_vreg);
regulator_disable(ctrl->vdda_vreg);
regulator_set_optimum_mode(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);
regulator_set_load(ctrl->vdda_vreg, VDDA_UA_OFF_LOAD);
}

static int edp_gpio_config(struct edp_ctrl *ctrl)
Expand Down
4 changes: 2 additions & 2 deletions drivers/phy/phy-qcom-ufs.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ int ufs_qcom_phy_cfg_vreg(struct phy *phy,
goto out;
}
uA_load = on ? vreg->max_uA : 0;
ret = regulator_set_optimum_mode(reg, uA_load);
ret = regulator_set_load(reg, uA_load);
if (ret >= 0) {
/*
* regulator_set_optimum_mode() returns new regulator
* regulator_set_load() returns new regulator
* mode upon success.
*/
ret = 0;
Expand Down
8 changes: 4 additions & 4 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3061,7 +3061,7 @@ unsigned int regulator_get_mode(struct regulator *regulator)
EXPORT_SYMBOL_GPL(regulator_get_mode);

/**
* regulator_set_optimum_mode - set regulator optimum operating mode
* regulator_set_load - set regulator load
* @regulator: regulator source
* @uA_load: load current
*
Expand All @@ -3084,9 +3084,9 @@ EXPORT_SYMBOL_GPL(regulator_get_mode);
* DRMS will sum the total requested load on the regulator and change
* to the most efficient operating mode if platform constraints allow.
*
* Returns the new regulator mode or error.
* On error a negative errno is returned.
*/
int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
int regulator_set_load(struct regulator *regulator, int uA_load)
{
struct regulator_dev *rdev = regulator->rdev;
int ret;
Expand All @@ -3098,7 +3098,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)

return ret;
}
EXPORT_SYMBOL_GPL(regulator_set_optimum_mode);
EXPORT_SYMBOL_GPL(regulator_set_load);

/**
* regulator_allow_bypass - allow the regulator to go into bypass mode
Expand Down
85 changes: 85 additions & 0 deletions drivers/regulator/devres.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,88 @@ void devm_regulator_bulk_unregister_supply_alias(struct device *dev,
devm_regulator_unregister_supply_alias(dev, id[i]);
}
EXPORT_SYMBOL_GPL(devm_regulator_bulk_unregister_supply_alias);

struct regulator_notifier_match {
struct regulator *regulator;
struct notifier_block *nb;
};

static int devm_regulator_match_notifier(struct device *dev, void *res,
void *data)
{
struct regulator_notifier_match *match = res;
struct regulator_notifier_match *target = data;

return match->regulator == target->regulator && match->nb == target->nb;
}

static void devm_regulator_destroy_notifier(struct device *dev, void *res)
{
struct regulator_notifier_match *match = res;

regulator_unregister_notifier(match->regulator, match->nb);
}

/**
* devm_regulator_register_notifier - Resource managed
* regulator_register_notifier
*
* @regulator: regulator source
* @nb: notifier block
*
* The notifier will be registers under the consumer device and be
* automatically be unregistered when the source device is unbound.
*/
int devm_regulator_register_notifier(struct regulator *regulator,
struct notifier_block *nb)
{
struct regulator_notifier_match *match;
int ret;

match = devres_alloc(devm_regulator_destroy_notifier,
sizeof(struct regulator_notifier_match),
GFP_KERNEL);
if (!match)
return -ENOMEM;

match->regulator = regulator;
match->nb = nb;

ret = regulator_register_notifier(regulator, nb);
if (ret < 0) {
devres_free(match);
return ret;
}

devres_add(regulator->dev, match);

return 0;
}
EXPORT_SYMBOL_GPL(devm_regulator_register_notifier);

/**
* devm_regulator_unregister_notifier - Resource managed
* regulator_unregister_notifier()
*
* @regulator: regulator source
* @nb: notifier block
*
* Unregister a notifier registered with devm_regulator_register_notifier().
* Normally this function will not need to be called and the resource
* management code will ensure that the resource is freed.
*/
void devm_regulator_unregister_notifier(struct regulator *regulator,
struct notifier_block *nb)
{
struct regulator_notifier_match match;
int rc;

match.regulator = regulator;
match.nb = nb;

rc = devres_release(regulator->dev, devm_regulator_destroy_notifier,
devm_regulator_match_notifier, &match);
if (rc != 0)
WARN_ON(rc);
}
EXPORT_SYMBOL_GPL(devm_regulator_unregister_notifier);
11 changes: 9 additions & 2 deletions drivers/regulator/palmas-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,9 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic,
(id == PALMAS_REG_LDO6))
desc->enable_time = 2000;
} else {
if (!ddata->has_regen3 && id == PALMAS_REG_REGEN3)
continue;

desc->n_voltages = 1;
if (reg_init && reg_init->roof_floor)
desc->ops = &palmas_ops_ext_control_extreg;
Expand Down Expand Up @@ -1398,6 +1401,7 @@ static struct palmas_pmic_driver_data palmas_ddata = {
.ldo_begin = PALMAS_REG_LDO1,
.ldo_end = PALMAS_REG_LDOUSB,
.max_reg = PALMAS_NUM_REGS,
.has_regen3 = true,
.palmas_regs_info = palmas_generic_regs_info,
.palmas_matches = palmas_matches,
.sleep_req_info = palma_sleep_req_info,
Expand All @@ -1411,6 +1415,7 @@ static struct palmas_pmic_driver_data tps65917_ddata = {
.ldo_begin = TPS65917_REG_LDO1,
.ldo_end = TPS65917_REG_LDO5,
.max_reg = TPS65917_NUM_REGS,
.has_regen3 = true,
.palmas_regs_info = tps65917_regs_info,
.palmas_matches = tps65917_matches,
.sleep_req_info = tps65917_sleep_req_info,
Expand Down Expand Up @@ -1505,7 +1510,7 @@ static void palmas_dt_to_pdata(struct device *dev,
pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator");
}

static struct of_device_id of_palmas_match_tbl[] = {
static const struct of_device_id of_palmas_match_tbl[] = {
{
.compatible = "ti,palmas-pmic",
.data = &palmas_ddata,
Expand Down Expand Up @@ -1572,9 +1577,11 @@ static int palmas_regulators_probe(struct platform_device *pdev)
if (!pmic)
return -ENOMEM;

if (of_device_is_compatible(node, "ti,tps659038-pmic"))
if (of_device_is_compatible(node, "ti,tps659038-pmic")) {
palmas_generic_regs_info[PALMAS_REG_REGEN2].ctrl_addr =
TPS659038_REGEN2_CTRL;
palmas_ddata.has_regen3 = false;
}

pmic->dev = &pdev->dev;
pmic->palmas = palmas;
Expand Down
Loading

0 comments on commit bea3672

Please sign in to comment.