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

Commit f950cce1 authored by David Collins's avatar David Collins
Browse files

regulator: cpr3-hmss-regulator: add support for msm8996v3 fuse differences



On MSM8996v1 and v2 chips, the HMSS CPR Turbo corner open-loop
reference voltage is 1.015 V.  On MSM8996v3 chips, this value is
changed to 1.140 V.  Update the driver to support this difference
by identifying the different SoC revisions in device tree using
the compatible property.

Change-Id: I216e291f1c9f220a1a4e69112eab76b6631c8ce1
Signed-off-by: default avatarDavid Collins <collinsd@codeaurora.org>
parent 9fd50032
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -36,7 +36,13 @@ HMSS specific properties:
- compatible
	Usage:      required
	Value type: <string>
	Definition: should be "qcom,cpr3-msm8996-hmss-regulator"
	Definition: should be one of the following:
		    "qcom,cpr3-msm8996-v1-hmss-regulator",
		    "qcom,cpr3-msm8996-v2-hmss-regulator",
		    "qcom,cpr3-msm8996-v3-hmss-regulator",
		    "qcom,cpr3-msm8996-hmss-regulator".
		    If the SoC revision is not specified, then it is assumed to
		    be the most recent revision, i.e. v3.

- interrupts
	Usage:      required
+4 −0
Original line number Diff line number Diff line
@@ -62,6 +62,10 @@
		 <&clock_gpu clk_gfx3d_clk_src_v2>;
};

&apcc_cpr {
	compatible = "qcom,cpr3-msm8996-v2-hmss-regulator";
};

/* GPU overrides */
&msm_gpu {
	/* Updated chip ID */
+43 −5
Original line number Diff line number Diff line
@@ -329,8 +329,8 @@ enum msm8996_cpr_limitation {

/* Additional MSM8996 specific data: */

/* Open loop voltage fuse reference voltages in microvolts */
static const int msm8996_hmss_fuse_ref_volt[MSM8996_HMSS_FUSE_CORNERS] = {
/* Open loop voltage fuse reference voltages in microvolts for MSM8996 v1/v2 */
static const int msm8996_v1_v2_hmss_fuse_ref_volt[MSM8996_HMSS_FUSE_CORNERS] = {
	605000,
	745000, /* Place holder entry for LowSVS */
	745000,
@@ -338,6 +338,15 @@ static const int msm8996_hmss_fuse_ref_volt[MSM8996_HMSS_FUSE_CORNERS] = {
	1015000,
};

/* Open loop voltage fuse reference voltages in microvolts for MSM8996 v3 */
static const int msm8996_v3_hmss_fuse_ref_volt[MSM8996_HMSS_FUSE_CORNERS] = {
	605000,
	745000, /* Place holder entry for LowSVS */
	745000,
	905000,
	1140000,
};

#define MSM8996_HMSS_FUSE_STEP_VOLT		10000
#define MSM8996_HMSS_VOLTAGE_FUSE_SIZE		6
#define MSM8996_HMSS_QUOT_OFFSET_SCALE		5
@@ -529,7 +538,8 @@ static int cpr3_msm8996_hmss_calculate_open_loop_voltages(
	int rc = 0;
	bool allow_interpolation;
	u64 freq_low, volt_low, freq_high, volt_high;
	int i, j;
	int i, j, soc_revision;
	const int *ref_volt;
	int *fuse_volt;
	int *fmax_corner;

@@ -542,9 +552,14 @@ static int cpr3_msm8996_hmss_calculate_open_loop_voltages(
		goto done;
	}

	soc_revision = vreg->thread->ctrl->soc_revision;
	ref_volt = soc_revision == 1 || soc_revision == 2
			? msm8996_v1_v2_hmss_fuse_ref_volt
			: msm8996_v3_hmss_fuse_ref_volt;

	for (i = 0; i < vreg->fuse_corner_count; i++) {
		fuse_volt[i] = cpr3_convert_open_loop_voltage_fuse(
			msm8996_hmss_fuse_ref_volt[i],
			ref_volt[i],
			MSM8996_HMSS_FUSE_STEP_VOLT, fuse->init_voltage[i],
			MSM8996_HMSS_VOLTAGE_FUSE_SIZE);

@@ -1439,14 +1454,31 @@ static int cpr3_hmss_regulator_resume(struct platform_device *pdev)
	return cpr3_regulator_resume(ctrl);
}

/* Data corresponds to the SoC revision */
static struct of_device_id cpr_regulator_match_table[] = {
	{ .compatible = "qcom,cpr3-msm8996-hmss-regulator", },
	{
		.compatible = "qcom,cpr3-msm8996-v1-hmss-regulator",
		.data = (void *)1
	},
	{
		.compatible = "qcom,cpr3-msm8996-v2-hmss-regulator",
		.data = (void *)2
	},
	{
		.compatible = "qcom,cpr3-msm8996-v3-hmss-regulator",
		.data = (void *)3
	},
	{
		.compatible = "qcom,cpr3-msm8996-hmss-regulator",
		.data = (void *)3
	},
	{}
};

static int cpr3_hmss_regulator_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	const struct of_device_id *match;
	struct cpr3_controller *ctrl;
	struct cpr3_regulator *vreg;
	int i, j, rc;
@@ -1472,6 +1504,12 @@ static int cpr3_hmss_regulator_probe(struct platform_device *pdev)
		return rc;
	}

	match = of_match_node(cpr_regulator_match_table, dev->of_node);
	if (match)
		ctrl->soc_revision = (uintptr_t)match->data;
	else
		cpr3_err(ctrl, "could not find compatible string match\n");

	rc = cpr3_map_fuse_base(ctrl, pdev);
	if (rc) {
		cpr3_err(ctrl, "could not map fuse base address\n");
+4 −0
Original line number Diff line number Diff line
@@ -260,6 +260,9 @@ enum cpr3_count_mode {
 * @sensor_count:	The number of CPR sensors found on the CPR loop managed
 *			by this CPR controller.  Must be equal to the number of
 *			elements in the sensor_owner array
 * @soc_revision:	Revision number of the SoC.  This may be unused by
 *			platforms that do not have different behavior for
 *			different SoC revisions.
 * @lock:		Mutex lock used to ensure mutual exclusion between
 *			all of the threads associated with the controller
 * @vdd_regulator:	Pointer to the VDD supply regulator which this CPR3
@@ -350,6 +353,7 @@ struct cpr3_controller {
	int			thread_count;
	u8			*sensor_owner;
	int			sensor_count;
	int			soc_revision;
	struct mutex		lock;
	struct regulator	*vdd_regulator;
	struct regulator	*system_regulator;