/* * Cryptographic API. * * Support for ATMEL AES HW acceleration. * * Copyright (c) 2012 Eukréa Electromatique - ATMEL * Author: Nicolas Royer <nicolas@eukrea.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * * Some ideas are from omap-aes.c driver. */#include<linux/kernel.h>#include<linux/module.h>#include<linux/slab.h>#include<linux/err.h>#include<linux/clk.h>#include<linux/io.h>#include<linux/hw_random.h>#include<linux/platform_device.h>#include<linux/device.h>#include<linux/init.h>#include<linux/errno.h>#include<linux/interrupt.h>#include<linux/irq.h>#include<linux/scatterlist.h>#include<linux/dma-mapping.h>#include<linux/of_device.h>#include<linux/delay.h>#include<linux/crypto.h>#include<linux/cryptohash.h>#include<crypto/scatterwalk.h>#include<crypto/algapi.h>#include<crypto/aes.h>#include<crypto/hash.h>#include<crypto/internal/hash.h>#include<linux/platform_data/crypto-atmel.h>#include<dt-bindings/dma/at91.h>#include"atmel-aes-regs.h"#define CFB8_BLOCK_SIZE 1#define CFB16_BLOCK_SIZE 2#define CFB32_BLOCK_SIZE 4#define CFB64_BLOCK_SIZE 8/* AES flags */#define AES_FLAGS_MODE_MASK 0x03ff#define AES_FLAGS_ENCRYPT BIT(0)#define AES_FLAGS_CBC BIT(1)#define AES_FLAGS_CFB BIT(2)#define AES_FLAGS_CFB8 BIT(3)#define AES_FLAGS_CFB16 BIT(4)#define AES_FLAGS_CFB32 BIT(5)#define AES_FLAGS_CFB64 BIT(6)#define AES_FLAGS_CFB128 BIT(7)#define AES_FLAGS_OFB BIT(8)#define AES_FLAGS_CTR BIT(9)#define AES_FLAGS_INIT BIT(16)#define AES_FLAGS_DMA BIT(17)#define AES_FLAGS_BUSY BIT(18)#define AES_FLAGS_FAST BIT(19)#define ATMEL_AES_QUEUE_LENGTH 50#define ATMEL_AES_DMA_THRESHOLD 16structatmel_aes_caps{boolhas_dualbuff;boolhas_cfb64;u32max_burst_size;};structatmel_aes_dev;structatmel_aes_ctx{structatmel_aes_dev*dd;intkeylen;u32key[