mirror of
				https://github.com/riscv-software-src/opensbi
				synced 2025-11-04 05:50:22 +00:00 
			
		
		
		
	The irqchip driver subsystem does not need any extra data, so it can use `struct fdt_driver` directly. The generic fdt_irqchip_init() performs a best-effort initialization of all matching DT nodes. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
		
			
				
	
	
		
			53 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.0 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" },
 | 
						|
	{ },
 | 
						|
};
 | 
						|
 | 
						|
const struct fdt_driver fdt_irqchip_aplic = {
 | 
						|
	.match_table = irqchip_aplic_match,
 | 
						|
	.init = irqchip_aplic_cold_init,
 | 
						|
};
 |