From: Hiago De Franco <hiagofranco@gmail.com>
To: Mathieu Poirier <mathieu.poirier@linaro.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
linux-pm@vger.kernel.org, linux-remoteproc@vger.kernel.org
Cc: Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Bjorn Andersson <andersson@kernel.org>,
Hiago De Franco <hiago.franco@toradex.com>,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@oss.nxp.com>,
daniel.baluta@nxp.com, iuliana.prodan@oss.nxp.com,
Fabio Estevam <festevam@gmail.com>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Peng Fan <peng.fan@nxp.com>
Subject: [PATCH v3 1/3] firmware: imx: introduce imx_sc_pm_get_resource_power_mode()
Date: Mon, 19 May 2025 14:15:12 -0300 [thread overview]
Message-ID: <20250519171514.61974-2-hiagofranco@gmail.com> (raw)
In-Reply-To: <20250519171514.61974-1-hiagofranco@gmail.com>
From: Hiago De Franco <hiago.franco@toradex.com>
This SCU API returns the power mode of a given resource.
As example, remoteproc/imx_rproc.c can now use this function to check
the power mode of the remote core to properly set "attached" or
"offline" modes.
Since there is no proper firmware/imx file to place this function, also
introduce firmware/imx/power.c file to keep all the PM functions inside.
Signed-off-by: Hiago De Franco <hiago.franco@toradex.com>
Suggested-by: Peng Fan <peng.fan@nxp.com>
---
v3: New patch.
---
drivers/firmware/imx/Makefile | 2 +-
drivers/firmware/imx/power.c | 52 +++++++++++++++++++++++++++++
include/linux/firmware/imx/svc/pm.h | 9 +++++
3 files changed, 62 insertions(+), 1 deletion(-)
create mode 100644 drivers/firmware/imx/power.c
diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile
index 8d046c341be8..5f5548e34459 100644
--- a/drivers/firmware/imx/Makefile
+++ b/drivers/firmware/imx/Makefile
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_IMX_DSP) += imx-dsp.o
-obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o
+obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o power.o
obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o
diff --git a/drivers/firmware/imx/power.c b/drivers/firmware/imx/power.c
new file mode 100644
index 000000000000..b982cebba72a
--- /dev/null
+++ b/drivers/firmware/imx/power.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * File containing client-side RPC functions for the PM (Power Management)
+ * service. These function are ported to clients that communicate to the SC.
+ */
+
+#include <linux/firmware/imx/svc/pm.h>
+
+struct imx_sc_msg_req_get_resource_power_mode {
+ struct imx_sc_rpc_msg hdr;
+ union {
+ struct {
+ u16 resource;
+ } req;
+ struct {
+ u8 mode;
+ } resp;
+ } data;
+} __packed __aligned(4);
+
+/**
+ * imx_sc_pm_get_resource_power_mode - Get power mode from a given resource.
+ * @ipc: IPC handle.
+ * @resource: Resource to check the power mode.
+ *
+ * Return: Returns < 0 for errors or the following for success:
+ * * %IMX_SC_PM_PW_MODE_OFF - Power off
+ * * %IMX_SC_PM_PW_MODE_STBY - Power in standby
+ * * %IMX_SC_PM_PW_MODE_LP - Power in low-power
+ * * %IMX_SC_PM_PW_MODE_ON - Power on
+ *
+ */
+int imx_sc_pm_get_resource_power_mode(struct imx_sc_ipc *ipc, u32 resource)
+{
+ struct imx_sc_msg_req_get_resource_power_mode msg;
+ struct imx_sc_rpc_msg *hdr = &msg.hdr;
+ int ret;
+
+ hdr->ver = IMX_SC_RPC_VERSION;
+ hdr->svc = IMX_SC_RPC_SVC_PM;
+ hdr->func = IMX_SC_PM_FUNC_GET_RESOURCE_POWER_MODE;
+ hdr->size = 2;
+
+ msg.data.req.resource = resource;
+
+ ret = imx_scu_call_rpc(ipc, &msg, true);
+ if (ret)
+ return ret;
+
+ return msg.data.resp.mode;
+}
+EXPORT_SYMBOL(imx_sc_pm_get_resource_power_mode);
diff --git a/include/linux/firmware/imx/svc/pm.h b/include/linux/firmware/imx/svc/pm.h
index 1f6975dd37b0..56e93a953295 100644
--- a/include/linux/firmware/imx/svc/pm.h
+++ b/include/linux/firmware/imx/svc/pm.h
@@ -82,4 +82,13 @@ enum imx_sc_pm_func {
#define IMX_SC_PM_PARENT_PLL2 3 /* Parent in PLL2 or PLL0/4 */
#define IMX_SC_PM_PARENT_BYPS 4 /* Parent is a bypass clock. */
+#if IS_ENABLED(CONFIG_IMX_SCU)
+int imx_sc_pm_get_resource_power_mode(struct imx_sc_ipc *ipc, u32 resource);
+#else
+static inline int imx_sc_pm_get_resource_power_mode(struct imx_sc_ipc *ipc,
+ u32 resource)
+{
+ return -EOPNOTSUPP;
+}
+#endif
#endif /* _SC_PM_API_H */
--
2.39.5
next prev parent reply other threads:[~2025-05-19 18:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-19 17:15 [PATCH v3 0/3] remoteproc: imx_rproc: allow attaching to running core kicked by the bootloader Hiago De Franco
2025-05-19 17:15 ` Hiago De Franco [this message]
2025-05-19 17:15 ` [PATCH v3 2/3] remoteproc: imx_rproc: skip clock enable when M-core is managed by the SCU Hiago De Franco
2025-05-19 17:15 ` [PATCH v3 3/3] remoteproc: imx_rproc: add power mode check for remote core attachment Hiago De Franco
2025-05-21 4:22 ` [PATCH v3 0/3] remoteproc: imx_rproc: allow attaching to running core kicked by the bootloader Peng Fan
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=20250519171514.61974-2-hiagofranco@gmail.com \
--to=hiagofranco@gmail.com \
--cc=andersson@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=festevam@gmail.com \
--cc=hiago.franco@toradex.com \
--cc=imx@lists.linux.dev \
--cc=iuliana.prodan@oss.nxp.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=ulf.hansson@linaro.org \
/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