cpu_init.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * Copyright (C) 2004-2006 Freescale Semiconductor, Inc.
  3. * Copyright (C) 2007-2009 DENX Software Engineering
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. *
  23. * Derived from the MPC83xx code.
  24. *
  25. */
  26. #include <common.h>
  27. #include <asm/io.h>
  28. #include <asm/mpc512x.h>
  29. #include <asm/processor.h>
  30. DECLARE_GLOBAL_DATA_PTR;
  31. /*
  32. * Set up the memory map, initialize registers,
  33. */
  34. void cpu_init_f (volatile immap_t * im)
  35. {
  36. u32 ips_div;
  37. /* Pointer is writable since we allocated a register for it */
  38. gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
  39. /* Clear initial global data */
  40. memset ((void *) gd, 0, sizeof (gd_t));
  41. /* Local Window and chip select configuration */
  42. #if defined(CONFIG_SYS_CS0_START) && defined(CONFIG_SYS_CS0_SIZE)
  43. out_be32(&im->sysconf.lpcs0aw,
  44. CSAW_START(CONFIG_SYS_CS0_START) |
  45. CSAW_STOP(CONFIG_SYS_CS0_START, CONFIG_SYS_CS0_SIZE));
  46. sync_law(&im->sysconf.lpcs0aw);
  47. #endif
  48. #if defined(CONFIG_SYS_CS0_CFG)
  49. out_be32(&im->lpc.cs_cfg[0], CONFIG_SYS_CS0_CFG);
  50. #endif
  51. #if defined(CONFIG_SYS_CS1_START) && defined(CONFIG_SYS_CS1_SIZE)
  52. out_be32(&im->sysconf.lpcs1aw,
  53. CSAW_START(CONFIG_SYS_CS1_START) |
  54. CSAW_STOP(CONFIG_SYS_CS1_START, CONFIG_SYS_CS1_SIZE));
  55. sync_law(&im->sysconf.lpcs1aw);
  56. #endif
  57. #if defined(CONFIG_SYS_CS1_CFG)
  58. out_be32(&im->lpc.cs_cfg[1], CONFIG_SYS_CS1_CFG);
  59. #endif
  60. #if defined(CONFIG_SYS_CS2_START) && (defined CONFIG_SYS_CS2_SIZE)
  61. out_be32(&im->sysconf.lpcs2aw,
  62. CSAW_START(CONFIG_SYS_CS2_START) |
  63. CSAW_STOP(CONFIG_SYS_CS2_START, CONFIG_SYS_CS2_SIZE));
  64. sync_law(&im->sysconf.lpcs2aw);
  65. #endif
  66. #if defined(CONFIG_SYS_CS2_CFG)
  67. out_be32(&im->lpc.cs_cfg[2], CONFIG_SYS_CS2_CFG);
  68. #endif
  69. #if defined(CONFIG_SYS_CS3_START) && defined(CONFIG_SYS_CS3_SIZE)
  70. out_be32(&im->sysconf.lpcs3aw,
  71. CSAW_START(CONFIG_SYS_CS3_START) |
  72. CSAW_STOP(CONFIG_SYS_CS3_START, CONFIG_SYS_CS3_SIZE));
  73. sync_law(&im->sysconf.lpcs3aw);
  74. #endif
  75. #if defined(CONFIG_SYS_CS3_CFG)
  76. out_be32(&im->lpc.cs_cfg[3], CONFIG_SYS_CS3_CFG);
  77. #endif
  78. #if defined(CONFIG_SYS_CS4_START) && defined(CONFIG_SYS_CS4_SIZE)
  79. out_be32(&im->sysconf.lpcs4aw,
  80. CSAW_START(CONFIG_SYS_CS4_START) |
  81. CSAW_STOP(CONFIG_SYS_CS4_START, CONFIG_SYS_CS4_SIZE));
  82. sync_law(&im->sysconf.lpcs4aw);
  83. #endif
  84. #if defined(CONFIG_SYS_CS4_CFG)
  85. out_be32(&im->lpc.cs_cfg[4], CONFIG_SYS_CS4_CFG);
  86. #endif
  87. #if defined(CONFIG_SYS_CS5_START) && defined(CONFIG_SYS_CS5_SIZE)
  88. out_be32(&im->sysconf.lpcs5aw,
  89. CSAW_START(CONFIG_SYS_CS5_START) |
  90. CSAW_STOP(CONFIG_SYS_CS5_START, CONFIG_SYS_CS5_SIZE));
  91. sync_law(&im->sysconf.lpcs5aw);
  92. #endif
  93. #if defined(CONFIG_SYS_CS5_CFG)
  94. out_be32(&im->lpc.cs_cfg[5], CONFIG_SYS_CS5_CFG);
  95. #endif
  96. #if defined(CONFIG_SYS_CS6_START) && defined(CONFIG_SYS_CS6_SIZE)
  97. out_be32(&im->sysconf.lpcs6aw,
  98. CSAW_START(CONFIG_SYS_CS6_START) |
  99. CSAW_STOP(CONFIG_SYS_CS6_START, CONFIG_SYS_CS6_SIZE));
  100. sync_law(&im->sysconf.lpcs6aw);
  101. #endif
  102. #if defined(CONFIG_SYS_CS6_CFG)
  103. out_be32(&im->lpc.cs_cfg[6], CONFIG_SYS_CS6_CFG);
  104. #endif
  105. #if defined(CONFIG_SYS_CS7_START) && defined(CONFIG_SYS_CS7_SIZE)
  106. out_be32(&im->sysconf.lpcs7aw,
  107. CSAW_START(CONFIG_SYS_CS7_START) |
  108. CSAW_STOP(CONFIG_SYS_CS7_START, CONFIG_SYS_CS7_SIZE));
  109. sync_law(&im->sysconf.lpcs7aw);
  110. #endif
  111. #if defined(CONFIG_SYS_CS7_CFG)
  112. out_be32(&im->lpc.cs_cfg[7], CONFIG_SYS_CS7_CFG);
  113. #endif
  114. #if defined CONFIG_SYS_CS_ALETIMING
  115. if (SVR_MJREV(in_be32(&im->sysconf.spridr)) >= 2)
  116. out_be32(&im->lpc.altr, CONFIG_SYS_CS_ALETIMING);
  117. #endif
  118. #if defined CONFIG_SYS_CS_BURST
  119. out_be32(&im->lpc.cs_bcr, CONFIG_SYS_CS_BURST);
  120. #endif
  121. #if defined CONFIG_SYS_CS_DEADCYCLE
  122. out_be32(&im->lpc.cs_dccr, CONFIG_SYS_CS_DEADCYCLE);
  123. #endif
  124. #if defined CONFIG_SYS_CS_HOLDCYCLE
  125. out_be32(&im->lpc.cs_hccr, CONFIG_SYS_CS_HOLDCYCLE);
  126. #endif
  127. /* system performance tweaking */
  128. #ifdef CONFIG_SYS_ACR_PIPE_DEP
  129. /* Arbiter pipeline depth */
  130. out_be32(&im->arbiter.acr,
  131. (im->arbiter.acr & ~ACR_PIPE_DEP) |
  132. (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT)
  133. );
  134. #endif
  135. #ifdef CONFIG_SYS_ACR_RPTCNT
  136. /* Arbiter repeat count */
  137. out_be32(im->arbiter.acr,
  138. (im->arbiter.acr & ~(ACR_RPTCNT)) |
  139. (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT)
  140. );
  141. #endif
  142. /* RSR - Reset Status Register - clear all status */
  143. gd->arch.reset_status = im->reset.rsr;
  144. out_be32(&im->reset.rsr, ~RSR_RES);
  145. /*
  146. * RMR - Reset Mode Register - enable checkstop reset
  147. */
  148. out_be32(&im->reset.rmr, RMR_CSRE & (1 << RMR_CSRE_SHIFT));
  149. /* Set IPS-CSB divider: IPS = 1/2 CSB */
  150. ips_div = in_be32(&im->clk.scfr[0]);
  151. ips_div &= ~(SCFR1_IPS_DIV_MASK);
  152. ips_div |= SCFR1_IPS_DIV << SCFR1_IPS_DIV_SHIFT;
  153. out_be32(&im->clk.scfr[0], ips_div);
  154. #ifdef SCFR1_LPC_DIV
  155. clrsetbits_be32(&im->clk.scfr[0], SCFR1_LPC_DIV_MASK,
  156. SCFR1_LPC_DIV << SCFR1_LPC_DIV_SHIFT);
  157. #endif
  158. #ifdef SCFR1_NFC_DIV
  159. clrsetbits_be32(&im->clk.scfr[0], SCFR1_NFC_DIV_MASK,
  160. SCFR1_NFC_DIV << SCFR1_NFC_DIV_SHIFT);
  161. #endif
  162. #ifdef SCFR1_DIU_DIV
  163. clrsetbits_be32(&im->clk.scfr[0], SCFR1_DIU_DIV_MASK,
  164. SCFR1_DIU_DIV << SCFR1_DIU_DIV_SHIFT);
  165. #endif
  166. /*
  167. * Enable Time Base/Decrementer
  168. *
  169. * NOTICE: TB needs to be enabled as early as possible in order to
  170. * have udelay() working; if not enabled, usually leads to a hang, like
  171. * during FLASH chip identification etc.
  172. */
  173. setbits_be32(&im->sysconf.spcr, SPCR_TBEN);
  174. /*
  175. * Enable clocks
  176. */
  177. out_be32(&im->clk.sccr[0], SCCR1_CLOCKS_EN);
  178. out_be32(&im->clk.sccr[1], SCCR2_CLOCKS_EN);
  179. #if defined(CONFIG_FSL_IIM) || defined(CONFIG_CMD_FUSE)
  180. setbits_be32(&im->clk.sccr[1], CLOCK_SCCR2_IIM_EN);
  181. #endif
  182. }
  183. int cpu_init_r (void)
  184. {
  185. return 0;
  186. }