headsmp.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * SMP support for R-Mobile / SH-Mobile
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. * Copyright (C) 2010 Takashi Yoshii
  6. *
  7. * Based on vexpress, Copyright (c) 2003 ARM Limited, All Rights Reserved
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/linkage.h>
  15. #include <linux/threads.h>
  16. #include <asm/assembler.h>
  17. #include <asm/memory.h>
  18. #define SCTLR_MMU 0x01
  19. #define BOOTROM_ADDRESS 0xE6340000
  20. #define RWTCSRA_ADDRESS 0xE6020004
  21. #define RWTCSRA_WOVF 0x10
  22. /*
  23. * Reset vector for secondary CPUs.
  24. * This will be mapped at address 0 by SBAR register.
  25. * We need _long_ jump to the physical address.
  26. */
  27. .arm
  28. .align 12
  29. ENTRY(shmobile_boot_vector)
  30. ldr r1, 1f
  31. bx r1
  32. ENDPROC(shmobile_boot_vector)
  33. .align 2
  34. .globl shmobile_boot_fn
  35. shmobile_boot_fn:
  36. 1: .space 4
  37. .globl shmobile_boot_size
  38. shmobile_boot_size:
  39. .long . - shmobile_boot_vector
  40. #ifdef CONFIG_ARCH_RCAR_GEN2
  41. /*
  42. * Reset vector for R-Car Gen2 and RZ/G1 secondary CPUs.
  43. * This will be mapped at address 0 by SBAR register.
  44. */
  45. ENTRY(shmobile_boot_vector_gen2)
  46. mrc p15, 0, r0, c0, c0, 5 @ r0 = MPIDR
  47. ldr r1, shmobile_boot_cpu_gen2
  48. cmp r0, r1
  49. bne shmobile_smp_continue_gen2
  50. mrc p15, 0, r1, c1, c0, 0 @ r1 = SCTLR
  51. and r0, r1, #SCTLR_MMU
  52. cmp r0, #SCTLR_MMU
  53. beq shmobile_smp_continue_gen2
  54. ldr r0, rwtcsra
  55. mov r1, #0
  56. ldrb r1, [r0]
  57. and r0, r1, #RWTCSRA_WOVF
  58. cmp r0, #RWTCSRA_WOVF
  59. bne shmobile_smp_continue_gen2
  60. ldr r0, bootrom
  61. bx r0
  62. shmobile_smp_continue_gen2:
  63. ldr r1, shmobile_boot_fn_gen2
  64. bx r1
  65. ENDPROC(shmobile_boot_vector_gen2)
  66. .align 4
  67. rwtcsra:
  68. .word RWTCSRA_ADDRESS
  69. bootrom:
  70. .word BOOTROM_ADDRESS
  71. .globl shmobile_boot_cpu_gen2
  72. shmobile_boot_cpu_gen2:
  73. .word 0x00000000
  74. .align 2
  75. .globl shmobile_boot_fn_gen2
  76. shmobile_boot_fn_gen2:
  77. .space 4
  78. .globl shmobile_boot_size_gen2
  79. shmobile_boot_size_gen2:
  80. .long . - shmobile_boot_vector_gen2
  81. #endif /* CONFIG_ARCH_RCAR_GEN2 */
  82. /*
  83. * Per-CPU SMP boot function/argument selection code based on MPIDR
  84. */
  85. ENTRY(shmobile_smp_boot)
  86. mrc p15, 0, r1, c0, c0, 5 @ r1 = MPIDR
  87. and r0, r1, #0xffffff @ MPIDR_HWID_BITMASK
  88. @ r0 = cpu_logical_map() value
  89. mov r1, #0 @ r1 = CPU index
  90. adr r2, 1f
  91. ldmia r2, {r5, r6, r7}
  92. add r5, r5, r2 @ array of per-cpu mpidr values
  93. add r6, r6, r2 @ array of per-cpu functions
  94. add r7, r7, r2 @ array of per-cpu arguments
  95. shmobile_smp_boot_find_mpidr:
  96. ldr r8, [r5, r1, lsl #2]
  97. cmp r8, r0
  98. bne shmobile_smp_boot_next
  99. ldr r9, [r6, r1, lsl #2]
  100. cmp r9, #0
  101. bne shmobile_smp_boot_found
  102. shmobile_smp_boot_next:
  103. add r1, r1, #1
  104. cmp r1, #NR_CPUS
  105. blo shmobile_smp_boot_find_mpidr
  106. b shmobile_smp_sleep
  107. shmobile_smp_boot_found:
  108. ldr r0, [r7, r1, lsl #2]
  109. ret r9
  110. ENDPROC(shmobile_smp_boot)
  111. ENTRY(shmobile_smp_sleep)
  112. wfi
  113. b shmobile_smp_boot
  114. ENDPROC(shmobile_smp_sleep)
  115. .align 2
  116. 1: .long shmobile_smp_mpidr - .
  117. .long shmobile_smp_fn - 1b
  118. .long shmobile_smp_arg - 1b
  119. .bss
  120. .globl shmobile_smp_mpidr
  121. shmobile_smp_mpidr:
  122. .space NR_CPUS * 4
  123. .globl shmobile_smp_fn
  124. shmobile_smp_fn:
  125. .space NR_CPUS * 4
  126. .globl shmobile_smp_arg
  127. shmobile_smp_arg:
  128. .space NR_CPUS * 4