UPSTREAM: vendorcode/google: support multiple SAR filenames

Using a fixed filename only allows for one SAR configuration to be
checked into CBFS. However, we have devices with shared firmware that
would desire separate SAR configurations. This change allows boards to
define a function to select one of multiple files stored in CBFS to be
used.

BUG=b:120958726, b:173465272
BRANCH=octopus
TEST=build

Signed-off-by: Justin TerAvest <teravest@chromium.org>

Change-Id: I6bfba61ae89e13c939f6228c65447cb6ce23c86e
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Original-Commit-Id: c650d6c5bb3bdc864e2b8b1051c1beffb45d2d6a
Original-Change-Id: Ib852aaaff39f1e9149fa43bf8dc25b2400737ea5
Original-Reviewed-on: https://review.coreboot.org/c/30222
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1382178
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
(cherry picked from commit 385af0cebb672a4b3676cd268c3268720b60a432)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/coreboot/+/2738786
Reviewed-by: Zhuohao Lee <zhuohao@chromium.org>
Commit-Queue: Zhuohao Lee <zhuohao@chromium.org>
Tested-by: Zhuohao Lee <zhuohao@chromium.org>
diff --git a/src/include/sar.h b/src/include/sar.h
index 9da4dd9..527a51a 100644
--- a/src/include/sar.h
+++ b/src/include/sar.h
@@ -54,4 +54,6 @@
  */
 int get_wifi_sar_limits(struct wifi_sar_limits *sar_limits);
 
+const char *get_wifi_sar_cbfs_filename(void);
+
 #endif /* _SAR_H_ */
diff --git a/src/vendorcode/google/chromeos/sar.c b/src/vendorcode/google/chromeos/sar.c
index 3adfe11..3ab0f29 100644
--- a/src/vendorcode/google/chromeos/sar.c
+++ b/src/vendorcode/google/chromeos/sar.c
@@ -26,7 +26,10 @@
 
 static int load_sar_file_from_cbfs(void *buf, size_t buffer_size)
 {
-	return cbfs_boot_load_file(WIFI_SAR_CBFS_FILENAME, buf,
+	const char *filename = get_wifi_sar_cbfs_filename();
+	if (filename == NULL)
+		filename = WIFI_SAR_CBFS_FILENAME;
+	return cbfs_boot_load_file(filename, buf,
 			buffer_size, CBFS_TYPE_RAW);
 }
 
@@ -121,3 +124,9 @@
 	memcpy(sar_limits, bin_buffer, bin_buff_adjusted_size);
 	return 0;
 }
+
+__weak
+const char *get_wifi_sar_cbfs_filename(void)
+{
+	return NULL;
+}