head-mmu-fr451.S 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. /* head-mmu-fr451.S: FR451 mmu-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/mem-layout.h>
  17. #include <asm/spr-regs.h>
  18. #include <asm/mb86943a.h>
  19. #include "head.inc"
  20. #define __400_DBR0 0xfe000e00
  21. #define __400_DBR1 0xfe000e08
  22. #define __400_DBR2 0xfe000e10
  23. #define __400_DBR3 0xfe000e18
  24. #define __400_DAM0 0xfe000f00
  25. #define __400_DAM1 0xfe000f08
  26. #define __400_DAM2 0xfe000f10
  27. #define __400_DAM3 0xfe000f18
  28. #define __400_LGCR 0xfe000010
  29. #define __400_LCR 0xfe000100
  30. #define __400_LSBR 0xfe000c00
  31. __INIT
  32. .balign 4
  33. ###############################################################################
  34. #
  35. # describe the position and layout of the SDRAM controller registers
  36. #
  37. # ENTRY: EXIT:
  38. # GR5 - cacheline size
  39. # GR11 - displacement of 2nd SDRAM addr reg from GR14
  40. # GR12 - displacement of 3rd SDRAM addr reg from GR14
  41. # GR13 - displacement of 4th SDRAM addr reg from GR14
  42. # GR14 - address of 1st SDRAM addr reg
  43. # GR15 - amount to shift address by to match SDRAM addr reg
  44. # GR26 &__head_reference [saved]
  45. # GR30 LED address [saved]
  46. # CC0 - T if DBR0 is present
  47. # CC1 - T if DBR1 is present
  48. # CC2 - T if DBR2 is present
  49. # CC3 - T if DBR3 is present
  50. #
  51. ###############################################################################
  52. .globl __head_fr451_describe_sdram
  53. __head_fr451_describe_sdram:
  54. sethi.p %hi(__400_DBR0),gr14
  55. setlo %lo(__400_DBR0),gr14
  56. setlos.p #__400_DBR1-__400_DBR0,gr11
  57. setlos #__400_DBR2-__400_DBR0,gr12
  58. setlos.p #__400_DBR3-__400_DBR0,gr13
  59. setlos #32,gr5 ; cacheline size
  60. setlos.p #0,gr15 ; amount to shift addr reg by
  61. setlos #0x00ff,gr4
  62. movgs gr4,cccr ; extant DARS/DAMK regs
  63. bralr
  64. ###############################################################################
  65. #
  66. # rearrange the bus controller registers
  67. #
  68. # ENTRY: EXIT:
  69. # GR26 &__head_reference [saved]
  70. # GR30 LED address revised LED address
  71. #
  72. ###############################################################################
  73. .globl __head_fr451_set_busctl
  74. __head_fr451_set_busctl:
  75. sethi.p %hi(__400_LGCR),gr4
  76. setlo %lo(__400_LGCR),gr4
  77. sethi.p %hi(__400_LSBR),gr10
  78. setlo %lo(__400_LSBR),gr10
  79. sethi.p %hi(__400_LCR),gr11
  80. setlo %lo(__400_LCR),gr11
  81. # set the bus controller
  82. ldi @(gr4,#0),gr5
  83. ori gr5,#0xff,gr5 ; make sure all chip-selects are enabled
  84. sti gr5,@(gr4,#0)
  85. sethi.p %hi(__region_CS1),gr4
  86. setlo %lo(__region_CS1),gr4
  87. sethi.p %hi(__region_CS1_M),gr5
  88. setlo %lo(__region_CS1_M),gr5
  89. sethi.p %hi(__region_CS1_C),gr6
  90. setlo %lo(__region_CS1_C),gr6
  91. sti gr4,@(gr10,#1*0x08)
  92. sti gr5,@(gr10,#1*0x08+0x100)
  93. sti gr6,@(gr11,#1*0x08)
  94. sethi.p %hi(__region_CS2),gr4
  95. setlo %lo(__region_CS2),gr4
  96. sethi.p %hi(__region_CS2_M),gr5
  97. setlo %lo(__region_CS2_M),gr5
  98. sethi.p %hi(__region_CS2_C),gr6
  99. setlo %lo(__region_CS2_C),gr6
  100. sti gr4,@(gr10,#2*0x08)
  101. sti gr5,@(gr10,#2*0x08+0x100)
  102. sti gr6,@(gr11,#2*0x08)
  103. sethi.p %hi(__region_CS3),gr4
  104. setlo %lo(__region_CS3),gr4
  105. sethi.p %hi(__region_CS3_M),gr5
  106. setlo %lo(__region_CS3_M),gr5
  107. sethi.p %hi(__region_CS3_C),gr6
  108. setlo %lo(__region_CS3_C),gr6
  109. sti gr4,@(gr10,#3*0x08)
  110. sti gr5,@(gr10,#3*0x08+0x100)
  111. sti gr6,@(gr11,#3*0x08)
  112. sethi.p %hi(__region_CS4),gr4
  113. setlo %lo(__region_CS4),gr4
  114. sethi.p %hi(__region_CS4_M),gr5
  115. setlo %lo(__region_CS4_M),gr5
  116. sethi.p %hi(__region_CS4_C),gr6
  117. setlo %lo(__region_CS4_C),gr6
  118. sti gr4,@(gr10,#4*0x08)
  119. sti gr5,@(gr10,#4*0x08+0x100)
  120. sti gr6,@(gr11,#4*0x08)
  121. sethi.p %hi(__region_CS5),gr4
  122. setlo %lo(__region_CS5),gr4
  123. sethi.p %hi(__region_CS5_M),gr5
  124. setlo %lo(__region_CS5_M),gr5
  125. sethi.p %hi(__region_CS5_C),gr6
  126. setlo %lo(__region_CS5_C),gr6
  127. sti gr4,@(gr10,#5*0x08)
  128. sti gr5,@(gr10,#5*0x08+0x100)
  129. sti gr6,@(gr11,#5*0x08)
  130. sethi.p %hi(__region_CS6),gr4
  131. setlo %lo(__region_CS6),gr4
  132. sethi.p %hi(__region_CS6_M),gr5
  133. setlo %lo(__region_CS6_M),gr5
  134. sethi.p %hi(__region_CS6_C),gr6
  135. setlo %lo(__region_CS6_C),gr6
  136. sti gr4,@(gr10,#6*0x08)
  137. sti gr5,@(gr10,#6*0x08+0x100)
  138. sti gr6,@(gr11,#6*0x08)
  139. sethi.p %hi(__region_CS7),gr4
  140. setlo %lo(__region_CS7),gr4
  141. sethi.p %hi(__region_CS7_M),gr5
  142. setlo %lo(__region_CS7_M),gr5
  143. sethi.p %hi(__region_CS7_C),gr6
  144. setlo %lo(__region_CS7_C),gr6
  145. sti gr4,@(gr10,#7*0x08)
  146. sti gr5,@(gr10,#7*0x08+0x100)
  147. sti gr6,@(gr11,#7*0x08)
  148. membar
  149. bar
  150. # adjust LED bank address
  151. #ifdef CONFIG_MB93091_VDK
  152. sethi.p %hi(__region_CS2 + 0x01200004),gr30
  153. setlo %lo(__region_CS2 + 0x01200004),gr30
  154. #endif
  155. bralr
  156. ###############################################################################
  157. #
  158. # determine the total SDRAM size
  159. #
  160. # ENTRY: EXIT:
  161. # GR25 - SDRAM size
  162. # GR26 &__head_reference [saved]
  163. # GR30 LED address [saved]
  164. #
  165. ###############################################################################
  166. .globl __head_fr451_survey_sdram
  167. __head_fr451_survey_sdram:
  168. sethi.p %hi(__400_DAM0),gr11
  169. setlo %lo(__400_DAM0),gr11
  170. sethi.p %hi(__400_DBR0),gr12
  171. setlo %lo(__400_DBR0),gr12
  172. sethi.p %hi(0xfe000000),gr17 ; unused SDRAM DBR value
  173. setlo %lo(0xfe000000),gr17
  174. setlos #0,gr25
  175. ldi @(gr12,#0x00),gr4 ; DAR0
  176. subcc gr4,gr17,gr0,icc0
  177. beq icc0,#0,__head_no_DCS0
  178. ldi @(gr11,#0x00),gr6 ; DAM0: bits 31:20 match addr 31:20
  179. add gr25,gr6,gr25
  180. addi gr25,#1,gr25
  181. __head_no_DCS0:
  182. ldi @(gr12,#0x08),gr4 ; DAR1
  183. subcc gr4,gr17,gr0,icc0
  184. beq icc0,#0,__head_no_DCS1
  185. ldi @(gr11,#0x08),gr6 ; DAM1: bits 31:20 match addr 31:20
  186. add gr25,gr6,gr25
  187. addi gr25,#1,gr25
  188. __head_no_DCS1:
  189. ldi @(gr12,#0x10),gr4 ; DAR2
  190. subcc gr4,gr17,gr0,icc0
  191. beq icc0,#0,__head_no_DCS2
  192. ldi @(gr11,#0x10),gr6 ; DAM2: bits 31:20 match addr 31:20
  193. add gr25,gr6,gr25
  194. addi gr25,#1,gr25
  195. __head_no_DCS2:
  196. ldi @(gr12,#0x18),gr4 ; DAR3
  197. subcc gr4,gr17,gr0,icc0
  198. beq icc0,#0,__head_no_DCS3
  199. ldi @(gr11,#0x18),gr6 ; DAM3: bits 31:20 match addr 31:20
  200. add gr25,gr6,gr25
  201. addi gr25,#1,gr25
  202. __head_no_DCS3:
  203. bralr
  204. ###############################################################################
  205. #
  206. # set the protection map with the I/DAMPR registers
  207. #
  208. # ENTRY: EXIT:
  209. # GR25 SDRAM size [saved]
  210. # GR26 &__head_reference [saved]
  211. # GR30 LED address [saved]
  212. #
  213. #
  214. # Using this map:
  215. # REGISTERS ADDRESS RANGE VIEW
  216. # =============== ====================== ===============================
  217. # IAMPR0/DAMPR0 0xC0000000-0xCFFFFFFF Cached kernel RAM Window
  218. # DAMPR11 0xE0000000-0xFFFFFFFF Uncached I/O
  219. #
  220. ###############################################################################
  221. .globl __head_fr451_set_protection
  222. __head_fr451_set_protection:
  223. movsg lr,gr27
  224. # set the I/O region protection registers for FR451 in MMU mode
  225. #define PGPROT_IO xAMPRx_L|xAMPRx_M|xAMPRx_S_KERNEL|xAMPRx_C|xAMPRx_V
  226. sethi.p %hi(__region_IO),gr5
  227. setlo %lo(__region_IO),gr5
  228. setlos #PGPROT_IO|xAMPRx_SS_512Mb,gr4
  229. or gr4,gr5,gr4
  230. movgs gr5,damlr11 ; General I/O tile
  231. movgs gr4,dampr11
  232. # need to open a window onto at least part of the RAM for the kernel's use
  233. sethi.p %hi(__sdram_base),gr8
  234. setlo %lo(__sdram_base),gr8 ; physical address
  235. sethi.p %hi(__page_offset),gr9
  236. setlo %lo(__page_offset),gr9 ; virtual address
  237. setlos #xAMPRx_L|xAMPRx_M|xAMPRx_SS_256Mb|xAMPRx_S_KERNEL|xAMPRx_V,gr11
  238. or gr8,gr11,gr8
  239. movgs gr9,iamlr0 ; mapped from real address 0
  240. movgs gr8,iampr0 ; cached kernel memory at 0xC0000000
  241. movgs gr9,damlr0
  242. movgs gr8,dampr0
  243. # set a temporary mapping for the kernel running at address 0 until we've turned on the MMU
  244. sethi.p %hi(__sdram_base),gr9
  245. setlo %lo(__sdram_base),gr9 ; virtual address
  246. and.p gr4,gr11,gr4
  247. and gr5,gr11,gr5
  248. or.p gr4,gr11,gr4
  249. or gr5,gr11,gr5
  250. movgs gr9,iamlr1 ; mapped from real address 0
  251. movgs gr8,iampr1 ; cached kernel memory at 0x00000000
  252. movgs gr9,damlr1
  253. movgs gr8,dampr1
  254. # we use DAMR2-10 for kmap_atomic(), cache flush and TLB management
  255. # since the DAMLR regs are not going to change, we can set them now
  256. # also set up IAMLR2 to the same as DAMLR5
  257. sethi.p %hi(KMAP_ATOMIC_PRIMARY_FRAME),gr4
  258. setlo %lo(KMAP_ATOMIC_PRIMARY_FRAME),gr4
  259. sethi.p %hi(PAGE_SIZE),gr5
  260. setlo %lo(PAGE_SIZE),gr5
  261. movgs gr4,damlr2
  262. movgs gr4,iamlr2
  263. add gr4,gr5,gr4
  264. movgs gr4,damlr3
  265. add gr4,gr5,gr4
  266. movgs gr4,damlr4
  267. add gr4,gr5,gr4
  268. movgs gr4,damlr5
  269. add gr4,gr5,gr4
  270. movgs gr4,damlr6
  271. add gr4,gr5,gr4
  272. movgs gr4,damlr7
  273. add gr4,gr5,gr4
  274. movgs gr4,damlr8
  275. add gr4,gr5,gr4
  276. movgs gr4,damlr9
  277. add gr4,gr5,gr4
  278. movgs gr4,damlr10
  279. movgs gr0,dampr2
  280. movgs gr0,dampr4
  281. movgs gr0,dampr5
  282. movgs gr0,dampr6
  283. movgs gr0,dampr7
  284. movgs gr0,dampr8
  285. movgs gr0,dampr9
  286. movgs gr0,dampr10
  287. movgs gr0,iamlr3
  288. movgs gr0,iamlr4
  289. movgs gr0,iamlr5
  290. movgs gr0,iamlr6
  291. movgs gr0,iamlr7
  292. movgs gr0,iampr2
  293. movgs gr0,iampr3
  294. movgs gr0,iampr4
  295. movgs gr0,iampr5
  296. movgs gr0,iampr6
  297. movgs gr0,iampr7
  298. # start in TLB context 0 with the swapper's page tables
  299. movgs gr0,cxnr
  300. sethi.p %hi(swapper_pg_dir),gr4
  301. setlo %lo(swapper_pg_dir),gr4
  302. sethi.p %hi(__page_offset),gr5
  303. setlo %lo(__page_offset),gr5
  304. sub gr4,gr5,gr4
  305. movgs gr4,ttbr
  306. setlos #xAMPRx_L|xAMPRx_M|xAMPRx_SS_16Kb|xAMPRx_S|xAMPRx_C|xAMPRx_V,gr5
  307. or gr4,gr5,gr4
  308. movgs gr4,dampr3
  309. # the FR451 also has an extra trap base register
  310. movsg tbr,gr4
  311. movgs gr4,btbr
  312. LEDS 0x3300
  313. jmpl @(gr27,gr0)
  314. ###############################################################################
  315. #
  316. # finish setting up the protection registers
  317. #
  318. ###############################################################################
  319. .globl __head_fr451_finalise_protection
  320. __head_fr451_finalise_protection:
  321. # turn on the timers as appropriate
  322. movgs gr0,timerh
  323. movgs gr0,timerl
  324. movgs gr0,timerd
  325. movsg hsr0,gr4
  326. sethi.p %hi(HSR0_ETMI),gr5
  327. setlo %lo(HSR0_ETMI),gr5
  328. or gr4,gr5,gr4
  329. movgs gr4,hsr0
  330. # clear the TLB entry cache
  331. movgs gr0,iamlr1
  332. movgs gr0,iampr1
  333. movgs gr0,damlr1
  334. movgs gr0,dampr1
  335. # clear the PGE cache
  336. sethi.p %hi(__flush_tlb_all),gr4
  337. setlo %lo(__flush_tlb_all),gr4
  338. jmpl @(gr4,gr0)