1/*
2* Copyright 2020, Data61
3* Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4* ABN 41 687 119 230.
5*
6* This software may be distributed and modified according to the terms of
7* the BSD 2-Clause license. Note that NO WARRANTY is provided.
8* See "LICENSE_BSD2.txt" for details.
9*
10* @TAG(DATA61_BSD)
11*/
12
13#include <assert.h>
14#include <stdbool.h>
15
16#include <utils/util.h>
17
18#include "../../../irqchip.h"
19
20#define TI_OMAP3_INT_CELL_COUNT 1
21
22static int parse_ti_omap3_interrupts(char *dtb_blob, int node_offset, int intr_controller_phandle,
23                                     irq_walk_cb_fn_t callback, void *token)
24{
25    bool is_extended = false;
26    int prop_len = 0;
27    const void *interrupts_prop = get_interrupts_prop(dtb_blob, node_offset, &is_extended, &prop_len);
28    assert(interrupts_prop != NULL);
29    if (is_extended) {
30        ZF_LOGE("ti omap3 extended interrupts property not supported");
31        return ENODEV;
32    }
33    int UNUSED total_cells = prop_len / sizeof(uint32_t);
34    /* There's only one interrupt cell for this IRQ chip */
35    /* TODO: rebase on riscv/plic.c and allow multiple callbacks */
36    assert(total_cells == TI_OMAP3_INT_CELL_COUNT);
37    ps_irq_t irq = { .type = PS_INTERRUPT, .irq = { .number = READ_CELL(1, interrupts_prop, 0) }};
38    int error = callback(irq, 0, TI_OMAP3_INT_CELL_COUNT, token);
39    if (error) {
40        return error;
41    }
42    return 0;
43}
44
45char *ti_omap3_compatible_list[] = {
46    "ti,omap3-intc",
47    /* in the kernel's hardware.yml, these are equivalent */
48    "ti,am33xx-intc",
49    NULL
50};
51DEFINE_IRQCHIP_PARSER(ti_omap3, ti_omap3_compatible_list, parse_ti_omap3_interrupts);
52