proc-arm1026.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. /*
  2. * linux/arch/arm/mm/proc-arm1026.S: MMU functions for ARM1026EJ-S
  3. *
  4. * Copyright (C) 2000 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. *
  14. * These are the low level assembler for performing cache and TLB
  15. * functions on the ARM1026EJ-S.
  16. */
  17. #include <linux/linkage.h>
  18. #include <linux/init.h>
  19. #include <asm/assembler.h>
  20. #include <asm/asm-offsets.h>
  21. #include <asm/hwcap.h>
  22. #include <asm/pgtable-hwdef.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/ptrace.h>
  25. #include "proc-macros.S"
  26. /*
  27. * This is the maximum size of an area which will be invalidated
  28. * using the single invalidate entry instructions. Anything larger
  29. * than this, and we go for the whole cache.
  30. *
  31. * This value should be chosen such that we choose the cheapest
  32. * alternative.
  33. */
  34. #define MAX_AREA_SIZE 32768
  35. /*
  36. * The size of one data cache line.
  37. */
  38. #define CACHE_DLINESIZE 32
  39. /*
  40. * The number of data cache segments.
  41. */
  42. #define CACHE_DSEGMENTS 16
  43. /*
  44. * The number of lines in a cache segment.
  45. */
  46. #define CACHE_DENTRIES 64
  47. /*
  48. * This is the size at which it becomes more efficient to
  49. * clean the whole cache, rather than using the individual
  50. * cache line maintenance instructions.
  51. */
  52. #define CACHE_DLIMIT 32768
  53. .text
  54. /*
  55. * cpu_arm1026_proc_init()
  56. */
  57. ENTRY(cpu_arm1026_proc_init)
  58. mov pc, lr
  59. /*
  60. * cpu_arm1026_proc_fin()
  61. */
  62. ENTRY(cpu_arm1026_proc_fin)
  63. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  64. bic r0, r0, #0x1000 @ ...i............
  65. bic r0, r0, #0x000e @ ............wca.
  66. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  67. mov pc, lr
  68. /*
  69. * cpu_arm1026_reset(loc)
  70. *
  71. * Perform a soft reset of the system. Put the CPU into the
  72. * same state as it would be if it had been reset, and branch
  73. * to what would be the reset vector.
  74. *
  75. * loc: location to jump to for soft reset
  76. */
  77. .align 5
  78. .pushsection .idmap.text, "ax"
  79. ENTRY(cpu_arm1026_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. ENDPROC(cpu_arm1026_reset)
  92. .popsection
  93. /*
  94. * cpu_arm1026_do_idle()
  95. */
  96. .align 5
  97. ENTRY(cpu_arm1026_do_idle)
  98. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  99. mov pc, lr
  100. /* ================================= CACHE ================================ */
  101. .align 5
  102. /*
  103. * flush_icache_all()
  104. *
  105. * Unconditionally clean and invalidate the entire icache.
  106. */
  107. ENTRY(arm1026_flush_icache_all)
  108. #ifndef CONFIG_CPU_ICACHE_DISABLE
  109. mov r0, #0
  110. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  111. #endif
  112. mov pc, lr
  113. ENDPROC(arm1026_flush_icache_all)
  114. /*
  115. * flush_user_cache_all()
  116. *
  117. * Invalidate all cache entries in a particular address
  118. * space.
  119. */
  120. ENTRY(arm1026_flush_user_cache_all)
  121. /* FALLTHROUGH */
  122. /*
  123. * flush_kern_cache_all()
  124. *
  125. * Clean and invalidate the entire cache.
  126. */
  127. ENTRY(arm1026_flush_kern_cache_all)
  128. mov r2, #VM_EXEC
  129. mov ip, #0
  130. __flush_whole_cache:
  131. #ifndef CONFIG_CPU_DCACHE_DISABLE
  132. 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
  133. bne 1b
  134. #endif
  135. tst r2, #VM_EXEC
  136. #ifndef CONFIG_CPU_ICACHE_DISABLE
  137. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  138. #endif
  139. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  140. mov pc, lr
  141. /*
  142. * flush_user_cache_range(start, end, flags)
  143. *
  144. * Invalidate a range of cache entries in the specified
  145. * address space.
  146. *
  147. * - start - start address (inclusive)
  148. * - end - end address (exclusive)
  149. * - flags - vm_flags for this space
  150. */
  151. ENTRY(arm1026_flush_user_cache_range)
  152. mov ip, #0
  153. sub r3, r1, r0 @ calculate total size
  154. cmp r3, #CACHE_DLIMIT
  155. bhs __flush_whole_cache
  156. #ifndef CONFIG_CPU_DCACHE_DISABLE
  157. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  158. add r0, r0, #CACHE_DLINESIZE
  159. cmp r0, r1
  160. blo 1b
  161. #endif
  162. tst r2, #VM_EXEC
  163. #ifndef CONFIG_CPU_ICACHE_DISABLE
  164. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  165. #endif
  166. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  167. mov pc, lr
  168. /*
  169. * coherent_kern_range(start, end)
  170. *
  171. * Ensure coherency between the Icache and the Dcache in the
  172. * region described by start. If you have non-snooping
  173. * Harvard caches, you need to implement this function.
  174. *
  175. * - start - virtual start address
  176. * - end - virtual end address
  177. */
  178. ENTRY(arm1026_coherent_kern_range)
  179. /* FALLTHROUGH */
  180. /*
  181. * coherent_user_range(start, end)
  182. *
  183. * Ensure coherency between the Icache and the Dcache in the
  184. * region described by start. If you have non-snooping
  185. * Harvard caches, you need to implement this function.
  186. *
  187. * - start - virtual start address
  188. * - end - virtual end address
  189. */
  190. ENTRY(arm1026_coherent_user_range)
  191. mov ip, #0
  192. bic r0, r0, #CACHE_DLINESIZE - 1
  193. 1:
  194. #ifndef CONFIG_CPU_DCACHE_DISABLE
  195. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  196. #endif
  197. #ifndef CONFIG_CPU_ICACHE_DISABLE
  198. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  199. #endif
  200. add r0, r0, #CACHE_DLINESIZE
  201. cmp r0, r1
  202. blo 1b
  203. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  204. mov pc, lr
  205. /*
  206. * flush_kern_dcache_area(void *addr, size_t size)
  207. *
  208. * Ensure no D cache aliasing occurs, either with itself or
  209. * the I cache
  210. *
  211. * - addr - kernel address
  212. * - size - region size
  213. */
  214. ENTRY(arm1026_flush_kern_dcache_area)
  215. mov ip, #0
  216. #ifndef CONFIG_CPU_DCACHE_DISABLE
  217. add r1, r0, r1
  218. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  219. add r0, r0, #CACHE_DLINESIZE
  220. cmp r0, r1
  221. blo 1b
  222. #endif
  223. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  224. mov pc, lr
  225. /*
  226. * dma_inv_range(start, end)
  227. *
  228. * Invalidate (discard) the specified virtual address range.
  229. * May not write back any entries. If 'start' or 'end'
  230. * are not cache line aligned, those lines must be written
  231. * back.
  232. *
  233. * - start - virtual start address
  234. * - end - virtual end address
  235. *
  236. * (same as v4wb)
  237. */
  238. arm1026_dma_inv_range:
  239. mov ip, #0
  240. #ifndef CONFIG_CPU_DCACHE_DISABLE
  241. tst r0, #CACHE_DLINESIZE - 1
  242. bic r0, r0, #CACHE_DLINESIZE - 1
  243. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  244. tst r1, #CACHE_DLINESIZE - 1
  245. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  246. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  247. add r0, r0, #CACHE_DLINESIZE
  248. cmp r0, r1
  249. blo 1b
  250. #endif
  251. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  252. mov pc, lr
  253. /*
  254. * dma_clean_range(start, end)
  255. *
  256. * Clean the specified virtual address range.
  257. *
  258. * - start - virtual start address
  259. * - end - virtual end address
  260. *
  261. * (same as v4wb)
  262. */
  263. arm1026_dma_clean_range:
  264. mov ip, #0
  265. #ifndef CONFIG_CPU_DCACHE_DISABLE
  266. bic r0, r0, #CACHE_DLINESIZE - 1
  267. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  268. add r0, r0, #CACHE_DLINESIZE
  269. cmp r0, r1
  270. blo 1b
  271. #endif
  272. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  273. mov pc, lr
  274. /*
  275. * dma_flush_range(start, end)
  276. *
  277. * Clean and invalidate the specified virtual address range.
  278. *
  279. * - start - virtual start address
  280. * - end - virtual end address
  281. */
  282. ENTRY(arm1026_dma_flush_range)
  283. mov ip, #0
  284. #ifndef CONFIG_CPU_DCACHE_DISABLE
  285. bic r0, r0, #CACHE_DLINESIZE - 1
  286. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  287. add r0, r0, #CACHE_DLINESIZE
  288. cmp r0, r1
  289. blo 1b
  290. #endif
  291. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  292. mov pc, lr
  293. /*
  294. * dma_map_area(start, size, dir)
  295. * - start - kernel virtual start address
  296. * - size - size of region
  297. * - dir - DMA direction
  298. */
  299. ENTRY(arm1026_dma_map_area)
  300. add r1, r1, r0
  301. cmp r2, #DMA_TO_DEVICE
  302. beq arm1026_dma_clean_range
  303. bcs arm1026_dma_inv_range
  304. b arm1026_dma_flush_range
  305. ENDPROC(arm1026_dma_map_area)
  306. /*
  307. * dma_unmap_area(start, size, dir)
  308. * - start - kernel virtual start address
  309. * - size - size of region
  310. * - dir - DMA direction
  311. */
  312. ENTRY(arm1026_dma_unmap_area)
  313. mov pc, lr
  314. ENDPROC(arm1026_dma_unmap_area)
  315. .globl arm1026_flush_kern_cache_louis
  316. .equ arm1026_flush_kern_cache_louis, arm1026_flush_kern_cache_all
  317. @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
  318. define_cache_functions arm1026
  319. .align 5
  320. ENTRY(cpu_arm1026_dcache_clean_area)
  321. #ifndef CONFIG_CPU_DCACHE_DISABLE
  322. mov ip, #0
  323. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  324. add r0, r0, #CACHE_DLINESIZE
  325. subs r1, r1, #CACHE_DLINESIZE
  326. bhi 1b
  327. #endif
  328. mov pc, lr
  329. /* =============================== PageTable ============================== */
  330. /*
  331. * cpu_arm1026_switch_mm(pgd)
  332. *
  333. * Set the translation base pointer to be as described by pgd.
  334. *
  335. * pgd: new page tables
  336. */
  337. .align 5
  338. ENTRY(cpu_arm1026_switch_mm)
  339. #ifdef CONFIG_MMU
  340. mov r1, #0
  341. #ifndef CONFIG_CPU_DCACHE_DISABLE
  342. 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
  343. bne 1b
  344. #endif
  345. #ifndef CONFIG_CPU_ICACHE_DISABLE
  346. mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
  347. #endif
  348. mcr p15, 0, r1, c7, c10, 4 @ drain WB
  349. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  350. mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
  351. #endif
  352. mov pc, lr
  353. /*
  354. * cpu_arm1026_set_pte_ext(ptep, pte, ext)
  355. *
  356. * Set a PTE and flush it out
  357. */
  358. .align 5
  359. ENTRY(cpu_arm1026_set_pte_ext)
  360. #ifdef CONFIG_MMU
  361. armv3_set_pte_ext
  362. mov r0, r0
  363. #ifndef CONFIG_CPU_DCACHE_DISABLE
  364. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  365. #endif
  366. #endif /* CONFIG_MMU */
  367. mov pc, lr
  368. __CPUINIT
  369. .type __arm1026_setup, #function
  370. __arm1026_setup:
  371. mov r0, #0
  372. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  373. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  374. #ifdef CONFIG_MMU
  375. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  376. mcr p15, 0, r4, c2, c0 @ load page table pointer
  377. #endif
  378. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  379. mov r0, #4 @ explicitly disable writeback
  380. mcr p15, 7, r0, c15, c0, 0
  381. #endif
  382. adr r5, arm1026_crval
  383. ldmia r5, {r5, r6}
  384. mrc p15, 0, r0, c1, c0 @ get control register v4
  385. bic r0, r0, r5
  386. orr r0, r0, r6
  387. #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
  388. orr r0, r0, #0x4000 @ .R.. .... .... ....
  389. #endif
  390. mov pc, lr
  391. .size __arm1026_setup, . - __arm1026_setup
  392. /*
  393. * R
  394. * .RVI ZFRS BLDP WCAM
  395. * .011 1001 ..11 0101
  396. *
  397. */
  398. .type arm1026_crval, #object
  399. arm1026_crval:
  400. crval clear=0x00007f3f, mmuset=0x00003935, ucset=0x00001934
  401. __INITDATA
  402. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  403. define_processor_functions arm1026, dabort=v5t_early_abort, pabort=legacy_pabort
  404. .section .rodata
  405. string cpu_arch_name, "armv5tej"
  406. string cpu_elf_name, "v5"
  407. .align
  408. string cpu_arm1026_name, "ARM1026EJ-S"
  409. .align
  410. .section ".proc.info.init", #alloc, #execinstr
  411. .type __arm1026_proc_info,#object
  412. __arm1026_proc_info:
  413. .long 0x4106a260 @ ARM 1026EJ-S (v5TEJ)
  414. .long 0xff0ffff0
  415. .long PMD_TYPE_SECT | \
  416. PMD_BIT4 | \
  417. PMD_SECT_AP_WRITE | \
  418. PMD_SECT_AP_READ
  419. .long PMD_TYPE_SECT | \
  420. PMD_BIT4 | \
  421. PMD_SECT_AP_WRITE | \
  422. PMD_SECT_AP_READ
  423. b __arm1026_setup
  424. .long cpu_arch_name
  425. .long cpu_elf_name
  426. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
  427. .long cpu_arm1026_name
  428. .long arm1026_processor_functions
  429. .long v4wbi_tlb_fns
  430. .long v4wb_user_fns
  431. .long arm1026_cache_fns
  432. .size __arm1026_proc_info, . - __arm1026_proc_info