1
0
Fork 0

LF-824: fw: imx: scu: Add missing APIs

APIs added:
 - IMX_SC_RM_FUNC_FIND_MEMREG
 - IMX_SC_RM_FUNC_GET_RESOURCE_OWNER
 - IMX_SC_RM_FUNC_SET_MEMREG_PERMISSIONS
 - IMX_SC_RM_FUNC_GET_DID

Signed-off-by: Franck LENORMAND <franck.lenormand@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Franck LENORMAND 2020-02-13 14:11:39 +01:00
parent acbef33f1d
commit 10237c7bcb
2 changed files with 161 additions and 2 deletions

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2016 Freescale Semiconductor, Inc.
* Copyright 2017~2019 NXP
* Copyright 2017~2020 NXP
*
* File containing client-side RPC functions for the RM service. These
* function are ported to clients that communicate to the SC.
@ -39,3 +39,130 @@ bool imx_sc_rm_is_resource_owned(struct imx_sc_ipc *ipc, u16 resource)
return hdr->func;
}
EXPORT_SYMBOL(imx_sc_rm_is_resource_owned);
struct imx_sc_msg_misc_find_memreg {
struct imx_sc_rpc_msg hdr;
union {
struct {
u32 add_start_hi;
u32 add_start_lo;
u32 add_end_hi;
u32 add_end_lo;
} req;
struct {
u8 val;
} resp;
} data;
};
int imx_sc_rm_find_memreg(struct imx_sc_ipc *ipc, u8 *mr, u64 addr_start,
u64 addr_end)
{
struct imx_sc_msg_misc_find_memreg msg;
struct imx_sc_rpc_msg *hdr = &msg.hdr;
int ret;
hdr->ver = IMX_SC_RPC_VERSION;
hdr->svc = IMX_SC_RPC_SVC_RM;
hdr->func = IMX_SC_RM_FUNC_FIND_MEMREG;
hdr->size = 5;
msg.data.req.add_start_hi = addr_start >> 32;
msg.data.req.add_start_lo = addr_start;
msg.data.req.add_end_hi = addr_end >> 32;
msg.data.req.add_end_lo = addr_end;
ret = imx_scu_call_rpc(ipc, &msg, true);
if (ret)
return ret;
if (mr)
*mr = msg.data.resp.val;
return 0;
}
EXPORT_SYMBOL(imx_sc_rm_find_memreg);
struct imx_sc_msg_misc_get_resource_owner {
struct imx_sc_rpc_msg hdr;
union {
struct {
u16 resource;
} req;
struct {
u8 val;
} resp;
} data;
};
int imx_sc_rm_get_resource_owner(struct imx_sc_ipc *ipc, u16 resource, u8 *pt)
{
struct imx_sc_msg_misc_get_resource_owner msg;
struct imx_sc_rpc_msg *hdr = &msg.hdr;
int ret;
hdr->ver = IMX_SC_RPC_VERSION;
hdr->svc = IMX_SC_RPC_SVC_RM;
hdr->func = IMX_SC_RM_FUNC_GET_RESOURCE_OWNER;
hdr->size = 2;
msg.data.req.resource = resource;
ret = imx_scu_call_rpc(ipc, &msg, true);
if (ret)
return ret;
if (pt)
*pt = msg.data.resp.val;
return 0;
}
EXPORT_SYMBOL(imx_sc_rm_get_resource_owner);
struct imx_sc_msg_set_memreg_permissions {
struct imx_sc_rpc_msg hdr;
u8 mr;
u8 pt;
u8 perm;
} __packed __aligned(4);
int imx_sc_rm_set_memreg_permissions(struct imx_sc_ipc *ipc, u8 mr,
u8 pt, u8 perm)
{
struct imx_sc_msg_set_memreg_permissions msg;
struct imx_sc_rpc_msg *hdr = &msg.hdr;
hdr->ver = IMX_SC_RPC_VERSION;
hdr->svc = IMX_SC_RPC_SVC_RM;
hdr->func = IMX_SC_RM_FUNC_SET_MEMREG_PERMISSIONS;
hdr->size = 2;
msg.mr = mr;
msg.pt = pt;
msg.perm = perm;
return imx_scu_call_rpc(ipc, &msg, true);
}
EXPORT_SYMBOL(imx_sc_rm_set_memreg_permissions);
int imx_sc_rm_get_did(struct imx_sc_ipc *ipc, u8 *did)
{
struct imx_sc_rpc_msg msg;
struct imx_sc_rpc_msg *hdr = &msg;
int ret;
hdr->ver = IMX_SC_RPC_VERSION;
hdr->svc = IMX_SC_RPC_SVC_RM;
hdr->func = IMX_SC_RM_FUNC_GET_DID;
hdr->size = 1;
ret = imx_scu_call_rpc(ipc, &msg, true);
if (ret < 0)
return ret;
if (did)
*did = msg.func;
return 0;
}
EXPORT_SYMBOL(imx_sc_rm_get_did);

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2016 Freescale Semiconductor, Inc.
* Copyright 2017-2019 NXP
* Copyright 2017-2020 NXP
*
* Header file containing the public API for the System Controller (SC)
* Power Management (PM) function. This includes functions for power state
@ -59,11 +59,43 @@ enum imx_sc_rm_func {
#if IS_ENABLED(CONFIG_IMX_SCU)
bool imx_sc_rm_is_resource_owned(struct imx_sc_ipc *ipc, u16 resource);
int imx_sc_rm_find_memreg(struct imx_sc_ipc *ipc, u8 *mr, u64 addr_start,
u64 addr_end);
int imx_sc_rm_get_resource_owner(struct imx_sc_ipc *ipc, u16 resource, u8 *pt);
int imx_sc_rm_set_memreg_permissions(struct imx_sc_ipc *ipc, u8 mr,
u8 pt, u8 perm);
int imx_sc_rm_get_did(struct imx_sc_ipc *ipc, u8 *did);
#else
static inline bool
imx_sc_rm_is_resource_owned(struct imx_sc_ipc *ipc, u16 resource)
{
return true;
}
static inline
int imx_sc_rm_find_memreg(struct imx_sc_ipc *ipc, u8 *mr, u64 addr_start,
u64 addr_end)
{
return -ENOTSUP;
}
static inline
int imx_sc_rm_get_resource_owner(struct imx_sc_ipc *ipc, u16 resource, u8 *pt)
{
return -ENOTSUP;
}
static inline
int imx_sc_rm_set_memreg_permissions(struct imx_sc_ipc *ipc, u8 mr,
u8 pt, u8 perm)
{
return -ENOTSUP;
}
static inline
int imx_sc_rm_get_did(struct imx_sc_ipc *ipc, u8 *did)
{
return -ENOTSUP;
}
#endif
#endif