/* * Cryptographic API. * * Support for Infineon DEU hardware crypto engine. * * Copyright (c) 2005 Johannes Doering , INFINEON * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * --------------------------------------------------------------------------- * Copyright (c) 2002, Dr Brian Gladman , Worcester, UK. * All rights reserved. * * LICENSE TERMS * * The free distribution and use of this software in both source and binary * form is allowed (with or without changes) provided that: * * 1. distributions of this source code include the above copyright * notice, this list of conditions and the following disclaimer; * * 2. distributions in binary form include the above copyright * notice, this list of conditions and the following disclaimer * in the documentation and/or other associated materials; * * 3. the copyright holder's name is not used to endorse products * built using this software without specific written permission. * * ALTERNATIVELY, provided that this notice is retained in full, this product * may be distributed under the terms of the GNU General Public License (GPL), * in which case the provisions of the GPL apply INSTEAD OF those given above. * * DISCLAIMER * * This software is provided 'as is' with no explicit or implied warranties * in respect of its properties, including, but not limited to, correctness * and/or fitness for purpose. * --------------------------------------------------------------------------- ** HISTORY ** $Date $Author $Comment * 9th Nov 2007 Teh Kok How Bug fixes * --------------------------------------------------------------------------- */ /** \addtogroup AMAZON_S_DEU \ingroup AMAZON_S_BSP \brief amazon_s deu driver module */ /*! \file amazon_s_deu_generic.c \ingroup AMAZON_S_DEU \brief deu driver file */ /*! \addtogroup AMAZON_S_DEU_FUNCTIONS \ingroup AMAZON_S_DEU \brief amazon_s deu driver functions */ //TODO: not required? //#include #include //#if defined(CONFIG_MODVERSIONS) // && !defined(MODVERSIONS) //#error CONFIG_MODVERSIONS defined!!! //#define MODVERSIONS //#include //#endif #if defined(CONFIG_MODVERSIONS) #define MODVERSIONS #include #endif #include #include #include #include #include #include #include /* Stuff about file systems that we need */ #include #ifdef CONFIG_AMAZON_S #include #include #include #define CLC_START AMAZON_S_DEU_CLK #endif #ifdef CONFIG_CRYPTO_DEV_AMAZON_S_DMA #include #include int disable_deudma = 0; #else int disable_deudma = 1; #endif #include extern int deu_dma_init (void); extern int ifxdeu_init_des (void); extern int ifxdeu_fini_des (void); extern int ifxdeu_init_aes (void); extern int ifxdeu_fini_aes (void); extern int ifxdeu_init_arc4 (void); extern int ifxdeu_fini_arc4 (void); extern int ifxdeu_init_sha1 (void); extern int ifxdeu_fini_sha1 (void); extern int ifxdeu_init_md5 (void); extern int ifxdeu_fini_md5 (void); extern int ifxdeu_init_sha1_hmac (void); extern int ifxdeu_fini_sha1_hmac (void); extern int ifxdeu_init_md5_hmac (void); extern int ifxdeu_fini_md5_hmac (void); /*! \fn static int __init deu_init (void) \ingroup AMAZON_S_DEU_FUNCTIONS \brief link all modules that have been selected in kernel config for ifx hw crypto support */ static int __init deu_init (void) { int ret = -ENOSYS; #if defined(CONFIG_AMAZON_S) volatile struct clc_controlr_t *clc = (struct clc_controlr_t *) CLC_START; //*AMAZON_S_PMU_PWDCR &= ((~(1 << 20))); //& 0x3fffff DEU_PMU_SETUP(PMU_ENABLE); clc->FSOE = 0; clc->SBWE = 0; clc->SPEN = 0; clc->SBWE = 0; clc->DISS = 0; clc->DISR = 0; #define IFX_DEU_DRV_VERSION "1.0.0" printk(KERN_INFO "Infineon Technologies DEU driver version %s \n", IFX_DEU_DRV_VERSION); #endif #ifdef CONFIG_CRYPTO_DEV_AMAZON_S_DMA deu_dma_init (); #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_DES) if ((ret = ifxdeu_init_des ())) { printk (KERN_ERR "IFX DES initialization failed!\n"); } #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_AES) if ((ret = ifxdeu_init_aes ())) { printk (KERN_ERR "IFX AES initialization failed!\n"); } #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_ARC4) if ((ret = ifxdeu_init_arc4 ())) { printk (KERN_ERR "IFX ARC4 initialization failed!\n"); } #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_SHA1) if ((ret = ifxdeu_init_sha1 ())) { printk (KERN_ERR "IFX SHA1 initialization failed!\n"); } #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_MD5) if ((ret = ifxdeu_init_md5 ())) { printk (KERN_ERR "IFX MD5 initialization failed!\n"); } #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_SHA1_HMAC) if ((ret = ifxdeu_init_sha1_hmac ())) { printk (KERN_ERR "IFX SHA1_HMAC initialization failed!\n"); } #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_MD5_HMAC) if ((ret = ifxdeu_init_md5_hmac ())) { printk (KERN_ERR "IFX MD5_HMAC initialization failed!\n"); } #endif return ret; } /*! \fn static void __exit deu_fini (void) \ingroup AMAZON_S_DEU_FUNCTIONS \brief remove the loaded crypto algorithms */ static void __exit deu_fini (void) { #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_DES) ifxdeu_fini_des (); #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_AES) ifxdeu_fini_aes (); #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_ARC4) ifxdeu_fini_arc4 (); #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_SHA1) ifxdeu_fini_sha1 (); #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_MD5) ifxdeu_fini_md5 (); #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_SHA1_HMAC) ifxdeu_fini_sha1_hmac (); #endif #if defined(CONFIG_CRYPTO_DEV_AMAZON_S_MD5_HMAC) ifxdeu_fini_md5_hmac (); #endif } int disable_multiblock = 0; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) module_param(disable_multiblock,int,0); #else //MODULE_PARM (disable_multiblock, "i"); MODULE_PARM_DESC (disable_multiblock, "Disable encryption of whole multiblock buffers."); #endif module_init (deu_init); module_exit (deu_fini); MODULE_DESCRIPTION ("Infineon DEU crypto engine support."); MODULE_LICENSE ("GPL"); MODULE_AUTHOR ("Johannes Doering");