proc-arm1026.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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 maintainence 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. ENTRY(cpu_arm1026_reset)
  79. mov ip, #0
  80. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  81. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  82. #ifdef CONFIG_MMU
  83. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  84. #endif
  85. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  86. bic ip, ip, #0x000f @ ............wcam
  87. bic ip, ip, #0x1100 @ ...i...s........
  88. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  89. mov pc, r0
  90. /*
  91. * cpu_arm1026_do_idle()
  92. */
  93. .align 5
  94. ENTRY(cpu_arm1026_do_idle)
  95. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  96. mov pc, lr
  97. /* ================================= CACHE ================================ */
  98. .align 5
  99. /*
  100. * flush_user_cache_all()
  101. *
  102. * Invalidate all cache entries in a particular address
  103. * space.
  104. */
  105. ENTRY(arm1026_flush_user_cache_all)
  106. /* FALLTHROUGH */
  107. /*
  108. * flush_kern_cache_all()
  109. *
  110. * Clean and invalidate the entire cache.
  111. */
  112. ENTRY(arm1026_flush_kern_cache_all)
  113. mov r2, #VM_EXEC
  114. mov ip, #0
  115. __flush_whole_cache:
  116. #ifndef CONFIG_CPU_DCACHE_DISABLE
  117. 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
  118. bne 1b
  119. #endif
  120. tst r2, #VM_EXEC
  121. #ifndef CONFIG_CPU_ICACHE_DISABLE
  122. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  123. #endif
  124. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  125. mov pc, lr
  126. /*
  127. * flush_user_cache_range(start, end, flags)
  128. *
  129. * Invalidate a range of cache entries in the specified
  130. * address space.
  131. *
  132. * - start - start address (inclusive)
  133. * - end - end address (exclusive)
  134. * - flags - vm_flags for this space
  135. */
  136. ENTRY(arm1026_flush_user_cache_range)
  137. mov ip, #0
  138. sub r3, r1, r0 @ calculate total size
  139. cmp r3, #CACHE_DLIMIT
  140. bhs __flush_whole_cache
  141. #ifndef CONFIG_CPU_DCACHE_DISABLE
  142. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  143. add r0, r0, #CACHE_DLINESIZE
  144. cmp r0, r1
  145. blo 1b
  146. #endif
  147. tst r2, #VM_EXEC
  148. #ifndef CONFIG_CPU_ICACHE_DISABLE
  149. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  150. #endif
  151. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  152. mov pc, lr
  153. /*
  154. * coherent_kern_range(start, end)
  155. *
  156. * Ensure coherency between the Icache and the Dcache in the
  157. * region described by start. If you have non-snooping
  158. * Harvard caches, you need to implement this function.
  159. *
  160. * - start - virtual start address
  161. * - end - virtual end address
  162. */
  163. ENTRY(arm1026_coherent_kern_range)
  164. /* FALLTHROUGH */
  165. /*
  166. * coherent_user_range(start, end)
  167. *
  168. * Ensure coherency between the Icache and the Dcache in the
  169. * region described by start. If you have non-snooping
  170. * Harvard caches, you need to implement this function.
  171. *
  172. * - start - virtual start address
  173. * - end - virtual end address
  174. */
  175. ENTRY(arm1026_coherent_user_range)
  176. mov ip, #0
  177. bic r0, r0, #CACHE_DLINESIZE - 1
  178. 1:
  179. #ifndef CONFIG_CPU_DCACHE_DISABLE
  180. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  181. #endif
  182. #ifndef CONFIG_CPU_ICACHE_DISABLE
  183. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  184. #endif
  185. add r0, r0, #CACHE_DLINESIZE
  186. cmp r0, r1
  187. blo 1b
  188. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  189. mov pc, lr
  190. /*
  191. * flush_kern_dcache_area(void *addr, size_t size)
  192. *
  193. * Ensure no D cache aliasing occurs, either with itself or
  194. * the I cache
  195. *
  196. * - addr - kernel address
  197. * - size - region size
  198. */
  199. ENTRY(arm1026_flush_kern_dcache_area)
  200. mov ip, #0
  201. #ifndef CONFIG_CPU_DCACHE_DISABLE
  202. add r1, r0, r1
  203. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  204. add r0, r0, #CACHE_DLINESIZE
  205. cmp r0, r1
  206. blo 1b
  207. #endif
  208. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  209. mov pc, lr
  210. /*
  211. * dma_inv_range(start, end)
  212. *
  213. * Invalidate (discard) the specified virtual address range.
  214. * May not write back any entries. If 'start' or 'end'
  215. * are not cache line aligned, those lines must be written
  216. * back.
  217. *
  218. * - start - virtual start address
  219. * - end - virtual end address
  220. *
  221. * (same as v4wb)
  222. */
  223. arm1026_dma_inv_range:
  224. mov ip, #0
  225. #ifndef CONFIG_CPU_DCACHE_DISABLE
  226. tst r0, #CACHE_DLINESIZE - 1
  227. bic r0, r0, #CACHE_DLINESIZE - 1
  228. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  229. tst r1, #CACHE_DLINESIZE - 1
  230. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  231. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  232. add r0, r0, #CACHE_DLINESIZE
  233. cmp r0, r1
  234. blo 1b
  235. #endif
  236. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  237. mov pc, lr
  238. /*
  239. * dma_clean_range(start, end)
  240. *
  241. * Clean the specified virtual address range.
  242. *
  243. * - start - virtual start address
  244. * - end - virtual end address
  245. *
  246. * (same as v4wb)
  247. */
  248. arm1026_dma_clean_range:
  249. mov ip, #0
  250. #ifndef CONFIG_CPU_DCACHE_DISABLE
  251. bic r0, r0, #CACHE_DLINESIZE - 1
  252. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  253. add r0, r0, #CACHE_DLINESIZE
  254. cmp r0, r1
  255. blo 1b
  256. #endif
  257. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  258. mov pc, lr
  259. /*
  260. * dma_flush_range(start, end)
  261. *
  262. * Clean and invalidate the specified virtual address range.
  263. *
  264. * - start - virtual start address
  265. * - end - virtual end address
  266. */
  267. ENTRY(arm1026_dma_flush_range)
  268. mov ip, #0
  269. #ifndef CONFIG_CPU_DCACHE_DISABLE
  270. bic r0, r0, #CACHE_DLINESIZE - 1
  271. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  272. add r0, r0, #CACHE_DLINESIZE
  273. cmp r0, r1
  274. blo 1b
  275. #endif
  276. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  277. mov pc, lr
  278. /*
  279. * dma_map_area(start, size, dir)
  280. * - start - kernel virtual start address
  281. * - size - size of region
  282. * - dir - DMA direction
  283. */
  284. ENTRY(arm1026_dma_map_area)
  285. add r1, r1, r0
  286. cmp r2, #DMA_TO_DEVICE
  287. beq arm1026_dma_clean_range
  288. bcs arm1026_dma_inv_range
  289. b arm1026_dma_flush_range
  290. ENDPROC(arm1026_dma_map_area)
  291. /*
  292. * dma_unmap_area(start, size, dir)
  293. * - start - kernel virtual start address
  294. * - size - size of region
  295. * - dir - DMA direction
  296. */
  297. ENTRY(arm1026_dma_unmap_area)
  298. mov pc, lr
  299. ENDPROC(arm1026_dma_unmap_area)
  300. ENTRY(arm1026_cache_fns)
  301. .long arm1026_flush_kern_cache_all
  302. .long arm1026_flush_user_cache_all
  303. .long arm1026_flush_user_cache_range
  304. .long arm1026_coherent_kern_range
  305. .long arm1026_coherent_user_range
  306. .long arm1026_flush_kern_dcache_area
  307. .long arm1026_dma_map_area
  308. .long arm1026_dma_unmap_area
  309. .long arm1026_dma_flush_range
  310. .align 5
  311. ENTRY(cpu_arm1026_dcache_clean_area)
  312. #ifndef CONFIG_CPU_DCACHE_DISABLE
  313. mov ip, #0
  314. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  315. add r0, r0, #CACHE_DLINESIZE
  316. subs r1, r1, #CACHE_DLINESIZE
  317. bhi 1b
  318. #endif
  319. mov pc, lr
  320. /* =============================== PageTable ============================== */
  321. /*
  322. * cpu_arm1026_switch_mm(pgd)
  323. *
  324. * Set the translation base pointer to be as described by pgd.
  325. *
  326. * pgd: new page tables
  327. */
  328. .align 5
  329. ENTRY(cpu_arm1026_switch_mm)
  330. #ifdef CONFIG_MMU
  331. mov r1, #0
  332. #ifndef CONFIG_CPU_DCACHE_DISABLE
  333. 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
  334. bne 1b
  335. #endif
  336. #ifndef CONFIG_CPU_ICACHE_DISABLE
  337. mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
  338. #endif
  339. mcr p15, 0, r1, c7, c10, 4 @ drain WB
  340. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  341. mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
  342. #endif
  343. mov pc, lr
  344. /*
  345. * cpu_arm1026_set_pte_ext(ptep, pte, ext)
  346. *
  347. * Set a PTE and flush it out
  348. */
  349. .align 5
  350. ENTRY(cpu_arm1026_set_pte_ext)
  351. #ifdef CONFIG_MMU
  352. armv3_set_pte_ext
  353. mov r0, r0
  354. #ifndef CONFIG_CPU_DCACHE_DISABLE
  355. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  356. #endif
  357. #endif /* CONFIG_MMU */
  358. mov pc, lr
  359. __INIT
  360. .type __arm1026_setup, #function
  361. __arm1026_setup:
  362. mov r0, #0
  363. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  364. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  365. #ifdef CONFIG_MMU
  366. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  367. mcr p15, 0, r4, c2, c0 @ load page table pointer
  368. #endif
  369. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  370. mov r0, #4 @ explicitly disable writeback
  371. mcr p15, 7, r0, c15, c0, 0
  372. #endif
  373. adr r5, arm1026_crval
  374. ldmia r5, {r5, r6}
  375. mrc p15, 0, r0, c1, c0 @ get control register v4
  376. bic r0, r0, r5
  377. orr r0, r0, r6
  378. #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
  379. orr r0, r0, #0x4000 @ .R.. .... .... ....
  380. #endif
  381. mov pc, lr
  382. .size __arm1026_setup, . - __arm1026_setup
  383. /*
  384. * R
  385. * .RVI ZFRS BLDP WCAM
  386. * .011 1001 ..11 0101
  387. *
  388. */
  389. .type arm1026_crval, #object
  390. arm1026_crval:
  391. crval clear=0x00007f3f, mmuset=0x00003935, ucset=0x00001934
  392. __INITDATA
  393. /*
  394. * Purpose : Function pointers used to access above functions - all calls
  395. * come through these
  396. */
  397. .type arm1026_processor_functions, #object
  398. arm1026_processor_functions:
  399. .word v5t_early_abort
  400. .word legacy_pabort
  401. .word cpu_arm1026_proc_init
  402. .word cpu_arm1026_proc_fin
  403. .word cpu_arm1026_reset
  404. .word cpu_arm1026_do_idle
  405. .word cpu_arm1026_dcache_clean_area
  406. .word cpu_arm1026_switch_mm
  407. .word cpu_arm1026_set_pte_ext
  408. .size arm1026_processor_functions, . - arm1026_processor_functions
  409. .section .rodata
  410. .type cpu_arch_name, #object
  411. cpu_arch_name:
  412. .asciz "armv5tej"
  413. .size cpu_arch_name, . - cpu_arch_name
  414. .type cpu_elf_name, #object
  415. cpu_elf_name:
  416. .asciz "v5"
  417. .size cpu_elf_name, . - cpu_elf_name
  418. .align
  419. .type cpu_arm1026_name, #object
  420. cpu_arm1026_name:
  421. .asciz "ARM1026EJ-S"
  422. .size cpu_arm1026_name, . - cpu_arm1026_name
  423. .align
  424. .section ".proc.info.init", #alloc, #execinstr
  425. .type __arm1026_proc_info,#object
  426. __arm1026_proc_info:
  427. .long 0x4106a260 @ ARM 1026EJ-S (v5TEJ)
  428. .long 0xff0ffff0
  429. .long PMD_TYPE_SECT | \
  430. PMD_BIT4 | \
  431. PMD_SECT_AP_WRITE | \
  432. PMD_SECT_AP_READ
  433. .long PMD_TYPE_SECT | \
  434. PMD_BIT4 | \
  435. PMD_SECT_AP_WRITE | \
  436. PMD_SECT_AP_READ
  437. b __arm1026_setup
  438. .long cpu_arch_name
  439. .long cpu_elf_name
  440. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
  441. .long cpu_arm1026_name
  442. .long arm1026_processor_functions
  443. .long v4wbi_tlb_fns
  444. .long v4wb_user_fns
  445. .long arm1026_cache_fns
  446. .size __arm1026_proc_info, . - __arm1026_proc_info