1 //<MStar Software> 2 //****************************************************************************** 3 // MStar Software 4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved. 5 // All software, firmware and related documentation herein ("MStar Software") are 6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by 7 // law, including, but not limited to, copyright law and international treaties. 8 // Any use, modification, reproduction, retransmission, or republication of all 9 // or part of MStar Software is expressly prohibited, unless prior written 10 // permission has been granted by MStar. 11 // 12 // By accessing, browsing and/or using MStar Software, you acknowledge that you 13 // have read, understood, and agree, to be bound by below terms ("Terms") and to 14 // comply with all applicable laws and regulations: 15 // 16 // 1. MStar shall retain any and all right, ownership and interest to MStar 17 // Software and any modification/derivatives thereof. 18 // No right, ownership, or interest to MStar Software and any 19 // modification/derivatives thereof is transferred to you under Terms. 20 // 21 // 2. You understand that MStar Software might include, incorporate or be 22 // supplied together with third party`s software and the use of MStar 23 // Software may require additional licenses from third parties. 24 // Therefore, you hereby agree it is your sole responsibility to separately 25 // obtain any and all third party right and license necessary for your use of 26 // such third party`s software. 27 // 28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as 29 // MStar`s confidential information and you agree to keep MStar`s 30 // confidential information in strictest confidence and not disclose to any 31 // third party. 32 // 33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any 34 // kind. Any warranties are hereby expressly disclaimed by MStar, including 35 // without limitation, any warranties of merchantability, non-infringement of 36 // intellectual property rights, fitness for a particular purpose, error free 37 // and in conformity with any international standard. You agree to waive any 38 // claim against MStar for any loss, damage, cost or expense that you may 39 // incur related to your use of MStar Software. 40 // In no event shall MStar be liable for any direct, indirect, incidental or 41 // consequential damages, including without limitation, lost of profit or 42 // revenues, lost or damage of data, and unauthorized system use. 43 // You agree that this Section 4 shall still apply without being affected 44 // even if MStar Software has been modified by MStar in accordance with your 45 // request or instruction for your use, except otherwise agreed by both 46 // parties in writing. 47 // 48 // 5. If requested, MStar may from time to time provide technical supports or 49 // services in relation with MStar Software to you for your use of 50 // MStar Software in conjunction with your or your customer`s product 51 // ("Services"). 52 // You understand and agree that, except otherwise agreed by both parties in 53 // writing, Services are provided on an "AS IS" basis and the warranty 54 // disclaimer set forth in Section 4 above shall apply. 55 // 56 // 6. Nothing contained herein shall be construed as by implication, estoppels 57 // or otherwise: 58 // (a) conferring any license or right to use MStar name, trademark, service 59 // mark, symbol or any other identification; 60 // (b) obligating MStar or any of its affiliates to furnish any person, 61 // including without limitation, you and your customers, any assistance 62 // of any kind whatsoever, or any information; or 63 // (c) conferring any license or right under any intellectual property right. 64 // 65 // 7. These terms shall be governed by and construed in accordance with the laws 66 // of Taiwan, R.O.C., excluding its conflict of law rules. 67 // Any and all dispute arising out hereof or related hereto shall be finally 68 // settled by arbitration referred to the Chinese Arbitration Association, 69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration 70 // Rules of the Association by three (3) arbitrators appointed in accordance 71 // with the said Rules. 72 // The place of arbitration shall be in Taipei, Taiwan and the language shall 73 // be English. 74 // The arbitration award shall be final and binding to both parties. 75 // 76 //****************************************************************************** 77 //<MStar Software> 78 //////////////////////////////////////////////////////////////////////////////// 79 // 80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc. 81 // All rights reserved. 82 // 83 // Unless otherwise stipulated in writing, any and all information contained 84 // herein regardless in any format shall remain the sole proprietary of 85 // MStar Semiconductor Inc. and be kept in strict confidence 86 // ("MStar Confidential Information") by the recipient. 87 // Any unauthorized act including without limitation unauthorized disclosure, 88 // copying, use, reproduction, sale, distribution, modification, disassembling, 89 // reverse engineering and compiling of the contents of MStar Confidential 90 // Information is unlawful and strictly prohibited. MStar hereby reserves the 91 // rights to any and all damages, losses, costs and expenses resulting therefrom. 92 //////////////////////////////////////////////////////////////////////////////// 93 94 #ifndef _REGNSK2_H_ 95 #define _REGNSK2_H_ 96 97 //////////////////////////////////////////////////////////////////////////////// 98 // Header Files 99 //////////////////////////////////////////////////////////////////////////////// 100 101 //////////////////////////////////////////////////////////////////////////////// 102 // Define & data type 103 //////////////////////////////////////////////////////////////////////////////// 104 //v: value n: shift n bits 105 #define __BIT(x) ((MS_U32)(1 << (x))) 106 #define __BIT0 __BIT(0) 107 #define __BIT1 __BIT(1) 108 #define __BIT2 __BIT(2) 109 #define __BIT3 __BIT(3) 110 #define __BIT4 __BIT(4) 111 #define __BIT5 __BIT(5) 112 #define __BIT6 __BIT(6) 113 #define __BIT7 __BIT(7) 114 #define __BIT8 __BIT(8) 115 #define __BIT9 __BIT(9) 116 #define __BITA __BIT(0xA) 117 #define __BITB __BIT(0xB) 118 #define __BITC __BIT(0xC) 119 #define __BITD __BIT(0xD) 120 #define __BITE __BIT(0xE) 121 #define __BITF __BIT(0xF) 122 123 #define __BIT21 __BIT(21) 124 #define __BIT31 __BIT(31) 125 126 //#define BMASK(_bits_) (__BIT(((1)?_bits_)+1)-__BIT(((0)?_bits_))) 127 128 #define BYTE0 0xFF 129 #define BYTE1 (0xFF<<8) 130 #define BYTE0_MASK 0x00FF 131 #define BYTE1_MASK 0xFF00 132 133 134 #define REG_CLKGEN0_BASE (0x100B00<<1) 135 #define REG_NSK2_BASE (0x180000<<1) 136 #define REG_OTP_BASE (0x190000<<1) 137 #define REG_OTP_CTRL_BASE (0x1A1300<<1) 138 #define REG_NI_BASE (0x1A1800<<1) 139 #define REG_RSA_BASE (0x1A1200<<1) 140 #define REG_KEY_TABLE_BASE (0x1A0C00<<1) 141 #define REG_JTAG_PWD_BASE (0x170300<<1) //check!! 142 #define REG_CIPHER_CH0_BASE (0x1A0700<<1) 143 144 #define REG_CRYPTO_DMA_BASE (0x1A0B00<<1) //x32_CryptoDMA0 145 146 147 #define REG_NSK2_ACPU_CMD 0xFC00 148 #define NSK2_ACPU_CMD 0xFF 149 150 #define REG_NSK2_ACPU_WARNING 0xFC04 151 #define NSK2_ACPU_BUSY __BIT31 152 153 #define REG_NSK2_ACPU_INT 0xFC08 154 #define NSK2_INT_CMD_EXIT __BIT0 155 #define NSK2_INT_ASYNC_EVENT __BIT1 156 #define NSK2_INT_ILLEGAL_CMD __BIT2 157 #define NSK2_INT_ILLEGAL_ACCESS __BIT3 158 #define NSK2_INT_RESET __BIT4 159 #define NSK2_INT_HANG __BIT5 160 #define NSK2_INT_KTE_VALID __BIT6 161 #define NSK2_INT_MASK_CLEAR __BIT31 162 163 164 #define REG_NSK2_ACPU_CTRL_BLOCK 0xFC0C 165 166 167 #define REG_NSK2_ACPU_ERROR 0xFC10 168 169 #define REG_NSK2_KTE_SWITCH_1 0xFC40 170 #define REG_NSK2_KTE_SWITCH_2 0xFC44 171 #define REG_NSK2_KTE_SWITCH_3 0xFC48 172 173 #define REG_NSK2_KTE_VALID 0xFC4C 174 #define NSK2_KTE_VALID_TRUE __BIT0 175 176 #define REG_NSK2_GENOUT_LOW 0xFC50 177 178 #define REG_NSK2_VEN_VERSION 0xFC70 179 180 #define REG_NSK2_GENOUT_HIGH 0xFDFC 181 182 183 #define REG_NI_NSK2_CTRL 0x0 184 #define NI_TS2NSK_ENABLE 0x1 185 #define NI_TS2NSK_RATE BMASK(3:1) 186 #define NI_TEST_RC_FREQ_MAP BMASK(7:4) 187 #define NI_N2ROM_PD __BIT8 188 #define NI_NO_RST_DELAY __BITD 189 #define NI_NSK2_CLK_ENABLE __BITE 190 #define NI_NSK2_RESET_DISABLE __BITF 191 192 #define REG_NI_NSK2_FREERUN 0x1 193 #define NI_NSK2_FREERUN_ENABLE __BIT2 194 #define NI_NSK2_RANDOM_FREERUN __BIT4 195 #define NI_NSK2_RANDOM_ONEBYONE __BIT5 196 197 #define REG_NI_SW_SET_RNG 0x5 198 #define NI_SW_RNG_MASK BMASK(15:0) 199 200 #define REG_NI_COMMAND 0x6 201 #define NI_COMMAND_START 0x1 202 203 #define NI_KIW_CMD_MASK BMASK(15:8) 204 #define NI_KIW_CMD_SHIFT 8 205 #define NI_NopNop 0x0 206 207 #define NI_OTP_ACK_NSK2 (1<<1) 208 #define NI_ERR_INVALID_SLOT (1<<2) 209 #define NI_NSKBIComplete (1<<NI_KIW_CMD_SHIFT) 210 #define NI_DriveAck (2<<NI_KIW_CMD_SHIFT) 211 #define NI_InvalidateCmChannel (4<<NI_KIW_CMD_SHIFT) 212 #define NI_InvalidateM2M (5<<NI_KIW_CMD_SHIFT) 213 #define NI_ConfigureCmChannel (6<<NI_KIW_CMD_SHIFT) 214 #define NI_WriteTransportKey (8<<NI_KIW_CMD_SHIFT) 215 #define NI_WriteM2MKey (9<<NI_KIW_CMD_SHIFT) 216 #define NI_WriteMDEMKey (10<<NI_KIW_CMD_SHIFT) 217 #define NI_WriteJTAGKey (12<<NI_KIW_CMD_SHIFT) 218 #define NI_WriteSCPUKey (13<<NI_KIW_CMD_SHIFT) 219 #define NI_WriteReservedKey (14<<NI_KIW_CMD_SHIFT) 220 #define NI_WriteRandomValue (15<<NI_KIW_CMD_SHIFT) 221 #define NI_WriteOTPKey (16<<NI_KIW_CMD_SHIFT) 222 #define NI_IncrementNvCounter (17<<NI_KIW_CMD_SHIFT) 223 224 225 #define NI_KIW_PidNo_MASK BMASK(23:16) 226 #define NI_WriteTKey_PidNo_Shift 16 227 #define NI_WriteTransportKey_PidNo BMASK(23:16) 228 #define NI_WriteTKey_SCB_Shift 24 229 #define NI_WriteTKey_SCB_MASK BMASK(25:24) 230 #define NI_WriteTKey_FSCB_Shift 26 231 #define NI_WriteTKey_FSCB_MASK BMASK(27:26) 232 233 #define NI_WriteESA 0x2 234 #define NI_JTAG_PasswordWriteSCPUKey 0x8 235 #define NI_CearWKResp 0xC 236 237 238 #define REG_NI_DSCMB_ALGO 0x7 239 240 #define NI_KIW_LSAD_ALGO_MASK BMASK(4:0) 241 #define NI_KIW_ESA_ALGO_SHIFT 8 242 #define NI_KIW_ESA_ALGO_MASK BMASK(12:8) 243 #define NI_KIW_LSAS_ALGO_SHIFT 16 244 #define NI_KIW_LSAS_ALGO_MASK BMASK(20:16) 245 246 #define NI_WriteESA_PidNo BMASK(7:0) 247 #define NI_WriteESA_ESASubSel_Shift 16 248 #define NI_WriteESA_ESASubSel_MASK BMASK(18:16) 249 #define NI_WriteESA_ESASel_Shift 19 250 #define NI_WriteESA_ESASel_MASK BMASK(22:19) 251 252 #define NI_WriteM2MKey_Shift 16 253 #define NI_WriteM2MKey_MASK BMASK(19:16) 254 255 #define REG_NI_IV_31_00 0x8 256 #define REG_NI_IV_63_31 0x9 257 #define REG_NI_IV_95_64 0xA 258 #define REG_NI_IV_127_96 0xB 259 260 #define REG_NI_STATUS 0xC 261 #define NI_NSK_BUSY __BIT0 262 #define NI_SKB_BUSY __BIT1 263 #define NI_AIW_BUSY __BIT2 264 #define NI_KIW_BUSY __BIT3 265 266 #define REG_NI_KTE_STATUS 0xD 267 #define NI_KTE_DEST_MASK BMASK(2:0) 268 #define NI_KTE_VALID __BIT3 269 #define NI_NSK2_FREQ_OKAY __BIT4 270 #define NI_SLOW_CLOCK_DETECT __BIT5 271 #define NI_CLOCK_HALT_DETECT __BIT6 272 273 #define REG_NI_COMPARE_GENOUT_L 0x17 274 #define NSK2_IS_BUSY __BIT(21) 275 #define NSK2_KTE_DEST BMASK(20:17) 276 #define NSK2_CON_CUR __BIT(16) 277 #define NSK2_CSA2VAR_EN __BIT(15) 278 #define NSK2_CSA3VAR_EN __BIT(14) 279 #define NSK2_CPNR __BIT(1) //Content Protection Not Required 280 #define NSK2_OTPPWD __BIT(0) //OTP Program Password Accepted 281 282 #define REG_NI_COMPARE_GENOUT_H 0x18 283 #define NI_GENOUT_H_MASK BMASK(5:0) 284 285 #define REG_NI_NSK2_TRNG_VALID 0x19 286 #define NI_NSK2_TRNG_VALID_MASK BMASK(0:0) 287 288 #define REG_NI_NSK2_TRNG_DATA 0x1A 289 290 #define REG_NI_NSK2_KTE_RESP 0x1C 291 292 293 #define REG_NI_NSK2_CLK_CSA 0x24 294 #define NSK2_PUSH_SLOW_CLK __BIT(0) 295 #define NSK2_EN_CSA_VAR __BIT(4) 296 297 #define REG_KT_KEYS_START_FPGA 0x28 298 #define REG_KT_KEYS_END_FPGA 0x36 299 300 301 #define REG_NI_NSK2_KTE_VALID_FPGA 0x37 302 #define NI_NSK2_KTE_VALID_FPGA __BIT0 303 304 #define REG_NI_NSK21_GENIN 0x40 305 306 #define REG_NI_NSK21_CONCURR_PROT_EN 0x41 307 308 #define REG_NI_NSK21_CONCURR_SET 0x42 309 310 #define REG_NI_NSK21_GEN_SHOT 0x43 311 312 #define REG_NI_NSK2_REG_GENIN 0x44 313 314 315 #define REG_RSA_CLK_ENABLE 0x1 316 #define RSA_PM_NSKCLK_ENABLE __BIT1 317 318 //TEMP for secure range <14, Aug> 319 #define REG_RSA_SECRANGE_START(_a_) (REG_RSA_BASE + (0x05 + (_a_)* 2) * 4 ) //0~5 320 #define REG_RSA_SECRANGE_END(_a_) (REG_RSA_BASE + (0x06 + (_a_)* 2) * 4 ) //0~5 321 #define REG_RSA_SECRANGE_SET 0x6 322 #define REG_RSA_SECRANGE_ENABLE 0x00010000 323 #define REG_RSA_SECRANGE_MASK 0x0000FFFF 324 325 #endif //_REGNSK2_H_ 326 327