kernel-entry-init.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2005-2008 Cavium Networks, Inc
  7. */
  8. #ifndef __ASM_MACH_CAVIUM_OCTEON_KERNEL_ENTRY_H
  9. #define __ASM_MACH_CAVIUM_OCTEON_KERNEL_ENTRY_H
  10. #define CP0_CVMCTL_REG $9, 7
  11. #define CP0_CVMMEMCTL_REG $11,7
  12. #define CP0_PRID_REG $15, 0
  13. #define CP0_DCACHE_ERR_REG $27, 1
  14. #define CP0_PRID_OCTEON_PASS1 0x000d0000
  15. #define CP0_PRID_OCTEON_CN30XX 0x000d0200
  16. .macro kernel_entry_setup
  17. # Registers set by bootloader:
  18. # (only 32 bits set by bootloader, all addresses are physical
  19. # addresses, and need to have the appropriate memory region set
  20. # by the kernel
  21. # a0 = argc
  22. # a1 = argv (kseg0 compat addr)
  23. # a2 = 1 if init core, zero otherwise
  24. # a3 = address of boot descriptor block
  25. .set push
  26. .set arch=octeon
  27. # Read the cavium mem control register
  28. dmfc0 v0, CP0_CVMMEMCTL_REG
  29. # Clear the lower 6 bits, the CVMSEG size
  30. dins v0, $0, 0, 6
  31. ori v0, CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
  32. dmtc0 v0, CP0_CVMMEMCTL_REG # Write the cavium mem control register
  33. dmfc0 v0, CP0_CVMCTL_REG # Read the cavium control register
  34. # Disable unaligned load/store support but leave HW fixup enabled
  35. # Needed for octeon specific memcpy
  36. or v0, v0, 0x5001
  37. xor v0, v0, 0x1001
  38. # First clear off CvmCtl[IPPCI] bit and move the performance
  39. # counters interrupt to IRQ 6
  40. dli v1, ~(7 << 7)
  41. and v0, v0, v1
  42. ori v0, v0, (6 << 7)
  43. mfc0 v1, CP0_PRID_REG
  44. and t1, v1, 0xfff8
  45. xor t1, t1, 0x9000 # 63-P1
  46. beqz t1, 4f
  47. and t1, v1, 0xfff8
  48. xor t1, t1, 0x9008 # 63-P2
  49. beqz t1, 4f
  50. and t1, v1, 0xfff8
  51. xor t1, t1, 0x9100 # 68-P1
  52. beqz t1, 4f
  53. and t1, v1, 0xff00
  54. xor t1, t1, 0x9200 # 66-PX
  55. bnez t1, 5f # Skip WAR for others.
  56. and t1, v1, 0x00ff
  57. slti t1, t1, 2 # 66-P1.2 and later good.
  58. beqz t1, 5f
  59. 4: # core-16057 work around
  60. or v0, v0, 0x2000 # Set IPREF bit.
  61. 5: # No core-16057 work around
  62. # Write the cavium control register
  63. dmtc0 v0, CP0_CVMCTL_REG
  64. sync
  65. # Flush dcache after config change
  66. cache 9, 0($0)
  67. # Zero all of CVMSEG to make sure parity is correct
  68. dli v0, CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE
  69. dsll v0, 7
  70. beqz v0, 2f
  71. 1: dsubu v0, 8
  72. sd $0, -32768(v0)
  73. bnez v0, 1b
  74. 2:
  75. mfc0 v0, CP0_PRID_REG
  76. bbit0 v0, 15, 1f
  77. # OCTEON II or better have bit 15 set. Clear the error bits.
  78. and t1, v0, 0xff00
  79. dli v0, 0x9500
  80. bge t1, v0, 1f # OCTEON III has no DCACHE_ERR_REG COP0
  81. dli v0, 0x27
  82. dmtc0 v0, CP0_DCACHE_ERR_REG
  83. 1:
  84. # Get my core id
  85. rdhwr v0, $0
  86. # Jump the master to kernel_entry
  87. bne a2, zero, octeon_main_processor
  88. nop
  89. #ifdef CONFIG_SMP
  90. #
  91. # All cores other than the master need to wait here for SMP bootstrap
  92. # to begin
  93. #
  94. octeon_spin_wait_boot:
  95. #ifdef CONFIG_RELOCATABLE
  96. PTR_LA t0, octeon_processor_relocated_kernel_entry
  97. LONG_L t0, (t0)
  98. beq zero, t0, 1f
  99. nop
  100. jr t0
  101. nop
  102. 1:
  103. #endif /* CONFIG_RELOCATABLE */
  104. # This is the variable where the next core to boot is stored
  105. PTR_LA t0, octeon_processor_boot
  106. # Get the core id of the next to be booted
  107. LONG_L t1, (t0)
  108. # Keep looping if it isn't me
  109. bne t1, v0, octeon_spin_wait_boot
  110. nop
  111. # Get my GP from the global variable
  112. PTR_LA t0, octeon_processor_gp
  113. LONG_L gp, (t0)
  114. # Get my SP from the global variable
  115. PTR_LA t0, octeon_processor_sp
  116. LONG_L sp, (t0)
  117. # Set the SP global variable to zero so the master knows we've started
  118. LONG_S zero, (t0)
  119. #ifdef __OCTEON__
  120. syncw
  121. syncw
  122. #else
  123. sync
  124. #endif
  125. # Jump to the normal Linux SMP entry point
  126. j smp_bootstrap
  127. nop
  128. #else /* CONFIG_SMP */
  129. #
  130. # Someone tried to boot SMP with a non SMP kernel. All extra cores
  131. # will halt here.
  132. #
  133. octeon_wait_forever:
  134. wait
  135. b octeon_wait_forever
  136. nop
  137. #endif /* CONFIG_SMP */
  138. octeon_main_processor:
  139. .set pop
  140. .endm
  141. /*
  142. * Do SMP slave processor setup necessary before we can safely execute C code.
  143. */
  144. .macro smp_slave_setup
  145. .endm
  146. #define USE_KEXEC_SMP_WAIT_FINAL
  147. .macro kexec_smp_wait_final
  148. .set push
  149. .set noreorder
  150. synci 0($0)
  151. .set pop
  152. .endm
  153. #endif /* __ASM_MACH_CAVIUM_OCTEON_KERNEL_ENTRY_H */