[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220421203659.27853-5-d-gerlach@ti.com>
Date: Thu, 21 Apr 2022 15:36:57 -0500
From: Dave Gerlach <d-gerlach@...com>
To: Rob Herring <robh+dt@...nel.org>,
Santosh Shilimkar <ssantosh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Tero Kristo <kristo@...nel.org>, Nishanth Menon <nm@...com>
CC: <linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
Vignesh Raghavendra <vigneshr@...com>,
Dave Gerlach <d-gerlach@...com>
Subject: [PATCH 4/6] firmware: ti_sci: Introduce ti,ctx-memory-region for reserved LPM memory
A reserved memory region in DDR must be used during low power modes for
saving of some system context when using the ti_sci firmware, so
introduce a property to allow providing this in the device tree so that
it can be read and shared with the firmware.
Also send a TISCI_MSG_PREPARE_SUSPEND message to the firmware during
probe to determine if system suspend is supported and if
ti_sci_init_suspend should be called based on the response received.
Signed-off-by: Dave Gerlach <d-gerlach@...com>
---
drivers/firmware/ti_sci.c | 45 +++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 4b0f747251c8..1c2000b40e8f 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -17,6 +17,7 @@
#include <linux/mailbox_client.h>
#include <linux/module.h>
#include <linux/of_device.h>
+#include <linux/of_reserved_mem.h>
#include <linux/semaphore.h>
#include <linux/slab.h>
#include <linux/soc/ti/ti-msgmgr.h>
@@ -96,6 +97,8 @@ struct ti_sci_desc {
* @minfo: Message info
* @node: list head
* @host_id: Host ID
+ * @mem_ctx_lo: Low word of address used for low power context memory
+ * @mem_ctx_hi: High word of address used for low power context memory
* @users: Number of users of this instance
* @is_suspending: Flag set to indicate in suspend path.
*/
@@ -114,6 +117,8 @@ struct ti_sci_info {
struct ti_sci_xfers_info minfo;
struct list_head node;
u8 host_id;
+ u32 mem_ctx_lo;
+ u32 mem_ctx_hi;
/* protected by ti_sci_list_mutex */
int users;
bool is_suspending;
@@ -3374,6 +3379,29 @@ static int ti_sci_resume(struct device *dev)
static DEFINE_SIMPLE_DEV_PM_OPS(ti_sci_pm_ops, ti_sci_suspend, ti_sci_resume);
+static int ti_sci_init_suspend(struct platform_device *pdev, struct ti_sci_info *info)
+{
+ struct device *dev = &pdev->dev;
+ struct device_node *rmem_np;
+ struct reserved_mem *rmem;
+
+ rmem_np = of_parse_phandle(dev->of_node, "ti,ctx-memory-region", 0);
+ if (!rmem_np) {
+ dev_warn(dev, "ti,ctx-memory-region is required for suspend but not provided.\n");
+ return -EINVAL;
+ }
+
+ rmem = of_reserved_mem_lookup(rmem_np);
+ of_node_put(rmem_np);
+ if (!rmem)
+ return -EINVAL;
+
+ info->mem_ctx_lo = (rmem->base & 0xFFFFFFFF);
+ info->mem_ctx_hi = (rmem->base >> 32);
+
+ return 0;
+}
+
/* Description for K2G */
static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = {
.default_host_id = 2,
@@ -3526,6 +3554,23 @@ static int ti_sci_probe(struct platform_device *pdev)
}
}
+ /*
+ * Attempt to call prepare_sleep, this will be NAK'd if suspend is not
+ * supported by firmware in use, in which case we will not attempt to
+ * init suspend.
+ */
+ ret = ti_sci_cmd_prepare_sleep(&info->handle, 0, info->mem_ctx_lo,
+ info->mem_ctx_hi, 0);
+ if (!ret) {
+ ret = ti_sci_init_suspend(pdev, info);
+ if (ret)
+ dev_warn(dev,
+ "ti_sci_init_suspend failed, mem suspend will be non-functional.\n");
+ }
+
+ /* Suspend is an optional feature, reset return value and continue. */
+ ret = 0;
+
dev_info(dev, "ABI: %d.%d (firmware rev 0x%04x '%s')\n",
info->handle.version.abi_major, info->handle.version.abi_minor,
info->handle.version.firmware_revision,
--
2.35.0
Powered by blists - more mailing lists