1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0+ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Copyright 2020 NXP 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * File containing client-side RPC functions for the RM service. These 6*4882a593Smuzhiyun * function are ported to clients that communicate to the SC. 7*4882a593Smuzhiyun */ 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun #include <linux/firmware/imx/svc/rm.h> 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun struct imx_sc_msg_rm_rsrc_owned { 12*4882a593Smuzhiyun struct imx_sc_rpc_msg hdr; 13*4882a593Smuzhiyun u16 resource; 14*4882a593Smuzhiyun } __packed __aligned(4); 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun /* 17*4882a593Smuzhiyun * This function check @resource is owned by current partition or not 18*4882a593Smuzhiyun * 19*4882a593Smuzhiyun * @param[in] ipc IPC handle 20*4882a593Smuzhiyun * @param[in] resource resource the control is associated with 21*4882a593Smuzhiyun * 22*4882a593Smuzhiyun * @return Returns 0 for not owned and 1 for owned. 23*4882a593Smuzhiyun */ imx_sc_rm_is_resource_owned(struct imx_sc_ipc * ipc,u16 resource)24*4882a593Smuzhiyunbool imx_sc_rm_is_resource_owned(struct imx_sc_ipc *ipc, u16 resource) 25*4882a593Smuzhiyun { 26*4882a593Smuzhiyun struct imx_sc_msg_rm_rsrc_owned msg; 27*4882a593Smuzhiyun struct imx_sc_rpc_msg *hdr = &msg.hdr; 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun hdr->ver = IMX_SC_RPC_VERSION; 30*4882a593Smuzhiyun hdr->svc = IMX_SC_RPC_SVC_RM; 31*4882a593Smuzhiyun hdr->func = IMX_SC_RM_FUNC_IS_RESOURCE_OWNED; 32*4882a593Smuzhiyun hdr->size = 2; 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun msg.resource = resource; 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun /* 37*4882a593Smuzhiyun * SCU firmware only returns value 0 or 1 38*4882a593Smuzhiyun * for resource owned check which means not owned or owned. 39*4882a593Smuzhiyun * So it is always successful. 40*4882a593Smuzhiyun */ 41*4882a593Smuzhiyun imx_scu_call_rpc(ipc, &msg, true); 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun return hdr->func; 44*4882a593Smuzhiyun } 45*4882a593Smuzhiyun EXPORT_SYMBOL(imx_sc_rm_is_resource_owned); 46