Driver for the AES engine in ECB and CBC modes found on some
Alchemy Au1200/Au1300 SoCs.
Signed-off-by: Manuel Lauss manuel.la...@gmail.com
---
lightly tested with the tcrypt module on Au1200; I have no idea whether
it really works correctly:
# modprobe alchemy-aes
alg: skcipher: setkey failed on test 2 for ecb-aes-alchemy: flags=20
# modprobe tcrypt mode=10
alg: skcipher: setkey failed on test 3 for cbc-aes-alchemy: flags=0
alg: skcipher: Failed to load transform for cbc(aes): -2
alg: skcipher: Failed to load transform for cbc(aes): -2
tcrypt: one or more tests failed!
FATAL: Error inserting tcrypt
(/lib/modules/2.6.34-rc6-db1200-00214-g9f84af9/kernel/crypto/tcrypt.ko):
Unknown symbol in module, or unknown parameter (see dmesg)
The error in test 3 for cbc-aes-alchemy probably comes from the inability
to process keys larger than 128 bits.
Please have a look.
Thanks!
drivers/crypto/Kconfig |8 +
drivers/crypto/Makefile |1 +
drivers/crypto/alchemy-aes.c | 579 ++
3 files changed, 588 insertions(+), 0 deletions(-)
create mode 100644 drivers/crypto/alchemy-aes.c
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index b08403d..7705b13 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -222,4 +222,12 @@ config CRYPTO_DEV_PPC4XX
help
This option allows you to have support for AMCC crypto acceleration.
+config CRYPTO_DEV_ALCHEMY_AES
+ tristate Au1200/Au1300 AES engine
+ depends on MACH_ALCHEMY
+ select CRYPTO_ALGAPI
+ select CRYPTO_BLKCIPHER
+ help
+ Driver for the AES engine in Alchemy Au1200/Au1300 series SoCs.
+
endif # CRYPTO_HW
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index 6ffcb3f..624777f 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_CRYPTO_DEV_MV_CESA) += mv_cesa.o
obj-$(CONFIG_CRYPTO_DEV_TALITOS) += talitos.o
obj-$(CONFIG_CRYPTO_DEV_IXP4XX) += ixp4xx_crypto.o
obj-$(CONFIG_CRYPTO_DEV_PPC4XX) += amcc/
+obj-$(CONFIG_CRYPTO_DEV_ALCHEMY_AES) += alchemy-aes.o
diff --git a/drivers/crypto/alchemy-aes.c b/drivers/crypto/alchemy-aes.c
new file mode 100644
index 000..14e8ace
--- /dev/null
+++ b/drivers/crypto/alchemy-aes.c
@@ -0,0 +1,579 @@
+/*
+ * alchemy-aes.c -- Driver for the Alchemy Au1200/Au1300 AES engine.
+ *
+ * (c) 2010 Manuel Lauss manuel.la...@gmail.com
+ *
+ * Licensed under the GPLv2.
+ */
+
+#include linux/crypto.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/slab.h
+#include linux/interrupt.h
+#include linux/completion.h
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/resource.h
+
+#include crypto/algapi.h
+#include crypto/aes.h
+
+#include asm/mach-au1x00/au1000.h
+#include asm/mach-au1x00/au1xxx_dbdma.h
+
+/*#define DEBUG*/
+
+#ifdef DEBUG
+#define DBG(x...) printk(KERN_ALERT AES: x)
+#define DBGHEX(x...) print_hex_dump(x)
+#else
+#define DBG(x...)
+#define DBGHEX(x...)
+#endif
+
+#define DRVNAMEalchemy-aes
+
+/* the AES engine likes the number 16 */
+#define ALCHEMY_AES_KEY_SIZE 16
+#define ALCHEMY_AES_IV_SIZE16
+#define ALCHEMY_AES_BLK_SIZE 16
+#define ALCHEMY_AES_DDMA_DSCRS 16
+
+/* register offsets */
+#define AES_STATUS 0x00
+#define AES_INDATA 0x04
+#define AES_OUTDATA0x08
+#define AES_INTCAUSE 0x0c
+#define AES_CONFIG 0x10
+
+#define AES_S_PS 0x01/* start crypto */
+#define AES_S_IE 0x02/* int enable */
+#define AES_S_CR_1 0x00/* periph. clock */
+#define AES_S_CR_2 0x04/* periph. clock div 2 */
+#define AES_S_CR_4 0x08/* periph. clock div 4 */
+#define AES_S_CR_8 0x0c/* periph. clock div 8 */
+#define AES_S_CR_MASK 0x0c
+#define AES_S_OUT 0x10/* set if out fifo has space */
+#define AES_S_IN 0x20/* set if in fifo has space */
+
+#define AES_CAUSE_RDY 0x01/* process complete */
+#define AES_CAUSE_OVR 0x02/* in fifo overflow */
+#define AES_CAUSE_UND 0x04/* out fifo underflow */
+
+#define AES_C_ED 0x01/* set to DE/clear to ENcrypt */
+#define AES_C_IKG 0x02/* do internal key generation */
+#define AES_C_RPK 0x04/* replay key (output 10th key) */
+#define AES_C_RK 0x08/* reuse internal key store */
+#define AES_C_UC 0x10/* undefined block count */
+#define AES_C_OP_ECB 0x00
+#define AES_C_OP_CBC 0x20
+#define AES_C_OP_CFB 0x40
+#define AES_C_OP_OFB 0x60
+#define AES_C_OP_MASK 0x60
+
+
+struct alchemy_aes_priv {
+ void __iomem *base;
+ int irq;
+
+ /* dbdma */
+ u32 dmatx;
+ u32 dmarx;
+ int txid;
+ int rxid;
+
+ unsigned char key[ALCHEMY_AES_KEY_SIZE];
+
+ struct completion done;
+ struct list_head alg_list;
+ struct resource *ioarea;
+};
+
+/* need to improvise to stash private data */
+struct alchemy_aes_alg {
+ struct crypto_alg alg;
+ struct