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

Commit 706635fc authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

msm: rpm-regulator-smd: fix request suppression policy



The rpm-regulator-smd driver sends requests for a given regulator to
the RPM only if the regulator has been enabled by a Linux consumer.
If the regulator is disabled from Linux's point of view, then voltage
and current requests are buffered until the regulator is enabled again.
This buffering can lead to regulators being left at unnecessarily high
voltages when they are no longer needed.

Modify the request suppression policy so that current and voltage updates
are suppressed only before the first enable/disable request is sent for a
regulator or while the regulator is disabled if it has been marked as
apps-only. The first request sent for a given regulator must provide a
value for the enable/disable parameter otherwise the RPM will treat it as
an implicit disable request. This would break use-cases that require
certain regulators to be left on until sufficient software control is
initialized. Add a new device tree property, qcom,apps-only, which can be
used to specify that a given regulator supplies hardware that is fully
controlled by the applications processor.

CRs-Fixed: 533263
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
Change-Id: I2a8820662e1471e5ff44f7d681d5d768da74980f
parent 86155e46
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ Optional properties:
- qcom,enable-time:    Time in us to delay after enabling the regulator
- qcom,hpm-min-load:   Load current in uA which corresponds to the minimum load
			which requires the regulator to be in high power mode.
- qcom,apps-only:      Flag which indicates that the regulator only has
			consumers on the application processor. If this flag
			is specified, then voltage and current updates are
			only sent to the RPM if the regulator is enabled.

[Second Level Nodes]

@@ -84,6 +88,7 @@ Optional properties:
				current updates are only sent if the given
				regulator has also been enabled by a Linux
				consumer.

The following properties specify initial values for parameters to be sent to the
RPM in regulator requests.
- qcom,init-enable:            0 = regulator disabled
+20 −4
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ struct rpm_vreg {
	struct mutex		mlock;
	unsigned long		flags;
	bool			sleep_request_sent;
	bool			apps_only;
	struct msm_rpm_request	*handle_active;
	struct msm_rpm_request	*handle_sleep;
};
@@ -241,6 +242,16 @@ static inline bool rpm_vreg_active_or_sleep_enabled(struct rpm_vreg *rpm_vreg)
					& BIT(RPM_REGULATOR_PARAM_ENABLE)));
}

static inline bool rpm_vreg_shared_active_or_sleep_enabled_valid
						(struct rpm_vreg *rpm_vreg)
{
	return !rpm_vreg->apps_only &&
		((rpm_vreg->aggr_req_active.valid
					& BIT(RPM_REGULATOR_PARAM_ENABLE))
		 || (rpm_vreg->aggr_req_sleep.valid
					& BIT(RPM_REGULATOR_PARAM_ENABLE)));
}

/*
 * This is used when voting for LPM or HPM by subtracting or adding to the
 * hpm_min_load of a regulator.  It has units of uA.
@@ -660,7 +671,8 @@ static int rpm_vreg_set_voltage(struct regulator_dev *rdev, int min_uV,
	 * if the regulator has been configured to always send voltage updates.
	 */
	if (reg->always_send_voltage
	    || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg))
	    || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg)
	    || rpm_vreg_shared_active_or_sleep_enabled_valid(reg->rpm_vreg))
		rc = rpm_vreg_aggregate_requests(reg);

	if (rc) {
@@ -719,7 +731,8 @@ static int rpm_vreg_set_voltage_corner(struct regulator_dev *rdev, int min_uV,
	 * updates.
	 */
	if (reg->always_send_voltage
	    || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg))
	    || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg)
	    || rpm_vreg_shared_active_or_sleep_enabled_valid(reg->rpm_vreg))
		rc = rpm_vreg_aggregate_requests(reg);

	if (rc) {
@@ -774,7 +787,8 @@ static int rpm_vreg_set_voltage_floor_corner(struct regulator_dev *rdev,
	 * voltage updates.
	 */
	if (reg->always_send_voltage
	    || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg))
	    || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg)
	    || rpm_vreg_shared_active_or_sleep_enabled_valid(reg->rpm_vreg))
		rc = rpm_vreg_aggregate_requests(reg);

	if (rc) {
@@ -829,7 +843,8 @@ static int rpm_vreg_set_mode(struct regulator_dev *rdev, unsigned int mode)
	 * current updates.
	 */
	if (reg->always_send_current
	    || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg))
	    || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg)
	    || rpm_vreg_shared_active_or_sleep_enabled_valid(reg->rpm_vreg))
		rc = rpm_vreg_aggregate_requests(reg);

	if (rc) {
@@ -1584,6 +1599,7 @@ static int rpm_vreg_resource_probe(struct platform_device *pdev)
	of_property_read_u32(node, "qcom,enable-time", &rpm_vreg->enable_time);
	of_property_read_u32(node, "qcom,hpm-min-load",
		&rpm_vreg->hpm_min_load);
	rpm_vreg->apps_only = of_property_read_bool(node, "qcom,apps-only");

	rpm_vreg->handle_active = msm_rpm_create_request(RPM_SET_ACTIVE,
		resource_type, rpm_vreg->resource_id, RPM_REGULATOR_PARAM_MAX);