1 /******************************************************************************
3 ** FILE NAME : ifxmips_atm_ar9.c
9 ** DESCRIPTION : ATM driver common source file (core functions)
10 ** COPYRIGHT : Copyright (c) 2006
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 ** 07 JUL 2009 Xu Liang Init Version
22 *******************************************************************************/
27 * ####################################
29 * ####################################
35 #include <linux/kernel.h>
36 #include <linux/module.h>
37 #include <linux/version.h>
38 #include <linux/types.h>
39 #include <linux/errno.h>
40 #include <linux/proc_fs.h>
41 #include <linux/init.h>
42 #include <linux/ioctl.h>
43 #include <asm/delay.h>
46 * Chip Specific Head File
48 #include <lantiq_soc.h>
49 #include "ifxmips_compat.h"
51 #include "ifxmips_mei_interface.h"
52 #include "ifxmips_atm_core.h"
53 #include "ifxmips_atm_ppe_common.h"
54 #if defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX
55 #include "ifxmips_atm_fw_ar9_retx.h"
57 #include "ifxmips_atm_fw_ar9.h"
63 * ####################################
65 * ####################################
71 #define EMA_CMD_BUF_LEN 0x0040
72 #define EMA_CMD_BASE_ADDR (0x00003B80 << 2)
73 #define EMA_DATA_BUF_LEN 0x0100
74 #define EMA_DATA_BASE_ADDR (0x00003C00 << 2)
75 #define EMA_WRITE_BURST 0x2
76 #define EMA_READ_BURST 0x2
81 * ####################################
83 * ####################################
87 * Hardware Init/Uninit Functions
89 static inline void init_pmu(void);
90 static inline void uninit_pmu(void);
91 static inline void reset_ppe(void);
92 static inline void init_ema(void);
93 static inline void init_mailbox(void);
94 static inline void init_atm_tc(void);
95 static inline void clear_share_buffer(void);
100 * ####################################
102 * ####################################
108 * ####################################
110 * ####################################
113 static inline void init_pmu(void)
115 //*(unsigned long *)0xBF10201C &= ~((1 << 15) | (1 << 13) | (1 << 9));
116 //PPE_TOP_PMU_SETUP(IFX_PMU_ENABLE);
117 PPE_SLL01_PMU_SETUP(IFX_PMU_ENABLE
);
118 PPE_TC_PMU_SETUP(IFX_PMU_ENABLE
);
119 PPE_EMA_PMU_SETUP(IFX_PMU_ENABLE
);
120 PPE_QSB_PMU_SETUP(IFX_PMU_ENABLE
);
121 PPE_TPE_PMU_SETUP(IFX_PMU_ENABLE
);
122 DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE
);
125 static inline void uninit_pmu(void)
127 PPE_SLL01_PMU_SETUP(IFX_PMU_DISABLE
);
128 PPE_TC_PMU_SETUP(IFX_PMU_DISABLE
);
129 PPE_EMA_PMU_SETUP(IFX_PMU_DISABLE
);
130 PPE_QSB_PMU_SETUP(IFX_PMU_DISABLE
);
131 PPE_TPE_PMU_SETUP(IFX_PMU_DISABLE
);
132 DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE
);
133 //PPE_TOP_PMU_SETUP(IFX_PMU_DISABLE);
136 static inline void reset_ppe(void)
140 //ifx_rcu_rst(IFX_RCU_DOMAIN_PPE, IFX_RCU_MODULE_ATM);
144 static inline void init_ema(void)
146 IFX_REG_W32((EMA_CMD_BUF_LEN
<< 16) | (EMA_CMD_BASE_ADDR
>> 2), EMA_CMDCFG
);
147 IFX_REG_W32((EMA_DATA_BUF_LEN
<< 16) | (EMA_DATA_BASE_ADDR
>> 2), EMA_DATACFG
);
148 IFX_REG_W32(0x000000FF, EMA_IER
);
149 IFX_REG_W32(EMA_READ_BURST
| (EMA_WRITE_BURST
<< 2), EMA_CFG
);
152 static inline void init_mailbox(void)
154 IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC
);
155 IFX_REG_W32(0x00000000, MBOX_IGU1_IER
);
156 IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC
);
157 IFX_REG_W32(0x00000000, MBOX_IGU3_IER
);
160 static inline void init_atm_tc(void)
164 static inline void clear_share_buffer(void)
166 volatile u32
*p
= SB_RAM0_ADDR(0);
169 for ( i
= 0; i
< SB_RAM0_DWLEN
+ SB_RAM1_DWLEN
+ SB_RAM2_DWLEN
+ SB_RAM3_DWLEN
+ SB_RAM4_DWLEN
; i
++ )
175 * Download PPE firmware binary code.
177 * src --- u32 *, binary code buffer
178 * dword_len --- unsigned int, binary code length in DWORD (32-bit)
180 * int --- IFX_SUCCESS: Success
183 static inline int pp32_download_code(u32
*code_src
, unsigned int code_dword_len
, u32
*data_src
, unsigned int data_dword_len
)
187 if ( code_src
== 0 || ((unsigned long)code_src
& 0x03) != 0
188 || data_src
== 0 || ((unsigned long)data_src
& 0x03) != 0 )
191 if ( code_dword_len
<= CDM_CODE_MEMORYn_DWLEN(0) )
192 IFX_REG_W32(0x00, CDM_CFG
);
194 IFX_REG_W32(0x04, CDM_CFG
);
197 dest
= CDM_CODE_MEMORY(0, 0);
198 while ( code_dword_len
-- > 0 )
199 IFX_REG_W32(*code_src
++, dest
++);
202 dest
= CDM_DATA_MEMORY(0, 0);
203 while ( data_dword_len
-- > 0 )
204 IFX_REG_W32(*data_src
++, dest
++);
212 * ####################################
214 * ####################################
217 extern void ifx_atm_get_fw_ver(unsigned int *major
, unsigned int *minor
)
219 ASSERT(major
!= NULL
, "pointer is NULL");
220 ASSERT(minor
!= NULL
, "pointer is NULL");
222 #if (defined(ENABLE_ATM_RETX) && ENABLE_ATM_RETX) || defined(VER_IN_FIRMWARE)
223 *major
= FW_VER_ID
->major
;
224 *minor
= FW_VER_ID
->minor
;
226 *major
= ATM_FW_VER_MAJOR
;
227 *minor
= ATM_FW_VER_MINOR
;
231 void ifx_atm_init_chip(void)
243 clear_share_buffer();
246 void ifx_atm_uninit_chip(void)
253 * Initialize and start up PP32.
257 * int --- IFX_SUCCESS: Success
260 int ifx_pp32_start(int pp32
)
264 /* download firmware */
265 ret
= pp32_download_code(firmware_binary_code
, sizeof(firmware_binary_code
) / sizeof(*firmware_binary_code
), firmware_binary_data
, sizeof(firmware_binary_data
) / sizeof(*firmware_binary_data
));
266 if ( ret
!= IFX_SUCCESS
)
270 IFX_REG_W32(DBG_CTRL_RESTART
, PP32_DBG_CTRL(0));
272 /* idle for a while to let PP32 init itself */
286 void ifx_pp32_stop(int pp32
)
289 IFX_REG_W32(DBG_CTRL_STOP
, PP32_DBG_CTRL(0));
This page took 0.067501 seconds and 5 git commands to generate.