Lines Matching +full:hart +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0-only
27 * Returns the hart ID of the given device tree node, or -ENODEV if the node
28 * isn't an enabled and valid RISC-V hart node.
30 int riscv_of_processor_hartid(struct device_node *node, unsigned long *hart) in riscv_of_processor_hartid() argument
34 *hart = (unsigned long)of_get_cpu_hwid(node, 0); in riscv_of_processor_hartid()
35 if (*hart == ~0UL) { in riscv_of_processor_hartid()
36 pr_warn("Found CPU without hart ID\n"); in riscv_of_processor_hartid()
37 return -ENODEV; in riscv_of_processor_hartid()
40 cpu = riscv_hartid_to_cpuid(*hart); in riscv_of_processor_hartid()
45 return -ENODEV; in riscv_of_processor_hartid()
50 int __init riscv_early_of_processor_hartid(struct device_node *node, unsigned long *hart) in riscv_early_of_processor_hartid() argument
56 return -ENODEV; in riscv_early_of_processor_hartid()
59 *hart = (unsigned long)of_get_cpu_hwid(node, 0); in riscv_early_of_processor_hartid()
60 if (*hart == ~0UL) { in riscv_early_of_processor_hartid()
61 pr_warn("Found CPU without hart ID\n"); in riscv_early_of_processor_hartid()
62 return -ENODEV; in riscv_early_of_processor_hartid()
66 return -ENODEV; in riscv_early_of_processor_hartid()
68 if (of_property_read_string(node, "riscv,isa-base", &isa)) in riscv_early_of_processor_hartid()
72 pr_warn("CPU with hartid=%lu does not support rv32i", *hart); in riscv_early_of_processor_hartid()
73 return -ENODEV; in riscv_early_of_processor_hartid()
77 pr_warn("CPU with hartid=%lu does not support rv64i", *hart); in riscv_early_of_processor_hartid()
78 return -ENODEV; in riscv_early_of_processor_hartid()
81 if (!of_property_present(node, "riscv,isa-extensions")) in riscv_early_of_processor_hartid()
82 return -ENODEV; in riscv_early_of_processor_hartid()
84 if (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 || in riscv_early_of_processor_hartid()
85 of_property_match_string(node, "riscv,isa-extensions", "m") < 0 || in riscv_early_of_processor_hartid()
86 of_property_match_string(node, "riscv,isa-extensions", "a") < 0) { in riscv_early_of_processor_hartid()
87 pr_warn("CPU with hartid=%lu does not support ima", *hart); in riscv_early_of_processor_hartid()
88 return -ENODEV; in riscv_early_of_processor_hartid()
96 *hart); in riscv_early_of_processor_hartid()
97 return -ENODEV; in riscv_early_of_processor_hartid()
101 pr_warn("CPU with hartid=%lu has no \"riscv,isa-base\" or \"riscv,isa\" property\n", in riscv_early_of_processor_hartid()
102 *hart); in riscv_early_of_processor_hartid()
103 return -ENODEV; in riscv_early_of_processor_hartid()
107 pr_warn("CPU with hartid=%lu does not support rv32ima", *hart); in riscv_early_of_processor_hartid()
108 return -ENODEV; in riscv_early_of_processor_hartid()
112 pr_warn("CPU with hartid=%lu does not support rv64ima", *hart); in riscv_early_of_processor_hartid()
113 return -ENODEV; in riscv_early_of_processor_hartid()
120 * Find hart ID of the CPU DT node under which given DT node falls.
123 * RISC-V core (HART) node and extract the cpuid from it.
127 for (; node; node = node->parent) { in riscv_of_parent_hartid()
131 pr_warn("Found CPU without hart ID\n"); in riscv_of_parent_hartid()
132 return -ENODEV; in riscv_of_parent_hartid()
138 return -1; in riscv_of_parent_hartid()
146 ci->marchid = sbi_spec_is_0_1() ? 0 : sbi_get_marchid(); in riscv_get_marchid()
148 ci->marchid = csr_read(CSR_MARCHID); in riscv_get_marchid()
150 ci->marchid = 0; in riscv_get_marchid()
152 return ci->marchid; in riscv_get_marchid()
160 ci->mvendorid = sbi_spec_is_0_1() ? 0 : sbi_get_mvendorid(); in riscv_get_mvendorid()
162 ci->mvendorid = csr_read(CSR_MVENDORID); in riscv_get_mvendorid()
164 ci->mvendorid = 0; in riscv_get_mvendorid()
166 return ci->mvendorid; in riscv_get_mvendorid()
175 return ci->mvendorid; in riscv_cached_mvendorid()
183 return ci->marchid; in riscv_cached_marchid()
191 return ci->mimpid; in riscv_cached_mimpid()
200 if (!ci->mvendorid) in riscv_cpuinfo_starting()
201 ci->mvendorid = sbi_spec_is_0_1() ? 0 : sbi_get_mvendorid(); in riscv_cpuinfo_starting()
202 if (!ci->marchid) in riscv_cpuinfo_starting()
203 ci->marchid = sbi_spec_is_0_1() ? 0 : sbi_get_marchid(); in riscv_cpuinfo_starting()
204 ci->mimpid = sbi_spec_is_0_1() ? 0 : sbi_get_mimpid(); in riscv_cpuinfo_starting()
206 if (!ci->mvendorid) in riscv_cpuinfo_starting()
207 ci->mvendorid = csr_read(CSR_MVENDORID); in riscv_cpuinfo_starting()
208 if (!ci->marchid) in riscv_cpuinfo_starting()
209 ci->marchid = csr_read(CSR_MARCHID); in riscv_cpuinfo_starting()
210 ci->mimpid = csr_read(CSR_MIMPID); in riscv_cpuinfo_starting()
212 ci->mvendorid = 0; in riscv_cpuinfo_starting()
213 ci->marchid = 0; in riscv_cpuinfo_starting()
214 ci->mimpid = 0; in riscv_cpuinfo_starting()
237 #define ALL_CPUS -1
247 ext_data = riscv_isa_vendor_ext_list[i]->ext_data; in print_vendor_isa()
250 vendor_bitmap = &ext_list->all_harts_isa_bitmap; in print_vendor_isa()
252 vendor_bitmap = &ext_list->per_hart_isa_bitmap[cpu]; in print_vendor_isa()
254 for (int j = 0; j < ext_list->ext_data_count; j++) { in print_vendor_isa()
255 if (!__riscv_isa_extension_available(vendor_bitmap->isa, ext_data[j].id)) in print_vendor_isa()
275 /* Only multi-letter extensions are split by underscores */ in print_isa()
276 if (strnlen(riscv_isa_ext[i].name, 2) != 1) in print_isa()
313 *pos = cpumask_next(*pos - 1, cpu_online_mask); in c_start()
331 unsigned long cpu_id = (unsigned long)v - 1; in c_show()
337 seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id)); in c_show()
342 * extensions supported on this hart is printed later in the hart isa: in c_show()
359 seq_printf(m, "mvendorid\t: 0x%lx\n", ci->mvendorid); in c_show()
360 seq_printf(m, "marchid\t\t: 0x%lx\n", ci->marchid); in c_show()
361 seq_printf(m, "mimpid\t\t: 0x%lx\n", ci->mimpid); in c_show()
364 * Print the ISA extensions specific to this hart, which may show in c_show()
367 seq_puts(m, "hart isa\t: "); in c_show()