Furquan Shaikh submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Michael Niewöhner: Looks good to me, approved
drivers/wifi/generic: Add support for generating SMBIOS data

This change adds support in generic WiFi driver in coreboot to
generate SMBIOS data for the WiFi device. Currently, this is used only
for Intel WiFi devices and the function is copied over from Intel WiFi
driver in coreboot. This change is done in preparation for getting rid
of the separate chip driver for Intel WiFi in coreboot.

BUG=b:169802515
BRANCH=zork

Change-Id: If3c056718bdc57f6976ce8e3f8acc7665ec3ccd7
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/46034
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Michael Niewöhner <foss@mniewoehner.de>
---
M src/drivers/wifi/generic/generic.c
1 file changed, 41 insertions(+), 0 deletions(-)

diff --git a/src/drivers/wifi/generic/generic.c b/src/drivers/wifi/generic/generic.c
index 0705731..e551bf3 100644
--- a/src/drivers/wifi/generic/generic.c
+++ b/src/drivers/wifi/generic/generic.c
@@ -6,8 +6,10 @@
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_def.h>
+#include <device/pci_ids.h>
#include <elog.h>
#include <sar.h>
+#include <smbios.h>
#include <string.h>
#include <wrdd.h>
#include "chip.h"
@@ -244,6 +246,42 @@
elog_add_event_wake(ELOG_WAKE_SOURCE_PME_WIFI, 0);
}

+#if CONFIG(GENERATE_SMBIOS_TABLES)
+static int smbios_write_intel_wifi(struct device *dev, int *handle, unsigned long *current)
+{
+ struct smbios_type_intel_wifi {
+ u8 type;
+ u8 length;
+ u16 handle;
+ u8 str;
+ u8 eos[2];
+ } __packed;
+
+ struct smbios_type_intel_wifi *t = (struct smbios_type_intel_wifi *)*current;
+ int len = sizeof(struct smbios_type_intel_wifi);
+
+ memset(t, 0, sizeof(struct smbios_type_intel_wifi));
+ t->type = 0x85;
+ t->length = len - 2;
+ t->handle = *handle;
+ /* Intel wifi driver expects this string to be in the table 0x85. */
+ t->str = smbios_add_string(t->eos, "KHOIHGIUCCHHII");
+
+ len = t->length + smbios_string_table_len(t->eos);
+ *current += len;
+ *handle += 1;
+ return len;
+}
+
+static int smbios_write_wifi(struct device *dev, int *handle, unsigned long *current)
+{
+ if (dev->vendor == PCI_VENDOR_ID_INTEL)
+ return smbios_write_intel_wifi(dev, handle, current);
+
+ return 0;
+}
+#endif
+
struct device_operations wifi_generic_ops = {
.read_resources = pci_dev_read_resources,
.set_resources = pci_dev_set_resources,
@@ -252,6 +290,9 @@
.ops_pci = &pci_dev_ops_pci,
.acpi_name = wifi_generic_acpi_name,
.acpi_fill_ssdt = wifi_generic_fill_ssdt_generator,
+#if CONFIG(GENERATE_SMBIOS_TABLES)
+ .get_smbios_data = smbios_write_wifi,
+#endif
};

static void wifi_generic_enable(struct device *dev)

To view, visit change 46034. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: If3c056718bdc57f6976ce8e3f8acc7665ec3ccd7
Gerrit-Change-Number: 46034
Gerrit-PatchSet: 5
Gerrit-Owner: Furquan Shaikh <furquan@google.com>
Gerrit-Reviewer: Duncan Laurie <dlaurie@chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan@google.com>
Gerrit-Reviewer: Karthik Ramasubramanian <kramasub@google.com>
Gerrit-Reviewer: Michael Niewöhner <foss@mniewoehner.de>
Gerrit-Reviewer: Rob Barnes <robbarnes@google.com>
Gerrit-Reviewer: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-MessageType: merged