crypto: starfive - Add crypto engine support
[platform/kernel/linux-starfive.git] / drivers / crypto / starfive / jh7110-cryp.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __STARFIVE_STR_H__
3 #define __STARFIVE_STR_H__
4
5 #include <linux/delay.h>
6 #include <linux/dma-mapping.h>
7 #include <linux/dmaengine.h>
8
9 #include <crypto/engine.h>
10
11 #define STARFIVE_ALG_CR_OFFSET                  0x0
12 #define STARFIVE_ALG_FIFO_OFFSET                0x4
13 #define STARFIVE_IE_MASK_OFFSET                 0x8
14 #define STARFIVE_IE_FLAG_OFFSET                 0xc
15 #define STARFIVE_DMA_IN_LEN_OFFSET              0x10
16 #define STARFIVE_DMA_OUT_LEN_OFFSET             0x14
17
18 #define STARFIVE_MSG_BUFFER_SIZE                SZ_16K
19
20 union starfive_alg_cr {
21         u32 v;
22         struct {
23                 u32 start                       :1;
24                 u32 aes_dma_en                  :1;
25                 u32 rsvd_0                      :1;
26                 u32 hash_dma_en                 :1;
27                 u32 alg_done                    :1;
28                 u32 rsvd_1                      :3;
29                 u32 clear                       :1;
30                 u32 rsvd_2                      :23;
31         };
32 };
33
34 struct starfive_cryp_ctx {
35         struct crypto_engine_ctx                enginectx;
36         struct starfive_cryp_dev                *cryp;
37
38         u8                                      *buffer;
39 };
40
41 struct starfive_cryp_dev {
42         struct list_head                        list;
43         struct device                           *dev;
44
45         struct clk                              *hclk;
46         struct clk                              *ahb;
47         struct reset_control                    *rst;
48
49         void __iomem                            *base;
50         phys_addr_t                             phys_base;
51
52         u32                                     dma_maxburst;
53         struct dma_chan                         *tx;
54         struct dma_chan                         *rx;
55         struct dma_slave_config                 cfg_in;
56         struct dma_slave_config                 cfg_out;
57         struct completion                       tx_comp;
58         struct completion                       rx_comp;
59
60         struct crypto_engine                    *engine;
61
62         union starfive_alg_cr                   alg_cr;
63 };
64
65 struct starfive_cryp_dev *starfive_cryp_find_dev(struct starfive_cryp_ctx *ctx);
66
67 #endif