xref: /utopia/UTPA2-700.0.x/modules/dscmb/hal/k6/nsk2/regNSK2.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
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_MPROT_BASE          (0x1A1D00<<1)
141 
142 #define REG_KEY_TABLE_BASE      (0x1A0C00<<1)
143 #define REG_JTAG_PWD_BASE       (0x170300<<1)	//check!!
144 #define REG_CIPHER_CH0_BASE     (0x1A0700<<1)
145 
146 #define REG_CRYPTO_DMA_BASE     (0x1A0B00<<1)	//x32_CryptoDMA0
147 
148 
149 #define REG_NSK2_ACPU_CMD       0xFC00
150     #define NSK2_ACPU_CMD           0xFF
151 
152 #define REG_NSK2_ACPU_WARNING   0xFC04
153     #define NSK2_ACPU_BUSY          __BIT31
154 
155 #define REG_NSK2_ACPU_INT       0xFC08
156     #define NSK2_INT_CMD_EXIT           __BIT0
157     #define NSK2_INT_ASYNC_EVENT        __BIT1
158     #define NSK2_INT_ILLEGAL_CMD        __BIT2
159     #define NSK2_INT_ILLEGAL_ACCESS     __BIT3
160     #define NSK2_INT_RESET              __BIT4
161     #define NSK2_INT_HANG               __BIT5
162     #define NSK2_INT_KTE_VALID          __BIT6
163     #define NSK2_INT_MASK_CLEAR         __BIT31
164 
165 
166 #define REG_NSK2_ACPU_CTRL_BLOCK    0xFC0C
167 
168 
169 #define REG_NSK2_ACPU_ERROR     0xFC10
170 
171 #define REG_NSK2_KTE_SWITCH_1   0xFC40
172 #define REG_NSK2_KTE_SWITCH_2   0xFC44
173 #define REG_NSK2_KTE_SWITCH_3   0xFC48
174 
175 #define REG_NSK2_KTE_VALID      0xFC4C
176     #define NSK2_KTE_VALID_TRUE         __BIT0
177 
178 #define REG_NSK2_GENOUT_LOW     0xFC50
179 
180 #define REG_NSK2_VEN_VERSION    0xFC70
181 
182 #define REG_NSK2_GENOUT_HIGH    0xFDFC
183 
184 
185 #define REG_NI_NSK2_CTRL                0x0
186     #define NI_TS2NSK_ENABLE                0x1
187     #define NI_TS2NSK_RATE                  BMASK(3:1)
188     #define NI_TEST_RC_FREQ_MAP             BMASK(7:4)
189     #define NI_N2ROM_PD                     __BIT8
190     #define NI_NO_RST_DELAY                 __BITD
191     #define NI_NSK2_CLK_ENABLE              __BITE
192     #define NI_NSK2_RESET_DISABLE           __BITF
193 
194 #define REG_NI_NSK2_FREERUN             0x1
195     #define NI_NSK2_FREERUN_ENABLE          __BIT2
196     #define NI_NSK2_RANDOM_FREERUN          __BIT4
197     #define NI_NSK2_RANDOM_ONEBYONE         __BIT5
198 
199 #define REG_NI_SW_SET_RNG               0x5
200     #define NI_SW_RNG_MASK                  BMASK(15:0)
201 
202 #define REG_NI_COMMAND                  0x6
203     #define NI_COMMAND_START                0x1
204 
205     #define NI_KIW_OID_MASK                 BMASK(3:3)
206     #define NI_KIW_OID_SHIFT                3
207 
208     #define NI_KIW_CMD_MASK                 BMASK(15:8)
209     #define NI_KIW_CMD_SHIFT                8
210     #define NI_NopNop                       0x0
211 
212     #define NI_OTP_ACK_NSK2                 (1<<1)
213     #define NI_ERR_INVALID_SLOT             (1<<2)
214     #define NI_NSKBIComplete                (1<<NI_KIW_CMD_SHIFT)
215     #define NI_DriveAck                     (2<<NI_KIW_CMD_SHIFT)
216     #define NI_InvalidateCmChannel          (4<<NI_KIW_CMD_SHIFT)
217     #define NI_InvalidateM2M                (5<<NI_KIW_CMD_SHIFT)
218     #define NI_ConfigureCmChannel           (6<<NI_KIW_CMD_SHIFT)
219     #define NI_WriteTransportKey            (8<<NI_KIW_CMD_SHIFT)
220     #define NI_WriteM2MKey                  (9<<NI_KIW_CMD_SHIFT)
221     #define NI_WriteMDEMKey                 (10<<NI_KIW_CMD_SHIFT)
222     #define NI_WriteJTAGKey                 (12<<NI_KIW_CMD_SHIFT)
223     #define NI_WriteSCPUKey                 (13<<NI_KIW_CMD_SHIFT)
224     #define NI_WriteReservedKey             (14<<NI_KIW_CMD_SHIFT)
225     #define NI_WriteRandomValue             (15<<NI_KIW_CMD_SHIFT)
226     #define NI_WriteOTPKey                  (16<<NI_KIW_CMD_SHIFT)
227     #define NI_IncrementNvCounter           (17<<NI_KIW_CMD_SHIFT)
228 
229 
230     #define NI_KIW_PidNo_MASK               BMASK(23:16)
231     #define NI_WriteTKey_PidNo_Shift        16
232     #define NI_WriteTransportKey_PidNo      BMASK(23:16)
233     #define NI_WriteTKey_SCB_Shift          24
234     #define NI_WriteTKey_SCB_MASK           BMASK(25:24)
235     #define NI_WriteTKey_FSCB_Shift         26
236     #define NI_WriteTKey_FSCB_MASK          BMASK(27:26)
237 
238     #define NI_WriteESA                     0x2
239     #define NI_JTAG_PasswordWriteSCPUKey    0x8
240     #define NI_CearWKResp                   0xC
241 
242 
243 #define REG_NI_DSCMB_ALGO               0x7
244 
245     #define NI_KIW_LSAD_ALGO_MASK           BMASK(4:0)
246     #define NI_KIW_ESA_ALGO_SHIFT           8
247     #define NI_KIW_ESA_ALGO_MASK            BMASK(12:8)
248     #define NI_KIW_LSAS_ALGO_SHIFT          16
249     #define NI_KIW_LSAS_ALGO_MASK           BMASK(20:16)
250 
251     #define NI_WriteESA_PidNo               BMASK(7:0)
252     #define NI_WriteESA_ESASubSel_Shift     16
253     #define NI_WriteESA_ESASubSel_MASK      BMASK(18:16)
254     #define NI_WriteESA_ESASel_Shift        19
255     #define NI_WriteESA_ESASel_MASK         BMASK(22:19)
256 
257     #define NI_WriteM2MKey_Shift            16
258     #define NI_WriteM2MKey_MASK             BMASK(19:16)
259 
260 #define REG_NI_IV_31_00                 0x8
261 #define REG_NI_IV_63_31                 0x9
262 #define REG_NI_IV_95_64                 0xA
263 #define REG_NI_IV_127_96                0xB
264 
265 #define REG_NI_STATUS                   0xC
266     #define NI_NSK_BUSY                     __BIT0
267     #define NI_SKB_BUSY                     __BIT1
268     #define NI_AIW_BUSY                     __BIT2
269     #define NI_KIW_BUSY                     __BIT3
270 
271 #define REG_NI_KTE_STATUS               0xD
272     #define NI_KTE_DEST_MASK                BMASK(2:0)
273     #define NI_KTE_VALID                    __BIT3
274     #define NI_NSK2_FREQ_OKAY               __BIT4
275     #define NI_SLOW_CLOCK_DETECT            __BIT5
276     #define NI_CLOCK_HALT_DETECT            __BIT6
277 
278 #define REG_NI_COMPARE_GENOUT_L         0x17
279     #define NSK2_IS_BUSY                    __BIT(21)
280     #define NSK2_KTE_DEST                   BMASK(20:17)
281     #define NSK2_CON_CUR                    __BIT(16)
282     #define NSK2_CSA2VAR_EN                 __BIT(15)
283     #define NSK2_CSA3VAR_EN                 __BIT(14)
284     #define NSK2_CPNR                       __BIT(1)   //Content Protection Not Required
285     #define NSK2_OTPPWD                     __BIT(0)   //OTP Program Password Accepted
286 
287 #define REG_NI_COMPARE_GENOUT_H         0x18
288     #define NI_GENOUT_H_MASK                BMASK(5:0)
289 
290 #define REG_NI_NSK2_TRNG_VALID          0x19
291     #define NI_NSK2_TRNG_VALID_MASK         BMASK(0:0)
292 
293 #define REG_NI_NSK2_PWD_ON              0x1B
294     #define N2_JTAGPWD0_ON                  __BIT(0)
295     #define N2_JTAGPWD1_ON                  __BIT(1)
296     #define N2_SCANPWD_ON                   __BIT(2)
297     #define N2_MBISTPWD_ON                  __BIT(3)
298     #define N2_M2MKEY_ON                    __BIT(4)
299     #define N2_SCPUKEY0_ON                  __BIT(5)
300     #define N2_SCPUKEY1_ON                  __BIT(6)
301     #define N2_RNGVALUE0_ON                 __BIT(8)
302     #define N2_RNGVALUE1_ON                 __BIT(9)
303 
304 
305 #define REG_NI_NSK2_TRNG_DATA           0x1A
306 
307 #define REG_NI_NSK2_KTE_RESP            0x1C
308 
309 
310 #define REG_NI_NSK2_CLK_CSA             0x24
311     #define NSK2_PUSH_SLOW_CLK               __BIT(0)
312     #define NSK2_EN_CSA_VAR                  __BIT(4)
313 
314 #define REG_KT_KEYS_START_FPGA          0x28
315 #define REG_KT_KEYS_END_FPGA            0x36
316 
317 
318 #define REG_NI_NSK2_KTE_VALID_FPGA      0x37
319     #define NI_NSK2_KTE_VALID_FPGA          __BIT0
320 
321 #define REG_NI_NSK21_GENIN              0x40
322 
323 #define REG_NI_NSK21_CONCURR_PROT_EN    0x41
324 
325 #define REG_NI_NSK21_CONCURR_SET        0x42
326 
327 #define REG_NI_NSK21_GEN_SHOT           0x43
328 
329 #define REG_NI_NSK2_REG_GENIN           0x44
330 
331 #define REG_NI_NSK21_GET_NVCOUNTER      0x78
332 
333 #define REG_RSA_CLK_ENABLE              0x1
334     #define RSA_PM_NSKCLK_ENABLE            __BIT1
335 
336 	//TEMP for secure range <14, Aug>
337 #define REG_MPROT_SECRANGE_START(_a_)	(REG_MPROT_BASE + ((_a_ * 2) + 0x0) * 4 ) //0~5
338 #define REG_MPROT_SECRANGE_END(_a_)		(REG_MPROT_BASE + ((_a_ * 2) + 0x1) * 4 ) //0~5
339 #define REG_MPROT_SECRANGE_SET			0x6
340 #define REG_MPROT_SECRANGE_ENABLE       0xFFFEFFFF
341     #define MPROT_SECRANGE_MASK			0x0000FFFF
342 #define REG_MPROT_SECRANGE_MASK		    (REG_MPROT_BASE + (0x10 << 2))
343 
344 #endif //_REGNSK2_H_
345 
346