Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Karthikeyan Ramasubramanian | fd5d788 | 2019-05-29 15:09:42 -0600 | [diff] [blame] | 2 | |
Karthikeyan Ramasubramanian | fd5d788 | 2019-05-29 15:09:42 -0600 | [diff] [blame] | 3 | #include <device/device.h> |
Furquan Shaikh | 7cb1034 | 2020-10-03 14:49:09 -0700 | [diff] [blame] | 4 | #include <device/pci.h> |
Karthikeyan Ramasubramanian | fd5d788 | 2019-05-29 15:09:42 -0600 | [diff] [blame] | 5 | #include <device/pci_def.h> |
Furquan Shaikh | a1ddd2a | 2020-10-04 12:42:09 -0700 | [diff] [blame] | 6 | #include <device/pci_ids.h> |
Furquan Shaikh | 54b2716 | 2020-10-03 16:33:07 -0700 | [diff] [blame] | 7 | #include <elog.h> |
Karthikeyan Ramasubramanian | afeb7b3 | 2020-07-23 00:25:25 -0600 | [diff] [blame] | 8 | #include "chip.h" |
Furquan Shaikh | 507a98b | 2020-10-27 15:28:21 -0700 | [diff] [blame] | 9 | #include "wifi_private.h" |
Karthikeyan Ramasubramanian | fd5d788 | 2019-05-29 15:09:42 -0600 | [diff] [blame] | 10 | |
Furquan Shaikh | 54b2716 | 2020-10-03 16:33:07 -0700 | [diff] [blame] | 11 | static void wifi_pci_dev_init(struct device *dev) |
| 12 | { |
Tim Wawrzynczak | 93982c3 | 2021-04-29 09:45:59 -0600 | [diff] [blame] | 13 | if (pci_dev_is_wake_source(PCI_BDF(dev))) |
Furquan Shaikh | 54b2716 | 2020-10-03 16:33:07 -0700 | [diff] [blame] | 14 | elog_add_event_wake(ELOG_WAKE_SOURCE_PME_WIFI, 0); |
| 15 | } |
| 16 | |
Furquan Shaikh | d436750 | 2020-10-27 18:00:46 -0700 | [diff] [blame] | 17 | struct device_operations wifi_pcie_ops = { |
Furquan Shaikh | 7cb1034 | 2020-10-03 14:49:09 -0700 | [diff] [blame] | 18 | .read_resources = pci_dev_read_resources, |
| 19 | .set_resources = pci_dev_set_resources, |
| 20 | .enable_resources = pci_dev_enable_resources, |
Furquan Shaikh | 54b2716 | 2020-10-03 16:33:07 -0700 | [diff] [blame] | 21 | .init = wifi_pci_dev_init, |
Furquan Shaikh | 7cb1034 | 2020-10-03 14:49:09 -0700 | [diff] [blame] | 22 | .ops_pci = &pci_dev_ops_pci, |
Furquan Shaikh | 5e00339 | 2020-10-04 17:34:04 -0700 | [diff] [blame] | 23 | #if CONFIG(HAVE_ACPI_TABLES) |
Furquan Shaikh | d436750 | 2020-10-27 18:00:46 -0700 | [diff] [blame] | 24 | .acpi_name = wifi_pcie_acpi_name, |
| 25 | .acpi_fill_ssdt = wifi_pcie_fill_ssdt, |
Furquan Shaikh | 5e00339 | 2020-10-04 17:34:04 -0700 | [diff] [blame] | 26 | #endif |
Furquan Shaikh | a1ddd2a | 2020-10-04 12:42:09 -0700 | [diff] [blame] | 27 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
Furquan Shaikh | d436750 | 2020-10-27 18:00:46 -0700 | [diff] [blame] | 28 | .get_smbios_data = smbios_write_wifi_pcie, |
| 29 | #endif |
| 30 | }; |
| 31 | |
| 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, |
Furquan Shaikh | a1ddd2a | 2020-10-04 12:42:09 -0700 | [diff] [blame] | 40 | #endif |
Karthikeyan Ramasubramanian | afeb7b3 | 2020-07-23 00:25:25 -0600 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | static void wifi_generic_enable(struct device *dev) |
| 44 | { |
| 45 | struct drivers_wifi_generic_config *config = dev ? dev->chip_info : NULL; |
| 46 | |
| 47 | if (!config) |
| 48 | return; |
| 49 | |
Furquan Shaikh | d436750 | 2020-10-27 18:00:46 -0700 | [diff] [blame] | 50 | if (dev->path.type == DEVICE_PATH_PCI) |
| 51 | dev->ops = &wifi_pcie_ops; |
| 52 | else |
| 53 | dev->ops = &wifi_cnvi_ops; |
Karthikeyan Ramasubramanian | afeb7b3 | 2020-07-23 00:25:25 -0600 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | struct chip_operations drivers_wifi_generic_ops = { |
| 57 | CHIP_NAME("WIFI Device") |
| 58 | .enable_dev = wifi_generic_enable |
| 59 | }; |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 60 | |
| 61 | static const unsigned short intel_pci_device_ids[] = { |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 62 | PCI_DID_1000_SERIES_WIFI, |
| 63 | PCI_DID_6005_SERIES_WIFI, |
| 64 | PCI_DID_6005_I_SERIES_WIFI, |
| 65 | PCI_DID_1030_SERIES_WIFI, |
| 66 | PCI_DID_6030_I_SERIES_WIFI, |
| 67 | PCI_DID_6030_SERIES_WIFI, |
| 68 | PCI_DID_6150_SERIES_WIFI, |
| 69 | PCI_DID_2030_SERIES_WIFI, |
| 70 | PCI_DID_2000_SERIES_WIFI, |
| 71 | PCI_DID_0135_SERIES_WIFI, |
| 72 | PCI_DID_0105_SERIES_WIFI, |
| 73 | PCI_DID_6035_SERIES_WIFI, |
| 74 | PCI_DID_5300_SERIES_WIFI, |
| 75 | PCI_DID_5100_SERIES_WIFI, |
| 76 | PCI_DID_6000_SERIES_WIFI, |
| 77 | PCI_DID_6000_I_SERIES_WIFI, |
| 78 | PCI_DID_5350_SERIES_WIFI, |
| 79 | PCI_DID_5150_SERIES_WIFI, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 80 | /* Wilkins Peak 2 */ |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 81 | PCI_DID_WP_7260_SERIES_1_WIFI, |
| 82 | PCI_DID_WP_7260_SERIES_2_WIFI, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 83 | /* Stone Peak 2 */ |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 84 | PCI_DID_SP_7265_SERIES_1_WIFI, |
| 85 | PCI_DID_SP_7265_SERIES_2_WIFI, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 86 | /* Stone Field Peak */ |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 87 | PCI_DID_SFP_8260_SERIES_1_WIFI, |
| 88 | PCI_DID_SFP_8260_SERIES_2_WIFI, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 89 | /* Windstorm Peak */ |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 90 | PCI_DID_WSP_8275_SERIES_1_WIFI, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 91 | /* Thunder Peak 2 */ |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 92 | PCI_DID_TP_9260_SERIES_WIFI, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 93 | /* Cyclone Peak */ |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 94 | PCI_DID_CyP_6SERIES_WIFI, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 95 | /* Typhoon Peak */ |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 96 | PCI_DID_TyP_6SERIES_WIFI, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 97 | /* Garfield Peak */ |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 98 | PCI_DID_GrP_6SERIES_1_WIFI, |
| 99 | PCI_DID_GrP_6SERIES_2_WIFI, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 100 | 0 |
| 101 | }; |
| 102 | |
| 103 | /* |
| 104 | * The PCI driver is retained for backward compatibility with boards that never utilized the |
| 105 | * chip driver to support Intel WiFi device. For these devices, the PCI driver helps perform the |
| 106 | * same operations as above (except exposing the wake property) by utilizing the same |
| 107 | * `wifi_generic_ops`. |
| 108 | */ |
| 109 | static const struct pci_driver intel_wifi_pci_driver __pci_driver = { |
Furquan Shaikh | d436750 | 2020-10-27 18:00:46 -0700 | [diff] [blame] | 110 | .ops = &wifi_pcie_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 111 | .vendor = PCI_VID_INTEL, |
Furquan Shaikh | 8262a2c | 2020-10-10 19:53:00 -0700 | [diff] [blame] | 112 | .devices = intel_pci_device_ids, |
| 113 | }; |