From patchwork Mon Oct 28 14:22:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13853636 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B01FD33990 for ; Mon, 28 Oct 2024 14:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8DduQ5a5iEKGftFFpS2C6ZNV4q2UCgGo/WE7bIsCA74=; b=Fk1Tn+/ROwq0DqpSQnr2qnfA2m /nf+LRye76IKPFI+X1PACbKhGOFCCVKuTNG/lx6kstPjbAoEQGwyEqGIhzC5zYR0mLWRJUzbGMoeG UAXm1+AoPQ/5cvfPGrjGHs1Er62Rgo919FFT7wuH3xgc+sHRbW5xrwjv0iHvYtFG4DEl8LwRE6zjD UFPD9rt1Y3YxfHirLNVq4trOFz0p1+qIk3pSUloS9OoShljmsMdA5I6YNH9mktRxJ1emlb55WSkCP BJp+lRoVSw8kQhsJs7WitZrcTZgP207WqRpzEXlXoRfpsOVguYjFRj7S6d7IOKGlE36UJFaO5NHz7 9seYAvyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5RBE-0000000BDHG-3N9f; Mon, 28 Oct 2024 14:57:16 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5QeF-0000000B6Vu-0UQ4 for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2024 14:23:12 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 80644A425CA; Mon, 28 Oct 2024 14:21:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4680C4CECD; Mon, 28 Oct 2024 14:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730125388; bh=70JpgkYvN9YM24Jz+FtvScOfqAM/jZI33kSB5+f8jrI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uWoduNTdbhD9TXD1VwGSVhid/JfbNZDhhSTtQ+Zs3ioRGg6tvVfDDsO7n6Ybo/UJl NsxIokqQOYhAL4WSF2svmo6fDJ32xwI3BhJ4nntHQH/9m04sMJzuX8t4AytmOrUT6S IxWlHolrSrED7yOnX/7n39zdEROIZr2p1dIlWx7wY+W7sUA86CfxB2bGLD+pOaaf6A banm0ijjslbav+xsnj1utuXglFa/F/XmiZcKG1MexyAYqAZyvIQH0RfdF7NOp1l8JX pN++CrTWodTvybBb9bEtYQ6Taw6kleIsLkJw3qOrLTxSI2wILjGwQQQgLV2ktbpqE8 GOTAT3N1G8tKw== From: Konrad Dybcio Date: Mon, 28 Oct 2024 15:22:57 +0100 Subject: [PATCH 1/3] dt-bindings: arm,psci: Allow S2RAM power_state parameter description MIME-Version: 1.0 Message-Id: <20241028-topic-cpu_suspend_s2ram-v1-1-9fdd9a04b75c@oss.qualcomm.com> References: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> In-Reply-To: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lorenzo Pieralisi , Mark Rutland Cc: Marijn Suijten , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730125380; l=1434; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=qowdcUV0IcXfH3TE+fGW1N5ucMJrGFxOqfTc+GjqJNE=; b=PkrsrLQrYHBH3Z0pNaW3PK242z+Gnl0VhBs6CQJrIOlHjhysAG9+Zc9b2RC7ghkCCjFg5lCTT bin1KT4oKNJA+UZHJeDOPleGn5YYe0DX/fXojY3JnSxnRIA+8yqJTag X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241028_072311_363117_6D0BBF9D X-CRM114-Status: UNSURE ( 9.44 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Konrad Dybcio Certain firmware implementations (such as the ones found on Qualcomm SoCs between roughly 2015 and 2023) expose an S3-like S2RAM state through the CPU_SUSPEND call, as opposed to exposing PSCIv1.0's optional PSCI_SYSTEM_SUSPEND. This really doesn't work well with the model where we associate all calls to CPU_SUSPEND with cpuidle. Allow specifying a single special CPU_SUSPEND suspend parameter value that is to be treated just like SYSTEM_SUSPEND from the OS's point of view. Signed-off-by: Konrad Dybcio --- Documentation/devicetree/bindings/arm/psci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/psci.yaml b/Documentation/devicetree/bindings/arm/psci.yaml index cbb012e217ab80c1ca88e611e7acc06c6d56fad0..a6901878697c8e1ec1cbfed62298ae3bc58f2501 100644 --- a/Documentation/devicetree/bindings/arm/psci.yaml +++ b/Documentation/devicetree/bindings/arm/psci.yaml @@ -98,6 +98,12 @@ properties: [1] Kernel documentation - ARM idle states bindings Documentation/devicetree/bindings/cpu/idle-states.yaml + arm,psci-s2ram-param: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + power_state parameter denoting the S2RAM/S3-like system suspend state + maxItems: 1 + patternProperties: "^power-domain-": $ref: /schemas/power/power-domain.yaml# From patchwork Mon Oct 28 14:22:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13853642 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE044D33992 for ; Mon, 28 Oct 2024 14:59:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RIsY/nREQ/fAaAdcNyrnzEfHa8eQNfg/wq8e5XlHCaA=; b=ATdO8KGYgsk7kQOcR20fkb443Z rHhlPkUX3URRT+HnabIBddPq+8xN5IzR+TMBnkyziIo6yyeRopaRYWfG13NbnP8iWIcIQGs8fGx8F FGQoe1Tmwk5aimMuj45DyyeRyP6Sp8oi4eRDHyedaRfKwi6rCqC6CBVhBrJ3OdFGRRnko+++ayLds AjHAk0zDGvzzmncyGYeCC7mZSHARxOOVmfMwA4A/OVZpglCqpMzZoeN4YxOi3/I2btDRI5jG9bYm/ pVDrcVe8soE7dKP7zFY22piXwRycM+DfHXa+OCJzFrROFYRtw9F0sR5KQqoLXAXMU2VU2qjHrLRTM /QxxaLug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5RCn-0000000BDWQ-3VIV; Mon, 28 Oct 2024 14:58:53 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5QeH-0000000B6WZ-12b4 for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2024 14:23:14 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6DD1F5C56F3; Mon, 28 Oct 2024 14:22:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B58B3C4CEE8; Mon, 28 Oct 2024 14:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730125392; bh=INIyxIjyW8dZrymPTrJki0+QEIhN5rfp5OXIveeeXZ0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jJ2f9wPsfrE+3WverENvTtoDPFfJmQyO1YYV46otysBHoQkrDQ2LSKZfoA5L5qju4 Zc0rx+1EQtCOXtkw1hlSTfDUDTPj8y2xH56BUB18XzAI2BFL/qwAeM/g+yv8YoluYl kL5zNLidcdx7h+lqz/o2Pv6MzLCyHtHwBup4AMq8o0aRA5kfbR6vwI2gpoCb+QuGEJ B7cs2vBEe17JVwULTELVB8YgA2/x/b+efJ6oiUZwp/emdJ09HI/DO49eJ+C1IUDeMD CCeuPSTY1jXexgHkvLvTYKhReHQA0VGzVz1D55YRMUrPaDCMTPQeIF04nBTqfJZktg GPWif56YlStwg== From: Konrad Dybcio Date: Mon, 28 Oct 2024 15:22:58 +0100 Subject: [PATCH 2/3] firmware/psci: Set pm_set_resume/suspend_via_firmware() for SYSTEM_SUSPEND MIME-Version: 1.0 Message-Id: <20241028-topic-cpu_suspend_s2ram-v1-2-9fdd9a04b75c@oss.qualcomm.com> References: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> In-Reply-To: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lorenzo Pieralisi , Mark Rutland Cc: Marijn Suijten , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bjorn Andersson , Konrad Dybcio , Sudeep Holla , Konrad Dybcio X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730125380; l=1306; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=INIyxIjyW8dZrymPTrJki0+QEIhN5rfp5OXIveeeXZ0=; b=hEJdSTloRMtioiwdZulRfEu6ZrNIJW/pFqzZKFYyiI1neblGkpxAW34SRPduGpLKNGaZLn5Dx 8UHBjCVaPk5Cet6SNHK/H7Pzfc47zOOWQ+8V6z1TwP6LpSXQ8RsXjCU X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241028_072313_401520_81B82ECA X-CRM114-Status: GOOD ( 10.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 if SYSTEM_SUSPEND is implemented. Signed-off-by: Konrad Dybcio Reviewed-by: Sudeep Holla --- drivers/firmware/psci/psci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 2328ca58bba61fdb677ac20a1a7447882cd0cf22..0e622aa5ad58bbe69dfc3a71bced597618e73f15 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -507,12 +507,22 @@ static int psci_system_suspend(unsigned long unused) static int psci_system_suspend_enter(suspend_state_t state) { + pm_set_resume_via_firmware(); + return cpu_suspend(0, psci_system_suspend); } +static int psci_system_suspend_begin(suspend_state_t state) +{ + pm_set_suspend_via_firmware(); + + return 0; +} + static const struct platform_suspend_ops psci_suspend_ops = { .valid = suspend_valid_only_mem, .enter = psci_system_suspend_enter, + .begin = psci_system_suspend_begin, }; static void __init psci_init_system_reset2(void) From patchwork Mon Oct 28 14:22:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 13853643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CAEE2D33990 for ; Mon, 28 Oct 2024 15:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1OGZekl39DzQk3gPXzj5m3/fX/JZ09Ijuh97AGPbBD8=; b=jTrqB3HerdByne0Un+n3fCjq9V y4vVWgbyRHkq12Q3gsCYpuFeFUupd9X0wM+IF3L+yEK/yrAVSV+t3ns2VVgxpq7KOeZjOVG7e3WQ7 SR377TDRZgfPtz33X+YRcv8vqq+VNcKj7uCGnQpC5x6wWvrYfZVf/fyUiIe2Sx4oXyRn9Z5rm9fJA t/BgRtxvuTy0ncy7yOMOGbtkqmdRhAYX+DxwXy410j/Jr8xttsmUTggcoMtvkKmKnDne6zodena05 mDnqfjc0dkVqGO/KT0nb0oTBww6uQhGkZDlL+7x2n5tKyMcSjBNjOill4NJ5HQEthwPs2nSA70ywh z1asN7Og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5REN-0000000BDno-499J; Mon, 28 Oct 2024 15:00:32 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5QeK-0000000B6Xg-2WDv for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2024 14:23:18 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 158305C56FA; Mon, 28 Oct 2024 14:22:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1E12C4CEE7; Mon, 28 Oct 2024 14:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730125396; bh=yl7Mfs856g30vpNRTxQo0XG82uyk/8hEkmCtSRgI5BE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Mffzb+IZ/0b3uzci/Q0aZsGlREKdAflGhK9yFluzbPp8ILpQeFqZJV4CKWQQGMrgR NyxCydIX83gVfMkZMPYQWFWG2I8ndKIvBI7qiSNo9VgdKlTMA6rtAV6SoX0Uy1OVWj VuKuaH6lnzLvE6T5rC29dD0NgdxQ6alkw++42ZfhGUJn6JdKgNd1ElrcxGpTj8trd0 FkgNAM1zS0vjT3bF9g9RW0AsMWWvKka85fcAK2KFGRgKXtNQVabkyuYNaBEv8Pos5m dx6HuPQnKUUap8JUH07gFuhmBGtiOrvlCDdkZIlGDWWahkxj/BQsprRgdwsrrVGZS7 jHZtTG1POO0Fg== From: Konrad Dybcio Date: Mon, 28 Oct 2024 15:22:59 +0100 Subject: [PATCH 3/3] firmware/psci: Allow specifying an S2RAM state through CPU_SUSPEND MIME-Version: 1.0 Message-Id: <20241028-topic-cpu_suspend_s2ram-v1-3-9fdd9a04b75c@oss.qualcomm.com> References: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> In-Reply-To: <20241028-topic-cpu_suspend_s2ram-v1-0-9fdd9a04b75c@oss.qualcomm.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lorenzo Pieralisi , Mark Rutland Cc: Marijn Suijten , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1730125380; l=3714; i=konrad.dybcio@oss.qualcomm.com; s=20230215; h=from:subject:message-id; bh=Bf2hbCxvBem19Ny5a2acnQioUv9USzkxEe/DauTX7oc=; b=FlN28QeiFZU8O2MvaHh0SMZln2dKNtdGQHi7Hs7jxj9PC3ah05CBwHvJH95lZGaASdtMNjQLk 1fNmg0+xUfyDeRqvE0W40TGGMjzDjMITQEIDQ9a0cduZox0+iTIK7WH X-Developer-Key: i=konrad.dybcio@oss.qualcomm.com; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241028_072316_766668_5BA507A6 X-CRM114-Status: GOOD ( 16.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Konrad Dybcio Certain firmware implementations (such as the ones found on Qualcomm SoCs between roughly 2015 and 2023) expose an S3-like S2RAM state through the CPU_SUSPEND call. This works exactly like SYSTEM_SUSPEND. The PSCI spec describes that call as optional (and only introduced in PSCIv1.0), so not all platforms expose it. Marking a DT-described "domain-idle-state" as such isn't currently well accounted for in the PSCI idle topology infrastructure: the cpuidle and genpd framework are deeply intertwined, and trying to separate them would cause more havoc than good. Instead, allow the specifying of a single CPU_SUSPEND sleep param under the /psci node that shall be treated exactly like SYSTEM_SUSPEND from Linux's POV. As a bonus, this way we also don't have to fight with the genpd idle governor to avoid taking the S3-like state into consideration. Signed-off-by: Konrad Dybcio --- drivers/firmware/psci/psci.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 0e622aa5ad58bbe69dfc3a71bced597618e73f15..20ae6a6d59a9f276db75260b6ca1a5827e443782 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -78,6 +78,7 @@ struct psci_0_1_function_ids get_psci_0_1_function_ids(void) static u32 psci_cpu_suspend_feature; static bool psci_system_reset2_supported; +static u32 psci_s2ram_suspend_param; static inline bool psci_has_ext_power_state(void) { @@ -519,10 +520,10 @@ static int psci_system_suspend_begin(suspend_state_t state) return 0; } -static const struct platform_suspend_ops psci_suspend_ops = { - .valid = suspend_valid_only_mem, - .enter = psci_system_suspend_enter, - .begin = psci_system_suspend_begin, +static const struct platform_suspend_ops psci_system_suspend_ops = { + .valid = suspend_valid_only_mem, + .enter = psci_system_suspend_enter, + .begin = psci_system_suspend_begin, }; static void __init psci_init_system_reset2(void) @@ -545,7 +546,7 @@ static void __init psci_init_system_suspend(void) ret = psci_features(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND)); if (ret != PSCI_RET_NOT_SUPPORTED) - suspend_set_ops(&psci_suspend_ops); + suspend_set_ops(&psci_system_suspend_ops); } static void __init psci_init_cpu_suspend(void) @@ -673,6 +674,17 @@ static int __init psci_probe(void) typedef int (*psci_initcall_t)(const struct device_node *); +static int psci_cpu_suspend_s2ram_enter(suspend_state_t state) +{ + return psci_cpu_suspend_enter(psci_s2ram_suspend_param); +} + +static const struct platform_suspend_ops psci_cpu_suspend_s2ram_ops = { + .valid = suspend_valid_only_mem, + .enter = psci_cpu_suspend_s2ram_enter, + .begin = psci_system_suspend_begin, +}; + /* * PSCI init function for PSCI versions >=0.2 * @@ -686,6 +698,20 @@ static int __init psci_0_2_init(const struct device_node *np) if (err) return err; + /* + * Some firmwares expose S2RAM entry through a custom suspend param. + * + * If found, register a suspend handler instead of registering the + * idle state with cpuidle. + */ + err = of_property_read_u32(np, "arm,psci-s2ram-param", &psci_s2ram_suspend_param); + if (!err) { + suspend_set_ops(&psci_cpu_suspend_s2ram_ops); + } else if (err != -EINVAL) { + pr_err("Couldn't read the S2RAM PSCI suspend param: %d\n", + psci_s2ram_suspend_param); + } + /* * Starting with v0.2, the PSCI specification introduced a call * (PSCI_VERSION) that allows probing the firmware version, so