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

Commit 5a44c6c4 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "regulator: msm_gfx_ldo: Add a property to adjust the open-loop voltage"

parents 305d1a35 c50fa979
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -103,6 +103,14 @@ This document describes the bindings that apply for the GFX LDO regulator.
		    corner value for each gfx corner. The elements in the array
		    are ordered from lowest voltage corner to highest voltage corner.

- qcom,ldo-init-voltage-adjustment
	Usage:      optional
	Value type: <prop-encoded-aray>
	Definition: Array of voltages in microvolts which indicate the static
		    adjustment to be applied to the open-loop voltages for the
		    LDO supported corners. The length of this property must be
		    equal to qcom,num-ldo-corners.

=======
Example
=======
@@ -135,4 +143,5 @@ Example

		mem-acc-supply = <&gfx_mem_acc>;
		qcom,mem-acc-corner-map = <1 1 2 2 2 2 2>;
		qcom,ldo-init-voltage-adjustment = <10000 20000 30000>;
	};
+47 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@
#define LDO_READY_BIT			BIT(2)
#define BHS_EN_REST_ACK_BIT		BIT(1)

#define MIN_LDO_VOLTAGE			345000
#define MIN_LDO_VOLTAGE			375000
#define MAX_LDO_VOLTAGE			980000
#define LDO_STEP_VOLATGE		5000

@@ -733,6 +733,46 @@ static struct regulator_ops msm_gfx_ldo_corner_ops = {
	.get_voltage	= msm_gfx_ldo_get_voltage,
};

static int msm_gfx_ldo_adjust_init_voltage(struct msm_gfx_ldo *ldo_vreg)
{
	int rc, len, size, i;
	u32 *volt_adjust;
	struct device_node *of_node = ldo_vreg->dev->of_node;
	char *prop_name = "qcom,ldo-init-voltage-adjustment";

	if (!of_find_property(of_node, prop_name, &len)) {
		/* No initial voltage adjustment needed. */
		return 0;
	}

	size = len / sizeof(u32);
	if (size != ldo_vreg->num_ldo_corners) {
		pr_err("%s length=%d is invalid: required:%d\n",
				prop_name, size, ldo_vreg->num_ldo_corners);
		return -EINVAL;
	}

	volt_adjust = devm_kcalloc(ldo_vreg->dev, size, sizeof(*volt_adjust),
								GFP_KERNEL);
	rc = of_property_read_u32_array(of_node, prop_name, volt_adjust, size);
	if (rc) {
		pr_err("failed to read %s property rc=%d\n", prop_name, rc);
		return rc;
	}

	for (i = 0; i < ldo_vreg->num_corners; i++) {
		if (volt_adjust[i]) {
			ldo_vreg->open_loop_volt[i] += volt_adjust[i];
			pr_info("adjusted the open-loop voltage[%d] %d -> %d\n",
				i + MIN_CORNER_OFFSET,
				ldo_vreg->open_loop_volt[i] - volt_adjust[i],
				ldo_vreg->open_loop_volt[i]);
		}
	}

	return 0;
}

static int msm_gfx_ldo_voltage_init(struct msm_gfx_ldo *ldo_vreg)
{
	struct device_node *of_node = ldo_vreg->dev->of_node;
@@ -786,6 +826,12 @@ static int msm_gfx_ldo_voltage_init(struct msm_gfx_ldo *ldo_vreg)
			i + MIN_CORNER_OFFSET, ldo_vreg->open_loop_volt[i]);
	}

	rc = msm_gfx_ldo_adjust_init_voltage(ldo_vreg);
	if (rc) {
		pr_err("Unable to adjust init voltages rc=%d\n", rc);
		return rc;
	}

	for (i = 0; i < ldo_vreg->num_ldo_corners; i++) {
		if (ldo_vreg->open_loop_volt[i] > ldo_vreg->ceiling_volt[i]) {
			pr_info("Warning: initial voltage[%d] %d above ceiling %d\n",