6
6
* Copyright (C) 2017 SiFive
7
7
*/
8
8
9
+ #include <linux/acpi.h>
9
10
#include <linux/bitmap.h>
10
11
#include <linux/ctype.h>
11
12
#include <linux/log2.h>
12
13
#include <linux/memory.h>
13
14
#include <linux/module.h>
14
15
#include <linux/of.h>
15
16
#include <linux/of_device.h>
17
+ #include <asm/acpi.h>
16
18
#include <asm/alternative.h>
17
19
#include <asm/cacheflush.h>
18
20
#include <asm/cpufeature.h>
@@ -100,6 +102,8 @@ void __init riscv_fill_hwcap(void)
100
102
char print_str [NUM_ALPHA_EXTS + 1 ];
101
103
int i , j , rc ;
102
104
unsigned long isa2hwcap [26 ] = {0 };
105
+ struct acpi_table_header * rhct ;
106
+ acpi_status status ;
103
107
unsigned int cpu ;
104
108
105
109
isa2hwcap ['i' - 'a' ] = COMPAT_HWCAP_ISA_I ;
@@ -113,22 +117,36 @@ void __init riscv_fill_hwcap(void)
113
117
114
118
bitmap_zero (riscv_isa , RISCV_ISA_EXT_MAX );
115
119
120
+ if (!acpi_disabled ) {
121
+ status = acpi_get_table (ACPI_SIG_RHCT , 0 , & rhct );
122
+ if (ACPI_FAILURE (status ))
123
+ return ;
124
+ }
125
+
116
126
for_each_possible_cpu (cpu ) {
117
127
unsigned long this_hwcap = 0 ;
118
128
DECLARE_BITMAP (this_isa , RISCV_ISA_EXT_MAX );
119
129
const char * temp ;
120
130
121
- node = of_cpu_device_node_get (cpu );
122
- if (!node ) {
123
- pr_warn ("Unable to find cpu node\n" );
124
- continue ;
125
- }
131
+ if (acpi_disabled ) {
132
+ node = of_cpu_device_node_get (cpu );
133
+ if (!node ) {
134
+ pr_warn ("Unable to find cpu node\n" );
135
+ continue ;
136
+ }
126
137
127
- rc = of_property_read_string (node , "riscv,isa" , & isa );
128
- of_node_put (node );
129
- if (rc ) {
130
- pr_warn ("Unable to find \"riscv,isa\" devicetree entry\n" );
131
- continue ;
138
+ rc = of_property_read_string (node , "riscv,isa" , & isa );
139
+ of_node_put (node );
140
+ if (rc ) {
141
+ pr_warn ("Unable to find \"riscv,isa\" devicetree entry\n" );
142
+ continue ;
143
+ }
144
+ } else {
145
+ rc = acpi_get_riscv_isa (rhct , cpu , & isa );
146
+ if (rc < 0 ) {
147
+ pr_warn ("Unable to get ISA for the hart - %d\n" , cpu );
148
+ continue ;
149
+ }
132
150
}
133
151
134
152
temp = isa ;
@@ -265,6 +283,9 @@ void __init riscv_fill_hwcap(void)
265
283
bitmap_and (riscv_isa , riscv_isa , this_isa , RISCV_ISA_EXT_MAX );
266
284
}
267
285
286
+ if (!acpi_disabled && rhct )
287
+ acpi_put_table ((struct acpi_table_header * )rhct );
288
+
268
289
/* We don't support systems with F but without D, so mask those out
269
290
* here. */
270
291
if ((elf_hwcap & COMPAT_HWCAP_ISA_F ) && !(elf_hwcap & COMPAT_HWCAP_ISA_D )) {
0 commit comments