1 --- a/src/mps/drv_mps_vmmc_ar9.c
2 +++ b/src/mps/drv_mps_vmmc_ar9.c
4 #include "ifxos_interrupt.h"
6 /* board specific headers */
7 +#if !defined CONFIG_LANTIQ
8 #include <asm/ifx/ifx_regs.h>
9 #include <asm/ifx_vpe.h>
10 #include <asm/ifx/ifx_gpio.h>
13 +#include <lantiq_soc.h>
16 /* device specific headers */
17 #include "drv_mps_vmmc.h"
18 #include "drv_mps_vmmc_dbg.h"
19 #include "drv_mps_vmmc_device.h"
21 +const void (*ifx_bsp_basic_mps_decrypt)(unsigned int addr, int n) = NULL;
23 +#define IFX_MPS_SRAM IFXMIPS_MPS_SRAM
25 /* ============================= */
26 /* Local Macros & Definitions */
27 /* ============================= */
28 @@ -65,12 +74,7 @@ extern mps_comm_dev *pMPSDev;
29 IFX_void_t ifx_mps_release (IFX_void_t);
30 extern IFX_uint32_t ifx_mps_reset_structures (mps_comm_dev * pMPSDev);
31 extern IFX_int32_t ifx_mps_bufman_close (IFX_void_t);
32 -IFX_int32_t ifx_mps_wdog_callback (IFX_uint32_t wdog_cleared_ok_count);
33 extern IFXOS_event_t fw_ready_evt;
34 -/* ============================= */
35 -/* Local function declaration */
36 -/* ============================= */
37 -static IFX_int32_t ifx_mps_fw_wdog_start_ar9(IFX_void_t);
39 /* ============================= */
40 /* Local variable definition */
41 @@ -88,61 +92,6 @@ IFX_int32_t (*ifx_wdog_callback) (IFX_ui
42 ******************************************************************************/
45 - * Start AR9 EDSP firmware watchdog mechanism.
46 - * Called after download and startup of VPE1.
49 - * \return 0 IFX_SUCCESS
50 - * \return -1 IFX_ERROR
53 -IFX_int32_t ifx_mps_fw_wdog_start_ar9()
55 - /* vpe1_wdog_ctr should be set up in u-boot as
56 - "vpe1_wdog_ctr_addr=0xBF2001B0"; protection from incorrect or missing
58 - if (vpe1_wdog_ctr != VPE1_WDOG_CTR_ADDR)
60 - vpe1_wdog_ctr = VPE1_WDOG_CTR_ADDR;
63 - /* vpe1_wdog_timeout should be set up in u-boot as "vpe1_wdog_timeout =
64 - <value in ms>"; protection from insane setting */
65 - if (vpe1_wdog_timeout < VPE1_WDOG_TMOUT_MIN)
67 - vpe1_wdog_timeout = VPE1_WDOG_TMOUT_MIN;
69 - if (vpe1_wdog_timeout > VPE1_WDOG_TMOUT_MAX)
71 - vpe1_wdog_timeout = VPE1_WDOG_TMOUT_MAX;
74 - /* recalculate in jiffies */
75 - vpe1_wdog_timeout = vpe1_wdog_timeout * HZ / 1000;
77 - /* register BSP callback function */
79 - vpe1_sw_wdog_register_reset_handler (ifx_mps_wdog_callback))
81 - TRACE (MPS, DBG_LEVEL_HIGH,
82 - (KERN_ERR "[%s %s %d]: Unable to register WDT callback.\r\n",
83 - __FILE__, __func__, __LINE__));
87 - /* start software watchdog timer */
88 - if (IFX_SUCCESS != vpe1_sw_wdog_start (0))
90 - TRACE (MPS, DBG_LEVEL_HIGH,
92 - "[%s %s %d]: Error starting software watchdog timer.\r\n",
93 - __FILE__, __func__, __LINE__));
100 * Firmware download to Voice CPU
101 * This function performs a firmware download to the coprocessor.
103 @@ -292,6 +241,18 @@ IFX_int32_t ifx_mps_download_firmware (m
104 decryption. Subtract sizeof(u32) from length to avoid decryption
105 of data beyond the FW image code */
106 pFWDwnld->length -= sizeof(IFX_uint32_t);
107 + switch(ltq_soc_type()) {
109 + ifx_bsp_basic_mps_decrypt = (const void (*)(unsigned int, int))0xbf0017c4;
112 + ifx_bsp_basic_mps_decrypt = (const void (*)(unsigned int, int))0xbf001ea4;
114 + case SOC_TYPE_VR9_2:
115 + ifx_bsp_basic_mps_decrypt = (const void (*)(unsigned int, int))0xbf001f38;
118 + if (ifx_bsp_basic_mps_decrypt)
119 ifx_bsp_basic_mps_decrypt((IFX_uint32_t)cpu1_base_addr, pFWDwnld->length);
122 @@ -318,9 +279,6 @@ IFX_int32_t ifx_mps_download_firmware (m
126 - /* start FW watchdog mechanism */
127 - ifx_mps_fw_wdog_start_ar9();
130 return ifx_mps_get_fw_version (0);
132 @@ -345,8 +303,6 @@ IFX_int32_t ifx_mps_restart (IFX_void_t)
136 - /* start FW watchdog mechanism */
137 - ifx_mps_fw_wdog_start_ar9();
138 TRACE (MPS, DBG_LEVEL_HIGH, ("IFX_MPS: Restarting firmware..."));
139 return ifx_mps_get_fw_version (0);
141 @@ -361,10 +317,6 @@ IFX_void_t ifx_mps_shutdown (IFX_void_t)
145 - /* stop software watchdog timer */
146 - vpe1_sw_wdog_stop (0);
147 - /* clean up the BSP callback function */
148 - vpe1_sw_wdog_register_reset_handler (IFX_NULL);
152 @@ -387,8 +339,6 @@ IFX_void_t ifx_mps_reset (IFX_void_t)
153 /* if VPE1 is already started, stop it */
156 - /* stop software watchdog timer first */
157 - vpe1_sw_wdog_stop (0);
161 @@ -436,101 +386,6 @@ IFX_void_t ifx_mps_release (IFX_void_t)
166 - * This function is called by BSP (module softdog_vpe) in case if software
167 - * watchdog timer expiration is detected by BSP.
168 - * This function needs to be registered at BSP as WDT callback using
169 - * vpe1_sw_wdog_register_reset_handler() API.
171 - * \return 0 IFX_SUCCESS, cannot fail
172 - * \ingroup Internal
174 -IFX_int32_t ifx_mps_wdog_callback (IFX_uint32_t wdog_cleared_ok_count)
176 - IFX_uint32_t flags;
178 - TRACE (MPS, DBG_LEVEL_HIGH,
179 - ("MPS: watchdog callback! arg=0x%08x\r\n", wdog_cleared_ok_count));
182 - /* reset SmartSLIC */
183 - IFXOS_LOCKINT (flags);
184 - if (ifx_gpio_pin_reserve
185 - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
187 - TRACE (MPS, DBG_LEVEL_HIGH,
188 - (KERN_ERR "[%s %s %d]: GPIO port/pin reservation error.\r\n",
189 - __FILE__, __func__, __LINE__));
191 - /* P1_ALTSEL0.15 = 0 */
192 - if (ifx_gpio_altsel0_clear
193 - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
195 - TRACE (MPS, DBG_LEVEL_HIGH,
196 - (KERN_ERR "[%s %s %d]: GPIO error clearing ALTSEL0.\r\n", __FILE__,
197 - __func__, __LINE__));
199 - /* P1_ALTSEL1.15 = 0 */
200 - if (ifx_gpio_altsel1_clear
201 - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
203 - TRACE (MPS, DBG_LEVEL_HIGH,
204 - (KERN_ERR "[%s %s %d]: GPIO error clearing ALTSEL1.\r\n", __FILE__,
205 - __func__, __LINE__));
207 - /* P1_DIR.15 = 1 */
208 - if (ifx_gpio_dir_out_set
209 - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
211 - TRACE (MPS, DBG_LEVEL_HIGH,
212 - (KERN_ERR "[%s %s %d]: GPIO error setting DIR.\r\n", __FILE__,
213 - __func__, __LINE__));
216 - if (ifx_gpio_open_drain_set
217 - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
219 - TRACE (MPS, DBG_LEVEL_HIGH,
220 - (KERN_ERR "[%s %s %d]: GPIO error setting OD.\r\n", __FILE__,
221 - __func__, __LINE__));
223 - /* P1_OUT.15 = 0 */
224 - if (ifx_gpio_output_clear
225 - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
227 - TRACE (MPS, DBG_LEVEL_HIGH,
228 - (KERN_ERR "[%s %s %d]: GPIO error clearing OUT.\r\n", __FILE__,
229 - __func__, __LINE__));
231 - if (ifx_gpio_pin_free
232 - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
234 - TRACE (MPS, DBG_LEVEL_HIGH,
235 - (KERN_ERR "[%s %s %d]: GPIO port/pin freeing error.\r\n", __FILE__,
236 - __func__, __LINE__));
238 - IFXOS_UNLOCKINT (flags);
240 - /* recalculate and compare the firmware checksum */
241 - ifx_mps_fw_crc_compare(cpu1_base_addr, pFW_img_data);
243 - /* dump exception area on a console */
244 - ifx_mps_dump_fw_xcpt(cpu1_base_addr, pFW_img_data);
246 - if (IFX_NULL != ifx_wdog_callback)
248 - /* call VMMC driver */
249 - ifx_wdog_callback (wdog_cleared_ok_count);
253 - TRACE (MPS, DBG_LEVEL_HIGH,
254 - (KERN_WARNING "MPS: VMMC watchdog timer callback is NULL.\r\n"));
260 * Register WDT callback.
261 * This function is called by VMMC driver to register its callback in
263 --- a/src/drv_vmmc_amazon_s.h
264 +++ b/src/drv_vmmc_amazon_s.h
269 -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
270 -#include <asm/ifx/ifx_gpio.h>
272 +#if !defined(SYSTEM_AR9) && !defined(SYSTEM_VR9)
273 #error no system selected
278 #define VMMC_PCM_IF_CFG_HOOK(mode, GPIOreserved, ret) \
280 - ret = VMMC_statusOk; \
281 - /* Reserve P0.0 as TDM/FSC */ \
282 - if (!GPIOreserved) \
283 - ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
284 - ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
285 - ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
286 - ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID);\
288 - /* Reserve P1.9 as TDM/DO */ \
289 - if (!GPIOreserved) \
290 - ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
291 - ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
292 - ret |= ifx_gpio_altsel1_clear(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
293 - ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
294 - ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
296 - /* Reserve P2.9 as TDM/DI */ \
297 - if (!GPIOreserved) \
298 - ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID); \
299 - ret |= ifx_gpio_altsel0_clear(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID); \
300 - ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID);\
301 - ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID); \
303 - /* Reserve P2.8 as TDM/DCL */ \
304 - if (!GPIOreserved) \
305 - ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
306 - ret |= ifx_gpio_altsel0_clear(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
307 - ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
308 - ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
311 - /* TDM/FSC+DCL Master */ \
312 - ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
313 - ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
315 - /* TDM/FSC+DCL Slave */ \
316 - ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
317 - ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
322 @@ -73,11 +32,6 @@ do { \
324 #define VMMC_DRIVER_UNLOAD_HOOK(ret) \
326 - ret = VMMC_statusOk; \
327 - ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
328 - ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
329 - ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID); \
330 - ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
333 #endif /* _DRV_VMMC_AMAZON_S_H */