Edward-JW Yang | 9c78368 | 2021-06-28 11:08:10 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2021, MediaTek Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <mt_lp_rm.h> |
| 8 | #include <mt_lp_irqremain.h> |
| 9 | #include <mtk_cirq.h> |
| 10 | #include <plat_mtk_lpm.h> |
| 11 | |
| 12 | |
| 13 | #define KEYPAD_IRQ_ID U(138) |
| 14 | |
| 15 | #define KEYPAD_WAKESRC 0x4 |
| 16 | |
| 17 | static struct mt_irqremain remain_irqs; |
| 18 | |
| 19 | int mt_lp_irqremain_submit(void) |
| 20 | { |
| 21 | if (remain_irqs.count == 0) { |
| 22 | return -1; |
| 23 | } |
| 24 | |
| 25 | set_wakeup_sources(remain_irqs.irqs, remain_irqs.count); |
| 26 | mt_lp_rm_do_update(-1, PLAT_RC_UPDATE_REMAIN_IRQS, &remain_irqs); |
| 27 | |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | int mt_lp_irqremain_aquire(void) |
| 32 | { |
| 33 | if (remain_irqs.count == 0) { |
| 34 | return -1; |
| 35 | } |
| 36 | |
| 37 | mt_cirq_sw_reset(); |
| 38 | mt_cirq_clone_gic(); |
| 39 | mt_cirq_enable(); |
| 40 | |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | int mt_lp_irqremain_release(void) |
| 45 | { |
| 46 | if (remain_irqs.count == 0) { |
| 47 | return -1; |
| 48 | } |
| 49 | |
| 50 | mt_cirq_flush(); |
| 51 | mt_cirq_disable(); |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | void mt_lp_irqremain_init(void) |
| 57 | { |
| 58 | uint32_t idx; |
| 59 | |
| 60 | remain_irqs.count = 0; |
| 61 | |
| 62 | /*edge keypad*/ |
| 63 | idx = remain_irqs.count; |
| 64 | remain_irqs.irqs[idx] = KEYPAD_IRQ_ID; |
| 65 | remain_irqs.wakeupsrc_cat[idx] = 0; |
| 66 | remain_irqs.wakeupsrc[idx] = KEYPAD_WAKESRC; |
| 67 | remain_irqs.count++; |
| 68 | |
| 69 | mt_lp_irqremain_submit(); |
| 70 | } |