1
0

400-falcon.patch 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  1. --- a/configure.in
  2. +++ b/configure.in
  3. @@ -956,14 +956,15 @@ AC_DEFINE([VMMC],[1],[enable VMMC suppor
  4. AM_CONDITIONAL(DANUBE, false)
  5. AM_CONDITIONAL(AR9, false)
  6. AM_CONDITIONAL(VR9, false)
  7. +AM_CONDITIONAL(FALCON, false)
  8. AC_ARG_WITH(device,
  9. AC_HELP_STRING(
  10. - [--with-device=DANUBE|TWINPASS|AR9|VR9],
  11. + [--with-device=DANUBE|TWINPASS|AR9|VR9|FALCON],
  12. [Set device type, default is DANUBE]
  13. ),
  14. [
  15. if test "$withval" = yes; then
  16. - AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9]);
  17. + AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9|FALCON]);
  18. else
  19. case $withval in
  20. DANUBE)
  21. @@ -986,8 +987,13 @@ AC_ARG_WITH(device,
  22. AC_DEFINE([SYSTEM_VR9],[1],[enable VR9 specific code])
  23. AM_CONDITIONAL(VR9, true)
  24. ;;
  25. + FALCON)
  26. + AC_MSG_RESULT(FALCON device is used);
  27. + AC_DEFINE([SYSTEM_FALCON],[1],[enable FALCON specific code])
  28. + AM_CONDITIONAL(FALCON, true)
  29. + ;;
  30. *)
  31. - AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9]);
  32. + AC_MSG_ERROR([Set device type! Valid choices are DANUBE|TWINPASS|AR9|VR9|FALCON]);
  33. ;;
  34. esac
  35. fi
  36. --- a/src/Makefile.am
  37. +++ b/src/Makefile.am
  38. @@ -70,6 +70,11 @@ drv_vmmc_SOURCES +=\
  39. mps/drv_mps_vmmc_ar9.c
  40. endif
  41. +if FALCON
  42. +drv_vmmc_SOURCES +=\
  43. + mps/drv_mps_vmmc_falcon.c
  44. +endif
  45. +
  46. endif
  47. if PMC_SUPPORT
  48. --- a/drv_version.h
  49. +++ b/drv_version.h
  50. @@ -36,6 +36,10 @@
  51. #define MIN_FW_MAJORSTEP 2
  52. #define MIN_FW_MINORSTEP 1
  53. #define MIN_FW_HOTFIXSTEP 0
  54. +#elif defined(SYSTEM_FALCON)
  55. +#define MIN_FW_MAJORSTEP 0
  56. +#define MIN_FW_MINORSTEP 1
  57. +#define MIN_FW_HOTFIXSTEP 0
  58. #else
  59. #error unknown system
  60. #endif
  61. --- a/src/drv_vmmc_bbd.c
  62. +++ b/src/drv_vmmc_bbd.c
  63. @@ -34,6 +34,7 @@
  64. #define VMMC_WL_SDD_BASIC_CFG 0x04000400
  65. #define VMMC_WL_SDD_RING_CFG 0x04000500
  66. #define VMMC_WL_SDD_DCDC_CFG 0x04000C00
  67. +#define VMMC_WL_SDD_MWI_CFG 0x04000600
  68. #define IDLE_EXT_TOGGLE_SLEEP_MS 5
  69. @@ -52,6 +53,8 @@
  70. #define BBD_VMMC_MAGIC 0x41523921 /* "AR9" */
  71. #elif defined(SYSTEM_VR9)
  72. #define BBD_VMMC_MAGIC 0x56523921 /* "VR9" */
  73. +#elif defined(SYSTEM_FALCON)
  74. +#define BBD_VMMC_MAGIC 0x46414C43 /* "FALC" */
  75. #else
  76. #error system undefined
  77. #endif
  78. @@ -525,9 +528,6 @@ static IFX_int32_t VMMC_BBD_BlockHandler
  79. IFX_uint16_t slic_val;
  80. IFX_int32_t ret = IFX_SUCCESS;
  81. - TRACE(VMMC, DBG_LEVEL_LOW,
  82. - ("bbd block with tag 0x%04X passed\n", pBBDblock->tag));
  83. -
  84. /* for FXO line allowed blocks are FXO_CRAM and TRANSPARENT */
  85. if (pCh->pALM->line_type_fxs != IFX_TRUE)
  86. {
  87. @@ -686,6 +686,7 @@ static IFX_int32_t VMMC_BBD_BlockHandler
  88. break;
  89. }
  90. } /* if */
  91. +
  92. return ret;
  93. }
  94. @@ -1026,6 +1027,7 @@ static IFX_int32_t vmmc_BBD_WhiteListedC
  95. }
  96. case VMMC_WL_SDD_RING_CFG:
  97. case VMMC_WL_SDD_DCDC_CFG:
  98. + case VMMC_WL_SDD_MWI_CFG:
  99. ret = CmdWrite (pCh->pParent, Msg.val, Msg.cmd.LENGTH);
  100. break;
  101. @@ -1068,7 +1070,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
  102. IFX_uint32_t countWords;
  103. IFX_uint32_t posBytes = 0;
  104. IFX_uint8_t lenBytes, *pByte;
  105. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  106. +#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  107. IFX_uint8_t padBytes = 0;
  108. #endif
  109. IFX_uint16_t cram_offset, cram_crc,
  110. @@ -1088,7 +1090,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
  111. #ifdef SYSTEM_DANUBE
  112. /* CMD1 is a COP command */
  113. pCmd[0] = (0x0200) | (pCh->nChannel - 1);
  114. -#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  115. +#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  116. /* SDD_Coef command */
  117. pCmd[0] = (0x0400) | (pCh->nChannel - 1);
  118. pCmd[1] = (0x0D00);
  119. @@ -1111,7 +1113,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
  120. pCmd[1] = ((cram_offset + (posBytes >> 1)) << 8);
  121. /* set CRAM data while taking care of endianess */
  122. cpb2w (&pCmd[2], &pByte[posBytes], lenBytes);
  123. -#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  124. +#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  125. /* calculate length to download (in words = 16bit),
  126. maximum allowed length for this message is 56 Bytes = 28 Words */
  127. if (countWords > ((MAX_CMD_WORD - CMD_HDR_CNT - 1)))
  128. @@ -1140,7 +1142,7 @@ static IFX_int32_t vmmc_BBD_DownloadChCr
  129. /* write Data */
  130. #if defined SYSTEM_DANUBE
  131. ret = CmdWrite (pCh->pParent, (IFX_uint32_t *) pCmd, lenBytes);
  132. -#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  133. +#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  134. #if 1
  135. /* lenBytes + 2 bytes for block offset/length which are not calculated
  136. in the download progress */
  137. --- a/src/mps/drv_mps_version.h
  138. +++ b/src/mps/drv_mps_version.h
  139. @@ -17,7 +17,7 @@
  140. #define VERSIONSTEP 2
  141. #define VERS_TYPE 5
  142. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  143. +#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  144. #define IFX_MPS_PLATFORM_NAME "MIPS34KEc"
  145. #elif defined(SYSTEM_DANUBE)
  146. #define IFX_MPS_PLATFORM_NAME "MIPS24KEc"
  147. --- a/src/mps/drv_mps_vmmc_linux.c
  148. +++ b/src/mps/drv_mps_vmmc_linux.c
  149. @@ -2229,7 +2229,7 @@ IFX_int32_t __init ifx_mps_init_module (
  150. #if defined(CONFIG_MIPS) && !defined(CONFIG_MIPS_UNCACHED)
  151. #if defined(SYSTEM_DANUBE)
  152. bDoCacheOps = IFX_TRUE; /* on Danube always perform cache ops */
  153. -#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  154. +#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  155. /* on AR9/VR9 cache is configured by BSP;
  156. here we check whether the D-cache is shared or partitioned;
  157. 1) in case of shared D-cache all cache operations are omitted;
  158. @@ -2259,7 +2259,8 @@ IFX_int32_t __init ifx_mps_init_module (
  159. /* reset the device before initializing the device driver */
  160. ifx_mps_reset ();
  161. - result = request_irq (INT_NUM_IM4_IRL18,
  162. +
  163. + result = request_irq (INT_NUM_IM4_IRL18,
  164. #ifdef LINUX_2_6
  165. ifx_mps_ad0_irq, 0x0
  166. #else /* */
  167. @@ -2400,7 +2401,7 @@ IFX_int32_t __init ifx_mps_init_module (
  168. if (result = ifx_mps_init_gpt_danube ())
  169. return result;
  170. #endif /*DANUBE*/
  171. - TRACE (MPS, DBG_LEVEL_HIGH, ("Downloading Firmware...\n"));
  172. + TRACE (MPS, DBG_LEVEL_HIGH, ("Downloading Firmware...\n"));
  173. ifx_mps_download_firmware (IFX_NULL, (mps_fw *) 0xa0a00000);
  174. udelay (500);
  175. TRACE (MPS, DBG_LEVEL_HIGH, ("Providing Buffers...\n"));
  176. --- /dev/null
  177. +++ b/src/mps/drv_mps_vmmc_falcon.c
  178. @@ -0,0 +1,396 @@
  179. +/******************************************************************************
  180. +
  181. + Copyright (c) 2009
  182. + Lantiq Deutschland GmbH
  183. + Am Campeon 3; 85579 Neubiberg, Germany
  184. +
  185. + For licensing information, see the file 'LICENSE' in the root folder of
  186. + this software module.
  187. +
  188. +****************************************************************************
  189. + Module : drv_mps_vmmc_falcon.c
  190. + Description : This file contains the implementation of the FALC-ON specific
  191. + driver functions.
  192. +*******************************************************************************/
  193. +
  194. +/* ============================= */
  195. +/* Includes */
  196. +/* ============================= */
  197. +#include "drv_config.h"
  198. +
  199. +#if defined(SYSTEM_FALCON) /* defined in drv_config.h */
  200. +
  201. +/* lib_ifxos headers */
  202. +#include "ifx_types.h"
  203. +#include "ifxos_linux_drv.h"
  204. +#include "ifxos_copy_user_space.h"
  205. +#include "ifxos_event.h"
  206. +#include "ifxos_lock.h"
  207. +#include "ifxos_select.h"
  208. +#include "ifxos_interrupt.h"
  209. +#include <linux/gpio.h>
  210. +#include <sys1_reg.h>
  211. +#include <falcon.h>
  212. +#include <falcon_irq.h>
  213. +#include <vpe.h>
  214. +#include <sysctrl.h>
  215. +void (*ifx_bsp_basic_mps_decrypt)(unsigned int addr, int n) = (void (*)(unsigned int, int))0xbf000290;
  216. +
  217. +#define IFX_MPS_SRAM IFXMIPS_MPS_SRAM
  218. +
  219. +/*#define USE_PLAIN_VOICE_FIRMWARE*/
  220. +/* board specific headers */
  221. +
  222. +/* device specific headers */
  223. +#include "drv_mps_vmmc.h"
  224. +#include "drv_mps_vmmc_dbg.h"
  225. +#include "drv_mps_vmmc_device.h"
  226. +
  227. +/* ============================= */
  228. +/* Local Macros & Definitions */
  229. +/* ============================= */
  230. +/* Firmware watchdog timer counter address */
  231. +#define VPE1_WDOG_CTR_ADDR ((IFX_uint32_t)((IFX_uint8_t* )IFX_MPS_SRAM + 432))
  232. +
  233. +/* Firmware watchdog timeout range, values in ms */
  234. +#define VPE1_WDOG_TMOUT_MIN 20
  235. +#define VPE1_WDOG_TMOUT_MAX 5000
  236. +
  237. +/* ============================= */
  238. +/* Global variable definition */
  239. +/* ============================= */
  240. +extern mps_comm_dev *pMPSDev;
  241. +
  242. +/* ============================= */
  243. +/* Global function declaration */
  244. +/* ============================= */
  245. +IFX_void_t ifx_mps_release (IFX_void_t);
  246. +extern IFX_uint32_t ifx_mps_reset_structures (mps_comm_dev * pMPSDev);
  247. +extern IFX_int32_t ifx_mps_bufman_close (IFX_void_t);
  248. +extern IFXOS_event_t fw_ready_evt;
  249. +
  250. +/* ============================= */
  251. +/* Local variable definition */
  252. +/* ============================= */
  253. +static IFX_int32_t vpe1_started = 0;
  254. +/* VMMC watchdog timer callback */
  255. +IFX_int32_t (*ifx_wdog_callback) (IFX_uint32_t flags) = IFX_NULL;
  256. +
  257. +/* ============================= */
  258. +/* Local function definition */
  259. +/* ============================= */
  260. +
  261. +/******************************************************************************
  262. + * AR9 Specific Routines
  263. + ******************************************************************************/
  264. +
  265. +/**
  266. + * Firmware download to Voice CPU
  267. + * This function performs a firmware download to the coprocessor.
  268. + *
  269. + * \param pMBDev Pointer to mailbox device structure
  270. + * \param pFWDwnld Pointer to firmware structure
  271. + * \return 0 IFX_SUCCESS, firmware ready
  272. + * \return -1 IFX_ERROR, firmware not downloaded.
  273. + * \ingroup Internal
  274. + */
  275. +IFX_int32_t ifx_mps_download_firmware (mps_mbx_dev *pMBDev, mps_fw *pFWDwnld)
  276. +{
  277. + IFX_uint32_t mem, cksum;
  278. + IFX_uint8_t crc;
  279. + IFX_boolean_t bMemReqNotPresent = IFX_FALSE;
  280. +
  281. + /* VCC register */
  282. + /* dummy accesss on GTC for GPONC-55, otherwise upper bits are random on read */
  283. + ltq_r32 ((u32 *)((KSEG1 | 0x1DC000B0)));
  284. + /* NTR Frequency Select 1536 kHz per default or take existing,
  285. + NTR Output Enable and NTR8K Output Enable */
  286. + if ((ltq_r32 ((u32 *)(GPON_SYS_BASE + 0xBC)) & 7) == 0)
  287. + ltq_w32_mask (0x10187, 0x183, (u32 *)(GPON_SYS_BASE + 0xBC));
  288. + else
  289. + ltq_w32_mask (0x10180, 0x180, (u32 *)(GPON_SYS_BASE + 0xBC));
  290. +#if 0
  291. + /* BIU-ICU1-IM1_ISR - IM1:FSCT_CMP1=1 and FSC_ROOT=1
  292. + (0x1f880328 = 0x00002800) */
  293. + ltq_w32 (0x00002800, (u32 *)(GPON_ICU1_BASE + 0x30));
  294. +#endif
  295. + /* copy FW footer from user space */
  296. + if (IFX_NULL == IFXOS_CpyFromUser(pFW_img_data,
  297. + pFWDwnld->data+pFWDwnld->length/4-sizeof(*pFW_img_data)/4,
  298. + sizeof(*pFW_img_data)))
  299. + {
  300. + TRACE (MPS, DBG_LEVEL_HIGH,
  301. + (KERN_ERR "[%s %s %d]: copy_from_user error\r\n",
  302. + __FILE__, __func__, __LINE__));
  303. + return IFX_ERROR;
  304. + }
  305. +
  306. + mem = pFW_img_data->mem;
  307. +
  308. + /* memory requirement sanity check */
  309. + if ((crc = ~((mem >> 16) + (mem >> 8) + mem)) != (mem >> 24))
  310. + {
  311. + TRACE (MPS, DBG_LEVEL_HIGH,
  312. + ("[%s %s %d]: warning, image does not contain size - assuming 1MB!\n",
  313. + __FILE__, __func__, __LINE__));
  314. + mem = 1 * 1024 * 1024;
  315. + bMemReqNotPresent = IFX_TRUE;
  316. + }
  317. + else
  318. + {
  319. + mem &= 0x00FFFFFF;
  320. + }
  321. +
  322. + /* check if FW image fits in available memory space */
  323. + if (mem > vpe1_get_max_mem(0))
  324. + {
  325. + TRACE (MPS, DBG_LEVEL_HIGH,
  326. + ("[%s %s %d]: error, firmware memory exceeds reserved space (%i > %i)!\n",
  327. + __FILE__, __func__, __LINE__, mem, vpe1_get_max_mem(0)));
  328. + return IFX_ERROR;
  329. + }
  330. +
  331. + /* reset the driver */
  332. + ifx_mps_reset ();
  333. +
  334. + /* call BSP to get cpu1 base address */
  335. + cpu1_base_addr = (IFX_uint32_t *)vpe1_get_load_addr(0);
  336. +
  337. + /* check if CPU1 base address is sane
  338. + \todo: check if address is 1MB aligned,
  339. + also make it visible in a /proc fs */
  340. + if (!cpu1_base_addr)
  341. + {
  342. + TRACE (MPS, DBG_LEVEL_HIGH,
  343. + (KERN_ERR "IFX_MPS: CPU1 base address is invalid!\r\n"));
  344. + return IFX_ERROR;
  345. + }
  346. + /* further use uncached value */
  347. + cpu1_base_addr = (IFX_uint32_t *)KSEG1ADDR(cpu1_base_addr);
  348. +
  349. + /* free all data buffers that might be currently used by FW */
  350. + if (IFX_NULL != ifx_mps_bufman_freeall)
  351. + {
  352. + ifx_mps_bufman_freeall();
  353. + }
  354. +
  355. + if(FW_FORMAT_NEW)
  356. + {
  357. + /* adjust download length */
  358. + pFWDwnld->length -= (sizeof(*pFW_img_data)-sizeof(IFX_uint32_t));
  359. + }
  360. + else
  361. + {
  362. + pFWDwnld->length -= sizeof(IFX_uint32_t);
  363. +
  364. + /* handle unlikely case if FW image does not contain memory requirement -
  365. + assumed for old format only */
  366. + if (IFX_TRUE == bMemReqNotPresent)
  367. + pFWDwnld->length += sizeof(IFX_uint32_t);
  368. +
  369. + /* in case of old FW format always assume that FW is encrypted;
  370. + use compile switch USE_PLAIN_VOICE_FIRMWARE for plain FW */
  371. +#ifndef USE_PLAIN_VOICE_FIRMWARE
  372. + pFW_img_data->enc = 1;
  373. +#else
  374. +#warning Using unencrypted firmware!
  375. + pFW_img_data->enc = 0;
  376. +#endif /* USE_PLAIN_VOICE_FIRMWARE */
  377. + /* initializations for the old format */
  378. + pFW_img_data->st_addr_crc = 2*sizeof(IFX_uint32_t) +
  379. + FW_AR9_OLD_FMT_XCPT_AREA_SZ;
  380. + pFW_img_data->en_addr_crc = pFWDwnld->length;
  381. + pFW_img_data->fw_vers = 0;
  382. + pFW_img_data->magic = 0;
  383. + }
  384. +
  385. + /* copy FW image to base address of CPU1 */
  386. + if (IFX_NULL ==
  387. + IFXOS_CpyFromUser ((IFX_void_t *)cpu1_base_addr,
  388. + (IFX_void_t *)pFWDwnld->data, pFWDwnld->length))
  389. + {
  390. + TRACE (MPS, DBG_LEVEL_HIGH,
  391. + (KERN_ERR "[%s %s %d]: copy_from_user error\r\n", __FILE__,
  392. + __func__, __LINE__));
  393. + return IFX_ERROR;
  394. + }
  395. +
  396. + /* process firmware decryption */
  397. + if (pFW_img_data->enc == 1)
  398. + {
  399. + if(FW_FORMAT_NEW)
  400. + {
  401. + /* adjust decryption length (avoid decrypting CRC32 checksum) */
  402. + pFWDwnld->length -= sizeof(IFX_uint32_t);
  403. + }
  404. + /* BootROM actually decrypts n+4 bytes if n bytes were passed for
  405. + decryption. Subtract sizeof(u32) from length to avoid decryption
  406. + of data beyond the FW image code */
  407. + pFWDwnld->length -= sizeof(IFX_uint32_t);
  408. + ifx_bsp_basic_mps_decrypt((unsigned int)cpu1_base_addr, pFWDwnld->length);
  409. + }
  410. +
  411. + /* calculate CRC32 checksum over downloaded image */
  412. + cksum = ifx_mps_fw_crc32(cpu1_base_addr, pFW_img_data);
  413. +
  414. + /* verify the checksum */
  415. + if(FW_FORMAT_NEW)
  416. + {
  417. + if (cksum != pFW_img_data->crc32)
  418. + {
  419. + TRACE (MPS, DBG_LEVEL_HIGH,
  420. + ("MPS: FW checksum error: img=0x%08x calc=0x%08x\r\n",
  421. + pFW_img_data->crc32, cksum));
  422. + return IFX_ERROR;
  423. + }
  424. + }
  425. + else
  426. + {
  427. + /* just store self-calculated checksum */
  428. + pFW_img_data->crc32 = cksum;
  429. + }
  430. +
  431. + /* start VPE1 */
  432. + ifx_mps_release ();
  433. +
  434. + /* get FW version */
  435. + return ifx_mps_get_fw_version (0);
  436. +}
  437. +
  438. +
  439. +/**
  440. + * Restart CPU1
  441. + * This function restarts CPU1 by accessing the reset request register and
  442. + * reinitializes the mailbox.
  443. + *
  444. + * \return 0 IFX_SUCCESS, successful restart
  445. + * \return -1 IFX_ERROR, if reset failed
  446. + * \ingroup Internal
  447. + */
  448. +IFX_int32_t ifx_mps_restart (IFX_void_t)
  449. +{
  450. + /* raise reset request for CPU1 and reset driver structures */
  451. + ifx_mps_reset ();
  452. + /* Disable GPTC Interrupt to CPU1 */
  453. + ifx_mps_shutdown_gpt ();
  454. + /* re-configure GPTC */
  455. + ifx_mps_init_gpt ();
  456. + /* let CPU1 run */
  457. + ifx_mps_release ();
  458. + TRACE (MPS, DBG_LEVEL_HIGH, ("IFX_MPS: Restarting firmware..."));
  459. + return ifx_mps_get_fw_version (0);
  460. +}
  461. +
  462. +/**
  463. + * Shutdown MPS - stop VPE1
  464. + * This function stops VPE1
  465. + *
  466. + * \ingroup Internal
  467. + */
  468. +IFX_void_t ifx_mps_shutdown (IFX_void_t)
  469. +{
  470. + if (vpe1_started)
  471. + {
  472. + /* stop VPE1 */
  473. + vpe1_sw_stop (0);
  474. + vpe1_started = 0;
  475. + }
  476. + /* free GPTC */
  477. + ifx_mps_shutdown_gpt ();
  478. +}
  479. +
  480. +/**
  481. + * Reset CPU1
  482. + * This function causes a reset of CPU1 by clearing the CPU0 boot ready bit
  483. + * in the reset request register RCU_RST_REQ.
  484. + * It does not change the boot configuration registers for CPU0 or CPU1.
  485. + *
  486. + * \return 0 IFX_SUCCESS, cannot fail
  487. + * \ingroup Internal
  488. + */
  489. +IFX_void_t ifx_mps_reset (IFX_void_t)
  490. +{
  491. + /* if VPE1 is already started, stop it */
  492. + if (vpe1_started)
  493. + {
  494. + vpe1_sw_stop (0);
  495. + vpe1_started = 0;
  496. + }
  497. +
  498. + /* reset driver */
  499. + ifx_mps_reset_structures (pMPSDev);
  500. + ifx_mps_bufman_close ();
  501. + return;
  502. +}
  503. +
  504. +/**
  505. + * Let CPU1 run
  506. + * This function starts VPE1
  507. + *
  508. + * \return none
  509. + * \ingroup Internal
  510. + */
  511. +IFX_void_t ifx_mps_release (IFX_void_t)
  512. +{
  513. + IFX_int_t ret;
  514. + IFX_int32_t RetCode = 0;
  515. +
  516. + /* Start VPE1 */
  517. + if (IFX_SUCCESS !=
  518. + vpe1_sw_start ((IFX_void_t *)cpu1_base_addr, 0, 0))
  519. + {
  520. + TRACE (MPS, DBG_LEVEL_HIGH, (KERN_ERR "Error starting VPE1\r\n"));
  521. + return;
  522. + }
  523. + vpe1_started = 1;
  524. +
  525. + /* sleep 3 seconds until FW is ready */
  526. + ret = IFXOS_EventWait (&fw_ready_evt, 3000, &RetCode);
  527. + if ((ret == IFX_ERROR) && (RetCode == 1))
  528. + {
  529. + /* timeout */
  530. + TRACE (MPS, DBG_LEVEL_HIGH,
  531. + (KERN_ERR "[%s %s %d]: Timeout waiting for firmware ready.\r\n",
  532. + __FILE__, __func__, __LINE__));
  533. + /* recalculate and compare the firmware checksum */
  534. + ifx_mps_fw_crc_compare(cpu1_base_addr, pFW_img_data);
  535. + /* dump exception area on a console */
  536. + ifx_mps_dump_fw_xcpt(cpu1_base_addr, pFW_img_data);
  537. + }
  538. +}
  539. +
  540. +/**
  541. + * Register WDT callback.
  542. + * This function is called by VMMC driver to register its callback in
  543. + * the MPS driver.
  544. + *
  545. + * \return 0 IFX_SUCCESS, cannot fail
  546. + * \ingroup Internal
  547. + */
  548. +IFX_int32_t
  549. +ifx_mps_register_wdog_callback (IFX_int32_t (*pfn) (IFX_uint32_t flags))
  550. +{
  551. + ifx_wdog_callback = pfn;
  552. + return 0;
  553. +}
  554. +
  555. +/**
  556. + Hardware setup on FALC ON
  557. +*/
  558. +void sys_hw_setup (void)
  559. +{
  560. + /* Set INFRAC register bit 1: clock enable of the GPE primary clock. */
  561. + sys_gpe_hw_activate (0);
  562. + /* enable 1.5 V */
  563. + ltq_w32_mask (0xf, 0x0b, (u32 *)(GPON_SYS1_BASE | 0xbc));
  564. + /* SYS1-CLKEN:GPTC = 1 and MPS, no longer FSCT = 1 */
  565. + sys1_hw_activate (ACTS_MPS | ACTS_GPTC);
  566. + /* GPTC:CLC:RMC = 1 */
  567. + ltq_w32 (0x00000100, (u32 *)(KSEG1 | 0x1E100E00));
  568. +}
  569. +
  570. +#ifndef VMMC_WITH_MPS
  571. +EXPORT_SYMBOL (ifx_mps_register_wdog_callback);
  572. +#endif /* !VMMC_WITH_MPS */
  573. +
  574. +#endif /* SYSTEM_FALCON */
  575. --- a/src/mps/drv_mps_vmmc_common.c
  576. +++ b/src/mps/drv_mps_vmmc_common.c
  577. @@ -66,6 +66,10 @@ static void inline bsp_mask_and_ack_irq(
  578. # include <asm/ifx/ifx_regs.h>
  579. # include <asm/ifx/ifx_gptu.h>
  580. #endif
  581. +#if defined(SYSTEM_FALCON)
  582. +#include <sys1_reg.h>
  583. +#include <sysctrl.h>
  584. +#endif
  585. #include "drv_mps_vmmc.h"
  586. #include "drv_mps_vmmc_dbg.h"
  587. @@ -1156,7 +1160,12 @@ IFX_uint32_t ifx_mps_init_structures (mp
  588. mailbox, * upstream and downstream direction. */
  589. memset (
  590. /* avoid to overwrite CPU boot registers */
  591. +#if defined(SYSTEM_FALCON)
  592. + (IFX_void_t *) MBX_Memory +
  593. + 2 * sizeof (mps_boot_cfg_reg),
  594. +#else
  595. (IFX_void_t *) MBX_Memory,
  596. +#endif
  597. 0,
  598. sizeof (mps_mbx_reg) - 2 * sizeof (mps_boot_cfg_reg));
  599. MBX_Memory->MBX_UPSTR_CMD_BASE =
  600. @@ -2651,7 +2660,6 @@ IFX_void_t ifx_mps_enable_mailbox_int ()
  601. #endif
  602. *IFX_MPS_AD0ENR = Ad0Reg.val;
  603. -
  604. }
  605. /**
  606. @@ -2669,6 +2677,7 @@ IFX_void_t ifx_mps_disable_mailbox_int (
  607. Ad0Reg.fld.cu_mbx = 0;
  608. Ad0Reg.fld.du_mbx = 0;
  609. *IFX_MPS_AD0ENR = Ad0Reg.val;
  610. +
  611. }
  612. /**
  613. @@ -2766,11 +2775,13 @@ irqreturn_t ifx_mps_ad0_irq (IFX_int32_t
  614. /* handle only enabled interrupts */
  615. MPS_Ad0StatusReg.val &= *IFX_MPS_AD0ENR;
  616. +#if !defined(SYSTEM_FALCON)
  617. #ifdef LINUX_2_6
  618. bsp_mask_and_ack_irq (irq);
  619. #else /* */
  620. mask_and_ack_danube_irq (irq);
  621. #endif /* */
  622. +#endif /* !defined(SYSTEM_FALCON) */
  623. /* FW is up and ready to process commands */
  624. if (MPS_Ad0StatusReg.fld.dl_end)
  625. {
  626. @@ -2919,11 +2930,13 @@ irqreturn_t ifx_mps_ad1_irq (IFX_int32_t
  627. /* handle only enabled interrupts */
  628. MPS_Ad1StatusReg.val &= *IFX_MPS_AD1ENR;
  629. +#if !defined(SYSTEM_FALCON)
  630. #ifdef LINUX_2_6
  631. bsp_mask_and_ack_irq (irq);
  632. #else /* */
  633. mask_and_ack_danube_irq (irq);
  634. #endif /* */
  635. +#endif /* !defined(SYSTEM_FALCON) */
  636. pMPSDev->event.MPS_Ad1Reg.val = MPS_Ad1StatusReg.val;
  637. /* use callback function or queue wake up to notify about data reception */
  638. @@ -2977,11 +2990,13 @@ irqreturn_t ifx_mps_vc_irq (IFX_int32_t
  639. IFX_MPS_CVC0SR[chan] = MPS_VCStatusReg.val;
  640. /* handle only enabled interrupts */
  641. MPS_VCStatusReg.val &= IFX_MPS_VC0ENR[chan];
  642. +#if !defined(SYSTEM_FALCON)
  643. #ifdef LINUX_2_6
  644. bsp_mask_and_ack_irq (irq);
  645. #else /* */
  646. mask_and_ack_danube_irq (irq);
  647. #endif /* */
  648. +#endif /* !defined(SYSTEM_FALCON) */
  649. pMPSDev->event.MPS_VCStatReg[chan].val = MPS_VCStatusReg.val;
  650. #ifdef PRINT_ON_ERR_INTERRUPT
  651. @@ -3126,6 +3141,7 @@ IFX_int32_t ifx_mps_get_fw_version (IFX_
  652. */
  653. IFX_return_t ifx_mps_init_gpt ()
  654. {
  655. +#if !defined(SYSTEM_FALCON)
  656. unsigned long flags;
  657. IFX_uint32_t timer_flags, timer, loops = 0;
  658. IFX_ulong_t count;
  659. @@ -3134,7 +3150,11 @@ IFX_return_t ifx_mps_init_gpt ()
  660. #else /* Danube */
  661. timer = TIMER1B;
  662. #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
  663. +#endif
  664. +#if defined(SYSTEM_FALCON)
  665. + sys_hw_setup ();
  666. +#else
  667. /* calibration loop - required to syncronize GPTC interrupt with falling
  668. edge of FSC clock */
  669. timer_flags =
  670. @@ -3179,7 +3199,7 @@ Probably already in use.\r\n", __FILE__,
  671. #endif /* DEBUG */
  672. IFXOS_UNLOCKINT (flags);
  673. -
  674. +#endif
  675. return IFX_SUCCESS;
  676. }
  677. @@ -3194,6 +3214,9 @@ Probably already in use.\r\n", __FILE__,
  678. */
  679. IFX_void_t ifx_mps_shutdown_gpt (IFX_void_t)
  680. {
  681. +#if defined(SYSTEM_FALCON)
  682. + sys1_hw_deactivate (ACTS_MPS);
  683. +#else
  684. IFX_uint32_t timer;
  685. #if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  686. timer = TIMER1A;
  687. @@ -3202,6 +3225,7 @@ IFX_void_t ifx_mps_shutdown_gpt (IFX_voi
  688. #endif /* SYSTEM_AR9 || SYSTEM_VR9 */
  689. ifx_gptu_timer_free (timer);
  690. +#endif
  691. }
  692. /**
  693. --- a/src/mps/drv_mps_vmmc_device.h
  694. +++ b/src/mps/drv_mps_vmmc_device.h
  695. @@ -22,7 +22,12 @@
  696. # include <lantiq_soc.h>
  697. # include <linux/gpio.h>
  698. #define IFXMIPS_MPS_SRAM ((u32 *)(KSEG1 + 0x1F200000))
  699. +#if defined(SYSTEM_FALCON)
  700. +#define IFXMIPS_MPS_BASE_ADDR (KSEG1 + 0x1D004000)
  701. +#else
  702. #define IFXMIPS_MPS_BASE_ADDR (KSEG1 + 0x1F107000)
  703. +#endif
  704. +
  705. #define IFXMIPS_MPS_CHIPID ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0344))
  706. #define IFXMIPS_MPS_VC0ENR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0000))
  707. #define IFXMIPS_MPS_RVC0SR ((u32 *)(IFXMIPS_MPS_BASE_ADDR + 0x0010))
  708. @@ -73,10 +78,11 @@
  709. /* MPS Common defines */
  710. /* ============================= */
  711. -#define MPS_BASEADDRESS 0xBF107000
  712. -#define MPS_RAD0SR MPS_BASEADDRESS + 0x0004
  713. -
  714. +#if defined(SYSTEM_FALCON)
  715. +#define MBX_BASEADDRESS 0xBF200040
  716. +#else
  717. #define MBX_BASEADDRESS 0xBF200000
  718. +#endif
  719. #define VCPU_BASEADDRESS 0xBF208000 /* 0xBF108000 */
  720. /*---------------------------------------------------------------------------*/
  721. #if !defined(CONFIG_LANTIQ)
  722. @@ -118,7 +124,6 @@
  723. /*---------------------------------------------------------------------------*/
  724. #ifdef CONFIG_MPS_EVENT_MBX
  725. -
  726. #define MBX_CMD_FIFO_SIZE 64 /**< Size of command FIFO in bytes */
  727. #define MBX_DATA_UPSTRM_FIFO_SIZE 64
  728. #define MBX_DATA_DNSTRM_FIFO_SIZE 128
  729. @@ -294,6 +299,10 @@ typedef struct
  730. #ifdef CONFIG_MPS_EVENT_MBX
  731. typedef struct
  732. {
  733. +#if defined(SYSTEM_FALCON)
  734. + mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
  735. + mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
  736. +#endif
  737. volatile IFX_uint32_t *MBX_UPSTR_CMD_BASE; /**< Upstream Command FIFO Base Address */
  738. volatile IFX_uint32_t MBX_UPSTR_CMD_SIZE; /**< Upstream Command FIFO size in byte */
  739. volatile IFX_uint32_t *MBX_DNSTR_CMD_BASE; /**< Downstream Command FIFO Base Address */
  740. @@ -317,13 +326,19 @@ typedef struct
  741. volatile IFX_uint32_t MBX_UPSTR_EVENT_WRITE; /**< Upstream Event FIFO Write Index */
  742. volatile IFX_uint32_t MBX_EVENT[MBX_EVENT_DATA_WORDS];
  743. volatile IFX_uint32_t reserved[4];
  744. +#if !defined(SYSTEM_FALCON)
  745. mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
  746. mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
  747. +#endif
  748. } mps_mbx_reg;
  749. #else /* */
  750. typedef struct
  751. {
  752. +#if defined(SYSTEM_FALCON)
  753. + mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
  754. + mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
  755. +#endif
  756. volatile IFX_uint32_t *MBX_UPSTR_CMD_BASE; /**< Upstream Command FIFO Base Address */
  757. volatile IFX_uint32_t MBX_UPSTR_CMD_SIZE; /**< Upstream Command FIFO size in byte */
  758. volatile IFX_uint32_t *MBX_DNSTR_CMD_BASE; /**< Downstream Command FIFO Base Address */
  759. @@ -341,8 +356,10 @@ typedef struct
  760. volatile IFX_uint32_t MBX_DNSTR_DATA_READ; /**< Downstream Data FIFO Read Index */
  761. volatile IFX_uint32_t MBX_DNSTR_DATA_WRITE; /**< Downstream Data FIFO Write Index */
  762. volatile IFX_uint32_t MBX_DATA[MBX_DATA_WORDS];
  763. +#if !defined(SYSTEM_FALCON)
  764. mps_boot_cfg_reg MBX_CPU0_BOOT_CFG; /**< CPU0 Boot Configuration */
  765. mps_boot_cfg_reg MBX_CPU1_BOOT_CFG; /**< CPU1 Boot Configuration */
  766. +#endif
  767. } mps_mbx_reg;
  768. #endif /* CONFIG_MPS_EVENT_MBX */
  769. --- a/src/drv_api.h
  770. +++ b/src/drv_api.h
  771. @@ -183,7 +183,7 @@
  772. #endif
  773. /* TAPI FXS Phone Detection feature is not available for Danube platform */
  774. -#if defined(TAPI_PHONE_DETECTION) && (defined(SYSTEM_AR9) || defined(SYSTEM_VR9))
  775. +#if defined(TAPI_PHONE_DETECTION) && (defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON))
  776. #define VMMC_CFG_ADD_FEAT_PHONE_DETECTION VMMC_FEAT_PHONE_DETECTION
  777. #else
  778. #define VMMC_CFG_ADD_FEAT_PHONE_DETECTION 0
  779. --- a/src/drv_vmmc_alm.c
  780. +++ b/src/drv_vmmc_alm.c
  781. @@ -800,7 +800,7 @@ IFX_void_t VMMC_ALM_Free_Ch_Structures (
  782. }
  783. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  784. +#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  785. /**
  786. Check whether SmartSLIC is connected
  787. @@ -836,7 +836,7 @@ IFX_boolean_t VMMC_ALM_SmartSLIC_IsConne
  788. #endif /*SYSTEM_AR9 || SYSTEM_VR9*/
  789. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  790. +#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  791. /**
  792. Read the number of channels on the SmartSLIC.
  793. @@ -1876,7 +1876,7 @@ IFX_int32_t VMMC_TAPI_LL_ALM_VMMC_Test_L
  794. /* write updated message contents */
  795. ret = CmdWrite (pDev, (IFX_uint32_t *)((IFX_void_t *)&debugCfg),
  796. DCCTL_CMD_LEN);
  797. -#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  798. +#elif defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  799. IFX_uint32_t dcctrlLoop[2];
  800. IFX_uint32_t ch = (IFX_uint32_t)(pCh->nChannel - 1);
  801. --- a/src/drv_vmmc_alm.h
  802. +++ b/src/drv_vmmc_alm.h
  803. @@ -65,7 +65,7 @@ extern IFX_void_t irq_VMMC_ALM_LineDisab
  804. extern IFX_void_t VMMC_ALM_CorrectLinemodeCache (VMMC_CHANNEL *pCh,
  805. IFX_uint16_t lm);
  806. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  807. +#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  808. extern IFX_boolean_t VMMC_ALM_SmartSLIC_IsConnected (
  809. VMMC_DEVICE *pDev);
  810. --- a/src/drv_vmmc_init.c
  811. +++ b/src/drv_vmmc_init.c
  812. @@ -52,15 +52,6 @@
  813. #include "ifx_pmu.h"
  814. #endif /* PMU_SUPPORTED */
  815. -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28))
  816. -# define IFX_MPS_CAD0SR IFXMIPS_MPS_CAD0SR
  817. -# define IFX_MPS_CAD1SR IFXMIPS_MPS_CAD1SR
  818. -# define IFX_MPS_CVC0SR IFXMIPS_MPS_CVC0SR
  819. -# define IFX_MPS_CVC1SR IFXMIPS_MPS_CVC1SR
  820. -# define IFX_MPS_CVC2SR IFXMIPS_MPS_CVC2SR
  821. -# define IFX_MPS_CVC3SR IFXMIPS_MPS_CVC3SR
  822. -#endif
  823. -
  824. /* ============================= */
  825. /* Local Macros & Definitions */
  826. /* ============================= */
  827. @@ -820,7 +811,7 @@ static IFX_int32_t VMMC_TAPI_LL_FW_Init(
  828. MIN_FW_HOTFIXSTEP};
  829. IFX_uint8_t tmp1, tmp2;
  830. IFX_TAPI_RESOURCE nResource;
  831. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  832. +#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  833. IFX_uint8_t nChannels, nFXOChannels;
  834. #endif /*SYSTEM_AR9 || SYSTEM_VR9*/
  835. IFX_int32_t ret = VMMC_statusOk;
  836. @@ -874,7 +865,7 @@ static IFX_int32_t VMMC_TAPI_LL_FW_Init(
  837. pDev->bSmartSlic = IFX_FALSE;
  838. pDev->bSlicSupportsIdleMode = IFX_FALSE;
  839. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  840. +#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  841. if (VMMC_SUCCESS(ret))
  842. {
  843. /* Reduce the number of ALM channels in the capabilities if the SLIC
  844. --- a/src/drv_vmmc_ioctl.c
  845. +++ b/src/drv_vmmc_ioctl.c
  846. @@ -273,7 +273,7 @@ IFX_int32_t VMMC_Dev_Spec_Ioctl (IFX_TAP
  847. case FIO_GET_VERS:
  848. {
  849. VMMC_IO_VERSION *pVers;
  850. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  851. +#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  852. VMMC_SDD_REVISION_READ_t *pSDDVersCmd = IFX_NULL;
  853. #endif /*SYSTEM_AR9 || SYSTEM_VR9*/
  854. SYS_VER_t *pCmd;
  855. @@ -322,7 +322,7 @@ IFX_int32_t VMMC_Dev_Spec_Ioctl (IFX_TAP
  856. pVers->nTapiVers = 3;
  857. pVers->nDrvVers = MAJORSTEP << 24 | MINORSTEP << 16 |
  858. VERSIONSTEP << 8 | VERS_TYPE;
  859. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  860. +#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9) || defined(SYSTEM_FALCON)
  861. /* in case of SmartSLIC based systems, we can give some more
  862. versions.*/
  863. if (VMMC_ALM_SmartSLIC_IsConnected(pDev))