s3-mips.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2016 Broadcom Corporation
  4. */
  5. #include <asm/asm.h>
  6. #include <asm/regdef.h>
  7. #include <asm/mipsregs.h>
  8. #include <asm/bmips.h>
  9. #include "pm.h"
  10. .text
  11. .set noreorder
  12. .align 5
  13. .global s3_reentry
  14. /*
  15. * a0: AON_CTRL base register
  16. * a1: D-Cache line size
  17. */
  18. LEAF(brcm_pm_do_s3)
  19. /* Get the address of s3_context */
  20. la t0, gp_regs
  21. sw ra, 0(t0)
  22. sw s0, 4(t0)
  23. sw s1, 8(t0)
  24. sw s2, 12(t0)
  25. sw s3, 16(t0)
  26. sw s4, 20(t0)
  27. sw s5, 24(t0)
  28. sw s6, 28(t0)
  29. sw s7, 32(t0)
  30. sw gp, 36(t0)
  31. sw sp, 40(t0)
  32. sw fp, 44(t0)
  33. /* Save CP0 Status */
  34. mfc0 t1, CP0_STATUS
  35. sw t1, 48(t0)
  36. /* Write-back gp registers - cache will be gone */
  37. addiu t1, a1, -1
  38. not t1
  39. and t0, t1
  40. /* Flush at least 64 bytes */
  41. addiu t2, t0, 64
  42. and t2, t1
  43. 1: cache 0x17, 0(t0)
  44. bne t0, t2, 1b
  45. addu t0, a1
  46. /* Drop to deep standby */
  47. li t1, PM_WARM_CONFIG
  48. sw zero, AON_CTRL_PM_CTRL(a0)
  49. lw zero, AON_CTRL_PM_CTRL(a0)
  50. sw t1, AON_CTRL_PM_CTRL(a0)
  51. lw t1, AON_CTRL_PM_CTRL(a0)
  52. li t1, (PM_WARM_CONFIG | PM_PWR_DOWN)
  53. sw t1, AON_CTRL_PM_CTRL(a0)
  54. lw t1, AON_CTRL_PM_CTRL(a0)
  55. /* Enable CP0 interrupt 2 and wait for interrupt */
  56. mfc0 t0, CP0_STATUS
  57. li t1, ~(ST0_IM | ST0_IE)
  58. and t0, t1
  59. ori t0, STATUSF_IP2
  60. mtc0 t0, CP0_STATUS
  61. nop
  62. nop
  63. nop
  64. ori t0, ST0_IE
  65. mtc0 t0, CP0_STATUS
  66. /* Wait for interrupt */
  67. wait
  68. nop
  69. s3_reentry:
  70. /* Clear call/return stack */
  71. li t0, (0x06 << 16)
  72. mtc0 t0, $22, 2
  73. ssnop
  74. ssnop
  75. ssnop
  76. /* Clear jump target buffer */
  77. li t0, (0x04 << 16)
  78. mtc0 t0, $22, 2
  79. ssnop
  80. ssnop
  81. ssnop
  82. sync
  83. nop
  84. /* Setup mmu defaults */
  85. mtc0 zero, CP0_WIRED
  86. mtc0 zero, CP0_ENTRYHI
  87. li k0, PM_DEFAULT_MASK
  88. mtc0 k0, CP0_PAGEMASK
  89. li sp, BMIPS_WARM_RESTART_VEC
  90. la k0, plat_wired_tlb_setup
  91. jalr k0
  92. nop
  93. /* Restore general purpose registers */
  94. la t0, gp_regs
  95. lw fp, 44(t0)
  96. lw sp, 40(t0)
  97. lw gp, 36(t0)
  98. lw s7, 32(t0)
  99. lw s6, 28(t0)
  100. lw s5, 24(t0)
  101. lw s4, 20(t0)
  102. lw s3, 16(t0)
  103. lw s2, 12(t0)
  104. lw s1, 8(t0)
  105. lw s0, 4(t0)
  106. lw ra, 0(t0)
  107. /* Restore CP0 status */
  108. lw t1, 48(t0)
  109. mtc0 t1, CP0_STATUS
  110. /* Return to caller */
  111. li v0, 0
  112. jr ra
  113. nop
  114. END(brcm_pm_do_s3)