mt_lp_irqremain.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2021-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 KEYPAD_IRQ_ID U(138)
  11. #define KEYPAD_WAKESRC 0x4
  12. static struct mt_irqremain remain_irqs;
  13. int mt_lp_irqremain_submit(void)
  14. {
  15. if (remain_irqs.count == 0) {
  16. return -1;
  17. }
  18. set_wakeup_sources(remain_irqs.irqs, remain_irqs.count);
  19. mt_lp_rm_do_update(-1, PLAT_RC_UPDATE_REMAIN_IRQS, &remain_irqs);
  20. return 0;
  21. }
  22. int mt_lp_irqremain_aquire(void)
  23. {
  24. if (remain_irqs.count == 0) {
  25. return -1;
  26. }
  27. mt_cirq_sw_reset();
  28. mt_cirq_clone_gic();
  29. mt_cirq_enable();
  30. return 0;
  31. }
  32. int mt_lp_irqremain_release(void)
  33. {
  34. if (remain_irqs.count == 0) {
  35. return -1;
  36. }
  37. mt_cirq_flush();
  38. mt_cirq_disable();
  39. return 0;
  40. }
  41. void mt_lp_irqremain_init(void)
  42. {
  43. uint32_t idx;
  44. remain_irqs.count = 0;
  45. /*edge keypad*/
  46. idx = remain_irqs.count;
  47. remain_irqs.irqs[idx] = KEYPAD_IRQ_ID;
  48. remain_irqs.wakeupsrc_cat[idx] = 0;
  49. remain_irqs.wakeupsrc[idx] = KEYPAD_WAKESRC;
  50. remain_irqs.count++;
  51. mt_lp_irqremain_submit();
  52. }