[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220421203659.27853-7-d-gerlach@ti.com>
Date: Thu, 21 Apr 2022 15:36:59 -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 6/6] firmware: ti_sci: Introduce prepare system suspend call
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 nevessary, send TI_SCI_MSG_BEGIN_SLEEP with information
about the mode is being entered and the address for DDR memory carveout.
Signed-off-by: Dave Gerlach <d-gerlach@...com>
---
drivers/firmware/ti_sci.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 772643cb940c..07b6fa98bb45 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -23,6 +23,7 @@
#include <linux/slab.h>
#include <linux/soc/ti/ti-msgmgr.h>
#include <linux/soc/ti/ti_sci_protocol.h>
+#include <linux/suspend.h>
#include <linux/reboot.h>
#include "ti_sci.h"
@@ -3388,11 +3389,41 @@ 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;
+
+ ret = ti_sci_cmd_prepare_sleep(&info->handle, mode, info->mem_ctx_lo,
+ info->mem_ctx_hi, 0);
+
+ return ret;
+}
+
static int ti_sci_suspend(struct device *dev)
{
struct ti_sci_info *info = dev_get_drvdata(dev);
int ret = 0;
+ 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.35.0
Powered by blists - more mailing lists