memsetup.S 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * Memory sub-system initialization code for INCA-IP development board.
  3. *
  4. * Copyright (c) 2003 Wolfgang Denk <wd@denx.de>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <config.h>
  25. #include <version.h>
  26. #include <asm/regdef.h>
  27. #define EBU_MODUL_BASE 0xB8000200
  28. #define EBU_CLC(value) 0x0000(value)
  29. #define EBU_CON(value) 0x0010(value)
  30. #define EBU_ADDSEL0(value) 0x0020(value)
  31. #define EBU_ADDSEL1(value) 0x0024(value)
  32. #define EBU_ADDSEL2(value) 0x0028(value)
  33. #define EBU_BUSCON0(value) 0x0060(value)
  34. #define EBU_BUSCON1(value) 0x0064(value)
  35. #define EBU_BUSCON2(value) 0x0068(value)
  36. #define MC_MODUL_BASE 0xBF800000
  37. #define MC_ERRCAUSE(value) 0x0100(value)
  38. #define MC_ERRADDR(value) 0x0108(value)
  39. #define MC_IOGP(value) 0x0800(value)
  40. #define MC_SELFRFSH(value) 0x0A00(value)
  41. #define MC_CTRLENA(value) 0x1000(value)
  42. #define MC_MRSCODE(value) 0x1008(value)
  43. #define MC_CFGDW(value) 0x1010(value)
  44. #define MC_CFGPB0(value) 0x1018(value)
  45. #define MC_LATENCY(value) 0x1038(value)
  46. #define MC_TREFRESH(value) 0x1040(value)
  47. #if CPU_CLOCK_RATE==150000000 /* 150 MHz clock for the MIPS core */
  48. #define CGU_MODUL_BASE 0xBF107000
  49. #define CGU_PLL1CR(value) 0x0008(value)
  50. #define CGU_DIVCR(value) 0x0010(value)
  51. #define CGU_MUXCR(value) 0x0014(value)
  52. #define CGU_PLL1SR(value) 0x000C(value)
  53. #endif
  54. .globl memsetup
  55. memsetup:
  56. /* EBU Initialization for the Flash CS0 and CS2.
  57. */
  58. li t0, EBU_MODUL_BASE
  59. li t1, 0xA0000041
  60. sw t1, EBU_ADDSEL0(t0)
  61. #if CPU_CLOCK_RATE==150000000 /* 150 MHz clock for the MIPS core */
  62. li t1, 0xA841417E
  63. sw t1, EBU_BUSCON0(t0) /* value set up by magic flash word */
  64. sw t1, EBU_BUSCON2(t0)
  65. #else /* 100 MHz */
  66. lw t1, EBU_BUSCON0(t0) /* value set up by magic flash word */
  67. sw t1, EBU_BUSCON2(t0)
  68. #endif
  69. li t1, 0xA0800041
  70. sw t1, EBU_ADDSEL2(t0)
  71. /* Need to initialize CS1 too, so as to to prevent overlapping with
  72. * Flash bank 1.
  73. */
  74. li t1, 0xBE0000F1
  75. sw t1, EBU_ADDSEL1(t0)
  76. #if CPU_CLOCK_RATE==150000000 /* 150 MHz clock for the MIPS core */
  77. li t1, 0x684143FD
  78. #else /* 100 MHz */
  79. li t1, 0x684142BD
  80. #endif
  81. sw t1, EBU_BUSCON1(t0)
  82. #if CPU_CLOCK_RATE==150000000 /* 150 MHz clock for the MIPS core */
  83. li t0, CGU_MODUL_BASE
  84. li t1, 0x80000017
  85. sw t1, CGU_DIVCR(t0)
  86. li t1, 0xC00B0001
  87. sw t1, CGU_PLL1CR(t0)
  88. lui t2, 0x8000
  89. b1:
  90. lw t1, CGU_PLL1SR(t0)
  91. and t1, t1, t2
  92. beq t1, zero, b1
  93. li t1, 0x80000001
  94. sw t1, CGU_MUXCR(t0)
  95. #endif
  96. /* SDRAM Initialization.
  97. */
  98. li t0, MC_MODUL_BASE
  99. /* Clear Error log registers */
  100. sw zero, MC_ERRCAUSE(t0)
  101. sw zero, MC_ERRADDR(t0)
  102. /* Set clock ratio to 1:1 */
  103. li t1, 0x03 /* clkrat=1:1, rddel=3 */
  104. sw t1, MC_IOGP(t0)
  105. /* Clear Power-down registers */
  106. sw zero, MC_SELFRFSH(t0)
  107. /* Set CAS Latency */
  108. li t1, 0x00000020 /* CL = 2 */
  109. sw t1, MC_MRSCODE(t0)
  110. /* Set word width to 16 bit */
  111. li t1, 0x2
  112. sw t1, MC_CFGDW(t0)
  113. /* Set CS0 to SDRAM parameters */
  114. li t1, 0x000014C9
  115. sw t1, MC_CFGPB0(t0)
  116. /* Set SDRAM latency parameters */
  117. li t1, 0x00026325 /* BC PC100 */
  118. sw t1, MC_LATENCY(t0)
  119. /* Set SDRAM refresh rate */
  120. li t1, 0x00000C30 /* 4K/64ms @ 100MHz */
  121. sw t1, MC_TREFRESH(t0)
  122. /* Finally enable the controller */
  123. li t1, 1
  124. sw t1, MC_CTRLENA(t0)
  125. j ra
  126. nop