1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (C) 2022, STMicroelectronics - All Rights Reserved 4 */ 5 6 #ifndef __PTA_STM32MP_BSEC_H 7 #define __PTA_STM32MP_BSEC_H 8 9 #include <util.h> 10 11 #define PTA_BSEC_UUID { 0x94cf71ad, 0x80e6, 0x40b5, \ 12 { 0xa7, 0xc6, 0x3d, 0xc5, 0x01, 0xeb, 0x28, 0x03 } } 13 14 /** 15 * Read OTP memory 16 * 17 * [in] value[0].a OTP start offset in byte 18 * [in] value[0].b Access type, see PTA_BSEC_TYPE_* 19 * [out] memref[1].buffer Output buffer to store read values 20 * [out] memref[1].size Size of OTP to be read 21 * 22 * Return codes: 23 * TEE_SUCCESS - Invoke command success 24 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param 25 * TEE_ERROR_ACCESS_DENIED - OTP not accessible by caller 26 */ 27 #define PTA_BSEC_CMD_READ_OTP 0x0 28 29 /** 30 * Write OTP memory 31 * 32 * [in] value[0].a OTP start offset in byte 33 * [in] value[0].b Access type (0 : shadow, 34 * 1 : fuse, 2 : lock) 35 * [in] memref[1].buffer Input buffer to read values 36 * [in] memref[1].size Size of OTP to be written 37 * 38 * Return codes: 39 * TEE_SUCCESS - Invoke command success 40 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param 41 * TEE_ERROR_ACCESS_DENIED - OTP not accessible by caller 42 */ 43 #define PTA_BSEC_CMD_WRITE_OTP 0x1 44 45 /** 46 * Get BSEC state 47 * Return the chip security level by reading the BSEC state 48 * 49 * [out] value[0].a One of PTA_BSEC_STATE_* 50 * Return codes: 51 * TEE_SUCCESS - Invoke command success 52 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param 53 */ 54 #define PTA_BSEC_CMD_GET_STATE 0x3 55 56 enum stm32_bsec_pta_sec_state { 57 PTA_BSEC_STATE_SEC_OPEN = 0, 58 PTA_BSEC_STATE_SEC_CLOSE = 1, 59 PTA_BSEC_STATE_INVALID = 3 60 }; 61 62 /* 63 * Access types identifiers for PTA_BSEC_CMD_READ_OTP and 64 * PTA_BSEC_CMD_WRITE_OTP = value[in].b. 65 * 66 * PTA_BSEC_SHADOW_ACCESS Access OTP shadow memory 67 * PTA_BSEC_FUSE_ACCESS Access OTP fuse memory 68 * PTA_BSEC_LOCKS_ACCESS Access OTP locks. The locks value read/written 69 * in memref[1] 32bit words are related to bit flag 70 * masks PTA_BSEC_LOCK_*. 71 */ 72 #define PTA_BSEC_SHADOW_ACCESS 0 73 #define PTA_BSEC_FUSE_ACCESS 1 74 #define PTA_BSEC_LOCKS_ACCESS 2 75 76 /* 77 * PTA_BSEC_LOCK_* - Bit mask of OTP locks in memref[1] 78 * 79 * PTA_BSEC_LOCK_PERM Fuse programming permanent lock 80 * PTA_BSEC_LOCK_SHADOW_R Shadow programming (from fuse) lock 81 * PTA_BSEC_LOCK_SHADOW_W Shadow memory write lock 82 * PTA_BSEC_LOCK_SHADOW_P Fuse programming sticky lock 83 * PTA_BSEC_LOCK_ERROR Flag indicating an error in lock access 84 */ 85 #define PTA_BSEC_LOCK_PERM BIT(30) 86 #define PTA_BSEC_LOCK_SHADOW_R BIT(29) 87 #define PTA_BSEC_LOCK_SHADOW_W BIT(28) 88 #define PTA_BSEC_LOCK_SHADOW_P BIT(27) 89 #define PTA_BSEC_LOCK_ERROR BIT(26) 90 91 #endif /* __PTA_STM32MP_BSEC_H */ 92