~funderscore blog cgit wiki get in touch
aboutsummaryrefslogtreecommitdiff
blob: ec0ec9ce1f9fb547a62677c5956b31b456fa984f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* SPDX-License-Identifier: GPL-2.0+ */

#ifndef _NPCM_SHA_H_
#define _NPCM_SHA_H_

#define HASH_DIG_H_NUM        8

/* SHA type */
enum npcm_sha_type {
	npcm_sha_type_sha2 = 0,
	npcm_sha_type_sha1,
	npcm_sha_type_num
};

struct npcm_sha_regs {
	unsigned int hash_data_in;
	unsigned char hash_ctr_sts;
	unsigned char reserved_0[0x03];
	unsigned char hash_cfg;
	unsigned char reserved_1[0x03];
	unsigned char hash_ver;
	unsigned char reserved_2[0x13];
	unsigned int hash_dig[HASH_DIG_H_NUM];
};

#define HASH_CTR_STS_SHA_EN             BIT(0)
#define HASH_CTR_STS_SHA_BUSY           BIT(1)
#define HASH_CTR_STS_SHA_RST            BIT(2)
#define HASH_CFG_SHA1_SHA2              BIT(0)

int npcm_sha_calc(u8 type, const u8 *buf, u32 len, u8 *digest);
int npcm_sha_selftest(u8 type);

#endif