ifxmips_atm_vr9.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /******************************************************************************
  2. **
  3. ** FILE NAME : ifxmips_atm_vr9.c
  4. ** PROJECT : UEIP
  5. ** MODULES : ATM
  6. **
  7. ** DATE : 7 Jul 2009
  8. ** AUTHOR : Xu Liang
  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
  13. **
  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.
  18. **
  19. ** HISTORY
  20. ** $Date $Author $Comment
  21. ** 07 JUL 2009 Xu Liang Init Version
  22. *******************************************************************************/
  23. /*
  24. * ####################################
  25. * Head File
  26. * ####################################
  27. */
  28. /*
  29. * Common Head File
  30. */
  31. #include <linux/kernel.h>
  32. #include <linux/module.h>
  33. #include <linux/version.h>
  34. #include <linux/types.h>
  35. #include <linux/errno.h>
  36. #include <linux/proc_fs.h>
  37. #include <linux/init.h>
  38. #include <linux/ioctl.h>
  39. #include <linux/platform_device.h>
  40. #include <linux/reset.h>
  41. #include <asm/delay.h>
  42. #include "ifxmips_atm_core.h"
  43. #include "ifxmips_atm_fw_vr9.h"
  44. #ifdef CONFIG_VR9
  45. #include <lantiq_soc.h>
  46. #define IFX_PMU_MODULE_PPE_SLL01 BIT(19)
  47. #define IFX_PMU_MODULE_PPE_TC BIT(21)
  48. #define IFX_PMU_MODULE_PPE_EMA BIT(22)
  49. #define IFX_PMU_MODULE_PPE_QSB BIT(18)
  50. #define IFX_PMU_MODULE_AHBS BIT(13)
  51. #define IFX_PMU_MODULE_DSL_DFE BIT(9)
  52. static inline void vr9_reset_ppe(struct platform_device *pdev)
  53. {
  54. struct device *dev = &pdev->dev;
  55. struct reset_control *dsp;
  56. struct reset_control *dfe;
  57. struct reset_control *tc;
  58. dsp = devm_reset_control_get(dev, "dsp");
  59. if (IS_ERR(dsp)) {
  60. if (PTR_ERR(dsp) != -EPROBE_DEFER)
  61. dev_err(dev, "Failed to lookup dsp reset\n");
  62. // return PTR_ERR(dsp);
  63. }
  64. dfe = devm_reset_control_get(dev, "dfe");
  65. if (IS_ERR(dfe)) {
  66. if (PTR_ERR(dfe) != -EPROBE_DEFER)
  67. dev_err(dev, "Failed to lookup dfe reset\n");
  68. // return PTR_ERR(dfe);
  69. }
  70. tc = devm_reset_control_get(dev, "tc");
  71. if (IS_ERR(tc)) {
  72. if (PTR_ERR(tc) != -EPROBE_DEFER)
  73. dev_err(dev, "Failed to lookup tc reset\n");
  74. // return PTR_ERR(tc);
  75. }
  76. reset_control_assert(dsp);
  77. udelay(1000);
  78. reset_control_assert(dfe);
  79. udelay(1000);
  80. reset_control_assert(tc);
  81. udelay(1000);
  82. *PP32_SRST &= ~0x000303CF;
  83. udelay(1000);
  84. *PP32_SRST |= 0x000303CF;
  85. udelay(1000);
  86. }
  87. static inline int vr9_pp32_download_code(int pp32, u32 *code_src, unsigned int code_dword_len, u32 *data_src, unsigned int data_dword_len)
  88. {
  89. unsigned int clr, set;
  90. volatile u32 *dest;
  91. if ( code_src == 0 || ((unsigned long)code_src & 0x03) != 0
  92. || data_src == 0 || ((unsigned long)data_src & 0x03) != 0 )
  93. return -1;
  94. clr = pp32 ? 0xF0 : 0x0F;
  95. if ( code_dword_len <= CDM_CODE_MEMORYn_DWLEN(0) )
  96. set = pp32 ? (3 << 6): (2 << 2);
  97. else
  98. set = 0x00;
  99. IFX_REG_W32_MASK(clr, set, CDM_CFG);
  100. dest = CDM_CODE_MEMORY(pp32, 0);
  101. while ( code_dword_len-- > 0 )
  102. IFX_REG_W32(*code_src++, dest++);
  103. dest = CDM_DATA_MEMORY(pp32, 0);
  104. while ( data_dword_len-- > 0 )
  105. IFX_REG_W32(*data_src++, dest++);
  106. return 0;
  107. }
  108. static void vr9_fw_ver(unsigned int *major, unsigned int *minor)
  109. {
  110. *major = FW_VER_ID->major;
  111. *minor = FW_VER_ID->minor;
  112. }
  113. static void vr9_init(struct platform_device *pdev)
  114. {
  115. volatile u32 *p;
  116. unsigned int i;
  117. /* setup pmu */
  118. ltq_pmu_enable(IFX_PMU_MODULE_PPE_SLL01 |
  119. IFX_PMU_MODULE_PPE_TC |
  120. IFX_PMU_MODULE_PPE_EMA |
  121. IFX_PMU_MODULE_PPE_QSB |
  122. IFX_PMU_MODULE_AHBS |
  123. IFX_PMU_MODULE_DSL_DFE);
  124. vr9_reset_ppe(pdev);
  125. /* pdma init */
  126. IFX_REG_W32(0x08, PDMA_CFG);
  127. IFX_REG_W32(0x00203580, SAR_PDMA_RX_CMDBUF_CFG);
  128. IFX_REG_W32(0x004035A0, SAR_PDMA_RX_FW_CMDBUF_CFG);
  129. /* mailbox init */
  130. IFX_REG_W32(0xFFFFFFFF, MBOX_IGU1_ISRC);
  131. IFX_REG_W32(0x00000000, MBOX_IGU1_IER);
  132. IFX_REG_W32(0xFFFFFFFF, MBOX_IGU3_ISRC);
  133. IFX_REG_W32(0x00000000, MBOX_IGU3_IER);
  134. /* tc init - clear sync state */
  135. *SFSM_STATE0 = 0;
  136. *SFSM_STATE1 = 0;
  137. /* init shared buffer */
  138. p = SB_RAM0_ADDR(0);
  139. for ( i = 0; i < SB_RAM0_DWLEN + SB_RAM1_DWLEN + SB_RAM2_DWLEN + SB_RAM3_DWLEN; i++ )
  140. IFX_REG_W32(0, p++);
  141. p = SB_RAM6_ADDR(0);
  142. for ( i = 0; i < SB_RAM6_DWLEN; i++ )
  143. IFX_REG_W32(0, p++);
  144. }
  145. static void vr9_shutdown(void)
  146. {
  147. }
  148. static int vr9_start(int pp32)
  149. {
  150. unsigned int mask = 1 << (pp32 << 4);
  151. int ret;
  152. /* download firmware */
  153. ret = vr9_pp32_download_code(pp32,
  154. vr9_fw_bin, sizeof(vr9_fw_bin) / sizeof(*vr9_fw_bin),
  155. vr9_fw_data, sizeof(vr9_fw_data) / sizeof(*vr9_fw_data));
  156. if ( ret != 0 )
  157. return ret;
  158. /* run PP32 */
  159. IFX_REG_W32_MASK(mask, 0, PP32_FREEZE);
  160. /* idle for a while to let PP32 init itself */
  161. udelay(10);
  162. return 0;
  163. }
  164. static void vr9_stop(int pp32)
  165. {
  166. unsigned int mask = 1 << (pp32 << 4);
  167. IFX_REG_W32_MASK(0, mask, PP32_FREEZE);
  168. }
  169. struct ltq_atm_ops vr9_ops = {
  170. .init = vr9_init,
  171. .shutdown = vr9_shutdown,
  172. .start = vr9_start,
  173. .stop = vr9_stop,
  174. .fw_ver = vr9_fw_ver,
  175. };
  176. #endif