Jim Liu | ca0be9e | 2023-01-17 16:59:23 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | |
| 3 | #ifndef _NPCM_SHA_H_ |
| 4 | #define _NPCM_SHA_H_ |
| 5 | |
| 6 | #define HASH_DIG_H_NUM 8 |
| 7 | |
| 8 | /* SHA type */ |
| 9 | enum npcm_sha_type { |
| 10 | npcm_sha_type_sha2 = 0, |
| 11 | npcm_sha_type_sha1, |
| 12 | npcm_sha_type_num |
| 13 | }; |
| 14 | |
| 15 | struct npcm_sha_regs { |
| 16 | unsigned int hash_data_in; |
| 17 | unsigned char hash_ctr_sts; |
| 18 | unsigned char reserved_0[0x03]; |
| 19 | unsigned char hash_cfg; |
| 20 | unsigned char reserved_1[0x03]; |
| 21 | unsigned char hash_ver; |
| 22 | unsigned char reserved_2[0x13]; |
| 23 | unsigned int hash_dig[HASH_DIG_H_NUM]; |
| 24 | }; |
| 25 | |
| 26 | #define HASH_CTR_STS_SHA_EN BIT(0) |
| 27 | #define HASH_CTR_STS_SHA_BUSY BIT(1) |
| 28 | #define HASH_CTR_STS_SHA_RST BIT(2) |
| 29 | #define HASH_CFG_SHA1_SHA2 BIT(0) |
| 30 | |
| 31 | int npcm_sha_calc(u8 type, const u8 *buf, u32 len, u8 *digest); |
| 32 | int npcm_sha_selftest(u8 type); |
| 33 | |
| 34 | #endif |