mt_lp_irqremain.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (c) 2020-2022, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <mt_cirq.h>
  7. #include <mt_lp_irqremain.h>
  8. #include <mt_lp_rm.h>
  9. #include <plat_mtk_lpm.h>
  10. #define EDMA0_IRQ_ID U(448)
  11. #define MDLA_IRQ_ID U(446)
  12. #define MALI4_IRQ_ID U(399)
  13. #define MALI3_IRQ_ID U(398)
  14. #define MALI2_IRQ_ID U(397)
  15. #define MALI1_IRQ_ID U(396)
  16. #define MALI0_IRQ_ID U(395)
  17. #define VPU_CORE1_IRQ_ID U(453)
  18. #define VPU_CORE0_IRQ_ID U(452)
  19. #define MD_WDT_IRQ_ID U(110)
  20. #define KEYPAD_IRQ_ID U(106)
  21. #define MD_WDT_WAKESRC 0x2000000
  22. #define KEYPAD_WAKESRC 0x4
  23. static struct mt_irqremain remain_irqs;
  24. int mt_lp_irqremain_submit(void)
  25. {
  26. if (remain_irqs.count == 0) {
  27. return -1;
  28. }
  29. set_wakeup_sources(remain_irqs.irqs, remain_irqs.count);
  30. mt_lp_rm_do_update(-1, PLAT_RC_UPDATE_REMAIN_IRQS, &remain_irqs);
  31. return 0;
  32. }
  33. int mt_lp_irqremain_aquire(void)
  34. {
  35. if (remain_irqs.count == 0) {
  36. return -1;
  37. }
  38. mt_cirq_sw_reset();
  39. mt_cirq_clone_gic();
  40. mt_cirq_enable();
  41. return 0;
  42. }
  43. int mt_lp_irqremain_release(void)
  44. {
  45. if (remain_irqs.count == 0) {
  46. return -1;
  47. }
  48. mt_cirq_flush();
  49. mt_cirq_disable();
  50. return 0;
  51. }
  52. void mt_lp_irqremain_init(void)
  53. {
  54. uint32_t idx;
  55. remain_irqs.count = 0;
  56. /* level edma0 */
  57. idx = remain_irqs.count;
  58. remain_irqs.irqs[idx] = EDMA0_IRQ_ID;
  59. remain_irqs.wakeupsrc_cat[idx] = 0;
  60. remain_irqs.wakeupsrc[idx] = 0;
  61. remain_irqs.count++;
  62. /* level mdla */
  63. idx = remain_irqs.count;
  64. remain_irqs.irqs[idx] = MDLA_IRQ_ID;
  65. remain_irqs.wakeupsrc_cat[idx] = 0;
  66. remain_irqs.wakeupsrc[idx] = 0;
  67. remain_irqs.count++;
  68. /* level mali4 */
  69. idx = remain_irqs.count;
  70. remain_irqs.irqs[idx] = MALI4_IRQ_ID;
  71. remain_irqs.wakeupsrc_cat[idx] = 0;
  72. remain_irqs.wakeupsrc[idx] = 0;
  73. remain_irqs.count++;
  74. /* level mali3 */
  75. idx = remain_irqs.count;
  76. remain_irqs.irqs[idx] = MALI3_IRQ_ID;
  77. remain_irqs.wakeupsrc_cat[idx] = 0;
  78. remain_irqs.wakeupsrc[idx] = 0;
  79. remain_irqs.count++;
  80. /* level mali2 */
  81. idx = remain_irqs.count;
  82. remain_irqs.irqs[idx] = MALI2_IRQ_ID;
  83. remain_irqs.wakeupsrc_cat[idx] = 0;
  84. remain_irqs.wakeupsrc[idx] = 0;
  85. remain_irqs.count++;
  86. /* level mali1 */
  87. idx = remain_irqs.count;
  88. remain_irqs.irqs[idx] = MALI1_IRQ_ID;
  89. remain_irqs.wakeupsrc_cat[idx] = 0;
  90. remain_irqs.wakeupsrc[idx] = 0;
  91. remain_irqs.count++;
  92. /* level mali0 */
  93. idx = remain_irqs.count;
  94. remain_irqs.irqs[idx] = MALI0_IRQ_ID;
  95. remain_irqs.wakeupsrc_cat[idx] = 0;
  96. remain_irqs.wakeupsrc[idx] = 0;
  97. remain_irqs.count++;
  98. /* level vpu core1 */
  99. idx = remain_irqs.count;
  100. remain_irqs.irqs[idx] = VPU_CORE1_IRQ_ID;
  101. remain_irqs.wakeupsrc_cat[idx] = 0;
  102. remain_irqs.wakeupsrc[idx] = 0;
  103. remain_irqs.count++;
  104. /* level vpu core0 */
  105. idx = remain_irqs.count;
  106. remain_irqs.irqs[idx] = VPU_CORE0_IRQ_ID;
  107. remain_irqs.wakeupsrc_cat[idx] = 0;
  108. remain_irqs.wakeupsrc[idx] = 0;
  109. remain_irqs.count++;
  110. /* edge mdwdt */
  111. idx = remain_irqs.count;
  112. remain_irqs.irqs[idx] = MD_WDT_IRQ_ID;
  113. remain_irqs.wakeupsrc_cat[idx] = 0;
  114. remain_irqs.wakeupsrc[idx] = MD_WDT_WAKESRC;
  115. remain_irqs.count++;
  116. /* edge keypad */
  117. idx = remain_irqs.count;
  118. remain_irqs.irqs[idx] = KEYPAD_IRQ_ID;
  119. remain_irqs.wakeupsrc_cat[idx] = 0;
  120. remain_irqs.wakeupsrc[idx] = KEYPAD_WAKESRC;
  121. remain_irqs.count++;
  122. mt_lp_irqremain_submit();
  123. }