rk3288_crypto.h (e5451c8f8330e03ad3cfa16048b4daf961af434f) | rk3288_crypto.h (bfd927ffa219ac81082b2dcc61a1c4037869befc) |
---|---|
1#ifndef __RK3288_CRYPTO_H__ 2#define __RK3288_CRYPTO_H__ 3 4#include <crypto/aes.h> 5#include <crypto/des.h> 6#include <crypto/algapi.h> 7#include <linux/interrupt.h> 8#include <linux/delay.h> | 1#ifndef __RK3288_CRYPTO_H__ 2#define __RK3288_CRYPTO_H__ 3 4#include <crypto/aes.h> 5#include <crypto/des.h> 6#include <crypto/algapi.h> 7#include <linux/interrupt.h> 8#include <linux/delay.h> |
9#include <crypto/internal/hash.h> |
|
9 | 10 |
11#include <crypto/md5.h> 12#include <crypto/sha.h> 13 |
|
10#define _SBF(v, f) ((v) << (f)) 11 12/* Crypto control registers*/ 13#define RK_CRYPTO_INTSTS 0x0000 14#define RK_CRYPTO_PKA_DONE_INT BIT(5) 15#define RK_CRYPTO_HASH_DONE_INT BIT(4) 16#define RK_CRYPTO_HRDMA_ERR_INT BIT(3) 17#define RK_CRYPTO_HRDMA_DONE_INT BIT(2) --- 126 unchanged lines hidden (view full) --- 144#define RK_CRYPTO_TDES_IV_1 0x011c 145#define RK_CRYPTO_TDES_KEY1_0 0x0120 146#define RK_CRYPTO_TDES_KEY1_1 0x0124 147#define RK_CRYPTO_TDES_KEY2_0 0x0128 148#define RK_CRYPTO_TDES_KEY2_1 0x012c 149#define RK_CRYPTO_TDES_KEY3_0 0x0130 150#define RK_CRYPTO_TDES_KEY3_1 0x0134 151 | 14#define _SBF(v, f) ((v) << (f)) 15 16/* Crypto control registers*/ 17#define RK_CRYPTO_INTSTS 0x0000 18#define RK_CRYPTO_PKA_DONE_INT BIT(5) 19#define RK_CRYPTO_HASH_DONE_INT BIT(4) 20#define RK_CRYPTO_HRDMA_ERR_INT BIT(3) 21#define RK_CRYPTO_HRDMA_DONE_INT BIT(2) --- 126 unchanged lines hidden (view full) --- 148#define RK_CRYPTO_TDES_IV_1 0x011c 149#define RK_CRYPTO_TDES_KEY1_0 0x0120 150#define RK_CRYPTO_TDES_KEY1_1 0x0124 151#define RK_CRYPTO_TDES_KEY2_0 0x0128 152#define RK_CRYPTO_TDES_KEY2_1 0x012c 153#define RK_CRYPTO_TDES_KEY3_0 0x0130 154#define RK_CRYPTO_TDES_KEY3_1 0x0134 155 |
156/* HASH */ 157#define RK_CRYPTO_HASH_CTRL 0x0180 158#define RK_CRYPTO_HASH_SWAP_DO BIT(3) 159#define RK_CRYPTO_HASH_SWAP_DI BIT(2) 160#define RK_CRYPTO_HASH_SHA1 _SBF(0x00, 0) 161#define RK_CRYPTO_HASH_MD5 _SBF(0x01, 0) 162#define RK_CRYPTO_HASH_SHA256 _SBF(0x02, 0) 163#define RK_CRYPTO_HASH_PRNG _SBF(0x03, 0) 164 165#define RK_CRYPTO_HASH_STS 0x0184 166#define RK_CRYPTO_HASH_DONE BIT(0) 167 168#define RK_CRYPTO_HASH_MSG_LEN 0x0188 169#define RK_CRYPTO_HASH_DOUT_0 0x018c 170#define RK_CRYPTO_HASH_DOUT_1 0x0190 171#define RK_CRYPTO_HASH_DOUT_2 0x0194 172#define RK_CRYPTO_HASH_DOUT_3 0x0198 173#define RK_CRYPTO_HASH_DOUT_4 0x019c 174#define RK_CRYPTO_HASH_DOUT_5 0x01a0 175#define RK_CRYPTO_HASH_DOUT_6 0x01a4 176#define RK_CRYPTO_HASH_DOUT_7 0x01a8 177 |
|
152#define CRYPTO_READ(dev, offset) \ 153 readl_relaxed(((dev)->reg + (offset))) 154#define CRYPTO_WRITE(dev, offset, val) \ 155 writel_relaxed((val), ((dev)->reg + (offset))) 156 157struct rk_crypto_info { 158 struct device *dev; 159 struct clk *aclk; 160 struct clk *hclk; 161 struct clk *sclk; 162 struct clk *dmaclk; 163 struct reset_control *rst; 164 void __iomem *reg; 165 int irq; 166 struct crypto_queue queue; 167 struct tasklet_struct crypto_tasklet; 168 struct ablkcipher_request *ablk_req; | 178#define CRYPTO_READ(dev, offset) \ 179 readl_relaxed(((dev)->reg + (offset))) 180#define CRYPTO_WRITE(dev, offset, val) \ 181 writel_relaxed((val), ((dev)->reg + (offset))) 182 183struct rk_crypto_info { 184 struct device *dev; 185 struct clk *aclk; 186 struct clk *hclk; 187 struct clk *sclk; 188 struct clk *dmaclk; 189 struct reset_control *rst; 190 void __iomem *reg; 191 int irq; 192 struct crypto_queue queue; 193 struct tasklet_struct crypto_tasklet; 194 struct ablkcipher_request *ablk_req; |
195 struct ahash_request *ahash_req; |
|
169 /* device lock */ 170 spinlock_t lock; 171 172 /* the public variable */ 173 struct scatterlist *sg_src; 174 struct scatterlist *sg_dst; 175 struct scatterlist sg_tmp; 176 struct scatterlist *first; --- 13 unchanged lines hidden (view full) --- 190 int (*enable_clk)(struct rk_crypto_info *dev); 191 void (*disable_clk)(struct rk_crypto_info *dev); 192 int (*load_data)(struct rk_crypto_info *dev, 193 struct scatterlist *sg_src, 194 struct scatterlist *sg_dst); 195 void (*unload_data)(struct rk_crypto_info *dev); 196}; 197 | 196 /* device lock */ 197 spinlock_t lock; 198 199 /* the public variable */ 200 struct scatterlist *sg_src; 201 struct scatterlist *sg_dst; 202 struct scatterlist sg_tmp; 203 struct scatterlist *first; --- 13 unchanged lines hidden (view full) --- 217 int (*enable_clk)(struct rk_crypto_info *dev); 218 void (*disable_clk)(struct rk_crypto_info *dev); 219 int (*load_data)(struct rk_crypto_info *dev, 220 struct scatterlist *sg_src, 221 struct scatterlist *sg_dst); 222 void (*unload_data)(struct rk_crypto_info *dev); 223}; 224 |
225/* the private variable of hash */ 226struct rk_ahash_ctx { 227 struct rk_crypto_info *dev; 228 /* for fallback */ 229 struct crypto_ahash *fallback_tfm; 230}; 231 232/* the privete variable of hash for fallback */ 233struct rk_ahash_rctx { 234 struct ahash_request fallback_req; 235}; 236 |
|
198/* the private variable of cipher */ 199struct rk_cipher_ctx { 200 struct rk_crypto_info *dev; 201 unsigned int keylen; 202}; 203 | 237/* the private variable of cipher */ 238struct rk_cipher_ctx { 239 struct rk_crypto_info *dev; 240 unsigned int keylen; 241}; 242 |
243enum alg_type { 244 ALG_TYPE_HASH, 245 ALG_TYPE_CIPHER, 246}; 247 |
|
204struct rk_crypto_tmp { | 248struct rk_crypto_tmp { |
205 struct rk_crypto_info *dev; 206 struct crypto_alg alg; | 249 struct rk_crypto_info *dev; 250 union { 251 struct crypto_alg crypto; 252 struct ahash_alg hash; 253 } alg; 254 enum alg_type type; |
207}; 208 209extern struct rk_crypto_tmp rk_ecb_aes_alg; 210extern struct rk_crypto_tmp rk_cbc_aes_alg; 211extern struct rk_crypto_tmp rk_ecb_des_alg; 212extern struct rk_crypto_tmp rk_cbc_des_alg; 213extern struct rk_crypto_tmp rk_ecb_des3_ede_alg; 214extern struct rk_crypto_tmp rk_cbc_des3_ede_alg; 215 | 255}; 256 257extern struct rk_crypto_tmp rk_ecb_aes_alg; 258extern struct rk_crypto_tmp rk_cbc_aes_alg; 259extern struct rk_crypto_tmp rk_ecb_des_alg; 260extern struct rk_crypto_tmp rk_cbc_des_alg; 261extern struct rk_crypto_tmp rk_ecb_des3_ede_alg; 262extern struct rk_crypto_tmp rk_cbc_des3_ede_alg; 263 |
264extern struct rk_crypto_tmp rk_ahash_sha1; 265extern struct rk_crypto_tmp rk_ahash_sha256; 266extern struct rk_crypto_tmp rk_ahash_md5; 267 |
|
216#endif | 268#endif |