kernel-entry-init.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 Embedded Alley Solutions, Inc
  7. * Copyright (C) 2005 Ralf Baechle ([email protected])
  8. * Copyright (C) 2009 Jiajie Chen ([email protected])
  9. * Copyright (C) 2012 Huacai Chen ([email protected])
  10. */
  11. #ifndef __ASM_MACH_LOONGSON64_KERNEL_ENTRY_H
  12. #define __ASM_MACH_LOONGSON64_KERNEL_ENTRY_H
  13. #include <asm/cpu.h>
  14. /*
  15. * Override macros used in arch/mips/kernel/head.S.
  16. */
  17. .macro kernel_entry_setup
  18. .set push
  19. .set mips64
  20. /* Set ELPA on LOONGSON3 pagegrain */
  21. mfc0 t0, CP0_PAGEGRAIN
  22. or t0, (0x1 << 29)
  23. mtc0 t0, CP0_PAGEGRAIN
  24. /* Enable STFill Buffer */
  25. mfc0 t0, CP0_PRID
  26. /* Loongson-3A R4+ */
  27. andi t1, t0, PRID_IMP_MASK
  28. li t2, PRID_IMP_LOONGSON_64G
  29. beq t1, t2, 1f
  30. nop
  31. /* Loongson-3A R2/R3 */
  32. andi t0, (PRID_IMP_MASK | PRID_REV_MASK)
  33. slti t0, t0, (PRID_IMP_LOONGSON_64C | PRID_REV_LOONGSON3A_R2_0)
  34. bnez t0, 2f
  35. nop
  36. 1:
  37. mfc0 t0, CP0_CONFIG6
  38. or t0, 0x100
  39. mtc0 t0, CP0_CONFIG6
  40. 2:
  41. _ehb
  42. .set pop
  43. .endm
  44. /*
  45. * Do SMP slave processor setup.
  46. */
  47. .macro smp_slave_setup
  48. .set push
  49. .set mips64
  50. /* Set ELPA on LOONGSON3 pagegrain */
  51. mfc0 t0, CP0_PAGEGRAIN
  52. or t0, (0x1 << 29)
  53. mtc0 t0, CP0_PAGEGRAIN
  54. /* Enable STFill Buffer */
  55. mfc0 t0, CP0_PRID
  56. /* Loongson-3A R4+ */
  57. andi t1, t0, PRID_IMP_MASK
  58. li t2, PRID_IMP_LOONGSON_64G
  59. beq t1, t2, 1f
  60. nop
  61. /* Loongson-3A R2/R3 */
  62. andi t0, (PRID_IMP_MASK | PRID_REV_MASK)
  63. slti t0, t0, (PRID_IMP_LOONGSON_64C | PRID_REV_LOONGSON3A_R2_0)
  64. bnez t0, 2f
  65. nop
  66. 1:
  67. mfc0 t0, CP0_CONFIG6
  68. or t0, 0x100
  69. mtc0 t0, CP0_CONFIG6
  70. 2:
  71. _ehb
  72. .set pop
  73. .endm
  74. #define USE_KEXEC_SMP_WAIT_FINAL
  75. .macro kexec_smp_wait_final
  76. /* s0:prid s1:initfn */
  77. /* a0:base t1:cpuid t2:node t9:count */
  78. mfc0 t1, CP0_EBASE
  79. andi t1, MIPS_EBASE_CPUNUM
  80. dins a0, t1, 8, 2 /* insert core id*/
  81. dext t2, t1, 2, 2
  82. dins a0, t2, 44, 2 /* insert node id */
  83. mfc0 s0, CP0_PRID
  84. andi s0, s0, (PRID_IMP_MASK | PRID_REV_MASK)
  85. beq s0, (PRID_IMP_LOONGSON_64C | PRID_REV_LOONGSON3B_R1), 1f
  86. beq s0, (PRID_IMP_LOONGSON_64C | PRID_REV_LOONGSON3B_R2), 1f
  87. b 2f /* Loongson-3A1000/3A2000/3A3000/3A4000 */
  88. 1: dins a0, t2, 14, 2 /* Loongson-3B1000/3B1500 need bit 15~14 */
  89. 2: li t9, 0x100 /* wait for init loop */
  90. 3: addiu t9, -1 /* limit mailbox access */
  91. bnez t9, 3b
  92. lw s1, 0x20(a0) /* check PC as an indicator */
  93. beqz s1, 2b
  94. ld s1, 0x20(a0) /* get PC via mailbox reg0 */
  95. ld sp, 0x28(a0) /* get SP via mailbox reg1 */
  96. ld gp, 0x30(a0) /* get GP via mailbox reg2 */
  97. ld a1, 0x38(a0)
  98. jr s1 /* jump to initial PC */
  99. .endm
  100. #endif /* __ASM_MACH_LOONGSON64_KERNEL_ENTRY_H */