blob: a81cb2b7711721d3b3ac286ff50428363d3545ec [file] [log] [blame]
Pankaj Gupta988bbb22020-12-09 14:02:40 +05301/*
2 * Copyright 2020 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#include <bl31/interrupt_mgmt.h>
9#include <common/debug.h>
10#include <ls_interrupt_mgmt.h>
11#include <plat/common/platform.h>
12
13static interrupt_type_handler_t type_el3_interrupt_table[MAX_INTR_EL3];
14
15int request_intr_type_el3(uint32_t id, interrupt_type_handler_t handler)
16{
17 /* Validate 'handler' and 'id' parameters */
18 if (!handler || id >= MAX_INTR_EL3) {
19 return -EINVAL;
20 }
21
22 /* Check if a handler has already been registered */
23 if (type_el3_interrupt_table[id] != NULL) {
24 return -EALREADY;
25 }
26
27 type_el3_interrupt_table[id] = handler;
28
29 return 0;
30}
31
32static uint64_t ls_el3_interrupt_handler(uint32_t id, uint32_t flags,
33 void *handle, void *cookie)
34{
35 uint32_t intr_id;
36 interrupt_type_handler_t handler;
37
38 intr_id = plat_ic_get_pending_interrupt_id();
39
40 INFO("Interrupt recvd is %d\n", intr_id);
41
42 handler = type_el3_interrupt_table[intr_id];
43 if (handler != NULL) {
44 handler(intr_id, flags, handle, cookie);
45 }
46
47 /*
48 * Mark this interrupt as complete to avoid a interrupt storm.
49 */
50 plat_ic_end_of_interrupt(intr_id);
51
52 return 0U;
53}
54
55void ls_el3_interrupt_config(void)
56{
57 uint64_t flags = 0U;
58 uint64_t rc;
59
60 set_interrupt_rm_flag(flags, NON_SECURE);
61 rc = register_interrupt_type_handler(INTR_TYPE_EL3,
62 ls_el3_interrupt_handler, flags);
63 if (rc != 0U) {
64 panic();
65 }
66}