summaryrefslogtreecommitdiff
path: root/drivers/misc/imx8/scu_api.c
diff options
context:
space:
mode:
authorPeng Fan <peng.fan@nxp.com>2019-05-05 13:23:51 +0000
committerStefano Babic <sbabic@denx.de>2019-07-19 15:16:54 +0200
commit7752a0fef74be1b222caf1d9c5cf07e0e4b6190c (patch)
tree1baef706901dba3142cebf8f94a95dbffef6ecb5 /drivers/misc/imx8/scu_api.c
parent5fbc667d8a8c7d96169ec5f7e29a2fbaf34f45aa (diff)
downloadu-boot-7752a0fef74be1b222caf1d9c5cf07e0e4b6190c.tar.gz
misc: imx8: add sc_misc_get_temp
Add sc_misc_get_temp to support get temperature Signed-off-by: Peng Fan <peng.fan@nxp.com>
Diffstat (limited to 'drivers/misc/imx8/scu_api.c')
-rw-r--r--drivers/misc/imx8/scu_api.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/misc/imx8/scu_api.c b/drivers/misc/imx8/scu_api.c
index d9c4d5d784..031bc0048b 100644
--- a/drivers/misc/imx8/scu_api.c
+++ b/drivers/misc/imx8/scu_api.c
@@ -273,6 +273,34 @@ int sc_misc_otp_fuse_read(sc_ipc_t ipc, u32 word, u32 *val)
return 0;
}
+int sc_misc_get_temp(sc_ipc_t ipc, sc_rsrc_t resource, sc_misc_temp_t temp,
+ s16 *celsius, s8 *tenths)
+{
+ struct udevice *dev = gd->arch.scu_dev;
+ int size = sizeof(struct sc_rpc_msg_s);
+ struct sc_rpc_msg_s msg;
+ int ret;
+
+ RPC_VER(&msg) = SC_RPC_VERSION;
+ RPC_SVC(&msg) = (u8)SC_RPC_SVC_MISC;
+ RPC_FUNC(&msg) = (u8)MISC_FUNC_GET_TEMP;
+ RPC_U16(&msg, 0U) = (u16)resource;
+ RPC_U8(&msg, 2U) = (u8)temp;
+ RPC_SIZE(&msg) = 2U;
+
+ ret = misc_call(dev, SC_FALSE, &msg, size, &msg, size);
+ if (ret < 0)
+ return ret;
+
+ if (celsius)
+ *celsius = RPC_I16(&msg, 0U);
+
+ if (tenths)
+ *tenths = RPC_I8(&msg, 2U);
+
+ return 0;
+}
+
/* RM */
sc_bool_t sc_rm_is_memreg_owned(sc_ipc_t ipc, sc_rm_mr_t mr)
{