add chaos_calmer branch
[15.05/openwrt.git] / package / kernel / lantiq / ltq-deu / src / ifxmips_deu_ar9.c
1 /******************************************************************************
2 **
3 ** FILE NAME    : ifxmips_deu_ar9.c
4 ** PROJECT      : IFX UEIP
5 ** MODULES      : DEU Module for AR9
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   \defgroup IFX_DEU IFX_DEU_DRIVERS
25   \ingroup API
26   \brief ifx deu driver module
27 */
28
29 /*!
30   \file ifxmips_deu_ar9.c
31   \brief ifx deu board specific driver file for ar9
32 */
33
34 /*! 
35  \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS 
36  \ingroup IFX_DEU
37  \brief board specific functions
38 */
39
40 /* Project header files */
41 #include <linux/module.h>
42 #include <linux/init.h>
43 #include <linux/types.h>
44 #include <linux/errno.h>
45 #include <asm/io.h> //dma_cache_inv
46
47 #include "ifxmips_deu_dma.h"
48 #include "ifxmips_deu_ar9.h"
49
50 /* Function decleration */
51 void aes_chip_init (void);
52 void des_chip_init (void);
53 int deu_dma_init (void);
54 u32 endian_swap(u32 input);
55 u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
56 void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
57 void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
58 void deu_dma_priv_init(void);
59 void __exit ifxdeu_fini_dma(void);
60
61 #define DES_3DES_START  IFX_DES_CON
62 #define AES_START       IFX_AES_CON
63 #define CLC_START       IFX_DEU_CLK
64
65 /* Variables */
66
67 u8 *g_dma_page_ptr = NULL;
68 u8 *g_dma_block = NULL;
69 u8 *g_dma_block2 = NULL;
70
71 deu_drv_priv_t deu_dma_priv;
72
73
74 /*! \fn u32 endian_swap(u32 input) 
75  *  \ingroup BOARD_SPECIFIC_FUNCTIONS
76  *  \brief Swap data given to the function 
77  *  \param input   Data input to be swapped
78  *  \return either the swapped data or the input data depending on whether it is in DMA mode or FPI mode
79 */
80 u32 endian_swap(u32 input)
81 {
82     return input;
83 }
84
85 /*! \fn u32 input_swap(u32 input)
86  *  \ingroup BOARD_SPECIFIC_FUNCTIONS
87  *  \brief Not used  
88  *  \return input
89 */
90
91 u32 input_swap(u32 input)
92 {
93     return input;
94 }
95
96 /*! \fn void aes_chip_init (void)
97  *  \ingroup BOARD_SPECIFIC_FUNCTIONS
98  *  \brief initialize AES hardware   
99 */
100
101 void aes_chip_init (void)
102 {
103    volatile struct aes_t *aes = (struct aes_t *) AES_START;
104
105    aes->controlr.SM = 1;
106    aes->controlr.ARS = 1;
107
108 }
109
110 /*! \fn void des_chip_init (void)
111  *  \ingroup BOARD_SPECIFIC_FUNCTIONS
112  *  \brief initialize DES hardware
113 */         
114                         
115 void des_chip_init (void)
116 {
117     volatile struct des_t *des = (struct des_t *) DES_3DES_START;
118
119     // start crypto engine with write to ILR
120     des->controlr.SM = 1;
121     asm("sync");
122     des->controlr.ARS = 1;
123
124 }
125
126 /*! \fn void chip_version(void) 
127  *  \ingroup BOARD_SPECIFIC_FUNCTIONS
128  *  \brief not used!
129 */     
130
131 void chip_version(void) 
132 {
133     return;
134 }
135