mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 23:41:23 +01:00

Currently, each platform keeps track of which irqchip driver is in use and calls its warm init function. Since the generic platform may use multiple irqchip drivers, it has logic to track an array of drivers. The code is simplified and made common across platforms by treating warm init and exit as properties of the driver, not the platform. Then the platform's only role is to select and prepare a driver during cold boot. For now, only add a .warm_init hook, since none of the existing drivers need an .exit hook. It could be added in the future if needed. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
/*
|
|
* 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/sbi_heap.h>
|
|
#include <sbi_utils/fdt/fdt_helper.h>
|
|
#include <sbi_utils/irqchip/fdt_irqchip.h>
|
|
#include <sbi_utils/irqchip/aplic.h>
|
|
|
|
static int irqchip_aplic_cold_init(const void *fdt, int nodeoff,
|
|
const struct fdt_match *match)
|
|
{
|
|
int rc;
|
|
struct aplic_data *pd;
|
|
|
|
pd = sbi_zalloc(sizeof(*pd));
|
|
if (!pd)
|
|
return SBI_ENOMEM;
|
|
|
|
rc = fdt_parse_aplic_node(fdt, nodeoff, pd);
|
|
if (rc)
|
|
goto fail_free_data;
|
|
|
|
rc = aplic_cold_irqchip_init(pd);
|
|
if (rc)
|
|
goto fail_free_data;
|
|
|
|
return 0;
|
|
|
|
fail_free_data:
|
|
sbi_free(pd);
|
|
return rc;
|
|
}
|
|
|
|
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 = NULL,
|
|
.exit = NULL,
|
|
};
|