1/****************************************************************************** 2** 3** FILE NAME : ifxmips_deu.c 4** PROJECT : IFX UEIP 5** MODULES : DEU Module for Danube 6** 7** DATE : September 8, 2009 8** AUTHOR : Mohammad Firdaus 9** DESCRIPTION : Data Encryption Unit Driver 10** COPYRIGHT : Copyright (c) 2009 11** Infineon Technologies AG 12** Am Campeon 1-12, 85579 Neubiberg, Germany 13** 14** This program is free software; you can redistribute it and/or modify 15** it under the terms of the GNU General Public License as published by 16** the Free Software Foundation; either version 2 of the License, or 17** (at your option) any later version. 18** 19** HISTORY 20** $Date $Author $Comment 21** 08,Sept 2009 Mohammad Firdaus Initial UEIP release 22*******************************************************************************/ 23 24/*! 25 \defgroup IFX_DEU IFX_DEU_DRIVERS 26 \ingroup API 27 \brief ifx deu driver module 28*/ 29 30/*! 31 \file ifxmips_deu.c 32 \ingroup IFX_DEU 33 \brief main deu driver file 34*/ 35 36/*! 37 \defgroup IFX_DEU_FUNCTIONS IFX_DEU_FUNCTIONS 38 \ingroup IFX_DEU 39 \brief IFX DEU functions 40*/ 41 42/* Project header */ 43#include <linux/version.h> 44#if defined(CONFIG_MODVERSIONS) 45#define MODVERSIONS 46#include <linux/modversions.h> 47#endif 48#include <linux/module.h> 49#include <linux/init.h> 50#include <linux/types.h> 51#include <linux/errno.h> 52#include <linux/crypto.h> 53#include <linux/proc_fs.h> 54#include <linux/platform_device.h> 55#include <linux/fs.h> /* Stuff about file systems that we need */ 56#include <asm/byteorder.h> 57#include "ifxmips_deu.h" 58 59#include <lantiq_soc.h> 60 61#if defined(CONFIG_DANUBE) 62#include "ifxmips_deu_danube.h" 63#elif defined(CONFIG_AR9) 64#include "ifxmips_deu_ar9.h" 65#elif defined(CONFIG_VR9) || defined(CONFIG_AR10) 66#include "ifxmips_deu_vr9.h" 67#else 68#error "Platform unknown!" 69#endif /* CONFIG_xxxx */ 70 71int disable_deudma = 1; 72 73void chip_version(void); 74 75/*! \fn static int __init deu_init (void) 76 * \ingroup IFX_DEU_FUNCTIONS 77 * \brief link all modules that have been selected in kernel config for ifx hw crypto support 78 * \return ret 79*/ 80 81static int ltq_deu_probe(struct platform_device *pdev) 82{ 83 int ret = -ENOSYS; 84 85 86 START_DEU_POWER; 87 88#define IFX_DEU_DRV_VERSION "2.0.0" 89 printk(KERN_INFO "Infineon Technologies DEU driver version %s \n", IFX_DEU_DRV_VERSION); 90 91 FIND_DEU_CHIP_VERSION; 92 93#if defined(CONFIG_CRYPTO_DEV_DES) 94 if ((ret = ifxdeu_init_des ())) { 95 printk (KERN_ERR "IFX DES initialization failed!\n"); 96 } 97#endif 98#if defined(CONFIG_CRYPTO_DEV_AES) 99 if ((ret = ifxdeu_init_aes ())) { 100 printk (KERN_ERR "IFX AES initialization failed!\n"); 101 } 102 103#endif 104#if defined(CONFIG_CRYPTO_DEV_ARC4) 105 if ((ret = ifxdeu_init_arc4 ())) { 106 printk (KERN_ERR "IFX ARC4 initialization failed!\n"); 107 } 108 109#endif 110#if defined(CONFIG_CRYPTO_DEV_SHA1) 111 if ((ret = ifxdeu_init_sha1 ())) { 112 printk (KERN_ERR "IFX SHA1 initialization failed!\n"); 113 } 114#endif 115#if defined(CONFIG_CRYPTO_DEV_MD5) 116 if ((ret = ifxdeu_init_md5 ())) { 117 printk (KERN_ERR "IFX MD5 initialization failed!\n"); 118 } 119 120#endif 121#if defined(CONFIG_CRYPTO_DEV_SHA1_HMAC) 122 if ((ret = ifxdeu_init_sha1_hmac ())) { 123 printk (KERN_ERR "IFX SHA1_HMAC initialization failed!\n"); 124 } 125#endif 126#if defined(CONFIG_CRYPTO_DEV_MD5_HMAC) 127 if ((ret = ifxdeu_init_md5_hmac ())) { 128 printk (KERN_ERR "IFX MD5_HMAC initialization failed!\n"); 129 } 130#endif 131 132 133 134 return ret; 135 136} 137 138/*! \fn static void __exit deu_fini (void) 139 * \ingroup IFX_DEU_FUNCTIONS 140 * \brief remove the loaded crypto algorithms 141*/ 142static int ltq_deu_remove(struct platform_device *pdev) 143{ 144//#ifdef CONFIG_CRYPTO_DEV_PWR_SAVE_MODE 145 #if defined(CONFIG_CRYPTO_DEV_DES) 146 ifxdeu_fini_des (); 147 #endif 148 #if defined(CONFIG_CRYPTO_DEV_AES) 149 ifxdeu_fini_aes (); 150 #endif 151 #if defined(CONFIG_CRYPTO_DEV_ARC4) 152 ifxdeu_fini_arc4 (); 153 #endif 154 #if defined(CONFIG_CRYPTO_DEV_SHA1) 155 ifxdeu_fini_sha1 (); 156 #endif 157 #if defined(CONFIG_CRYPTO_DEV_MD5) 158 ifxdeu_fini_md5 (); 159 #endif 160 #if defined(CONFIG_CRYPTO_DEV_SHA1_HMAC) 161 ifxdeu_fini_sha1_hmac (); 162 #endif 163 #if defined(CONFIG_CRYPTO_DEV_MD5_HMAC) 164 ifxdeu_fini_md5_hmac (); 165 #endif 166 printk("DEU has exited successfully\n"); 167 168 return 0; 169} 170 171 172int disable_multiblock = 0; 173 174#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) 175module_param(disable_multiblock,int,0); 176 177#else 178//MODULE_PARM (disable_multiblock, "i"); 179MODULE_PARM_DESC (disable_multiblock, 180 "Disable encryption of whole multiblock buffers."); 181#endif 182 183static const struct of_device_id ltq_deu_match[] = { 184#ifdef CONFIG_DANUBE 185 { .compatible = "lantiq,deu-danube"}, 186#elif defined CONFIG_AR9 187 { .compatible = "lantiq,deu-arx100"}, 188#elif defined CONFIG_VR9 189 { .compatible = "lantiq,deu-xrx200"}, 190#endif 191 {}, 192}; 193MODULE_DEVICE_TABLE(of, ltq_deu_match); 194 195 196static struct platform_driver ltq_deu_driver = { 197 .probe = ltq_deu_probe, 198 .remove = ltq_deu_remove, 199 .driver = { 200 .name = "deu", 201 .owner = THIS_MODULE, 202 .of_match_table = ltq_deu_match, 203 }, 204}; 205 206module_platform_driver(ltq_deu_driver); 207 208MODULE_DESCRIPTION ("Infineon DEU crypto engine support."); 209MODULE_LICENSE ("GPL"); 210MODULE_AUTHOR ("Mohammad Firdaus"); 211