jh7110-cryp.h (42ef0e944b0119e9987819af0a5a04d32d5e5edf) | jh7110-cryp.h (7883d1b28a2b0e62edcacea22de6b36a1918b15a) |
---|---|
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> | 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#include <crypto/sha2.h> 11#include <crypto/sm3.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 | 12 13#define STARFIVE_ALG_CR_OFFSET 0x0 14#define STARFIVE_ALG_FIFO_OFFSET 0x4 15#define STARFIVE_IE_MASK_OFFSET 0x8 16#define STARFIVE_IE_FLAG_OFFSET 0xc 17#define STARFIVE_DMA_IN_LEN_OFFSET 0x10 18#define STARFIVE_DMA_OUT_LEN_OFFSET 0x14 19 |
20#define STARFIVE_IE_MASK_HASH_DONE 0x4 21#define STARFIVE_IE_FLAG_HASH_DONE 0x4 22 |
|
18#define STARFIVE_MSG_BUFFER_SIZE SZ_16K | 23#define STARFIVE_MSG_BUFFER_SIZE SZ_16K |
24#define MAX_KEY_SIZE SHA512_BLOCK_SIZE |
|
19 | 25 |
26union starfive_hash_csr { 27 u32 v; 28 struct { 29 u32 start :1; 30 u32 reset :1; 31 u32 ie :1; 32 u32 firstb :1; 33#define STARFIVE_HASH_SM3 0x0 34#define STARFIVE_HASH_SHA224 0x3 35#define STARFIVE_HASH_SHA256 0x4 36#define STARFIVE_HASH_SHA384 0x5 37#define STARFIVE_HASH_SHA512 0x6 38#define STARFIVE_HASH_MODE_MASK 0x7 39 u32 mode :3; 40 u32 rsvd_1 :1; 41 u32 final :1; 42 u32 rsvd_2 :2; 43#define STARFIVE_HASH_HMAC_FLAGS 0x800 44 u32 hmac :1; 45 u32 rsvd_3 :1; 46#define STARFIVE_HASH_KEY_DONE BIT(13) 47 u32 key_done :1; 48 u32 key_flag :1; 49 u32 hmac_done :1; 50#define STARFIVE_HASH_BUSY BIT(16) 51 u32 busy :1; 52 u32 hashdone :1; 53 u32 rsvd_4 :14; 54 }; 55}; 56 57 |
|
20union 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 34struct starfive_cryp_ctx { 35 struct crypto_engine_ctx enginectx; 36 struct starfive_cryp_dev *cryp; | 58union starfive_alg_cr { 59 u32 v; 60 struct { 61 u32 start :1; 62 u32 aes_dma_en :1; 63 u32 rsvd_0 :1; 64 u32 hash_dma_en :1; 65 u32 alg_done :1; 66 u32 rsvd_1 :3; 67 u32 clear :1; 68 u32 rsvd_2 :23; 69 }; 70}; 71 72struct starfive_cryp_ctx { 73 struct crypto_engine_ctx enginectx; 74 struct starfive_cryp_dev *cryp; |
75 struct starfive_cryp_request_ctx *rctx; 76 77 unsigned int hash_mode; 78 u8 key[MAX_KEY_SIZE]; 79 int keylen; 80 bool is_hmac; 81 struct crypto_ahash *ahash_fbk; |
|
37}; 38 39struct starfive_cryp_dev { 40 struct list_head list; 41 struct device *dev; | 82}; 83 84struct starfive_cryp_dev { 85 struct list_head list; 86 struct device *dev; |
42 | |
43 struct clk *hclk; 44 struct clk *ahb; 45 struct reset_control *rst; 46 47 void __iomem *base; 48 phys_addr_t phys_base; 49 50 u32 dma_maxburst; 51 struct dma_chan *tx; 52 struct dma_chan *rx; 53 struct dma_slave_config cfg_in; 54 struct dma_slave_config cfg_out; | 87 struct clk *hclk; 88 struct clk *ahb; 89 struct reset_control *rst; 90 91 void __iomem *base; 92 phys_addr_t phys_base; 93 94 u32 dma_maxburst; 95 struct dma_chan *tx; 96 struct dma_chan *rx; 97 struct dma_slave_config cfg_in; 98 struct dma_slave_config cfg_out; |
55 | |
56 struct crypto_engine *engine; | 99 struct crypto_engine *engine; |
57 | 100 struct tasklet_struct hash_done; 101 int err; |
58 union starfive_alg_cr alg_cr; | 102 union starfive_alg_cr alg_cr; |
103 union { 104 struct ahash_request *hreq; 105 } req; |
|
59}; 60 | 106}; 107 |
108struct starfive_cryp_request_ctx { 109 union { 110 union starfive_hash_csr hash; 111 } csr; 112 113 struct scatterlist *in_sg; 114 struct ahash_request ahash_fbk_req; 115 size_t total; 116 unsigned int blksize; 117 unsigned int digsize; 118 unsigned long in_sg_len; 119}; 120 |
|
61struct starfive_cryp_dev *starfive_cryp_find_dev(struct starfive_cryp_ctx *ctx); 62 | 121struct starfive_cryp_dev *starfive_cryp_find_dev(struct starfive_cryp_ctx *ctx); 122 |
123int starfive_hash_register_algs(void); 124void starfive_hash_unregister_algs(void); 125 126void starfive_hash_done_task(unsigned long param); |
|
63#endif | 127#endif |