forked from Mirrors/opensbi
		
	platform: generic: Modify platform ops instead of using hooks
Switch all existing platform overrides to use the helper pattern instead of the platform hooks. After this commit, only the .match_table and .init members of struct platform_override are used. There are two minor behavioral differences: - For Allwinner D1, fdt_add_cpu_idle_states() is now called before the body of generic_final_init(). This should have no functional impact. - For StarFive JH7110, if the /chosen/starfive,boot-hart-id property is missing, the code now falls back to using generic_coldboot_harts, instead of accepting any hart. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20250325234342.711447-7-samuel.holland@sifive.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
		
				
					committed by
					
						
						Anup Patel
					
				
			
			
				
	
			
			
			
						parent
						
							2489e1421d
						
					
				
				
					commit
					b353af63e2
				
			@@ -11,7 +11,7 @@
 | 
			
		||||
#include <sbi_utils/fdt/fdt_helper.h>
 | 
			
		||||
#include <sbi_utils/fdt/fdt_fixup.h>
 | 
			
		||||
 | 
			
		||||
static u64 sifive_fu540_tlbr_flush_limit(const struct fdt_match *match)
 | 
			
		||||
static u64 sifive_fu540_tlbr_flush_limit(void)
 | 
			
		||||
{
 | 
			
		||||
	/*
 | 
			
		||||
	 * The sfence.vma by virtual address does not work on
 | 
			
		||||
@@ -20,6 +20,13 @@ static u64 sifive_fu540_tlbr_flush_limit(const struct fdt_match *match)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int sifive_fu540_platform_init(const void *fdt, int nodeoff, const struct fdt_match *match)
 | 
			
		||||
{
 | 
			
		||||
	generic_platform_ops.get_tlbr_flush_limit = sifive_fu540_tlbr_flush_limit;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static const struct fdt_match sifive_fu540_match[] = {
 | 
			
		||||
	{ .compatible = "sifive,fu540" },
 | 
			
		||||
	{ .compatible = "sifive,fu540g" },
 | 
			
		||||
@@ -30,5 +37,5 @@ static const struct fdt_match sifive_fu540_match[] = {
 | 
			
		||||
 | 
			
		||||
const struct platform_override sifive_fu540 = {
 | 
			
		||||
	.match_table = sifive_fu540_match,
 | 
			
		||||
	.tlbr_flush_limit = sifive_fu540_tlbr_flush_limit,
 | 
			
		||||
	.init = sifive_fu540_platform_init,
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -219,7 +219,7 @@ static const struct fdt_driver *const sifive_fu740_reset_drivers[] = {
 | 
			
		||||
	NULL
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static u64 sifive_fu740_tlbr_flush_limit(const struct fdt_match *match)
 | 
			
		||||
static u64 sifive_fu740_tlbr_flush_limit(void)
 | 
			
		||||
{
 | 
			
		||||
	/*
 | 
			
		||||
	 * Needed to address CIP-1200 errata on SiFive FU740
 | 
			
		||||
@@ -231,18 +231,27 @@ static u64 sifive_fu740_tlbr_flush_limit(const struct fdt_match *match)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int sifive_fu740_final_init(bool cold_boot, void *fdt,
 | 
			
		||||
				   const struct fdt_match *match)
 | 
			
		||||
static int sifive_fu740_final_init(bool cold_boot)
 | 
			
		||||
{
 | 
			
		||||
	int rc;
 | 
			
		||||
 | 
			
		||||
	if (cold_boot) {
 | 
			
		||||
		const void *fdt = fdt_get_address();
 | 
			
		||||
 | 
			
		||||
		rc = fdt_driver_init_one(fdt, sifive_fu740_reset_drivers);
 | 
			
		||||
		if (rc)
 | 
			
		||||
			sbi_printf("%s: failed to find da9063 for reset\n",
 | 
			
		||||
				   __func__);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return generic_final_init(cold_boot);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int sifive_fu740_platform_init(const void *fdt, int nodeoff, const struct fdt_match *match)
 | 
			
		||||
{
 | 
			
		||||
	generic_platform_ops.final_init = sifive_fu740_final_init;
 | 
			
		||||
	generic_platform_ops.get_tlbr_flush_limit = sifive_fu740_tlbr_flush_limit;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -255,6 +264,5 @@ static const struct fdt_match sifive_fu740_match[] = {
 | 
			
		||||
 | 
			
		||||
const struct platform_override sifive_fu740 = {
 | 
			
		||||
	.match_table = sifive_fu740_match,
 | 
			
		||||
	.tlbr_flush_limit = sifive_fu740_tlbr_flush_limit,
 | 
			
		||||
	.final_init = sifive_fu740_final_init,
 | 
			
		||||
	.init = sifive_fu740_platform_init,
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user