srio.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 2 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. * MA 02111-1307 USA
  18. */
  19. #include <common.h>
  20. #include <config.h>
  21. #include <asm/fsl_law.h>
  22. #include <asm/fsl_serdes.h>
  23. #include <asm/fsl_srio.h>
  24. #define SRIO_PORT_ACCEPT_ALL 0x10000001
  25. #define SRIO_IB_ATMU_AR 0x80f55000
  26. #define SRIO_OB_ATMU_AR_MAINT 0x80077000
  27. #define SRIO_OB_ATMU_AR_RW 0x80045000
  28. #define SRIO_LCSBA1CSR_OFFSET 0x5c
  29. #define SRIO_MAINT_WIN_SIZE 0x1000000 /* 16M */
  30. #define SRIO_RW_WIN_SIZE 0x100000 /* 1M */
  31. #define SRIO_LCSBA1CSR 0x60000000
  32. #if defined(CONFIG_FSL_CORENET)
  33. #define _DEVDISR_SRIO1 FSL_CORENET_DEVDISR_SRIO1
  34. #define _DEVDISR_SRIO2 FSL_CORENET_DEVDISR_SRIO2
  35. #define _DEVDISR_RMU FSL_CORENET_DEVDISR_RMU
  36. #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR
  37. #elif defined(CONFIG_MPC85xx)
  38. #define _DEVDISR_SRIO1 MPC85xx_DEVDISR_SRIO
  39. #define _DEVDISR_SRIO2 MPC85xx_DEVDISR_SRIO
  40. #define _DEVDISR_RMU MPC85xx_DEVDISR_RMSG
  41. #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR
  42. #elif defined(CONFIG_MPC86xx)
  43. #define _DEVDISR_SRIO1 MPC86xx_DEVDISR_SRIO
  44. #define _DEVDISR_SRIO2 MPC86xx_DEVDISR_SRIO
  45. #define _DEVDISR_RMU MPC86xx_DEVDISR_RMSG
  46. #define CONFIG_SYS_MPC8xxx_GUTS_ADDR \
  47. (&((immap_t *)CONFIG_SYS_IMMR)->im_gur)
  48. #else
  49. #error "No defines for DEVDISR_SRIO"
  50. #endif
  51. void srio_init(void)
  52. {
  53. ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC8xxx_GUTS_ADDR;
  54. int srio1_used = 0, srio2_used = 0;
  55. if (is_serdes_configured(SRIO1)) {
  56. set_next_law(CONFIG_SYS_SRIO1_MEM_PHYS,
  57. law_size_bits(CONFIG_SYS_SRIO1_MEM_SIZE),
  58. LAW_TRGT_IF_RIO_1);
  59. srio1_used = 1;
  60. printf("SRIO1: enabled\n");
  61. } else {
  62. printf("SRIO1: disabled\n");
  63. }
  64. #ifdef CONFIG_SRIO2
  65. if (is_serdes_configured(SRIO2)) {
  66. set_next_law(CONFIG_SYS_SRIO2_MEM_PHYS,
  67. law_size_bits(CONFIG_SYS_SRIO2_MEM_SIZE),
  68. LAW_TRGT_IF_RIO_2);
  69. srio2_used = 1;
  70. printf("SRIO2: enabled\n");
  71. } else {
  72. printf("SRIO2: disabled\n");
  73. }
  74. #endif
  75. #ifdef CONFIG_FSL_CORENET
  76. /* On FSL_CORENET devices we can disable individual ports */
  77. if (!srio1_used)
  78. setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_SRIO1);
  79. if (!srio2_used)
  80. setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_SRIO2);
  81. #endif
  82. /* neither port is used - disable everything */
  83. if (!srio1_used && !srio2_used) {
  84. setbits_be32(&gur->devdisr, _DEVDISR_SRIO1);
  85. setbits_be32(&gur->devdisr, _DEVDISR_SRIO2);
  86. setbits_be32(&gur->devdisr, _DEVDISR_RMU);
  87. }
  88. }
  89. #ifdef CONFIG_SRIOBOOT_MASTER
  90. void srio_boot_master(void)
  91. {
  92. struct ccsr_rio *srio = (void *)CONFIG_SYS_FSL_SRIO_ADDR;
  93. /* set port accept-all */
  94. out_be32((void *)&srio->impl.port[CONFIG_SRIOBOOT_MASTER_PORT].ptaacr,
  95. SRIO_PORT_ACCEPT_ALL);
  96. debug("SRIOBOOT - MASTER: Master port [ %d ] for srio boot.\n",
  97. CONFIG_SRIOBOOT_MASTER_PORT);
  98. /* configure inbound window for slave's u-boot image */
  99. debug("SRIOBOOT - MASTER: Inbound window for slave's image; "
  100. "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n",
  101. (u64)CONFIG_SRIOBOOT_SLAVE_IMAGE_LAW_PHYS1,
  102. (u64)CONFIG_SRIOBOOT_SLAVE_IMAGE_SRIO_PHYS1,
  103. CONFIG_SRIOBOOT_SLAVE_IMAGE_SIZE);
  104. out_be32((void *)&srio->atmu
  105. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[0].riwtar,
  106. CONFIG_SRIOBOOT_SLAVE_IMAGE_LAW_PHYS1 >> 12);
  107. out_be32((void *)&srio->atmu
  108. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[0].riwbar,
  109. CONFIG_SRIOBOOT_SLAVE_IMAGE_SRIO_PHYS1 >> 12);
  110. out_be32((void *)&srio->atmu
  111. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[0].riwar,
  112. SRIO_IB_ATMU_AR
  113. | atmu_size_mask(CONFIG_SRIOBOOT_SLAVE_IMAGE_SIZE));
  114. /* configure inbound window for slave's u-boot image */
  115. debug("SRIOBOOT - MASTER: Inbound window for slave's image; "
  116. "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n",
  117. (u64)CONFIG_SRIOBOOT_SLAVE_IMAGE_LAW_PHYS2,
  118. (u64)CONFIG_SRIOBOOT_SLAVE_IMAGE_SRIO_PHYS2,
  119. CONFIG_SRIOBOOT_SLAVE_IMAGE_SIZE);
  120. out_be32((void *)&srio->atmu
  121. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[1].riwtar,
  122. CONFIG_SRIOBOOT_SLAVE_IMAGE_LAW_PHYS2 >> 12);
  123. out_be32((void *)&srio->atmu
  124. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[1].riwbar,
  125. CONFIG_SRIOBOOT_SLAVE_IMAGE_SRIO_PHYS2 >> 12);
  126. out_be32((void *)&srio->atmu
  127. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[1].riwar,
  128. SRIO_IB_ATMU_AR
  129. | atmu_size_mask(CONFIG_SRIOBOOT_SLAVE_IMAGE_SIZE));
  130. /* configure inbound window for slave's ucode */
  131. debug("SRIOBOOT - MASTER: Inbound window for slave's ucode; "
  132. "Local = 0x%llx, Srio = 0x%llx, Size = 0x%x\n",
  133. (u64)CONFIG_SRIOBOOT_SLAVE_UCODE_LAW_PHYS,
  134. (u64)CONFIG_SRIOBOOT_SLAVE_UCODE_SRIO_PHYS,
  135. CONFIG_SRIOBOOT_SLAVE_UCODE_SIZE);
  136. out_be32((void *)&srio->atmu
  137. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[2].riwtar,
  138. CONFIG_SRIOBOOT_SLAVE_UCODE_LAW_PHYS >> 12);
  139. out_be32((void *)&srio->atmu
  140. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[2].riwbar,
  141. CONFIG_SRIOBOOT_SLAVE_UCODE_SRIO_PHYS >> 12);
  142. out_be32((void *)&srio->atmu
  143. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[2].riwar,
  144. SRIO_IB_ATMU_AR
  145. | atmu_size_mask(CONFIG_SRIOBOOT_SLAVE_UCODE_SIZE));
  146. /* configure inbound window for slave's ENV */
  147. debug("SRIOBOOT - MASTER: Inbound window for slave's ENV; "
  148. "Local = 0x%llx, Siro = 0x%llx, Size = 0x%x\n",
  149. CONFIG_SRIOBOOT_SLAVE_ENV_LAW_PHYS,
  150. CONFIG_SRIOBOOT_SLAVE_ENV_SRIO_PHYS,
  151. CONFIG_SRIOBOOT_SLAVE_ENV_SIZE);
  152. out_be32((void *)&srio->atmu
  153. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[3].riwtar,
  154. CONFIG_SRIOBOOT_SLAVE_ENV_LAW_PHYS >> 12);
  155. out_be32((void *)&srio->atmu
  156. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[3].riwbar,
  157. CONFIG_SRIOBOOT_SLAVE_ENV_SRIO_PHYS >> 12);
  158. out_be32((void *)&srio->atmu
  159. .port[CONFIG_SRIOBOOT_MASTER_PORT].inbw[3].riwar,
  160. SRIO_IB_ATMU_AR
  161. | atmu_size_mask(CONFIG_SRIOBOOT_SLAVE_ENV_SIZE));
  162. }
  163. #ifdef CONFIG_SRIOBOOT_SLAVE_HOLDOFF
  164. void srio_boot_master_release_slave(void)
  165. {
  166. struct ccsr_rio *srio = (void *)CONFIG_SYS_FSL_SRIO_ADDR;
  167. u32 escsr;
  168. debug("SRIOBOOT - MASTER: "
  169. "Check the port status and release slave core ...\n");
  170. escsr = in_be32((void *)&srio->lp_serial
  171. .port[CONFIG_SRIOBOOT_MASTER_PORT].pescsr);
  172. if (escsr & 0x2) {
  173. if (escsr & 0x10100) {
  174. debug("SRIOBOOT - MASTER: Port [ %d ] is error.\n",
  175. CONFIG_SRIOBOOT_MASTER_PORT);
  176. } else {
  177. debug("SRIOBOOT - MASTER: "
  178. "Port [ %d ] is ready, now release slave's core ...\n",
  179. CONFIG_SRIOBOOT_MASTER_PORT);
  180. /*
  181. * configure outbound window
  182. * with maintenance attribute to set slave's LCSBA1CSR
  183. */
  184. out_be32((void *)&srio->atmu
  185. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  186. .outbw[1].rowtar, 0);
  187. out_be32((void *)&srio->atmu
  188. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  189. .outbw[1].rowtear, 0);
  190. if (CONFIG_SRIOBOOT_MASTER_PORT)
  191. out_be32((void *)&srio->atmu
  192. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  193. .outbw[1].rowbar,
  194. CONFIG_SYS_SRIO2_MEM_PHYS >> 12);
  195. else
  196. out_be32((void *)&srio->atmu
  197. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  198. .outbw[1].rowbar,
  199. CONFIG_SYS_SRIO1_MEM_PHYS >> 12);
  200. out_be32((void *)&srio->atmu
  201. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  202. .outbw[1].rowar,
  203. SRIO_OB_ATMU_AR_MAINT
  204. | atmu_size_mask(SRIO_MAINT_WIN_SIZE));
  205. /*
  206. * configure outbound window
  207. * with R/W attribute to set slave's BRR
  208. */
  209. out_be32((void *)&srio->atmu
  210. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  211. .outbw[2].rowtar,
  212. SRIO_LCSBA1CSR >> 9);
  213. out_be32((void *)&srio->atmu
  214. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  215. .outbw[2].rowtear, 0);
  216. if (CONFIG_SRIOBOOT_MASTER_PORT)
  217. out_be32((void *)&srio->atmu
  218. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  219. .outbw[2].rowbar,
  220. (CONFIG_SYS_SRIO2_MEM_PHYS
  221. + SRIO_MAINT_WIN_SIZE) >> 12);
  222. else
  223. out_be32((void *)&srio->atmu
  224. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  225. .outbw[2].rowbar,
  226. (CONFIG_SYS_SRIO1_MEM_PHYS
  227. + SRIO_MAINT_WIN_SIZE) >> 12);
  228. out_be32((void *)&srio->atmu
  229. .port[CONFIG_SRIOBOOT_MASTER_PORT]
  230. .outbw[2].rowar,
  231. SRIO_OB_ATMU_AR_RW
  232. | atmu_size_mask(SRIO_RW_WIN_SIZE));
  233. /*
  234. * Set the LCSBA1CSR register in slave
  235. * by the maint-outbound window
  236. */
  237. if (CONFIG_SRIOBOOT_MASTER_PORT) {
  238. out_be32((void *)CONFIG_SYS_SRIO2_MEM_VIRT
  239. + SRIO_LCSBA1CSR_OFFSET,
  240. SRIO_LCSBA1CSR);
  241. while (in_be32((void *)CONFIG_SYS_SRIO2_MEM_VIRT
  242. + SRIO_LCSBA1CSR_OFFSET)
  243. != SRIO_LCSBA1CSR)
  244. ;
  245. /*
  246. * And then set the BRR register
  247. * to release slave core
  248. */
  249. out_be32((void *)CONFIG_SYS_SRIO2_MEM_VIRT
  250. + SRIO_MAINT_WIN_SIZE
  251. + CONFIG_SRIOBOOT_SLAVE_BRR_OFFSET,
  252. CONFIG_SRIOBOOT_SLAVE_RELEASE_MASK);
  253. } else {
  254. out_be32((void *)CONFIG_SYS_SRIO1_MEM_VIRT
  255. + SRIO_LCSBA1CSR_OFFSET,
  256. SRIO_LCSBA1CSR);
  257. while (in_be32((void *)CONFIG_SYS_SRIO1_MEM_VIRT
  258. + SRIO_LCSBA1CSR_OFFSET)
  259. != SRIO_LCSBA1CSR)
  260. ;
  261. /*
  262. * And then set the BRR register
  263. * to release slave core
  264. */
  265. out_be32((void *)CONFIG_SYS_SRIO1_MEM_VIRT
  266. + SRIO_MAINT_WIN_SIZE
  267. + CONFIG_SRIOBOOT_SLAVE_BRR_OFFSET,
  268. CONFIG_SRIOBOOT_SLAVE_RELEASE_MASK);
  269. }
  270. debug("SRIOBOOT - MASTER: "
  271. "Release slave successfully! Now the slave should start up!\n");
  272. }
  273. } else
  274. debug("SRIOBOOT - MASTER: Port [ %d ] is not ready.\n",
  275. CONFIG_SRIOBOOT_MASTER_PORT);
  276. }
  277. #endif
  278. #endif