1 /******************************************************************************
3 ** FILE NAME : ifxmips_ptm_amazon_se.c
9 ** DESCRIPTION : PTM 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 <linux/platform_device.h>
44 #include <linux/reset.h>
45 #include <asm/delay.h>
48 * Chip Specific Head File
50 #include <asm/ifx/ifx_types.h>
51 #include <asm/ifx/ifx_regs.h>
52 #include <asm/ifx/common_routines.h>
53 #include <asm/ifx/ifx_pmu.h>
54 #include <asm/ifx/ifx_rcu.h>
55 #include "ifxmips_ptm_adsl.h"
56 #include "ifxmips_ptm_fw_amazon_se.h"
61 * ####################################
63 * ####################################
69 #define EMA_CMD_BUF_LEN 0x0040
70 #define EMA_CMD_BASE_ADDR (0x00001580 << 2)
71 #define EMA_DATA_BUF_LEN 0x0100
72 #define EMA_DATA_BASE_ADDR (0x00000B00 << 2)
73 #define EMA_WRITE_BURST 0x2
74 #define EMA_READ_BURST 0x2
79 * ####################################
81 * ####################################
85 * Hardware Init/Uninit Functions
87 static inline void init_pmu(void);
88 static inline void uninit_pmu(void);
89 static inline void reset_ppe(struct platform_device
*pdev
);
90 static inline void init_ema(void);
91 static inline void init_mailbox(void);
92 static inline void init_atm_tc(void);
93 static inline void clear_share_buffer(void);
98 * ####################################
100 * ####################################
106 * ####################################
108 * ####################################
111 static inline void init_pmu(void)
113 //*(unsigned long *)0xBF10201C &= ~((1 << 15) | (1 << 13) | (1 << 9));
114 //PPE_TOP_PMU_SETUP(IFX_PMU_ENABLE);
115 PPE_SLL01_PMU_SETUP(IFX_PMU_ENABLE
);
116 PPE_TC_PMU_SETUP(IFX_PMU_ENABLE
);
117 PPE_EMA_PMU_SETUP(IFX_PMU_ENABLE
);
118 //PPE_QSB_PMU_SETUP(IFX_PMU_ENABLE);
119 PPE_TPE_PMU_SETUP(IFX_PMU_ENABLE
);
120 DSL_DFE_PMU_SETUP(IFX_PMU_ENABLE
);
123 static inline void uninit_pmu(void)
125 PPE_SLL01_PMU_SETUP(IFX_PMU_DISABLE
);
126 PPE_TC_PMU_SETUP(IFX_PMU_DISABLE
);
127 PPE_EMA_PMU_SETUP(IFX_PMU_DISABLE
);
128 //PPE_QSB_PMU_SETUP(IFX_PMU_DISABLE);
129 PPE_TPE_PMU_SETUP(IFX_PMU_DISABLE
);
130 DSL_DFE_PMU_SETUP(IFX_PMU_DISABLE
);
131 //PPE_TOP_PMU_SETUP(IFX_PMU_DISABLE);
134 static inline void reset_ppe(struct platform_device
*pdev
)
137 unsigned int etop_cfg
;
138 unsigned int etop_mdio_cfg
;
139 unsigned int etop_ig_plen_ctrl
;
140 unsigned int enet_mac_cfg
;
142 etop_cfg
= *IFX_PP32_ETOP_CFG
;
143 etop_mdio_cfg
= *IFX_PP32_ETOP_MDIO_CFG
;
144 etop_ig_plen_ctrl
= *IFX_PP32_ETOP_IG_PLEN_CTRL
;
145 enet_mac_cfg
= *IFX_PP32_ENET_MAC_CFG
;
147 *IFX_PP32_ETOP_CFG
= (*IFX_PP32_ETOP_CFG
& ~0x03C0) | 0x0001;
150 ifx_rcu_rst(IFX_RCU_DOMAIN_PPE
, IFX_RCU_MODULE_PTM
);
152 *IFX_PP32_ETOP_MDIO_CFG
= etop_mdio_cfg
;
153 *IFX_PP32_ETOP_IG_PLEN_CTRL
= etop_ig_plen_ctrl
;
154 *IFX_PP32_ENET_MAC_CFG
= enet_mac_cfg
;
155 *IFX_PP32_ETOP_CFG
= etop_cfg
;
159 static inline void init_ema(void)
161 // Configure share buffer master selection
166 IFX_REG_W32((EMA_CMD_BUF_LEN
<< 16) | (EMA_CMD_BASE_ADDR
>> 2), EMA_CMDCFG
);
167 IFX_REG_W32((EMA_DATA_BUF_LEN
<< 16) | (EMA_DATA_BASE_ADDR
>> 2), EMA_DATACFG
);
168 IFX_REG_W32(0x000000FF, EMA_IER
);
169 IFX_REG_W32(EMA_READ_BURST
| (EMA_WRITE_BURST
<< 2), EMA_CFG
);
172 static inline void init_mailbox(void)
174 IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC
);
175 IFX_REG_W32(0x00000000, MBOX_IGU1_IER
);
176 IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC
);
177 IFX_REG_W32(0x00000000, MBOX_IGU3_IER
);
180 static inline void init_atm_tc(void)
182 IFX_REG_W32(0x0F00, DREG_AT_CTRL
);
183 IFX_REG_W32(0x3C00, DREG_AR_CTRL
);
184 IFX_REG_W32(0x0, DREG_AT_IDLE0
);
185 IFX_REG_W32(0x0, DREG_AT_IDLE1
);
186 IFX_REG_W32(0x0, DREG_AR_IDLE0
);
187 IFX_REG_W32(0x0, DREG_AR_IDLE1
);
188 IFX_REG_W32(0x0, RFBI_CFG
);
189 IFX_REG_W32(0x0200, SFSM_DBA0
);
190 IFX_REG_W32(0x0800, SFSM_DBA1
);
191 IFX_REG_W32(0x0321, SFSM_CBA0
);
192 IFX_REG_W32(0x0921, SFSM_CBA1
);
193 IFX_REG_W32(0x14011, SFSM_CFG0
);
194 IFX_REG_W32(0x14011, SFSM_CFG1
);
195 IFX_REG_W32(0x0332, FFSM_DBA0
);
196 IFX_REG_W32(0x0932, FFSM_DBA1
);
197 IFX_REG_W32(0x3000C, FFSM_CFG0
);
198 IFX_REG_W32(0x3000C, FFSM_CFG1
);
199 IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC0
);
200 IFX_REG_W32(0xF0D10000, FFSM_IDLE_HEAD_BC1
);
203 static inline void clear_share_buffer(void)
205 volatile u32
*p
= SB_RAM0_ADDR(0);
208 for ( i
= 0; i
< SB_RAM0_DWLEN
+ SB_RAM1_DWLEN
; i
++ )
214 * Download PPE firmware binary code.
216 * src --- u32 *, binary code buffer
217 * dword_len --- unsigned int, binary code length in DWORD (32-bit)
222 static inline int pp32_download_code(u32
*code_src
, unsigned int code_dword_len
, u32
*data_src
, unsigned int data_dword_len
)
226 if ( code_src
== 0 || ((unsigned long)code_src
& 0x03) != 0
227 || data_src
== 0 || ((unsigned long)data_src
& 0x03) != 0 )
230 if ( code_dword_len
<= CDM_CODE_MEMORYn_DWLEN(0) )
231 IFX_REG_W32(0x00, CDM_CFG
);
233 IFX_REG_W32(0x04, CDM_CFG
);
236 dest
= CDM_CODE_MEMORY(0, 0);
237 while ( code_dword_len
-- > 0 )
238 IFX_REG_W32(*code_src
++, dest
++);
241 dest
= CDM_DATA_MEMORY(0, 0);
242 while ( data_dword_len
-- > 0 )
243 IFX_REG_W32(*data_src
++, dest
++);
251 * ####################################
253 * ####################################
256 extern void ifx_ptm_get_fw_ver(unsigned int *major
, unsigned int *minor
)
258 ASSERT(major
!= NULL
, "pointer is NULL");
259 ASSERT(minor
!= NULL
, "pointer is NULL");
261 *major
= FW_VER_ID
->major
;
262 *minor
= FW_VER_ID
->minor
;
265 void ifx_ptm_init_chip(struct platform_device
*pdev
)
277 clear_share_buffer();
280 void ifx_ptm_uninit_chip(void)
287 * Initialize and start up PP32.
294 int ifx_pp32_start(int pp32
)
298 /* download firmware */
299 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
));
304 IFX_REG_W32(DBG_CTRL_RESTART
, PP32_DBG_CTRL(pp32
));
306 /* idle for a while to let PP32 init itself */
320 void ifx_pp32_stop(int pp32
)
323 IFX_REG_W32(DBG_CTRL_STOP
, PP32_DBG_CTRL(pp32
));