platform: generic: Add an init hook matching fdt_driver

In preparation for reusing the fdt_driver code to match platform
overrides, add a new .init hook matching the type signature from
fdt_driver. This hook replaces the existing .fw_init hook, since
it is called at roughly the same place in the init process.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20250325234342.711447-5-samuel.holland@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Samuel Holland
2025-03-25 16:43:27 -07:00
committed by Anup Patel
parent de777cc633
commit e78a0ebdc4
3 changed files with 14 additions and 7 deletions

View File

@@ -17,6 +17,8 @@
struct platform_override {
const struct fdt_match *match_table;
int (*init)(const void *fdt, int nodeoff,
const struct fdt_match *match);
u64 (*features)(const struct fdt_match *match);
u64 (*tlbr_flush_limit)(const struct fdt_match *match);
u32 (*tlb_num_entries)(const struct fdt_match *match);
@@ -29,7 +31,6 @@ struct platform_override {
int (*extensions_init)(const struct fdt_match *match,
struct sbi_hart_features *hfeatures);
int (*pmu_init)(const struct fdt_match *match);
void (*fw_init)(const void *fdt, const struct fdt_match *match);
int (*vendor_ext_provider)(long funcid,
struct sbi_trap_regs *regs,
struct sbi_ecall_return *out,

View File

@@ -40,7 +40,7 @@ static void fw_platform_lookup_special(const void *fdt, int root_offset)
{
const struct platform_override *plat;
const struct fdt_match *match;
int pos;
int pos, rc;
for (pos = 0; platform_override_modules[pos]; pos++) {
plat = platform_override_modules[pos];
@@ -51,6 +51,12 @@ static void fw_platform_lookup_special(const void *fdt, int root_offset)
if (!match)
continue;
if (plat->init) {
rc = plat->init(fdt, root_offset, match);
if (rc)
continue;
}
generic_plat = plat;
generic_plat_match = match;
break;
@@ -178,9 +184,6 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,
fw_platform_lookup_special(fdt, root_offset);
if (generic_plat && generic_plat->fw_init)
generic_plat->fw_init(fdt, generic_plat_match);
model = fdt_getprop(fdt, root_offset, "model", &len);
if (model)
sbi_strncpy(platform.name, model, sizeof(platform.name) - 1);

View File

@@ -301,7 +301,8 @@ static bool starfive_jh7110_cold_boot_allowed(u32 hartid,
return true;
}
static void starfive_jh7110_fw_init(const void *fdt, const struct fdt_match *match)
static int starfive_jh7110_platform_init(const void *fdt, int nodeoff,
const struct fdt_match *match)
{
const fdt32_t *val;
int len, coff;
@@ -312,6 +313,8 @@ static void starfive_jh7110_fw_init(const void *fdt, const struct fdt_match *mat
if (val && len >= sizeof(fdt32_t))
selected_hartid = (u32) fdt32_to_cpu(*val);
}
return 0;
}
static const struct fdt_match starfive_jh7110_match[] = {
@@ -321,7 +324,7 @@ static const struct fdt_match starfive_jh7110_match[] = {
const struct platform_override starfive_jh7110 = {
.match_table = starfive_jh7110_match,
.init = starfive_jh7110_platform_init,
.cold_boot_allowed = starfive_jh7110_cold_boot_allowed,
.fw_init = starfive_jh7110_fw_init,
.final_init = starfive_jh7110_final_init,
};