deptest: Do not clobber the base build and staging dirs
[openwrt/svn-archive/archive.git] / target / linux / ifxmips / files-2.6.32 / drivers / crypto / ifxmips / ifxmips_deu.c
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) 2010 Ralph Hempel <ralph.hempel@lantiq.com>
17 * Copyright (C) 2009 Mohammad Firdaus
18 */
19
20 /*!
21 \defgroup IFX_DEU IFX_DEU_DRIVERS
22 \ingroup API
23 \brief ifx deu driver module
24 */
25
26 /*!
27 \file ifxmips_deu.c
28 \ingroup IFX_DEU
29 \brief main deu driver file
30 */
31
32 /*!
33 \defgroup IFX_DEU_FUNCTIONS IFX_DEU_FUNCTIONS
34 \ingroup IFX_DEU
35 \brief IFX DEU functions
36 */
37
38 /* Project header */
39 #include <linux/version.h>
40 #if defined(CONFIG_MODVERSIONS)
41 #define MODVERSIONS
42 #include <linux/modversions.h>
43 #endif
44 #include <linux/module.h>
45 #include <linux/init.h>
46 #include <linux/types.h>
47 #include <linux/errno.h>
48 #include <linux/crypto.h>
49 #include <linux/proc_fs.h>
50 #include <linux/fs.h> /* Stuff about file systems that we need */
51 #include <asm/byteorder.h>
52 #include <ifxmips_pmu.h>
53 #include "ifxmips_deu.h"
54
55 #ifdef CONFIG_CRYPTO_DEV_IFXMIPS_DMA
56 int disable_deudma = 0;
57 #else
58 int disable_deudma = 1;
59 #endif /* CONFIG_CRYPTO_DEV_IFXMIPS_DMA */
60
61 #ifdef CRYPTO_DEBUG
62 char deu_debug_level = 3;
63 #endif
64
65 /*! \fn static int __init deu_init (void)
66 * \ingroup IFX_DEU_FUNCTIONS
67 * \brief link all modules that have been selected in kernel config for ifx hw crypto support
68 * \return ret
69 */
70 static int __init deu_init (void)
71 {
72 int ret = -ENOSYS;
73 u32 config;
74
75 volatile struct clc_controlr_t *clc = (struct clc_controlr_t *) IFX_DEU_CLK;
76
77 ifxmips_pmu_enable(1<<20);
78
79 printk(KERN_INFO "Lantiq crypto hardware driver version %s\n", IFX_DEU_DRV_VERSION);
80
81 chip_version();
82
83 clc->FSOE = 0;
84 clc->SBWE = 0;
85 clc->SPEN = 0;
86 clc->SBWE = 0;
87 clc->DISS = 0;
88 clc->DISR = 0;
89
90 config = *IFX_DEU_ID;
91
92 #ifdef CONFIG_CRYPTO_DEV_IFXMIPS_DMA
93 deu_dma_init ();
94 #endif
95
96 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_DES)
97 if(config & IFX_DEU_ID_DES) {
98 if ((ret = ifxdeu_init_des ())) {
99 printk (KERN_ERR "IFX DES initialization failed!\n");
100 }
101 } else {
102 printk (KERN_ERR "IFX DES not supported!\n");
103 }
104 #endif
105 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_AES)
106 if(config & IFX_DEU_ID_AES) {
107 if ((ret = ifxdeu_init_aes ())) {
108 printk (KERN_ERR "IFX AES initialization failed!\n");
109 }
110 } else {
111 printk (KERN_ERR "IFX AES not supported!\n");
112 }
113 #endif
114 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_ARC4)
115 if ((ret = ifxdeu_init_arc4 ())) {
116 printk (KERN_ERR "IFX ARC4 initialization failed!\n");
117 }
118 #endif
119 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_SHA1)
120 if(config & IFX_DEU_ID_HASH) {
121 if ((ret = ifxdeu_init_sha1 ())) {
122 printk (KERN_ERR "IFX SHA1 initialization failed!\n");
123 }
124 } else {
125 printk (KERN_ERR "IFX SHA1 not supported!\n");
126 }
127 #endif
128 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_MD5)
129 if(config & IFX_DEU_ID_HASH) {
130 if ((ret = ifxdeu_init_md5 ())) {
131 printk (KERN_ERR "IFX MD5 initialization failed!\n");
132 }
133 } else {
134 printk (KERN_ERR "IFX MD5 not supported!\n");
135 }
136 #endif
137 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_SHA1_HMAC)
138 if ((ret = ifxdeu_init_sha1_hmac ())) {
139 printk (KERN_ERR "IFX SHA1_HMAC initialization failed!\n");
140 }
141 #endif
142 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_MD5_HMAC)
143 if ((ret = ifxdeu_init_md5_hmac ())) {
144 printk (KERN_ERR "IFX MD5_HMAC initialization failed!\n");
145 }
146 #endif
147 return ret;
148 }
149
150 /*! \fn static void __exit deu_fini (void)
151 * \ingroup IFX_DEU_FUNCTIONS
152 * \brief remove the loaded crypto algorithms
153 */
154 static void __exit deu_fini (void)
155 {
156 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_DES)
157 ifxdeu_fini_des ();
158 #endif
159 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_AES)
160 ifxdeu_fini_aes ();
161 #endif
162 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_ARC4)
163 ifxdeu_fini_arc4 ();
164 #endif
165 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_SHA1)
166 ifxdeu_fini_sha1 ();
167 #endif
168 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_MD5)
169 ifxdeu_fini_md5 ();
170 #endif
171 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_SHA1_HMAC)
172 ifxdeu_fini_sha1_hmac ();
173 #endif
174 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_MD5_HMAC)
175 ifxdeu_fini_md5_hmac ();
176 #endif
177 printk("DEU has exited successfully\n");
178
179 #if defined(CONFIG_CRYPTO_DEV_IFXMIPS_DMA)
180 ifxdeu_fini_dma();
181 printk("DMA has deregistered successfully\n");
182 #endif
183 }
184
185 module_init (deu_init);
186 module_exit (deu_fini);
187
188 MODULE_DESCRIPTION ("Infineon crypto engine support.");
189 MODULE_LICENSE ("GPL");
190 MODULE_AUTHOR ("Mohammad Firdaus");