1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __EFUSE_OPT_H__ 17 #define __EFUSE_OPT_H__ 18 #include <hi_boot_rom.h> 19 20 #define EFUSE_MAX_INDEX_SIZE 32 21 #define EFUSE_BIT_NUM 2048 22 #define SIZE_32_BITS 32 23 #define SIZE_64_BITS 64 24 #define SHIFT_5_BITS 5 25 #define SHA_256_LENGTH 32 26 #define EFUSE_CFG_MAX_LEN 1320 27 #define EFUSE_CFG_MIN_LEN 48 28 #define U32_PER_LINE 4 29 #define EFUSE_READ_MAX_BITS 256 30 31 typedef struct { 32 hi_u8 hash[SHA_256_LENGTH]; /* hash of configuration file. */ 33 hi_u8 stru_ver; /* default 0. */ 34 hi_u8 stru_size; /* sizeof(struct otp_config_header). */ 35 hi_u16 number; /* Item number to be burn. */ 36 hi_u32 file_size; /* Configuration file size. */ 37 hi_u32 reserved[2]; /* Reserved 2 u32. */ 38 hi_u8 data[0]; /* Item: size = file_size - stru_size. */ 39 } efuse_config_header; 40 41 typedef struct { 42 hi_u8 stru_ver; /* default 0. */ 43 hi_u8 stru_size; /* sizeof(struct otp_config_item) */ 44 hi_u16 start_bit; /* Start bit of OTP */ 45 hi_u16 bit_width; /* Bit width */ 46 hi_u16 value_len; /* Length of value Byte(s), 4-byte-aligned. */ 47 hi_u8 value[0]; /* Item, offset: stru_size. */ 48 } efuse_config_item; 49 50 hi_u32 efuse_burn(uintptr_t file_addr, hi_u32 file_len); 51 hi_u32 efuse_read(hi_u16 start_bit, hi_u16 size); 52 hi_u8 get_writeable_encpt_cnt(hi_void); 53 54 #endif 55