proc-arm920.S 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. /*
  2. * linux/arch/arm/mm/proc-arm920.S: MMU functions for ARM920
  3. *
  4. * Copyright (C) 1999,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. * 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 arm920.
  25. *
  26. * CONFIG_CPU_ARM920_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. * The size of one data cache line.
  39. */
  40. #define CACHE_DLINESIZE 32
  41. /*
  42. * The number of data cache segments.
  43. */
  44. #define CACHE_DSEGMENTS 8
  45. /*
  46. * The number of lines in a cache segment.
  47. */
  48. #define CACHE_DENTRIES 64
  49. /*
  50. * This is the size at which it becomes more efficient to
  51. * clean the whole cache, rather than using the individual
  52. * cache line maintenance instructions.
  53. */
  54. #define CACHE_DLIMIT 65536
  55. .text
  56. /*
  57. * cpu_arm920_proc_init()
  58. */
  59. ENTRY(cpu_arm920_proc_init)
  60. ret lr
  61. /*
  62. * cpu_arm920_proc_fin()
  63. */
  64. ENTRY(cpu_arm920_proc_fin)
  65. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  66. bic r0, r0, #0x1000 @ ...i............
  67. bic r0, r0, #0x000e @ ............wca.
  68. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  69. ret lr
  70. /*
  71. * cpu_arm920_reset(loc)
  72. *
  73. * Perform a soft reset of the system. Put the CPU into the
  74. * same state as it would be if it had been reset, and branch
  75. * to what would be the reset vector.
  76. *
  77. * loc: location to jump to for soft reset
  78. */
  79. .align 5
  80. .pushsection .idmap.text, "ax"
  81. ENTRY(cpu_arm920_reset)
  82. mov ip, #0
  83. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  84. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  85. #ifdef CONFIG_MMU
  86. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  87. #endif
  88. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  89. bic ip, ip, #0x000f @ ............wcam
  90. bic ip, ip, #0x1100 @ ...i...s........
  91. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  92. ret r0
  93. ENDPROC(cpu_arm920_reset)
  94. .popsection
  95. /*
  96. * cpu_arm920_do_idle()
  97. */
  98. .align 5
  99. ENTRY(cpu_arm920_do_idle)
  100. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  101. ret lr
  102. #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  103. /*
  104. * flush_icache_all()
  105. *
  106. * Unconditionally clean and invalidate the entire icache.
  107. */
  108. ENTRY(arm920_flush_icache_all)
  109. mov r0, #0
  110. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  111. ret lr
  112. ENDPROC(arm920_flush_icache_all)
  113. /*
  114. * flush_user_cache_all()
  115. *
  116. * Invalidate all cache entries in a particular address
  117. * space.
  118. */
  119. ENTRY(arm920_flush_user_cache_all)
  120. /* FALLTHROUGH */
  121. /*
  122. * flush_kern_cache_all()
  123. *
  124. * Clean and invalidate the entire cache.
  125. */
  126. ENTRY(arm920_flush_kern_cache_all)
  127. mov r2, #VM_EXEC
  128. mov ip, #0
  129. __flush_whole_cache:
  130. mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 8 segments
  131. 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
  132. 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
  133. subs r3, r3, #1 << 26
  134. bcs 2b @ entries 63 to 0
  135. subs r1, r1, #1 << 5
  136. bcs 1b @ segments 7 to 0
  137. tst r2, #VM_EXEC
  138. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  139. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  140. ret 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 address space
  150. */
  151. ENTRY(arm920_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. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  157. tst r2, #VM_EXEC
  158. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  159. add r0, r0, #CACHE_DLINESIZE
  160. cmp r0, r1
  161. blo 1b
  162. tst r2, #VM_EXEC
  163. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  164. ret lr
  165. /*
  166. * coherent_kern_range(start, end)
  167. *
  168. * Ensure coherency between the Icache and the Dcache in the
  169. * region described by start, end. 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(arm920_coherent_kern_range)
  176. /* FALLTHROUGH */
  177. /*
  178. * coherent_user_range(start, end)
  179. *
  180. * Ensure coherency between the Icache and the Dcache in the
  181. * region described by start, end. If you have non-snooping
  182. * Harvard caches, you need to implement this function.
  183. *
  184. * - start - virtual start address
  185. * - end - virtual end address
  186. */
  187. ENTRY(arm920_coherent_user_range)
  188. bic r0, r0, #CACHE_DLINESIZE - 1
  189. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  190. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  191. add r0, r0, #CACHE_DLINESIZE
  192. cmp r0, r1
  193. blo 1b
  194. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  195. mov r0, #0
  196. ret lr
  197. /*
  198. * flush_kern_dcache_area(void *addr, size_t size)
  199. *
  200. * Ensure no D cache aliasing occurs, either with itself or
  201. * the I cache
  202. *
  203. * - addr - kernel address
  204. * - size - region size
  205. */
  206. ENTRY(arm920_flush_kern_dcache_area)
  207. add r1, r0, r1
  208. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  209. add r0, r0, #CACHE_DLINESIZE
  210. cmp r0, r1
  211. blo 1b
  212. mov r0, #0
  213. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  214. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  215. ret lr
  216. /*
  217. * dma_inv_range(start, end)
  218. *
  219. * Invalidate (discard) the specified virtual address range.
  220. * May not write back any entries. If 'start' or 'end'
  221. * are not cache line aligned, those lines must be written
  222. * back.
  223. *
  224. * - start - virtual start address
  225. * - end - virtual end address
  226. *
  227. * (same as v4wb)
  228. */
  229. arm920_dma_inv_range:
  230. tst r0, #CACHE_DLINESIZE - 1
  231. bic r0, r0, #CACHE_DLINESIZE - 1
  232. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  233. tst r1, #CACHE_DLINESIZE - 1
  234. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  235. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  236. add r0, r0, #CACHE_DLINESIZE
  237. cmp r0, r1
  238. blo 1b
  239. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  240. ret lr
  241. /*
  242. * dma_clean_range(start, end)
  243. *
  244. * Clean the specified virtual address range.
  245. *
  246. * - start - virtual start address
  247. * - end - virtual end address
  248. *
  249. * (same as v4wb)
  250. */
  251. arm920_dma_clean_range:
  252. bic r0, r0, #CACHE_DLINESIZE - 1
  253. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  254. add r0, r0, #CACHE_DLINESIZE
  255. cmp r0, r1
  256. blo 1b
  257. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  258. ret 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(arm920_dma_flush_range)
  268. bic r0, r0, #CACHE_DLINESIZE - 1
  269. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  270. add r0, r0, #CACHE_DLINESIZE
  271. cmp r0, r1
  272. blo 1b
  273. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  274. ret lr
  275. /*
  276. * dma_map_area(start, size, dir)
  277. * - start - kernel virtual start address
  278. * - size - size of region
  279. * - dir - DMA direction
  280. */
  281. ENTRY(arm920_dma_map_area)
  282. add r1, r1, r0
  283. cmp r2, #DMA_TO_DEVICE
  284. beq arm920_dma_clean_range
  285. bcs arm920_dma_inv_range
  286. b arm920_dma_flush_range
  287. ENDPROC(arm920_dma_map_area)
  288. /*
  289. * dma_unmap_area(start, size, dir)
  290. * - start - kernel virtual start address
  291. * - size - size of region
  292. * - dir - DMA direction
  293. */
  294. ENTRY(arm920_dma_unmap_area)
  295. ret lr
  296. ENDPROC(arm920_dma_unmap_area)
  297. .globl arm920_flush_kern_cache_louis
  298. .equ arm920_flush_kern_cache_louis, arm920_flush_kern_cache_all
  299. @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
  300. define_cache_functions arm920
  301. #endif
  302. ENTRY(cpu_arm920_dcache_clean_area)
  303. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  304. add r0, r0, #CACHE_DLINESIZE
  305. subs r1, r1, #CACHE_DLINESIZE
  306. bhi 1b
  307. ret lr
  308. /* =============================== PageTable ============================== */
  309. /*
  310. * cpu_arm920_switch_mm(pgd)
  311. *
  312. * Set the translation base pointer to be as described by pgd.
  313. *
  314. * pgd: new page tables
  315. */
  316. .align 5
  317. ENTRY(cpu_arm920_switch_mm)
  318. #ifdef CONFIG_MMU
  319. mov ip, #0
  320. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  321. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  322. #else
  323. @ && 'Clean & Invalidate whole DCache'
  324. @ && Re-written to use Index Ops.
  325. @ && Uses registers r1, r3 and ip
  326. mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 8 segments
  327. 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
  328. 2: mcr p15, 0, r3, c7, c14, 2 @ clean & invalidate D index
  329. subs r3, r3, #1 << 26
  330. bcs 2b @ entries 63 to 0
  331. subs r1, r1, #1 << 5
  332. bcs 1b @ segments 7 to 0
  333. #endif
  334. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  335. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  336. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  337. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  338. #endif
  339. ret lr
  340. /*
  341. * cpu_arm920_set_pte(ptep, pte, ext)
  342. *
  343. * Set a PTE and flush it out
  344. */
  345. .align 5
  346. ENTRY(cpu_arm920_set_pte_ext)
  347. #ifdef CONFIG_MMU
  348. armv3_set_pte_ext
  349. mov r0, r0
  350. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  351. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  352. #endif
  353. ret lr
  354. /* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */
  355. .globl cpu_arm920_suspend_size
  356. .equ cpu_arm920_suspend_size, 4 * 3
  357. #ifdef CONFIG_ARM_CPU_SUSPEND
  358. ENTRY(cpu_arm920_do_suspend)
  359. stmfd sp!, {r4 - r6, lr}
  360. mrc p15, 0, r4, c13, c0, 0 @ PID
  361. mrc p15, 0, r5, c3, c0, 0 @ Domain ID
  362. mrc p15, 0, r6, c1, c0, 0 @ Control register
  363. stmia r0, {r4 - r6}
  364. ldmfd sp!, {r4 - r6, pc}
  365. ENDPROC(cpu_arm920_do_suspend)
  366. ENTRY(cpu_arm920_do_resume)
  367. mov ip, #0
  368. mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs
  369. mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches
  370. ldmia r0, {r4 - r6}
  371. mcr p15, 0, r4, c13, c0, 0 @ PID
  372. mcr p15, 0, r5, c3, c0, 0 @ Domain ID
  373. mcr p15, 0, r1, c2, c0, 0 @ TTB address
  374. mov r0, r6 @ control register
  375. b cpu_resume_mmu
  376. ENDPROC(cpu_arm920_do_resume)
  377. #endif
  378. .type __arm920_setup, #function
  379. __arm920_setup:
  380. mov r0, #0
  381. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  382. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  383. #ifdef CONFIG_MMU
  384. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  385. #endif
  386. adr r5, arm920_crval
  387. ldmia r5, {r5, r6}
  388. mrc p15, 0, r0, c1, c0 @ get control register v4
  389. bic r0, r0, r5
  390. orr r0, r0, r6
  391. ret lr
  392. .size __arm920_setup, . - __arm920_setup
  393. /*
  394. * R
  395. * .RVI ZFRS BLDP WCAM
  396. * ..11 0001 ..11 0101
  397. *
  398. */
  399. .type arm920_crval, #object
  400. arm920_crval:
  401. crval clear=0x00003f3f, mmuset=0x00003135, ucset=0x00001130
  402. __INITDATA
  403. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  404. define_processor_functions arm920, dabort=v4t_early_abort, pabort=legacy_pabort, suspend=1
  405. .section ".rodata"
  406. string cpu_arch_name, "armv4t"
  407. string cpu_elf_name, "v4"
  408. string cpu_arm920_name, "ARM920T"
  409. .align
  410. .section ".proc.info.init", #alloc
  411. .type __arm920_proc_info,#object
  412. __arm920_proc_info:
  413. .long 0x41009200
  414. .long 0xff00fff0
  415. .long PMD_TYPE_SECT | \
  416. PMD_SECT_BUFFERABLE | \
  417. PMD_SECT_CACHEABLE | \
  418. PMD_BIT4 | \
  419. PMD_SECT_AP_WRITE | \
  420. PMD_SECT_AP_READ
  421. .long PMD_TYPE_SECT | \
  422. PMD_BIT4 | \
  423. PMD_SECT_AP_WRITE | \
  424. PMD_SECT_AP_READ
  425. initfn __arm920_setup, __arm920_proc_info
  426. .long cpu_arch_name
  427. .long cpu_elf_name
  428. .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
  429. .long cpu_arm920_name
  430. .long arm920_processor_functions
  431. .long v4wbi_tlb_fns
  432. .long v4wb_user_fns
  433. #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
  434. .long arm920_cache_fns
  435. #else
  436. .long v4wt_cache_fns
  437. #endif
  438. .size __arm920_proc_info, . - __arm920_proc_info