jh7110-cryp.h (7883d1b28a2b0e62edcacea22de6b36a1918b15a) | jh7110-cryp.h (445a4aaf5842073e4130b1d6dbe3785284d9615f) |
---|---|
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 --- 4 unchanged lines hidden (view full) --- 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 | 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 --- 4 unchanged lines hidden (view full) --- 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_MASK_PKA_DONE 0x8 |
|
21#define STARFIVE_IE_FLAG_HASH_DONE 0x4 | 22#define STARFIVE_IE_FLAG_HASH_DONE 0x4 |
23#define STARFIVE_IE_FLAG_PKA_DONE 0x8 |
|
22 23#define STARFIVE_MSG_BUFFER_SIZE SZ_16K 24#define MAX_KEY_SIZE SHA512_BLOCK_SIZE 25 26union starfive_hash_csr { 27 u32 v; 28 struct { 29 u32 start :1; --- 19 unchanged lines hidden (view full) --- 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 | 24 25#define STARFIVE_MSG_BUFFER_SIZE SZ_16K 26#define MAX_KEY_SIZE SHA512_BLOCK_SIZE 27 28union starfive_hash_csr { 29 u32 v; 30 struct { 31 u32 start :1; --- 19 unchanged lines hidden (view full) --- 51 u32 hmac_done :1; 52#define STARFIVE_HASH_BUSY BIT(16) 53 u32 busy :1; 54 u32 hashdone :1; 55 u32 rsvd_4 :14; 56 }; 57}; 58 |
59union starfive_pka_cacr { 60 u32 v; 61 struct { 62 u32 start :1; 63 u32 reset :1; 64 u32 ie :1; 65 u32 rsvd_0 :1; 66 u32 fifo_mode :1; 67 u32 not_r2 :1; 68 u32 ecc_sub :1; 69 u32 pre_expf :1; 70 u32 cmd :4; 71 u32 rsvd_1 :1; 72 u32 ctrl_dummy :1; 73 u32 ctrl_false :1; 74 u32 cln_done :1; 75 u32 opsize :6; 76 u32 rsvd_2 :2; 77 u32 exposize :6; 78 u32 rsvd_3 :1; 79 u32 bigendian :1; 80 }; 81}; |
|
57 | 82 |
83struct starfive_rsa_key { 84 u8 *n; 85 u8 *e; 86 u8 *d; 87 int e_bitlen; 88 int d_bitlen; 89 int bitlen; 90 size_t key_sz; 91}; 92 |
|
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; --- 7 unchanged lines hidden (view full) --- 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; | 93union starfive_alg_cr { 94 u32 v; 95 struct { 96 u32 start :1; 97 u32 aes_dma_en :1; 98 u32 rsvd_0 :1; 99 u32 hash_dma_en :1; 100 u32 alg_done :1; --- 7 unchanged lines hidden (view full) --- 108 struct crypto_engine_ctx enginectx; 109 struct starfive_cryp_dev *cryp; 110 struct starfive_cryp_request_ctx *rctx; 111 112 unsigned int hash_mode; 113 u8 key[MAX_KEY_SIZE]; 114 int keylen; 115 bool is_hmac; |
116 struct starfive_rsa_key rsa_key; 117 struct crypto_akcipher *akcipher_fbk; |
|
81 struct crypto_ahash *ahash_fbk; 82}; 83 84struct starfive_cryp_dev { 85 struct list_head list; 86 struct device *dev; 87 struct clk *hclk; 88 struct clk *ahb; --- 4 unchanged lines hidden (view full) --- 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; 99 struct crypto_engine *engine; 100 struct tasklet_struct hash_done; | 118 struct crypto_ahash *ahash_fbk; 119}; 120 121struct starfive_cryp_dev { 122 struct list_head list; 123 struct device *dev; 124 struct clk *hclk; 125 struct clk *ahb; --- 4 unchanged lines hidden (view full) --- 130 131 u32 dma_maxburst; 132 struct dma_chan *tx; 133 struct dma_chan *rx; 134 struct dma_slave_config cfg_in; 135 struct dma_slave_config cfg_out; 136 struct crypto_engine *engine; 137 struct tasklet_struct hash_done; |
138 struct completion pka_done; |
|
101 int err; 102 union starfive_alg_cr alg_cr; 103 union { 104 struct ahash_request *hreq; 105 } req; 106}; 107 108struct starfive_cryp_request_ctx { 109 union { 110 union starfive_hash_csr hash; | 139 int err; 140 union starfive_alg_cr alg_cr; 141 union { 142 struct ahash_request *hreq; 143 } req; 144}; 145 146struct starfive_cryp_request_ctx { 147 union { 148 union starfive_hash_csr hash; |
149 union starfive_pka_cacr pka; |
|
111 } csr; 112 113 struct scatterlist *in_sg; | 150 } csr; 151 152 struct scatterlist *in_sg; |
153 struct scatterlist *out_sg; |
|
114 struct ahash_request ahash_fbk_req; 115 size_t total; | 154 struct ahash_request ahash_fbk_req; 155 size_t total; |
156 size_t nents; |
|
116 unsigned int blksize; 117 unsigned int digsize; 118 unsigned long in_sg_len; | 157 unsigned int blksize; 158 unsigned int digsize; 159 unsigned long in_sg_len; |
160 u8 rsa_data[] __aligned(sizeof(u32)); |
|
119}; 120 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 | 161}; 162 163struct starfive_cryp_dev *starfive_cryp_find_dev(struct starfive_cryp_ctx *ctx); 164 165int starfive_hash_register_algs(void); 166void starfive_hash_unregister_algs(void); 167 |
168int starfive_rsa_register_algs(void); 169void starfive_rsa_unregister_algs(void); 170 |
|
126void starfive_hash_done_task(unsigned long param); 127#endif | 171void starfive_hash_done_task(unsigned long param); 172#endif |