From 507a98b689975561b54e5e156d624f7dcad6d393 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Tue, 27 Oct 2020 15:28:21 -0700 Subject: drivers/wifi/generic: Move SMBIOS functions to a separate file This change reorganizes the WiFi generic driver to move the SMBIOS functions to a separate file. This change is done to reduce the noise in generic.c file and improve readability of the file. Change-Id: I38ed46f5ae1594945d2078b00e8315d9234f36d7 Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/c/coreboot/+/46859 Tested-by: build bot (Jenkins) Reviewed-by: Duncan Laurie --- src/drivers/wifi/generic/Makefile.inc | 8 ++++++- src/drivers/wifi/generic/generic.c | 39 +----------------------------- src/drivers/wifi/generic/smbios.c | 42 +++++++++++++++++++++++++++++++++ src/drivers/wifi/generic/wifi_private.h | 8 +++++++ 4 files changed, 58 insertions(+), 39 deletions(-) create mode 100644 src/drivers/wifi/generic/smbios.c create mode 100644 src/drivers/wifi/generic/wifi_private.h (limited to 'src') diff --git a/src/drivers/wifi/generic/Makefile.inc b/src/drivers/wifi/generic/Makefile.inc index 407041afce..3683c3eaad 100644 --- a/src/drivers/wifi/generic/Makefile.inc +++ b/src/drivers/wifi/generic/Makefile.inc @@ -1,5 +1,11 @@ -ramstage-$(CONFIG_DRIVERS_WIFI_GENERIC) += generic.c + +ifeq ($(CONFIG_DRIVERS_WIFI_GENERIC),y) + +ramstage-y += generic.c +ramstage-$(CONFIG_GENERATE_SMBIOS_TABLES) += smbios.c cbfs-files-$(CONFIG_WIFI_SAR_CBFS) += wifi_sar_defaults.hex wifi_sar_defaults.hex-file := $(call strip_quotes,$(CONFIG_WIFI_SAR_CBFS_FILEPATH)) wifi_sar_defaults.hex-type := raw + +endif diff --git a/src/drivers/wifi/generic/generic.c b/src/drivers/wifi/generic/generic.c index 6ffa7f1f85..56944e61da 100644 --- a/src/drivers/wifi/generic/generic.c +++ b/src/drivers/wifi/generic/generic.c @@ -9,10 +9,9 @@ #include #include #include -#include -#include #include #include "chip.h" +#include "wifi_private.h" /* WRDS Spec Revision */ #define WRDS_REVISION 0x0 @@ -243,42 +242,6 @@ static void wifi_pci_dev_init(struct device *dev) 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, diff --git a/src/drivers/wifi/generic/smbios.c b/src/drivers/wifi/generic/smbios.c new file mode 100644 index 0000000000..0c1b976f00 --- /dev/null +++ b/src/drivers/wifi/generic/smbios.c @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include + +#include "wifi_private.h" + +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; +} + +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; +} diff --git a/src/drivers/wifi/generic/wifi_private.h b/src/drivers/wifi/generic/wifi_private.h new file mode 100644 index 0000000000..11b9198320 --- /dev/null +++ b/src/drivers/wifi/generic/wifi_private.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef _WIFI_GENERIC_PRIVATE_H_ +#define _WIFI_GENERIC_PRIVATE_H_ + +int smbios_write_wifi(struct device *dev, int *handle, unsigned long *current); + +#endif -- cgit v1.2.3