Merge tag 'hwmon-for-v6.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / nvmem / stm32-bsec-optee-ta.h
blob3966a053517951d7ec9c9bffd2cf939162d3d956
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * OP-TEE STM32MP BSEC PTA interface, used by STM32 ROMEM driver
5 * Copyright (C) 2022, STMicroelectronics - All Rights Reserved
6 */
8 #if IS_ENABLED(CONFIG_NVMEM_STM32_BSEC_OPTEE_TA)
9 /**
10 * stm32_bsec_optee_ta_open() - initialize the STM32 BSEC TA
11 * @ctx: the OP-TEE context on success
13 * Return:
14 * On success, 0. On failure, -errno.
16 int stm32_bsec_optee_ta_open(struct tee_context **ctx);
18 /**
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);
28 /**
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
35 * Return:
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);
41 /**
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
49 * Return:
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);
55 #else
57 static inline int stm32_bsec_optee_ta_open(struct tee_context **ctx)
59 return -EOPNOTSUPP;
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,
68 size_t bytes)
70 return -EOPNOTSUPP;
73 static 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)
78 return -EOPNOTSUPP;
80 #endif /* CONFIG_NVMEM_STM32_BSEC_OPTEE_TA */