proc-arm1020e.S 12 KB

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