cpu_ops.c 855 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2020 Western Digital Corporation or its affiliates.
  4. */
  5. #include <linux/errno.h>
  6. #include <linux/mm.h>
  7. #include <linux/of.h>
  8. #include <linux/string.h>
  9. #include <linux/sched.h>
  10. #include <asm/cpu_ops.h>
  11. #include <asm/cpu_ops_sbi.h>
  12. #include <asm/sbi.h>
  13. #include <asm/smp.h>
  14. const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init;
  15. extern const struct cpu_operations cpu_ops_sbi;
  16. #ifndef CONFIG_RISCV_BOOT_SPINWAIT
  17. const struct cpu_operations cpu_ops_spinwait = {
  18. .name = "",
  19. .cpu_prepare = NULL,
  20. .cpu_start = NULL,
  21. };
  22. #endif
  23. void __init cpu_set_ops(int cpuid)
  24. {
  25. #if IS_ENABLED(CONFIG_RISCV_SBI)
  26. if (sbi_probe_extension(SBI_EXT_HSM)) {
  27. if (!cpuid)
  28. pr_info("SBI HSM extension detected\n");
  29. cpu_ops[cpuid] = &cpu_ops_sbi;
  30. } else
  31. #endif
  32. cpu_ops[cpuid] = &cpu_ops_spinwait;
  33. }