proc-mohawk.S 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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. .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. mov pc, 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. mov pc, 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. mov pc, 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. mov pc, 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. mov pc, 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 pc, lr
  184. /*
  185. * flush_kern_dcache_area(void *addr, size_t size)
  186. *
  187. * Ensure no D cache aliasing occurs, either with itself or
  188. * the I cache
  189. *
  190. * - addr - kernel address
  191. * - size - region size
  192. */
  193. ENTRY(mohawk_flush_kern_dcache_area)
  194. add r1, r0, r1
  195. 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  196. add r0, r0, #CACHE_DLINESIZE
  197. cmp r0, r1
  198. blo 1b
  199. mov r0, #0
  200. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  201. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  202. mov pc, lr
  203. /*
  204. * dma_inv_range(start, end)
  205. *
  206. * Invalidate (discard) the specified virtual address range.
  207. * May not write back any entries. If 'start' or 'end'
  208. * are not cache line aligned, those lines must be written
  209. * back.
  210. *
  211. * - start - virtual start address
  212. * - end - virtual end address
  213. *
  214. * (same as v4wb)
  215. */
  216. mohawk_dma_inv_range:
  217. tst r0, #CACHE_DLINESIZE - 1
  218. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  219. tst r1, #CACHE_DLINESIZE - 1
  220. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  221. bic r0, r0, #CACHE_DLINESIZE - 1
  222. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  223. add r0, r0, #CACHE_DLINESIZE
  224. cmp r0, r1
  225. blo 1b
  226. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  227. mov pc, lr
  228. /*
  229. * dma_clean_range(start, end)
  230. *
  231. * Clean the specified virtual address range.
  232. *
  233. * - start - virtual start address
  234. * - end - virtual end address
  235. *
  236. * (same as v4wb)
  237. */
  238. mohawk_dma_clean_range:
  239. bic r0, r0, #CACHE_DLINESIZE - 1
  240. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  241. add r0, r0, #CACHE_DLINESIZE
  242. cmp r0, r1
  243. blo 1b
  244. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  245. mov pc, lr
  246. /*
  247. * dma_flush_range(start, end)
  248. *
  249. * Clean and invalidate the specified virtual address range.
  250. *
  251. * - start - virtual start address
  252. * - end - virtual end address
  253. */
  254. ENTRY(mohawk_dma_flush_range)
  255. bic r0, r0, #CACHE_DLINESIZE - 1
  256. 1:
  257. mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
  258. add r0, r0, #CACHE_DLINESIZE
  259. cmp r0, r1
  260. blo 1b
  261. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  262. mov pc, lr
  263. /*
  264. * dma_map_area(start, size, dir)
  265. * - start - kernel virtual start address
  266. * - size - size of region
  267. * - dir - DMA direction
  268. */
  269. ENTRY(mohawk_dma_map_area)
  270. add r1, r1, r0
  271. cmp r2, #DMA_TO_DEVICE
  272. beq mohawk_dma_clean_range
  273. bcs mohawk_dma_inv_range
  274. b mohawk_dma_flush_range
  275. ENDPROC(mohawk_dma_map_area)
  276. /*
  277. * dma_unmap_area(start, size, dir)
  278. * - start - kernel virtual start address
  279. * - size - size of region
  280. * - dir - DMA direction
  281. */
  282. ENTRY(mohawk_dma_unmap_area)
  283. mov pc, lr
  284. ENDPROC(mohawk_dma_unmap_area)
  285. @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
  286. define_cache_functions mohawk
  287. ENTRY(cpu_mohawk_dcache_clean_area)
  288. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  289. add r0, r0, #CACHE_DLINESIZE
  290. subs r1, r1, #CACHE_DLINESIZE
  291. bhi 1b
  292. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  293. mov pc, lr
  294. /*
  295. * cpu_mohawk_switch_mm(pgd)
  296. *
  297. * Set the translation base pointer to be as described by pgd.
  298. *
  299. * pgd: new page tables
  300. */
  301. .align 5
  302. ENTRY(cpu_mohawk_switch_mm)
  303. mov ip, #0
  304. mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
  305. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  306. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  307. orr r0, r0, #0x18 @ cache the page table in L2
  308. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  309. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  310. mov pc, lr
  311. /*
  312. * cpu_mohawk_set_pte_ext(ptep, pte, ext)
  313. *
  314. * Set a PTE and flush it out
  315. */
  316. .align 5
  317. ENTRY(cpu_mohawk_set_pte_ext)
  318. armv3_set_pte_ext
  319. mov r0, r0
  320. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  321. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  322. mov pc, lr
  323. __CPUINIT
  324. .type __mohawk_setup, #function
  325. __mohawk_setup:
  326. mov r0, #0
  327. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches
  328. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  329. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs
  330. orr r4, r4, #0x18 @ cache the page table in L2
  331. mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
  332. mov r0, #0 @ don't allow CP access
  333. mcr p15, 0, r0, c15, c1, 0 @ write CP access register
  334. adr r5, mohawk_crval
  335. ldmia r5, {r5, r6}
  336. mrc p15, 0, r0, c1, c0 @ get control register
  337. bic r0, r0, r5
  338. orr r0, r0, r6
  339. mov pc, lr
  340. .size __mohawk_setup, . - __mohawk_setup
  341. /*
  342. * R
  343. * .RVI ZFRS BLDP WCAM
  344. * .011 1001 ..00 0101
  345. *
  346. */
  347. .type mohawk_crval, #object
  348. mohawk_crval:
  349. crval clear=0x00007f3f, mmuset=0x00003905, ucset=0x00001134
  350. __INITDATA
  351. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  352. define_processor_functions mohawk, dabort=v5t_early_abort, pabort=legacy_pabort
  353. .section ".rodata"
  354. string cpu_arch_name, "armv5te"
  355. string cpu_elf_name, "v5"
  356. string cpu_mohawk_name, "Marvell 88SV331x"
  357. .align
  358. .section ".proc.info.init", #alloc, #execinstr
  359. .type __88sv331x_proc_info,#object
  360. __88sv331x_proc_info:
  361. .long 0x56158000 @ Marvell 88SV331x (MOHAWK)
  362. .long 0xfffff000
  363. .long PMD_TYPE_SECT | \
  364. PMD_SECT_BUFFERABLE | \
  365. PMD_SECT_CACHEABLE | \
  366. PMD_BIT4 | \
  367. PMD_SECT_AP_WRITE | \
  368. PMD_SECT_AP_READ
  369. .long PMD_TYPE_SECT | \
  370. PMD_BIT4 | \
  371. PMD_SECT_AP_WRITE | \
  372. PMD_SECT_AP_READ
  373. b __mohawk_setup
  374. .long cpu_arch_name
  375. .long cpu_elf_name
  376. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  377. .long cpu_mohawk_name
  378. .long mohawk_processor_functions
  379. .long v4wbi_tlb_fns
  380. .long v4wb_user_fns
  381. .long mohawk_cache_fns
  382. .size __88sv331x_proc_info, . - __88sv331x_proc_info