proc-feroceon.S 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. /*
  2. * linux/arch/arm/mm/proc-feroceon.S: MMU functions for Feroceon
  3. *
  4. * Heavily based on proc-arm926.S
  5. * Maintainer: Assaf Hoffman <hoffman@marvell.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/linkage.h>
  22. #include <linux/init.h>
  23. #include <asm/assembler.h>
  24. #include <asm/elf.h>
  25. #include <asm/pgtable-hwdef.h>
  26. #include <asm/pgtable.h>
  27. #include <asm/page.h>
  28. #include <asm/ptrace.h>
  29. #include "proc-macros.S"
  30. /*
  31. * This is the maximum size of an area which will be invalidated
  32. * using the single invalidate entry instructions. Anything larger
  33. * than this, and we go for the whole cache.
  34. *
  35. * This value should be chosen such that we choose the cheapest
  36. * alternative.
  37. */
  38. #define CACHE_DLIMIT 16384
  39. /*
  40. * the cache line size of the I and D cache
  41. */
  42. #define CACHE_DLINESIZE 32
  43. .text
  44. /*
  45. * cpu_feroceon_proc_init()
  46. */
  47. ENTRY(cpu_feroceon_proc_init)
  48. mov pc, lr
  49. /*
  50. * cpu_feroceon_proc_fin()
  51. */
  52. ENTRY(cpu_feroceon_proc_fin)
  53. stmfd sp!, {lr}
  54. mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
  55. msr cpsr_c, ip
  56. bl feroceon_flush_kern_cache_all
  57. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  58. bic r0, r0, #0x1000 @ ...i............
  59. bic r0, r0, #0x000e @ ............wca.
  60. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  61. ldmfd sp!, {pc}
  62. /*
  63. * cpu_feroceon_reset(loc)
  64. *
  65. * Perform a soft reset of the system. Put the CPU into the
  66. * same state as it would be if it had been reset, and branch
  67. * to what would be the reset vector.
  68. *
  69. * loc: location to jump to for soft reset
  70. */
  71. .align 5
  72. ENTRY(cpu_feroceon_reset)
  73. mov ip, #0
  74. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  75. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  76. #ifdef CONFIG_MMU
  77. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  78. #endif
  79. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  80. bic ip, ip, #0x000f @ ............wcam
  81. bic ip, ip, #0x1100 @ ...i...s........
  82. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  83. mov pc, r0
  84. /*
  85. * cpu_feroceon_do_idle()
  86. *
  87. * Called with IRQs disabled
  88. */
  89. .align 10
  90. ENTRY(cpu_feroceon_do_idle)
  91. mov r0, #0
  92. mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
  93. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  94. mov pc, lr
  95. /*
  96. * flush_user_cache_all()
  97. *
  98. * Clean and invalidate all cache entries in a particular
  99. * address space.
  100. */
  101. ENTRY(feroceon_flush_user_cache_all)
  102. /* FALLTHROUGH */
  103. /*
  104. * flush_kern_cache_all()
  105. *
  106. * Clean and invalidate the entire cache.
  107. */
  108. ENTRY(feroceon_flush_kern_cache_all)
  109. mov r2, #VM_EXEC
  110. mov ip, #0
  111. __flush_whole_cache:
  112. 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
  113. bne 1b
  114. tst r2, #VM_EXEC
  115. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  116. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  117. mov pc, lr
  118. /*
  119. * flush_user_cache_range(start, end, flags)
  120. *
  121. * Clean and invalidate a range of cache entries in the
  122. * specified address range.
  123. *
  124. * - start - start address (inclusive)
  125. * - end - end address (exclusive)
  126. * - flags - vm_flags describing address space
  127. */
  128. ENTRY(feroceon_flush_user_cache_range)
  129. mov ip, #0
  130. sub r3, r1, r0 @ calculate total size
  131. cmp r3, #CACHE_DLIMIT
  132. bgt __flush_whole_cache
  133. 1: tst r2, #VM_EXEC
  134. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
  135. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  136. add r0, r0, #CACHE_DLINESIZE
  137. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
  138. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  139. add r0, r0, #CACHE_DLINESIZE
  140. cmp r0, r1
  141. blo 1b
  142. tst r2, #VM_EXEC
  143. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  144. mov pc, lr
  145. /*
  146. * coherent_kern_range(start, end)
  147. *
  148. * Ensure coherency between the Icache and the Dcache in the
  149. * region described by start, end. If you have non-snooping
  150. * Harvard caches, you need to implement this function.
  151. *
  152. * - start - virtual start address
  153. * - end - virtual end address
  154. */
  155. ENTRY(feroceon_coherent_kern_range)
  156. /* FALLTHROUGH */
  157. /*
  158. * coherent_user_range(start, end)
  159. *
  160. * Ensure coherency between the Icache and the Dcache in the
  161. * region described by start, end. If you have non-snooping
  162. * Harvard caches, you need to implement this function.
  163. *
  164. * - start - virtual start address
  165. * - end - virtual end address
  166. */
  167. ENTRY(feroceon_coherent_user_range)
  168. bic r0, r0, #CACHE_DLINESIZE - 1
  169. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  170. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  171. add r0, r0, #CACHE_DLINESIZE
  172. cmp r0, r1
  173. blo 1b
  174. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  175. mov pc, lr
  176. /*
  177. * flush_kern_dcache_page(void *page)
  178. *
  179. * Ensure no D cache aliasing occurs, either with itself or
  180. * the I cache
  181. *
  182. * - addr - page aligned address
  183. */
  184. ENTRY(feroceon_flush_kern_dcache_page)
  185. add r1, r0, #PAGE_SZ
  186. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  187. add r0, r0, #CACHE_DLINESIZE
  188. cmp r0, r1
  189. blo 1b
  190. mov r0, #0
  191. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  192. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  193. mov pc, lr
  194. /*
  195. * dma_inv_range(start, end)
  196. *
  197. * Invalidate (discard) the specified virtual address range.
  198. * May not write back any entries. If 'start' or 'end'
  199. * are not cache line aligned, those lines must be written
  200. * back.
  201. *
  202. * - start - virtual start address
  203. * - end - virtual end address
  204. *
  205. * (same as v4wb)
  206. */
  207. ENTRY(feroceon_dma_inv_range)
  208. tst r0, #CACHE_DLINESIZE - 1
  209. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  210. tst r1, #CACHE_DLINESIZE - 1
  211. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  212. bic r0, r0, #CACHE_DLINESIZE - 1
  213. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  214. add r0, r0, #CACHE_DLINESIZE
  215. cmp r0, r1
  216. blo 1b
  217. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  218. mov pc, lr
  219. /*
  220. * dma_clean_range(start, end)
  221. *
  222. * Clean the specified virtual address range.
  223. *
  224. * - start - virtual start address
  225. * - end - virtual end address
  226. *
  227. * (same as v4wb)
  228. */
  229. ENTRY(feroceon_dma_clean_range)
  230. bic r0, r0, #CACHE_DLINESIZE - 1
  231. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  232. add r0, r0, #CACHE_DLINESIZE
  233. cmp r0, r1
  234. blo 1b
  235. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  236. mov pc, lr
  237. /*
  238. * dma_flush_range(start, end)
  239. *
  240. * Clean and invalidate the specified virtual address range.
  241. *
  242. * - start - virtual start address
  243. * - end - virtual end address
  244. */
  245. ENTRY(feroceon_dma_flush_range)
  246. bic r0, r0, #CACHE_DLINESIZE - 1
  247. 1:
  248. mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  249. add r0, r0, #CACHE_DLINESIZE
  250. cmp r0, r1
  251. blo 1b
  252. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  253. mov pc, lr
  254. ENTRY(feroceon_cache_fns)
  255. .long feroceon_flush_kern_cache_all
  256. .long feroceon_flush_user_cache_all
  257. .long feroceon_flush_user_cache_range
  258. .long feroceon_coherent_kern_range
  259. .long feroceon_coherent_user_range
  260. .long feroceon_flush_kern_dcache_page
  261. .long feroceon_dma_inv_range
  262. .long feroceon_dma_clean_range
  263. .long feroceon_dma_flush_range
  264. ENTRY(cpu_feroceon_dcache_clean_area)
  265. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  266. add r0, r0, #CACHE_DLINESIZE
  267. subs r1, r1, #CACHE_DLINESIZE
  268. bhi 1b
  269. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  270. mov pc, lr
  271. /* =============================== PageTable ============================== */
  272. /*
  273. * cpu_feroceon_switch_mm(pgd)
  274. *
  275. * Set the translation base pointer to be as described by pgd.
  276. *
  277. * pgd: new page tables
  278. */
  279. .align 5
  280. ENTRY(cpu_feroceon_switch_mm)
  281. #ifdef CONFIG_MMU
  282. mov ip, #0
  283. @ && 'Clean & Invalidate whole DCache'
  284. 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
  285. bne 1b
  286. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  287. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  288. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  289. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  290. #endif
  291. mov pc, lr
  292. /*
  293. * cpu_feroceon_set_pte_ext(ptep, pte, ext)
  294. *
  295. * Set a PTE and flush it out
  296. */
  297. .align 5
  298. ENTRY(cpu_feroceon_set_pte_ext)
  299. #ifdef CONFIG_MMU
  300. str r1, [r0], #-2048 @ linux version
  301. eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
  302. bic r2, r1, #PTE_SMALL_AP_MASK
  303. bic r2, r2, #PTE_TYPE_MASK
  304. orr r2, r2, #PTE_TYPE_SMALL
  305. tst r1, #L_PTE_USER @ User?
  306. orrne r2, r2, #PTE_SMALL_AP_URO_SRW
  307. tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
  308. orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
  309. tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
  310. movne r2, #0
  311. str r2, [r0] @ hardware version
  312. mov r0, r0
  313. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  314. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  315. #endif
  316. mov pc, lr
  317. __INIT
  318. .type __feroceon_setup, #function
  319. __feroceon_setup:
  320. mov r0, #0
  321. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  322. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  323. #ifdef CONFIG_MMU
  324. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  325. #endif
  326. adr r5, feroceon_crval
  327. ldmia r5, {r5, r6}
  328. mrc p15, 0, r0, c1, c0 @ get control register v4
  329. bic r0, r0, r5
  330. orr r0, r0, r6
  331. mov pc, lr
  332. .size __feroceon_setup, . - __feroceon_setup
  333. /*
  334. * R
  335. * .RVI ZFRS BLDP WCAM
  336. * .011 0001 ..11 0101
  337. *
  338. */
  339. .type feroceon_crval, #object
  340. feroceon_crval:
  341. crval clear=0x00007f3f, mmuset=0x00003135, ucset=0x00001134
  342. __INITDATA
  343. /*
  344. * Purpose : Function pointers used to access above functions - all calls
  345. * come through these
  346. */
  347. .type feroceon_processor_functions, #object
  348. feroceon_processor_functions:
  349. .word v5t_early_abort
  350. .word pabort_noifar
  351. .word cpu_feroceon_proc_init
  352. .word cpu_feroceon_proc_fin
  353. .word cpu_feroceon_reset
  354. .word cpu_feroceon_do_idle
  355. .word cpu_feroceon_dcache_clean_area
  356. .word cpu_feroceon_switch_mm
  357. .word cpu_feroceon_set_pte_ext
  358. .size feroceon_processor_functions, . - feroceon_processor_functions
  359. .section ".rodata"
  360. .type cpu_arch_name, #object
  361. cpu_arch_name:
  362. .asciz "armv5te"
  363. .size cpu_arch_name, . - cpu_arch_name
  364. .type cpu_elf_name, #object
  365. cpu_elf_name:
  366. .asciz "v5"
  367. .size cpu_elf_name, . - cpu_elf_name
  368. .type cpu_feroceon_name, #object
  369. cpu_feroceon_name:
  370. .asciz "Feroceon"
  371. .size cpu_feroceon_name, . - cpu_feroceon_name
  372. .align
  373. .section ".proc.info.init", #alloc, #execinstr
  374. #ifdef CONFIG_CPU_FEROCEON_OLD_ID
  375. .type __feroceon_old_id_proc_info,#object
  376. __feroceon_old_id_proc_info:
  377. .long 0x41069260
  378. .long 0xfffffff0
  379. .long PMD_TYPE_SECT | \
  380. PMD_SECT_BUFFERABLE | \
  381. PMD_SECT_CACHEABLE | \
  382. PMD_BIT4 | \
  383. PMD_SECT_AP_WRITE | \
  384. PMD_SECT_AP_READ
  385. .long PMD_TYPE_SECT | \
  386. PMD_BIT4 | \
  387. PMD_SECT_AP_WRITE | \
  388. PMD_SECT_AP_READ
  389. b __feroceon_setup
  390. .long cpu_arch_name
  391. .long cpu_elf_name
  392. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  393. .long cpu_feroceon_name
  394. .long feroceon_processor_functions
  395. .long v4wbi_tlb_fns
  396. .long v4wb_user_fns
  397. .long feroceon_cache_fns
  398. .size __feroceon_old_id_proc_info, . - __feroceon_old_id_proc_info
  399. #endif
  400. .type __feroceon_proc_info,#object
  401. __feroceon_proc_info:
  402. .long 0x56055310
  403. .long 0xfffffff0
  404. .long PMD_TYPE_SECT | \
  405. PMD_SECT_BUFFERABLE | \
  406. PMD_SECT_CACHEABLE | \
  407. PMD_BIT4 | \
  408. PMD_SECT_AP_WRITE | \
  409. PMD_SECT_AP_READ
  410. .long PMD_TYPE_SECT | \
  411. PMD_BIT4 | \
  412. PMD_SECT_AP_WRITE | \
  413. PMD_SECT_AP_READ
  414. b __feroceon_setup
  415. .long cpu_arch_name
  416. .long cpu_elf_name
  417. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  418. .long cpu_feroceon_name
  419. .long feroceon_processor_functions
  420. .long v4wbi_tlb_fns
  421. .long v4wb_user_fns
  422. .long feroceon_cache_fns
  423. .size __feroceon_proc_info, . - __feroceon_proc_info