From: Ye Li <[email protected]> The XSPI SET GMID command is used to assign GMID ownership to the requester, allowing access to protected XSPI control registers. This API must be called in SPL if XSPI GMID-protected settings need to be modified. Otherwise, XSPI configuration depends on the previous GMID owner to provide the correct settings.
Signed-off-by: Ye Li <[email protected]> Signed-off-by: Alice Guo <[email protected]> --- arch/arm/include/asm/mach-imx/ele_api.h | 2 ++ drivers/misc/imx_ele/ele_api.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/arch/arm/include/asm/mach-imx/ele_api.h b/arch/arm/include/asm/mach-imx/ele_api.h index 64b243dcaaa..09511a7e0d5 100644 --- a/arch/arm/include/asm/mach-imx/ele_api.h +++ b/arch/arm/include/asm/mach-imx/ele_api.h @@ -47,6 +47,7 @@ #define ELE_ATTEST_REQ (0xDB) #define ELE_RELEASE_PATCH_REQ (0xDC) #define ELE_OTP_SEQ_SWITH_REQ (0xDD) +#define ELE_SET_GMID_REQ (0xE4) #define ELE_WRITE_SHADOW_REQ (0xF2) #define ELE_READ_SHADOW_REQ (0xF3) @@ -160,4 +161,5 @@ int ele_return_lifecycle_update(ulong signed_msg_blk, u32 *response); int ele_start_rng(void); int ele_write_shadow_fuse(u32 fuse_id, u32 fuse_val, u32 *response); int ele_read_shadow_fuse(u32 fuse_id, u32 *fuse_val, u32 *response); +int ele_set_gmid(u32 *response); #endif diff --git a/drivers/misc/imx_ele/ele_api.c b/drivers/misc/imx_ele/ele_api.c index 661f70cf870..e194091fa9d 100644 --- a/drivers/misc/imx_ele/ele_api.c +++ b/drivers/misc/imx_ele/ele_api.c @@ -794,3 +794,31 @@ int ele_generate_dek_blob(u32 key_id, u32 src_paddr, u32 dst_paddr, u32 max_outp return ret; } + +int ele_set_gmid(u32 *response) +{ + struct udevice *dev = gd->arch.ele_dev; + int size = sizeof(struct ele_msg); + struct ele_msg msg = {}; + int ret; + + if (!dev) { + printf("ele dev is not initialized\n"); + return -ENODEV; + } + + msg.version = ELE_VERSION; + msg.tag = ELE_CMD_TAG; + msg.size = 1; + msg.command = ELE_SET_GMID_REQ; + + ret = misc_call(dev, false, &msg, size, &msg, size); + if (ret) + printf("Error: %s: ret %d, response 0x%x\n", + __func__, ret, msg.data[0]); + + if (response) + *response = msg.data[0]; + + return ret; +} -- 2.43.0

