head-v7.S 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2011 Freescale Semiconductor, Inc.
  3. * Copyright 2011 Linaro Ltd.
  4. *
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/linkage.h>
  13. #include <linux/init.h>
  14. #include <asm/hardware/cache-l2x0.h>
  15. .section ".text.head", "ax"
  16. __CPUINIT
  17. /*
  18. * The secondary kernel init calls v7_flush_dcache_all before it enables
  19. * the L1; however, the L1 comes out of reset in an undefined state, so
  20. * the clean + invalidate performed by v7_flush_dcache_all causes a bunch
  21. * of cache lines with uninitialized data and uninitialized tags to get
  22. * written out to memory, which does really unpleasant things to the main
  23. * processor. We fix this by performing an invalidate, rather than a
  24. * clean + invalidate, before jumping into the kernel.
  25. *
  26. * This funciton is cloned from arch/arm/mach-tegra/headsmp.S, and needs
  27. * to be called for both secondary cores startup and primary core resume
  28. * procedures. Ideally, it should be moved into arch/arm/mm/cache-v7.S.
  29. */
  30. ENTRY(v7_invalidate_l1)
  31. mov r0, #0
  32. mcr p15, 2, r0, c0, c0, 0
  33. mrc p15, 1, r0, c0, c0, 0
  34. ldr r1, =0x7fff
  35. and r2, r1, r0, lsr #13
  36. ldr r1, =0x3ff
  37. and r3, r1, r0, lsr #3 @ NumWays - 1
  38. add r2, r2, #1 @ NumSets
  39. and r0, r0, #0x7
  40. add r0, r0, #4 @ SetShift
  41. clz r1, r3 @ WayShift
  42. add r4, r3, #1 @ NumWays
  43. 1: sub r2, r2, #1 @ NumSets--
  44. mov r3, r4 @ Temp = NumWays
  45. 2: subs r3, r3, #1 @ Temp--
  46. mov r5, r3, lsl r1
  47. mov r6, r2, lsl r0
  48. orr r5, r5, r6 @ Reg = (Temp<<WayShift)|(NumSets<<SetShift)
  49. mcr p15, 0, r5, c7, c6, 2
  50. bgt 2b
  51. cmp r2, #0
  52. bgt 1b
  53. dsb
  54. isb
  55. mov pc, lr
  56. ENDPROC(v7_invalidate_l1)
  57. #ifdef CONFIG_SMP
  58. ENTRY(v7_secondary_startup)
  59. bl v7_invalidate_l1
  60. b secondary_startup
  61. ENDPROC(v7_secondary_startup)
  62. #endif