forked from Mirrors/opensbi
		
	lib: utils: Move PLIC DT fix up codes to fdt_helper.c
Now that we have a dedicated fdt_helper.c file for DT releated helper routines, move plic_fdt_fixup() codes from plic.c to fdt_helper.c and rename it to fdt_plic_fixup() at the same time, to keep name consistency in the same file. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
This commit is contained in:
		@@ -12,6 +12,31 @@
 | 
			
		||||
#include <sbi/sbi_platform.h>
 | 
			
		||||
#include <sbi/sbi_scratch.h>
 | 
			
		||||
 | 
			
		||||
void fdt_plic_fixup(void *fdt, const char *compat)
 | 
			
		||||
{
 | 
			
		||||
	u32 *cells;
 | 
			
		||||
	int i, cells_count;
 | 
			
		||||
	int plic_off;
 | 
			
		||||
 | 
			
		||||
	plic_off = fdt_node_offset_by_compatible(fdt, 0, compat);
 | 
			
		||||
	if (plic_off < 0)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	cells = (u32 *)fdt_getprop(fdt, plic_off,
 | 
			
		||||
				   "interrupts-extended", &cells_count);
 | 
			
		||||
	if (!cells)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	cells_count = cells_count / sizeof(u32);
 | 
			
		||||
	if (!cells_count)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < (cells_count / 2); i++) {
 | 
			
		||||
		if (fdt32_to_cpu(cells[2 * i + 1]) == IRQ_M_EXT)
 | 
			
		||||
			cells[2 * i + 1] = cpu_to_fdt32(0xffffffff);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * We use PMP to protect OpenSBI firmware to safe-guard it from buggy S-mode
 | 
			
		||||
 * software, see pmp_init() in lib/sbi/sbi_hart.c. The protected memory region
 | 
			
		||||
 
 | 
			
		||||
@@ -12,8 +12,6 @@
 | 
			
		||||
#include <sbi/sbi_console.h>
 | 
			
		||||
#include <sbi/sbi_string.h>
 | 
			
		||||
#include <sbi_utils/irqchip/plic.h>
 | 
			
		||||
#include <libfdt.h>
 | 
			
		||||
#include <fdt.h>
 | 
			
		||||
 | 
			
		||||
#define PLIC_PRIORITY_BASE 0x0
 | 
			
		||||
#define PLIC_PENDING_BASE 0x1000
 | 
			
		||||
@@ -47,31 +45,6 @@ void plic_set_ie(u32 cntxid, u32 word_index, u32 val)
 | 
			
		||||
	writel(val, plic_ie + word_index * 4);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void plic_fdt_fixup(void *fdt, const char *compat)
 | 
			
		||||
{
 | 
			
		||||
	u32 *cells;
 | 
			
		||||
	int i, cells_count;
 | 
			
		||||
	int plic_off;
 | 
			
		||||
 | 
			
		||||
	plic_off = fdt_node_offset_by_compatible(fdt, 0, compat);
 | 
			
		||||
	if (plic_off < 0)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	cells = (u32 *)fdt_getprop(fdt, plic_off,
 | 
			
		||||
				   "interrupts-extended", &cells_count);
 | 
			
		||||
	if (!cells)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	cells_count = cells_count / sizeof(u32);
 | 
			
		||||
	if (!cells_count)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < (cells_count / 2); i++) {
 | 
			
		||||
		if (fdt32_to_cpu(cells[2 * i + 1]) == IRQ_M_EXT)
 | 
			
		||||
			cells[2 * i + 1] = cpu_to_fdt32(0xffffffff);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int plic_warm_irqchip_init(u32 target_hart, int m_cntx_id, int s_cntx_id)
 | 
			
		||||
{
 | 
			
		||||
	size_t i, ie_words = plic_num_sources / 32 + 1;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user