proc-mohawk.S 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. /*
  2. * linux/arch/arm/mm/proc-mohawk.S: MMU functions for Marvell PJ1 core
  3. *
  4. * PJ1 (codename Mohawk) is a hybrid of the xscale3 and Marvell's own core.
  5. *
  6. * Heavily based on proc-arm926.S and proc-xsc3.S
  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. #include <linux/linkage.h>
  23. #include <linux/init.h>
  24. #include <asm/assembler.h>
  25. #include <asm/hwcap.h>
  26. #include <asm/pgtable-hwdef.h>
  27. #include <asm/pgtable.h>
  28. #include <asm/page.h>
  29. #include <asm/ptrace.h>
  30. #include "proc-macros.S"
  31. /*
  32. * This is the maximum size of an area which will be flushed. If the
  33. * area is larger than this, then we flush the whole cache.
  34. */
  35. #define CACHE_DLIMIT 32768
  36. /*
  37. * The cache line size of the L1 D cache.
  38. */
  39. #define CACHE_DLINESIZE 32
  40. /*
  41. * cpu_mohawk_proc_init()
  42. */
  43. ENTRY(cpu_mohawk_proc_init)
  44. ret lr
  45. /*
  46. * cpu_mohawk_proc_fin()
  47. */
  48. ENTRY(cpu_mohawk_proc_fin)
  49. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  50. bic r0, r0, #0x1800 @ ...iz...........
  51. bic r0, r0, #0x0006 @ .............ca.
  52. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  53. ret lr
  54. /*
  55. * cpu_mohawk_reset(loc)
  56. *
  57. * Perform a soft reset of the system. Put the CPU into the
  58. * same state as it would be if it had been reset, and branch
  59. * to what would be the reset vector.
  60. *
  61. * loc: location to jump to for soft reset
  62. *
  63. * (same as arm926)
  64. */
  65. .align 5
  66. .pushsection .idmap.text, "ax"
  67. ENTRY(cpu_mohawk_reset)
  68. mov ip, #0
  69. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  70. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  71. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  72. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  73. bic ip, ip, #0x0007 @ .............cam
  74. bic ip, ip, #0x1100 @ ...i...s........
  75. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  76. ret r0
  77. ENDPROC(cpu_mohawk_reset)
  78. .popsection
  79. /*
  80. * cpu_mohawk_do_idle()
  81. *
  82. * Called with IRQs disabled
  83. */
  84. .align 5
  85. ENTRY(cpu_mohawk_do_idle)
  86. mov r0, #0
  87. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  88. mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
  89. ret lr
  90. /*
  91. * flush_icache_all()
  92. *
  93. * Unconditionally clean and invalidate the entire icache.
  94. */
  95. ENTRY(mohawk_flush_icache_all)
  96. mov r0, #0
  97. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  98. ret lr
  99. ENDPROC(mohawk_flush_icache_all)
  100. /*
  101. * flush_user_cache_all()
  102. *
  103. * Clean and invalidate all cache entries in a particular
  104. * address space.
  105. */
  106. ENTRY(mohawk_flush_user_cache_all)
  107. /* FALLTHROUGH */
  108. /*
  109. * flush_kern_cache_all()
  110. *
  111. * Clean and invalidate the entire cache.
  112. */
  113. ENTRY(mohawk_flush_kern_cache_all)
  114. mov r2, #VM_EXEC
  115. mov ip, #0
  116. __flush_whole_cache:
  117. mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
  118. tst r2, #VM_EXEC
  119. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  120. mcrne p15, 0, ip, c7, c10, 0 @ drain write buffer
  121. ret lr
  122. /*
  123. * flush_user_cache_range(start, end, flags)
  124. *
  125. * Clean and invalidate a range of cache entries in the
  126. * specified address range.
  127. *
  128. * - start - start address (inclusive)
  129. * - end - end address (exclusive)
  130. * - flags - vm_flags describing address space
  131. *
  132. * (same as arm926)
  133. */
  134. ENTRY(mohawk_flush_user_cache_range)
  135. mov ip, #0
  136. sub r3, r1, r0 @ calculate total size
  137. cmp r3, #CACHE_DLIMIT
  138. bgt __flush_whole_cache
  139. 1: tst r2, #VM_EXEC
  140. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
  141. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  142. add r0, r0, #CACHE_DLINESIZE
  143. mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
  144. mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
  145. add r0, r0, #CACHE_DLINESIZE
  146. cmp r0, r1
  147. blo 1b
  148. tst r2, #VM_EXEC
  149. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  150. ret lr
  151. /*
  152. * coherent_kern_range(start, end)
  153. *
  154. * Ensure coherency between the Icache and the Dcache in the
  155. * region described by start, end. If you have non-snooping
  156. * Harvard caches, you need to implement this function.
  157. *
  158. * - start - virtual start address
  159. * - end - virtual end address
  160. */
  161. ENTRY(mohawk_coherent_kern_range)
  162. /* FALLTHROUGH */
  163. /*
  164. * coherent_user_range(start, end)
  165. *
  166. * Ensure coherency between the Icache and the Dcache in the
  167. * region described by start, end. If you have non-snooping
  168. * Harvard caches, you need to implement this function.
  169. *
  170. * - start - virtual start address
  171. * - end - virtual end address
  172. *
  173. * (same as arm926)
  174. */
  175. ENTRY(mohawk_coherent_user_range)
  176. bic r0, r0, #CACHE_DLINESIZE - 1
  177. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  178. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  179. add r0, r0, #CACHE_DLINESIZE
  180. cmp r0, r1
  181. blo 1b
  182. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  183. mov r0, #0
  184. ret lr
  185. /*
  186. * flush_kern_dcache_area(void *addr, size_t size)
  187. *
  188. * Ensure no D cache aliasing occurs, either with itself or
  189. * the I cache
  190. *
  191. * - addr - kernel address
  192. * - size - region size
  193. */
  194. ENTRY(mohawk_flush_kern_dcache_area)
  195. add r1, r0, r1
  196. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  197. add r0, r0, #CACHE_DLINESIZE
  198. cmp r0, r1
  199. blo 1b
  200. mov r0, #0
  201. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  202. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  203. ret lr
  204. /*
  205. * dma_inv_range(start, end)
  206. *
  207. * Invalidate (discard) the specified virtual address range.
  208. * May not write back any entries. If 'start' or 'end'
  209. * are not cache line aligned, those lines must be written
  210. * back.
  211. *
  212. * - start - virtual start address
  213. * - end - virtual end address
  214. *
  215. * (same as v4wb)
  216. */
  217. mohawk_dma_inv_range:
  218. tst r0, #CACHE_DLINESIZE - 1
  219. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  220. tst r1, #CACHE_DLINESIZE - 1
  221. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  222. bic r0, r0, #CACHE_DLINESIZE - 1
  223. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  224. add r0, r0, #CACHE_DLINESIZE
  225. cmp r0, r1
  226. blo 1b
  227. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  228. ret lr
  229. /*
  230. * dma_clean_range(start, end)
  231. *
  232. * Clean the specified virtual address range.
  233. *
  234. * - start - virtual start address
  235. * - end - virtual end address
  236. *
  237. * (same as v4wb)
  238. */
  239. mohawk_dma_clean_range:
  240. bic r0, r0, #CACHE_DLINESIZE - 1
  241. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  242. add r0, r0, #CACHE_DLINESIZE
  243. cmp r0, r1
  244. blo 1b
  245. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  246. ret lr
  247. /*
  248. * dma_flush_range(start, end)
  249. *
  250. * Clean and invalidate the specified virtual address range.
  251. *
  252. * - start - virtual start address
  253. * - end - virtual end address
  254. */
  255. ENTRY(mohawk_dma_flush_range)
  256. bic r0, r0, #CACHE_DLINESIZE - 1
  257. 1:
  258. mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  259. add r0, r0, #CACHE_DLINESIZE
  260. cmp r0, r1
  261. blo 1b
  262. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  263. ret lr
  264. /*
  265. * dma_map_area(start, size, dir)
  266. * - start - kernel virtual start address
  267. * - size - size of region
  268. * - dir - DMA direction
  269. */
  270. ENTRY(mohawk_dma_map_area)
  271. add r1, r1, r0
  272. cmp r2, #DMA_TO_DEVICE
  273. beq mohawk_dma_clean_range
  274. bcs mohawk_dma_inv_range
  275. b mohawk_dma_flush_range
  276. ENDPROC(mohawk_dma_map_area)
  277. /*
  278. * dma_unmap_area(start, size, dir)
  279. * - start - kernel virtual start address
  280. * - size - size of region
  281. * - dir - DMA direction
  282. */
  283. ENTRY(mohawk_dma_unmap_area)
  284. ret lr
  285. ENDPROC(mohawk_dma_unmap_area)
  286. .globl mohawk_flush_kern_cache_louis
  287. .equ mohawk_flush_kern_cache_louis, mohawk_flush_kern_cache_all
  288. @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
  289. define_cache_functions mohawk
  290. ENTRY(cpu_mohawk_dcache_clean_area)
  291. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  292. add r0, r0, #CACHE_DLINESIZE
  293. subs r1, r1, #CACHE_DLINESIZE
  294. bhi 1b
  295. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  296. ret lr
  297. /*
  298. * cpu_mohawk_switch_mm(pgd)
  299. *
  300. * Set the translation base pointer to be as described by pgd.
  301. *
  302. * pgd: new page tables
  303. */
  304. .align 5
  305. ENTRY(cpu_mohawk_switch_mm)
  306. mov ip, #0
  307. mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
  308. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  309. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  310. orr r0, r0, #0x18 @ cache the page table in L2
  311. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  312. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  313. ret lr
  314. /*
  315. * cpu_mohawk_set_pte_ext(ptep, pte, ext)
  316. *
  317. * Set a PTE and flush it out
  318. */
  319. .align 5
  320. ENTRY(cpu_mohawk_set_pte_ext)
  321. #ifdef CONFIG_MMU
  322. armv3_set_pte_ext
  323. mov r0, r0
  324. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  325. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  326. ret lr
  327. #endif
  328. .globl cpu_mohawk_suspend_size
  329. .equ cpu_mohawk_suspend_size, 4 * 6
  330. #ifdef CONFIG_ARM_CPU_SUSPEND
  331. ENTRY(cpu_mohawk_do_suspend)
  332. stmfd sp!, {r4 - r9, lr}
  333. mrc p14, 0, r4, c6, c0, 0 @ clock configuration, for turbo mode
  334. mrc p15, 0, r5, c15, c1, 0 @ CP access reg
  335. mrc p15, 0, r6, c13, c0, 0 @ PID
  336. mrc p15, 0, r7, c3, c0, 0 @ domain ID
  337. mrc p15, 0, r8, c1, c0, 1 @ auxiliary control reg
  338. mrc p15, 0, r9, c1, c0, 0 @ control reg
  339. bic r4, r4, #2 @ clear frequency change bit
  340. stmia r0, {r4 - r9} @ store cp regs
  341. ldmia sp!, {r4 - r9, pc}
  342. ENDPROC(cpu_mohawk_do_suspend)
  343. ENTRY(cpu_mohawk_do_resume)
  344. ldmia r0, {r4 - r9} @ load cp regs
  345. mov ip, #0
  346. mcr p15, 0, ip, c7, c7, 0 @ invalidate I & D caches, BTB
  347. mcr p15, 0, ip, c7, c10, 4 @ drain write (&fill) buffer
  348. mcr p15, 0, ip, c7, c5, 4 @ flush prefetch buffer
  349. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  350. mcr p14, 0, r4, c6, c0, 0 @ clock configuration, turbo mode.
  351. mcr p15, 0, r5, c15, c1, 0 @ CP access reg
  352. mcr p15, 0, r6, c13, c0, 0 @ PID
  353. mcr p15, 0, r7, c3, c0, 0 @ domain ID
  354. orr r1, r1, #0x18 @ cache the page table in L2
  355. mcr p15, 0, r1, c2, c0, 0 @ translation table base addr
  356. mcr p15, 0, r8, c1, c0, 1 @ auxiliary control reg
  357. mov r0, r9 @ control register
  358. b cpu_resume_mmu
  359. ENDPROC(cpu_mohawk_do_resume)
  360. #endif
  361. .type __mohawk_setup, #function
  362. __mohawk_setup:
  363. mov r0, #0
  364. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches
  365. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  366. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs
  367. orr r4, r4, #0x18 @ cache the page table in L2
  368. mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
  369. mov r0, #0 @ don't allow CP access
  370. mcr p15, 0, r0, c15, c1, 0 @ write CP access register
  371. adr r5, mohawk_crval
  372. ldmia r5, {r5, r6}
  373. mrc p15, 0, r0, c1, c0 @ get control register
  374. bic r0, r0, r5
  375. orr r0, r0, r6
  376. ret lr
  377. .size __mohawk_setup, . - __mohawk_setup
  378. /*
  379. * R
  380. * .RVI ZFRS BLDP WCAM
  381. * .011 1001 ..00 0101
  382. *
  383. */
  384. .type mohawk_crval, #object
  385. mohawk_crval:
  386. crval clear=0x00007f3f, mmuset=0x00003905, ucset=0x00001134
  387. __INITDATA
  388. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  389. define_processor_functions mohawk, dabort=v5t_early_abort, pabort=legacy_pabort
  390. .section ".rodata"
  391. string cpu_arch_name, "armv5te"
  392. string cpu_elf_name, "v5"
  393. string cpu_mohawk_name, "Marvell 88SV331x"
  394. .align
  395. .section ".proc.info.init", #alloc
  396. .type __88sv331x_proc_info,#object
  397. __88sv331x_proc_info:
  398. .long 0x56158000 @ Marvell 88SV331x (MOHAWK)
  399. .long 0xfffff000
  400. .long PMD_TYPE_SECT | \
  401. PMD_SECT_BUFFERABLE | \
  402. PMD_SECT_CACHEABLE | \
  403. PMD_BIT4 | \
  404. PMD_SECT_AP_WRITE | \
  405. PMD_SECT_AP_READ
  406. .long PMD_TYPE_SECT | \
  407. PMD_BIT4 | \
  408. PMD_SECT_AP_WRITE | \
  409. PMD_SECT_AP_READ
  410. initfn __mohawk_setup, __88sv331x_proc_info
  411. .long cpu_arch_name
  412. .long cpu_elf_name
  413. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  414. .long cpu_mohawk_name
  415. .long mohawk_processor_functions
  416. .long v4wbi_tlb_fns
  417. .long v4wb_user_fns
  418. .long mohawk_cache_fns
  419. .size __88sv331x_proc_info, . - __88sv331x_proc_info