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

Commit 657774e4 authored by Karthik Parsha's avatar Karthik Parsha
Browse files

msm: spm: Add support to use SPM for clock gating mode



On targets that support auto clock gating, spm needs to be disabled
for the hardware to do auto clock gating. If auto clock gating is not
supported or not used, spm needs to be left enabled when programmed
for clock gating.

Add driver support to keep the spm enabled, and, if qchannel interface
is present then add driver support to enable spm legacy mode. This
would keep the spm enabled for clock gating. Use the dt flag
qcom,use-spm-clock-gating to determine if spm needs to be used for
clock gating.

Also, fix lpm-levels driver to support clock gating and auto clock gating
modes.

Change-Id: I4c796d7e063633e41910e780ee2a05e5205db0bd
Signed-off-by: default avatarKarthik Parsha <kparsha@codeaurora.org>
parent 4fe162d7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -60,6 +60,10 @@ Optional properties
- qcom,supports-rpm-hs: Indicates that this SPM instance allow handshake with
RPM processor when executing the sleep command in the SPM sequence. Supported
only on SAW2 v3.0 and above.
- qcom,use-spm-clock-gating: This boolean property is used to indicate that
	the SPM needs to be used for clock gating. Using the SPM for clock
	gating would result in auto clock gating being disabled. Use this on
	targets that do not support or do not use auto clock gating.

Example 1:
	qcom,spm@f9089000 {
+2 −4
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ int set_l2_mode(struct low_power_ops *ops, int mode, bool notify_rpm)
		ops->tz_flag = MSM_SCM_L2_GDHS;
		coresight_cti_ctx_save();
		break;
	case MSM_SPM_MODE_CLOCK_GATING:
	case MSM_SPM_MODE_RETENTION:
	case MSM_SPM_MODE_DISABLED:
		ops->tz_flag = MSM_SCM_L2_ON;
@@ -225,10 +226,7 @@ int set_l2_mode(struct low_power_ops *ops, int mode, bool notify_rpm)

int set_cci_mode(struct low_power_ops *ops, int mode, bool notify_rpm)
{
	int lpm = mode;
	if (mode == MSM_SPM_MODE_CLOCK_GATING)
		lpm = MSM_SPM_MODE_DISABLED;
	return msm_spm_config_low_power_mode(ops->spm, lpm, notify_rpm);
	return msm_spm_config_low_power_mode(ops->spm, mode, notify_rpm);
}

static int cpu_power_select(struct cpuidle_device *dev,
+9 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ struct msm_spm_device {
	void __iomem *q2s_reg;
	bool qchannel_ignore;
	bool allow_rpm_hs;
	bool use_spm_clk_gating;
};

struct msm_spm_vdd_info {
@@ -162,7 +163,7 @@ static void msm_spm_config_q2s(struct msm_spm_device *dev, unsigned int mode)
	case MSM_SPM_MODE_DISABLED:
	case MSM_SPM_MODE_CLOCK_GATING:
		qchannel_ignore = 1;
		spm_legacy_mode = 0;
		spm_legacy_mode = dev->use_spm_clk_gating;
		break;
	case MSM_SPM_MODE_RETENTION:
		qchannel_ignore = 0;
@@ -197,6 +198,10 @@ static int msm_spm_dev_set_low_power_mode(struct msm_spm_device *dev,
			|| (mode == MSM_SPM_MODE_GDHS))
		pc_mode = true;

	if ((mode == MSM_SPM_MODE_CLOCK_GATING)
			&& (!dev->use_spm_clk_gating))
		mode = MSM_SPM_MODE_DISABLED;

	if (mode == MSM_SPM_MODE_DISABLED) {
		ret = msm_spm_drv_set_spm_enable(&dev->reg_data, false);
	} else if (!msm_spm_drv_set_spm_enable(&dev->reg_data, true)) {
@@ -630,6 +635,9 @@ static int msm_spm_dev_probe(struct platform_device *pdev)
	key = "qcom,use-qchannel-for-pc";
	dev->qchannel_ignore = !of_property_read_bool(node, key);

	key = "qcom,use-spm-clock-gating";
	dev->use_spm_clk_gating = of_property_read_bool(node, key);

	/*
	 * At system boot, cpus and or clusters can remain in reset. CCI SPM
	 * will not be triggered unless SPM_LEGACY_MODE bit is set for the