regulator: cprh-kbss-regulator: use APM hysteresis for voltage adjustments

Adjust floor voltages based upon a configurable APM hysteresis voltage.
This reduces the number of corners whose floor voltages must be raised
to ensure stable operation with manual APM switching. In particular,
for corners with ceiling voltage greater than or equal to the APM
threshold voltage and floor voltage less than APM threshold voltage
set an adjusted floor of max(floor, APM threshold - APM hysteresis).

Change-Id: I65bebcfd8f4785bce9f65243987c05444aab14ee
CRs-Fixed: 1001346
Signed-off-by: Osvaldo Banuelos <osvaldob@codeaurora.org>
This commit is contained in:
Osvaldo Banuelos 2016-04-07 15:16:40 -07:00 committed by Bryan Huntsman
parent bb3716d1cc
commit 2d36c20ef4
2 changed files with 17 additions and 9 deletions

View file

@ -50,10 +50,12 @@ KBSS specific properties:
- qcom,apm-hysteresis-voltage
Usage: optional
Value type: <u32>
Definition: Specifies the voltage delta in microvolts between the APM
threshold voltage and the highest corner open-loop voltage
which may be used as the ceiling for the corner. If this
property is not specified, then a value of 0 is assumed.
Definition: Specifies the voltage in microvolts used to adjust floor
voltages with respect to the APM threshold voltage. This
voltage is used to reduce the number of corners whose floor
must be raised to ensure stable operation with manual APM
switching. If this property is not specified, then a value
of 0 is assumed.
- qcom,voltage-base
Usage: required

View file

@ -771,10 +771,11 @@ static int cprh_kbss_apm_threshold_as_corner(struct cpr3_regulator *vreg)
*
* The following algorithm is applied in the case that
* floor < threshold <= ceiling:
* if open_loop >= threshold - adj, then floor = threshold
* if open_loop >= threshold, then floor = threshold - adj
* else ceiling = threshold - step
* where adj = an adjustment factor to ensure sufficient voltage margin and
* step = VDD output step size
* where adj = APM hysteresis voltage established to minimize number
* of corners with artificially increased floor voltages
* and step = voltage in microvolts of a single step of the VDD supply
*
* The open-loop voltage is also bounded by the new floor or ceiling value as
* needed.
@ -810,8 +811,9 @@ static int cprh_kbss_adjust_voltages_for_apm(struct cpr3_regulator *vreg)
prev_ceiling = corner->ceiling_volt;
prev_open_loop = corner->open_loop_volt;
if (corner->open_loop_volt >= threshold - adj) {
corner->floor_volt = threshold;
if (corner->open_loop_volt >= threshold) {
corner->floor_volt = max(corner->floor_volt,
threshold - adj);
if (corner->open_loop_volt < corner->floor_volt)
corner->open_loop_volt = corner->floor_volt;
} else {
@ -1289,6 +1291,10 @@ static int cprh_kbss_init_controller(struct cpr3_controller *ctrl)
if (rc)
cpr3_debug(ctrl, "qcom,apm-threshold-voltage not specified\n");
of_property_read_u32(ctrl->dev->of_node, "qcom,apm-hysteresis-voltage",
&ctrl->apm_adj_volt);
ctrl->apm_adj_volt = CPR3_ROUND(ctrl->apm_adj_volt, ctrl->step_volt);
ctrl->saw_use_unit_mV = of_property_read_bool(ctrl->dev->of_node,
"qcom,cpr-saw-use-unit-mV");