blob: e8e066bc79589649032c8ac5bec4bc4a5ebda746 [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Karthikeyan Ramasubramanianfd5d7882019-05-29 15:09:42 -06002
Karthikeyan Ramasubramanianfd5d7882019-05-29 15:09:42 -06003#include <device/device.h>
Furquan Shaikh7cb10342020-10-03 14:49:09 -07004#include <device/pci.h>
Karthikeyan Ramasubramanianfd5d7882019-05-29 15:09:42 -06005#include <device/pci_def.h>
Furquan Shaikha1ddd2a2020-10-04 12:42:09 -07006#include <device/pci_ids.h>
Furquan Shaikh54b27162020-10-03 16:33:07 -07007#include <elog.h>
Karthikeyan Ramasubramanianafeb7b32020-07-23 00:25:25 -06008#include "chip.h"
Furquan Shaikh507a98b2020-10-27 15:28:21 -07009#include "wifi_private.h"
Tim Wawrzynczak6f73a202022-02-04 12:45:37 -070010#include "wifi.h"
Karthikeyan Ramasubramanianfd5d7882019-05-29 15:09:42 -060011
Furquan Shaikh54b27162020-10-03 16:33:07 -070012static void wifi_pci_dev_init(struct device *dev)
13{
Tim Wawrzynczak93982c32021-04-29 09:45:59 -060014 if (pci_dev_is_wake_source(PCI_BDF(dev)))
Furquan Shaikh54b27162020-10-03 16:33:07 -070015 elog_add_event_wake(ELOG_WAKE_SOURCE_PME_WIFI, 0);
16}
17
Furquan Shaikhd4367502020-10-27 18:00:46 -070018struct device_operations wifi_pcie_ops = {
Furquan Shaikh7cb10342020-10-03 14:49:09 -070019 .read_resources = pci_dev_read_resources,
20 .set_resources = pci_dev_set_resources,
21 .enable_resources = pci_dev_enable_resources,
Furquan Shaikh54b27162020-10-03 16:33:07 -070022 .init = wifi_pci_dev_init,
Furquan Shaikh7cb10342020-10-03 14:49:09 -070023 .ops_pci = &pci_dev_ops_pci,
Tim Wawrzynczak5e6fd362022-03-10 16:25:27 -070024 .scan_bus = scan_static_bus,
Furquan Shaikh5e003392020-10-04 17:34:04 -070025#if CONFIG(HAVE_ACPI_TABLES)
Furquan Shaikhd4367502020-10-27 18:00:46 -070026 .acpi_name = wifi_pcie_acpi_name,
27 .acpi_fill_ssdt = wifi_pcie_fill_ssdt,
Furquan Shaikh5e003392020-10-04 17:34:04 -070028#endif
Furquan Shaikha1ddd2a2020-10-04 12:42:09 -070029#if CONFIG(GENERATE_SMBIOS_TABLES)
Furquan Shaikhd4367502020-10-27 18:00:46 -070030 .get_smbios_data = smbios_write_wifi_pcie,
31#endif
32};
33
34struct device_operations wifi_cnvi_ops = {
35 .read_resources = noop_read_resources,
36 .set_resources = noop_set_resources,
37#if CONFIG(HAVE_ACPI_TABLES)
38 .acpi_fill_ssdt = wifi_cnvi_fill_ssdt,
39#endif
40#if CONFIG(GENERATE_SMBIOS_TABLES)
41 .get_smbios_data = smbios_write_wifi_cnvi,
Furquan Shaikha1ddd2a2020-10-04 12:42:09 -070042#endif
Karthikeyan Ramasubramanianafeb7b32020-07-23 00:25:25 -060043};
44
Tim Wawrzynczak5e6fd362022-03-10 16:25:27 -070045struct device_operations wifi_generic_ops = {
46 .read_resources = noop_read_resources,
47 .set_resources = noop_set_resources,
48};
49
Tim Wawrzynczak6f73a202022-02-04 12:45:37 -070050static bool is_cnvi(const struct device *dev)
51{
Tim Wawrzynczak6f73a202022-02-04 12:45:37 -070052 return dev && dev->path.type != DEVICE_PATH_PCI;
Tim Wawrzynczak6f73a202022-02-04 12:45:37 -070053}
54
55bool wifi_generic_cnvi_ddr_rfim_enabled(const struct device *dev)
56{
57 const struct drivers_wifi_generic_config *config;
58
59 if (!dev || !is_cnvi(dev) || !dev->chip_info)
60 return false;
61
62 config = dev->chip_info;
63 return config->enable_cnvi_ddr_rfim;
64}
65
Karthikeyan Ramasubramanianafeb7b32020-07-23 00:25:25 -060066static void wifi_generic_enable(struct device *dev)
67{
Tim Wawrzynczak6f73a202022-02-04 12:45:37 -070068#if !DEVTREE_EARLY
Tim Wawrzynczak5e6fd362022-03-10 16:25:27 -070069 const struct device *parent = dev->bus->dev;
70 if (parent && parent->ops == &wifi_pcie_ops)
71 dev->ops = &wifi_generic_ops;
Tim Wawrzynczak6f73a202022-02-04 12:45:37 -070072 else
Tim Wawrzynczak5e6fd362022-03-10 16:25:27 -070073 dev->ops = &wifi_cnvi_ops;
Tim Wawrzynczak6f73a202022-02-04 12:45:37 -070074#endif
Karthikeyan Ramasubramanianafeb7b32020-07-23 00:25:25 -060075}
76
77struct chip_operations drivers_wifi_generic_ops = {
78 CHIP_NAME("WIFI Device")
79 .enable_dev = wifi_generic_enable
80};
Furquan Shaikh8262a2c2020-10-10 19:53:00 -070081
82static const unsigned short intel_pci_device_ids[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010083 PCI_DID_1000_SERIES_WIFI,
84 PCI_DID_6005_SERIES_WIFI,
85 PCI_DID_6005_I_SERIES_WIFI,
86 PCI_DID_1030_SERIES_WIFI,
87 PCI_DID_6030_I_SERIES_WIFI,
88 PCI_DID_6030_SERIES_WIFI,
89 PCI_DID_6150_SERIES_WIFI,
90 PCI_DID_2030_SERIES_WIFI,
91 PCI_DID_2000_SERIES_WIFI,
92 PCI_DID_0135_SERIES_WIFI,
93 PCI_DID_0105_SERIES_WIFI,
94 PCI_DID_6035_SERIES_WIFI,
95 PCI_DID_5300_SERIES_WIFI,
96 PCI_DID_5100_SERIES_WIFI,
97 PCI_DID_6000_SERIES_WIFI,
98 PCI_DID_6000_I_SERIES_WIFI,
99 PCI_DID_5350_SERIES_WIFI,
100 PCI_DID_5150_SERIES_WIFI,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700101 /* Wilkins Peak 2 */
Felix Singer43b7f412022-03-07 04:34:52 +0100102 PCI_DID_WP_7260_SERIES_1_WIFI,
103 PCI_DID_WP_7260_SERIES_2_WIFI,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700104 /* Stone Peak 2 */
Felix Singer43b7f412022-03-07 04:34:52 +0100105 PCI_DID_SP_7265_SERIES_1_WIFI,
106 PCI_DID_SP_7265_SERIES_2_WIFI,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700107 /* Stone Field Peak */
Felix Singer43b7f412022-03-07 04:34:52 +0100108 PCI_DID_SFP_8260_SERIES_1_WIFI,
109 PCI_DID_SFP_8260_SERIES_2_WIFI,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700110 /* Windstorm Peak */
Felix Singer43b7f412022-03-07 04:34:52 +0100111 PCI_DID_WSP_8275_SERIES_1_WIFI,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700112 /* Thunder Peak 2 */
Felix Singer43b7f412022-03-07 04:34:52 +0100113 PCI_DID_TP_9260_SERIES_WIFI,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700114 /* Cyclone Peak */
Felix Singer43b7f412022-03-07 04:34:52 +0100115 PCI_DID_CyP_6SERIES_WIFI,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700116 /* Typhoon Peak */
Felix Singer43b7f412022-03-07 04:34:52 +0100117 PCI_DID_TyP_6SERIES_WIFI,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700118 /* Garfield Peak */
Felix Singer43b7f412022-03-07 04:34:52 +0100119 PCI_DID_GrP_6SERIES_1_WIFI,
120 PCI_DID_GrP_6SERIES_2_WIFI,
Bora Guvendikf1186562022-05-02 11:05:13 -0700121 PCI_DID_GrP_6SERIES_3_WIFI,
Subrata Banik510a55d2022-05-23 13:47:50 +0530122 /* Typhoon Peak 2 */
123 PCI_DID_TyP2_6SERIES_1_WIFI,
124 PCI_DID_TyP2_6SERIES_2_WIFI,
125 PCI_DID_TyP2_6SERIES_3_WIFI,
126 PCI_DID_TyP2_6SERIES_4_WIFI,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700127 0
128};
129
130/*
131 * The PCI driver is retained for backward compatibility with boards that never utilized the
132 * chip driver to support Intel WiFi device. For these devices, the PCI driver helps perform the
133 * same operations as above (except exposing the wake property) by utilizing the same
134 * `wifi_generic_ops`.
135 */
136static const struct pci_driver intel_wifi_pci_driver __pci_driver = {
Furquan Shaikhd4367502020-10-27 18:00:46 -0700137 .ops = &wifi_pcie_ops,
Felix Singer43b7f412022-03-07 04:34:52 +0100138 .vendor = PCI_VID_INTEL,
Furquan Shaikh8262a2c2020-10-10 19:53:00 -0700139 .devices = intel_pci_device_ids,
140};