proc-mohawk.S 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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. mov pc, 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. mov pc, 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. ENTRY(cpu_mohawk_reset)
  67. mov ip, #0
  68. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  69. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  70. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  71. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  72. bic ip, ip, #0x0007 @ .............cam
  73. bic ip, ip, #0x1100 @ ...i...s........
  74. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  75. mov pc, r0
  76. /*
  77. * cpu_mohawk_do_idle()
  78. *
  79. * Called with IRQs disabled
  80. */
  81. .align 5
  82. ENTRY(cpu_mohawk_do_idle)
  83. mov r0, #0
  84. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  85. mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
  86. mov pc, lr
  87. /*
  88. * flush_icache_all()
  89. *
  90. * Unconditionally clean and invalidate the entire icache.
  91. */
  92. ENTRY(mohawk_flush_icache_all)
  93. mov r0, #0
  94. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  95. mov pc, lr
  96. ENDPROC(mohawk_flush_icache_all)
  97. /*
  98. * flush_user_cache_all()
  99. *
  100. * Clean and invalidate all cache entries in a particular
  101. * address space.
  102. */
  103. ENTRY(mohawk_flush_user_cache_all)
  104. /* FALLTHROUGH */
  105. /*
  106. * flush_kern_cache_all()
  107. *
  108. * Clean and invalidate the entire cache.
  109. */
  110. ENTRY(mohawk_flush_kern_cache_all)
  111. mov r2, #VM_EXEC
  112. mov ip, #0
  113. __flush_whole_cache:
  114. mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
  115. tst r2, #VM_EXEC
  116. mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
  117. mcrne p15, 0, ip, c7, c10, 0 @ drain write buffer
  118. mov pc, lr
  119. /*
  120. * flush_user_cache_range(start, end, flags)
  121. *
  122. * Clean and invalidate a range of cache entries in the
  123. * specified address range.
  124. *
  125. * - start - start address (inclusive)
  126. * - end - end address (exclusive)
  127. * - flags - vm_flags describing address space
  128. *
  129. * (same as arm926)
  130. */
  131. ENTRY(mohawk_flush_user_cache_range)
  132. mov ip, #0
  133. sub r3, r1, r0 @ calculate total size
  134. cmp r3, #CACHE_DLIMIT
  135. bgt __flush_whole_cache
  136. 1: tst r2, #VM_EXEC
  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. 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. cmp r0, r1
  144. blo 1b
  145. tst r2, #VM_EXEC
  146. mcrne p15, 0, ip, c7, c10, 4 @ drain WB
  147. mov pc, lr
  148. /*
  149. * coherent_kern_range(start, end)
  150. *
  151. * Ensure coherency between the Icache and the Dcache in the
  152. * region described by start, end. If you have non-snooping
  153. * Harvard caches, you need to implement this function.
  154. *
  155. * - start - virtual start address
  156. * - end - virtual end address
  157. */
  158. ENTRY(mohawk_coherent_kern_range)
  159. /* FALLTHROUGH */
  160. /*
  161. * coherent_user_range(start, end)
  162. *
  163. * Ensure coherency between the Icache and the Dcache in the
  164. * region described by start, end. If you have non-snooping
  165. * Harvard caches, you need to implement this function.
  166. *
  167. * - start - virtual start address
  168. * - end - virtual end address
  169. *
  170. * (same as arm926)
  171. */
  172. ENTRY(mohawk_coherent_user_range)
  173. bic r0, r0, #CACHE_DLINESIZE - 1
  174. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  175. mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
  176. add r0, r0, #CACHE_DLINESIZE
  177. cmp r0, r1
  178. blo 1b
  179. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  180. mov pc, lr
  181. /*
  182. * flush_kern_dcache_area(void *addr, size_t size)
  183. *
  184. * Ensure no D cache aliasing occurs, either with itself or
  185. * the I cache
  186. *
  187. * - addr - kernel address
  188. * - size - region size
  189. */
  190. ENTRY(mohawk_flush_kern_dcache_area)
  191. add r1, r0, r1
  192. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  193. add r0, r0, #CACHE_DLINESIZE
  194. cmp r0, r1
  195. blo 1b
  196. mov r0, #0
  197. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  198. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  199. mov pc, lr
  200. /*
  201. * dma_inv_range(start, end)
  202. *
  203. * Invalidate (discard) the specified virtual address range.
  204. * May not write back any entries. If 'start' or 'end'
  205. * are not cache line aligned, those lines must be written
  206. * back.
  207. *
  208. * - start - virtual start address
  209. * - end - virtual end address
  210. *
  211. * (same as v4wb)
  212. */
  213. mohawk_dma_inv_range:
  214. tst r0, #CACHE_DLINESIZE - 1
  215. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  216. tst r1, #CACHE_DLINESIZE - 1
  217. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  218. bic r0, r0, #CACHE_DLINESIZE - 1
  219. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  220. add r0, r0, #CACHE_DLINESIZE
  221. cmp r0, r1
  222. blo 1b
  223. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  224. mov pc, lr
  225. /*
  226. * dma_clean_range(start, end)
  227. *
  228. * Clean the specified virtual address range.
  229. *
  230. * - start - virtual start address
  231. * - end - virtual end address
  232. *
  233. * (same as v4wb)
  234. */
  235. mohawk_dma_clean_range:
  236. bic r0, r0, #CACHE_DLINESIZE - 1
  237. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  238. add r0, r0, #CACHE_DLINESIZE
  239. cmp r0, r1
  240. blo 1b
  241. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  242. mov pc, lr
  243. /*
  244. * dma_flush_range(start, end)
  245. *
  246. * Clean and invalidate the specified virtual address range.
  247. *
  248. * - start - virtual start address
  249. * - end - virtual end address
  250. */
  251. ENTRY(mohawk_dma_flush_range)
  252. bic r0, r0, #CACHE_DLINESIZE - 1
  253. 1:
  254. mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  255. add r0, r0, #CACHE_DLINESIZE
  256. cmp r0, r1
  257. blo 1b
  258. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  259. mov pc, lr
  260. /*
  261. * dma_map_area(start, size, dir)
  262. * - start - kernel virtual start address
  263. * - size - size of region
  264. * - dir - DMA direction
  265. */
  266. ENTRY(mohawk_dma_map_area)
  267. add r1, r1, r0
  268. cmp r2, #DMA_TO_DEVICE
  269. beq mohawk_dma_clean_range
  270. bcs mohawk_dma_inv_range
  271. b mohawk_dma_flush_range
  272. ENDPROC(mohawk_dma_map_area)
  273. /*
  274. * dma_unmap_area(start, size, dir)
  275. * - start - kernel virtual start address
  276. * - size - size of region
  277. * - dir - DMA direction
  278. */
  279. ENTRY(mohawk_dma_unmap_area)
  280. mov pc, lr
  281. ENDPROC(mohawk_dma_unmap_area)
  282. @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
  283. define_cache_functions mohawk
  284. ENTRY(cpu_mohawk_dcache_clean_area)
  285. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  286. add r0, r0, #CACHE_DLINESIZE
  287. subs r1, r1, #CACHE_DLINESIZE
  288. bhi 1b
  289. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  290. mov pc, lr
  291. /*
  292. * cpu_mohawk_switch_mm(pgd)
  293. *
  294. * Set the translation base pointer to be as described by pgd.
  295. *
  296. * pgd: new page tables
  297. */
  298. .align 5
  299. ENTRY(cpu_mohawk_switch_mm)
  300. mov ip, #0
  301. mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
  302. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  303. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  304. orr r0, r0, #0x18 @ cache the page table in L2
  305. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  306. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  307. mov pc, lr
  308. /*
  309. * cpu_mohawk_set_pte_ext(ptep, pte, ext)
  310. *
  311. * Set a PTE and flush it out
  312. */
  313. .align 5
  314. ENTRY(cpu_mohawk_set_pte_ext)
  315. armv3_set_pte_ext
  316. mov r0, r0
  317. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  318. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  319. mov pc, lr
  320. __CPUINIT
  321. .type __mohawk_setup, #function
  322. __mohawk_setup:
  323. mov r0, #0
  324. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches
  325. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  326. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs
  327. orr r4, r4, #0x18 @ cache the page table in L2
  328. mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
  329. mov r0, #0 @ don't allow CP access
  330. mcr p15, 0, r0, c15, c1, 0 @ write CP access register
  331. adr r5, mohawk_crval
  332. ldmia r5, {r5, r6}
  333. mrc p15, 0, r0, c1, c0 @ get control register
  334. bic r0, r0, r5
  335. orr r0, r0, r6
  336. mov pc, lr
  337. .size __mohawk_setup, . - __mohawk_setup
  338. /*
  339. * R
  340. * .RVI ZFRS BLDP WCAM
  341. * .011 1001 ..00 0101
  342. *
  343. */
  344. .type mohawk_crval, #object
  345. mohawk_crval:
  346. crval clear=0x00007f3f, mmuset=0x00003905, ucset=0x00001134
  347. __INITDATA
  348. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  349. define_processor_functions mohawk, dabort=v5t_early_abort, pabort=legacy_pabort
  350. .section ".rodata"
  351. string cpu_arch_name, "armv5te"
  352. string cpu_elf_name, "v5"
  353. string cpu_mohawk_name, "Marvell 88SV331x"
  354. .align
  355. .section ".proc.info.init", #alloc, #execinstr
  356. .type __88sv331x_proc_info,#object
  357. __88sv331x_proc_info:
  358. .long 0x56158000 @ Marvell 88SV331x (MOHAWK)
  359. .long 0xfffff000
  360. .long PMD_TYPE_SECT | \
  361. PMD_SECT_BUFFERABLE | \
  362. PMD_SECT_CACHEABLE | \
  363. PMD_BIT4 | \
  364. PMD_SECT_AP_WRITE | \
  365. PMD_SECT_AP_READ
  366. .long PMD_TYPE_SECT | \
  367. PMD_BIT4 | \
  368. PMD_SECT_AP_WRITE | \
  369. PMD_SECT_AP_READ
  370. b __mohawk_setup
  371. .long cpu_arch_name
  372. .long cpu_elf_name
  373. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  374. .long cpu_mohawk_name
  375. .long mohawk_processor_functions
  376. .long v4wbi_tlb_fns
  377. .long v4wb_user_fns
  378. .long mohawk_cache_fns
  379. .size __88sv331x_proc_info, . - __88sv331x_proc_info