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