cpu_init.c 5.4 KB

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