blob: b5a0284394abd4a9535d9d7a2c0948e31403de08 [file] [log] [blame]
jason-ch chenfa82b9b2021-11-16 09:48:20 +08001/*
2 * Copyright (c) 2022, MediaTek Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
developerbdeb0ba2022-07-08 14:48:56 +08007#include <mt_cirq.h>
jason-ch chenfa82b9b2021-11-16 09:48:20 +08008#include <mt_lp_irqremain.h>
9#include <mt_lp_rm.h>
jason-ch chenfa82b9b2021-11-16 09:48:20 +080010#include <plat_mtk_lpm.h>
11
12#define KEYPAD_IRQ_ID U(138)
13#define KEYPAD_WAKESRC (0x4U)
14
15static struct mt_irqremain remain_irqs;
16
17int mt_lp_irqremain_submit(void)
18{
19 int ret = 0;
20
21 if (remain_irqs.count == 0) {
22 ret = -1;
23 } else {
24 set_wakeup_sources(remain_irqs.irqs, remain_irqs.count);
25 mt_lp_rm_do_update(-1, PLAT_RC_UPDATE_REMAIN_IRQS, &remain_irqs);
26 }
27
28 return ret;
29}
30
31int mt_lp_irqremain_aquire(void)
32{
33 int ret = 0;
34
35 if (remain_irqs.count == 0) {
36 ret = -1;
37 } else {
38 mt_cirq_sw_reset();
39 mt_cirq_clone_gic();
40 mt_cirq_enable();
41 }
42
43 return ret;
44}
45
46int mt_lp_irqremain_release(void)
47{
48 int ret = 0;
49
50 if (remain_irqs.count == 0) {
51 ret = -1;
52 } else {
53 mt_cirq_flush();
54 mt_cirq_disable();
55 }
56
57 return ret;
58}
59
60void mt_lp_irqremain_init(void)
61{
62 uint32_t idx;
63
64 remain_irqs.count = 0U;
65
66 /*edge keypad*/
67 idx = remain_irqs.count;
68 remain_irqs.irqs[idx] = KEYPAD_IRQ_ID;
69 remain_irqs.wakeupsrc_cat[idx] = 0U;
70 remain_irqs.wakeupsrc[idx] = KEYPAD_WAKESRC;
71 remain_irqs.count++;
72
73 mt_lp_irqremain_submit();
74}