1 /******************************************************************************
3 ** FILE NAME : ifxmips_deu_ar9.c
5 ** MODULES : DEU Module for AR9
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 *******************************************************************************/
24 \defgroup IFX_DEU IFX_DEU_DRIVERS
26 \brief ifx deu driver module
30 \file ifxmips_deu_ar9.c
31 \brief ifx deu board specific driver file for ar9
35 \defgroup BOARD_SPECIFIC_FUNCTIONS IFX_BOARD_SPECIFIC_FUNCTIONS
37 \brief board specific functions
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
47 #include "ifxmips_deu_dma.h"
48 #include "ifxmips_deu_ar9.h"
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);
61 #define DES_3DES_START IFX_DES_CON
62 #define AES_START IFX_AES_CON
63 #define CLC_START IFX_DEU_CLK
67 u8 *g_dma_page_ptr = NULL;
68 u8 *g_dma_block = NULL;
69 u8 *g_dma_block2 = NULL;
71 deu_drv_priv_t deu_dma_priv;
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
80 u32 endian_swap(u32 input)
85 /*! \fn u32 input_swap(u32 input)
86 * \ingroup BOARD_SPECIFIC_FUNCTIONS
91 u32 input_swap(u32 input)
96 /*! \fn void aes_chip_init (void)
97 * \ingroup BOARD_SPECIFIC_FUNCTIONS
98 * \brief initialize AES hardware
101 void aes_chip_init (void)
103 volatile struct aes_t *aes = (struct aes_t *) AES_START;
105 aes->controlr.SM = 1;
106 aes->controlr.ARS = 1;
110 /*! \fn void des_chip_init (void)
111 * \ingroup BOARD_SPECIFIC_FUNCTIONS
112 * \brief initialize DES hardware
115 void des_chip_init (void)
117 volatile struct des_t *des = (struct des_t *) DES_3DES_START;
119 // start crypto engine with write to ILR
120 des->controlr.SM = 1;
122 des->controlr.ARS = 1;
126 /*! \fn void chip_version(void)
127 * \ingroup BOARD_SPECIFIC_FUNCTIONS
131 void chip_version(void)