PageRenderTime 25ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/arch/arm/mm/proc-mohawk.S

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