blob: ec0ec9ce1f9fb547a62677c5956b31b456fa984f [file] [log] [blame]
Jim Liuca0be9e2023-01-17 16:59:23 +08001/* 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 */
9enum npcm_sha_type {
10 npcm_sha_type_sha2 = 0,
11 npcm_sha_type_sha1,
12 npcm_sha_type_num
13};
14
15struct 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
31int npcm_sha_calc(u8 type, const u8 *buf, u32 len, u8 *digest);
32int npcm_sha_selftest(u8 type);
33
34#endif