Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; version 2 or (at your option) |
| 7 | * any later version of the License. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 13 | */ |
| 14 | |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 15 | #include <device/device.h> |
| 16 | #include <device/pci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 17 | #include <device/pci_ops.h> |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 18 | #include <device/pci_ids.h> |
Naresh G Solanki | 3c6377f | 2017-07-03 21:57:11 +0530 | [diff] [blame] | 19 | #include <elog.h> |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 20 | #include <smbios.h> |
| 21 | #include <string.h> |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 22 | #include "chip.h" |
Karthikeyan Ramasubramanian | fd5d788 | 2019-05-29 15:09:42 -0600 | [diff] [blame] | 23 | #include "drivers/wifi/generic_wifi.h" |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 24 | |
Naresh G Solanki | 3c6377f | 2017-07-03 21:57:11 +0530 | [diff] [blame] | 25 | #define PMCS_DR 0xcc |
| 26 | #define PME_STS (1 << 15) |
| 27 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 28 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 29 | static int smbios_write_wifi(struct device *dev, int *handle, |
| 30 | unsigned long *current) |
| 31 | { |
| 32 | struct smbios_type_intel_wifi { |
| 33 | u8 type; |
| 34 | u8 length; |
| 35 | u16 handle; |
| 36 | u8 str; |
Konstantin Aladyshev | d0df1d7 | 2017-08-01 15:52:46 +0300 | [diff] [blame] | 37 | u8 eos[2]; |
Stefan Reinauer | 6a00113 | 2017-07-13 02:20:27 +0200 | [diff] [blame] | 38 | } __packed; |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 39 | |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 40 | struct smbios_type_intel_wifi *t = |
| 41 | (struct smbios_type_intel_wifi *)*current; |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 42 | int len = sizeof(struct smbios_type_intel_wifi); |
| 43 | |
| 44 | memset(t, 0, sizeof(struct smbios_type_intel_wifi)); |
| 45 | t->type = 0x85; |
| 46 | t->length = len - 2; |
| 47 | t->handle = *handle; |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 48 | /* |
| 49 | * Intel wifi driver expects this string to be in the table 0x85 |
| 50 | * with PCI IDs enumerated below. |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 51 | */ |
| 52 | t->str = smbios_add_string(t->eos, "KHOIHGIUCCHHII"); |
| 53 | |
| 54 | len = t->length + smbios_string_table_len(t->eos); |
| 55 | *current += len; |
| 56 | *handle += 1; |
| 57 | return len; |
| 58 | } |
Kyösti Mälkki | 828e73e | 2016-07-28 17:26:39 +0300 | [diff] [blame] | 59 | #endif |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 60 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 61 | #if CONFIG(HAVE_ACPI_TABLES) |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 62 | static void intel_wifi_fill_ssdt(struct device *dev) |
| 63 | { |
| 64 | struct drivers_intel_wifi_config *config = dev->chip_info; |
Karthikeyan Ramasubramanian | fd5d788 | 2019-05-29 15:09:42 -0600 | [diff] [blame] | 65 | struct generic_wifi_config generic_config; |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 66 | |
Karthikeyan Ramasubramanian | fd5d788 | 2019-05-29 15:09:42 -0600 | [diff] [blame] | 67 | if (config) { |
| 68 | generic_config.wake = config->wake; |
| 69 | /* By default, all intel wifi chips wake from S3 */ |
| 70 | generic_config.maxsleep = 3; |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 71 | } |
Karthikeyan Ramasubramanian | fd5d788 | 2019-05-29 15:09:42 -0600 | [diff] [blame] | 72 | generic_wifi_fill_ssdt(dev, config ? &generic_config : NULL); |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 73 | } |
| 74 | #endif |
| 75 | |
Naresh G Solanki | 3c6377f | 2017-07-03 21:57:11 +0530 | [diff] [blame] | 76 | static void wifi_pci_dev_init(struct device *dev) |
| 77 | { |
| 78 | pci_dev_init(dev); |
| 79 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 80 | if (CONFIG(ELOG)) { |
Naresh G Solanki | 3c6377f | 2017-07-03 21:57:11 +0530 | [diff] [blame] | 81 | uint32_t val; |
| 82 | val = pci_read_config16(dev, PMCS_DR); |
| 83 | if (val & PME_STS) |
| 84 | elog_add_event_wake(ELOG_WAKE_SOURCE_PME_WIFI, 0); |
Elyes HAOUAS | 88607a4 | 2018-10-05 10:36:45 +0200 | [diff] [blame] | 85 | } |
Naresh G Solanki | 3c6377f | 2017-07-03 21:57:11 +0530 | [diff] [blame] | 86 | } |
| 87 | |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 88 | static struct pci_operations pci_ops = { |
| 89 | .set_subsystem = pci_dev_set_subsystem, |
| 90 | }; |
| 91 | |
| 92 | struct device_operations device_ops = { |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame^] | 93 | .read_resources = pci_dev_read_resources, |
| 94 | .set_resources = pci_dev_set_resources, |
| 95 | .enable_resources = pci_dev_enable_resources, |
| 96 | .init = wifi_pci_dev_init, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 97 | #if CONFIG(GENERATE_SMBIOS_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame^] | 98 | .get_smbios_data = smbios_write_wifi, |
Kyösti Mälkki | 828e73e | 2016-07-28 17:26:39 +0300 | [diff] [blame] | 99 | #endif |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame^] | 100 | .ops_pci = &pci_ops, |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 101 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame^] | 102 | .acpi_name = generic_wifi_acpi_name, |
| 103 | .acpi_fill_ssdt = intel_wifi_fill_ssdt, |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 104 | #endif |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 105 | }; |
| 106 | |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 107 | static const unsigned short pci_device_ids[] = { |
Subrata Banik | f952983 | 2018-03-22 05:25:45 +0530 | [diff] [blame] | 108 | PCI_DEVICE_ID_1000_SERIES_WIFI, |
| 109 | PCI_DEVICE_ID_6005_SERIES_WIFI, |
| 110 | PCI_DEVICE_ID_6005_I_SERIES_WIFI, |
| 111 | PCI_DEVICE_ID_1030_SERIES_WIFI, |
| 112 | PCI_DEVICE_ID_6030_I_SERIES_WIFI, |
| 113 | PCI_DEVICE_ID_6030_SERIES_WIFI, |
| 114 | PCI_DEVICE_ID_6150_SERIES_WIFI, |
| 115 | PCI_DEVICE_ID_2030_SERIES_WIFI, |
| 116 | PCI_DEVICE_ID_2000_SERIES_WIFI, |
| 117 | PCI_DEVICE_ID_0135_SERIES_WIFI, |
| 118 | PCI_DEVICE_ID_0105_SERIES_WIFI, |
| 119 | PCI_DEVICE_ID_6035_SERIES_WIFI, |
| 120 | PCI_DEVICE_ID_5300_SERIES_WIFI, |
| 121 | PCI_DEVICE_ID_5100_SERIES_WIFI, |
| 122 | PCI_DEVICE_ID_6000_SERIES_WIFI, |
| 123 | PCI_DEVICE_ID_6000_I_SERIES_WIFI, |
| 124 | PCI_DEVICE_ID_5350_SERIES_WIFI, |
| 125 | PCI_DEVICE_ID_5150_SERIES_WIFI, |
| 126 | /* Wilkins Peak 2 */ |
| 127 | PCI_DEVICE_ID_WP_7260_SERIES_1_WIFI, |
| 128 | PCI_DEVICE_ID_WP_7260_SERIES_2_WIFI, |
| 129 | /* Stone Peak 2 */ |
| 130 | PCI_DEVICE_ID_SP_7265_SERIES_1_WIFI, |
| 131 | PCI_DEVICE_ID_SP_7265_SERIES_2_WIFI, |
Subrata Banik | 4530af2 | 2018-09-28 22:43:10 +0530 | [diff] [blame] | 132 | /* Stone Field Peak */ |
| 133 | PCI_DEVICE_ID_SFP_8260_SERIES_1_WIFI, |
| 134 | PCI_DEVICE_ID_SFP_8260_SERIES_2_WIFI, |
| 135 | /* Windstorm Peak */ |
| 136 | PCI_DEVICE_ID_WSP_8275_SERIES_1_WIFI, |
Subrata Banik | f952983 | 2018-03-22 05:25:45 +0530 | [diff] [blame] | 137 | /* Jefferson Peak */ |
| 138 | PCI_DEVICE_ID_JP_9000_SERIES_1_WIFI, |
| 139 | PCI_DEVICE_ID_JP_9000_SERIES_2_WIFI, |
| 140 | PCI_DEVICE_ID_JP_9000_SERIES_3_WIFI, |
Furquan Shaikh | 39130a4 | 2018-05-30 19:57:14 -0700 | [diff] [blame] | 141 | /* Thunder Peak 2 */ |
| 142 | PCI_DEVICE_ID_TP_9260_SERIES_WIFI, |
Subrata Banik | f952983 | 2018-03-22 05:25:45 +0530 | [diff] [blame] | 143 | /* Harrison Peak */ |
| 144 | PCI_DEVICE_ID_HrP_9560_SERIES_1_WIFI, |
| 145 | PCI_DEVICE_ID_HrP_9560_SERIES_2_WIFI, |
Subrata Banik | 71da5fe | 2019-02-19 12:11:26 +0530 | [diff] [blame] | 146 | PCI_DEVICE_ID_HrP_9560_SERIES_3_WIFI, |
Subrata Banik | 13f5360 | 2019-03-28 10:35:30 +0530 | [diff] [blame] | 147 | PCI_DEVICE_ID_HrP_9560_SERIES_4_WIFI, |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 148 | 0 |
| 149 | }; |
Vladimir Serbinenko | 41f55b7 | 2014-10-31 09:10:16 +0100 | [diff] [blame] | 150 | |
| 151 | static const struct pci_driver pch_intel_wifi __pci_driver = { |
| 152 | .ops = &device_ops, |
| 153 | .vendor = PCI_VENDOR_ID_INTEL, |
| 154 | .devices = pci_device_ids, |
| 155 | }; |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 156 | |
| 157 | static void intel_wifi_enable(struct device *dev) |
| 158 | { |
| 159 | dev->ops = &device_ops; |
| 160 | } |
| 161 | |
| 162 | struct chip_operations drivers_intel_wifi_ops = { |
| 163 | CHIP_NAME("Intel WiFi") |
Elyes HAOUAS | 2aa3b16 | 2018-11-27 17:02:10 +0100 | [diff] [blame] | 164 | .enable_dev = intel_wifi_enable |
Duncan Laurie | 5c02644 | 2016-05-11 14:05:07 -0700 | [diff] [blame] | 165 | }; |