Files
system76-coreboot/src/vendorcode/google/chromeos/sar.c
Furquan Shaikh eb876a5830 vc/google/chromeos: Deprecate support for SAR tables in VPD
SAR table in VPD has been deprecated for Chrome OS platforms for > 1
year now. All new Chrome OS platforms have switched to using SAR
tables from CBFS.

This change drops the support for SAR table in VPD from coreboot to
align with the factory changes. `get_wifi_sar_limits()` is thus
updated to look for SAR file in CBFS only.

Anyone building ToT coreboot for an already released Chrome OS
platform with SAR table in VPD will have to extract the "wifi_sar" key
from VPD and add it as a file to CBFS using following steps:

 - On DUT, read SAR value using `vpd -i RO_VPD -g wifi_sar`
 - In coreboot repo, generate CBFS SAR file using:
   `echo ${SAR_STRING} > site-local/${BOARD}-sar.hex`
 - Add to site-local/Kconfig:
   ```
   config WIFI_SAR_CBFS_FILEPATH
     string
     default "site-local/${BOARD}-sar.hex"
   ```

BUG=b:173465272

Change-Id: I21d190dcc9f3554fab6e21b4498e7588a32bb1f0
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/51483
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
2021-03-17 07:55:33 +00:00

93 lines
2.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* SPDX-License-Identifier: GPL-2.0-only */
#include <cbfs.h>
#include <console/console.h>
#include <drivers/vpd/vpd.h>
#include <lib.h>
#include <sar.h>
#include <stdlib.h>
#include <string.h>
#include <types.h>
#define WIFI_SAR_CBFS_FILENAME "wifi_sar_defaults.hex"
/*
* Retrieve WiFi SAR limits data from CBFS and decode it
* WiFi SAR data is expected in the format: [<WRDD><EWRD>][WGDS]
*
* [<WRDD><EWRD>] = NUM_SAR_LIMITS * BYTES_PER_SAR_LIMIT bytes.
* [WGDS]=[WGDS_VERSION][WGDS_DATA]
*
* For [WGDS_VERSION] 0x00,
* [WGDS_DATA] = [GROUP#0][GROUP#1][GROUP#2]
*
* [GROUP#<i>] =
* [2.4Ghz Max Allowed][2.4Ghz Chain A Offset]
* [2.4Ghz Chain B Offset][5Ghz Max Allowed]
* [5Ghz Chain A Offset][5Ghz Chain B Offset]
*
* [GROUP#0] is for FCC
* [GROUP#1] is for Europe/Japan
* [GROUP#2] is for ROW
*/
int get_wifi_sar_limits(struct wifi_sar_limits *sar_limits)
{
const char *filename;
size_t sar_str_len, sar_bin_len;
char *sar_str;
int ret = -1;
/*
* If GEO_SAR_ENABLE is not selected, SAR file does not contain
* delta table settings.
*/
if (CONFIG(GEO_SAR_ENABLE))
sar_bin_len = sizeof(struct wifi_sar_limits);
else
sar_bin_len = sizeof(struct wifi_sar_limits) -
sizeof(struct wifi_sar_delta_table);
/*
* Each hex digit is represented as a character in CBFS SAR file. Thus,
* the SAR file is double the size of its binary buffer equivalent.
* Hence, the buffer size allocated for SAR file is:
* `2 * sar_bin_len + 1`
* 1 additional byte is allocated to store the terminating '\0'.
*/
sar_str_len = 2 * sar_bin_len + 1;
sar_str = malloc(sar_str_len);
if (!sar_str) {
printk(BIOS_ERR, "Failed to allocate space for SAR string!\n");
return ret;
}
printk(BIOS_DEBUG, "Checking CBFS for default SAR values\n");
filename = get_wifi_sar_cbfs_filename();
if (filename == NULL)
filename = WIFI_SAR_CBFS_FILENAME;
if (cbfs_load(filename, sar_str, sar_str_len) != sar_str_len) {
printk(BIOS_ERR, "%s has bad len in CBFS\n", filename);
goto done;
}
memset(sar_limits, 0, sizeof(*sar_limits));
if (hexstrtobin(sar_str, (uint8_t *)sar_limits, sar_bin_len) != sar_bin_len) {
printk(BIOS_ERR, "Error: wifi_sar contains non-hex value!\n");
goto done;
}
ret = 0;
done:
free(sar_str);
return ret;
}
__weak
const char *get_wifi_sar_cbfs_filename(void)
{
return WIFI_SAR_CBFS_FILENAME;
}