mt_lp_irqremain.c 1.2 KB

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