ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/marvell/linux/drivers/crypto/asr/bcm/asr-cipher.h b/marvell/linux/drivers/crypto/asr/bcm/asr-cipher.h
new file mode 100644
index 0000000..3902cf3
--- /dev/null
+++ b/marvell/linux/drivers/crypto/asr/bcm/asr-cipher.h
@@ -0,0 +1,135 @@
+#ifndef ASR_CIPHER_H
+#define ASR_CIPHER_H
+
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/crypto.h>
+#include <crypto/aes.h>
+#include <crypto/scatterwalk.h>
+#include <crypto/algapi.h>
+#include <crypto/internal/skcipher.h>
+
+/* CIHER flags */
+#define FLAGS_ENCRYPT (1 << 0)
+#define FLAGS_ECB (0 << 1)
+#define FLAGS_CBC (1 << 1)
+#define FLAGS_CTR (2 << 1)
+#define FLAGS_OPMODE_MASK (3 << 1)
+#define FLAGS_BUSY (1 << 3)
+#define FLAGS_AES (0 << 4)
+#define FLAGS_SM4 (1 << 4)
+
+#define CIPHER_FLAGS_PERSISTENT FLAGS_BUSY
+
+#define BYTES_TO_BITS 8
+#define WORK_BUF_SIZE 2048
+
+#define ASR_CIPHER_QUEUE_LENGTH 50
+#define ASR_CIPHER_PRIORITY 300
+
+#define ASR_CIPHER_BUFFER_ORDER 2
+#define ASR_CIPHER_BUFFER_SIZE (PAGE_SIZE << ASR_CIPHER_BUFFER_ORDER)
+
+typedef enum {
+ EXT_KEY = 0,
+ RK_KEY,
+ SSK_KEY,
+} AES_KEY_SELECT_T;
+
+typedef enum {
+ AES_128 = 128/8,
+ AES_192 = 192/8,
+ AES_256 = 256/8,
+} AES_KEY_LEN_T;
+
+typedef enum {
+ AES_ECB_ALG = 0,
+ AES_CBC_ALG,
+ AES_CTR_ALG,
+ AES_XTS_ALG,
+ AES_KEYWRAP,
+} AES_MODE_T;
+
+typedef enum {
+ AES_DECRYPT_OP = 0,
+ AES_ENCRYPT_OP,
+} AES_OP_MODE_T;
+
+typedef enum {
+ ENG_AES = 0,
+ ENG_DES,
+ ENG_RC4,
+} CRYPTO_ENG_SEL_T;
+
+typedef struct {
+ uint32_t paddr;
+ uint32_t size;
+ uint32_t next_desc;
+ uint32_t reserved;
+} DMA_DESC_T;
+
+struct rijndael_key {
+ uint8_t K[(60 + 60 + 4) * sizeof(uint32_t)];
+ uint32_t *eK;
+ uint32_t *dK;
+ int Nr;
+};
+
+typedef union Symmetric_key {
+ struct rijndael_key rijndael;
+} symmetric_key;
+
+struct asr_bcm_cipher;
+
+typedef int (*asr_cipher_fn_t)(struct asr_bcm_cipher *dd);
+typedef irqreturn_t (*asr_cipher_irq_t)(void *);
+
+
+struct asr_cipher_ctx {
+ struct asr_bcm_cipher *dd;
+ asr_cipher_fn_t start;
+ int keylen;
+ u32 key[AES_KEYSIZE_256 / sizeof(u32)];
+ u16 block_size;
+ bool use_rkek;
+};
+
+struct asr_cipher_reqctx {
+ unsigned long mode;
+ bool use_rkek;
+ u32 lastc[AES_BLOCK_SIZE / sizeof(u32)];
+};
+
+struct asr_bcm_cipher {
+ struct device *dev;
+ struct crypto_async_request *areq;
+
+ void __iomem *io_base;
+ unsigned long phys_base;
+
+ struct asr_cipher_ctx *ctx;
+
+ bool is_async;
+ bool rkek_burned;
+ unsigned long flags;
+
+ spinlock_t lock;
+ struct mutex cipher_lock;
+ struct crypto_queue queue;
+ struct tasklet_struct queue_task;
+
+ asr_cipher_fn_t resume;
+ struct tasklet_struct done_task;
+
+ size_t total;
+ size_t datalen;
+ u32 *data;
+
+ size_t buflen;
+ void *buf;
+
+ struct scatterlist aligned_sg;
+ struct scatterlist *real_dst;
+};
+
+#endif
\ No newline at end of file