blob: 74cfce6fd599f7f65e2b48a342ce72abb8006f9e [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#ifndef _ASR_RNG_H_
2#define _ASR_RNG_H_
3
4#include <crypto/aes.h>
5#include <linux/crypto.h>
6#include <crypto/algapi.h>
7#include <linux/interrupt.h>
8#include <linux/mutex.h>
9#include <linux/miscdevice.h>
10
11#define RNG_SYTE_CNT (0x04)
12#define RNG_SRC_ADDR (0x14)
13#define RNG_DEST_ADDR (0x24)
14#define RNG_NEXTDEST_ADDR (0x34)
15#define RNG_SQU_CTRL (0x44)
16#define RNG_CURR_DESC_PTR (0x74)
17#define RNG_INT_MASK (0x84)
18#define RNG_INT_STATUS (0xa4)
19#define RNG_CTRL (0xc0)
20#define RNG_DATA (0xc4)
21#define RNG_SEED_VAL (0xc8)
22
23#define SQU_CTRL_FIFO_CLR (1 << 30)
24#define CTRL_RNG_VALID (1 << 31)
25#define CTRL_RNG_SEED_VALID (1 << 30)
26#define CTRL_RNG_SEED_EN (1 << 1)
27#define CTRL_RNG_EN (1 << 0)
28
29struct asr_rng {
30 struct device *dev;
31 unsigned long phys_base;
32 void __iomem *io_base;
33 void __iomem *seed_base;
34 struct hwrng *hwrng;
35 unsigned int rn_saved;
36
37 struct mutex rng_lock;
38 struct clk *rng_clk;
39 int clk_synced;
40 refcount_t refcount;
41
42 struct asr_rng_ops *rng_ops;
43};
44
45struct asr_rng_ops {
46 int (*dev_get)(struct asr_rng *);
47 int (*dev_put)(struct asr_rng *);
48};
49
50#endif