proc-arm920.S 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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. mov pc, 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. mov pc, 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. mov pc, 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. mov pc, 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. mov pc, 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. 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 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. mov pc, 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 pc, lr
  196. /*
  197. * flush_kern_dcache_area(void *addr, size_t size)
  198. *
  199. * Ensure no D cache aliasing occurs, either with itself or
  200. * the I cache
  201. *
  202. * - addr - kernel address
  203. * - size - region size
  204. */
  205. ENTRY(arm920_flush_kern_dcache_area)
  206. add r1, r0, r1
  207. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  208. add r0, r0, #CACHE_DLINESIZE
  209. cmp r0, r1
  210. blo 1b
  211. mov r0, #0
  212. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  213. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  214. mov pc, lr
  215. /*
  216. * dma_inv_range(start, end)
  217. *
  218. * Invalidate (discard) the specified virtual address range.
  219. * May not write back any entries. If 'start' or 'end'
  220. * are not cache line aligned, those lines must be written
  221. * back.
  222. *
  223. * - start - virtual start address
  224. * - end - virtual end address
  225. *
  226. * (same as v4wb)
  227. */
  228. arm920_dma_inv_range:
  229. tst r0, #CACHE_DLINESIZE - 1
  230. bic r0, r0, #CACHE_DLINESIZE - 1
  231. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  232. tst r1, #CACHE_DLINESIZE - 1
  233. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  234. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  235. add r0, r0, #CACHE_DLINESIZE
  236. cmp r0, r1
  237. blo 1b
  238. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  239. mov pc, lr
  240. /*
  241. * dma_clean_range(start, end)
  242. *
  243. * Clean the specified virtual address range.
  244. *
  245. * - start - virtual start address
  246. * - end - virtual end address
  247. *
  248. * (same as v4wb)
  249. */
  250. arm920_dma_clean_range:
  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. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  257. mov pc, lr
  258. /*
  259. * dma_flush_range(start, end)
  260. *
  261. * Clean and invalidate the specified virtual address range.
  262. *
  263. * - start - virtual start address
  264. * - end - virtual end address
  265. */
  266. ENTRY(arm920_dma_flush_range)
  267. bic r0, r0, #CACHE_DLINESIZE - 1
  268. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  269. add r0, r0, #CACHE_DLINESIZE
  270. cmp r0, r1
  271. blo 1b
  272. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  273. mov pc, lr
  274. /*
  275. * dma_map_area(start, size, dir)
  276. * - start - kernel virtual start address
  277. * - size - size of region
  278. * - dir - DMA direction
  279. */
  280. ENTRY(arm920_dma_map_area)
  281. add r1, r1, r0
  282. cmp r2, #DMA_TO_DEVICE
  283. beq arm920_dma_clean_range
  284. bcs arm920_dma_inv_range
  285. b arm920_dma_flush_range
  286. ENDPROC(arm920_dma_map_area)
  287. /*
  288. * dma_unmap_area(start, size, dir)
  289. * - start - kernel virtual start address
  290. * - size - size of region
  291. * - dir - DMA direction
  292. */
  293. ENTRY(arm920_dma_unmap_area)
  294. mov pc, lr
  295. ENDPROC(arm920_dma_unmap_area)
  296. .globl arm920_flush_kern_cache_louis
  297. .equ arm920_flush_kern_cache_louis, arm920_flush_kern_cache_all
  298. @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
  299. define_cache_functions arm920
  300. #endif
  301. ENTRY(cpu_arm920_dcache_clean_area)
  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. mov pc, lr
  307. /* =============================== PageTable ============================== */
  308. /*
  309. * cpu_arm920_switch_mm(pgd)
  310. *
  311. * Set the translation base pointer to be as described by pgd.
  312. *
  313. * pgd: new page tables
  314. */
  315. .align 5
  316. ENTRY(cpu_arm920_switch_mm)
  317. #ifdef CONFIG_MMU
  318. mov ip, #0
  319. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  320. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  321. #else
  322. @ && 'Clean & Invalidate whole DCache'
  323. @ && Re-written to use Index Ops.
  324. @ && Uses registers r1, r3 and ip
  325. mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 8 segments
  326. 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
  327. 2: mcr p15, 0, r3, c7, c14, 2 @ clean & invalidate D index
  328. subs r3, r3, #1 << 26
  329. bcs 2b @ entries 63 to 0
  330. subs r1, r1, #1 << 5
  331. bcs 1b @ segments 7 to 0
  332. #endif
  333. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  334. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  335. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  336. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  337. #endif
  338. mov pc, lr
  339. /*
  340. * cpu_arm920_set_pte(ptep, pte, ext)
  341. *
  342. * Set a PTE and flush it out
  343. */
  344. .align 5
  345. ENTRY(cpu_arm920_set_pte_ext)
  346. #ifdef CONFIG_MMU
  347. armv3_set_pte_ext
  348. mov r0, r0
  349. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  350. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  351. #endif
  352. mov pc, lr
  353. /* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */
  354. .globl cpu_arm920_suspend_size
  355. .equ cpu_arm920_suspend_size, 4 * 3
  356. #ifdef CONFIG_ARM_CPU_SUSPEND
  357. ENTRY(cpu_arm920_do_suspend)
  358. stmfd sp!, {r4 - r6, lr}
  359. mrc p15, 0, r4, c13, c0, 0 @ PID
  360. mrc p15, 0, r5, c3, c0, 0 @ Domain ID
  361. mrc p15, 0, r6, c1, c0, 0 @ Control register
  362. stmia r0, {r4 - r6}
  363. ldmfd sp!, {r4 - r6, pc}
  364. ENDPROC(cpu_arm920_do_suspend)
  365. ENTRY(cpu_arm920_do_resume)
  366. mov ip, #0
  367. mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs
  368. mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches
  369. ldmia r0, {r4 - r6}
  370. mcr p15, 0, r4, c13, c0, 0 @ PID
  371. mcr p15, 0, r5, c3, c0, 0 @ Domain ID
  372. mcr p15, 0, r1, c2, c0, 0 @ TTB address
  373. mov r0, r6 @ control register
  374. b cpu_resume_mmu
  375. ENDPROC(cpu_arm920_do_resume)
  376. #endif
  377. __CPUINIT
  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. mov pc, 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, #execinstr
  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. b __arm920_setup
  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