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

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

Merge "regulator: spm-regulator: add support for regulator mode switching"

parents 3d6ca4a6 ccdbb6d7
Loading
Loading
Loading
Loading
+75 −75
Original line number Diff line number Diff line
@@ -567,7 +567,8 @@
		qcom,cpr-up-down-delay-time = <3000>;
		qcom,cpr-step-quot-init-min = <11>;
		qcom,cpr-step-quot-init-max = <13>;
		qcom,cpr-count-mode = <2>;		/* Staggered */
		qcom,cpr-count-mode = <0>;		/* All-at-once min */
		qcom,cpr-count-repeat = <25>;

		qcom,apm-ctrl = <&apc_apm>;
		qcom,apm-threshold-voltage = <850000>;
@@ -582,14 +583,13 @@
		vdd-thread1-ldo-ret-supply = <&kryo1_retention_vreg>;

		qcom,cpr-enable;
		qcom,cpr-hw-closed-loop;
		qcom,cpr-clock-throttling = <0x20>;

		thread@0 {
			qcom,cpr-thread-id = <0>;
			qcom,cpr-consecutive-up = <0>;
			qcom,cpr-consecutive-down = <2>;
			qcom,cpr-up-threshold = <0>;
			qcom,cpr-consecutive-down = <3>;
			qcom,cpr-up-threshold = <2>;
			qcom,cpr-down-threshold = <2>;

			apc0_pwrcl_vreg: regulator-pwrcl {
@@ -644,37 +644,37 @@
				       2519 2257 2668 2372    0    0    0    0>;

				qcom,cpr-open-loop-voltage-fuse-adjustment =
					<25000 0 0 (-25000) (-25000)>,
					<25000 0 0 (-25000) (-25000)>,
					<25000 0 0 (-25000) (-25000)>,
					<25000 0 0 (-25000) (-25000)>,
					<25000 0 0 0 0>,
					<25000 0 0 0 0>,
					<25000 0 0 0 0>,
					<25000 0 0 0 0>;
					<45000     0 50000  20000   15000>,
					<45000     0 50000  20000   15000>,
					<45000     0 50000  20000   15000>,
					<45000     0 50000  20000   15000>,
					<45000     0 50000  20000   15000>,
					<45000     0 50000  20000   15000>,
					<45000     0 50000  20000   15000>,
					<45000     0 50000  20000   15000>;
				qcom,cpr-closed-loop-voltage-fuse-adjustment =
					<25000 10000 0 0 0>,
					<25000 10000 0 0 0>,
					<25000 10000 0 0 0>,
					<25000 10000 0 0 0>,
					<25000 10000 0 0 0>,
					<25000 10000 0 0 0>,
					<25000 10000 0 0 0>,
					<25000 10000 0 0 0>;
					<35000 35000 40000  40000   40000>,
					<20000 10000  5000 (-5000) (-5000)>,
					<20000 10000  5000 (-5000) (-5000)>,
					<20000 10000  5000 (-5000) (-5000)>,
					<20000 10000  5000 (-5000) (-5000)>,
					<20000 10000  5000 (-5000) (-5000)>,
					<20000 10000  5000 (-5000) (-5000)>,
					<20000 10000  5000 (-5000) (-5000)>;

				qcom,cpr-open-loop-voltage-adjustment =
					<(-15000) (-15000) (-15000) (-15000)
					 (-33000) (-34000) (-35000) (-38000)
					 (-40000) (-42000) (-44000) (-45000)
					 (-46000) (-47000) (-48000) (-50000)>;
					 (-13000) (-14000) (-15000) (-18000)
					 (-20000) (-22000) (-24000) (-25000)
					 (-26000) (-27000) (-28000) (-30000)>;
				qcom,cpr-open-loop-voltage-min-diff =
				       <0 0 0 0 (-50000) 0 0 0 0 0 0 0 0 0 0 0>;

				qcom,cpr-closed-loop-voltage-adjustment =
					<(-10000) (-10000) (-10000) (-10000)
						0        0        0        0
						0        0        0        0
						0        0        0        0>;
					<(-15000) (-15000) (-15000) (-15000)
					 (-13000) (-14000) (-15000) (-18000)
					 (-20000) (-22000) (-24000) (-25000)
					 (-26000) (-27000) (-28000) (-30000)>;

				qcom,allow-voltage-interpolation;
				qcom,allow-quotient-interpolation;
@@ -731,23 +731,23 @@
				       2519 2257 2668 2372    0    0    0    0>;

				qcom,cpr-open-loop-voltage-fuse-adjustment =
					<10000 5000 (-60000) (-35000) (-60000)>,
					<10000 5000 (-60000) (-35000) (-60000)>,
					<10000 5000 (-60000) (-35000) (-60000)>,
					<10000 5000 (-60000) (-35000) (-60000)>,
					<10000 5000 0 0 0>,
					<10000 5000 0 0 0>,
					<10000 5000 0 0 0>,
					<10000 5000 0 0 0>;
					<55000    0   15000    15000  (-15000)>,
					<55000    0   15000    15000  (-15000)>,
					<55000    0   15000    15000  (-15000)>,
					<55000    0   15000    15000  (-15000)>,
					<55000    0   15000    15000  (-15000)>,
					<55000    0   15000    15000  (-15000)>,
					<55000    0   15000    15000  (-15000)>,
					<55000    0   15000    15000  (-15000)>;
				qcom,cpr-closed-loop-voltage-fuse-adjustment =
					<10000 5000 (-10000) (-10000) (-10000)>,
					<10000 5000 (-10000) (-10000) (-10000)>,
					<10000 5000 (-10000) (-10000) (-10000)>,
					<10000 5000 (-10000) (-10000) (-10000)>,
					<10000 5000 0 0 0>,
					<10000 5000        0        0        0>,
					<10000 5000 0 0 0>,
					<10000 5000 0 0 0>;
					<10000 5000 (-20000)        0 (-35000)>,
					<10000 5000 (-20000)        0 (-35000)>,
					<10000 5000 (-20000)        0 (-35000)>,
					<10000 5000 (-20000)        0 (-35000)>,
					<10000 5000 (-20000)        0 (-35000)>,
					<10000 5000 (-20000)        0 (-35000)>,
					<10000 5000 (-20000)        0 (-35000)>;

				qcom,allow-voltage-interpolation;
				qcom,allow-quotient-interpolation;
@@ -758,8 +758,8 @@
		thread@1 {
			qcom,cpr-thread-id = <1>;
			qcom,cpr-consecutive-up = <0>;
			qcom,cpr-consecutive-down = <2>;
			qcom,cpr-up-threshold = <0>;
			qcom,cpr-consecutive-down = <3>;
			qcom,cpr-up-threshold = <2>;
			qcom,cpr-down-threshold = <2>;

			apc1_vreg: regulator {
@@ -790,7 +790,7 @@
					470000  470000  470000  470000  470000
					470000  470000  470000  470000  470000>;
				qcom,cpr-floor-to-ceiling-max-range =
					<80000   80000   80000   80000   80000
					<    0   80000   80000   80000   80000
					 80000   80000   80000   80000   80000
					 80000   80000   80000   80000   80000
					 80000   80000   80000   80000   80000
@@ -820,17 +820,17 @@
				       2519 2257 2668 2372    0    0    0    0>;

				qcom,cpr-open-loop-voltage-fuse-adjustment =
					<0 0 0 (-65000) (-20000)>,
					<0 0 0 (-65000) (-20000)>,
					<0 0 0 (-25000) (-20000)>,
					<0 0 0 (-25000) (-20000)>,
					<0 0 0 0 0>,
					<0 0 0 0 0>,
					<0 0 0 0 0>,
					<0 0 0 0 0>;
					<35000     0 40000 (-30000) 25000>,
					<35000     0 40000 (-30000) 25000>,
					<35000     0 40000   25000  25000>,
					<35000     0 40000   25000  25000>,
					<35000     0 40000   25000  25000>,
					<35000     0 40000   25000  25000>,
					<35000     0 40000   25000  25000>,
					<35000     0 40000   25000  25000>;
				qcom,cpr-closed-loop-voltage-fuse-adjustment =
					<0 0 0 0 0>,
					<0 0 0 0 0>,
					<35000 35000 40000 (-30000) 40000>,
					<    0     0     0 (-70000)     0>,
					<    0     0     0        0     0>,
					<    0     0     0        0     0>,
					<    0     0     0        0     0>,
@@ -840,24 +840,24 @@

				qcom,cpr-open-loop-voltage-adjustment =
					<(-15000) (-15000) (-15000) (-15000)
					 (-31000) (-32000) (-33000) (-34000)
					 (-35000) (-38000) (-41000) (-43000)
					 (-45000) (-45000) (-46000) (-46000)
					 (-47000) (-47000) (-48000) (-48000)
					 (-48000) (-49000) (-49000) (-50000)
					 (-50000)>;
					 (-11000) (-12000) (-13000) (-14000)
					 (-15000) (-18000) (-21000) (-23000)
					 (-25000) (-25000) (-26000) (-26000)
					 (-27000) (-27000) (-28000) (-28000)
					 (-28000) (-29000) (-29000) (-30000)
					 (-30000)>;
				qcom,cpr-open-loop-voltage-min-diff =
					<0 0 0 0 (-50000) 0 0 0 0 0 0 0 0 0 0 0
					 0 0 0 0 0 0 0 0 0>;

				qcom,cpr-closed-loop-voltage-adjustment =
					<(-10000) (-10000) (-10000) (-10000)
						0        0        0        0
						0        0        0        0
						0        0        0        0
						0        0        0        0
						0        0        0        0
						0>;
					<(-15000) (-15000) (-15000) (-15000)
					 (-11000) (-12000) (-13000) (-14000)
					 (-15000) (-18000) (-21000) (-23000)
					 (-25000) (-25000) (-26000) (-26000)
					 (-27000) (-27000) (-28000) (-28000)
					 (-28000) (-29000) (-29000) (-30000)
					 (-30000)>;

				qcom,allow-voltage-interpolation;
				qcom,allow-quotient-interpolation;
+14 −0
Original line number Diff line number Diff line
@@ -73,11 +73,25 @@
&apcc_cpr {
	compatible = "qcom,cpr3-msm8996-v2-hmss-regulator";

	qcom,cpr-count-mode = <2>;		/* Staggered */
	/delete-property/ qcom,cpr-count-repeat;

	qcom,apm-ctrl = <&apc_apm>;
	qcom,apm-threshold-voltage = <850000>;
	qcom,apm-hysteresis-voltage = <5000>;

	qcom,cpr-enable;
	qcom,cpr-hw-closed-loop;

	thread@0 {
		qcom,cpr-consecutive-down = <2>;
		qcom,cpr-up-threshold = <0>;
	};

	thread@1 {
		qcom,cpr-consecutive-down = <2>;
		qcom,cpr-up-threshold = <0>;
	};
};

&apc0_pwrcl_vreg {
+29 −3
Original line number Diff line number Diff line
@@ -823,7 +823,8 @@ void cpr3_open_loop_voltage_as_ceiling(struct cpr3_regulator *vreg)
 * @combo_offset:	The array offset for the selected fuse combo
 *
 * This function also ensures that the open-loop voltage for each corner falls
 * within the final floor to ceiling voltage range.
 * within the final floor to ceiling voltage range and that floor voltages
 * increase monotonically.
 *
 * Return: 0 on success, errno on failure
 */
@@ -831,11 +832,12 @@ int cpr3_limit_floor_voltages(struct cpr3_regulator *vreg, int corner_sum,
				int combo_offset)
{
	char *prop = "qcom,cpr-floor-to-ceiling-max-range";
	int i, rc, floor_new;
	int i, floor_new;
	u32 *floor_range;
	int rc = 0;

	if (!of_find_property(vreg->of_node, prop, NULL))
		return 0;
		goto enforce_monotonicity;

	floor_range = kcalloc(vreg->corner_count, sizeof(*floor_range),
				GFP_KERNEL);
@@ -864,6 +866,30 @@ int cpr3_limit_floor_voltages(struct cpr3_regulator *vreg, int corner_sum,

free_floor_adjust:
	kfree(floor_range);

enforce_monotonicity:
	/* Ensure that floor voltages increase monotonically. */
	for (i = 1; i < vreg->corner_count; i++) {
		if (vreg->corner[i].floor_volt
		    < vreg->corner[i - 1].floor_volt) {
			cpr3_debug(vreg, "corner %d floor voltage=%d uV < corner %d voltage=%d uV; overriding: corner %d voltage=%d\n",
				i, vreg->corner[i].floor_volt,
				i - 1, vreg->corner[i - 1].floor_volt,
				i, vreg->corner[i - 1].floor_volt);
			vreg->corner[i].floor_volt
				= vreg->corner[i - 1].floor_volt;

			if (vreg->corner[i].open_loop_volt
			    < vreg->corner[i].floor_volt)
				vreg->corner[i].open_loop_volt
					= vreg->corner[i].floor_volt;
			if (vreg->corner[i].ceiling_volt
			    < vreg->corner[i].floor_volt)
				vreg->corner[i].ceiling_volt
					= vreg->corner[i].floor_volt;
		}
	}

	return rc;
}

+32 −1
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ struct spm_vreg {
	bool				online;
	u16				spmi_base_addr;
	u8				init_mode;
	u8				mode;
	int				step_rate;
	enum qpnp_regulator_uniq_type	regulator_type;
	u32				cpu_num;
@@ -413,10 +414,36 @@ static int spm_regulator_is_enabled(struct regulator_dev *rdev)
	return vreg->online;
}

static unsigned int spm_regulator_get_mode(struct regulator_dev *rdev)
{
	struct spm_vreg *vreg = rdev_get_drvdata(rdev);

	return vreg->mode == QPNP_SMPS_MODE_PWM
			? REGULATOR_MODE_NORMAL : REGULATOR_MODE_IDLE;
}

static int spm_regulator_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
	struct spm_vreg *vreg = rdev_get_drvdata(rdev);

	/*
	 * Map REGULATOR_MODE_NORMAL to PWM mode and REGULATOR_MODE_IDLE to
	 * init_mode.  This ensures that the regulator always stays in PWM mode
	 * in the case that qcom,mode has been specified as "pwm" in device
	 * tree.
	 */
	vreg->mode
	 = mode == REGULATOR_MODE_NORMAL ? QPNP_SMPS_MODE_PWM : vreg->init_mode;

	return qpnp_smps_set_mode(vreg, vreg->mode);
}

static struct regulator_ops spm_regulator_ops = {
	.get_voltage	= spm_regulator_get_voltage,
	.set_voltage	= spm_regulator_set_voltage,
	.list_voltage	= spm_regulator_list_voltage,
	.get_mode	= spm_regulator_get_mode,
	.set_mode	= spm_regulator_set_mode,
	.enable		= spm_regulator_enable,
	.disable	= spm_regulator_disable,
	.is_enabled	= spm_regulator_is_enabled,
@@ -689,6 +716,8 @@ static int qpnp_smps_init_mode(struct spm_vreg *vreg)
				__func__, rc);
	}

	vreg->mode = vreg->init_mode;

	return rc;
}

@@ -891,7 +920,9 @@ static int spm_regulator_probe(struct spmi_device *spmi)
	}
	init_data->constraints.input_uV = init_data->constraints.max_uV;
	init_data->constraints.valid_ops_mask |= REGULATOR_CHANGE_STATUS
						| REGULATOR_CHANGE_VOLTAGE;
			| REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_MODE;
	init_data->constraints.valid_modes_mask
				= REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE;

	if (!init_data->constraints.name) {
		dev_err(&spmi->dev, "%s: node is missing regulator name\n",