From: Georgi Vlaev <g-vlaev@ti.com>
To: Nishanth Menon <nm@ti.com>, Tero Kristo <kristo@kernel.org>,
Santosh Shilimkar <ssantosh@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
Vibhore Vardhan <vibhore@ti.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
Roger Quadros <rogerq@kernel.org>, Georgi Vlaev <g-vlaev@ti.com>
Subject: [PATCH v5 6/6] firmware: ti_sci: Introduce prepare system suspend call
Date: Mon, 28 Nov 2022 16:05:22 +0200 [thread overview]
Message-ID: <20221128140522.49474-7-g-vlaev@ti.com> (raw)
In-Reply-To: <20221128140522.49474-1-g-vlaev@ti.com>
From: Dave Gerlach <d-gerlach@ti.com>
Introduce a ti_sci_prepare_system_suspend call to be used in the driver
suspend handler to allow the system to identify the low power mode being
entered and if necessary, send TISCI_MSG_PREPARE_SLEEP with information
about the mode is being entered and the address for allocated memory for
storing the context during Deep Sleep.
We're using "pm_suspend_target_state" to map the kernel's target suspend
state to SysFW low power mode. Make sure this is available only when
CONFIG_SUSPEND is enabled.
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Vibhore Vardhan <vibhore@ti.com>
Signed-off-by: Georgi Vlaev <g-vlaev@ti.com>
Tested-by: Roger Quadros <rogerq@kernel.org>
---
drivers/firmware/ti_sci.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 09bca1a15d74..681f2ebb3fe4 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -3568,9 +3568,46 @@ static void ti_sci_set_is_suspending(struct ti_sci_info *info, bool is_suspendin
info->is_suspending = is_suspending;
}
+static int ti_sci_prepare_system_suspend(struct ti_sci_info *info)
+{
+#if IS_ENABLED(CONFIG_SUSPEND)
+ u8 mode;
+
+ /* Map and validate the target Linux suspend state to TISCI LPM. */
+ switch (pm_suspend_target_state) {
+ case PM_SUSPEND_MEM:
+ /* S2MEM is not supported by the firmware. */
+ if (!(info->fw_caps & MSG_FLAG_CAPS_LPM_DEEP_SLEEP))
+ return 0;
+ /* S2MEM can't continue if the LPM firmware is not loaded. */
+ if (!info->lpm_firmware_loaded)
+ return -EINVAL;
+ mode = TISCI_MSG_VALUE_SLEEP_MODE_DEEP_SLEEP;
+ break;
+ default:
+ /*
+ * Do not fail if we don't have action to take for a
+ * specific suspend mode.
+ */
+ return 0;
+ }
+
+ return ti_sci_cmd_prepare_sleep(&info->handle, mode,
+ (u32)(info->ctx_mem_addr & 0xffffffff),
+ (u32)((u64)info->ctx_mem_addr >> 32), 0);
+#else
+ return 0;
+#endif
+}
+
static int ti_sci_suspend(struct device *dev)
{
struct ti_sci_info *info = dev_get_drvdata(dev);
+ int ret;
+
+ ret = ti_sci_prepare_system_suspend(info);
+ if (ret)
+ return ret;
/*
* We must switch operation to polled mode now as drivers and the genpd
* layer may make late TI SCI calls to change clock and device states
--
2.30.2
prev parent reply other threads:[~2022-11-28 14:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 14:05 [PATCH v5 0/5] firmware: ti_sci: Introduce system suspend support Georgi Vlaev
2022-11-28 14:05 ` [PATCH v5 1/6] dt-bindings: ti, sci: Add lpm region and firmware-name Georgi Vlaev
2022-11-28 14:05 ` [PATCH v5 2/6] firmware: ti_sci: Introduce Power Management Ops Georgi Vlaev
2022-11-28 14:05 ` [PATCH v5 3/6] firmware: ti_sci: Add support for querying the firmware caps Georgi Vlaev
2022-11-28 14:05 ` [PATCH v5 4/6] firmware: ti_sci: Allocate memory for the LPM modes Georgi Vlaev
2022-11-28 14:05 ` [PATCH v5 5/6] firmware: ti_sci: Use dt provided fw name and address to load at suspend time Georgi Vlaev
2022-11-28 14:05 ` Georgi Vlaev [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221128140522.49474-7-g-vlaev@ti.com \
--to=g-vlaev@ti.com \
--cc=devicetree@vger.kernel.org \
--cc=kristo@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nm@ti.com \
--cc=robh+dt@kernel.org \
--cc=rogerq@kernel.org \
--cc=ssantosh@kernel.org \
--cc=vibhore@ti.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®