[U-Boot,1/4] imx8: scu_api: add sc_pm_get_resource_power_mode
diff mbox series

Message ID 20190716085034.30990-1-peng.fan@nxp.com
State New
Delegated to: Stefano Babic
Headers show
Series
  • [U-Boot,1/4] imx8: scu_api: add sc_pm_get_resource_power_mode
Related show

Commit Message

Peng Fan July 16, 2019, 8:35 a.m. UTC
Add sc_pm_get_resource_power_mode to get resource power mode

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/include/asm/arch-imx8/sci/sci.h |  2 ++
 drivers/misc/imx8/scu_api.c              | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

Patch
diff mbox series

diff --git a/arch/arm/include/asm/arch-imx8/sci/sci.h b/arch/arm/include/asm/arch-imx8/sci/sci.h
index 97377697f0..b73cda2286 100644
--- a/arch/arm/include/asm/arch-imx8/sci/sci.h
+++ b/arch/arm/include/asm/arch-imx8/sci/sci.h
@@ -58,6 +58,8 @@  static inline int sc_err_to_linux(sc_err_t err)
 /* PM API*/
 int sc_pm_set_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource,
 				  sc_pm_power_mode_t mode);
+int sc_pm_get_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource,
+				  sc_pm_power_mode_t *mode);
 int sc_pm_set_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
 			 sc_pm_clock_rate_t *rate);
 int sc_pm_get_clock_rate(sc_ipc_t ipc, sc_rsrc_t resource, sc_pm_clk_t clk,
diff --git a/drivers/misc/imx8/scu_api.c b/drivers/misc/imx8/scu_api.c
index d9c4d5d784..b181c6a29f 100644
--- a/drivers/misc/imx8/scu_api.c
+++ b/drivers/misc/imx8/scu_api.c
@@ -119,6 +119,31 @@  int sc_pm_set_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource,
 	return ret;
 }
 
+int sc_pm_get_resource_power_mode(sc_ipc_t ipc, sc_rsrc_t resource,
+				  sc_pm_power_mode_t *mode)
+{
+	struct udevice *dev = gd->arch.scu_dev;
+	struct sc_rpc_msg_s msg;
+	int size = sizeof(struct sc_rpc_msg_s);
+	int ret;
+
+	RPC_VER(&msg) = SC_RPC_VERSION;
+	RPC_SVC(&msg) = (u8)(SC_RPC_SVC_PM);
+	RPC_FUNC(&msg) = (u8)(PM_FUNC_GET_RESOURCE_POWER_MODE);
+	RPC_U16(&msg, 0U) = (u16)(resource);
+	RPC_SIZE(&msg) = 2U;
+
+	ret = misc_call(dev, SC_FALSE, &msg, size, &msg, size);
+	if (ret)
+		printf("%s: resource:%d: res:%d\n",
+		       __func__, resource, RPC_R8(&msg));
+
+	if (mode)
+		*mode = RPC_U8(&msg, 0U);
+
+	return ret;
+}
+
 /* PAD */
 int sc_pad_set(sc_ipc_t ipc, sc_pad_t pad, u32 val)
 {