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
@@ -13,6 +13,7 @@
|
||||
#include <sbi/sbi_ecall_interface.h>
|
||||
#include <sbi/sbi_error.h>
|
||||
#include <sbi/sbi_hsm.h>
|
||||
#include <sbi/sbi_platform.h>
|
||||
#include <sbi/sbi_pmu.h>
|
||||
#include <sbi/sbi_scratch.h>
|
||||
#include <sbi_utils/fdt/fdt_fixup.h>
|
||||
@@ -165,17 +166,6 @@ static const struct sbi_hsm_device sun20i_d1_ppu = {
|
||||
.hart_resume = sun20i_d1_hart_resume,
|
||||
};
|
||||
|
||||
static int sun20i_d1_final_init(bool cold_boot, void *fdt,
|
||||
const struct fdt_match *match)
|
||||
{
|
||||
if (cold_boot) {
|
||||
sun20i_d1_riscv_cfg_init();
|
||||
sbi_hsm_set_device(&sun20i_d1_ppu);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct sbi_cpu_idle_state sun20i_d1_cpu_idle_states[] = {
|
||||
{
|
||||
.name = "cpu-nonretentive",
|
||||
@@ -189,14 +179,32 @@ static const struct sbi_cpu_idle_state sun20i_d1_cpu_idle_states[] = {
|
||||
{ }
|
||||
};
|
||||
|
||||
static int sun20i_d1_fdt_fixup(void *fdt, const struct fdt_match *match)
|
||||
static int sun20i_d1_final_init(bool cold_boot)
|
||||
{
|
||||
return fdt_add_cpu_idle_states(fdt, sun20i_d1_cpu_idle_states);
|
||||
int rc;
|
||||
|
||||
if (cold_boot) {
|
||||
void *fdt = fdt_get_address_rw();
|
||||
|
||||
sun20i_d1_riscv_cfg_init();
|
||||
sbi_hsm_set_device(&sun20i_d1_ppu);
|
||||
|
||||
rc = fdt_add_cpu_idle_states(fdt, sun20i_d1_cpu_idle_states);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return generic_final_init(cold_boot);
|
||||
}
|
||||
|
||||
static int sun20i_d1_extensions_init(const struct fdt_match *match,
|
||||
struct sbi_hart_features *hfeatures)
|
||||
static int sun20i_d1_extensions_init(struct sbi_hart_features *hfeatures)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = generic_extensions_init(hfeatures);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
thead_c9xx_register_pmu_device();
|
||||
|
||||
/* auto-detection doesn't work on t-head c9xx cores */
|
||||
@@ -207,6 +215,15 @@ static int sun20i_d1_extensions_init(const struct fdt_match *match,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sun20i_d1_platform_init(const void *fdt, int nodeoff,
|
||||
const struct fdt_match *match)
|
||||
{
|
||||
generic_platform_ops.final_init = sun20i_d1_final_init;
|
||||
generic_platform_ops.extensions_init = sun20i_d1_extensions_init;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct fdt_match sun20i_d1_match[] = {
|
||||
{ .compatible = "allwinner,sun20i-d1" },
|
||||
{ },
|
||||
@@ -214,7 +231,5 @@ static const struct fdt_match sun20i_d1_match[] = {
|
||||
|
||||
const struct platform_override sun20i_d1 = {
|
||||
.match_table = sun20i_d1_match,
|
||||
.final_init = sun20i_d1_final_init,
|
||||
.fdt_fixup = sun20i_d1_fdt_fixup,
|
||||
.extensions_init = sun20i_d1_extensions_init,
|
||||
.init = sun20i_d1_platform_init,
|
||||
};
|
||||
|
Reference in New Issue
Block a user