proc-mohawk.S 10 KB

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