提交 36e4f839 编写于 作者: S Stephen Boyd 提交者: Mark Brown

regulator: Add input current limit support

Some regulators can limit their input current (typically annotated
as ilim). Add an op (set_input_current_limit) and a DT property +
constraint to support this.
Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 57f66b78
...@@ -7,6 +7,7 @@ Optional properties: ...@@ -7,6 +7,7 @@ Optional properties:
- regulator-microvolt-offset: Offset applied to voltages to compensate for voltage drops - regulator-microvolt-offset: Offset applied to voltages to compensate for voltage drops
- regulator-min-microamp: smallest current consumers may set - regulator-min-microamp: smallest current consumers may set
- regulator-max-microamp: largest current consumers may set - regulator-max-microamp: largest current consumers may set
- regulator-input-current-limit-microamp: maximum input current regulator allows
- regulator-always-on: boolean, regulator should never be disabled - regulator-always-on: boolean, regulator should never be disabled
- regulator-boot-on: bootloader/firmware enabled regulator - regulator-boot-on: bootloader/firmware enabled regulator
- regulator-allow-bypass: allow the regulator to go into bypass mode - regulator-allow-bypass: allow the regulator to go into bypass mode
......
...@@ -1008,6 +1008,15 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1008,6 +1008,15 @@ static int set_machine_constraints(struct regulator_dev *rdev,
if (ret != 0) if (ret != 0)
goto out; goto out;
if (rdev->constraints->ilim_uA && ops->set_input_current_limit) {
ret = ops->set_input_current_limit(rdev,
rdev->constraints->ilim_uA);
if (ret < 0) {
rdev_err(rdev, "failed to set input limit\n");
goto out;
}
}
/* do we need to setup our suspend state */ /* do we need to setup our suspend state */
if (rdev->constraints->initial_state) { if (rdev->constraints->initial_state) {
ret = suspend_prepare(rdev, rdev->constraints->initial_state); ret = suspend_prepare(rdev, rdev->constraints->initial_state);
......
...@@ -58,6 +58,10 @@ static void of_get_regulation_constraints(struct device_node *np, ...@@ -58,6 +58,10 @@ static void of_get_regulation_constraints(struct device_node *np,
if (!of_property_read_u32(np, "regulator-max-microamp", &pval)) if (!of_property_read_u32(np, "regulator-max-microamp", &pval))
constraints->max_uA = pval; constraints->max_uA = pval;
if (!of_property_read_u32(np, "regulator-input-current-limit-microamp",
&pval))
constraints->ilim_uA = pval;
/* Current change possible? */ /* Current change possible? */
if (constraints->min_uA != constraints->max_uA) if (constraints->min_uA != constraints->max_uA)
constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT; constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT;
......
...@@ -91,6 +91,7 @@ struct regulator_linear_range { ...@@ -91,6 +91,7 @@ struct regulator_linear_range {
* @set_current_limit: Configure a limit for a current-limited regulator. * @set_current_limit: Configure a limit for a current-limited regulator.
* The driver should select the current closest to max_uA. * The driver should select the current closest to max_uA.
* @get_current_limit: Get the configured limit for a current-limited regulator. * @get_current_limit: Get the configured limit for a current-limited regulator.
* @set_input_current_limit: Configure an input limit.
* *
* @set_mode: Set the configured operating mode for the regulator. * @set_mode: Set the configured operating mode for the regulator.
* @get_mode: Get the configured operating mode for the regulator. * @get_mode: Get the configured operating mode for the regulator.
...@@ -145,6 +146,8 @@ struct regulator_ops { ...@@ -145,6 +146,8 @@ struct regulator_ops {
int min_uA, int max_uA); int min_uA, int max_uA);
int (*get_current_limit) (struct regulator_dev *); int (*get_current_limit) (struct regulator_dev *);
int (*set_input_current_limit) (struct regulator_dev *, int lim_uA);
/* enable/disable regulator */ /* enable/disable regulator */
int (*enable) (struct regulator_dev *); int (*enable) (struct regulator_dev *);
int (*disable) (struct regulator_dev *); int (*disable) (struct regulator_dev *);
......
...@@ -75,6 +75,7 @@ struct regulator_state { ...@@ -75,6 +75,7 @@ struct regulator_state {
* *
* @min_uA: Smallest current consumers may set. * @min_uA: Smallest current consumers may set.
* @max_uA: Largest current consumers may set. * @max_uA: Largest current consumers may set.
* @ilim_uA: Maximum input current.
* @system_load: Load that isn't captured by any consumer requests. * @system_load: Load that isn't captured by any consumer requests.
* *
* @valid_modes_mask: Mask of modes which may be configured by consumers. * @valid_modes_mask: Mask of modes which may be configured by consumers.
...@@ -113,6 +114,7 @@ struct regulation_constraints { ...@@ -113,6 +114,7 @@ struct regulation_constraints {
/* current output range (inclusive) - for current control */ /* current output range (inclusive) - for current control */
int min_uA; int min_uA;
int max_uA; int max_uA;
int ilim_uA;
int system_load; int system_load;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册