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

@@ -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);