[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231227-topic-psci_fw_sus-v1-2-6910add70bf3@linaro.org>
Date: Wed, 27 Dec 2023 23:15:31 +0100
From: Konrad Dybcio <konrad.dybcio@...aro.org>
To: Mark Rutland <mark.rutland@....com>,
Lorenzo Pieralisi <lpieralisi@...nel.org>
Cc: Marijn Suijten <marijn.suijten@...ainline.org>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konrad.dybcio@...aro.org>
Subject: [PATCH 2/2] firmware/psci: Set
pm_set_resume/suspend_via_firmware() on qcom
Most Qualcomm platforms implementing PSCI (ab)use CPU_SUSPEND for
entering various stages of suspend, across the SoC. These range from a
simple WFI to a full-fledged power collapse of the entire chip
(mostly, anyway).
Some device drivers are curious to know whether "the firmware" (which is
often assumed to be ACPI) takes care of suspending or resuming the
platform. Set the flag that reports this behavior on the aforementioned
chips.
Some newer Qualcomm chips ship with firmware that actually advertises
PSCI SYSTEM_SUSPEND, so the compatible list should only grow slightly.
Signed-off-by: Konrad Dybcio <konrad.dybcio@...aro.org>
---
drivers/firmware/psci/psci.c | 57 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index 1bcb752977b1..ddfdc14e2423 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -523,6 +523,30 @@ static const struct platform_suspend_ops psci_suspend_ops = {
.begin = psci_system_suspend_begin,
};
+/*
+ * Some PSCI implementations (particularly on Qualcomm platforms) silently
+ * sneak in SoC-wide power collapse through CPU_SUSPEND, while advertising no
+ * support for SYSTEM_SUSPEND.
+ */
+
+static int psci_cpu_as_system_suspend_enter(suspend_state_t state)
+{
+ pm_set_resume_via_firmware();
+
+ return 0;
+}
+
+static int suspend_valid_all(suspend_state_t state)
+{
+ return state == PM_SUSPEND_TO_IDLE;
+}
+
+static const struct platform_suspend_ops psci_cpu_as_system_suspend_ops = {
+ .valid = suspend_valid_all,
+ .enter = psci_cpu_as_system_suspend_enter,
+ .begin = psci_system_suspend_begin,
+};
+
static void __init psci_init_system_reset2(void)
{
int ret;
@@ -533,8 +557,33 @@ static void __init psci_init_system_reset2(void)
psci_system_reset2_supported = true;
}
+
+static const struct of_device_id cpu_as_system_suspend_match_table[] = {
+ { .compatible = "qcom,msm8998" },
+ { .compatible = "qcom,qcm2290" },
+ { .compatible = "qcom,sa8775p" },
+ { .compatible = "qcom,sc7180" },
+ { .compatible = "qcom,sc7280" },
+ { .compatible = "qcom,sc8180x" },
+ { .compatible = "qcom,sc8280xp" },
+ { .compatible = "qcom,sdm630" },
+ { .compatible = "qcom,sdm670" },
+ { .compatible = "qcom,sdm845" },
+ { .compatible = "qcom,sm4450" },
+ { .compatible = "qcom,sm6115" },
+ { .compatible = "qcom,sm6125" },
+ { .compatible = "qcom,sm6350" },
+ { .compatible = "qcom,sm6375" },
+ { .compatible = "qcom,sm7125" },
+ { .compatible = "qcom,sm8150" },
+ { .compatible = "qcom,sm8250" },
+ { .compatible = "qcom,sm8350" },
+ { }
+};
+
static void __init psci_init_system_suspend(void)
{
+ struct device_node *np = of_find_node_by_path("/");
int ret;
if (!IS_ENABLED(CONFIG_SUSPEND))
@@ -542,8 +591,14 @@ static void __init psci_init_system_suspend(void)
ret = psci_features(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND));
- if (ret != PSCI_RET_NOT_SUPPORTED)
+ if (ret == PSCI_RET_NOT_SUPPORTED) {
+ if (of_match_node(cpu_as_system_suspend_match_table, np))
+ suspend_set_ops(&psci_cpu_as_system_suspend_ops);
+ } else {
suspend_set_ops(&psci_suspend_ops);
+ }
+
+ of_node_put(np);
}
static void __init psci_init_cpu_suspend(void)
--
2.43.0
Powered by blists - more mailing lists