proc-arm926.S 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /*
  2. * linux/arch/arm/mm/proc-arm926.S: MMU functions for ARM926EJ-S
  3. *
  4. * Copyright (C) 1999-2001 ARM Limited
  5. * Copyright (C) 2000 Deep Blue Solutions Ltd.
  6. * hacked for non-paged-MM by Hyok S. Choi, 2003.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. *
  23. * These are the low level assembler for performing cache and TLB
  24. * functions on the arm926.
  25. *
  26. * CONFIG_CPU_ARM926_CPU_IDLE -> nohlt
  27. */
  28. #include <linux/linkage.h>
  29. #include <linux/init.h>
  30. #include <asm/assembler.h>
  31. #include <asm/hwcap.h>
  32. #include <asm/pgtable-hwdef.h>
  33. #include <asm/pgtable.h>
  34. #include <asm/page.h>
  35. #include <asm/ptrace.h>
  36. #include "proc-macros.S"
  37. /*
  38. * This is the maximum size of an area which will be invalidated
  39. * using the single invalidate entry instructions. Anything larger
  40. * than this, and we go for the whole cache.
  41. *
  42. * This value should be chosen such that we choose the cheapest
  43. * alternative.
  44. */
  45. #define CACHE_DLIMIT 16384
  46. /*
  47. * the cache line size of the I and D cache
  48. */
  49. #define CACHE_DLINESIZE 32
  50. .text
  51. /*
  52. * cpu_arm926_proc_init()
  53. */
  54. ENTRY(cpu_arm926_proc_init)
  55. mov pc, lr
  56. /*
  57. * cpu_arm926_proc_fin()
  58. */
  59. ENTRY(cpu_arm926_proc_fin)
  60. stmfd sp!, {lr}
  61. mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
  62. msr cpsr_c, ip
  63. bl arm926_flush_kern_cache_all
  64. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  65. bic r0, r0, #0x1000 @ ...i............
  66. bic r0, r0, #0x000e @ ............wca.
  67. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  68. ldmfd sp!, {pc}
  69. /*
  70. * cpu_arm926_reset(loc)
  71. *
  72. * Perform a soft reset of the system. Put the CPU into the
  73. * same state as it would be if it had been reset, and branch
  74. * to what would be the reset vector.
  75. *
  76. * loc: location to jump to for soft reset
  77. */
  78. .align 5
  79. ENTRY(cpu_arm926_reset)
  80. mov ip, #0
  81. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  82. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  83. #ifdef CONFIG_MMU
  84. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  85. #endif
  86. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  87. bic ip, ip, #0x000f @ ............wcam
  88. bic ip, ip, #0x1100 @ ...i...s........
  89. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  90. mov pc, r0
  91. /*
  92. * cpu_arm926_do_idle()
  93. *
  94. * Called with IRQs disabled
  95. */
  96. .align 10
  97. ENTRY(cpu_arm926_do_idle)
  98. mov r0, #0
  99. mrc p15, 0, r1, c1, c0, 0 @ Read control register
  100. mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
  101. bic r2, r1, #1 << 12
  102. mrs r3, cpsr @ Disable FIQs while Icache
  103. orr ip, r3, #PSR_F_BIT @ is disabled
  104. msr cpsr_c, ip
  105. mcr p15, 0, r2, c1, c0, 0 @ Disable I cache
  106. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  107. mcr p15, 0, r1, c1, c0, 0 @ Restore ICache enable
  108. msr cpsr_c, r3 @ Restore FIQ state
  109. mov pc, lr
  110. /*
  111. * flush_user_cache_all()
  112. *
  113. * Clean and invalidate all cache entries in a particular
  114. * address space.
  115. */
  116. ENTRY(arm926_flush_user_cache_all)
  117. /* FALLTHROUGH */
  118. /*
  119. * flush_kern_cache_all()
  120. *
  121. * Clean and invalidate the entire cache.
  122. */
  123. ENTRY(arm926_flush_kern_cache_all)
  124. mov r2, #VM_EXEC
  125. mov ip, #0
  126. __flush_whole_cache:
  127. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  128. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  129. #else
  130. 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
  131. bne 1b
  132. #endif
  133. tst r2, #VM_EXEC
  134. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  135. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  136. mov pc, lr
  137. /*
  138. * flush_user_cache_range(start, end, flags)
  139. *
  140. * Clean and invalidate a range of cache entries in the
  141. * specified address range.
  142. *
  143. * - start - start address (inclusive)
  144. * - end - end address (exclusive)
  145. * - flags - vm_flags describing address space
  146. */
  147. ENTRY(arm926_flush_user_cache_range)
  148. mov ip, #0
  149. sub r3, r1, r0 @ calculate total size
  150. cmp r3, #CACHE_DLIMIT
  151. bgt __flush_whole_cache
  152. 1: tst r2, #VM_EXEC
  153. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  154. mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  155. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  156. add r0, r0, #CACHE_DLINESIZE
  157. mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  158. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  159. add r0, r0, #CACHE_DLINESIZE
  160. #else
  161. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
  162. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  163. add r0, r0, #CACHE_DLINESIZE
  164. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
  165. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  166. add r0, r0, #CACHE_DLINESIZE
  167. #endif
  168. cmp r0, r1
  169. blo 1b
  170. tst r2, #VM_EXEC
  171. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  172. mov pc, lr
  173. /*
  174. * coherent_kern_range(start, end)
  175. *
  176. * Ensure coherency between the Icache and the Dcache in the
  177. * region described by start, end. If you have non-snooping
  178. * Harvard caches, you need to implement this function.
  179. *
  180. * - start - virtual start address
  181. * - end - virtual end address
  182. */
  183. ENTRY(arm926_coherent_kern_range)
  184. /* FALLTHROUGH */
  185. /*
  186. * coherent_user_range(start, end)
  187. *
  188. * Ensure coherency between the Icache and the Dcache in the
  189. * region described by start, end. If you have non-snooping
  190. * Harvard caches, you need to implement this function.
  191. *
  192. * - start - virtual start address
  193. * - end - virtual end address
  194. */
  195. ENTRY(arm926_coherent_user_range)
  196. bic r0, r0, #CACHE_DLINESIZE - 1
  197. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  198. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  199. add r0, r0, #CACHE_DLINESIZE
  200. cmp r0, r1
  201. blo 1b
  202. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  203. mov pc, lr
  204. /*
  205. * flush_kern_dcache_page(void *page)
  206. *
  207. * Ensure no D cache aliasing occurs, either with itself or
  208. * the I cache
  209. *
  210. * - addr - page aligned address
  211. */
  212. ENTRY(arm926_flush_kern_dcache_page)
  213. add r1, r0, #PAGE_SZ
  214. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  215. add r0, r0, #CACHE_DLINESIZE
  216. cmp r0, r1
  217. blo 1b
  218. mov r0, #0
  219. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  220. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  221. mov pc, lr
  222. /*
  223. * dma_inv_range(start, end)
  224. *
  225. * Invalidate (discard) the specified virtual address range.
  226. * May not write back any entries. If 'start' or 'end'
  227. * are not cache line aligned, those lines must be written
  228. * back.
  229. *
  230. * - start - virtual start address
  231. * - end - virtual end address
  232. *
  233. * (same as v4wb)
  234. */
  235. ENTRY(arm926_dma_inv_range)
  236. #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  237. tst r0, #CACHE_DLINESIZE - 1
  238. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  239. tst r1, #CACHE_DLINESIZE - 1
  240. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  241. #endif
  242. bic r0, r0, #CACHE_DLINESIZE - 1
  243. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  244. add r0, r0, #CACHE_DLINESIZE
  245. cmp r0, r1
  246. blo 1b
  247. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  248. mov pc, lr
  249. /*
  250. * dma_clean_range(start, end)
  251. *
  252. * Clean the specified virtual address range.
  253. *
  254. * - start - virtual start address
  255. * - end - virtual end address
  256. *
  257. * (same as v4wb)
  258. */
  259. ENTRY(arm926_dma_clean_range)
  260. #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  261. bic r0, r0, #CACHE_DLINESIZE - 1
  262. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  263. add r0, r0, #CACHE_DLINESIZE
  264. cmp r0, r1
  265. blo 1b
  266. #endif
  267. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  268. mov pc, lr
  269. /*
  270. * dma_flush_range(start, end)
  271. *
  272. * Clean and invalidate the specified virtual address range.
  273. *
  274. * - start - virtual start address
  275. * - end - virtual end address
  276. */
  277. ENTRY(arm926_dma_flush_range)
  278. bic r0, r0, #CACHE_DLINESIZE - 1
  279. 1:
  280. #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  281. mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  282. #else
  283. mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  284. #endif
  285. add r0, r0, #CACHE_DLINESIZE
  286. cmp r0, r1
  287. blo 1b
  288. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  289. mov pc, lr
  290. ENTRY(arm926_cache_fns)
  291. .long arm926_flush_kern_cache_all
  292. .long arm926_flush_user_cache_all
  293. .long arm926_flush_user_cache_range
  294. .long arm926_coherent_kern_range
  295. .long arm926_coherent_user_range
  296. .long arm926_flush_kern_dcache_page
  297. .long arm926_dma_inv_range
  298. .long arm926_dma_clean_range
  299. .long arm926_dma_flush_range
  300. ENTRY(cpu_arm926_dcache_clean_area)
  301. #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  302. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  303. add r0, r0, #CACHE_DLINESIZE
  304. subs r1, r1, #CACHE_DLINESIZE
  305. bhi 1b
  306. #endif
  307. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  308. mov pc, lr
  309. /* =============================== PageTable ============================== */
  310. /*
  311. * cpu_arm926_switch_mm(pgd)
  312. *
  313. * Set the translation base pointer to be as described by pgd.
  314. *
  315. * pgd: new page tables
  316. */
  317. .align 5
  318. ENTRY(cpu_arm926_switch_mm)
  319. #ifdef CONFIG_MMU
  320. mov ip, #0
  321. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  322. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  323. #else
  324. @ && 'Clean & Invalidate whole DCache'
  325. 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
  326. bne 1b
  327. #endif
  328. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  329. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  330. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  331. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  332. #endif
  333. mov pc, lr
  334. /*
  335. * cpu_arm926_set_pte_ext(ptep, pte, ext)
  336. *
  337. * Set a PTE and flush it out
  338. */
  339. .align 5
  340. ENTRY(cpu_arm926_set_pte_ext)
  341. #ifdef CONFIG_MMU
  342. armv3_set_pte_ext
  343. mov r0, r0
  344. #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  345. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  346. #endif
  347. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  348. #endif
  349. mov pc, lr
  350. __INIT
  351. .type __arm926_setup, #function
  352. __arm926_setup:
  353. mov r0, #0
  354. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  355. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  356. #ifdef CONFIG_MMU
  357. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  358. #endif
  359. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  360. mov r0, #4 @ disable write-back on caches explicitly
  361. mcr p15, 7, r0, c15, c0, 0
  362. #endif
  363. adr r5, arm926_crval
  364. ldmia r5, {r5, r6}
  365. mrc p15, 0, r0, c1, c0 @ get control register v4
  366. bic r0, r0, r5
  367. orr r0, r0, r6
  368. #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
  369. orr r0, r0, #0x4000 @ .1.. .... .... ....
  370. #endif
  371. mov pc, lr
  372. .size __arm926_setup, . - __arm926_setup
  373. /*
  374. * R
  375. * .RVI ZFRS BLDP WCAM
  376. * .011 0001 ..11 0101
  377. *
  378. */
  379. .type arm926_crval, #object
  380. arm926_crval:
  381. crval clear=0x00007f3f, mmuset=0x00003135, ucset=0x00001134
  382. __INITDATA
  383. /*
  384. * Purpose : Function pointers used to access above functions - all calls
  385. * come through these
  386. */
  387. .type arm926_processor_functions, #object
  388. arm926_processor_functions:
  389. .word v5tj_early_abort
  390. .word pabort_noifar
  391. .word cpu_arm926_proc_init
  392. .word cpu_arm926_proc_fin
  393. .word cpu_arm926_reset
  394. .word cpu_arm926_do_idle
  395. .word cpu_arm926_dcache_clean_area
  396. .word cpu_arm926_switch_mm
  397. .word cpu_arm926_set_pte_ext
  398. .size arm926_processor_functions, . - arm926_processor_functions
  399. .section ".rodata"
  400. .type cpu_arch_name, #object
  401. cpu_arch_name:
  402. .asciz "armv5tej"
  403. .size cpu_arch_name, . - cpu_arch_name
  404. .type cpu_elf_name, #object
  405. cpu_elf_name:
  406. .asciz "v5"
  407. .size cpu_elf_name, . - cpu_elf_name
  408. .type cpu_arm926_name, #object
  409. cpu_arm926_name:
  410. .asciz "ARM926EJ-S"
  411. .size cpu_arm926_name, . - cpu_arm926_name
  412. .align
  413. .section ".proc.info.init", #alloc, #execinstr
  414. .type __arm926_proc_info,#object
  415. __arm926_proc_info:
  416. .long 0x41069260 @ ARM926EJ-S (v5TEJ)
  417. .long 0xff0ffff0
  418. .long PMD_TYPE_SECT | \
  419. PMD_SECT_BUFFERABLE | \
  420. PMD_SECT_CACHEABLE | \
  421. PMD_BIT4 | \
  422. PMD_SECT_AP_WRITE | \
  423. PMD_SECT_AP_READ
  424. .long PMD_TYPE_SECT | \
  425. PMD_BIT4 | \
  426. PMD_SECT_AP_WRITE | \
  427. PMD_SECT_AP_READ
  428. b __arm926_setup
  429. .long cpu_arch_name
  430. .long cpu_elf_name
  431. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
  432. .long cpu_arm926_name
  433. .long arm926_processor_functions
  434. .long v4wbi_tlb_fns
  435. .long v4wb_user_fns
  436. .long arm926_cache_fns
  437. .size __arm926_proc_info, . - __arm926_proc_info