head-uc-fr401.S 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /* head-uc-fr401.S: FR401/3/5 uc-linux specific bits of initialisation
  2. *
  3. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/threads.h>
  13. #include <linux/linkage.h>
  14. #include <asm/ptrace.h>
  15. #include <asm/page.h>
  16. #include <asm/spr-regs.h>
  17. #include <asm/mb86943a.h>
  18. #include "head.inc"
  19. #define __400_DBR0 0xfe000e00
  20. #define __400_DBR1 0xfe000e08
  21. #define __400_DBR2 0xfe000e10 /* not on FR401 */
  22. #define __400_DBR3 0xfe000e18 /* not on FR401 */
  23. #define __400_DAM0 0xfe000f00
  24. #define __400_DAM1 0xfe000f08
  25. #define __400_DAM2 0xfe000f10 /* not on FR401 */
  26. #define __400_DAM3 0xfe000f18 /* not on FR401 */
  27. #define __400_LGCR 0xfe000010
  28. #define __400_LCR 0xfe000100
  29. #define __400_LSBR 0xfe000c00
  30. __INIT
  31. .balign 4
  32. ###############################################################################
  33. #
  34. # describe the position and layout of the SDRAM controller registers
  35. #
  36. # ENTRY: EXIT:
  37. # GR5 - cacheline size
  38. # GR11 - displacement of 2nd SDRAM addr reg from GR14
  39. # GR12 - displacement of 3rd SDRAM addr reg from GR14
  40. # GR13 - displacement of 4th SDRAM addr reg from GR14
  41. # GR14 - address of 1st SDRAM addr reg
  42. # GR15 - amount to shift address by to match SDRAM addr reg
  43. # GR26 &__head_reference [saved]
  44. # GR30 LED address [saved]
  45. # CC0 - T if DBR0 is present
  46. # CC1 - T if DBR1 is present
  47. # CC2 - T if DBR2 is present (not FR401/FR401A)
  48. # CC3 - T if DBR3 is present (not FR401/FR401A)
  49. #
  50. ###############################################################################
  51. .globl __head_fr401_describe_sdram
  52. __head_fr401_describe_sdram:
  53. sethi.p %hi(__400_DBR0),gr14
  54. setlo %lo(__400_DBR0),gr14
  55. setlos.p #__400_DBR1-__400_DBR0,gr11
  56. setlos #__400_DBR2-__400_DBR0,gr12
  57. setlos.p #__400_DBR3-__400_DBR0,gr13
  58. setlos #32,gr5 ; cacheline size
  59. setlos.p #0,gr15 ; amount to shift addr reg by
  60. # specify which DBR regs are present
  61. setlos #0x00ff,gr4
  62. movgs gr4,cccr
  63. movsg psr,gr3 ; check for FR401/FR401A
  64. srli gr3,#25,gr3
  65. subicc gr3,#0x20>>1,gr0,icc0
  66. bnelr icc0,#1
  67. setlos #0x000f,gr4
  68. movgs gr4,cccr
  69. bralr
  70. ###############################################################################
  71. #
  72. # rearrange the bus controller registers
  73. #
  74. # ENTRY: EXIT:
  75. # GR26 &__head_reference [saved]
  76. # GR30 LED address revised LED address
  77. #
  78. ###############################################################################
  79. .globl __head_fr401_set_busctl
  80. __head_fr401_set_busctl:
  81. sethi.p %hi(__400_LGCR),gr4
  82. setlo %lo(__400_LGCR),gr4
  83. sethi.p %hi(__400_LSBR),gr10
  84. setlo %lo(__400_LSBR),gr10
  85. sethi.p %hi(__400_LCR),gr11
  86. setlo %lo(__400_LCR),gr11
  87. # set the bus controller
  88. ldi @(gr4,#0),gr5
  89. ori gr5,#0xff,gr5 ; make sure all chip-selects are enabled
  90. sti gr5,@(gr4,#0)
  91. sethi.p %hi(__region_CS1),gr4
  92. setlo %lo(__region_CS1),gr4
  93. sethi.p %hi(__region_CS1_M),gr5
  94. setlo %lo(__region_CS1_M),gr5
  95. sethi.p %hi(__region_CS1_C),gr6
  96. setlo %lo(__region_CS1_C),gr6
  97. sti gr4,@(gr10,#1*0x08)
  98. sti gr5,@(gr10,#1*0x08+0x100)
  99. sti gr6,@(gr11,#1*0x08)
  100. sethi.p %hi(__region_CS2),gr4
  101. setlo %lo(__region_CS2),gr4
  102. sethi.p %hi(__region_CS2_M),gr5
  103. setlo %lo(__region_CS2_M),gr5
  104. sethi.p %hi(__region_CS2_C),gr6
  105. setlo %lo(__region_CS2_C),gr6
  106. sti gr4,@(gr10,#2*0x08)
  107. sti gr5,@(gr10,#2*0x08+0x100)
  108. sti gr6,@(gr11,#2*0x08)
  109. sethi.p %hi(__region_CS3),gr4
  110. setlo %lo(__region_CS3),gr4
  111. sethi.p %hi(__region_CS3_M),gr5
  112. setlo %lo(__region_CS3_M),gr5
  113. sethi.p %hi(__region_CS3_C),gr6
  114. setlo %lo(__region_CS3_C),gr6
  115. sti gr4,@(gr10,#3*0x08)
  116. sti gr5,@(gr10,#3*0x08+0x100)
  117. sti gr6,@(gr11,#3*0x08)
  118. sethi.p %hi(__region_CS4),gr4
  119. setlo %lo(__region_CS4),gr4
  120. sethi.p %hi(__region_CS4_M),gr5
  121. setlo %lo(__region_CS4_M),gr5
  122. sethi.p %hi(__region_CS4_C),gr6
  123. setlo %lo(__region_CS4_C),gr6
  124. sti gr4,@(gr10,#4*0x08)
  125. sti gr5,@(gr10,#4*0x08+0x100)
  126. sti gr6,@(gr11,#4*0x08)
  127. sethi.p %hi(__region_CS5),gr4
  128. setlo %lo(__region_CS5),gr4
  129. sethi.p %hi(__region_CS5_M),gr5
  130. setlo %lo(__region_CS5_M),gr5
  131. sethi.p %hi(__region_CS5_C),gr6
  132. setlo %lo(__region_CS5_C),gr6
  133. sti gr4,@(gr10,#5*0x08)
  134. sti gr5,@(gr10,#5*0x08+0x100)
  135. sti gr6,@(gr11,#5*0x08)
  136. sethi.p %hi(__region_CS6),gr4
  137. setlo %lo(__region_CS6),gr4
  138. sethi.p %hi(__region_CS6_M),gr5
  139. setlo %lo(__region_CS6_M),gr5
  140. sethi.p %hi(__region_CS6_C),gr6
  141. setlo %lo(__region_CS6_C),gr6
  142. sti gr4,@(gr10,#6*0x08)
  143. sti gr5,@(gr10,#6*0x08+0x100)
  144. sti gr6,@(gr11,#6*0x08)
  145. sethi.p %hi(__region_CS7),gr4
  146. setlo %lo(__region_CS7),gr4
  147. sethi.p %hi(__region_CS7_M),gr5
  148. setlo %lo(__region_CS7_M),gr5
  149. sethi.p %hi(__region_CS7_C),gr6
  150. setlo %lo(__region_CS7_C),gr6
  151. sti gr4,@(gr10,#7*0x08)
  152. sti gr5,@(gr10,#7*0x08+0x100)
  153. sti gr6,@(gr11,#7*0x08)
  154. membar
  155. bar
  156. # adjust LED bank address
  157. sethi.p %hi(LED_ADDR - 0x20000000 +__region_CS2),gr30
  158. setlo %lo(LED_ADDR - 0x20000000 +__region_CS2),gr30
  159. bralr
  160. ###############################################################################
  161. #
  162. # determine the total SDRAM size
  163. #
  164. # ENTRY: EXIT:
  165. # GR25 - SDRAM size
  166. # GR26 &__head_reference [saved]
  167. # GR30 LED address [saved]
  168. #
  169. ###############################################################################
  170. .globl __head_fr401_survey_sdram
  171. __head_fr401_survey_sdram:
  172. sethi.p %hi(__400_DAM0),gr11
  173. setlo %lo(__400_DAM0),gr11
  174. sethi.p %hi(__400_DBR0),gr12
  175. setlo %lo(__400_DBR0),gr12
  176. sethi.p %hi(0xfe000000),gr17 ; unused SDRAM DBR value
  177. setlo %lo(0xfe000000),gr17
  178. setlos #0,gr25
  179. ldi @(gr12,#0x00),gr4 ; DAR0
  180. subcc gr4,gr17,gr0,icc0
  181. beq icc0,#0,__head_no_DCS0
  182. ldi @(gr11,#0x00),gr6 ; DAM0: bits 31:20 match addr 31:20
  183. add gr25,gr6,gr25
  184. addi gr25,#1,gr25
  185. __head_no_DCS0:
  186. ldi @(gr12,#0x08),gr4 ; DAR1
  187. subcc gr4,gr17,gr0,icc0
  188. beq icc0,#0,__head_no_DCS1
  189. ldi @(gr11,#0x08),gr6 ; DAM1: bits 31:20 match addr 31:20
  190. add gr25,gr6,gr25
  191. addi gr25,#1,gr25
  192. __head_no_DCS1:
  193. # FR401/FR401A does not have DCS2/3
  194. movsg psr,gr3
  195. srli gr3,#25,gr3
  196. subicc gr3,#0x20>>1,gr0,icc0
  197. beq icc0,#0,__head_no_DCS3
  198. ldi @(gr12,#0x10),gr4 ; DAR2
  199. subcc gr4,gr17,gr0,icc0
  200. beq icc0,#0,__head_no_DCS2
  201. ldi @(gr11,#0x10),gr6 ; DAM2: bits 31:20 match addr 31:20
  202. add gr25,gr6,gr25
  203. addi gr25,#1,gr25
  204. __head_no_DCS2:
  205. ldi @(gr12,#0x18),gr4 ; DAR3
  206. subcc gr4,gr17,gr0,icc0
  207. beq icc0,#0,__head_no_DCS3
  208. ldi @(gr11,#0x18),gr6 ; DAM3: bits 31:20 match addr 31:20
  209. add gr25,gr6,gr25
  210. addi gr25,#1,gr25
  211. __head_no_DCS3:
  212. bralr
  213. ###############################################################################
  214. #
  215. # set the protection map with the I/DAMPR registers
  216. #
  217. # ENTRY: EXIT:
  218. # GR25 SDRAM size [saved]
  219. # GR26 &__head_reference [saved]
  220. # GR30 LED address [saved]
  221. #
  222. ###############################################################################
  223. .globl __head_fr401_set_protection
  224. __head_fr401_set_protection:
  225. movsg lr,gr27
  226. # set the I/O region protection registers for FR401/3/5
  227. sethi.p %hi(__region_IO),gr5
  228. setlo %lo(__region_IO),gr5
  229. ori gr5,#xAMPRx_SS_512Mb|xAMPRx_S_KERNEL|xAMPRx_C|xAMPRx_V,gr5
  230. movgs gr0,iampr7
  231. movgs gr5,dampr7 ; General I/O tile
  232. # need to tile the remaining IAMPR/DAMPR registers to cover as much of the RAM as possible
  233. # - start with the highest numbered registers
  234. sethi.p %hi(__kernel_image_end),gr8
  235. setlo %lo(__kernel_image_end),gr8
  236. sethi.p %hi(32768),gr4 ; allow for a maximal allocator bitmap
  237. setlo %lo(32768),gr4
  238. add gr8,gr4,gr8
  239. sethi.p %hi(1024*2048-1),gr4 ; round up to nearest 2MiB
  240. setlo %lo(1024*2048-1),gr4
  241. add.p gr8,gr4,gr8
  242. not gr4,gr4
  243. and gr8,gr4,gr8
  244. sethi.p %hi(__page_offset),gr9
  245. setlo %lo(__page_offset),gr9
  246. add gr9,gr25,gr9
  247. # GR8 = base of uncovered RAM
  248. # GR9 = top of uncovered RAM
  249. #ifdef CONFIG_MB93093_PDK
  250. sethi.p %hi(__region_CS2),gr4
  251. setlo %lo(__region_CS2),gr4
  252. ori gr4,#xAMPRx_SS_1Mb|xAMPRx_S_KERNEL|xAMPRx_C|xAMPRx_V,gr4
  253. movgs gr4,dampr6
  254. movgs gr0,iampr6
  255. #else
  256. call __head_split_region
  257. movgs gr4,iampr6
  258. movgs gr5,dampr6
  259. #endif
  260. call __head_split_region
  261. movgs gr4,iampr5
  262. movgs gr5,dampr5
  263. call __head_split_region
  264. movgs gr4,iampr4
  265. movgs gr5,dampr4
  266. call __head_split_region
  267. movgs gr4,iampr3
  268. movgs gr5,dampr3
  269. call __head_split_region
  270. movgs gr4,iampr2
  271. movgs gr5,dampr2
  272. call __head_split_region
  273. movgs gr4,iampr1
  274. movgs gr5,dampr1
  275. # cover kernel core image with kernel-only segment
  276. sethi.p %hi(__page_offset),gr8
  277. setlo %lo(__page_offset),gr8
  278. call __head_split_region
  279. #ifdef CONFIG_PROTECT_KERNEL
  280. ori.p gr4,#xAMPRx_S_KERNEL,gr4
  281. ori gr5,#xAMPRx_S_KERNEL,gr5
  282. #endif
  283. movgs gr4,iampr0
  284. movgs gr5,dampr0
  285. jmpl @(gr27,gr0)