Files
opensbi/platform/generic/andes/andes_sbi.c
Samuel Holland b353af63e2 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>
2025-04-23 12:32:51 +05:30

64 lines
1.5 KiB
C

// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright (C) 2023 Renesas Electronics Corp.
*
*/
#include <andes/andes.h>
#include <andes/andes_sbi.h>
#include <andes/andes_pma.h>
#include <sbi/riscv_asm.h>
#include <sbi/sbi_error.h>
enum sbi_ext_andes_fid {
SBI_EXT_ANDES_FID0 = 0, /* Reserved for future use */
SBI_EXT_ANDES_IOCP_SW_WORKAROUND,
SBI_EXT_ANDES_PMA_PROBE,
SBI_EXT_ANDES_PMA_SET,
SBI_EXT_ANDES_PMA_FREE,
};
static bool andes_cache_controllable(void)
{
return (((csr_read(CSR_MICM_CFG) & MICM_CFG_ISZ_MASK) ||
(csr_read(CSR_MDCM_CFG) & MDCM_CFG_DSZ_MASK)) &&
(csr_read(CSR_MMSC_CFG) & MMSC_CFG_CCTLCSR_MASK) &&
(csr_read(CSR_MCACHE_CTL) & MCACHE_CTL_CCTL_SUEN_MASK) &&
misa_extension('U'));
}
static bool andes_iocp_disabled(void)
{
return (csr_read(CSR_MMSC_CFG) & MMSC_IOCP_MASK) ? false : true;
}
static bool andes_apply_iocp_sw_workaround(void)
{
return andes_cache_controllable() && andes_iocp_disabled();
}
int andes_sbi_vendor_ext_provider(long funcid,
struct sbi_trap_regs *regs,
struct sbi_ecall_return *out)
{
int ret = 0;
switch (funcid) {
case SBI_EXT_ANDES_IOCP_SW_WORKAROUND:
out->value = andes_apply_iocp_sw_workaround();
break;
case SBI_EXT_ANDES_PMA_PROBE:
out->value = andes_sbi_probe_pma();
break;
case SBI_EXT_ANDES_PMA_SET:
ret = andes_sbi_set_pma(regs->a0, regs->a1, regs->a2);
break;
case SBI_EXT_ANDES_PMA_FREE:
ret = andes_sbi_free_pma(regs->a0);
break;
default:
ret = SBI_ENOTSUPP;
}
return ret;
}