File: fdt_irqchip_aplic.c

package info (click to toggle)
opensbi 1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,936 kB
  • sloc: ansic: 18,783; asm: 1,116; makefile: 509; sh: 277
file content (56 lines) | stat: -rw-r--r-- 1,211 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * SPDX-License-Identifier: BSD-2-Clause
 *
 * Copyright (c) 2021 Western Digital Corporation or its affiliates.
 * Copyright (c) 2022 Ventana Micro Systems Inc.
 *
 * Authors:
 *   Anup Patel <anup.patel@wdc.com>
 */

#include <libfdt.h>
#include <sbi/riscv_asm.h>
#include <sbi/sbi_error.h>
#include <sbi_utils/fdt/fdt_helper.h>
#include <sbi_utils/irqchip/fdt_irqchip.h>
#include <sbi_utils/irqchip/aplic.h>

#define APLIC_MAX_NR			16

static unsigned long aplic_count = 0;
static struct aplic_data aplic[APLIC_MAX_NR];

static int irqchip_aplic_warm_init(void)
{
	/* Nothing to do here. */
	return 0;
}

static int irqchip_aplic_cold_init(void *fdt, int nodeoff,
				  const struct fdt_match *match)
{
	int rc;
	struct aplic_data *pd;

	if (APLIC_MAX_NR <= aplic_count)
		return SBI_ENOSPC;
	pd = &aplic[aplic_count++];

	rc = fdt_parse_aplic_node(fdt, nodeoff, pd);
	if (rc)
		return rc;

	return aplic_cold_irqchip_init(pd);
}

static const struct fdt_match irqchip_aplic_match[] = {
	{ .compatible = "riscv,aplic" },
	{ },
};

struct fdt_irqchip fdt_irqchip_aplic = {
	.match_table = irqchip_aplic_match,
	.cold_init = irqchip_aplic_cold_init,
	.warm_init = irqchip_aplic_warm_init,
	.exit = NULL,
};