proc-arm1020e.S 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. /*
  2. * linux/arch/arm/mm/proc-arm1020e.S: MMU functions for ARM1020
  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. * 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 arm1020e.
  25. *
  26. * CONFIG_CPU_ARM1020_CPU_IDLE -> nohlt
  27. */
  28. #include <linux/linkage.h>
  29. #include <linux/init.h>
  30. #include <asm/assembler.h>
  31. #include <asm/asm-offsets.h>
  32. #include <asm/hwcap.h>
  33. #include <asm/pgtable-hwdef.h>
  34. #include <asm/pgtable.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 MAX_AREA_SIZE 32768
  46. /*
  47. * The size of one data cache line.
  48. */
  49. #define CACHE_DLINESIZE 32
  50. /*
  51. * The number of data cache segments.
  52. */
  53. #define CACHE_DSEGMENTS 16
  54. /*
  55. * The number of lines in a cache segment.
  56. */
  57. #define CACHE_DENTRIES 64
  58. /*
  59. * This is the size at which it becomes more efficient to
  60. * clean the whole cache, rather than using the individual
  61. * cache line maintenance instructions.
  62. */
  63. #define CACHE_DLIMIT 32768
  64. .text
  65. /*
  66. * cpu_arm1020e_proc_init()
  67. */
  68. ENTRY(cpu_arm1020e_proc_init)
  69. mov pc, lr
  70. /*
  71. * cpu_arm1020e_proc_fin()
  72. */
  73. ENTRY(cpu_arm1020e_proc_fin)
  74. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  75. bic r0, r0, #0x1000 @ ...i............
  76. bic r0, r0, #0x000e @ ............wca.
  77. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  78. mov pc, lr
  79. /*
  80. * cpu_arm1020e_reset(loc)
  81. *
  82. * Perform a soft reset of the system. Put the CPU into the
  83. * same state as it would be if it had been reset, and branch
  84. * to what would be the reset vector.
  85. *
  86. * loc: location to jump to for soft reset
  87. */
  88. .align 5
  89. .pushsection .idmap.text, "ax"
  90. ENTRY(cpu_arm1020e_reset)
  91. mov ip, #0
  92. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  93. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  94. #ifdef CONFIG_MMU
  95. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  96. #endif
  97. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  98. bic ip, ip, #0x000f @ ............wcam
  99. bic ip, ip, #0x1100 @ ...i...s........
  100. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  101. mov pc, r0
  102. ENDPROC(cpu_arm1020e_reset)
  103. .popsection
  104. /*
  105. * cpu_arm1020e_do_idle()
  106. */
  107. .align 5
  108. ENTRY(cpu_arm1020e_do_idle)
  109. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  110. mov pc, lr
  111. /* ================================= CACHE ================================ */
  112. .align 5
  113. /*
  114. * flush_icache_all()
  115. *
  116. * Unconditionally clean and invalidate the entire icache.
  117. */
  118. ENTRY(arm1020e_flush_icache_all)
  119. #ifndef CONFIG_CPU_ICACHE_DISABLE
  120. mov r0, #0
  121. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  122. #endif
  123. mov pc, lr
  124. ENDPROC(arm1020e_flush_icache_all)
  125. /*
  126. * flush_user_cache_all()
  127. *
  128. * Invalidate all cache entries in a particular address
  129. * space.
  130. */
  131. ENTRY(arm1020e_flush_user_cache_all)
  132. /* FALLTHROUGH */
  133. /*
  134. * flush_kern_cache_all()
  135. *
  136. * Clean and invalidate the entire cache.
  137. */
  138. ENTRY(arm1020e_flush_kern_cache_all)
  139. mov r2, #VM_EXEC
  140. mov ip, #0
  141. __flush_whole_cache:
  142. #ifndef CONFIG_CPU_DCACHE_DISABLE
  143. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  144. mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
  145. 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
  146. 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
  147. subs r3, r3, #1 << 26
  148. bcs 2b @ entries 63 to 0
  149. subs r1, r1, #1 << 5
  150. bcs 1b @ segments 15 to 0
  151. #endif
  152. tst r2, #VM_EXEC
  153. #ifndef CONFIG_CPU_ICACHE_DISABLE
  154. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  155. #endif
  156. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  157. mov pc, lr
  158. /*
  159. * flush_user_cache_range(start, end, flags)
  160. *
  161. * Invalidate a range of cache entries in the specified
  162. * address space.
  163. *
  164. * - start - start address (inclusive)
  165. * - end - end address (exclusive)
  166. * - flags - vm_flags for this space
  167. */
  168. ENTRY(arm1020e_flush_user_cache_range)
  169. mov ip, #0
  170. sub r3, r1, r0 @ calculate total size
  171. cmp r3, #CACHE_DLIMIT
  172. bhs __flush_whole_cache
  173. #ifndef CONFIG_CPU_DCACHE_DISABLE
  174. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  175. add r0, r0, #CACHE_DLINESIZE
  176. cmp r0, r1
  177. blo 1b
  178. #endif
  179. tst r2, #VM_EXEC
  180. #ifndef CONFIG_CPU_ICACHE_DISABLE
  181. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  182. #endif
  183. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  184. mov pc, lr
  185. /*
  186. * coherent_kern_range(start, end)
  187. *
  188. * Ensure coherency between the Icache and the Dcache in the
  189. * region described by start. 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(arm1020e_coherent_kern_range)
  196. /* FALLTHROUGH */
  197. /*
  198. * coherent_user_range(start, end)
  199. *
  200. * Ensure coherency between the Icache and the Dcache in the
  201. * region described by start. If you have non-snooping
  202. * Harvard caches, you need to implement this function.
  203. *
  204. * - start - virtual start address
  205. * - end - virtual end address
  206. */
  207. ENTRY(arm1020e_coherent_user_range)
  208. mov ip, #0
  209. bic r0, r0, #CACHE_DLINESIZE - 1
  210. 1:
  211. #ifndef CONFIG_CPU_DCACHE_DISABLE
  212. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  213. #endif
  214. #ifndef CONFIG_CPU_ICACHE_DISABLE
  215. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  216. #endif
  217. add r0, r0, #CACHE_DLINESIZE
  218. cmp r0, r1
  219. blo 1b
  220. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  221. mov r0, #0
  222. mov pc, lr
  223. /*
  224. * flush_kern_dcache_area(void *addr, size_t size)
  225. *
  226. * Ensure no D cache aliasing occurs, either with itself or
  227. * the I cache
  228. *
  229. * - addr - kernel address
  230. * - size - region size
  231. */
  232. ENTRY(arm1020e_flush_kern_dcache_area)
  233. mov ip, #0
  234. #ifndef CONFIG_CPU_DCACHE_DISABLE
  235. add r1, r0, r1
  236. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  237. add r0, r0, #CACHE_DLINESIZE
  238. cmp r0, r1
  239. blo 1b
  240. #endif
  241. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  242. mov pc, lr
  243. /*
  244. * dma_inv_range(start, end)
  245. *
  246. * Invalidate (discard) the specified virtual address range.
  247. * May not write back any entries. If 'start' or 'end'
  248. * are not cache line aligned, those lines must be written
  249. * back.
  250. *
  251. * - start - virtual start address
  252. * - end - virtual end address
  253. *
  254. * (same as v4wb)
  255. */
  256. arm1020e_dma_inv_range:
  257. mov ip, #0
  258. #ifndef CONFIG_CPU_DCACHE_DISABLE
  259. tst r0, #CACHE_DLINESIZE - 1
  260. bic r0, r0, #CACHE_DLINESIZE - 1
  261. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  262. tst r1, #CACHE_DLINESIZE - 1
  263. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  264. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  265. add r0, r0, #CACHE_DLINESIZE
  266. cmp r0, r1
  267. blo 1b
  268. #endif
  269. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  270. mov pc, lr
  271. /*
  272. * dma_clean_range(start, end)
  273. *
  274. * Clean the specified virtual address range.
  275. *
  276. * - start - virtual start address
  277. * - end - virtual end address
  278. *
  279. * (same as v4wb)
  280. */
  281. arm1020e_dma_clean_range:
  282. mov ip, #0
  283. #ifndef CONFIG_CPU_DCACHE_DISABLE
  284. bic r0, r0, #CACHE_DLINESIZE - 1
  285. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  286. add r0, r0, #CACHE_DLINESIZE
  287. cmp r0, r1
  288. blo 1b
  289. #endif
  290. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  291. mov pc, lr
  292. /*
  293. * dma_flush_range(start, end)
  294. *
  295. * Clean and invalidate the specified virtual address range.
  296. *
  297. * - start - virtual start address
  298. * - end - virtual end address
  299. */
  300. ENTRY(arm1020e_dma_flush_range)
  301. mov ip, #0
  302. #ifndef CONFIG_CPU_DCACHE_DISABLE
  303. bic r0, r0, #CACHE_DLINESIZE - 1
  304. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  305. add r0, r0, #CACHE_DLINESIZE
  306. cmp r0, r1
  307. blo 1b
  308. #endif
  309. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  310. mov pc, lr
  311. /*
  312. * dma_map_area(start, size, dir)
  313. * - start - kernel virtual start address
  314. * - size - size of region
  315. * - dir - DMA direction
  316. */
  317. ENTRY(arm1020e_dma_map_area)
  318. add r1, r1, r0
  319. cmp r2, #DMA_TO_DEVICE
  320. beq arm1020e_dma_clean_range
  321. bcs arm1020e_dma_inv_range
  322. b arm1020e_dma_flush_range
  323. ENDPROC(arm1020e_dma_map_area)
  324. /*
  325. * dma_unmap_area(start, size, dir)
  326. * - start - kernel virtual start address
  327. * - size - size of region
  328. * - dir - DMA direction
  329. */
  330. ENTRY(arm1020e_dma_unmap_area)
  331. mov pc, lr
  332. ENDPROC(arm1020e_dma_unmap_area)
  333. @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
  334. define_cache_functions arm1020e
  335. .align 5
  336. ENTRY(cpu_arm1020e_dcache_clean_area)
  337. #ifndef CONFIG_CPU_DCACHE_DISABLE
  338. mov ip, #0
  339. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  340. add r0, r0, #CACHE_DLINESIZE
  341. subs r1, r1, #CACHE_DLINESIZE
  342. bhi 1b
  343. #endif
  344. mov pc, lr
  345. /* =============================== PageTable ============================== */
  346. /*
  347. * cpu_arm1020e_switch_mm(pgd)
  348. *
  349. * Set the translation base pointer to be as described by pgd.
  350. *
  351. * pgd: new page tables
  352. */
  353. .align 5
  354. ENTRY(cpu_arm1020e_switch_mm)
  355. #ifdef CONFIG_MMU
  356. #ifndef CONFIG_CPU_DCACHE_DISABLE
  357. mcr p15, 0, r3, c7, c10, 4
  358. mov r1, #0xF @ 16 segments
  359. 1: mov r3, #0x3F @ 64 entries
  360. 2: mov ip, r3, LSL #26 @ shift up entry
  361. orr ip, ip, r1, LSL #5 @ shift in/up index
  362. mcr p15, 0, ip, c7, c14, 2 @ Clean & Inval DCache entry
  363. mov ip, #0
  364. subs r3, r3, #1
  365. cmp r3, #0
  366. bge 2b @ entries 3F to 0
  367. subs r1, r1, #1
  368. cmp r1, #0
  369. bge 1b @ segments 15 to 0
  370. #endif
  371. mov r1, #0
  372. #ifndef CONFIG_CPU_ICACHE_DISABLE
  373. mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
  374. #endif
  375. mcr p15, 0, r1, c7, c10, 4 @ drain WB
  376. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  377. mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
  378. #endif
  379. mov pc, lr
  380. /*
  381. * cpu_arm1020e_set_pte(ptep, pte)
  382. *
  383. * Set a PTE and flush it out
  384. */
  385. .align 5
  386. ENTRY(cpu_arm1020e_set_pte_ext)
  387. #ifdef CONFIG_MMU
  388. armv3_set_pte_ext
  389. mov r0, r0
  390. #ifndef CONFIG_CPU_DCACHE_DISABLE
  391. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  392. #endif
  393. #endif /* CONFIG_MMU */
  394. mov pc, lr
  395. __CPUINIT
  396. .type __arm1020e_setup, #function
  397. __arm1020e_setup:
  398. mov r0, #0
  399. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  400. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  401. #ifdef CONFIG_MMU
  402. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  403. #endif
  404. adr r5, arm1020e_crval
  405. ldmia r5, {r5, r6}
  406. mrc p15, 0, r0, c1, c0 @ get control register v4
  407. bic r0, r0, r5
  408. orr r0, r0, r6
  409. #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
  410. orr r0, r0, #0x4000 @ .R.. .... .... ....
  411. #endif
  412. mov pc, lr
  413. .size __arm1020e_setup, . - __arm1020e_setup
  414. /*
  415. * R
  416. * .RVI ZFRS BLDP WCAM
  417. * .011 1001 ..11 0101
  418. */
  419. .type arm1020e_crval, #object
  420. arm1020e_crval:
  421. crval clear=0x00007f3f, mmuset=0x00003935, ucset=0x00001930
  422. __INITDATA
  423. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  424. define_processor_functions arm1020e, dabort=v4t_early_abort, pabort=legacy_pabort
  425. .section ".rodata"
  426. string cpu_arch_name, "armv5te"
  427. string cpu_elf_name, "v5"
  428. string cpu_arm1020e_name, "ARM1020E"
  429. .align
  430. .section ".proc.info.init", #alloc, #execinstr
  431. .type __arm1020e_proc_info,#object
  432. __arm1020e_proc_info:
  433. .long 0x4105a200 @ ARM 1020TE (Architecture v5TE)
  434. .long 0xff0ffff0
  435. .long PMD_TYPE_SECT | \
  436. PMD_BIT4 | \
  437. PMD_SECT_AP_WRITE | \
  438. PMD_SECT_AP_READ
  439. .long PMD_TYPE_SECT | \
  440. PMD_BIT4 | \
  441. PMD_SECT_AP_WRITE | \
  442. PMD_SECT_AP_READ
  443. b __arm1020e_setup
  444. .long cpu_arch_name
  445. .long cpu_elf_name
  446. .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_EDSP
  447. .long cpu_arm1020e_name
  448. .long arm1020e_processor_functions
  449. .long v4wbi_tlb_fns
  450. .long v4wb_user_fns
  451. .long arm1020e_cache_fns
  452. .size __arm1020e_proc_info, . - __arm1020e_proc_info