[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3882f0ac-b74c-6eb2-197c-34ca233cd7a3@ti.com>
Date: Thu, 3 Aug 2023 10:26:32 -0500
From: Andrew Davis <afd@...com>
To: Dhruva Gole <d-gole@...com>, Nishanth Menon <nm@...com>,
Tero Kristo <kristo@...nel.org>,
Santosh Shilimkar <ssantosh@...nel.org>
CC: <linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <linux-pm@...r.kernel.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
"Praneeth Bajjuri" <praneeth@...com>,
Tony Lindgren <tony@...mide.com>,
Dave Gerlach <d-gerlach@...com>,
Vibhore Vardhan <vibhore@...com>, Georgi Vlaev <g-vlaev@...com>
Subject: Re: [PATCH V6 4/4] firmware: ti_sci: Introduce system suspend resume
support
On 8/3/23 1:42 AM, Dhruva Gole wrote:
> Introduce system suspend resume calls that will allow the ti_sci
> driver to support deep sleep low power mode when the user space issues a
> suspend to mem.
>
> Also, write 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.
>
> Co-developed-by: Dave Gerlach <d-gerlach@...com>
> Signed-off-by: Dave Gerlach <d-gerlach@...com>
> Signed-off-by: Vibhore Vardhan <vibhore@...com>
> Signed-off-by: Georgi Vlaev <g-vlaev@...com>
> Signed-off-by: Dhruva Gole <d-gole@...com>
> ---
> drivers/firmware/ti_sci.c | 63 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 63 insertions(+)
>
> diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
> index 0334ade19868..172b726e00a6 100644
> --- a/drivers/firmware/ti_sci.c
> +++ b/drivers/firmware/ti_sci.c
> @@ -22,6 +22,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"
> @@ -3521,6 +3522,67 @@ static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode,
> return NOTIFY_BAD;
> }
>
> +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;
> + 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_cmd_set_io_isolation(&info->handle, TISCI_MSG_VALUE_IO_ENABLE);
After this the will the IOs be in isolation? Or does the firmware wait
until power down begins later?
Andrew
> + if (ret)
> + return ret;
> + dev_dbg(dev, "%s: set I/O isolation: %d\n", __func__, ret);
> +
> + ret = ti_sci_prepare_system_suspend(info);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +
> +static int ti_sci_resume(struct device *dev)
> +{
> + struct ti_sci_info *info = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = ti_sci_cmd_set_io_isolation(&info->handle, TISCI_MSG_VALUE_IO_DISABLE);
> + if (ret)
> + return ret;
> + dev_dbg(dev, "%s: disable I/O isolation: %d\n", __func__, ret);
> +
> + return 0;
> +}
> +
> +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)
> {
> @@ -3759,6 +3821,7 @@ static struct platform_driver ti_sci_driver = {
> .driver = {
> .name = "ti-sci",
> .of_match_table = of_match_ptr(ti_sci_of_match),
> + .pm = &ti_sci_pm_ops,
> },
> };
> module_platform_driver(ti_sci_driver);
Powered by blists - more mailing lists