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

@@ -102,11 +102,23 @@ static void ae350_hsm_device_init(const void *fdt)
}
}
static int ae350_final_init(bool cold_boot, void *fdt,
const struct fdt_match *match)
static int ae350_final_init(bool cold_boot)
{
if (cold_boot)
if (cold_boot) {
const void *fdt = fdt_get_address();
ae350_hsm_device_init(fdt);
}
return generic_final_init(cold_boot);
}
static int ae350_platform_init(const void *fdt, int nodeoff, const struct fdt_match *match)
{
generic_platform_ops.final_init = ae350_final_init;
generic_platform_ops.extensions_init = andes_pmu_extensions_init;
generic_platform_ops.pmu_init = andes_pmu_init;
generic_platform_ops.vendor_ext_provider = andes_sbi_vendor_ext_provider;
return 0;
}
@@ -118,8 +130,5 @@ static const struct fdt_match andes_ae350_match[] = {
const struct platform_override andes_ae350 = {
.match_table = andes_ae350_match,
.final_init = ae350_final_init,
.extensions_init = andes_pmu_extensions_init,
.pmu_init = andes_pmu_init,
.vendor_ext_provider = andes_sbi_vendor_ext_provider,
.init = ae350_platform_init,
};

View File

@@ -11,6 +11,7 @@
#include <sbi/sbi_error.h>
#include <sbi/sbi_pmu.h>
#include <libfdt.h>
#include <platform_override.h>
static void andes_hw_counter_enable_irq(uint32_t ctr_idx)
{
@@ -57,10 +58,14 @@ static struct sbi_pmu_device andes_pmu = {
.hw_counter_filter_mode = andes_hw_counter_filter_mode
};
int andes_pmu_extensions_init(const struct fdt_match *match,
struct sbi_hart_features *hfeatures)
int andes_pmu_extensions_init(struct sbi_hart_features *hfeatures)
{
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
int rc;
rc = generic_extensions_init(hfeatures);
if (rc)
return rc;
if (!has_andes_pmu())
return 0;
@@ -82,12 +87,12 @@ int andes_pmu_extensions_init(const struct fdt_match *match,
return 0;
}
int andes_pmu_init(const struct fdt_match *match)
int andes_pmu_init(void)
{
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
if (sbi_hart_has_extension(scratch, SBI_HART_EXT_XANDESPMU))
sbi_pmu_set_device(&andes_pmu);
return 0;
return generic_pmu_init();
}

View File

@@ -38,8 +38,7 @@ static bool andes_apply_iocp_sw_workaround(void)
int andes_sbi_vendor_ext_provider(long funcid,
struct sbi_trap_regs *regs,
struct sbi_ecall_return *out,
const struct fdt_match *match)
struct sbi_ecall_return *out)
{
int ret = 0;