1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
|
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
* Copyright(c) 2021-2024 Intel Corporation
*/
#include "iwl-drv.h"
#include "pnvm.h"
#include "iwl-prph.h"
#include "iwl-io.h"
#include "fw/uefi.h"
#include "fw/api/alive.h"
#include <linux/efi.h>
#include "fw/runtime.h"
#define IWL_EFI_VAR_GUID EFI_GUID(0x92daaf2f, 0xc02b, 0x455b, \
0xb2, 0xec, 0xf5, 0xa3, \
0x59, 0x4f, 0x4a, 0xea)
struct iwl_uefi_pnvm_mem_desc {
__le32 addr;
__le32 size;
const u8 data[];
} __packed;
static void *iwl_uefi_get_variable(efi_char16_t *name, efi_guid_t *guid,
unsigned long *data_size)
{
efi_status_t status;
void *data;
if (!data_size)
return ERR_PTR(-EINVAL);
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE))
return ERR_PTR(-ENODEV);
/* first call with NULL data to get the exact entry size */
*data_size = 0;
status = efi.get_variable(name, guid, NULL, data_size, NULL);
if (status != EFI_BUFFER_TOO_SMALL || !*data_size)
return ERR_PTR(-EIO);
data = kmalloc(*data_size, GFP_KERNEL);
if (!data)
return ERR_PTR(-ENOMEM);
status = efi.get_variable(name, guid, NULL, data_size, data);
if (status != EFI_SUCCESS) {
kfree(data);
return ERR_PTR(-ENOENT);
}
return data;
}
void *iwl_uefi_get_pnvm(struct iwl_trans *trans, size_t *len)
{
unsigned long package_size;
void *data;
*len = 0;
data = iwl_uefi_get_variable(IWL_UEFI_OEM_PNVM_NAME, &IWL_EFI_VAR_GUID,
&package_size);
if (IS_ERR(data)) {
IWL_DEBUG_FW(trans,
"PNVM UEFI variable not found 0x%lx (len %lu)\n",
PTR_ERR(data), package_size);
return data;
}
IWL_DEBUG_FW(trans, "Read PNVM from UEFI with size %lu\n", package_size);
*len = package_size;
return data;
}
static
void *iwl_uefi_get_verified_variable(struct iwl_trans *trans,
efi_char16_t *uefi_var_name,
char *var_name,
unsigned int expected_size,
unsigned long *size)
{
void *var;
unsigned long var_size;
var = iwl_uefi_get_variable(uefi_var_name, &IWL_EFI_VAR_GUID,
&var_size);
if (IS_ERR(var)) {
IWL_DEBUG_RADIO(trans,
"%s UEFI variable not found 0x%lx\n", var_name,
PTR_ERR(var));
return var;
}
if (var_size < expected_size) {
IWL_DEBUG_RADIO(trans,
"Invalid %s UEFI variable len (%lu)\n",
var_name, var_size);
kfree(var);
return ERR_PTR(-EINVAL);
}
IWL_DEBUG_RADIO(trans, "%s from UEFI with size %lu\n", var_name,
var_size);
if (size)
*size = var_size;
return var;
}
int iwl_uefi_handle_tlv_mem_desc(struct iwl_trans *trans, const u8 *data,
u32 tlv_len, struct iwl_pnvm_image *pnvm_data)
{
const struct iwl_uefi_pnvm_mem_desc *desc = (const void *)data;
u32 data_len;
if (tlv_len < sizeof(*desc)) {
IWL_DEBUG_FW(trans, "TLV len (%d) is too small\n", tlv_len);
return -EINVAL;
}
data_len = tlv_len - sizeof(*desc);
IWL_DEBUG_FW(trans,
"Handle IWL_UCODE_TLV_MEM_DESC, len %d data_len %d\n",
tlv_len, data_len);
if (le32_to_cpu(desc->size) != data_len) {
IWL_DEBUG_FW(trans, "invalid mem desc size %d\n", desc->size);
return -EINVAL;
}
if (pnvm_data->n_chunks == IPC_DRAM_MAP_ENTRY_NUM_MAX) {
IWL_DEBUG_FW(trans, "too many payloads to allocate in DRAM.\n");
return -EINVAL;
}
IWL_DEBUG_FW(trans, "Adding data (size %d)\n", data_len);
pnvm_data->chunks[pnvm_data->n_chunks].data = desc->data;
pnvm_data->chunks[pnvm_data->n_chunks].len = data_len;
pnvm_data->n_chunks++;
return 0;
}
static int iwl_uefi_reduce_power_section(struct iwl_trans *trans,
const u8 *data, size_t len,
struct iwl_pnvm_image *pnvm_data)
{
const struct iwl_ucode_tlv *tlv;
IWL_DEBUG_FW(trans, "Handling REDUCE_POWER section\n");
memset(pnvm_data, 0, sizeof(*pnvm_data));
while (len >= sizeof(*tlv)) {
u32 tlv_len, tlv_type;
len -= sizeof(*tlv);
tlv = (const void *)data;
tlv_len = le32_to_cpu(tlv->length);
tlv_type = le32_to_cpu(tlv->type);
if (len < tlv_len) {
IWL_ERR(trans, "invalid TLV len: %zd/%u\n",
len, tlv_len);
return -EINVAL;
}
data += sizeof(*tlv);
switch (tlv_type) {
case IWL_UCODE_TLV_MEM_DESC:
if (iwl_uefi_handle_tlv_mem_desc(trans, data, tlv_len,
pnvm_data))
return -EINVAL;
break;
case IWL_UCODE_TLV_PNVM_SKU:
IWL_DEBUG_FW(trans,
"New REDUCE_POWER section started, stop parsing.\n");
goto done;
default:
IWL_DEBUG_FW(trans, "Found TLV 0x%0x, len %d\n",
tlv_type, tlv_len);
break;
}
len -= ALIGN(tlv_len, 4);
data += ALIGN(tlv_len, 4);
}
done:
if (!pnvm_data->n_chunks) {
IWL_DEBUG_FW(trans, "Empty REDUCE_POWER, skipping.\n");
return -ENOENT;
}
return 0;
}
int iwl_uefi_reduce_power_parse(struct iwl_trans *trans,
const u8 *data, size_t len,
struct iwl_pnvm_image *pnvm_data)
{
const struct iwl_ucode_tlv *tlv;
IWL_DEBUG_FW(trans, "Parsing REDUCE_POWER data\n");
while (len >= sizeof(*tlv)) {
u32 tlv_len, tlv_type;
len -= sizeof(*tlv);
tlv = (const void *)data;
tlv_len = le32_to_cpu(tlv->length);
tlv_type = le32_to_cpu(tlv->type);
if (len < tlv_len) {
IWL_ERR(trans, "invalid TLV len: %zd/%u\n",
len, tlv_len);
return -EINVAL;
}
if (tlv_type == IWL_UCODE_TLV_PNVM_SKU) {
const struct iwl_sku_id *sku_id =
(const void *)(data + sizeof(*tlv));
IWL_DEBUG_FW(trans,
"Got IWL_UCODE_TLV_PNVM_SKU len %d\n",
tlv_len);
IWL_DEBUG_FW(trans, "sku_id 0x%0x 0x%0x 0x%0x\n",
le32_to_cpu(sku_id->data[0]),
le32_to_cpu(sku_id->data[1]),
le32_to_cpu(sku_id->data[2]));
data += sizeof(*tlv) + ALIGN(tlv_len, 4);
len -= ALIGN(tlv_len, 4);
if (trans->sku_id[0] == le32_to_cpu(sku_id->data[0]) &&
trans->sku_id[1] == le32_to_cpu(sku_id->data[1]) &&
trans->sku_id[2] == le32_to_cpu(sku_id->data[2])) {
int ret = iwl_uefi_reduce_power_section(trans,
data, len,
pnvm_data);
if (!ret)
return 0;
} else {
IWL_DEBUG_FW(trans, "SKU ID didn't match!\n");
}
} else {
data += sizeof(*tlv) + ALIGN(tlv_len, 4);
len -= ALIGN(tlv_len, 4);
}
}
return -ENOENT;
}
u8 *iwl_uefi_get_reduced_power(struct iwl_trans *trans, size_t *len)
{
struct pnvm_sku_package *package;
unsigned long package_size;
u8 *data;
package = iwl_uefi_get_verified_variable(trans,
IWL_UEFI_REDUCED_POWER_NAME,
"Reduced Power",
sizeof(*package),
&package_size);
if (IS_ERR(package))
return ERR_CAST(package);
IWL_DEBUG_FW(trans, "rev %d, total_size %d, n_skus %d\n",
package->rev, package->total_size, package->n_skus);
*len = package_size - sizeof(*package);
data = kmemdup(package->data, *len, GFP_KERNEL);
if (!data) {
kfree(package);
return ERR_PTR(-ENOMEM);
}
kfree(package);
return data;
}
static int iwl_uefi_step_parse(struct uefi_cnv_common_step_data *common_step_data,
struct iwl_trans *trans)
{
if (common_step_data->revision != 1)
return -EINVAL;
trans->mbx_addr_0_step = (u32)common_step_data->revision |
(u32)common_step_data->cnvi_eq_channel << 8 |
(u32)common_step_data->cnvr_eq_channel << 16 |
(u32)common_step_data->radio1 << 24;
trans->mbx_addr_1_step = (u32)common_step_data->radio2;
return 0;
}
void iwl_uefi_get_step_table(struct iwl_trans *trans)
{
struct uefi_cnv_common_step_data *data;
int ret;
if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210)
return;
data = iwl_uefi_get_verified_variable(trans, IWL_UEFI_STEP_NAME,
"STEP", sizeof(*data), NULL);
if (IS_ERR(data))
return;
ret = iwl_uefi_step_parse(data, trans);
if (ret < 0)
IWL_DEBUG_FW(trans, "Cannot read STEP tables. rev is invalid\n");
kfree(data);
}
IWL_EXPORT_SYMBOL(iwl_uefi_get_step_table);
static int iwl_uefi_sgom_parse(struct uefi_cnv_wlan_sgom_data *sgom_data,
struct iwl_fw_runtime *fwrt)
{
int i, j;
if (sgom_data->revision != 1)
return -EINVAL;
memcpy(fwrt->sgom_table.offset_map, sgom_data->offset_map,
sizeof(fwrt->sgom_table.offset_map));
for (i = 0; i < MCC_TO_SAR_OFFSET_TABLE_ROW_SIZE; i++) {
for (j = 0; j < MCC_TO_SAR_OFFSET_TABLE_COL_SIZE; j++) {
/* since each byte is composed of to values, */
/* one for each letter, */
/* extract and check each of them separately */
u8 value = fwrt->sgom_table.offset_map[i][j];
u8 low = value & 0xF;
u8 high = (value & 0xF0) >> 4;
if (high > fwrt->geo_num_profiles)
high = 0;
if (low > fwrt->geo_num_profiles)
low = 0;
fwrt->sgom_table.offset_map[i][j] = (high << 4) | low;
}
}
fwrt->sgom_enabled = true;
return 0;
}
void iwl_uefi_get_sgom_table(struct iwl_trans *trans,
struct iwl_fw_runtime *fwrt)
{
struct uefi_cnv_wlan_sgom_data *data;
int ret;
if (!fwrt->geo_enabled)
return;
data = iwl_uefi_get_verified_variable(trans, IWL_UEFI_SGOM_NAME,
"SGOM", sizeof(*data), NULL);
if (IS_ERR(data))
return;
ret = iwl_uefi_sgom_parse(data, fwrt);
if (ret < 0)
IWL_DEBUG_FW(trans, "Cannot read SGOM tables. rev is invalid\n");
kfree(data);
}
IWL_EXPORT_SYMBOL(iwl_uefi_get_sgom_table);
static int iwl_uefi_uats_parse(struct uefi_cnv_wlan_uats_data *uats_data,
struct iwl_fw_runtime *fwrt)
{
if (uats_data->revision != 1)
return -EINVAL;
memcpy(fwrt->uats_table.offset_map, uats_data->offset_map,
sizeof(fwrt->uats_table.offset_map));
return 0;
}
int iwl_uefi_get_uats_table(struct iwl_trans *trans,
struct iwl_fw_runtime *fwrt)
{
struct uefi_cnv_wlan_uats_data *data;
int ret;
data = iwl_uefi_get_verified_variable(trans, IWL_UEFI_UATS_NAME,
"UATS", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
ret = iwl_uefi_uats_parse(data, fwrt);
if (ret < 0) {
IWL_DEBUG_FW(trans, "Cannot read UATS table. rev is invalid\n");
kfree(data);
return ret;
}
kfree(data);
return 0;
}
IWL_EXPORT_SYMBOL(iwl_uefi_get_uats_table);
static void iwl_uefi_set_sar_profile(struct iwl_fw_runtime *fwrt,
struct uefi_sar_profile *uefi_sar_prof,
u8 prof_index, bool enabled)
{
memcpy(&fwrt->sar_profiles[prof_index].chains, uefi_sar_prof,
sizeof(struct uefi_sar_profile));
fwrt->sar_profiles[prof_index].enabled = enabled & IWL_SAR_ENABLE_MSK;
}
int iwl_uefi_get_wrds_table(struct iwl_fw_runtime *fwrt)
{
struct uefi_cnv_var_wrds *data;
int ret = 0;
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WRDS_NAME,
"WRDS", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
if (data->revision != IWL_UEFI_WRDS_REVISION) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WRDS revision:%d\n",
data->revision);
goto out;
}
/* The profile from WRDS is officially profile 1, but goes
* into sar_profiles[0] (because we don't have a profile 0).
*/
iwl_uefi_set_sar_profile(fwrt, &data->sar_profile, 0, data->mode);
out:
kfree(data);
return ret;
}
int iwl_uefi_get_ewrd_table(struct iwl_fw_runtime *fwrt)
{
struct uefi_cnv_var_ewrd *data;
int i, ret = 0;
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_EWRD_NAME,
"EWRD", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
if (data->revision != IWL_UEFI_EWRD_REVISION) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI EWRD revision:%d\n",
data->revision);
goto out;
}
if (data->num_profiles >= BIOS_SAR_MAX_PROFILE_NUM) {
ret = -EINVAL;
goto out;
}
for (i = 0; i < data->num_profiles; i++)
/* The EWRD profiles officially go from 2 to 4, but we
* save them in sar_profiles[1-3] (because we don't
* have profile 0). So in the array we start from 1.
*/
iwl_uefi_set_sar_profile(fwrt, &data->sar_profiles[i], i + 1,
data->mode);
out:
kfree(data);
return ret;
}
int iwl_uefi_get_wgds_table(struct iwl_fw_runtime *fwrt)
{
struct uefi_cnv_var_wgds *data;
int i, ret = 0;
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WGDS_NAME,
"WGDS", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
if (data->revision != IWL_UEFI_WGDS_REVISION) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WGDS revision:%d\n",
data->revision);
goto out;
}
if (data->num_profiles < BIOS_GEO_MIN_PROFILE_NUM ||
data->num_profiles > BIOS_GEO_MAX_PROFILE_NUM) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Invalid number of profiles in WGDS: %d\n",
data->num_profiles);
goto out;
}
fwrt->geo_rev = data->revision;
for (i = 0; i < data->num_profiles; i++)
memcpy(&fwrt->geo_profiles[i], &data->geo_profiles[i],
sizeof(struct iwl_geo_profile));
fwrt->geo_num_profiles = data->num_profiles;
fwrt->geo_enabled = true;
out:
kfree(data);
return ret;
}
int iwl_uefi_get_ppag_table(struct iwl_fw_runtime *fwrt)
{
struct uefi_cnv_var_ppag *data;
int ret = 0;
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_PPAG_NAME,
"PPAG", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
if (data->revision < IWL_UEFI_MIN_PPAG_REV ||
data->revision > IWL_UEFI_MAX_PPAG_REV) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI PPAG revision:%d\n",
data->revision);
goto out;
}
fwrt->ppag_ver = data->revision;
fwrt->ppag_flags = iwl_bios_get_ppag_flags(data->ppag_modes,
fwrt->ppag_ver);
BUILD_BUG_ON(sizeof(fwrt->ppag_chains) != sizeof(data->ppag_chains));
memcpy(&fwrt->ppag_chains, &data->ppag_chains,
sizeof(data->ppag_chains));
out:
kfree(data);
return ret;
}
int iwl_uefi_get_tas_table(struct iwl_fw_runtime *fwrt,
struct iwl_tas_data *tas_data)
{
struct uefi_cnv_var_wtas *uefi_tas;
int ret = 0, enabled, i;
uefi_tas = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WTAS_NAME,
"WTAS", sizeof(*uefi_tas), NULL);
if (IS_ERR(uefi_tas))
return -EINVAL;
if (uefi_tas->revision != IWL_UEFI_WTAS_REVISION) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WTAS revision:%d\n",
uefi_tas->revision);
goto out;
}
enabled = iwl_parse_tas_selection(fwrt, tas_data,
uefi_tas->tas_selection);
if (!enabled) {
IWL_DEBUG_RADIO(fwrt, "TAS not enabled\n");
ret = 0;
goto out;
}
IWL_DEBUG_RADIO(fwrt, "Reading TAS table revision %d\n",
uefi_tas->revision);
if (uefi_tas->black_list_size > IWL_WTAS_BLACK_LIST_MAX) {
IWL_DEBUG_RADIO(fwrt, "TAS invalid array size %d\n",
uefi_tas->black_list_size);
ret = -EINVAL;
goto out;
}
tas_data->block_list_size = cpu_to_le32(uefi_tas->black_list_size);
IWL_DEBUG_RADIO(fwrt, "TAS array size %u\n", uefi_tas->black_list_size);
for (i = 0; i < uefi_tas->black_list_size; i++) {
tas_data->block_list_array[i] =
cpu_to_le32(uefi_tas->black_list[i]);
IWL_DEBUG_RADIO(fwrt, "TAS block list country %d\n",
uefi_tas->black_list[i]);
}
out:
kfree(uefi_tas);
return ret;
}
int iwl_uefi_get_pwr_limit(struct iwl_fw_runtime *fwrt,
u64 *dflt_pwr_limit)
{
struct uefi_cnv_var_splc *data;
int ret = 0;
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_SPLC_NAME,
"SPLC", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
if (data->revision != IWL_UEFI_SPLC_REVISION) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI SPLC revision:%d\n",
data->revision);
goto out;
}
*dflt_pwr_limit = data->default_pwr_limit;
out:
kfree(data);
return ret;
}
int iwl_uefi_get_mcc(struct iwl_fw_runtime *fwrt, char *mcc)
{
struct uefi_cnv_var_wrdd *data;
int ret = 0;
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WRDD_NAME,
"WRDD", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
if (data->revision != IWL_UEFI_WRDD_REVISION) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WRDD revision:%d\n",
data->revision);
goto out;
}
if (data->mcc != UEFI_MCC_CHINA) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "UEFI WRDD is supported only for CN\n");
goto out;
}
mcc[0] = (data->mcc >> 8) & 0xff;
mcc[1] = data->mcc & 0xff;
mcc[2] = '\0';
out:
kfree(data);
return ret;
}
int iwl_uefi_get_eckv(struct iwl_fw_runtime *fwrt, u32 *extl_clk)
{
struct uefi_cnv_var_eckv *data;
int ret = 0;
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_ECKV_NAME,
"ECKV", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
if (data->revision != IWL_UEFI_ECKV_REVISION) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WRDD revision:%d\n",
data->revision);
goto out;
}
*extl_clk = data->ext_clock_valid;
out:
kfree(data);
return ret;
}
int iwl_uefi_get_wbem(struct iwl_fw_runtime *fwrt, u32 *value)
{
struct uefi_cnv_wlan_wbem_data *data;
int ret = 0;
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_WBEM_NAME,
"WBEM", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
if (data->revision != IWL_UEFI_WBEM_REVISION) {
ret = -EINVAL;
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI WBEM revision:%d\n",
data->revision);
goto out;
}
*value = data->wbem_320mhz_per_mcc & IWL_UEFI_WBEM_REV0_MASK;
IWL_DEBUG_RADIO(fwrt, "Loaded WBEM config from UEFI\n");
out:
kfree(data);
return ret;
}
int iwl_uefi_get_dsm(struct iwl_fw_runtime *fwrt, enum iwl_dsm_funcs func,
u32 *value)
{
struct uefi_cnv_var_general_cfg *data;
int ret = -EINVAL;
/* Not supported function index */
if (func >= DSM_FUNC_NUM_FUNCS || func == 5)
return -EOPNOTSUPP;
data = iwl_uefi_get_verified_variable(fwrt->trans, IWL_UEFI_DSM_NAME,
"DSM", sizeof(*data), NULL);
if (IS_ERR(data))
return -EINVAL;
if (data->revision != IWL_UEFI_DSM_REVISION) {
IWL_DEBUG_RADIO(fwrt, "Unsupported UEFI DSM revision:%d\n",
data->revision);
goto out;
}
if (ARRAY_SIZE(data->functions) != UEFI_MAX_DSM_FUNCS) {
IWL_DEBUG_RADIO(fwrt, "Invalid size of DSM functions array\n");
goto out;
}
*value = data->functions[func];
ret = 0;
out:
kfree(data);
return ret;
}
|