Lines Matching +full:otp +full:- +full:1
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
10 #include "stm32-bsec-optee-ta.h"
13 * Read OTP memory
15 * [in] value[0].a OTP start offset in byte
16 * [in] value[0].b Access type (0:shadow, 1:fuse, 2:lock)
17 * [out] memref[1].buffer Output buffer to store read values
18 * [out] memref[1].size Size of OTP to be read
21 * TEE_SUCCESS - Invoke command success
22 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
23 * TEE_ERROR_ACCESS_DENIED - OTP not accessible by caller
28 * Write OTP memory
30 * [in] value[0].a OTP start offset in byte
31 * [in] value[0].b Access type (0:shadow, 1:fuse, 2:lock)
32 * [in] memref[1].buffer Input buffer to read values
33 * [in] memref[1].size Size of OTP to be written
36 * TEE_SUCCESS - Invoke command success
37 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
38 * TEE_ERROR_ACCESS_DENIED - OTP not accessible by caller
44 #define FUSE_ACCESS 1
50 /* OP-TEE STM32MP BSEC TA UUID */
62 /* Currently this driver only supports GP compliant, OP-TEE based TA */ in stm32_bsec_optee_ta_match()
63 if ((ver->impl_id == TEE_IMPL_ID_OPTEE) && in stm32_bsec_optee_ta_match()
64 (ver->gen_caps & TEE_GEN_CAP_GP)) in stm32_bsec_optee_ta_match()
65 return 1; in stm32_bsec_optee_ta_match()
70 /* Open a session to OP-TEE for STM32MP BSEC TA */
86 rc = -EINVAL; in stm32_bsec_ta_open_session()
94 /* close a session to OP-TEE for STM32MP BSEC TA */
100 /* stm32_bsec_optee_ta_open() - initialize the STM32MP BSEC TA */
111 if (rc == -ENOENT) in stm32_bsec_optee_ta_open()
112 return -EPROBE_DEFER; in stm32_bsec_optee_ta_open()
132 /* stm32_bsec_optee_ta_open() - release the PTA STM32MP BSEC TA */
138 /* stm32_bsec_optee_ta_read() - nvmem read access using PTA client driver */
163 num_bytes = round_up(offset + bytes - start, 4); in stm32_bsec_optee_ta_read()
174 param[1].attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT; in stm32_bsec_optee_ta_read()
175 param[1].u.memref.shm = shm; in stm32_bsec_optee_ta_read()
176 param[1].u.memref.size = num_bytes; in stm32_bsec_optee_ta_read()
183 ret = -EIO; in stm32_bsec_optee_ta_read()
204 /* stm32_bsec_optee_ta_write() - nvmem write access using PTA client driver */
218 /* Allow only writing complete 32-bits aligned words */ in stm32_bsec_optee_ta_write()
220 return -EINVAL; in stm32_bsec_optee_ta_write()
239 param[1].attr = TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT; in stm32_bsec_optee_ta_write()
240 param[1].u.memref.shm = shm; in stm32_bsec_optee_ta_write()
241 param[1].u.memref.size = bytes; in stm32_bsec_optee_ta_write()
258 ret = -EIO; in stm32_bsec_optee_ta_write()
273 nb_lock = (offset + bytes - start) / 4; in stm32_bsec_optee_ta_write()
277 param[1].u.memref.size = nb_lock * 4; in stm32_bsec_optee_ta_write()
286 ret = -EIO; in stm32_bsec_optee_ta_write()