• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 
9 #ifndef HPM_BKEY_H
10 #define HPM_BKEY_H
11 
12 typedef struct {
13     struct {
14         __RW uint32_t DATA[8];                 /* 0x0 - 0x1C: Key data */
15     } KEY[2];
16     __RW uint32_t ECC[2];                      /* 0x40 - 0x44: Key ECC and access control */
17     __RW uint32_t SELECT;                      /* 0x48: Key selection */
18 } BKEY_Type;
19 
20 
21 /* Bitfield definition for register of struct array KEY: 0 */
22 /*
23  * DATA (RW)
24  *
25  * security key data
26  */
27 #define BKEY_DATA_DATA_MASK (0xFFFFFFFFUL)
28 #define BKEY_DATA_DATA_SHIFT (0U)
29 #define BKEY_DATA_DATA_SET(x) (((uint32_t)(x) << BKEY_DATA_DATA_SHIFT) & BKEY_DATA_DATA_MASK)
30 #define BKEY_DATA_DATA_GET(x) (((uint32_t)(x) & BKEY_DATA_DATA_MASK) >> BKEY_DATA_DATA_SHIFT)
31 
32 /* Bitfield definition for register array: ECC */
33 /*
34  * WLOCK (RW)
35  *
36  * write lock to key0
37  * 0: write enable
38  * 1: write ignored
39  */
40 #define BKEY_ECC_WLOCK_MASK (0x80000000UL)
41 #define BKEY_ECC_WLOCK_SHIFT (31U)
42 #define BKEY_ECC_WLOCK_SET(x) (((uint32_t)(x) << BKEY_ECC_WLOCK_SHIFT) & BKEY_ECC_WLOCK_MASK)
43 #define BKEY_ECC_WLOCK_GET(x) (((uint32_t)(x) & BKEY_ECC_WLOCK_MASK) >> BKEY_ECC_WLOCK_SHIFT)
44 
45 /*
46  * RLOCK (RW)
47  *
48  * read lock to key0
49  * 0: key read enable
50  * 1: key always read as 0
51  */
52 #define BKEY_ECC_RLOCK_MASK (0x40000000UL)
53 #define BKEY_ECC_RLOCK_SHIFT (30U)
54 #define BKEY_ECC_RLOCK_SET(x) (((uint32_t)(x) << BKEY_ECC_RLOCK_SHIFT) & BKEY_ECC_RLOCK_MASK)
55 #define BKEY_ECC_RLOCK_GET(x) (((uint32_t)(x) & BKEY_ECC_RLOCK_MASK) >> BKEY_ECC_RLOCK_SHIFT)
56 
57 /*
58  * ECC (RW)
59  *
60  * Parity check bits for key0
61  */
62 #define BKEY_ECC_ECC_MASK (0xFFFFU)
63 #define BKEY_ECC_ECC_SHIFT (0U)
64 #define BKEY_ECC_ECC_SET(x) (((uint32_t)(x) << BKEY_ECC_ECC_SHIFT) & BKEY_ECC_ECC_MASK)
65 #define BKEY_ECC_ECC_GET(x) (((uint32_t)(x) & BKEY_ECC_ECC_MASK) >> BKEY_ECC_ECC_SHIFT)
66 
67 /* Bitfield definition for register: SELECT */
68 /*
69  * SELECT (RW)
70  *
71  * select key, key0 treated as secure key, in non-scure mode, only key1 can be selected
72  * 0: select key0 in secure mode, key1 in non-secure mode
73  * 1: select key1 in secure or nonsecure mode
74  */
75 #define BKEY_SELECT_SELECT_MASK (0x1U)
76 #define BKEY_SELECT_SELECT_SHIFT (0U)
77 #define BKEY_SELECT_SELECT_SET(x) (((uint32_t)(x) << BKEY_SELECT_SELECT_SHIFT) & BKEY_SELECT_SELECT_MASK)
78 #define BKEY_SELECT_SELECT_GET(x) (((uint32_t)(x) & BKEY_SELECT_SELECT_MASK) >> BKEY_SELECT_SELECT_SHIFT)
79 
80 
81 
82 /* DATA register group index macro definition */
83 #define BKEY_KEY_DATA_0 (0UL)
84 #define BKEY_KEY_DATA_1 (1UL)
85 #define BKEY_KEY_DATA_2 (2UL)
86 #define BKEY_KEY_DATA_3 (3UL)
87 #define BKEY_KEY_DATA_4 (4UL)
88 #define BKEY_KEY_DATA_5 (5UL)
89 #define BKEY_KEY_DATA_6 (6UL)
90 #define BKEY_KEY_DATA_7 (7UL)
91 
92 /* KEY register group index macro definition */
93 #define BKEY_KEY_0 (0UL)
94 #define BKEY_KEY_1 (1UL)
95 
96 /* ECC register group index macro definition */
97 #define BKEY_ECC_KEY0 (0UL)
98 #define BKEY_ECC_KEY1 (1UL)
99 
100 
101 #endif /* HPM_BKEY_H */