xref: /OK3568_Linux_fs/u-boot/include/rockchip/crypto_v1.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier:     GPL-2.0+ */
2 /*
3  * (C) Copyright 2019 Rockchip Electronics Co., Ltd
4  */
5 
6 #ifndef _ROCKCHIP_CRYPTO_V1_H_
7 #define _ROCKCHIP_CRYPTO_V1_H_
8 
9 struct rk_crypto_reg {
10 	u32 crypto_intsts;
11 	u32 crypto_intena;
12 	u32 crypto_ctrl;
13 	u32 crypto_conf;
14 	u32 crypto_brdmas;
15 	u32 crypto_btdmas;
16 	u32 crypto_brdmal;
17 	u32 crypto_hrdmas;
18 	u32 crypto_hrdmal;
19 	u32 reserved0[(0x80 - 0x24) / 4];
20 
21 	u32 crypto_aes_ctrl;
22 	u32 crypto_aes_sts;
23 	u32 crypto_aes_din[4];
24 	u32 crypto_aes_dout[4];
25 	u32 crypto_aes_iv[4];
26 	u32 crypto_aes_key[8];
27 	u32 crypto_aes_cnt[4];
28 	u32 reserved1[(0x100 - 0xe8) / 4];
29 
30 	u32 crypto_tdes_ctrl;
31 	u32 crypto_tdes_sts;
32 	u32 crypto_tdes_din[2];
33 	u32 crypto_tdes_dout[2];
34 	u32 crypto_tdes_iv[2];
35 	u32 crypto_tdes_key1[2];
36 	u32 crypto_tdes_key2[2];
37 	u32 crypto_tdes_key3[2];
38 	u32 reserved2[(0x180 - 0x138) / 4];
39 
40 	u32 crypto_hash_ctrl;
41 	u32 crypto_hash_sts;
42 	u32 crypto_hash_msg_len;
43 	u32 crypto_hash_dout[8];
44 	u32 crypto_hash_seed[5];
45 	u32 reserved3[(0x200 - 0x1c0) / 4];
46 
47 	u32 crypto_trng_ctrl;
48 	u32 crypto_trng_dout[8];
49 	u32 reserved4[(0x280 - 0x224) / 4];
50 
51 	u32 crypto_pka_ctrl;
52 	u32 reserved5[(0x400 - 0x284) / 4];
53 
54 	u32 crypto_pka_m[(0x500 - 0x400) / 4];
55 	u32 crypto_pka_c[(0x600 - 0x500) / 4];
56 	u32 crypto_pka_n[(0x700 - 0x600) / 4];
57 	u32 crypto_pka_e;
58 };
59 
60 check_member(rk_crypto_reg, crypto_pka_e, 0x700);
61 
62 /************************ Register bits definition ****************************/
63 /* CRYPTO_HASH_CTRL */
64 #define ENGINE_SELECTION_SHA1		0x0
65 #define ENGINE_SELECTION_MD5		0x1
66 #define ENGINE_SELECTION_SHA256		0x2
67 #define HASH_SWAP_DO			0x8
68 
69 /* CRYPTO_CONF */
70 #define HR_ADDR_MODE			BIT(8)
71 #define BT_ADDR_MODE			BIT(7)
72 #define BR_ADDR_MODE			BIT(6)
73 #define BYTESWAP_HRFIFO			BIT(5)
74 #define BYTESWAP_BTFIFO			BIT(4)
75 #define BYTESWAP_BRFIFO			BIT(3)
76 #define DESSEL				BIT(2)
77 
78 /* CRYPTO_CTRL */
79 #define TRNG_FLUSH			BIT(9)
80 #define TRNG_START			BIT(8)
81 #define PKA_FLUSH			BIT(7)
82 #define HASH_FLUSH			BIT(6)
83 #define BLOCK_FLUSH			BIT(5)
84 #define PKA_START			BIT(4)
85 #define HASH_START			BIT(3)
86 #define BLOCK_START			BIT(2)
87 #define TDES_START			BIT(1)
88 #define AES_START			BIT(0)
89 #define PKA_HASH_CTRL			(PKA_FLUSH | HASH_FLUSH)
90 #define PKA_CTRL			(PKA_FLUSH | PKA_START)
91 
92 /* CRYPTO_INTSTS */
93 #define PKA_DONE_INT			BIT(5)
94 #define HASH_DONE_INT			BIT(4)
95 #define HRDMA_ERR_INT			BIT(3)
96 #define HRDMA_DONE_INT			BIT(2)
97 #define BCDMA_ERR_INT			BIT(1)
98 #define BCDMA_DONE_INT			BIT(0)
99 
100 /* CRYPTO_PKA_CTRL */
101 #define PKA_BLOCK_SIZE_512		0
102 #define PKA_BLOCK_SIZE_1024		1
103 #define PKA_BLOCK_SIZE_2048		2
104 
105 #endif
106