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