/* * 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<crypto/scatterwalk.h>#include<crypto/algapi.h>#include<crypto/aes.h>#include<linux/platform_data/crypto-atmel.h>#include<dt-bindings/dma/at91.h>#include"atmel-aes-regs.h"#define ATMEL_AES_PRIORITY 300#define ATMEL_AES_BUFFER_ORDER 2#define ATMEL_AES_BUFFER_SIZE (PAGE_SIZE << ATMEL_AES_BUFFER_ORDER)#define CFB8_BLOCK_SIZE 1#define CFB16_BLOCK_SIZE 2#define CFB32_BLOCK_SIZE 4#define CFB64_BLOCK_SIZE 8#define SIZE_IN_WORDS(x) ((x) >> 2)/* AES flags *//* Reserve bits [18:16] [14:12] [0] for mode (same as for AES_MR) */#define AES_FLAGS_ENCRYPT AES_MR_CYPHER_ENC#define AES_FLAGS_OPMODE_MASK (AES_MR_OPMOD_MASK | AES_MR_CFBS_MASK)#define AES_FLAGS_ECB AES_MR_OPMOD_ECB#define AES_FLAGS_CBC AES_MR_OPMOD_CBC#define AES_FLAGS_OFB AES_MR_OPMOD_OFB#define AES_FLAGS_CFB128 (AES_MR_OPMOD_CFB | AES_MR_CFBS_128b)#define AES_FLAGS_CFB64 (AES_MR_OPMOD_CFB | AES_MR_CFBS_64b)#define AES_FLAGS_CFB32 (AES_MR_OPMOD_CFB | AES_MR_CFBS_32b)#define AES_FLAGS_CFB16 (AES_MR_OPMOD_CFB | AES_MR_CFBS_16b)#define AES_FLAGS_CFB8 (AES_MR_OPMOD_CFB | AES_MR_CFBS_8b)#define AES_FLAGS_CTR AES_MR_OPMOD_CTR#define AES_FLAGS_MODE_MASK (AES_FLAGS_OPMODE_