lowlevel_init.S 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. modified from SH-IPL+g
  3. Renesaso SuperH / Solution Enginge MS775xSE01 BSC setting.
  4. Support CPU : SH7750/SH7750S/SH7750R/SH7751/SH7751R
  5. Coyright (c) 2007 Nobuhiro Iwamatsu <iwmatsu@nigauri.org>
  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/processor.h>
  27. #ifdef CONFIG_CPU_SH7751
  28. #define BCR2_D_VALUE 0x2FFC /* Area 1-6 width: 32/32/32/32/32/16 */
  29. #define WCR1_D_VALUE 0x02770771 /* DMA:0 A6:2 A3:0 A0:1 Others:15 */
  30. #ifdef CONFIG_MARUBUN_PCCARD
  31. #define WCR2_D_VALUE 0xFFFE4FE7 /* A6:15 A6B:7 A5:15 A5B:7 A4:15
  32. A3:2 A2:15 A1:15 A0:6 A0B:7 */
  33. #else /* CONFIG_MARUBUN_PCCARD */
  34. #define WCR2_D_VALUE 0x7FFE4FE7 /* A6:3 A6B:7 A5:15 A5B:7 A4:15
  35. A3:2 A2:15 A1:15 A0:6 A0B:7 */
  36. #endif /* CONFIG_MARUBUN_PCCARD */
  37. #define WCR3_D_VALUE 0x01777771 /* A6: 0-1 A5: 1-3 A4: 1-3 A3: 1-3
  38. A2: 1-3 A1: 1-3 A0: 0-1 */
  39. #define RTCOR_D_VALUE 0xA50D /* Write code A5, data 0D (~15us?) */
  40. #define SDMR3_ADDRESS 0xFF940088 /* SDMR3 address on 32-bit bus */
  41. #define MCR_D1_VALUE 0x100901B4 /* SDRAM 32-bit, CAS/RAS Refresh, ... */
  42. #define MCR_D2_VALUE 0x500901B4 /* Same w/MRSET now 1 (mode reg cmd) */
  43. #else /* CONFIG_CPU_SH7751 */
  44. #define BCR2_D_VALUE 0x2E3C /* Area 1-6 width: 32/32/64/16/32/16 */
  45. #define WCR1_D_VALUE 0x02720777 /* DMA:0 A6:2 A4:2 A3:0 Others:15 */
  46. #define WCR2_D_VALUE 0xFFFE4FFF /* A6:15 A6B:7 A5:15 A5B:7 A4:15
  47. A3:2 A2:15 A1:15 A0:15 A0B:7 */
  48. #define WCR3_D_VALUE 0x01717771 /* A6: 0-1 A5: 1-3 A4: 0-1 A3: 1-3
  49. A2: 1-3 A1: 1-3 A0: 0-1 */
  50. #define RTCOR_D_VALUE 0xA510 /* Write code A5, data 10 (~15us?) */
  51. #define SDMR3_ADDRESS 0xFF940110 /* SDMR3 address on 64-bit bus */
  52. #define MCR_D1_VALUE 0x8801001C /* SDRAM 64-bit, CAS/RAS Refresh, ... */
  53. #define MCR_D2_VALUE 0xC801001C /* Same w/MRSET now 1 (mode reg cmd) */
  54. #endif /* CONFIG_CPU_SH7751 */
  55. .global lowlevel_init
  56. .text
  57. .align 2
  58. lowlevel_init:
  59. mov.l CCR_A, r1 ! CCR Address
  60. mov.l CCR_D_DISABLE, r0 ! CCR Data
  61. mov.l r0, @r1
  62. init_bsc:
  63. mov.l FRQCR_A,r1 /* FRQCR Address */
  64. mov.l FRQCR_D,r0 /* FRQCR Data */
  65. mov.w r0,@r1
  66. mov.l BCR1_A,r1 /* BCR1 Address */
  67. mov.l BCR1_D,r0 /* BCR1 Data */
  68. mov.l r0,@r1
  69. mov.l BCR2_A,r1 /* BCR2 Address */
  70. mov.l BCR2_D,r0 /* BCR2 Data */
  71. mov.w r0,@r1
  72. mov.l WCR1_A,r1 /* WCR1 Address */
  73. mov.l WCR1_D,r0 /* WCR1 Data */
  74. mov.l r0,@r1
  75. mov.l WCR2_A,r1 /* WCR2 Address */
  76. mov.l WCR2_D,r0 /* WCR2 Data */
  77. mov.l r0,@r1
  78. mov.l WCR3_A,r1 /* WCR3 Address */
  79. mov.l WCR3_D,r0 /* WCR3 Data */
  80. mov.l r0,@r1
  81. mov.l MCR_A,r1 /* MCR Address */
  82. mov.l MCR_D1,r0 /* MCR Data1 */
  83. mov.l r0,@r1
  84. mov.l SDMR3_A,r1 /* Set SDRAM mode */
  85. mov #0,r0
  86. mov.b r0,@r1
  87. ! Do you need PCMCIA setting?
  88. ! If so, please add the lines here...
  89. mov.l RTCNT_A,r1 /* RTCNT Address */
  90. mov.l RTCNT_D,r0 /* RTCNT Data */
  91. mov.w r0,@r1
  92. mov.l RTCOR_A,r1 /* RTCOR Address */
  93. mov.l RTCOR_D,r0 /* RTCOR Data */
  94. mov.w r0,@r1
  95. mov.l RTCSR_A,r1 /* RTCSR Address */
  96. mov.l RTCSR_D,r0 /* RTCSR Data */
  97. mov.w r0,@r1
  98. mov.l RFCR_A,r1 /* RFCR Address */
  99. mov.l RFCR_D,r0 /* RFCR Data */
  100. mov.w r0,@r1 /* Clear reflesh counter */
  101. /* Wait DRAM refresh 30 times */
  102. mov #30,r3
  103. 1:
  104. mov.w @r1,r0
  105. extu.w r0,r2
  106. cmp/hi r3,r2
  107. bf 1b
  108. mov.l MCR_A,r1 /* MCR Address */
  109. mov.l MCR_D2,r0 /* MCR Data2 */
  110. mov.l r0,@r1
  111. mov.l SDMR3_A,r1 /* Set SDRAM mode */
  112. mov #0,r0
  113. mov.b r0,@r1
  114. rts
  115. nop
  116. .align 2
  117. CCR_A: .long CCR
  118. CCR_D_DISABLE: .long 0x0808
  119. FRQCR_A: .long FRQCR
  120. FRQCR_D:
  121. #ifdef CONFIG_CPU_TYPE_R
  122. .long 0x00000e1a /* 12:3:3 */
  123. #else /* CONFIG_CPU_TYPE_R */
  124. #ifdef CONFIG_GOOD_SESH4
  125. .long 0x00000e13 /* 6:2:1 */
  126. #else
  127. .long 0x00000e23 /* 6:1:1 */
  128. #endif
  129. #endif /* CONFIG_CPU_TYPE_R */
  130. BCR1_A: .long BCR1
  131. BCR1_D: .long 0x00000008 /* Area 3 SDRAM */
  132. BCR2_A: .long BCR2
  133. BCR2_D: .long BCR2_D_VALUE /* Bus width settings */
  134. WCR1_A: .long WCR1
  135. WCR1_D: .long WCR1_D_VALUE /* Inter-area or turnaround wait states */
  136. WCR2_A: .long WCR2
  137. WCR2_D: .long WCR2_D_VALUE /* Per-area access and burst wait states */
  138. WCR3_A: .long WCR3
  139. WCR3_D: .long WCR3_D_VALUE /* Address setup and data hold cycles */
  140. RTCSR_A: .long RTCSR
  141. RTCSR_D: .long 0xA518 /* RTCSR Write Code A5h Data 18h */
  142. RTCNT_A: .long RTCNT
  143. RTCNT_D: .long 0xA500 /* RTCNT Write Code A5h Data 00h */
  144. RTCOR_A: .long RTCOR
  145. RTCOR_D: .long RTCOR_D_VALUE /* Set refresh time (about 15us) */
  146. SDMR3_A: .long SDMR3_ADDRESS
  147. MCR_A: .long MCR
  148. MCR_D1: .long MCR_D1_VALUE
  149. MCR_D2: .long MCR_D2_VALUE
  150. RFCR_A: .long RFCR
  151. RFCR_D: .long 0xA400 /* RFCR Write Code A4h Data 00h */