1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * OP-TEE STM32MP BSEC PTA interface, used by STM32 ROMEM driver
5 * Copyright (C) 2022, STMicroelectronics - All Rights Reserved
8 #if IS_ENABLED(CONFIG_NVMEM_STM32_BSEC_OPTEE_TA)
10 * stm32_bsec_optee_ta_open() - initialize the STM32 BSEC TA
11 * @ctx: the OP-TEE context on success
14 * On success, 0. On failure, -errno.
16 int stm32_bsec_optee_ta_open(struct tee_context
**ctx
);
19 * stm32_bsec_optee_ta_close() - release the STM32 BSEC TA
20 * @ctx: the OP-TEE context
22 * This function used to clean the OP-TEE resources initialized in
23 * stm32_bsec_optee_ta_open(); it can be used as callback to
24 * devm_add_action_or_reset()
26 void stm32_bsec_optee_ta_close(void *ctx
);
29 * stm32_bsec_optee_ta_read() - nvmem read access using TA client driver
30 * @ctx: the OP-TEE context provided by stm32_bsec_optee_ta_open
31 * @offset: nvmem offset
32 * @buf: buffer to fill with nvem values
33 * @bytes: number of bytes to read
36 * On success, 0. On failure, -errno.
38 int stm32_bsec_optee_ta_read(struct tee_context
*ctx
, unsigned int offset
,
39 void *buf
, size_t bytes
);
42 * stm32_bsec_optee_ta_write() - nvmem write access using TA client driver
43 * @ctx: the OP-TEE context provided by stm32_bsec_optee_ta_open
44 * @lower: number of lower OTP, not protected by ECC
45 * @offset: nvmem offset
46 * @buf: buffer with nvem values
47 * @bytes: number of bytes to write
50 * On success, 0. On failure, -errno.
52 int stm32_bsec_optee_ta_write(struct tee_context
*ctx
, unsigned int lower
,
53 unsigned int offset
, void *buf
, size_t bytes
);
57 static inline int stm32_bsec_optee_ta_open(struct tee_context
**ctx
)
62 static inline void stm32_bsec_optee_ta_close(void *ctx
)
66 static inline int stm32_bsec_optee_ta_read(struct tee_context
*ctx
,
67 unsigned int offset
, void *buf
,
73 static inline int stm32_bsec_optee_ta_write(struct tee_context
*ctx
,
75 unsigned int offset
, void *buf
,
80 #endif /* CONFIG_NVMEM_STM32_BSEC_OPTEE_TA */