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