Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bea36728 authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branches 'regulator/topic/mode',...

Merge remote-tracking branches 'regulator/topic/mode', 'regulator/topic/notifier', 'regulator/topic/palmas', 'regulator/topic/qcom' and 'regulator/topic/stw481x' into regulator-next
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -137,7 +137,7 @@ Indirect operating mode control.
Consumer drivers can request a change in their supply regulator operating mode
Consumer drivers can request a change in their supply regulator operating mode
by calling :-
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
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)
on all its consumers) and change operating mode (if necessary and permitted)
+3 −3
Original line number Original line Diff line number Diff line
@@ -332,7 +332,7 @@ static int edp_regulator_enable(struct edp_ctrl *ctrl)
		goto vdda_set_fail;
		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) {
	if (ret < 0) {
		pr_err("%s: vdda_vreg set regulator mode failed.\n", __func__);
		pr_err("%s: vdda_vreg set regulator mode failed.\n", __func__);
		goto vdda_set_fail;
		goto vdda_set_fail;
@@ -356,7 +356,7 @@ static int edp_regulator_enable(struct edp_ctrl *ctrl)
lvl_enable_fail:
lvl_enable_fail:
	regulator_disable(ctrl->vdda_vreg);
	regulator_disable(ctrl->vdda_vreg);
vdda_enable_fail:
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:
vdda_set_fail:
	return ret;
	return ret;
}
}
@@ -365,7 +365,7 @@ static void edp_regulator_disable(struct edp_ctrl *ctrl)
{
{
	regulator_disable(ctrl->lvl_vreg);
	regulator_disable(ctrl->lvl_vreg);
	regulator_disable(ctrl->vdda_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)
static int edp_gpio_config(struct edp_ctrl *ctrl)
+2 −2
Original line number Original line Diff line number Diff line
@@ -346,10 +346,10 @@ int ufs_qcom_phy_cfg_vreg(struct phy *phy,
			goto out;
			goto out;
		}
		}
		uA_load = on ? vreg->max_uA : 0;
		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) {
		if (ret >= 0) {
			/*
			/*
			 * regulator_set_optimum_mode() returns new regulator
			 * regulator_set_load() returns new regulator
			 * mode upon success.
			 * mode upon success.
			 */
			 */
			ret = 0;
			ret = 0;
+4 −4
Original line number Original line Diff line number Diff line
@@ -3061,7 +3061,7 @@ unsigned int regulator_get_mode(struct regulator *regulator)
EXPORT_SYMBOL_GPL(regulator_get_mode);
EXPORT_SYMBOL_GPL(regulator_get_mode);


/**
/**
 * regulator_set_optimum_mode - set regulator optimum operating mode
 * regulator_set_load - set regulator load
 * @regulator: regulator source
 * @regulator: regulator source
 * @uA_load: load current
 * @uA_load: load current
 *
 *
@@ -3084,9 +3084,9 @@ EXPORT_SYMBOL_GPL(regulator_get_mode);
 * DRMS will sum the total requested load on the regulator and change
 * DRMS will sum the total requested load on the regulator and change
 * to the most efficient operating mode if platform constraints allow.
 * 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;
	struct regulator_dev *rdev = regulator->rdev;
	int ret;
	int ret;
@@ -3098,7 +3098,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)


	return ret;
	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
 * regulator_allow_bypass - allow the regulator to go into bypass mode
+85 −0
Original line number Original line Diff line number Diff line
@@ -413,3 +413,88 @@ void devm_regulator_bulk_unregister_supply_alias(struct device *dev,
		devm_regulator_unregister_supply_alias(dev, id[i]);
		devm_regulator_unregister_supply_alias(dev, id[i]);
}
}
EXPORT_SYMBOL_GPL(devm_regulator_bulk_unregister_supply_alias);
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);
Loading