head-uc-fr555.S 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /* head-uc-fr555.S: FR555 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 __551_DARS0 0xfeff0100
  20. #define __551_DARS1 0xfeff0104
  21. #define __551_DARS2 0xfeff0108
  22. #define __551_DARS3 0xfeff010c
  23. #define __551_DAMK0 0xfeff0110
  24. #define __551_DAMK1 0xfeff0114
  25. #define __551_DAMK2 0xfeff0118
  26. #define __551_DAMK3 0xfeff011c
  27. #define __551_LCR 0xfeff1100
  28. #define __551_LSBR 0xfeff1c00
  29. __INIT
  30. .balign 4
  31. ###############################################################################
  32. #
  33. # describe the position and layout of the SDRAM controller registers
  34. #
  35. # ENTRY: EXIT:
  36. # GR5 - cacheline size
  37. # GR11 - displacement of 2nd SDRAM addr reg from GR14
  38. # GR12 - displacement of 3rd SDRAM addr reg from GR14
  39. # GR13 - displacement of 4th SDRAM addr reg from GR14
  40. # GR14 - address of 1st SDRAM addr reg
  41. # GR15 - amount to shift address by to match SDRAM addr reg
  42. # GR26 &__head_reference [saved]
  43. # GR30 LED address [saved]
  44. # CC0 - T if DARS0 is present
  45. # CC1 - T if DARS1 is present
  46. # CC2 - T if DARS2 is present
  47. # CC3 - T if DARS3 is present
  48. #
  49. ###############################################################################
  50. .globl __head_fr555_describe_sdram
  51. __head_fr555_describe_sdram:
  52. sethi.p %hi(__551_DARS0),gr14
  53. setlo %lo(__551_DARS0),gr14
  54. setlos.p #__551_DARS1-__551_DARS0,gr11
  55. setlos #__551_DARS2-__551_DARS0,gr12
  56. setlos.p #__551_DARS3-__551_DARS0,gr13
  57. setlos #64,gr5 ; cacheline size
  58. setlos #20,gr15 ; amount to shift addr by
  59. setlos #0x00ff,gr4
  60. movgs gr4,cccr ; extant DARS/DAMK regs
  61. bralr
  62. ###############################################################################
  63. #
  64. # rearrange the bus controller registers
  65. #
  66. # ENTRY: EXIT:
  67. # GR26 &__head_reference [saved]
  68. # GR30 LED address revised LED address
  69. #
  70. ###############################################################################
  71. .globl __head_fr555_set_busctl
  72. __head_fr555_set_busctl:
  73. LEDS 0x100f
  74. sethi.p %hi(__551_LSBR),gr10
  75. setlo %lo(__551_LSBR),gr10
  76. sethi.p %hi(__551_LCR),gr11
  77. setlo %lo(__551_LCR),gr11
  78. # set the bus controller
  79. sethi.p %hi(__region_CS1),gr4
  80. setlo %lo(__region_CS1),gr4
  81. sethi.p %hi(__region_CS1_M),gr5
  82. setlo %lo(__region_CS1_M),gr5
  83. sethi.p %hi(__region_CS1_C),gr6
  84. setlo %lo(__region_CS1_C),gr6
  85. sti gr4,@(gr10,#1*0x08)
  86. sti gr5,@(gr10,#1*0x08+0x100)
  87. sti gr6,@(gr11,#1*0x08)
  88. sethi.p %hi(__region_CS2),gr4
  89. setlo %lo(__region_CS2),gr4
  90. sethi.p %hi(__region_CS2_M),gr5
  91. setlo %lo(__region_CS2_M),gr5
  92. sethi.p %hi(__region_CS2_C),gr6
  93. setlo %lo(__region_CS2_C),gr6
  94. sti gr4,@(gr10,#2*0x08)
  95. sti gr5,@(gr10,#2*0x08+0x100)
  96. sti gr6,@(gr11,#2*0x08)
  97. sethi.p %hi(__region_CS3),gr4
  98. setlo %lo(__region_CS3),gr4
  99. sethi.p %hi(__region_CS3_M),gr5
  100. setlo %lo(__region_CS3_M),gr5
  101. sethi.p %hi(__region_CS3_C),gr6
  102. setlo %lo(__region_CS3_C),gr6
  103. sti gr4,@(gr10,#3*0x08)
  104. sti gr5,@(gr10,#3*0x08+0x100)
  105. sti gr6,@(gr11,#3*0x08)
  106. sethi.p %hi(__region_CS4),gr4
  107. setlo %lo(__region_CS4),gr4
  108. sethi.p %hi(__region_CS4_M),gr5
  109. setlo %lo(__region_CS4_M),gr5
  110. sethi.p %hi(__region_CS4_C),gr6
  111. setlo %lo(__region_CS4_C),gr6
  112. sti gr4,@(gr10,#4*0x08)
  113. sti gr5,@(gr10,#4*0x08+0x100)
  114. sti gr6,@(gr11,#4*0x08)
  115. sethi.p %hi(__region_CS5),gr4
  116. setlo %lo(__region_CS5),gr4
  117. sethi.p %hi(__region_CS5_M),gr5
  118. setlo %lo(__region_CS5_M),gr5
  119. sethi.p %hi(__region_CS5_C),gr6
  120. setlo %lo(__region_CS5_C),gr6
  121. sti gr4,@(gr10,#5*0x08)
  122. sti gr5,@(gr10,#5*0x08+0x100)
  123. sti gr6,@(gr11,#5*0x08)
  124. sethi.p %hi(__region_CS6),gr4
  125. setlo %lo(__region_CS6),gr4
  126. sethi.p %hi(__region_CS6_M),gr5
  127. setlo %lo(__region_CS6_M),gr5
  128. sethi.p %hi(__region_CS6_C),gr6
  129. setlo %lo(__region_CS6_C),gr6
  130. sti gr4,@(gr10,#6*0x08)
  131. sti gr5,@(gr10,#6*0x08+0x100)
  132. sti gr6,@(gr11,#6*0x08)
  133. sethi.p %hi(__region_CS7),gr4
  134. setlo %lo(__region_CS7),gr4
  135. sethi.p %hi(__region_CS7_M),gr5
  136. setlo %lo(__region_CS7_M),gr5
  137. sethi.p %hi(__region_CS7_C),gr6
  138. setlo %lo(__region_CS7_C),gr6
  139. sti gr4,@(gr10,#7*0x08)
  140. sti gr5,@(gr10,#7*0x08+0x100)
  141. sti gr6,@(gr11,#7*0x08)
  142. membar
  143. bar
  144. # adjust LED bank address
  145. #ifdef CONFIG_MB93091_VDK
  146. sethi.p %hi(LED_ADDR - 0x20000000 +__region_CS2),gr30
  147. setlo %lo(LED_ADDR - 0x20000000 +__region_CS2),gr30
  148. #endif
  149. bralr
  150. ###############################################################################
  151. #
  152. # determine the total SDRAM size
  153. #
  154. # ENTRY: EXIT:
  155. # GR25 - SDRAM size
  156. # GR26 &__head_reference [saved]
  157. # GR30 LED address [saved]
  158. #
  159. ###############################################################################
  160. .globl __head_fr555_survey_sdram
  161. __head_fr555_survey_sdram:
  162. sethi.p %hi(__551_DAMK0),gr11
  163. setlo %lo(__551_DAMK0),gr11
  164. sethi.p %hi(__551_DARS0),gr12
  165. setlo %lo(__551_DARS0),gr12
  166. sethi.p %hi(0xfff),gr17 ; unused SDRAM AMK value
  167. setlo %lo(0xfff),gr17
  168. setlos #0,gr25
  169. ldi @(gr11,#0x00),gr6 ; DAMK0: bits 11:0 match addr 11:0
  170. subcc gr6,gr17,gr0,icc0
  171. beq icc0,#0,__head_no_DCS0
  172. ldi @(gr12,#0x00),gr4 ; DARS0
  173. add gr25,gr6,gr25
  174. addi gr25,#1,gr25
  175. __head_no_DCS0:
  176. ldi @(gr11,#0x04),gr6 ; DAMK1: bits 11:0 match addr 11:0
  177. subcc gr6,gr17,gr0,icc0
  178. beq icc0,#0,__head_no_DCS1
  179. ldi @(gr12,#0x04),gr4 ; DARS1
  180. add gr25,gr6,gr25
  181. addi gr25,#1,gr25
  182. __head_no_DCS1:
  183. ldi @(gr11,#0x8),gr6 ; DAMK2: bits 11:0 match addr 11:0
  184. subcc gr6,gr17,gr0,icc0
  185. beq icc0,#0,__head_no_DCS2
  186. ldi @(gr12,#0x8),gr4 ; DARS2
  187. add gr25,gr6,gr25
  188. addi gr25,#1,gr25
  189. __head_no_DCS2:
  190. ldi @(gr11,#0xc),gr6 ; DAMK3: bits 11:0 match addr 11:0
  191. subcc gr6,gr17,gr0,icc0
  192. beq icc0,#0,__head_no_DCS3
  193. ldi @(gr12,#0xc),gr4 ; DARS3
  194. add gr25,gr6,gr25
  195. addi gr25,#1,gr25
  196. __head_no_DCS3:
  197. slli gr25,#20,gr25 ; shift [11:0] -> [31:20]
  198. bralr
  199. ###############################################################################
  200. #
  201. # set the protection map with the I/DAMPR registers
  202. #
  203. # ENTRY: EXIT:
  204. # GR25 SDRAM size saved
  205. # GR30 LED address saved
  206. #
  207. ###############################################################################
  208. .globl __head_fr555_set_protection
  209. __head_fr555_set_protection:
  210. movsg lr,gr27
  211. sethi.p %hi(0xfff00000),gr11
  212. setlo %lo(0xfff00000),gr11
  213. # set the I/O region protection registers for FR555
  214. sethi.p %hi(__region_IO),gr7
  215. setlo %lo(__region_IO),gr7
  216. ori gr7,#xAMPRx_SS_512Mb|xAMPRx_S_KERNEL|xAMPRx_C|xAMPRx_V,gr5
  217. movgs gr0,iampr15
  218. movgs gr0,iamlr15
  219. movgs gr5,dampr15
  220. movgs gr7,damlr15
  221. # need to tile the remaining IAMPR/DAMPR registers to cover as much of the RAM as possible
  222. # - start with the highest numbered registers
  223. sethi.p %hi(__kernel_image_end),gr8
  224. setlo %lo(__kernel_image_end),gr8
  225. sethi.p %hi(32768),gr4 ; allow for a maximal allocator bitmap
  226. setlo %lo(32768),gr4
  227. add gr8,gr4,gr8
  228. sethi.p %hi(1024*2048-1),gr4 ; round up to nearest 2MiB
  229. setlo %lo(1024*2048-1),gr4
  230. add.p gr8,gr4,gr8
  231. not gr4,gr4
  232. and gr8,gr4,gr8
  233. sethi.p %hi(__page_offset),gr9
  234. setlo %lo(__page_offset),gr9
  235. add gr9,gr25,gr9
  236. # GR8 = base of uncovered RAM
  237. # GR9 = top of uncovered RAM
  238. # GR11 - mask for DAMLR/IAMLR regs
  239. #
  240. call __head_split_region
  241. movgs gr4,iampr14
  242. movgs gr6,iamlr14
  243. movgs gr5,dampr14
  244. movgs gr7,damlr14
  245. call __head_split_region
  246. movgs gr4,iampr13
  247. movgs gr6,iamlr13
  248. movgs gr5,dampr13
  249. movgs gr7,damlr13
  250. call __head_split_region
  251. movgs gr4,iampr12
  252. movgs gr6,iamlr12
  253. movgs gr5,dampr12
  254. movgs gr7,damlr12
  255. call __head_split_region
  256. movgs gr4,iampr11
  257. movgs gr6,iamlr11
  258. movgs gr5,dampr11
  259. movgs gr7,damlr11
  260. call __head_split_region
  261. movgs gr4,iampr10
  262. movgs gr6,iamlr10
  263. movgs gr5,dampr10
  264. movgs gr7,damlr10
  265. call __head_split_region
  266. movgs gr4,iampr9
  267. movgs gr6,iamlr9
  268. movgs gr5,dampr9
  269. movgs gr7,damlr9
  270. call __head_split_region
  271. movgs gr4,iampr8
  272. movgs gr6,iamlr8
  273. movgs gr5,dampr8
  274. movgs gr7,damlr8
  275. call __head_split_region
  276. movgs gr4,iampr7
  277. movgs gr6,iamlr7
  278. movgs gr5,dampr7
  279. movgs gr7,damlr7
  280. call __head_split_region
  281. movgs gr4,iampr6
  282. movgs gr6,iamlr6
  283. movgs gr5,dampr6
  284. movgs gr7,damlr6
  285. call __head_split_region
  286. movgs gr4,iampr5
  287. movgs gr6,iamlr5
  288. movgs gr5,dampr5
  289. movgs gr7,damlr5
  290. call __head_split_region
  291. movgs gr4,iampr4
  292. movgs gr6,iamlr4
  293. movgs gr5,dampr4
  294. movgs gr7,damlr4
  295. call __head_split_region
  296. movgs gr4,iampr3
  297. movgs gr6,iamlr3
  298. movgs gr5,dampr3
  299. movgs gr7,damlr3
  300. call __head_split_region
  301. movgs gr4,iampr2
  302. movgs gr6,iamlr2
  303. movgs gr5,dampr2
  304. movgs gr7,damlr2
  305. call __head_split_region
  306. movgs gr4,iampr1
  307. movgs gr6,iamlr1
  308. movgs gr5,dampr1
  309. movgs gr7,damlr1
  310. # cover kernel core image with kernel-only segment
  311. sethi.p %hi(__page_offset),gr8
  312. setlo %lo(__page_offset),gr8
  313. call __head_split_region
  314. #ifdef CONFIG_PROTECT_KERNEL
  315. ori.p gr4,#xAMPRx_S_KERNEL,gr4
  316. ori gr5,#xAMPRx_S_KERNEL,gr5
  317. #endif
  318. movgs gr4,iampr0
  319. movgs gr6,iamlr0
  320. movgs gr5,dampr0
  321. movgs gr7,damlr0
  322. jmpl @(gr27,gr0)