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:
Samuel Holland
2025-03-25 16:43:29 -07:00
committed by Anup Patel
parent 2489e1421d
commit b353af63e2
12 changed files with 160 additions and 80 deletions

View File

@@ -21,9 +21,14 @@
#define SOPHGO_SG2042_TIMER_SIZE 0x10000UL
#define SOPHGO_SG2042_TIMER_NUM 16
static int sophgo_sg2042_early_init(bool cold_boot, const void *fdt,
const struct fdt_match *match)
static int sophgo_sg2042_early_init(bool cold_boot)
{
int rc;
rc = generic_early_init(cold_boot);
if (rc)
return rc;
thead_register_tlb_flush_trap_handler();
/*
@@ -44,13 +49,26 @@ static int sophgo_sg2042_early_init(bool cold_boot, const void *fdt,
return 0;
}
static int sophgo_sg2042_extensions_init(const struct fdt_match *match,
struct sbi_hart_features *hfeatures)
static int sophgo_sg2042_extensions_init(struct sbi_hart_features *hfeatures)
{
int rc;
rc = generic_extensions_init(hfeatures);
if (rc)
return rc;
thead_c9xx_register_pmu_device();
return 0;
}
static int sophgo_sg2042_platform_init(const void *fdt, int nodeoff, const struct fdt_match *match)
{
generic_platform_ops.early_init = sophgo_sg2042_early_init;
generic_platform_ops.extensions_init = sophgo_sg2042_extensions_init;
return 0;
}
static const struct fdt_match sophgo_sg2042_match[] = {
{ .compatible = "sophgo,sg2042" },
{ },
@@ -58,6 +76,5 @@ static const struct fdt_match sophgo_sg2042_match[] = {
const struct platform_override sophgo_sg2042 = {
.match_table = sophgo_sg2042_match,
.early_init = sophgo_sg2042_early_init,
.extensions_init = sophgo_sg2042_extensions_init,
.init = sophgo_sg2042_platform_init,
};