acpi: Add IORT helper functions
[coreboot2.git] / src / drivers / wifi / generic / generic.c
blob283b45a5d1b0d6412b14a05f9b8f38b11dddb11a
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <device/device.h>
4 #include <device/pci.h>
5 #include <device/pci_ids.h>
6 #include <elog.h>
7 #include "chip.h"
8 #include "wifi_private.h"
9 #include "wifi.h"
11 static void wifi_pci_dev_init(struct device *dev)
13 if (pci_dev_is_wake_source(PCI_BDF(dev)))
14 elog_add_event_wake(ELOG_WAKE_SOURCE_PME_WIFI, 0);
17 struct device_operations wifi_pcie_ops = {
18 .read_resources = pci_dev_read_resources,
19 .set_resources = pci_dev_set_resources,
20 .enable_resources = pci_dev_enable_resources,
21 .init = wifi_pci_dev_init,
22 .ops_pci = &pci_dev_ops_pci,
23 #if CONFIG(HAVE_ACPI_TABLES)
24 .acpi_name = wifi_pcie_acpi_name,
25 .acpi_fill_ssdt = wifi_pcie_fill_ssdt,
26 #endif
27 #if CONFIG(GENERATE_SMBIOS_TABLES)
28 .get_smbios_data = smbios_write_wifi_pcie,
29 #endif
32 struct device_operations wifi_cnvi_ops = {
33 .read_resources = noop_read_resources,
34 .set_resources = noop_set_resources,
35 #if CONFIG(HAVE_ACPI_TABLES)
36 .acpi_fill_ssdt = wifi_cnvi_fill_ssdt,
37 #endif
38 #if CONFIG(GENERATE_SMBIOS_TABLES)
39 .get_smbios_data = smbios_write_wifi_cnvi,
40 #endif
43 static bool is_cnvi(const struct device *dev)
45 return dev && dev->path.type != DEVICE_PATH_PCI;
48 bool wifi_generic_cnvi_ddr_rfim_enabled(const struct device *dev)
50 const struct drivers_wifi_generic_config *config;
52 if (!dev || !is_cnvi(dev) || !dev->chip_info)
53 return false;
55 config = dev->chip_info;
56 return config->enable_cnvi_ddr_rfim;
59 static void wifi_generic_enable(struct device *dev)
61 #if !DEVTREE_EARLY
62 if (is_cnvi(dev))
63 dev->ops = &wifi_cnvi_ops;
64 else
65 dev->ops = &wifi_pcie_ops;
66 #endif
69 struct chip_operations drivers_wifi_generic_ops = {
70 .name = "WIFI Device",
71 .enable_dev = wifi_generic_enable
74 static const unsigned short intel_pci_device_ids[] = {
75 PCI_DID_1000_SERIES_WIFI,
76 PCI_DID_6005_SERIES_WIFI,
77 PCI_DID_6005_I_SERIES_WIFI,
78 PCI_DID_1030_SERIES_WIFI,
79 PCI_DID_6030_I_SERIES_WIFI,
80 PCI_DID_6030_SERIES_WIFI,
81 PCI_DID_6150_SERIES_WIFI,
82 PCI_DID_2030_SERIES_WIFI,
83 PCI_DID_2000_SERIES_WIFI,
84 PCI_DID_0135_SERIES_WIFI,
85 PCI_DID_0105_SERIES_WIFI,
86 PCI_DID_6035_SERIES_WIFI,
87 PCI_DID_5300_SERIES_WIFI,
88 PCI_DID_5100_SERIES_WIFI,
89 PCI_DID_6000_SERIES_WIFI,
90 PCI_DID_6000_I_SERIES_WIFI,
91 PCI_DID_5350_SERIES_WIFI,
92 PCI_DID_5150_SERIES_WIFI,
93 /* Wilkins Peak 2 */
94 PCI_DID_WP_7260_SERIES_1_WIFI,
95 PCI_DID_WP_7260_SERIES_2_WIFI,
96 /* Stone Peak 2 */
97 PCI_DID_SP_7265_SERIES_1_WIFI,
98 PCI_DID_SP_7265_SERIES_2_WIFI,
99 /* Stone Field Peak */
100 PCI_DID_SFP_8260_SERIES_1_WIFI,
101 PCI_DID_SFP_8260_SERIES_2_WIFI,
102 /* Windstorm Peak */
103 PCI_DID_WSP_8275_SERIES_1_WIFI,
104 /* Thunder Peak 2 */
105 PCI_DID_TP_9260_SERIES_WIFI,
106 /* Cyclone Peak (CyP) */
107 PCI_DID_CP_6SERIES_WIFI,
108 /* Typhoon Peak (TyP) */
109 PCI_DID_TP_6SERIES_WIFI,
110 /* Misty Peak (MtP) */
111 PCI_DID_MP_7SERIES_WIFI,
116 * The PCI driver is retained for backward compatibility with boards that never utilized the
117 * chip driver to support Intel WiFi device. For these devices, the PCI driver helps perform the
118 * same operations as above (except exposing the wake property) by utilizing the same
119 * `wifi_generic_ops`.
121 static const struct pci_driver intel_wifi_pci_driver __pci_driver = {
122 .ops = &wifi_pcie_ops,
123 .vendor = PCI_VID_INTEL,
124 .devices = intel_pci_device_ids,