brintos

brintos / linux-shallow public Read only

0
0
Text · 2.1 KiB · 3966a05 Raw
81 lines · c
1/* SPDX-License-Identifier: GPL-2.0-or-later */2/*3 * OP-TEE STM32MP BSEC PTA interface, used by STM32 ROMEM driver4 *5 * Copyright (C) 2022, STMicroelectronics - All Rights Reserved6 */7 8#if IS_ENABLED(CONFIG_NVMEM_STM32_BSEC_OPTEE_TA)9/**10 * stm32_bsec_optee_ta_open() - initialize the STM32 BSEC TA11 * @ctx: the OP-TEE context on success12 *13 * Return:14 *	On success, 0. On failure, -errno.15 */16int stm32_bsec_optee_ta_open(struct tee_context **ctx);17 18/**19 * stm32_bsec_optee_ta_close() - release the STM32 BSEC TA20 * @ctx: the OP-TEE context21 *22 * This function used to clean the OP-TEE resources initialized in23 * stm32_bsec_optee_ta_open(); it can be used as callback to24 * devm_add_action_or_reset()25 */26void stm32_bsec_optee_ta_close(void *ctx);27 28/**29 * stm32_bsec_optee_ta_read() - nvmem read access using TA client driver30 * @ctx: the OP-TEE context provided by stm32_bsec_optee_ta_open31 * @offset: nvmem offset32 * @buf: buffer to fill with nvem values33 * @bytes: number of bytes to read34 *35 * Return:36 *	On success, 0. On failure, -errno.37 */38int stm32_bsec_optee_ta_read(struct tee_context *ctx, unsigned int offset,39			     void *buf, size_t bytes);40 41/**42 * stm32_bsec_optee_ta_write() - nvmem write access using TA client driver43 * @ctx: the OP-TEE context provided by stm32_bsec_optee_ta_open44 * @lower: number of lower OTP, not protected by ECC45 * @offset: nvmem offset46 * @buf: buffer with nvem values47 * @bytes: number of bytes to write48 *49 * Return:50 *	On success, 0. On failure, -errno.51 */52int stm32_bsec_optee_ta_write(struct tee_context *ctx, unsigned int lower,53			      unsigned int offset, void *buf, size_t bytes);54 55#else56 57static inline int stm32_bsec_optee_ta_open(struct tee_context **ctx)58{59	return -EOPNOTSUPP;60}61 62static inline void stm32_bsec_optee_ta_close(void *ctx)63{64}65 66static inline int stm32_bsec_optee_ta_read(struct tee_context *ctx,67					   unsigned int offset, void *buf,68					   size_t bytes)69{70	return -EOPNOTSUPP;71}72 73static inline int stm32_bsec_optee_ta_write(struct tee_context *ctx,74					    unsigned int lower,75					    unsigned int offset, void *buf,76					    size_t bytes)77{78	return -EOPNOTSUPP;79}80#endif /* CONFIG_NVMEM_STM32_BSEC_OPTEE_TA */81