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

Commit 3cbee4bc authored by David Collins's avatar David Collins
Browse files

regulator: cpr-regulator: add initial voltage reference property support



Add support in the cpr-regulator driver for a new device tree
property named qcom,cpr-init-voltage-ref which specifies the
reference voltages to use when decoding initial voltage fuse
values.  This property decouples inital voltage fuse decoding
from the specification of CPR ceiling voltages.  This feature
is needed since some SoCs utilize reference voltages which
are different from the ceiling voltages.

Change-Id: I87cd8a053253fa538e773aefa774c53ab69063a2
Signed-off-by: default avatarDavid Collins <collinsd@codeaurora.org>
parent cb99ebc7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -290,6 +290,11 @@ Optional properties:
				highest voltage fuse corner.
				A given cpr-regulator device must have either qcom,cpr-fuse-init-voltage
				specified or qcom,pvs-voltage-table (and its associated properties).
- qcom,cpr-init-voltage-ref:	Array of reference voltages in microvolts used when decoding the initial
				voltage fuse values.  The elements in the array are ordered from lowest
				voltage corner to highest voltage corner.  This property must be of length
				defined by qcom,cpr-fuse-corners.
				This property is required if qcom,cpr-fuse-init-voltage is present.
- qcom,cpr-init-voltage-step:	The voltage step size in microvolts of the CPR initial voltage fuses described by the
				qcom,cpr-fuse-init-voltage property.
				This property is required if qcom,cpr-fuse-init-voltage is present.
@@ -410,6 +415,7 @@ Example:
				<27 36 6 0>,
				<27 18 6 0>,
				<27 0 6 0>;
		qcom,cpr-init-voltage-ref = <1050000 1150000 1280000>;
		qcom,cpr-init-voltage-step = <10000>;
	};
+1 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@
					<27 36 6 0>,
					<27 18 6 0>,
					<27 0 6 0>;
		qcom,cpr-init-voltage-ref = <1050000 1150000 1350000>;
		qcom,cpr-init-voltage-step = <10000>;
		qcom,cpr-corner-map = <1 1 2 2 3 3 3>;
		qcom,cpr-corner-frequency-map =
+2 −0
Original line number Diff line number Diff line
@@ -532,6 +532,7 @@
					<138  0 6 0>,
					<138  6 6 0>,
					<138 12 6 0>;
		qcom,cpr-init-voltage-ref = <900000 1000000 1115000>;
		qcom,cpr-init-voltage-step = <10000>;
	};

@@ -576,6 +577,7 @@
					<138 54 6 0>,
					<138 60 6 0>,
					<139  2 6 0>;
		qcom,cpr-init-voltage-ref = <900000 1000000 1115000>;
		qcom,cpr-init-voltage-step = <10000>;
	};
};
+22 −3
Original line number Diff line number Diff line
@@ -1220,7 +1220,7 @@ static int cpr_pvs_per_corner_init(struct device_node *of_node,
{
	u64 efuse_bits;
	int i, size, sign, steps, step_size_uv, rc;
	u32 *fuse_sel, *tmp;
	u32 *fuse_sel, *tmp, *ref_uv;
	struct property *prop;

	prop = of_find_property(of_node, "qcom,cpr-fuse-init-voltage", NULL);
@@ -1252,6 +1252,24 @@ static int cpr_pvs_per_corner_init(struct device_node *of_node,
		kfree(fuse_sel);
		return rc;
	}

	ref_uv = kzalloc((cpr_vreg->num_fuse_corners + 1) * sizeof(*ref_uv),
			GFP_KERNEL);
	if (!ref_uv) {
		pr_err("Could not allocate memory for reference voltages\n");
		kfree(fuse_sel);
		return -ENOMEM;
	}

	rc = of_property_read_u32_array(of_node, "qcom,cpr-init-voltage-ref",
		&ref_uv[CPR_FUSE_CORNER_MIN], cpr_vreg->num_fuse_corners);
	if (rc < 0) {
		pr_err("read qcom,cpr-init-voltage-ref failed, rc = %d\n", rc);
		kfree(fuse_sel);
		kfree(ref_uv);
		return rc;
	}

	tmp = fuse_sel;
	for (i = CPR_FUSE_CORNER_MIN; i <= cpr_vreg->num_fuse_corners; i++) {
		efuse_bits = cpr_read_efuse_param(cpr_vreg, fuse_sel[0],
@@ -1259,8 +1277,8 @@ static int cpr_pvs_per_corner_init(struct device_node *of_node,
		sign = (efuse_bits & (1 << (fuse_sel[2] - 1))) ? -1 : 1;
		steps = efuse_bits & ((1 << (fuse_sel[2] - 1)) - 1);
		pr_debug("corner %d: sign = %d, steps = %d\n", i, sign, steps);
		cpr_vreg->pvs_corner_v[i] = cpr_vreg->ceiling_volt[i] +
					sign * steps * step_size_uv;
		cpr_vreg->pvs_corner_v[i] =
				ref_uv[i] + sign * steps * step_size_uv;
		cpr_vreg->pvs_corner_v[i] = DIV_ROUND_UP(
				cpr_vreg->pvs_corner_v[i],
				cpr_vreg->step_volt) *
@@ -1280,6 +1298,7 @@ static int cpr_pvs_per_corner_init(struct device_node *of_node,
		fuse_sel += 4;
	}
	kfree(tmp);
	kfree(ref_uv);

	return 0;
}