ltq-deu: make deu hash lock global and remove md5_hmac_ exports
[openwrt/staging/dedeckeh.git] / package / kernel / lantiq / ltq-deu / src / ifxmips_deu.c
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
71 int disable_deudma = 1;
72 spinlock_t ltq_deu_hash_lock;
73 EXPORT_SYMBOL_GPL(ltq_deu_hash_lock);
74
75 void chip_version(void);
76
77 /*! \fn static int __init deu_init (void)
78 * \ingroup IFX_DEU_FUNCTIONS
79 * \brief link all modules that have been selected in kernel config for ifx hw crypto support
80 * \return ret
81 */
82
83 static int ltq_deu_probe(struct platform_device *pdev)
84 {
85 int ret = -ENOSYS;
86
87
88 START_DEU_POWER;
89 CRTCL_SECT_HASH_INIT;
90
91 #define IFX_DEU_DRV_VERSION "2.0.0"
92 printk(KERN_INFO "Infineon Technologies DEU driver version %s \n", IFX_DEU_DRV_VERSION);
93
94 FIND_DEU_CHIP_VERSION;
95
96 #if defined(CONFIG_CRYPTO_DEV_DES)
97 if ((ret = ifxdeu_init_des ())) {
98 printk (KERN_ERR "IFX DES initialization failed!\n");
99 }
100 #endif
101 #if defined(CONFIG_CRYPTO_DEV_AES)
102 if ((ret = ifxdeu_init_aes ())) {
103 printk (KERN_ERR "IFX AES initialization failed!\n");
104 }
105
106 #endif
107 #if defined(CONFIG_CRYPTO_DEV_ARC4)
108 if ((ret = ifxdeu_init_arc4 ())) {
109 printk (KERN_ERR "IFX ARC4 initialization failed!\n");
110 }
111
112 #endif
113 #if defined(CONFIG_CRYPTO_DEV_SHA1)
114 if ((ret = ifxdeu_init_sha1 ())) {
115 printk (KERN_ERR "IFX SHA1 initialization failed!\n");
116 }
117 #endif
118 #if defined(CONFIG_CRYPTO_DEV_MD5)
119 if ((ret = ifxdeu_init_md5 ())) {
120 printk (KERN_ERR "IFX MD5 initialization failed!\n");
121 }
122
123 #endif
124 #if defined(CONFIG_CRYPTO_DEV_SHA1_HMAC)
125 if ((ret = ifxdeu_init_sha1_hmac ())) {
126 printk (KERN_ERR "IFX SHA1_HMAC initialization failed!\n");
127 }
128 #endif
129 #if defined(CONFIG_CRYPTO_DEV_MD5_HMAC)
130 if ((ret = ifxdeu_init_md5_hmac ())) {
131 printk (KERN_ERR "IFX MD5_HMAC initialization failed!\n");
132 }
133 #endif
134
135
136
137 return ret;
138
139 }
140
141 /*! \fn static void __exit deu_fini (void)
142 * \ingroup IFX_DEU_FUNCTIONS
143 * \brief remove the loaded crypto algorithms
144 */
145 static int ltq_deu_remove(struct platform_device *pdev)
146 {
147 //#ifdef CONFIG_CRYPTO_DEV_PWR_SAVE_MODE
148 #if defined(CONFIG_CRYPTO_DEV_DES)
149 ifxdeu_fini_des ();
150 #endif
151 #if defined(CONFIG_CRYPTO_DEV_AES)
152 ifxdeu_fini_aes ();
153 #endif
154 #if defined(CONFIG_CRYPTO_DEV_ARC4)
155 ifxdeu_fini_arc4 ();
156 #endif
157 #if defined(CONFIG_CRYPTO_DEV_SHA1)
158 ifxdeu_fini_sha1 ();
159 #endif
160 #if defined(CONFIG_CRYPTO_DEV_MD5)
161 ifxdeu_fini_md5 ();
162 #endif
163 #if defined(CONFIG_CRYPTO_DEV_SHA1_HMAC)
164 ifxdeu_fini_sha1_hmac ();
165 #endif
166 #if defined(CONFIG_CRYPTO_DEV_MD5_HMAC)
167 ifxdeu_fini_md5_hmac ();
168 #endif
169 printk("DEU has exited successfully\n");
170
171 return 0;
172 }
173
174
175 int disable_multiblock = 0;
176
177 module_param(disable_multiblock,int,0);
178
179
180 static const struct of_device_id ltq_deu_match[] = {
181 #ifdef CONFIG_DANUBE
182 { .compatible = "lantiq,deu-danube"},
183 #elif defined CONFIG_AR9
184 { .compatible = "lantiq,deu-arx100"},
185 #elif defined CONFIG_VR9
186 { .compatible = "lantiq,deu-xrx200"},
187 #endif
188 {},
189 };
190 MODULE_DEVICE_TABLE(of, ltq_deu_match);
191
192
193 static struct platform_driver ltq_deu_driver = {
194 .probe = ltq_deu_probe,
195 .remove = ltq_deu_remove,
196 .driver = {
197 .name = "deu",
198 .owner = THIS_MODULE,
199 .of_match_table = ltq_deu_match,
200 },
201 };
202
203 module_platform_driver(ltq_deu_driver);
204
205 MODULE_DESCRIPTION ("Infineon DEU crypto engine support.");
206 MODULE_LICENSE ("GPL");
207 MODULE_AUTHOR ("Mohammad Firdaus");