proc-xscale.S 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. /*
  2. * linux/arch/arm/mm/proc-xscale.S
  3. *
  4. * Author: Nicolas Pitre
  5. * Created: November 2000
  6. * Copyright: (C) 2000, 2001 MontaVista Software Inc.
  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 version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * MMU functions for the Intel XScale CPUs
  13. *
  14. * 2001 Aug 21:
  15. * some contributions by Brett Gaines <brett.w.gaines@intel.com>
  16. * Copyright 2001 by Intel Corp.
  17. *
  18. * 2001 Sep 08:
  19. * Completely revisited, many important fixes
  20. * Nicolas Pitre <nico@cam.org>
  21. */
  22. #include <linux/linkage.h>
  23. #include <linux/init.h>
  24. #include <asm/assembler.h>
  25. #include <asm/procinfo.h>
  26. #include <asm/hardware.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 area
  33. * is larger than this, then we flush the whole cache
  34. */
  35. #define MAX_AREA_SIZE 32768
  36. /*
  37. * the cache line size of the I and D cache
  38. */
  39. #define CACHELINESIZE 32
  40. /*
  41. * the size of the data cache
  42. */
  43. #define CACHESIZE 32768
  44. /*
  45. * Virtual address used to allocate the cache when flushed
  46. *
  47. * This must be an address range which is _never_ used. It should
  48. * apparently have a mapping in the corresponding page table for
  49. * compatibility with future CPUs that _could_ require it. For instance we
  50. * don't care.
  51. *
  52. * This must be aligned on a 2*CACHESIZE boundary. The code selects one of
  53. * the 2 areas in alternance each time the clean_d_cache macro is used.
  54. * Without this the XScale core exhibits cache eviction problems and no one
  55. * knows why.
  56. *
  57. * Reminder: the vector table is located at 0xffff0000-0xffff0fff.
  58. */
  59. #define CLEAN_ADDR 0xfffe0000
  60. /*
  61. * This macro is used to wait for a CP15 write and is needed
  62. * when we have to ensure that the last operation to the co-pro
  63. * was completed before continuing with operation.
  64. */
  65. .macro cpwait, rd
  66. mrc p15, 0, \rd, c2, c0, 0 @ arbitrary read of cp15
  67. mov \rd, \rd @ wait for completion
  68. sub pc, pc, #4 @ flush instruction pipeline
  69. .endm
  70. .macro cpwait_ret, lr, rd
  71. mrc p15, 0, \rd, c2, c0, 0 @ arbitrary read of cp15
  72. sub pc, \lr, \rd, LSR #32 @ wait for completion and
  73. @ flush instruction pipeline
  74. .endm
  75. /*
  76. * This macro cleans the entire dcache using line allocate.
  77. * The main loop has been unrolled to reduce loop overhead.
  78. * rd and rs are two scratch registers.
  79. */
  80. .macro clean_d_cache, rd, rs
  81. ldr \rs, =clean_addr
  82. ldr \rd, [\rs]
  83. eor \rd, \rd, #CACHESIZE
  84. str \rd, [\rs]
  85. add \rs, \rd, #CACHESIZE
  86. 1: mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line
  87. add \rd, \rd, #CACHELINESIZE
  88. mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line
  89. add \rd, \rd, #CACHELINESIZE
  90. mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line
  91. add \rd, \rd, #CACHELINESIZE
  92. mcr p15, 0, \rd, c7, c2, 5 @ allocate D cache line
  93. add \rd, \rd, #CACHELINESIZE
  94. teq \rd, \rs
  95. bne 1b
  96. .endm
  97. .data
  98. clean_addr: .word CLEAN_ADDR
  99. .text
  100. /*
  101. * cpu_xscale_proc_init()
  102. *
  103. * Nothing too exciting at the moment
  104. */
  105. ENTRY(cpu_xscale_proc_init)
  106. mov pc, lr
  107. /*
  108. * cpu_xscale_proc_fin()
  109. */
  110. ENTRY(cpu_xscale_proc_fin)
  111. str lr, [sp, #-4]!
  112. mov r0, #PSR_F_BIT|PSR_I_BIT|SVC_MODE
  113. msr cpsr_c, r0
  114. bl xscale_flush_kern_cache_all @ clean caches
  115. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  116. bic r0, r0, #0x1800 @ ...IZ...........
  117. bic r0, r0, #0x0006 @ .............CA.
  118. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  119. ldr pc, [sp], #4
  120. /*
  121. * cpu_xscale_reset(loc)
  122. *
  123. * Perform a soft reset of the system. Put the CPU into the
  124. * same state as it would be if it had been reset, and branch
  125. * to what would be the reset vector.
  126. *
  127. * loc: location to jump to for soft reset
  128. */
  129. .align 5
  130. ENTRY(cpu_xscale_reset)
  131. mov r1, #PSR_F_BIT|PSR_I_BIT|SVC_MODE
  132. msr cpsr_c, r1 @ reset CPSR
  133. mrc p15, 0, r1, c1, c0, 0 @ ctrl register
  134. bic r1, r1, #0x0086 @ ........B....CA.
  135. bic r1, r1, #0x3900 @ ..VIZ..S........
  136. mcr p15, 0, r1, c1, c0, 0 @ ctrl register
  137. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches & BTB
  138. bic r1, r1, #0x0001 @ ...............M
  139. mcr p15, 0, r1, c1, c0, 0 @ ctrl register
  140. @ CAUTION: MMU turned off from this point. We count on the pipeline
  141. @ already containing those two last instructions to survive.
  142. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  143. mov pc, r0
  144. /*
  145. * cpu_xscale_do_idle()
  146. *
  147. * Cause the processor to idle
  148. *
  149. * For now we do nothing but go to idle mode for every case
  150. *
  151. * XScale supports clock switching, but using idle mode support
  152. * allows external hardware to react to system state changes.
  153. */
  154. .align 5
  155. ENTRY(cpu_xscale_do_idle)
  156. mov r0, #1
  157. mcr p14, 0, r0, c7, c0, 0 @ Go to IDLE
  158. mov pc, lr
  159. /* ================================= CACHE ================================ */
  160. /*
  161. * flush_user_cache_all()
  162. *
  163. * Invalidate all cache entries in a particular address
  164. * space.
  165. */
  166. ENTRY(xscale_flush_user_cache_all)
  167. /* FALLTHROUGH */
  168. /*
  169. * flush_kern_cache_all()
  170. *
  171. * Clean and invalidate the entire cache.
  172. */
  173. ENTRY(xscale_flush_kern_cache_all)
  174. mov r2, #VM_EXEC
  175. mov ip, #0
  176. __flush_whole_cache:
  177. clean_d_cache r0, r1
  178. tst r2, #VM_EXEC
  179. mcrne p15, 0, ip, c7, c5, 0 @ Invalidate I cache & BTB
  180. mcrne p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
  181. mov pc, lr
  182. /*
  183. * flush_user_cache_range(start, end, vm_flags)
  184. *
  185. * Invalidate a range of cache entries in the specified
  186. * address space.
  187. *
  188. * - start - start address (may not be aligned)
  189. * - end - end address (exclusive, may not be aligned)
  190. * - vma - vma_area_struct describing address space
  191. */
  192. .align 5
  193. ENTRY(xscale_flush_user_cache_range)
  194. mov ip, #0
  195. sub r3, r1, r0 @ calculate total size
  196. cmp r3, #MAX_AREA_SIZE
  197. bhs __flush_whole_cache
  198. 1: tst r2, #VM_EXEC
  199. mcrne p15, 0, r0, c7, c5, 1 @ Invalidate I cache line
  200. mcr p15, 0, r0, c7, c10, 1 @ Clean D cache line
  201. mcr p15, 0, r0, c7, c6, 1 @ Invalidate D cache line
  202. add r0, r0, #CACHELINESIZE
  203. cmp r0, r1
  204. blo 1b
  205. tst r2, #VM_EXEC
  206. mcrne p15, 0, ip, c7, c5, 6 @ Invalidate BTB
  207. mcrne p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
  208. mov pc, lr
  209. /*
  210. * coherent_kern_range(start, end)
  211. *
  212. * Ensure coherency between the Icache and the Dcache in the
  213. * region described by start. If you have non-snooping
  214. * Harvard caches, you need to implement this function.
  215. *
  216. * - start - virtual start address
  217. * - end - virtual end address
  218. *
  219. * Note: single I-cache line invalidation isn't used here since
  220. * it also trashes the mini I-cache used by JTAG debuggers.
  221. */
  222. ENTRY(xscale_coherent_kern_range)
  223. /* FALLTHROUGH */
  224. /*
  225. * coherent_user_range(start, end)
  226. *
  227. * Ensure coherency between the Icache and the Dcache in the
  228. * region described by start. If you have non-snooping
  229. * Harvard caches, you need to implement this function.
  230. *
  231. * - start - virtual start address
  232. * - end - virtual end address
  233. *
  234. * Note: single I-cache line invalidation isn't used here since
  235. * it also trashes the mini I-cache used by JTAG debuggers.
  236. */
  237. ENTRY(xscale_coherent_user_range)
  238. bic r0, r0, #CACHELINESIZE - 1
  239. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  240. add r0, r0, #CACHELINESIZE
  241. cmp r0, r1
  242. blo 1b
  243. mov r0, #0
  244. mcr p15, 0, r0, c7, c5, 0 @ Invalidate I cache & BTB
  245. mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
  246. mov pc, lr
  247. /*
  248. * flush_kern_dcache_page(void *page)
  249. *
  250. * Ensure no D cache aliasing occurs, either with itself or
  251. * the I cache
  252. *
  253. * - addr - page aligned address
  254. */
  255. ENTRY(xscale_flush_kern_dcache_page)
  256. add r1, r0, #PAGE_SZ
  257. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  258. mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  259. add r0, r0, #CACHELINESIZE
  260. cmp r0, r1
  261. blo 1b
  262. mov r0, #0
  263. mcr p15, 0, r0, c7, c5, 0 @ Invalidate I cache & BTB
  264. mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
  265. mov pc, lr
  266. /*
  267. * dma_inv_range(start, end)
  268. *
  269. * Invalidate (discard) the specified virtual address range.
  270. * May not write back any entries. If 'start' or 'end'
  271. * are not cache line aligned, those lines must be written
  272. * back.
  273. *
  274. * - start - virtual start address
  275. * - end - virtual end address
  276. */
  277. ENTRY(xscale_dma_inv_range)
  278. mrc p15, 0, r2, c0, c0, 0 @ read ID
  279. eor r2, r2, #0x69000000
  280. eor r2, r2, #0x00052000
  281. bics r2, r2, #1
  282. beq xscale_dma_flush_range
  283. tst r0, #CACHELINESIZE - 1
  284. bic r0, r0, #CACHELINESIZE - 1
  285. mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
  286. tst r1, #CACHELINESIZE - 1
  287. mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
  288. 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  289. add r0, r0, #CACHELINESIZE
  290. cmp r0, r1
  291. blo 1b
  292. mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
  293. mov pc, lr
  294. /*
  295. * dma_clean_range(start, end)
  296. *
  297. * Clean the specified virtual address range.
  298. *
  299. * - start - virtual start address
  300. * - end - virtual end address
  301. */
  302. ENTRY(xscale_dma_clean_range)
  303. bic r0, r0, #CACHELINESIZE - 1
  304. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  305. add r0, r0, #CACHELINESIZE
  306. cmp r0, r1
  307. blo 1b
  308. mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
  309. mov pc, lr
  310. /*
  311. * dma_flush_range(start, end)
  312. *
  313. * Clean and invalidate the specified virtual address range.
  314. *
  315. * - start - virtual start address
  316. * - end - virtual end address
  317. */
  318. ENTRY(xscale_dma_flush_range)
  319. bic r0, r0, #CACHELINESIZE - 1
  320. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  321. mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
  322. add r0, r0, #CACHELINESIZE
  323. cmp r0, r1
  324. blo 1b
  325. mcr p15, 0, r0, c7, c10, 4 @ Drain Write (& Fill) Buffer
  326. mov pc, lr
  327. ENTRY(xscale_cache_fns)
  328. .long xscale_flush_kern_cache_all
  329. .long xscale_flush_user_cache_all
  330. .long xscale_flush_user_cache_range
  331. .long xscale_coherent_kern_range
  332. .long xscale_coherent_user_range
  333. .long xscale_flush_kern_dcache_page
  334. .long xscale_dma_inv_range
  335. .long xscale_dma_clean_range
  336. .long xscale_dma_flush_range
  337. ENTRY(cpu_xscale_dcache_clean_area)
  338. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  339. add r0, r0, #CACHELINESIZE
  340. subs r1, r1, #CACHELINESIZE
  341. bhi 1b
  342. mov pc, lr
  343. /* ================================ CACHE LOCKING============================
  344. *
  345. * The XScale MicroArchitecture implements support for locking entries into
  346. * the data and instruction cache. The following functions implement the core
  347. * low level instructions needed to accomplish the locking. The developer's
  348. * manual states that the code that performs the locking must be in non-cached
  349. * memory. To accomplish this, the code in xscale-cache-lock.c copies the
  350. * following functions from the cache into a non-cached memory region that
  351. * is allocated through consistent_alloc().
  352. *
  353. */
  354. .align 5
  355. /*
  356. * xscale_icache_lock
  357. *
  358. * r0: starting address to lock
  359. * r1: end address to lock
  360. */
  361. ENTRY(xscale_icache_lock)
  362. iLockLoop:
  363. bic r0, r0, #CACHELINESIZE - 1
  364. mcr p15, 0, r0, c9, c1, 0 @ lock into cache
  365. cmp r0, r1 @ are we done?
  366. add r0, r0, #CACHELINESIZE @ advance to next cache line
  367. bls iLockLoop
  368. mov pc, lr
  369. /*
  370. * xscale_icache_unlock
  371. */
  372. ENTRY(xscale_icache_unlock)
  373. mcr p15, 0, r0, c9, c1, 1 @ Unlock icache
  374. mov pc, lr
  375. /*
  376. * xscale_dcache_lock
  377. *
  378. * r0: starting address to lock
  379. * r1: end address to lock
  380. */
  381. ENTRY(xscale_dcache_lock)
  382. mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
  383. mov r2, #1
  384. mcr p15, 0, r2, c9, c2, 0 @ Put dcache in lock mode
  385. cpwait ip @ Wait for completion
  386. mrs r2, cpsr
  387. orr r3, r2, #PSR_F_BIT | PSR_I_BIT
  388. dLockLoop:
  389. msr cpsr_c, r3
  390. mcr p15, 0, r0, c7, c10, 1 @ Write back line if it is dirty
  391. mcr p15, 0, r0, c7, c6, 1 @ Flush/invalidate line
  392. msr cpsr_c, r2
  393. ldr ip, [r0], #CACHELINESIZE @ Preload 32 bytes into cache from
  394. @ location [r0]. Post-increment
  395. @ r3 to next cache line
  396. cmp r0, r1 @ Are we done?
  397. bls dLockLoop
  398. mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
  399. mov r2, #0
  400. mcr p15, 0, r2, c9, c2, 0 @ Get out of lock mode
  401. cpwait_ret lr, ip
  402. /*
  403. * xscale_dcache_unlock
  404. */
  405. ENTRY(xscale_dcache_unlock)
  406. mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
  407. mcr p15, 0, ip, c9, c2, 1 @ Unlock cache
  408. mov pc, lr
  409. /*
  410. * Needed to determine the length of the code that needs to be copied.
  411. */
  412. .align 5
  413. ENTRY(xscale_cache_dummy)
  414. mov pc, lr
  415. /* ================================ TLB LOCKING==============================
  416. *
  417. * The XScale MicroArchitecture implements support for locking entries into
  418. * the Instruction and Data TLBs. The following functions provide the
  419. * low level support for supporting these under Linux. xscale-lock.c
  420. * implements some higher level management code. Most of the following
  421. * is taken straight out of the Developer's Manual.
  422. */
  423. /*
  424. * Lock I-TLB entry
  425. *
  426. * r0: Virtual address to translate and lock
  427. */
  428. .align 5
  429. ENTRY(xscale_itlb_lock)
  430. mrs r2, cpsr
  431. orr r3, r2, #PSR_F_BIT | PSR_I_BIT
  432. msr cpsr_c, r3 @ Disable interrupts
  433. mcr p15, 0, r0, c8, c5, 1 @ Invalidate I-TLB entry
  434. mcr p15, 0, r0, c10, c4, 0 @ Translate and lock
  435. msr cpsr_c, r2 @ Restore interrupts
  436. cpwait_ret lr, ip
  437. /*
  438. * Lock D-TLB entry
  439. *
  440. * r0: Virtual address to translate and lock
  441. */
  442. .align 5
  443. ENTRY(xscale_dtlb_lock)
  444. mrs r2, cpsr
  445. orr r3, r2, #PSR_F_BIT | PSR_I_BIT
  446. msr cpsr_c, r3 @ Disable interrupts
  447. mcr p15, 0, r0, c8, c6, 1 @ Invalidate D-TLB entry
  448. mcr p15, 0, r0, c10, c8, 0 @ Translate and lock
  449. msr cpsr_c, r2 @ Restore interrupts
  450. cpwait_ret lr, ip
  451. /*
  452. * Unlock all I-TLB entries
  453. */
  454. .align 5
  455. ENTRY(xscale_itlb_unlock)
  456. mcr p15, 0, ip, c10, c4, 1 @ Unlock I-TLB
  457. mcr p15, 0, ip, c8, c5, 0 @ Invalidate I-TLB
  458. cpwait_ret lr, ip
  459. /*
  460. * Unlock all D-TLB entries
  461. */
  462. ENTRY(xscale_dtlb_unlock)
  463. mcr p15, 0, ip, c10, c8, 1 @ Unlock D-TBL
  464. mcr p15, 0, ip, c8, c6, 0 @ Invalidate D-TLB
  465. cpwait_ret lr, ip
  466. /* =============================== PageTable ============================== */
  467. #define PTE_CACHE_WRITE_ALLOCATE 0
  468. /*
  469. * cpu_xscale_switch_mm(pgd)
  470. *
  471. * Set the translation base pointer to be as described by pgd.
  472. *
  473. * pgd: new page tables
  474. */
  475. .align 5
  476. ENTRY(cpu_xscale_switch_mm)
  477. clean_d_cache r1, r2
  478. mcr p15, 0, ip, c7, c5, 0 @ Invalidate I cache & BTB
  479. mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
  480. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  481. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  482. cpwait_ret lr, ip
  483. /*
  484. * cpu_xscale_set_pte(ptep, pte)
  485. *
  486. * Set a PTE and flush it out
  487. *
  488. * Errata 40: must set memory to write-through for user read-only pages.
  489. */
  490. .align 5
  491. ENTRY(cpu_xscale_set_pte)
  492. str r1, [r0], #-2048 @ linux version
  493. bic r2, r1, #0xff0
  494. orr r2, r2, #PTE_TYPE_EXT @ extended page
  495. eor r3, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
  496. tst r3, #L_PTE_USER @ User?
  497. orrne r2, r2, #PTE_EXT_AP_URO_SRW @ yes -> user r/o, system r/w
  498. tst r3, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
  499. orreq r2, r2, #PTE_EXT_AP_UNO_SRW @ yes -> user n/a, system r/w
  500. @ combined with user -> user r/w
  501. @
  502. @ Handle the X bit. We want to set this bit for the minicache
  503. @ (U = E = B = W = 0, C = 1) or when write allocate is enabled,
  504. @ and we have a writeable, cacheable region. If we ignore the
  505. @ U and E bits, we can allow user space to use the minicache as
  506. @ well.
  507. @
  508. @ X = (C & ~W & ~B) | (C & W & B & write_allocate)
  509. @
  510. eor ip, r1, #L_PTE_CACHEABLE
  511. tst ip, #L_PTE_CACHEABLE | L_PTE_WRITE | L_PTE_BUFFERABLE
  512. #if PTE_CACHE_WRITE_ALLOCATE
  513. eorne ip, r1, #L_PTE_CACHEABLE | L_PTE_WRITE | L_PTE_BUFFERABLE
  514. tstne ip, #L_PTE_CACHEABLE | L_PTE_WRITE | L_PTE_BUFFERABLE
  515. #endif
  516. orreq r2, r2, #PTE_EXT_TEX(1)
  517. @
  518. @ Erratum 40: The B bit must be cleared for a user read-only
  519. @ cacheable page.
  520. @
  521. @ B = B & ~(U & C & ~W)
  522. @
  523. and ip, r1, #L_PTE_USER | L_PTE_WRITE | L_PTE_CACHEABLE
  524. teq ip, #L_PTE_USER | L_PTE_CACHEABLE
  525. biceq r2, r2, #PTE_BUFFERABLE
  526. tst r3, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
  527. movne r2, #0 @ no -> fault
  528. str r2, [r0] @ hardware version
  529. mov ip, #0
  530. mcr p15, 0, r0, c7, c10, 1 @ Clean D cache line
  531. mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
  532. mov pc, lr
  533. .ltorg
  534. .align
  535. __INIT
  536. .type __xscale_setup, #function
  537. __xscale_setup:
  538. mcr p15, 0, ip, c7, c7, 0 @ invalidate I, D caches & BTB
  539. mcr p15, 0, ip, c7, c10, 4 @ Drain Write (& Fill) Buffer
  540. mcr p15, 0, ip, c8, c7, 0 @ invalidate I, D TLBs
  541. #ifdef CONFIG_IWMMXT
  542. mov r0, #0 @ initially disallow access to CP0/CP1
  543. #else
  544. mov r0, #1 @ Allow access to CP0
  545. #endif
  546. orr r0, r0, #1 << 6 @ cp6 for IOP3xx and Bulverde
  547. orr r0, r0, #1 << 13 @ Its undefined whether this
  548. mcr p15, 0, r0, c15, c1, 0 @ affects USR or SVC modes
  549. mrc p15, 0, r0, c1, c0, 0 @ get control register
  550. ldr r5, xscale_cr1_clear
  551. bic r0, r0, r5
  552. ldr r5, xscale_cr1_set
  553. orr r0, r0, r5
  554. mov pc, lr
  555. .size __xscale_setup, . - __xscale_setup
  556. /*
  557. * R
  558. * .RVI ZFRS BLDP WCAM
  559. * ..11 1.01 .... .101
  560. *
  561. */
  562. .type xscale_cr1_clear, #object
  563. .type xscale_cr1_set, #object
  564. xscale_cr1_clear:
  565. .word 0x3b07
  566. xscale_cr1_set:
  567. .word 0x3905
  568. __INITDATA
  569. /*
  570. * Purpose : Function pointers used to access above functions - all calls
  571. * come through these
  572. */
  573. .type xscale_processor_functions, #object
  574. ENTRY(xscale_processor_functions)
  575. .word v5t_early_abort
  576. .word cpu_xscale_proc_init
  577. .word cpu_xscale_proc_fin
  578. .word cpu_xscale_reset
  579. .word cpu_xscale_do_idle
  580. .word cpu_xscale_dcache_clean_area
  581. .word cpu_xscale_switch_mm
  582. .word cpu_xscale_set_pte
  583. .size xscale_processor_functions, . - xscale_processor_functions
  584. .section ".rodata"
  585. .type cpu_arch_name, #object
  586. cpu_arch_name:
  587. .asciz "armv5te"
  588. .size cpu_arch_name, . - cpu_arch_name
  589. .type cpu_elf_name, #object
  590. cpu_elf_name:
  591. .asciz "v5"
  592. .size cpu_elf_name, . - cpu_elf_name
  593. .type cpu_80200_name, #object
  594. cpu_80200_name:
  595. .asciz "XScale-80200"
  596. .size cpu_80200_name, . - cpu_80200_name
  597. .type cpu_8032x_name, #object
  598. cpu_8032x_name:
  599. .asciz "XScale-IOP8032x Family"
  600. .size cpu_8032x_name, . - cpu_8032x_name
  601. .type cpu_8033x_name, #object
  602. cpu_8033x_name:
  603. .asciz "XScale-IOP8033x Family"
  604. .size cpu_8033x_name, . - cpu_8033x_name
  605. .type cpu_pxa250_name, #object
  606. cpu_pxa250_name:
  607. .asciz "XScale-PXA250"
  608. .size cpu_pxa250_name, . - cpu_pxa250_name
  609. .type cpu_pxa210_name, #object
  610. cpu_pxa210_name:
  611. .asciz "XScale-PXA210"
  612. .size cpu_pxa210_name, . - cpu_pxa210_name
  613. .type cpu_ixp42x_name, #object
  614. cpu_ixp42x_name:
  615. .asciz "XScale-IXP42x Family"
  616. .size cpu_ixp42x_name, . - cpu_ixp42x_name
  617. .type cpu_ixp46x_name, #object
  618. cpu_ixp46x_name:
  619. .asciz "XScale-IXP46x Family"
  620. .size cpu_ixp46x_name, . - cpu_ixp46x_name
  621. .type cpu_ixp2400_name, #object
  622. cpu_ixp2400_name:
  623. .asciz "XScale-IXP2400"
  624. .size cpu_ixp2400_name, . - cpu_ixp2400_name
  625. .type cpu_ixp2800_name, #object
  626. cpu_ixp2800_name:
  627. .asciz "XScale-IXP2800"
  628. .size cpu_ixp2800_name, . - cpu_ixp2800_name
  629. .type cpu_pxa255_name, #object
  630. cpu_pxa255_name:
  631. .asciz "XScale-PXA255"
  632. .size cpu_pxa255_name, . - cpu_pxa255_name
  633. .type cpu_pxa270_name, #object
  634. cpu_pxa270_name:
  635. .asciz "XScale-PXA270"
  636. .size cpu_pxa270_name, . - cpu_pxa270_name
  637. .align
  638. .section ".proc.info", #alloc, #execinstr
  639. .type __80200_proc_info,#object
  640. __80200_proc_info:
  641. .long 0x69052000
  642. .long 0xfffffff0
  643. .long PMD_TYPE_SECT | \
  644. PMD_SECT_BUFFERABLE | \
  645. PMD_SECT_CACHEABLE | \
  646. PMD_SECT_AP_WRITE | \
  647. PMD_SECT_AP_READ
  648. b __xscale_setup
  649. .long cpu_arch_name
  650. .long cpu_elf_name
  651. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  652. .long cpu_80200_name
  653. .long xscale_processor_functions
  654. .long v4wbi_tlb_fns
  655. .long xscale_mc_user_fns
  656. .long xscale_cache_fns
  657. .size __80200_proc_info, . - __80200_proc_info
  658. .type __8032x_proc_info,#object
  659. __8032x_proc_info:
  660. .long 0x69052420
  661. .long 0xfffff5e0 @ mask should accomodate IOP80219 also
  662. .long PMD_TYPE_SECT | \
  663. PMD_SECT_BUFFERABLE | \
  664. PMD_SECT_CACHEABLE | \
  665. PMD_SECT_AP_WRITE | \
  666. PMD_SECT_AP_READ
  667. b __xscale_setup
  668. .long cpu_arch_name
  669. .long cpu_elf_name
  670. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  671. .long cpu_8032x_name
  672. .long xscale_processor_functions
  673. .long v4wbi_tlb_fns
  674. .long xscale_mc_user_fns
  675. .long xscale_cache_fns
  676. .size __8032x_proc_info, . - __8032x_proc_info
  677. .type __8033x_proc_info,#object
  678. __8033x_proc_info:
  679. .long 0x69054010
  680. .long 0xffffff30
  681. .long PMD_TYPE_SECT | \
  682. PMD_SECT_BUFFERABLE | \
  683. PMD_SECT_CACHEABLE | \
  684. PMD_SECT_AP_WRITE | \
  685. PMD_SECT_AP_READ
  686. b __xscale_setup
  687. .long cpu_arch_name
  688. .long cpu_elf_name
  689. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  690. .long cpu_8033x_name
  691. .long xscale_processor_functions
  692. .long v4wbi_tlb_fns
  693. .long xscale_mc_user_fns
  694. .long xscale_cache_fns
  695. .size __8033x_proc_info, . - __8033x_proc_info
  696. .type __pxa250_proc_info,#object
  697. __pxa250_proc_info:
  698. .long 0x69052100
  699. .long 0xfffff7f0
  700. .long PMD_TYPE_SECT | \
  701. PMD_SECT_BUFFERABLE | \
  702. PMD_SECT_CACHEABLE | \
  703. PMD_SECT_AP_WRITE | \
  704. PMD_SECT_AP_READ
  705. b __xscale_setup
  706. .long cpu_arch_name
  707. .long cpu_elf_name
  708. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  709. .long cpu_pxa250_name
  710. .long xscale_processor_functions
  711. .long v4wbi_tlb_fns
  712. .long xscale_mc_user_fns
  713. .long xscale_cache_fns
  714. .size __pxa250_proc_info, . - __pxa250_proc_info
  715. .type __pxa210_proc_info,#object
  716. __pxa210_proc_info:
  717. .long 0x69052120
  718. .long 0xfffff3f0
  719. .long PMD_TYPE_SECT | \
  720. PMD_SECT_BUFFERABLE | \
  721. PMD_SECT_CACHEABLE | \
  722. PMD_SECT_AP_WRITE | \
  723. PMD_SECT_AP_READ
  724. b __xscale_setup
  725. .long cpu_arch_name
  726. .long cpu_elf_name
  727. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  728. .long cpu_pxa210_name
  729. .long xscale_processor_functions
  730. .long v4wbi_tlb_fns
  731. .long xscale_mc_user_fns
  732. .long xscale_cache_fns
  733. .size __pxa210_proc_info, . - __pxa210_proc_info
  734. .type __ixp2400_proc_info, #object
  735. __ixp2400_proc_info:
  736. .long 0x69054190
  737. .long 0xfffffff0
  738. .long PMD_TYPE_SECT | \
  739. PMD_SECT_BUFFERABLE | \
  740. PMD_SECT_CACHEABLE | \
  741. PMD_SECT_AP_WRITE | \
  742. PMD_SECT_AP_READ
  743. b __xscale_setup
  744. .long cpu_arch_name
  745. .long cpu_elf_name
  746. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  747. .long cpu_ixp2400_name
  748. .long xscale_processor_functions
  749. .long v4wbi_tlb_fns
  750. .long xscale_mc_user_fns
  751. .long xscale_cache_fns
  752. .size __ixp2400_proc_info, . - __ixp2400_proc_info
  753. .type __ixp2800_proc_info, #object
  754. __ixp2800_proc_info:
  755. .long 0x690541a0
  756. .long 0xfffffff0
  757. .long PMD_TYPE_SECT | \
  758. PMD_SECT_BUFFERABLE | \
  759. PMD_SECT_CACHEABLE | \
  760. PMD_SECT_AP_WRITE | \
  761. PMD_SECT_AP_READ
  762. b __xscale_setup
  763. .long cpu_arch_name
  764. .long cpu_elf_name
  765. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  766. .long cpu_ixp2800_name
  767. .long xscale_processor_functions
  768. .long v4wbi_tlb_fns
  769. .long xscale_mc_user_fns
  770. .long xscale_cache_fns
  771. .size __ixp2800_proc_info, . - __ixp2800_proc_info
  772. .type __ixp42x_proc_info, #object
  773. __ixp42x_proc_info:
  774. .long 0x690541c0
  775. .long 0xffffffc0
  776. .long PMD_TYPE_SECT | \
  777. PMD_SECT_BUFFERABLE | \
  778. PMD_SECT_CACHEABLE | \
  779. PMD_SECT_AP_WRITE | \
  780. PMD_SECT_AP_READ
  781. b __xscale_setup
  782. .long cpu_arch_name
  783. .long cpu_elf_name
  784. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  785. .long cpu_ixp42x_name
  786. .long xscale_processor_functions
  787. .long v4wbi_tlb_fns
  788. .long xscale_mc_user_fns
  789. .long xscale_cache_fns
  790. .size __ixp42x_proc_info, . - __ixp42x_proc_info
  791. .type __ixp46x_proc_info, #object
  792. __ixp46x_proc_info:
  793. .long 0x69054200
  794. .long 0xffffff00
  795. .long 0x00000c0e
  796. b __xscale_setup
  797. .long cpu_arch_name
  798. .long cpu_elf_name
  799. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  800. .long cpu_ixp46x_name
  801. .long xscale_processor_functions
  802. .long v4wbi_tlb_fns
  803. .long xscale_mc_user_fns
  804. .long xscale_cache_fns
  805. .size __ixp46x_proc_info, . - __ixp46x_proc_info
  806. .type __pxa255_proc_info,#object
  807. __pxa255_proc_info:
  808. .long 0x69052d00
  809. .long 0xfffffff0
  810. .long PMD_TYPE_SECT | \
  811. PMD_SECT_BUFFERABLE | \
  812. PMD_SECT_CACHEABLE | \
  813. PMD_SECT_AP_WRITE | \
  814. PMD_SECT_AP_READ
  815. b __xscale_setup
  816. .long cpu_arch_name
  817. .long cpu_elf_name
  818. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  819. .long cpu_pxa255_name
  820. .long xscale_processor_functions
  821. .long v4wbi_tlb_fns
  822. .long xscale_mc_user_fns
  823. .long xscale_cache_fns
  824. .size __pxa255_proc_info, . - __pxa255_proc_info
  825. .type __pxa270_proc_info,#object
  826. __pxa270_proc_info:
  827. .long 0x69054110
  828. .long 0xfffffff0
  829. .long PMD_TYPE_SECT | \
  830. PMD_SECT_BUFFERABLE | \
  831. PMD_SECT_CACHEABLE | \
  832. PMD_SECT_AP_WRITE | \
  833. PMD_SECT_AP_READ
  834. b __xscale_setup
  835. .long cpu_arch_name
  836. .long cpu_elf_name
  837. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  838. .long cpu_pxa270_name
  839. .long xscale_processor_functions
  840. .long v4wbi_tlb_fns
  841. .long xscale_mc_user_fns
  842. .long xscale_cache_fns
  843. .size __pxa270_proc_info, . - __pxa270_proc_info