1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef _DRV_HASH_V100_H_ 20 #define _DRV_HASH_V100_H_ 21 22 #include "drv_osal_lib.h" 23 24 /* ************************** Internal Structure Definition *************************** */ 25 /* Define the offset of reg */ 26 #define SEC_CHN_CFG 0x0304 27 #define CALC_ERR 0x0320 28 #define CIPHER_INT_STATUS 0x0404 29 #define NORM_SMMU_START_ADDR 0x0440 30 #define SEC_SMMU_START_ADDR 0x0444 31 #define HASH_INT_STATUS 0x0804 32 #define HASH_INT_EN 0x0808 33 #define HASH_INT_RAW 0x080C 34 #define HASH_IN_SMMU_EN 0x0810 35 #define CHAN0_HASH_DAT_IN 0x0818 36 #define CHAN0_HASH_TOTAL_DAT_LEN 0x081C 37 #define chann_hash_ctrl(id) (0x0800 + (id) * 0x80) 38 #define chann_hash_in_node_cfg(id) (0x0804 + (id) * 0x80) 39 #define chann_hash_in_node_start_addr(id)(0x0808 + (id) * 0x80) 40 #define chann_hash_in_buf_rptr(id) (0x080C + (id) * 0x80) 41 #define chann_hash_state_val(id) (0x0340 + (id) * 0x08) 42 #define chann_hash_state_val_addr(id) (0x0344 + (id) * 0x08) 43 #define chann_hash_in_node_start_high(id)(0x0820 + (id) * 0x80) 44 45 /* Define the union sec_chn_cfg */ 46 typedef union { 47 /* Define the struct bits */ 48 struct { 49 hi_u32 cipher_sec_chn_cfg : 8; /* [7..0] */ 50 hi_u32 cipher_sec_chn_cfg_lock : 1; /* [8] */ 51 hi_u32 reserved_0 : 7; /* [15..9] */ 52 hi_u32 hash_sec_chn_cfg : 8; /* [23..16] */ 53 hi_u32 hash_sec_chn_cfg_lock : 1; /* [24] */ 54 hi_u32 reserved_1 : 7; /* [31..25] */ 55 } bits; 56 57 /* Define an unsigned member */ 58 hi_u32 u32; 59 } sec_chn_cfg; 60 61 /* Define the union chan0_hash_ctrl */ 62 typedef union { 63 /* Define the struct bits */ 64 struct { 65 hi_u32 hash_ch0_start : 1; /* [0] */ 66 hi_u32 hash_ch0_agl_sel : 3; /* [3..1] */ 67 hi_u32 hash_ch0_hmac_calc_step : 1; /* [4] */ 68 hi_u32 hash_ch0_mode : 1; /* [5] */ 69 hi_u32 hash_ch0_key_sel : 1; /* [6] */ 70 hi_u32 reserved_0 : 2; /* [8..7] */ 71 hi_u32 hash_ch0_auto_padding_en : 1; /* [9] */ 72 hi_u32 hash_ch0_hmac_key_addr : 3; /* [12..10] */ 73 hi_u32 hash_ch0_used : 1; /* [13] */ 74 hi_u32 hash_ch0_sec_alarm : 1; /* [13] */ 75 hi_u32 reserved_1 : 17; /* [31..15] */ 76 } bits; 77 78 /* Define an unsigned member */ 79 hi_u32 u32; 80 } chan0_hash_ctrl; 81 82 /* Define the union hash_int_status */ 83 typedef union { 84 /* Define the struct bits */ 85 struct { 86 hi_u32 reserved_0 : 18; /* [17..0] */ 87 hi_u32 hash_chn_oram_int : 8; /* [25..18] */ 88 hi_u32 reserved_1 : 6; /* [31..26] */ 89 } bits; 90 91 /* Define an unsigned member */ 92 hi_u32 u32; 93 } hash_int_status; 94 95 /* Define the union hash_int_en */ 96 typedef union { 97 /* Define the struct bits */ 98 struct { 99 hi_u32 reserved_0 : 18; /* [17..0] */ 100 hi_u32 hash_chn_oram_en : 8; /* [25..18] */ 101 hi_u32 reserved_1 : 4; /* [29..26] */ 102 hi_u32 hash_sec_int_en : 1; /* [30] */ 103 hi_u32 hash_int_en : 1; /* [31] */ 104 } bits; 105 106 /* Define an unsigned member */ 107 hi_u32 u32; 108 } hash_int_en; 109 110 /* Define the union hash_int_raw */ 111 typedef union { 112 /* Define the struct bits */ 113 struct { 114 hi_u32 reserved_0 : 18; /* [17..0] */ 115 hi_u32 hash_chn_oram_raw : 8; /* [25..18] */ 116 hi_u32 reserved_1 : 6; /* [31..26] */ 117 } bits; 118 119 /* Define an unsigned member */ 120 hi_u32 u32; 121 } hash_int_raw; 122 123 /* Define the union cipher_int_status */ 124 typedef union { 125 /* Define the struct bits */ 126 struct { 127 hi_u32 reserved_0 : 1; /* [0] */ 128 hi_u32 cipher_chn_ibuf_int : 7; /* [7..1] */ 129 hi_u32 cipher_chn_obuf_int : 8; /* [15..8] */ 130 hi_u32 reserved_1 : 16; /* [31..16] */ 131 } bits; 132 133 /* Define an unsigned member */ 134 hi_u32 u32; 135 } cipher_int_status; 136 137 /* Define the union hash_in_smmu_en */ 138 typedef union { 139 /* Define the struct bits */ 140 struct { 141 hi_u32 hash_in_chan_rd_dat_smmu_en : 7; /* [6..0] */ 142 hi_u32 reserved_0 : 9; /* [15..7] */ 143 hi_u32 hash_in_chan_rd_node_smmu_en : 7; /* [22..16] */ 144 hi_u32 reserved_1 : 9; /* [31..23] */ 145 } bits; 146 147 /* Define an unsigned member */ 148 hi_u32 u32; 149 } hash_in_smmu_en; 150 151 /* Define the union chann_hash_ctrl */ 152 typedef union { 153 /* Define the struct bits */ 154 struct { 155 hi_u32 reserved_0 : 1; /* [0] */ 156 hi_u32 hash_chn_agl_sel : 3; /* [3..1] */ 157 hi_u32 reserved_1 : 1; /* [4] */ 158 hi_u32 hash_chn_mode : 1; /* [5] */ 159 hi_u32 hash_chn_key_sel : 1; /* [6] */ 160 hi_u32 hash_chn_dat_in_byte_swap_en : 1; /* [7] */ 161 hi_u32 hash_chn_dat_in_bit_swap_en : 1; /* [8] */ 162 hi_u32 hash_chn_auto_padding_en : 1; /* [9] */ 163 hi_u32 hash_chn_hmac_key_addr : 3; /* [12..10] */ 164 hi_u32 reserved_2 : 19; /* [31..13] */ 165 } bits; 166 167 /* Define an unsigned member */ 168 hi_u32 u32; 169 } chann_hash_ctrl; 170 171 /* Define the union chann_hash_int_node_cfg */ 172 typedef union { 173 /* Define the struct bits */ 174 struct { 175 hi_u32 hash_in_node_mpackage_int_level : 8; /* [7..0] */ 176 hi_u32 hash_in_node_rptr : 8; /* [15..8] */ 177 hi_u32 hash_in_node_wptr : 8; /* [23..16] */ 178 hi_u32 hash_in_node_total_num : 8; /* [31..24] */ 179 } bits; 180 181 /* Define an unsigned member */ 182 hi_u32 u32; 183 } chann_hash_int_node_cfg; 184 185 #endif /* End of _DRV_HASH_V100_H_ */ 186