Lines Matching +full:value +full:- +full:start

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"
15 * [in] value[0].a OTP start offset in byte
16 * [in] value[0].b Access type (0:shadow, 1:fuse, 2:lock)
21 * TEE_SUCCESS - Invoke command success
22 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
23 * TEE_ERROR_ACCESS_DENIED - OTP not accessible by caller
30 * [in] value[0].a OTP start offset in byte
31 * [in] value[0].b Access type (0:shadow, 1:fuse, 2:lock)
36 * TEE_SUCCESS - Invoke command success
37 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
38 * TEE_ERROR_ACCESS_DENIED - OTP not accessible by caller
42 /* value of PTA_BSEC access type = value[in] b */
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()
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 */
146 u32 start, num_bytes; in stm32_bsec_optee_ta_read() local
162 start = ALIGN_DOWN(offset, 4); in stm32_bsec_optee_ta_read()
163 num_bytes = round_up(offset + bytes - start, 4); in stm32_bsec_optee_ta_read()
165 param[0].u.value.a = start; in stm32_bsec_optee_ta_read()
166 param[0].u.value.b = SHADOW_ACCESS; 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()
230 param[0].u.value.a = offset; in stm32_bsec_optee_ta_write()
231 param[0].u.value.b = FUSE_ACCESS; in stm32_bsec_optee_ta_write()
258 ret = -EIO; in stm32_bsec_optee_ta_write()
264 u32 start, nb_lock; in stm32_bsec_optee_ta_write() local
272 start = max_t(u32, offset, lower * 4); in stm32_bsec_optee_ta_write()
273 nb_lock = (offset + bytes - start) / 4; in stm32_bsec_optee_ta_write()
275 param[0].u.value.a = start; in stm32_bsec_optee_ta_write()
276 param[0].u.value.b = LOCK_ACCESS; in stm32_bsec_optee_ta_write()
286 ret = -EIO; in stm32_bsec_optee_ta_write()
289 start / 4, start / 4 + nb_lock, ret); in stm32_bsec_optee_ta_write()