summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorKarthikeyan Ramasubramanian <kramasub@google.com>2020-07-23 00:25:25 -0600
committerPatrick Georgi <pgeorgi@google.com>2020-07-28 16:07:47 +0000
commitafeb7b3f6864f74bbcf22c8744998e55db219be2 (patch)
treea6b50fad0064ccccf26691e3b947cd86cbd7a812 /src/drivers
parentff7b9970f422735c9289768b0572b6ee49f68dfb (diff)
downloadcoreboot-afeb7b3f6864f74bbcf22c8744998e55db219be2.tar.xz
drivers/wifi: Adapt generic wifi driver into a chip driver
Re-organize the existing generic wifi driver into a generic wifi chip driver. This allows generic wifi chip information to be added to the devicetree. BUG=None TEST=./util/abuild/abuild Change-Id: I63f957a008ecf4a6a810c2a135ed62ea81a79fe0 Signed-off-by: Karthikeyan Ramasubramanian <kramasub@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/43768 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/intel/wifi/Kconfig2
-rw-r--r--src/drivers/intel/wifi/wifi.c8
-rw-r--r--src/drivers/wifi/Makefile.inc1
-rw-r--r--src/drivers/wifi/generic/Kconfig (renamed from src/drivers/wifi/Kconfig)6
-rw-r--r--src/drivers/wifi/generic/Makefile.inc1
-rw-r--r--src/drivers/wifi/generic/chip.h (renamed from src/drivers/wifi/generic_wifi.h)20
-rw-r--r--src/drivers/wifi/generic/generic.c (renamed from src/drivers/wifi/generic.c)35
7 files changed, 50 insertions, 23 deletions
diff --git a/src/drivers/intel/wifi/Kconfig b/src/drivers/intel/wifi/Kconfig
index fb60c6fbe1..83df82233e 100644
--- a/src/drivers/intel/wifi/Kconfig
+++ b/src/drivers/intel/wifi/Kconfig
@@ -2,7 +2,7 @@ config DRIVERS_INTEL_WIFI
bool "Support Intel PCI-e WiFi adapters"
depends on PCI
default y if PCIEXP_PLUGIN_SUPPORT
- select DRIVERS_GENERIC_WIFI if HAVE_ACPI_TABLES
+ select DRIVERS_WIFI_GENERIC if HAVE_ACPI_TABLES
help
When enabled, add identifiers in ACPI and SMBIOS tables to
make OS drivers work with certain Intel PCI-e WiFi chipsets.
diff --git a/src/drivers/intel/wifi/wifi.c b/src/drivers/intel/wifi/wifi.c
index 9fcd7ba8af..0ad0e1c4a1 100644
--- a/src/drivers/intel/wifi/wifi.c
+++ b/src/drivers/intel/wifi/wifi.c
@@ -8,7 +8,7 @@
#include <smbios.h>
#include <string.h>
#include "chip.h"
-#include "drivers/wifi/generic_wifi.h"
+#include "drivers/wifi/generic/chip.h"
#define PMCS_DR 0xcc
#define PME_STS (1 << 15)
@@ -50,14 +50,14 @@ static int smbios_write_wifi(struct device *dev, int *handle,
static void intel_wifi_fill_ssdt(const struct device *dev)
{
struct drivers_intel_wifi_config *config = dev->chip_info;
- struct generic_wifi_config generic_config;
+ struct drivers_wifi_generic_config generic_config;
if (config) {
generic_config.wake = config->wake;
/* By default, all intel wifi chips wake from S3 */
generic_config.maxsleep = 3;
}
- generic_wifi_fill_ssdt(dev, config ? &generic_config : NULL);
+ wifi_generic_fill_ssdt(dev, config ? &generic_config : NULL);
}
#endif
@@ -83,7 +83,7 @@ struct device_operations device_ops = {
#endif
.ops_pci = &pci_dev_ops_pci,
#if CONFIG(HAVE_ACPI_TABLES)
- .acpi_name = generic_wifi_acpi_name,
+ .acpi_name = wifi_generic_acpi_name,
.acpi_fill_ssdt = intel_wifi_fill_ssdt,
#endif
};
diff --git a/src/drivers/wifi/Makefile.inc b/src/drivers/wifi/Makefile.inc
deleted file mode 100644
index d37015c7d3..0000000000
--- a/src/drivers/wifi/Makefile.inc
+++ /dev/null
@@ -1 +0,0 @@
-ramstage-$(CONFIG_DRIVERS_GENERIC_WIFI) += generic.c
diff --git a/src/drivers/wifi/Kconfig b/src/drivers/wifi/generic/Kconfig
index 11ac7c1464..049a952e71 100644
--- a/src/drivers/wifi/Kconfig
+++ b/src/drivers/wifi/generic/Kconfig
@@ -1,4 +1,4 @@
-config DRIVERS_GENERIC_WIFI
+config DRIVERS_WIFI_GENERIC
bool
default n
depends on HAVE_ACPI_TABLES
@@ -6,7 +6,7 @@ config DRIVERS_GENERIC_WIFI
When enabled, add identifiers in ACPI tables that are common
to WiFi chipsets from multiple vendors.
-if DRIVERS_GENERIC_WIFI
+if DRIVERS_WIFI_GENERIC
config USE_SAR
bool
@@ -54,4 +54,4 @@ config DSAR_SET_NUM
help
There can be up to 3 optional SAR table sets.
-endif # DRIVERS_GENERIC_WIFI
+endif # DRIVERS_WIFI_GENERIC
diff --git a/src/drivers/wifi/generic/Makefile.inc b/src/drivers/wifi/generic/Makefile.inc
new file mode 100644
index 0000000000..6240c7146a
--- /dev/null
+++ b/src/drivers/wifi/generic/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_WIFI_GENERIC) += generic.c
diff --git a/src/drivers/wifi/generic_wifi.h b/src/drivers/wifi/generic/chip.h
index 57209e9547..fe3a1d1b99 100644
--- a/src/drivers/wifi/generic_wifi.h
+++ b/src/drivers/wifi/generic/chip.h
@@ -1,31 +1,31 @@
/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef _GENERIC_WIFI_H_
-#define _GENERIC_WIFI_H_
+#ifndef _WIFI_GENERIC_H_
+#define _WIFI_GENERIC_H_
/**
- * struct generic_wifi_config - Data structure to contain common wifi config
+ * struct drivers_wifi_generic_config - Data structure to contain generic wifi config
* @wake: Wake pin for ACPI _PRW
* @maxsleep: Maximum sleep state to wake from
*/
-struct generic_wifi_config {
+struct drivers_wifi_generic_config {
unsigned int wake;
unsigned int maxsleep;
};
/**
- * wifi_fill_ssdt() - Fill ACPI SSDT table for WiFi controller
+ * wifi_generic_fill_ssdt() - Fill ACPI SSDT table for WiFi controller
* @dev: Device structure corresponding to WiFi controller.
- * @config: Common wifi config required to fill ACPI SSDT table.
+ * @config: Generic wifi config required to fill ACPI SSDT table.
*
* This function implements common device operation to help fill ACPI SSDT
* table for WiFi controller.
*/
-void generic_wifi_fill_ssdt(const struct device *dev,
- const struct generic_wifi_config *config);
+void wifi_generic_fill_ssdt(const struct device *dev,
+ const struct drivers_wifi_generic_config *config);
/**
- * wifi_acpi_name() - Get ACPI name for WiFi controller
+ * wifi_generic_acpi_name() - Get ACPI name for WiFi controller
* @dev: Device structure corresponding to WiFi controller.
*
* This function implements common device operation to get the ACPI name for
@@ -33,6 +33,6 @@ void generic_wifi_fill_ssdt(const struct device *dev,
*
* Return: string representing the ACPI name for WiFi controller.
*/
-const char *generic_wifi_acpi_name(const struct device *dev);
+const char *wifi_generic_acpi_name(const struct device *dev);
#endif /* _GENERIC_WIFI_H_ */
diff --git a/src/drivers/wifi/generic.c b/src/drivers/wifi/generic/generic.c
index 8858fab097..00a2f583fe 100644
--- a/src/drivers/wifi/generic.c
+++ b/src/drivers/wifi/generic/generic.c
@@ -8,7 +8,7 @@
#include <sar.h>
#include <string.h>
#include <wrdd.h>
-#include "generic_wifi.h"
+#include "chip.h"
/* WRDS Spec Revision */
#define WRDS_REVISION 0x0
@@ -159,8 +159,8 @@ static void emit_sar_acpi_structures(void)
acpigen_pop_len();
}
-void generic_wifi_fill_ssdt(const struct device *dev,
- const struct generic_wifi_config *config)
+void wifi_generic_fill_ssdt(const struct device *dev,
+ const struct drivers_wifi_generic_config *config)
{
const char *path;
u32 address;
@@ -222,7 +222,7 @@ void generic_wifi_fill_ssdt(const struct device *dev,
dev->chip_ops ? dev->chip_ops->name : "", dev_path(dev));
}
-const char *generic_wifi_acpi_name(const struct device *dev)
+const char *wifi_generic_acpi_name(const struct device *dev)
{
static char wifi_acpi_name[WIFI_ACPI_NAME_MAX_LEN];
@@ -231,3 +231,30 @@ const char *generic_wifi_acpi_name(const struct device *dev)
(dev_path_encode(dev) & 0xff));
return wifi_acpi_name;
}
+
+static void wifi_generic_fill_ssdt_generator(const struct device *dev)
+{
+ wifi_generic_fill_ssdt(dev, dev->chip_info);
+}
+
+static struct device_operations wifi_generic_ops = {
+ .read_resources = noop_read_resources,
+ .set_resources = noop_set_resources,
+ .acpi_name = wifi_generic_acpi_name,
+ .acpi_fill_ssdt = wifi_generic_fill_ssdt_generator,
+};
+
+static void wifi_generic_enable(struct device *dev)
+{
+ struct drivers_wifi_generic_config *config = dev ? dev->chip_info : NULL;
+
+ if (!config)
+ return;
+
+ dev->ops = &wifi_generic_ops;
+}
+
+struct chip_operations drivers_wifi_generic_ops = {
+ CHIP_NAME("WIFI Device")
+ .enable_dev = wifi_generic_enable
+};