500-ar9_vr9.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. --- a/src/mps/drv_mps_vmmc_ar9.c
  2. +++ b/src/mps/drv_mps_vmmc_ar9.c
  3. @@ -30,15 +30,24 @@
  4. #include "ifxos_interrupt.h"
  5. /* board specific headers */
  6. +#if !defined CONFIG_LANTIQ
  7. #include <asm/ifx/ifx_regs.h>
  8. #include <asm/ifx_vpe.h>
  9. #include <asm/ifx/ifx_gpio.h>
  10. +#endif
  11. +
  12. +#include <lantiq_soc.h>
  13. +#include <asm/vpe.h>
  14. /* device specific headers */
  15. #include "drv_mps_vmmc.h"
  16. #include "drv_mps_vmmc_dbg.h"
  17. #include "drv_mps_vmmc_device.h"
  18. +const void (*ifx_bsp_basic_mps_decrypt)(unsigned int addr, int n) = NULL;
  19. +
  20. +#define IFX_MPS_SRAM IFXMIPS_MPS_SRAM
  21. +
  22. /* ============================= */
  23. /* Local Macros & Definitions */
  24. /* ============================= */
  25. @@ -65,12 +74,7 @@ extern mps_comm_dev *pMPSDev;
  26. IFX_void_t ifx_mps_release (IFX_void_t);
  27. extern IFX_uint32_t ifx_mps_reset_structures (mps_comm_dev * pMPSDev);
  28. extern IFX_int32_t ifx_mps_bufman_close (IFX_void_t);
  29. -IFX_int32_t ifx_mps_wdog_callback (IFX_uint32_t wdog_cleared_ok_count);
  30. extern IFXOS_event_t fw_ready_evt;
  31. -/* ============================= */
  32. -/* Local function declaration */
  33. -/* ============================= */
  34. -static IFX_int32_t ifx_mps_fw_wdog_start_ar9(IFX_void_t);
  35. /* ============================= */
  36. /* Local variable definition */
  37. @@ -88,61 +92,6 @@ IFX_int32_t (*ifx_wdog_callback) (IFX_ui
  38. ******************************************************************************/
  39. /**
  40. - * Start AR9 EDSP firmware watchdog mechanism.
  41. - * Called after download and startup of VPE1.
  42. - *
  43. - * \param none
  44. - * \return 0 IFX_SUCCESS
  45. - * \return -1 IFX_ERROR
  46. - * \ingroup Internal
  47. - */
  48. -IFX_int32_t ifx_mps_fw_wdog_start_ar9()
  49. -{
  50. - /* vpe1_wdog_ctr should be set up in u-boot as
  51. - "vpe1_wdog_ctr_addr=0xBF2001B0"; protection from incorrect or missing
  52. - setting */
  53. - if (vpe1_wdog_ctr != VPE1_WDOG_CTR_ADDR)
  54. - {
  55. - vpe1_wdog_ctr = VPE1_WDOG_CTR_ADDR;
  56. - }
  57. -
  58. - /* vpe1_wdog_timeout should be set up in u-boot as "vpe1_wdog_timeout =
  59. - <value in ms>"; protection from insane setting */
  60. - if (vpe1_wdog_timeout < VPE1_WDOG_TMOUT_MIN)
  61. - {
  62. - vpe1_wdog_timeout = VPE1_WDOG_TMOUT_MIN;
  63. - }
  64. - if (vpe1_wdog_timeout > VPE1_WDOG_TMOUT_MAX)
  65. - {
  66. - vpe1_wdog_timeout = VPE1_WDOG_TMOUT_MAX;
  67. - }
  68. -
  69. - /* recalculate in jiffies */
  70. - vpe1_wdog_timeout = vpe1_wdog_timeout * HZ / 1000;
  71. -
  72. - /* register BSP callback function */
  73. - if (IFX_SUCCESS !=
  74. - vpe1_sw_wdog_register_reset_handler (ifx_mps_wdog_callback))
  75. - {
  76. - TRACE (MPS, DBG_LEVEL_HIGH,
  77. - (KERN_ERR "[%s %s %d]: Unable to register WDT callback.\r\n",
  78. - __FILE__, __func__, __LINE__));
  79. - return IFX_ERROR;;
  80. - }
  81. -
  82. - /* start software watchdog timer */
  83. - if (IFX_SUCCESS != vpe1_sw_wdog_start (0))
  84. - {
  85. - TRACE (MPS, DBG_LEVEL_HIGH,
  86. - (KERN_ERR
  87. - "[%s %s %d]: Error starting software watchdog timer.\r\n",
  88. - __FILE__, __func__, __LINE__));
  89. - return IFX_ERROR;
  90. - }
  91. - return IFX_SUCCESS;
  92. -}
  93. -
  94. -/**
  95. * Firmware download to Voice CPU
  96. * This function performs a firmware download to the coprocessor.
  97. *
  98. @@ -292,6 +241,18 @@ IFX_int32_t ifx_mps_download_firmware (m
  99. decryption. Subtract sizeof(u32) from length to avoid decryption
  100. of data beyond the FW image code */
  101. pFWDwnld->length -= sizeof(IFX_uint32_t);
  102. + switch(ltq_soc_type()) {
  103. + case SOC_TYPE_AR9:
  104. + ifx_bsp_basic_mps_decrypt = (const void (*)(unsigned int, int))0xbf0017c4;
  105. + break;
  106. + case SOC_TYPE_VR9:
  107. + ifx_bsp_basic_mps_decrypt = (const void (*)(unsigned int, int))0xbf001ea4;
  108. + break;
  109. + case SOC_TYPE_VR9_2:
  110. + ifx_bsp_basic_mps_decrypt = (const void (*)(unsigned int, int))0xbf001f38;
  111. + break;
  112. + }
  113. + if (ifx_bsp_basic_mps_decrypt)
  114. ifx_bsp_basic_mps_decrypt((IFX_uint32_t)cpu1_base_addr, pFWDwnld->length);
  115. }
  116. @@ -318,9 +279,6 @@ IFX_int32_t ifx_mps_download_firmware (m
  117. /* start VPE1 */
  118. ifx_mps_release ();
  119. - /* start FW watchdog mechanism */
  120. - ifx_mps_fw_wdog_start_ar9();
  121. -
  122. /* get FW version */
  123. return ifx_mps_get_fw_version (0);
  124. }
  125. @@ -345,8 +303,6 @@ IFX_int32_t ifx_mps_restart (IFX_void_t)
  126. ifx_mps_init_gpt ();
  127. /* let CPU1 run */
  128. ifx_mps_release ();
  129. - /* start FW watchdog mechanism */
  130. - ifx_mps_fw_wdog_start_ar9();
  131. TRACE (MPS, DBG_LEVEL_HIGH, ("IFX_MPS: Restarting firmware..."));
  132. return ifx_mps_get_fw_version (0);
  133. }
  134. @@ -361,10 +317,6 @@ IFX_void_t ifx_mps_shutdown (IFX_void_t)
  135. {
  136. if (vpe1_started)
  137. {
  138. - /* stop software watchdog timer */
  139. - vpe1_sw_wdog_stop (0);
  140. - /* clean up the BSP callback function */
  141. - vpe1_sw_wdog_register_reset_handler (IFX_NULL);
  142. /* stop VPE1 */
  143. vpe1_sw_stop (0);
  144. vpe1_started = 0;
  145. @@ -387,8 +339,6 @@ IFX_void_t ifx_mps_reset (IFX_void_t)
  146. /* if VPE1 is already started, stop it */
  147. if (vpe1_started)
  148. {
  149. - /* stop software watchdog timer first */
  150. - vpe1_sw_wdog_stop (0);
  151. vpe1_sw_stop (0);
  152. vpe1_started = 0;
  153. }
  154. @@ -436,101 +386,6 @@ IFX_void_t ifx_mps_release (IFX_void_t)
  155. }
  156. /**
  157. - * WDT callback.
  158. - * This function is called by BSP (module softdog_vpe) in case if software
  159. - * watchdog timer expiration is detected by BSP.
  160. - * This function needs to be registered at BSP as WDT callback using
  161. - * vpe1_sw_wdog_register_reset_handler() API.
  162. - *
  163. - * \return 0 IFX_SUCCESS, cannot fail
  164. - * \ingroup Internal
  165. - */
  166. -IFX_int32_t ifx_mps_wdog_callback (IFX_uint32_t wdog_cleared_ok_count)
  167. -{
  168. - IFX_uint32_t flags;
  169. -#ifdef DEBUG
  170. - TRACE (MPS, DBG_LEVEL_HIGH,
  171. - ("MPS: watchdog callback! arg=0x%08x\r\n", wdog_cleared_ok_count));
  172. -#endif /* DEBUG */
  173. -
  174. - /* reset SmartSLIC */
  175. - IFXOS_LOCKINT (flags);
  176. - if (ifx_gpio_pin_reserve
  177. - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
  178. - {
  179. - TRACE (MPS, DBG_LEVEL_HIGH,
  180. - (KERN_ERR "[%s %s %d]: GPIO port/pin reservation error.\r\n",
  181. - __FILE__, __func__, __LINE__));
  182. - }
  183. - /* P1_ALTSEL0.15 = 0 */
  184. - if (ifx_gpio_altsel0_clear
  185. - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
  186. - {
  187. - TRACE (MPS, DBG_LEVEL_HIGH,
  188. - (KERN_ERR "[%s %s %d]: GPIO error clearing ALTSEL0.\r\n", __FILE__,
  189. - __func__, __LINE__));
  190. - }
  191. - /* P1_ALTSEL1.15 = 0 */
  192. - if (ifx_gpio_altsel1_clear
  193. - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
  194. - {
  195. - TRACE (MPS, DBG_LEVEL_HIGH,
  196. - (KERN_ERR "[%s %s %d]: GPIO error clearing ALTSEL1.\r\n", __FILE__,
  197. - __func__, __LINE__));
  198. - }
  199. - /* P1_DIR.15 = 1 */
  200. - if (ifx_gpio_dir_out_set
  201. - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
  202. - {
  203. - TRACE (MPS, DBG_LEVEL_HIGH,
  204. - (KERN_ERR "[%s %s %d]: GPIO error setting DIR.\r\n", __FILE__,
  205. - __func__, __LINE__));
  206. - }
  207. - /* P1_OD.15 = 1 */
  208. - if (ifx_gpio_open_drain_set
  209. - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
  210. - {
  211. - TRACE (MPS, DBG_LEVEL_HIGH,
  212. - (KERN_ERR "[%s %s %d]: GPIO error setting OD.\r\n", __FILE__,
  213. - __func__, __LINE__));
  214. - }
  215. - /* P1_OUT.15 = 0 */
  216. - if (ifx_gpio_output_clear
  217. - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
  218. - {
  219. - TRACE (MPS, DBG_LEVEL_HIGH,
  220. - (KERN_ERR "[%s %s %d]: GPIO error clearing OUT.\r\n", __FILE__,
  221. - __func__, __LINE__));
  222. - }
  223. - if (ifx_gpio_pin_free
  224. - (IFX_GPIO_PIN_ID (SSLIC_RST_PORT, SSLIC_RST_PIN), IFX_MPS_MODULE_ID))
  225. - {
  226. - TRACE (MPS, DBG_LEVEL_HIGH,
  227. - (KERN_ERR "[%s %s %d]: GPIO port/pin freeing error.\r\n", __FILE__,
  228. - __func__, __LINE__));
  229. - }
  230. - IFXOS_UNLOCKINT (flags);
  231. -
  232. - /* recalculate and compare the firmware checksum */
  233. - ifx_mps_fw_crc_compare(cpu1_base_addr, pFW_img_data);
  234. -
  235. - /* dump exception area on a console */
  236. - ifx_mps_dump_fw_xcpt(cpu1_base_addr, pFW_img_data);
  237. -
  238. - if (IFX_NULL != ifx_wdog_callback)
  239. - {
  240. - /* call VMMC driver */
  241. - ifx_wdog_callback (wdog_cleared_ok_count);
  242. - }
  243. - else
  244. - {
  245. - TRACE (MPS, DBG_LEVEL_HIGH,
  246. - (KERN_WARNING "MPS: VMMC watchdog timer callback is NULL.\r\n"));
  247. - }
  248. - return 0;
  249. -}
  250. -
  251. -/**
  252. * Register WDT callback.
  253. * This function is called by VMMC driver to register its callback in
  254. * the MPS driver.
  255. --- a/src/drv_vmmc_amazon_s.h
  256. +++ b/src/drv_vmmc_amazon_s.h
  257. @@ -15,9 +15,7 @@
  258. */
  259. -#if defined(SYSTEM_AR9) || defined(SYSTEM_VR9)
  260. -#include <asm/ifx/ifx_gpio.h>
  261. -#else
  262. +#if !defined(SYSTEM_AR9) && !defined(SYSTEM_VR9)
  263. #error no system selected
  264. #endif
  265. @@ -27,45 +25,6 @@
  266. */
  267. #define VMMC_PCM_IF_CFG_HOOK(mode, GPIOreserved, ret) \
  268. do { \
  269. - ret = VMMC_statusOk; \
  270. - /* Reserve P0.0 as TDM/FSC */ \
  271. - if (!GPIOreserved) \
  272. - ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
  273. - ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
  274. - ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
  275. - ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID);\
  276. - \
  277. - /* Reserve P1.9 as TDM/DO */ \
  278. - if (!GPIOreserved) \
  279. - ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  280. - ret |= ifx_gpio_altsel0_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  281. - ret |= ifx_gpio_altsel1_clear(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  282. - ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  283. - ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  284. - \
  285. - /* Reserve P2.9 as TDM/DI */ \
  286. - if (!GPIOreserved) \
  287. - ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  288. - ret |= ifx_gpio_altsel0_clear(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  289. - ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID);\
  290. - ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  291. - \
  292. - /* Reserve P2.8 as TDM/DCL */ \
  293. - if (!GPIOreserved) \
  294. - ret |= ifx_gpio_pin_reserve(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
  295. - ret |= ifx_gpio_altsel0_clear(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
  296. - ret |= ifx_gpio_altsel1_set(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
  297. - ret |= ifx_gpio_open_drain_set(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
  298. - \
  299. - if (mode == 2) { \
  300. - /* TDM/FSC+DCL Master */ \
  301. - ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
  302. - ret |= ifx_gpio_dir_out_set(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
  303. - } else { \
  304. - /* TDM/FSC+DCL Slave */ \
  305. - ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
  306. - ret |= ifx_gpio_dir_in_set(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
  307. - } \
  308. } while(0);
  309. /**
  310. @@ -73,11 +32,6 @@ do { \
  311. */
  312. #define VMMC_DRIVER_UNLOAD_HOOK(ret) \
  313. do { \
  314. - ret = VMMC_statusOk; \
  315. - ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(0, 0), VMMC_TAPI_GPIO_MODULE_ID); \
  316. - ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(1, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  317. - ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(2, 9), VMMC_TAPI_GPIO_MODULE_ID); \
  318. - ret |= ifx_gpio_pin_free(IFX_GPIO_PIN_ID(2, 8), VMMC_TAPI_GPIO_MODULE_ID); \
  319. } while (0)
  320. #endif /* _DRV_VMMC_AMAZON_S_H */