mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 v4 5/5] firmware: ti_sci: Introduce prepare system suspend call
Date: Wed, 16 Nov 2022 20:13:07 +0200	[thread overview]
Message-ID: <20221116181307.198209-6-g-vlaev@ti.com> (raw)
In-Reply-To: <20221116181307.198209-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 TI_SCI_MSG_BEGIN_SLEEP with information
about the mode is being entered and the address for allocated memory for
storing the context during Deep Sleep.

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 | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index fec4ef0ae4c3..3fad7209b722 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -3510,9 +3510,39 @@ 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)
+{
+	int ret = 0;
+	int mode;
+
+	switch (pm_suspend_target_state) {
+	case PM_SUSPEND_MEM:
+		mode = TISCI_MSG_VALUE_SLEEP_MODE_DEEP_SLEEP;
+		break;
+	default:
+		ret = -EINVAL;
+	}
+
+	/*
+	 * Do not fail if we don't have action to take for a
+	 * specific suspend mode.
+	 */
+	if (ret)
+		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);
+}
+
 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


  parent reply	other threads:[~2022-11-16 18:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 18:13 [PATCH v4 0/5] firmware: ti_sci: Introduce system suspend support Georgi Vlaev
2022-11-16 18:13 ` [PATCH v4 1/5] dt-bindings: ti, sci: Add lpm region and firmware-name Georgi Vlaev
2022-11-18 12:59   ` Krzysztof Kozlowski
2022-11-21 22:26     ` Georgi Vlaev
2022-11-16 18:13 ` [PATCH v4 2/5] firmware: ti_sci: Introduce Power Management Ops Georgi Vlaev
2022-11-16 18:13 ` [PATCH v4 3/5] firmware: ti_sci: Allocate memory for the LPM modes Georgi Vlaev
2022-11-21 18:44   ` Nishanth Menon
2022-11-21 21:45     ` Georgi Vlaev
2022-11-21 18:56   ` Nishanth Menon
2022-11-21 22:03     ` Georgi Vlaev
2022-11-16 18:13 ` [PATCH v4 4/5] firmware: ti_sci: Use dt provided fw name and address to load at suspend time Georgi Vlaev
2022-11-16 18:13 ` Georgi Vlaev [this message]
2022-11-23 12:58   ` [PATCH v4 5/5] firmware: ti_sci: Introduce prepare system suspend call Roger Quadros

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=20221116181307.198209-6-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®