1 /******************************************************************************
3 ** FILE NAME : ifxmips_deu_vr9.c
5 ** MODULES : DEU Module for VR9
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
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.
20 ** $Date $Author $Comment
21 ** 08,Sept 2009 Mohammad Firdaus Initial UEIP release
22 *******************************************************************************/
25 \defgroup IFX_DEU IFX_DEU_DRIVERS
27 \brief deu driver module
31 \file ifxmips_deu_vr9.c
33 \brief board specific deu driver file for vr9
37 \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
39 \brief board specific deu driver functions
42 /* Project header files */
43 #include <linux/module.h>
44 #include <linux/init.h>
45 #include <linux/types.h>
46 #include <linux/errno.h>
47 #include <asm/io.h> //dma_cache_inv
49 #include "ifxmips_deu_dma.h"
50 #include "ifxmips_deu_vr9.h"
52 /* Function decleration */
53 void aes_chip_init (void);
54 void des_chip_init (void);
55 int deu_dma_init (void);
56 void deu_dma_priv_init(void);
57 u32 endian_swap(u32 input);
58 u32* memory_alignment(const u8 *arg, u32 *buff_alloc, int in_out, int nbytes);
59 void aes_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
60 void des_dma_memory_copy(u32 *outcopy, u32 *out_dma, u8 *out_arg, int nbytes);
61 void __exit ifxdeu_fini_dma(void);
63 #define DES_3DES_START IFX_DES_CON
64 #define AES_START IFX_AES_CON
68 u8 *g_dma_page_ptr = NULL;
69 u8 *g_dma_block = NULL;
70 u8 *g_dma_block2 = NULL;
72 deu_drv_priv_t deu_dma_priv;
75 /*! \fn u32 endian_swap(u32 input)
76 * \ingroup BOARD_SPECIFIC_FUNCTIONS
77 * \brief Swap data given to the function
78 * \param input Data input to be swapped
79 * \return either the swapped data or the input data depending on whether it is in DMA mode or FPI mode
83 u32 endian_swap(u32 input)
88 /*! \fn u32 input_swap(u32 input)
89 * \ingroup BOARD_SPECIFIC_FUNCTIONS
94 u32 input_swap(u32 input)
99 /*! \fn void aes_chip_init (void)
100 * \ingroup BOARD_SPECIFIC_FUNCTIONS
101 * \brief initialize AES hardware
104 void aes_chip_init (void)
106 volatile struct aes_t *aes = (struct aes_t *) AES_START;
108 // start crypto engine with write to ILR
109 aes->controlr.SM = 1;
110 aes->controlr.NDC = 0;
112 aes->controlr.ENDI = 1;
114 aes->controlr.ARS = 0;
118 /*! \fn void des_chip_init (void)
119 * \ingroup IFX_AES_FUNCTIONS
120 * \brief initialize DES hardware
123 void des_chip_init (void)
125 volatile struct des_t *des = (struct des_t *) DES_3DES_START;
127 // start crypto engine with write to ILR
128 des->controlr.SM = 1;
129 des->controlr.NDC = 1;
131 des->controlr.ENDI = 1;
133 des->controlr.ARS = 0;
136 /*! \fn void chip_version(void)
137 * \ingroup IFX_DES_FUNCTIONS
138 * \brief function not used in VR9
140 void chip_version(void)