1e705c121SKalle Valo /******************************************************************************
2e705c121SKalle Valo  *
3e705c121SKalle Valo  * This file is provided under a dual BSD/GPLv2 license.  When using or
4e705c121SKalle Valo  * redistributing this file, you may do so under either license.
5e705c121SKalle Valo  *
6e705c121SKalle Valo  * GPL LICENSE SUMMARY
7e705c121SKalle Valo  *
8e705c121SKalle Valo  * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved.
9e705c121SKalle Valo  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10b3ff1270SLuca Coelho  * Copyright(c) 2016 Intel Deutschland GmbH
11e705c121SKalle Valo  *
12e705c121SKalle Valo  * This program is free software; you can redistribute it and/or modify
13e705c121SKalle Valo  * it under the terms of version 2 of the GNU General Public License as
14e705c121SKalle Valo  * published by the Free Software Foundation.
15e705c121SKalle Valo  *
16e705c121SKalle Valo  * This program is distributed in the hope that it will be useful, but
17e705c121SKalle Valo  * WITHOUT ANY WARRANTY; without even the implied warranty of
18e705c121SKalle Valo  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19e705c121SKalle Valo  * General Public License for more details.
20e705c121SKalle Valo  *
21e705c121SKalle Valo  * You should have received a copy of the GNU General Public License
22e705c121SKalle Valo  * along with this program; if not, write to the Free Software
23e705c121SKalle Valo  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
24e705c121SKalle Valo  * USA
25e705c121SKalle Valo  *
26e705c121SKalle Valo  * The full GNU General Public License is included in this distribution
27e705c121SKalle Valo  * in the file called COPYING.
28e705c121SKalle Valo  *
29e705c121SKalle Valo  * Contact Information:
30cb2f8277SEmmanuel Grumbach  *  Intel Linux Wireless <linuxwifi@intel.com>
31e705c121SKalle Valo  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
32e705c121SKalle Valo  *
33e705c121SKalle Valo  * BSD LICENSE
34e705c121SKalle Valo  *
35e705c121SKalle Valo  * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
36e705c121SKalle Valo  * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
37e705c121SKalle Valo  * All rights reserved.
38e705c121SKalle Valo  *
39e705c121SKalle Valo  * Redistribution and use in source and binary forms, with or without
40e705c121SKalle Valo  * modification, are permitted provided that the following conditions
41e705c121SKalle Valo  * are met:
42e705c121SKalle Valo  *
43e705c121SKalle Valo  *  * Redistributions of source code must retain the above copyright
44e705c121SKalle Valo  *    notice, this list of conditions and the following disclaimer.
45e705c121SKalle Valo  *  * Redistributions in binary form must reproduce the above copyright
46e705c121SKalle Valo  *    notice, this list of conditions and the following disclaimer in
47e705c121SKalle Valo  *    the documentation and/or other materials provided with the
48e705c121SKalle Valo  *    distribution.
49e705c121SKalle Valo  *  * Neither the name Intel Corporation nor the names of its
50e705c121SKalle Valo  *    contributors may be used to endorse or promote products derived
51e705c121SKalle Valo  *    from this software without specific prior written permission.
52e705c121SKalle Valo  *
53e705c121SKalle Valo  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54e705c121SKalle Valo  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55e705c121SKalle Valo  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56e705c121SKalle Valo  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57e705c121SKalle Valo  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58e705c121SKalle Valo  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
59e705c121SKalle Valo  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60e705c121SKalle Valo  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61e705c121SKalle Valo  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62e705c121SKalle Valo  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
63e705c121SKalle Valo  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64e705c121SKalle Valo  *
65e705c121SKalle Valo  *****************************************************************************/
66e705c121SKalle Valo 
67e705c121SKalle Valo #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
68e705c121SKalle Valo 
69e705c121SKalle Valo #include <linux/module.h>
70b3ff1270SLuca Coelho #include <linux/pm_runtime.h>
71e705c121SKalle Valo #include <linux/pci.h>
72e705c121SKalle Valo #include <linux/pci-aspm.h>
73e705c121SKalle Valo #include <linux/acpi.h>
74e705c121SKalle Valo 
75e705c121SKalle Valo #include "iwl-trans.h"
76e705c121SKalle Valo #include "iwl-drv.h"
77e705c121SKalle Valo #include "internal.h"
78e705c121SKalle Valo 
79e705c121SKalle Valo #define IWL_PCI_DEVICE(dev, subdev, cfg) \
80e705c121SKalle Valo 	.vendor = PCI_VENDOR_ID_INTEL,  .device = (dev), \
81e705c121SKalle Valo 	.subvendor = PCI_ANY_ID, .subdevice = (subdev), \
82e705c121SKalle Valo 	.driver_data = (kernel_ulong_t)&(cfg)
83e705c121SKalle Valo 
84e705c121SKalle Valo /* Hardware specific file defines the PCI IDs table for that hardware module */
85e705c121SKalle Valo static const struct pci_device_id iwl_hw_card_ids[] = {
86e705c121SKalle Valo #if IS_ENABLED(CONFIG_IWLDVM)
87e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1201, iwl5100_agn_cfg)}, /* Mini Card */
88e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1301, iwl5100_agn_cfg)}, /* Half Mini Card */
89e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1204, iwl5100_agn_cfg)}, /* Mini Card */
90e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1304, iwl5100_agn_cfg)}, /* Half Mini Card */
91e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1205, iwl5100_bgn_cfg)}, /* Mini Card */
92e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1305, iwl5100_bgn_cfg)}, /* Half Mini Card */
93e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1206, iwl5100_abg_cfg)}, /* Mini Card */
94e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1306, iwl5100_abg_cfg)}, /* Half Mini Card */
95e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1221, iwl5100_agn_cfg)}, /* Mini Card */
96e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1321, iwl5100_agn_cfg)}, /* Half Mini Card */
97e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1224, iwl5100_agn_cfg)}, /* Mini Card */
98e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1324, iwl5100_agn_cfg)}, /* Half Mini Card */
99e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1225, iwl5100_bgn_cfg)}, /* Mini Card */
100e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1325, iwl5100_bgn_cfg)}, /* Half Mini Card */
101e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1226, iwl5100_abg_cfg)}, /* Mini Card */
102e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4232, 0x1326, iwl5100_abg_cfg)}, /* Half Mini Card */
103e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4237, 0x1211, iwl5100_agn_cfg)}, /* Mini Card */
104e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4237, 0x1311, iwl5100_agn_cfg)}, /* Half Mini Card */
105e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4237, 0x1214, iwl5100_agn_cfg)}, /* Mini Card */
106e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4237, 0x1314, iwl5100_agn_cfg)}, /* Half Mini Card */
107e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4237, 0x1215, iwl5100_bgn_cfg)}, /* Mini Card */
108e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4237, 0x1315, iwl5100_bgn_cfg)}, /* Half Mini Card */
109e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4237, 0x1216, iwl5100_abg_cfg)}, /* Mini Card */
110e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4237, 0x1316, iwl5100_abg_cfg)}, /* Half Mini Card */
111e705c121SKalle Valo 
112e705c121SKalle Valo /* 5300 Series WiFi */
113e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4235, 0x1021, iwl5300_agn_cfg)}, /* Mini Card */
114e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4235, 0x1121, iwl5300_agn_cfg)}, /* Half Mini Card */
115e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4235, 0x1024, iwl5300_agn_cfg)}, /* Mini Card */
116e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4235, 0x1124, iwl5300_agn_cfg)}, /* Half Mini Card */
117e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4235, 0x1001, iwl5300_agn_cfg)}, /* Mini Card */
118e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4235, 0x1101, iwl5300_agn_cfg)}, /* Half Mini Card */
119e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4235, 0x1004, iwl5300_agn_cfg)}, /* Mini Card */
120e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4235, 0x1104, iwl5300_agn_cfg)}, /* Half Mini Card */
121e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4236, 0x1011, iwl5300_agn_cfg)}, /* Mini Card */
122e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4236, 0x1111, iwl5300_agn_cfg)}, /* Half Mini Card */
123e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4236, 0x1014, iwl5300_agn_cfg)}, /* Mini Card */
124e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4236, 0x1114, iwl5300_agn_cfg)}, /* Half Mini Card */
125e705c121SKalle Valo 
126e705c121SKalle Valo /* 5350 Series WiFi/WiMax */
127e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423A, 0x1001, iwl5350_agn_cfg)}, /* Mini Card */
128e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423A, 0x1021, iwl5350_agn_cfg)}, /* Mini Card */
129e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423B, 0x1011, iwl5350_agn_cfg)}, /* Mini Card */
130e705c121SKalle Valo 
131e705c121SKalle Valo /* 5150 Series Wifi/WiMax */
132e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423C, 0x1201, iwl5150_agn_cfg)}, /* Mini Card */
133e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423C, 0x1301, iwl5150_agn_cfg)}, /* Half Mini Card */
134e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423C, 0x1206, iwl5150_abg_cfg)}, /* Mini Card */
135e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423C, 0x1306, iwl5150_abg_cfg)}, /* Half Mini Card */
136e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423C, 0x1221, iwl5150_agn_cfg)}, /* Mini Card */
137e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423C, 0x1321, iwl5150_agn_cfg)}, /* Half Mini Card */
138e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423C, 0x1326, iwl5150_abg_cfg)}, /* Half Mini Card */
139e705c121SKalle Valo 
140e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423D, 0x1211, iwl5150_agn_cfg)}, /* Mini Card */
141e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423D, 0x1311, iwl5150_agn_cfg)}, /* Half Mini Card */
142e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423D, 0x1216, iwl5150_abg_cfg)}, /* Mini Card */
143e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x423D, 0x1316, iwl5150_abg_cfg)}, /* Half Mini Card */
144e705c121SKalle Valo 
145e705c121SKalle Valo /* 6x00 Series */
146e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x422B, 0x1101, iwl6000_3agn_cfg)},
147e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x422B, 0x1108, iwl6000_3agn_cfg)},
148e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x422B, 0x1121, iwl6000_3agn_cfg)},
149e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x422B, 0x1128, iwl6000_3agn_cfg)},
150e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x422C, 0x1301, iwl6000i_2agn_cfg)},
151e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x422C, 0x1306, iwl6000i_2abg_cfg)},
152e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x422C, 0x1307, iwl6000i_2bg_cfg)},
153e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x422C, 0x1321, iwl6000i_2agn_cfg)},
154e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x422C, 0x1326, iwl6000i_2abg_cfg)},
155e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4238, 0x1111, iwl6000_3agn_cfg)},
156e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4238, 0x1118, iwl6000_3agn_cfg)},
157e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4239, 0x1311, iwl6000i_2agn_cfg)},
158e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x4239, 0x1316, iwl6000i_2abg_cfg)},
159e705c121SKalle Valo 
160e705c121SKalle Valo /* 6x05 Series */
161e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x1301, iwl6005_2agn_cfg)},
162e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x1306, iwl6005_2abg_cfg)},
163e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x1307, iwl6005_2bg_cfg)},
164e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x1308, iwl6005_2agn_cfg)},
165e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x1321, iwl6005_2agn_cfg)},
166e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x1326, iwl6005_2abg_cfg)},
167e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x1328, iwl6005_2agn_cfg)},
168e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0085, 0x1311, iwl6005_2agn_cfg)},
169e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0085, 0x1318, iwl6005_2agn_cfg)},
170e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0085, 0x1316, iwl6005_2abg_cfg)},
171e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0xC020, iwl6005_2agn_sff_cfg)},
172e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0085, 0xC220, iwl6005_2agn_sff_cfg)},
173e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0085, 0xC228, iwl6005_2agn_sff_cfg)},
174e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x4820, iwl6005_2agn_d_cfg)},
175e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x1304, iwl6005_2agn_mow1_cfg)},/* low 5GHz active */
176e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0082, 0x1305, iwl6005_2agn_mow2_cfg)},/* high 5GHz active */
177e705c121SKalle Valo 
178e705c121SKalle Valo /* 6x30 Series */
179e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)},
180e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x008A, 0x5307, iwl1030_bg_cfg)},
181e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x008A, 0x5325, iwl1030_bgn_cfg)},
182e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x008A, 0x5327, iwl1030_bg_cfg)},
183e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x008B, 0x5315, iwl1030_bgn_cfg)},
184e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x008B, 0x5317, iwl1030_bg_cfg)},
185e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0090, 0x5211, iwl6030_2agn_cfg)},
186e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0090, 0x5215, iwl6030_2bgn_cfg)},
187e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0090, 0x5216, iwl6030_2abg_cfg)},
188e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0091, 0x5201, iwl6030_2agn_cfg)},
189e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0091, 0x5205, iwl6030_2bgn_cfg)},
190e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0091, 0x5206, iwl6030_2abg_cfg)},
191e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0091, 0x5207, iwl6030_2bg_cfg)},
192e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0091, 0x5221, iwl6030_2agn_cfg)},
193e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0091, 0x5225, iwl6030_2bgn_cfg)},
194e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0091, 0x5226, iwl6030_2abg_cfg)},
195e705c121SKalle Valo 
196e705c121SKalle Valo /* 6x50 WiFi/WiMax Series */
197e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0087, 0x1301, iwl6050_2agn_cfg)},
198e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0087, 0x1306, iwl6050_2abg_cfg)},
199e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0087, 0x1321, iwl6050_2agn_cfg)},
200e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0087, 0x1326, iwl6050_2abg_cfg)},
201e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0089, 0x1311, iwl6050_2agn_cfg)},
202e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0089, 0x1316, iwl6050_2abg_cfg)},
203e705c121SKalle Valo 
204e705c121SKalle Valo /* 6150 WiFi/WiMax Series */
205e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0885, 0x1305, iwl6150_bgn_cfg)},
206e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0885, 0x1307, iwl6150_bg_cfg)},
207e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0885, 0x1325, iwl6150_bgn_cfg)},
208e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0885, 0x1327, iwl6150_bg_cfg)},
209e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0886, 0x1315, iwl6150_bgn_cfg)},
210e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0886, 0x1317, iwl6150_bg_cfg)},
211e705c121SKalle Valo 
212e705c121SKalle Valo /* 1000 Series WiFi */
213e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0083, 0x1205, iwl1000_bgn_cfg)},
214e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0083, 0x1305, iwl1000_bgn_cfg)},
215e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0083, 0x1225, iwl1000_bgn_cfg)},
216e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0083, 0x1325, iwl1000_bgn_cfg)},
217e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0084, 0x1215, iwl1000_bgn_cfg)},
218e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0084, 0x1315, iwl1000_bgn_cfg)},
219e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0083, 0x1206, iwl1000_bg_cfg)},
220e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0083, 0x1306, iwl1000_bg_cfg)},
221e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0083, 0x1226, iwl1000_bg_cfg)},
222e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0083, 0x1326, iwl1000_bg_cfg)},
223e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0084, 0x1216, iwl1000_bg_cfg)},
224e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0084, 0x1316, iwl1000_bg_cfg)},
225e705c121SKalle Valo 
226e705c121SKalle Valo /* 100 Series WiFi */
227e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08AE, 0x1005, iwl100_bgn_cfg)},
228e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08AE, 0x1007, iwl100_bg_cfg)},
229e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08AF, 0x1015, iwl100_bgn_cfg)},
230e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08AF, 0x1017, iwl100_bg_cfg)},
231e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08AE, 0x1025, iwl100_bgn_cfg)},
232e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08AE, 0x1027, iwl100_bg_cfg)},
233e705c121SKalle Valo 
234e705c121SKalle Valo /* 130 Series WiFi */
235e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0896, 0x5005, iwl130_bgn_cfg)},
236e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0896, 0x5007, iwl130_bg_cfg)},
237e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0897, 0x5015, iwl130_bgn_cfg)},
238e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0897, 0x5017, iwl130_bg_cfg)},
239e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0896, 0x5025, iwl130_bgn_cfg)},
240e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0896, 0x5027, iwl130_bg_cfg)},
241e705c121SKalle Valo 
242e705c121SKalle Valo /* 2x00 Series */
243e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0890, 0x4022, iwl2000_2bgn_cfg)},
244e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0891, 0x4222, iwl2000_2bgn_cfg)},
245e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0890, 0x4422, iwl2000_2bgn_cfg)},
246e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0890, 0x4822, iwl2000_2bgn_d_cfg)},
247e705c121SKalle Valo 
248e705c121SKalle Valo /* 2x30 Series */
249e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0887, 0x4062, iwl2030_2bgn_cfg)},
250e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0888, 0x4262, iwl2030_2bgn_cfg)},
251e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0887, 0x4462, iwl2030_2bgn_cfg)},
252e705c121SKalle Valo 
253e705c121SKalle Valo /* 6x35 Series */
254e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)},
255e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x088E, 0x406A, iwl6035_2agn_sff_cfg)},
256e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)},
257e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x088F, 0x426A, iwl6035_2agn_sff_cfg)},
258e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)},
259e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x088E, 0x446A, iwl6035_2agn_sff_cfg)},
260e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x088E, 0x4860, iwl6035_2agn_cfg)},
261e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x088F, 0x5260, iwl6035_2agn_cfg)},
262e705c121SKalle Valo 
263e705c121SKalle Valo /* 105 Series */
264e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)},
265e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0895, 0x0222, iwl105_bgn_cfg)},
266e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0894, 0x0422, iwl105_bgn_cfg)},
267e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0894, 0x0822, iwl105_bgn_d_cfg)},
268e705c121SKalle Valo 
269e705c121SKalle Valo /* 135 Series */
270e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0892, 0x0062, iwl135_bgn_cfg)},
271e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0893, 0x0262, iwl135_bgn_cfg)},
272e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x0892, 0x0462, iwl135_bgn_cfg)},
273e705c121SKalle Valo #endif /* CONFIG_IWLDVM */
274e705c121SKalle Valo 
275e705c121SKalle Valo #if IS_ENABLED(CONFIG_IWLMVM)
276e705c121SKalle Valo /* 7260 Series */
277e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4070, iwl7260_2ac_cfg)},
278e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4072, iwl7260_2ac_cfg)},
279e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4170, iwl7260_2ac_cfg)},
280e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4C60, iwl7260_2ac_cfg)},
281e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4C70, iwl7260_2ac_cfg)},
282e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4060, iwl7260_2n_cfg)},
283e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x406A, iwl7260_2n_cfg)},
284e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4160, iwl7260_2n_cfg)},
285e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4062, iwl7260_n_cfg)},
286e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4162, iwl7260_n_cfg)},
287e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0x4270, iwl7260_2ac_cfg)},
288e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0x4272, iwl7260_2ac_cfg)},
289e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0x4260, iwl7260_2n_cfg)},
290e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0x426A, iwl7260_2n_cfg)},
291e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0x4262, iwl7260_n_cfg)},
292e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4470, iwl7260_2ac_cfg)},
293e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4472, iwl7260_2ac_cfg)},
294e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4460, iwl7260_2n_cfg)},
295e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x446A, iwl7260_2n_cfg)},
296e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4462, iwl7260_n_cfg)},
297e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4870, iwl7260_2ac_cfg)},
298e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x486E, iwl7260_2ac_cfg)},
299e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4A70, iwl7260_2ac_cfg_high_temp)},
300e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4A6E, iwl7260_2ac_cfg_high_temp)},
301e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4A6C, iwl7260_2ac_cfg_high_temp)},
302e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4570, iwl7260_2ac_cfg)},
303e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4560, iwl7260_2n_cfg)},
304e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0x4370, iwl7260_2ac_cfg)},
305e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0x4360, iwl7260_2n_cfg)},
306e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x5070, iwl7260_2ac_cfg)},
307e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x5072, iwl7260_2ac_cfg)},
308e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x5170, iwl7260_2ac_cfg)},
309e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x5770, iwl7260_2ac_cfg)},
310e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4020, iwl7260_2n_cfg)},
311e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x402A, iwl7260_2n_cfg)},
312e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0x4220, iwl7260_2n_cfg)},
313e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0x4420, iwl7260_2n_cfg)},
314e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC070, iwl7260_2ac_cfg)},
315e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC072, iwl7260_2ac_cfg)},
316e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC170, iwl7260_2ac_cfg)},
317e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC060, iwl7260_2n_cfg)},
318e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC06A, iwl7260_2n_cfg)},
319e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC160, iwl7260_2n_cfg)},
320e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC062, iwl7260_n_cfg)},
321e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC162, iwl7260_n_cfg)},
322e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC770, iwl7260_2ac_cfg)},
323e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC760, iwl7260_2n_cfg)},
324e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0xC270, iwl7260_2ac_cfg)},
325e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xCC70, iwl7260_2ac_cfg)},
326e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xCC60, iwl7260_2ac_cfg)},
327e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0xC272, iwl7260_2ac_cfg)},
328e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0xC260, iwl7260_2n_cfg)},
329e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0xC26A, iwl7260_n_cfg)},
330e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0xC262, iwl7260_n_cfg)},
331e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC470, iwl7260_2ac_cfg)},
332e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC472, iwl7260_2ac_cfg)},
333e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC460, iwl7260_2n_cfg)},
334e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC462, iwl7260_n_cfg)},
335e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC570, iwl7260_2ac_cfg)},
336e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC560, iwl7260_2n_cfg)},
337e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0xC370, iwl7260_2ac_cfg)},
338e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC360, iwl7260_2n_cfg)},
339e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC020, iwl7260_2n_cfg)},
340e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC02A, iwl7260_2n_cfg)},
341e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B2, 0xC220, iwl7260_2n_cfg)},
342e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B1, 0xC420, iwl7260_2n_cfg)},
343e705c121SKalle Valo 
344e705c121SKalle Valo /* 3160 Series */
345e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x0070, iwl3160_2ac_cfg)},
346e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x0072, iwl3160_2ac_cfg)},
347e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x0170, iwl3160_2ac_cfg)},
348e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x0172, iwl3160_2ac_cfg)},
349e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x0060, iwl3160_2n_cfg)},
350e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x0062, iwl3160_n_cfg)},
351e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B4, 0x0270, iwl3160_2ac_cfg)},
352e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B4, 0x0272, iwl3160_2ac_cfg)},
353e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x0470, iwl3160_2ac_cfg)},
354e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x0472, iwl3160_2ac_cfg)},
355e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B4, 0x0370, iwl3160_2ac_cfg)},
356e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x8070, iwl3160_2ac_cfg)},
357e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x8072, iwl3160_2ac_cfg)},
358e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x8170, iwl3160_2ac_cfg)},
359e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x8172, iwl3160_2ac_cfg)},
360e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x8060, iwl3160_2n_cfg)},
361e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x8062, iwl3160_n_cfg)},
362e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B4, 0x8270, iwl3160_2ac_cfg)},
363e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B4, 0x8370, iwl3160_2ac_cfg)},
364e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B4, 0x8272, iwl3160_2ac_cfg)},
365e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x8470, iwl3160_2ac_cfg)},
366e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x8570, iwl3160_2ac_cfg)},
367e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x1070, iwl3160_2ac_cfg)},
368e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x08B3, 0x1170, iwl3160_2ac_cfg)},
369e705c121SKalle Valo 
370e705c121SKalle Valo /* 3165 Series */
371e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3165, 0x4010, iwl3165_2ac_cfg)},
372e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3165, 0x4012, iwl3165_2ac_cfg)},
373e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3166, 0x4212, iwl3165_2ac_cfg)},
374e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3165, 0x4410, iwl3165_2ac_cfg)},
375e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3165, 0x4510, iwl3165_2ac_cfg)},
376e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3165, 0x4110, iwl3165_2ac_cfg)},
377e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3166, 0x4310, iwl3165_2ac_cfg)},
378e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3166, 0x4210, iwl3165_2ac_cfg)},
379e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3165, 0x8010, iwl3165_2ac_cfg)},
380e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x3165, 0x8110, iwl3165_2ac_cfg)},
381e705c121SKalle Valo 
382c4836b05SOren Givon /* 3168 Series */
3837b08c67fSOren Givon 	{IWL_PCI_DEVICE(0x24FB, 0x2010, iwl3168_2ac_cfg)},
384c4836b05SOren Givon 	{IWL_PCI_DEVICE(0x24FB, 0x2110, iwl3168_2ac_cfg)},
3857b08c67fSOren Givon 	{IWL_PCI_DEVICE(0x24FB, 0x2050, iwl3168_2ac_cfg)},
3867b08c67fSOren Givon 	{IWL_PCI_DEVICE(0x24FB, 0x2150, iwl3168_2ac_cfg)},
387c4836b05SOren Givon 	{IWL_PCI_DEVICE(0x24FB, 0x0000, iwl3168_2ac_cfg)},
388c4836b05SOren Givon 
389e705c121SKalle Valo /* 7265 Series */
390e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)},
391e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5110, iwl7265_2ac_cfg)},
392e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5100, iwl7265_2ac_cfg)},
393e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095B, 0x5310, iwl7265_2ac_cfg)},
394e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095B, 0x5302, iwl7265_n_cfg)},
395e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095B, 0x5210, iwl7265_2ac_cfg)},
396006bda75SOren Givon 	{IWL_PCI_DEVICE(0x095A, 0x5C10, iwl7265_2ac_cfg)},
397e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5012, iwl7265_2ac_cfg)},
398e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5412, iwl7265_2ac_cfg)},
399e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)},
400e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5510, iwl7265_2ac_cfg)},
401e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5400, iwl7265_2ac_cfg)},
402e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)},
403e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)},
404e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x500A, iwl7265_2n_cfg)},
405e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095B, 0x5200, iwl7265_2n_cfg)},
406e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5002, iwl7265_n_cfg)},
407e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5102, iwl7265_n_cfg)},
408e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095B, 0x5202, iwl7265_n_cfg)},
409e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x9010, iwl7265_2ac_cfg)},
410e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x9012, iwl7265_2ac_cfg)},
411e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x900A, iwl7265_2ac_cfg)},
412e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x9110, iwl7265_2ac_cfg)},
413e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x9112, iwl7265_2ac_cfg)},
414006bda75SOren Givon 	{IWL_PCI_DEVICE(0x095B, 0x9210, iwl7265_2ac_cfg)},
415e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095B, 0x9200, iwl7265_2ac_cfg)},
416e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x9510, iwl7265_2ac_cfg)},
417006bda75SOren Givon 	{IWL_PCI_DEVICE(0x095B, 0x9310, iwl7265_2ac_cfg)},
418e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x9410, iwl7265_2ac_cfg)},
419e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5020, iwl7265_2n_cfg)},
420e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x502A, iwl7265_2n_cfg)},
421e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5420, iwl7265_2n_cfg)},
422e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5090, iwl7265_2ac_cfg)},
423e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5190, iwl7265_2ac_cfg)},
424e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5590, iwl7265_2ac_cfg)},
425e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095B, 0x5290, iwl7265_2ac_cfg)},
426e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5490, iwl7265_2ac_cfg)},
427e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x5F10, iwl7265_2ac_cfg)},
428e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095B, 0x5212, iwl7265_2ac_cfg)},
429e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095B, 0x520A, iwl7265_2ac_cfg)},
430e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x9000, iwl7265_2ac_cfg)},
431e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x095A, 0x9400, iwl7265_2ac_cfg)},
432e705c121SKalle Valo 
433e705c121SKalle Valo /* 8000 Series */
434e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0010, iwl8260_2ac_cfg)},
435e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x1010, iwl8260_2ac_cfg)},
4364b79deecSOren Givon 	{IWL_PCI_DEVICE(0x24F3, 0x10B0, iwl8260_2ac_cfg)},
4374615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x0130, iwl8260_2ac_cfg)},
4384615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x1130, iwl8260_2ac_cfg)},
4394615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x0132, iwl8260_2ac_cfg)},
4404615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x1132, iwl8260_2ac_cfg)},
441e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0110, iwl8260_2ac_cfg)},
4424615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x01F0, iwl8260_2ac_cfg)},
4434615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x0012, iwl8260_2ac_cfg)},
4444615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x1012, iwl8260_2ac_cfg)},
445e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x1110, iwl8260_2ac_cfg)},
446e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0050, iwl8260_2ac_cfg)},
447e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0250, iwl8260_2ac_cfg)},
448e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x1050, iwl8260_2ac_cfg)},
449e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0150, iwl8260_2ac_cfg)},
4504615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x1150, iwl8260_2ac_cfg)},
451e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F4, 0x0030, iwl8260_2ac_cfg)},
452e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F4, 0x1030, iwl8260_2ac_cfg)},
453e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0xC010, iwl8260_2ac_cfg)},
454e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0xC110, iwl8260_2ac_cfg)},
455e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0xD010, iwl8260_2ac_cfg)},
456e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0xC050, iwl8260_2ac_cfg)},
457e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0xD050, iwl8260_2ac_cfg)},
4584b79deecSOren Givon 	{IWL_PCI_DEVICE(0x24F3, 0xD0B0, iwl8260_2ac_cfg)},
4594b79deecSOren Givon 	{IWL_PCI_DEVICE(0x24F3, 0xB0B0, iwl8260_2ac_cfg)},
460e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x8010, iwl8260_2ac_cfg)},
4614615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x8110, iwl8260_2ac_cfg)},
462e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x9010, iwl8260_2ac_cfg)},
4634615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x9110, iwl8260_2ac_cfg)},
464e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F4, 0x8030, iwl8260_2ac_cfg)},
465e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F4, 0x9030, iwl8260_2ac_cfg)},
4664615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x8130, iwl8260_2ac_cfg)},
4674615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x9130, iwl8260_2ac_cfg)},
4684615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x8132, iwl8260_2ac_cfg)},
4694615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x9132, iwl8260_2ac_cfg)},
470e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x8050, iwl8260_2ac_cfg)},
4714615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x8150, iwl8260_2ac_cfg)},
472e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x9050, iwl8260_2ac_cfg)},
4734615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x9150, iwl8260_2ac_cfg)},
474e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0004, iwl8260_2n_cfg)},
4754615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x0044, iwl8260_2n_cfg)},
476e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F5, 0x0010, iwl4165_2ac_cfg)},
477e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F6, 0x0030, iwl4165_2ac_cfg)},
478e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0810, iwl8260_2ac_cfg)},
479e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0910, iwl8260_2ac_cfg)},
480e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0850, iwl8260_2ac_cfg)},
481e705c121SKalle Valo 	{IWL_PCI_DEVICE(0x24F3, 0x0950, iwl8260_2ac_cfg)},
4824615fd15SEmmanuel Grumbach 	{IWL_PCI_DEVICE(0x24F3, 0x0930, iwl8260_2ac_cfg)},
4838d0e4f8fSOren Givon 	{IWL_PCI_DEVICE(0x24F3, 0x0000, iwl8265_2ac_cfg)},
484abf10f86SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0010, iwl8265_2ac_cfg)},
485d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0110, iwl8265_2ac_cfg)},
486d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x1110, iwl8265_2ac_cfg)},
487f24bbae5SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x1130, iwl8265_2ac_cfg)},
488f24bbae5SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0130, iwl8265_2ac_cfg)},
489d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x1010, iwl8265_2ac_cfg)},
490d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0050, iwl8265_2ac_cfg)},
491d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0150, iwl8265_2ac_cfg)},
492d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x9010, iwl8265_2ac_cfg)},
493d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x8110, iwl8265_2ac_cfg)},
494d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x8050, iwl8265_2ac_cfg)},
4958d0e4f8fSOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x8010, iwl8265_2ac_cfg)},
4969baa0398SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0810, iwl8265_2ac_cfg)},
497d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x9110, iwl8265_2ac_cfg)},
498d34475b9SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x8130, iwl8265_2ac_cfg)},
499f24bbae5SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0910, iwl8265_2ac_cfg)},
500f24bbae5SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0930, iwl8265_2ac_cfg)},
501f24bbae5SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0950, iwl8265_2ac_cfg)},
502f24bbae5SOren Givon 	{IWL_PCI_DEVICE(0x24FD, 0x0850, iwl8265_2ac_cfg)},
50389374fe6SDreyfuss, Haim 
50489374fe6SDreyfuss, Haim /* 9000 Series */
505aea2a5f0SHaim Dreyfuss 	{IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)},
506aea2a5f0SHaim Dreyfuss 	{IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_cfg)},
507*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x0A10, iwl9000_2ac_cfg)},
508*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9000_2ac_cfg)},
509*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x0210, iwl9000_2ac_cfg)},
510*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x0410, iwl9000_2ac_cfg)},
511*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x0610, iwl9000_2ac_cfg)},
512*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x0310, iwl9000_2ac_cfg)},
513*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x0000, iwl9000_2ac_cfg)},
514*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x0510, iwl9000_2ac_cfg)},
515*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x2010, iwl9000_2ac_cfg)},
516*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x2526, 0x1420, iwl9000_2ac_cfg)},
517*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x0710, iwl9000_2ac_cfg)},
518*486c96a7SOren Givon 	{IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl9000_2ac_cfg)},
519e34d975eSHaim Dreyfuss 
520e34d975eSHaim Dreyfuss /* a000 Series */
521e34d975eSHaim Dreyfuss 	{IWL_PCI_DEVICE(0x2720, 0x0A10, iwla000_2ac_cfg)},
522e705c121SKalle Valo #endif /* CONFIG_IWLMVM */
523e705c121SKalle Valo 
524e705c121SKalle Valo 	{0}
525e705c121SKalle Valo };
526e705c121SKalle Valo MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
527e705c121SKalle Valo 
528e705c121SKalle Valo #ifdef CONFIG_ACPI
529e705c121SKalle Valo #define SPL_METHOD		"SPLC"
530e705c121SKalle Valo #define SPL_DOMAINTYPE_MODULE	BIT(0)
531e705c121SKalle Valo #define SPL_DOMAINTYPE_WIFI	BIT(1)
532e705c121SKalle Valo #define SPL_DOMAINTYPE_WIGIG	BIT(2)
533e705c121SKalle Valo #define SPL_DOMAINTYPE_RFEM	BIT(3)
534e705c121SKalle Valo 
535e705c121SKalle Valo static u64 splx_get_pwr_limit(struct iwl_trans *trans, union acpi_object *splx)
536e705c121SKalle Valo {
537e705c121SKalle Valo 	union acpi_object *limits, *domain_type, *power_limit;
538e705c121SKalle Valo 
539e705c121SKalle Valo 	if (splx->type != ACPI_TYPE_PACKAGE ||
540e705c121SKalle Valo 	    splx->package.count != 2 ||
541e705c121SKalle Valo 	    splx->package.elements[0].type != ACPI_TYPE_INTEGER ||
542e705c121SKalle Valo 	    splx->package.elements[0].integer.value != 0) {
543e705c121SKalle Valo 		IWL_ERR(trans, "Unsupported splx structure\n");
544e705c121SKalle Valo 		return 0;
545e705c121SKalle Valo 	}
546e705c121SKalle Valo 
547e705c121SKalle Valo 	limits = &splx->package.elements[1];
548e705c121SKalle Valo 	if (limits->type != ACPI_TYPE_PACKAGE ||
549e705c121SKalle Valo 	    limits->package.count < 2 ||
550e705c121SKalle Valo 	    limits->package.elements[0].type != ACPI_TYPE_INTEGER ||
551e705c121SKalle Valo 	    limits->package.elements[1].type != ACPI_TYPE_INTEGER) {
552e705c121SKalle Valo 		IWL_ERR(trans, "Invalid limits element\n");
553e705c121SKalle Valo 		return 0;
554e705c121SKalle Valo 	}
555e705c121SKalle Valo 
556e705c121SKalle Valo 	domain_type = &limits->package.elements[0];
557e705c121SKalle Valo 	power_limit = &limits->package.elements[1];
558e705c121SKalle Valo 	if (!(domain_type->integer.value & SPL_DOMAINTYPE_WIFI)) {
559e705c121SKalle Valo 		IWL_DEBUG_INFO(trans, "WiFi power is not limited\n");
560e705c121SKalle Valo 		return 0;
561e705c121SKalle Valo 	}
562e705c121SKalle Valo 
563e705c121SKalle Valo 	return power_limit->integer.value;
564e705c121SKalle Valo }
565e705c121SKalle Valo 
566e705c121SKalle Valo static void set_dflt_pwr_limit(struct iwl_trans *trans, struct pci_dev *pdev)
567e705c121SKalle Valo {
568e705c121SKalle Valo 	acpi_handle pxsx_handle;
569e705c121SKalle Valo 	acpi_handle handle;
570e705c121SKalle Valo 	struct acpi_buffer splx = {ACPI_ALLOCATE_BUFFER, NULL};
571e705c121SKalle Valo 	acpi_status status;
572e705c121SKalle Valo 
573e705c121SKalle Valo 	pxsx_handle = ACPI_HANDLE(&pdev->dev);
574e705c121SKalle Valo 	if (!pxsx_handle) {
575e705c121SKalle Valo 		IWL_DEBUG_INFO(trans,
576e705c121SKalle Valo 			       "Could not retrieve root port ACPI handle\n");
577e705c121SKalle Valo 		return;
578e705c121SKalle Valo 	}
579e705c121SKalle Valo 
580e705c121SKalle Valo 	/* Get the method's handle */
581e705c121SKalle Valo 	status = acpi_get_handle(pxsx_handle, (acpi_string)SPL_METHOD, &handle);
582e705c121SKalle Valo 	if (ACPI_FAILURE(status)) {
583e705c121SKalle Valo 		IWL_DEBUG_INFO(trans, "SPL method not found\n");
584e705c121SKalle Valo 		return;
585e705c121SKalle Valo 	}
586e705c121SKalle Valo 
587e705c121SKalle Valo 	/* Call SPLC with no arguments */
588e705c121SKalle Valo 	status = acpi_evaluate_object(handle, NULL, NULL, &splx);
589e705c121SKalle Valo 	if (ACPI_FAILURE(status)) {
590e705c121SKalle Valo 		IWL_ERR(trans, "SPLC invocation failed (0x%x)\n", status);
591e705c121SKalle Valo 		return;
592e705c121SKalle Valo 	}
593e705c121SKalle Valo 
594e705c121SKalle Valo 	trans->dflt_pwr_limit = splx_get_pwr_limit(trans, splx.pointer);
595e705c121SKalle Valo 	IWL_DEBUG_INFO(trans, "Default power limit set to %lld\n",
596e705c121SKalle Valo 		       trans->dflt_pwr_limit);
597e705c121SKalle Valo 	kfree(splx.pointer);
598e705c121SKalle Valo }
599e705c121SKalle Valo 
600e705c121SKalle Valo #else /* CONFIG_ACPI */
601e705c121SKalle Valo static void set_dflt_pwr_limit(struct iwl_trans *trans, struct pci_dev *pdev) {}
602e705c121SKalle Valo #endif
603e705c121SKalle Valo 
604e705c121SKalle Valo /* PCI registers */
605e705c121SKalle Valo #define PCI_CFG_RETRY_TIMEOUT	0x041
606e705c121SKalle Valo 
607e705c121SKalle Valo static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
608e705c121SKalle Valo {
609e705c121SKalle Valo 	const struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
610e705c121SKalle Valo 	const struct iwl_cfg *cfg_7265d __maybe_unused = NULL;
611e705c121SKalle Valo 	struct iwl_trans *iwl_trans;
612e705c121SKalle Valo 	int ret;
613e705c121SKalle Valo 
614e705c121SKalle Valo 	iwl_trans = iwl_trans_pcie_alloc(pdev, ent, cfg);
615e705c121SKalle Valo 	if (IS_ERR(iwl_trans))
616e705c121SKalle Valo 		return PTR_ERR(iwl_trans);
617e705c121SKalle Valo 
618e705c121SKalle Valo #if IS_ENABLED(CONFIG_IWLMVM)
619e705c121SKalle Valo 	/*
620e705c121SKalle Valo 	 * special-case 7265D, it has the same PCI IDs.
621e705c121SKalle Valo 	 *
622e705c121SKalle Valo 	 * Note that because we already pass the cfg to the transport above,
623e705c121SKalle Valo 	 * all the parameters that the transport uses must, until that is
624e705c121SKalle Valo 	 * changed, be identical to the ones in the 7265D configuration.
625e705c121SKalle Valo 	 */
626e705c121SKalle Valo 	if (cfg == &iwl7265_2ac_cfg)
627e705c121SKalle Valo 		cfg_7265d = &iwl7265d_2ac_cfg;
628e705c121SKalle Valo 	else if (cfg == &iwl7265_2n_cfg)
629e705c121SKalle Valo 		cfg_7265d = &iwl7265d_2n_cfg;
630e705c121SKalle Valo 	else if (cfg == &iwl7265_n_cfg)
631e705c121SKalle Valo 		cfg_7265d = &iwl7265d_n_cfg;
632e705c121SKalle Valo 	if (cfg_7265d &&
633e705c121SKalle Valo 	    (iwl_trans->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_7265D) {
634e705c121SKalle Valo 		cfg = cfg_7265d;
635e705c121SKalle Valo 		iwl_trans->cfg = cfg_7265d;
636e705c121SKalle Valo 	}
6371afb0ae4SHaim Dreyfuss 
6381afb0ae4SHaim Dreyfuss 	if (iwl_trans->cfg->rf_id) {
639*486c96a7SOren Givon 		if (cfg == &iwl9000_2ac_cfg &&
640*486c96a7SOren Givon 		    iwl_trans->hw_rf_id == CSR_HW_RF_ID_TYPE_LC) {
641*486c96a7SOren Givon 			cfg = &iwl9000lc_2ac_cfg;
642*486c96a7SOren Givon 			iwl_trans->cfg = cfg;
6431afb0ae4SHaim Dreyfuss 		}
6441afb0ae4SHaim Dreyfuss 	}
645e705c121SKalle Valo #endif
646e705c121SKalle Valo 
647e705c121SKalle Valo 	pci_set_drvdata(pdev, iwl_trans);
6486f482e37SSara Sharon 	iwl_trans->drv = iwl_drv_start(iwl_trans, cfg);
649e705c121SKalle Valo 
6506f482e37SSara Sharon 	if (IS_ERR(iwl_trans->drv)) {
6516f482e37SSara Sharon 		ret = PTR_ERR(iwl_trans->drv);
652e705c121SKalle Valo 		goto out_free_trans;
653e705c121SKalle Valo 	}
654e705c121SKalle Valo 
655e705c121SKalle Valo 	set_dflt_pwr_limit(iwl_trans, pdev);
656e705c121SKalle Valo 
657e705c121SKalle Valo 	/* register transport layer debugfs here */
658f8a1edb7SJohannes Berg 	ret = iwl_trans_pcie_dbgfs_register(iwl_trans);
659e705c121SKalle Valo 	if (ret)
660e705c121SKalle Valo 		goto out_free_drv;
661e705c121SKalle Valo 
6624cbb8e50SLuciano Coelho 	/* if RTPM is in use, enable it in our device */
6634cbb8e50SLuciano Coelho 	if (iwl_trans->runtime_pm_mode != IWL_PLAT_PM_MODE_DISABLED) {
6644479a899SLuca Coelho 		/* We explicitly set the device to active here to
6654479a899SLuca Coelho 		 * clear contingent errors.
6664479a899SLuca Coelho 		 */
667b3ff1270SLuca Coelho 		pm_runtime_set_active(&pdev->dev);
6684479a899SLuca Coelho 
669b3ff1270SLuca Coelho 		pm_runtime_set_autosuspend_delay(&pdev->dev,
670b3ff1270SLuca Coelho 					 iwlwifi_mod_params.d0i3_entry_delay);
671b3ff1270SLuca Coelho 		pm_runtime_use_autosuspend(&pdev->dev);
6724479a899SLuca Coelho 
6734479a899SLuca Coelho 		/* We are not supposed to call pm_runtime_allow() by
6744479a899SLuca Coelho 		 * ourselves, but let userspace enable runtime PM via
6754479a899SLuca Coelho 		 * sysfs.  However, since we don't enable this from
6764479a899SLuca Coelho 		 * userspace yet, we need to allow/forbid() ourselves.
6774479a899SLuca Coelho 		*/
678b3ff1270SLuca Coelho 		pm_runtime_allow(&pdev->dev);
6794cbb8e50SLuciano Coelho 	}
6804cbb8e50SLuciano Coelho 
6814479a899SLuca Coelho 	/* The PCI device starts with a reference taken and we are
6824479a899SLuca Coelho 	 * supposed to release it here.  But to simplify the
6834479a899SLuca Coelho 	 * interaction with the opmode, we don't do it now, but let
6845d93f3a2SLuca Coelho 	 * the opmode release it when it's ready.
6854479a899SLuca Coelho 	 */
6864479a899SLuca Coelho 
687e705c121SKalle Valo 	return 0;
688e705c121SKalle Valo 
689e705c121SKalle Valo out_free_drv:
6906f482e37SSara Sharon 	iwl_drv_stop(iwl_trans->drv);
691e705c121SKalle Valo out_free_trans:
692e705c121SKalle Valo 	iwl_trans_pcie_free(iwl_trans);
693e705c121SKalle Valo 	return ret;
694e705c121SKalle Valo }
695e705c121SKalle Valo 
696e705c121SKalle Valo static void iwl_pci_remove(struct pci_dev *pdev)
697e705c121SKalle Valo {
698e705c121SKalle Valo 	struct iwl_trans *trans = pci_get_drvdata(pdev);
699e705c121SKalle Valo 
7004479a899SLuca Coelho 	/* if RTPM was in use, restore it to the state before probe */
7014479a899SLuca Coelho 	if (trans->runtime_pm_mode != IWL_PLAT_PM_MODE_DISABLED) {
7024479a899SLuca Coelho 		/* We should not call forbid here, but we do for now.
7034479a899SLuca Coelho 		 * Check the comment to pm_runtime_allow() in
7044479a899SLuca Coelho 		 * iwl_pci_probe().
7054479a899SLuca Coelho 		 */
7064479a899SLuca Coelho 		pm_runtime_forbid(trans->dev);
7074479a899SLuca Coelho 	}
7084479a899SLuca Coelho 
7096f482e37SSara Sharon 	iwl_drv_stop(trans->drv);
7104479a899SLuca Coelho 
711e705c121SKalle Valo 	iwl_trans_pcie_free(trans);
712e705c121SKalle Valo }
713e705c121SKalle Valo 
714e705c121SKalle Valo #ifdef CONFIG_PM_SLEEP
715e705c121SKalle Valo 
716e705c121SKalle Valo static int iwl_pci_suspend(struct device *device)
717e705c121SKalle Valo {
718e705c121SKalle Valo 	/* Before you put code here, think about WoWLAN. You cannot check here
719e705c121SKalle Valo 	 * whether WoWLAN is enabled or not, and your code will run even if
720e705c121SKalle Valo 	 * WoWLAN is enabled - don't kill the NIC, someone may need it in Sx.
721e705c121SKalle Valo 	 */
722e705c121SKalle Valo 
723e705c121SKalle Valo 	return 0;
724e705c121SKalle Valo }
725e705c121SKalle Valo 
726e705c121SKalle Valo static int iwl_pci_resume(struct device *device)
727e705c121SKalle Valo {
728e705c121SKalle Valo 	struct pci_dev *pdev = to_pci_dev(device);
729e705c121SKalle Valo 	struct iwl_trans *trans = pci_get_drvdata(pdev);
730e705c121SKalle Valo 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
731e705c121SKalle Valo 	bool hw_rfkill;
732e705c121SKalle Valo 
733e705c121SKalle Valo 	/* Before you put code here, think about WoWLAN. You cannot check here
734e705c121SKalle Valo 	 * whether WoWLAN is enabled or not, and your code will run even if
735e705c121SKalle Valo 	 * WoWLAN is enabled - the NIC may be alive.
736e705c121SKalle Valo 	 */
737e705c121SKalle Valo 
738e705c121SKalle Valo 	/*
739e705c121SKalle Valo 	 * We disable the RETRY_TIMEOUT register (0x41) to keep
740e705c121SKalle Valo 	 * PCI Tx retries from interfering with C3 CPU state.
741e705c121SKalle Valo 	 */
742e705c121SKalle Valo 	pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
743e705c121SKalle Valo 
744e705c121SKalle Valo 	if (!trans->op_mode)
745e705c121SKalle Valo 		return 0;
746e705c121SKalle Valo 
747e705c121SKalle Valo 	/*
748e705c121SKalle Valo 	 * Enable rfkill interrupt (in order to keep track of
749e705c121SKalle Valo 	 * the rfkill status)
750e705c121SKalle Valo 	 */
751e705c121SKalle Valo 	iwl_enable_rfkill_int(trans);
752e705c121SKalle Valo 
753e705c121SKalle Valo 	hw_rfkill = iwl_is_rfkill_set(trans);
754e705c121SKalle Valo 
755e705c121SKalle Valo 	mutex_lock(&trans_pcie->mutex);
756e705c121SKalle Valo 	iwl_trans_pcie_rf_kill(trans, hw_rfkill);
757e705c121SKalle Valo 	mutex_unlock(&trans_pcie->mutex);
758e705c121SKalle Valo 
759e705c121SKalle Valo 	return 0;
760e705c121SKalle Valo }
761e705c121SKalle Valo 
7624cbb8e50SLuciano Coelho int iwl_pci_fw_enter_d0i3(struct iwl_trans *trans)
7634cbb8e50SLuciano Coelho {
7644cbb8e50SLuciano Coelho 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
7654cbb8e50SLuciano Coelho 	int ret;
7664cbb8e50SLuciano Coelho 
7674cbb8e50SLuciano Coelho 	if (test_bit(STATUS_FW_ERROR, &trans->status))
7684cbb8e50SLuciano Coelho 		return 0;
7694cbb8e50SLuciano Coelho 
7704cbb8e50SLuciano Coelho 	set_bit(STATUS_TRANS_GOING_IDLE, &trans->status);
7714cbb8e50SLuciano Coelho 
7724cbb8e50SLuciano Coelho 	/* config the fw */
7734cbb8e50SLuciano Coelho 	ret = iwl_op_mode_enter_d0i3(trans->op_mode);
7744cbb8e50SLuciano Coelho 	if (ret == 1) {
7754cbb8e50SLuciano Coelho 		IWL_DEBUG_RPM(trans, "aborting d0i3 entrance\n");
7764cbb8e50SLuciano Coelho 		clear_bit(STATUS_TRANS_GOING_IDLE, &trans->status);
7774cbb8e50SLuciano Coelho 		return -EBUSY;
7784cbb8e50SLuciano Coelho 	}
7794cbb8e50SLuciano Coelho 	if (ret)
7804cbb8e50SLuciano Coelho 		goto err;
7814cbb8e50SLuciano Coelho 
7824cbb8e50SLuciano Coelho 	ret = wait_event_timeout(trans_pcie->d0i3_waitq,
7834cbb8e50SLuciano Coelho 				 test_bit(STATUS_TRANS_IDLE, &trans->status),
7844cbb8e50SLuciano Coelho 				 msecs_to_jiffies(IWL_TRANS_IDLE_TIMEOUT));
7854cbb8e50SLuciano Coelho 	if (!ret) {
7864cbb8e50SLuciano Coelho 		IWL_ERR(trans, "Timeout entering D0i3\n");
7874cbb8e50SLuciano Coelho 		ret = -ETIMEDOUT;
7884cbb8e50SLuciano Coelho 		goto err;
7894cbb8e50SLuciano Coelho 	}
7904cbb8e50SLuciano Coelho 
7914cbb8e50SLuciano Coelho 	clear_bit(STATUS_TRANS_GOING_IDLE, &trans->status);
7924cbb8e50SLuciano Coelho 
7934cbb8e50SLuciano Coelho 	return 0;
7944cbb8e50SLuciano Coelho err:
7954cbb8e50SLuciano Coelho 	clear_bit(STATUS_TRANS_GOING_IDLE, &trans->status);
7964cbb8e50SLuciano Coelho 	iwl_trans_fw_error(trans);
7974cbb8e50SLuciano Coelho 	return ret;
7984cbb8e50SLuciano Coelho }
7994cbb8e50SLuciano Coelho 
8004cbb8e50SLuciano Coelho int iwl_pci_fw_exit_d0i3(struct iwl_trans *trans)
8014cbb8e50SLuciano Coelho {
8024cbb8e50SLuciano Coelho 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
8034cbb8e50SLuciano Coelho 	int ret;
8044cbb8e50SLuciano Coelho 
8054cbb8e50SLuciano Coelho 	/* sometimes a D0i3 entry is not followed through */
8064cbb8e50SLuciano Coelho 	if (!test_bit(STATUS_TRANS_IDLE, &trans->status))
8074cbb8e50SLuciano Coelho 		return 0;
8084cbb8e50SLuciano Coelho 
8094cbb8e50SLuciano Coelho 	/* config the fw */
8104cbb8e50SLuciano Coelho 	ret = iwl_op_mode_exit_d0i3(trans->op_mode);
8114cbb8e50SLuciano Coelho 	if (ret)
8124cbb8e50SLuciano Coelho 		goto err;
8134cbb8e50SLuciano Coelho 
8144cbb8e50SLuciano Coelho 	/* we clear STATUS_TRANS_IDLE only when D0I3_END command is completed */
8154cbb8e50SLuciano Coelho 
8164cbb8e50SLuciano Coelho 	ret = wait_event_timeout(trans_pcie->d0i3_waitq,
8174cbb8e50SLuciano Coelho 				 !test_bit(STATUS_TRANS_IDLE, &trans->status),
8184cbb8e50SLuciano Coelho 				 msecs_to_jiffies(IWL_TRANS_IDLE_TIMEOUT));
8194cbb8e50SLuciano Coelho 	if (!ret) {
8204cbb8e50SLuciano Coelho 		IWL_ERR(trans, "Timeout exiting D0i3\n");
8214cbb8e50SLuciano Coelho 		ret = -ETIMEDOUT;
8224cbb8e50SLuciano Coelho 		goto err;
8234cbb8e50SLuciano Coelho 	}
8244cbb8e50SLuciano Coelho 
8254cbb8e50SLuciano Coelho 	return 0;
8264cbb8e50SLuciano Coelho err:
8274cbb8e50SLuciano Coelho 	clear_bit(STATUS_TRANS_IDLE, &trans->status);
8284cbb8e50SLuciano Coelho 	iwl_trans_fw_error(trans);
8294cbb8e50SLuciano Coelho 	return ret;
8304cbb8e50SLuciano Coelho }
8314cbb8e50SLuciano Coelho 
832b3ff1270SLuca Coelho #ifdef CONFIG_IWLWIFI_PCIE_RTPM
833b3ff1270SLuca Coelho static int iwl_pci_runtime_suspend(struct device *device)
834b3ff1270SLuca Coelho {
835b3ff1270SLuca Coelho 	struct pci_dev *pdev = to_pci_dev(device);
836b3ff1270SLuca Coelho 	struct iwl_trans *trans = pci_get_drvdata(pdev);
8374cbb8e50SLuciano Coelho 	int ret;
838b3ff1270SLuca Coelho 
839b3ff1270SLuca Coelho 	IWL_DEBUG_RPM(trans, "entering runtime suspend\n");
840b3ff1270SLuca Coelho 
8414cbb8e50SLuciano Coelho 	if (test_bit(STATUS_DEVICE_ENABLED, &trans->status)) {
8424cbb8e50SLuciano Coelho 		ret = iwl_pci_fw_enter_d0i3(trans);
8434cbb8e50SLuciano Coelho 		if (ret < 0)
8444cbb8e50SLuciano Coelho 			return ret;
8454cbb8e50SLuciano Coelho 	}
846b3ff1270SLuca Coelho 
847b3ff1270SLuca Coelho 	trans->system_pm_mode = IWL_PLAT_PM_MODE_D0I3;
848b3ff1270SLuca Coelho 
84923ae6128SMatti Gottlieb 	iwl_trans_d3_suspend(trans, false, false);
850b3ff1270SLuca Coelho 
851b3ff1270SLuca Coelho 	return 0;
852b3ff1270SLuca Coelho }
853b3ff1270SLuca Coelho 
854b3ff1270SLuca Coelho static int iwl_pci_runtime_resume(struct device *device)
855b3ff1270SLuca Coelho {
856b3ff1270SLuca Coelho 	struct pci_dev *pdev = to_pci_dev(device);
857b3ff1270SLuca Coelho 	struct iwl_trans *trans = pci_get_drvdata(pdev);
858b3ff1270SLuca Coelho 	enum iwl_d3_status d3_status;
859b3ff1270SLuca Coelho 
860b3ff1270SLuca Coelho 	IWL_DEBUG_RPM(trans, "exiting runtime suspend (resume)\n");
861b3ff1270SLuca Coelho 
86223ae6128SMatti Gottlieb 	iwl_trans_d3_resume(trans, &d3_status, false, false);
863b3ff1270SLuca Coelho 
8644cbb8e50SLuciano Coelho 	if (test_bit(STATUS_DEVICE_ENABLED, &trans->status))
8654cbb8e50SLuciano Coelho 		return iwl_pci_fw_exit_d0i3(trans);
866b3ff1270SLuca Coelho 
867b3ff1270SLuca Coelho 	return 0;
868b3ff1270SLuca Coelho }
869863eac30SLuca Coelho 
870863eac30SLuca Coelho static int iwl_pci_system_prepare(struct device *device)
871863eac30SLuca Coelho {
872863eac30SLuca Coelho 	struct pci_dev *pdev = to_pci_dev(device);
873863eac30SLuca Coelho 	struct iwl_trans *trans = pci_get_drvdata(pdev);
874863eac30SLuca Coelho 
875863eac30SLuca Coelho 	IWL_DEBUG_RPM(trans, "preparing for system suspend\n");
876863eac30SLuca Coelho 
877863eac30SLuca Coelho 	/* This is called before entering system suspend and before
878863eac30SLuca Coelho 	 * the runtime resume is called.  Set the suspending flag to
879863eac30SLuca Coelho 	 * prevent the wakelock from being taken.
880863eac30SLuca Coelho 	 */
881863eac30SLuca Coelho 	trans->suspending = true;
882863eac30SLuca Coelho 
883863eac30SLuca Coelho 	/* Wake the device up from runtime suspend before going to
884863eac30SLuca Coelho 	 * platform suspend.  This is needed because we don't know
885863eac30SLuca Coelho 	 * whether wowlan any is set and, if it's not, mac80211 will
886863eac30SLuca Coelho 	 * disconnect (in which case, we can't be in D0i3).
887863eac30SLuca Coelho 	 */
888863eac30SLuca Coelho 	pm_runtime_resume(device);
889863eac30SLuca Coelho 
890863eac30SLuca Coelho 	return 0;
891863eac30SLuca Coelho }
892863eac30SLuca Coelho 
893863eac30SLuca Coelho static void iwl_pci_system_complete(struct device *device)
894863eac30SLuca Coelho {
895863eac30SLuca Coelho 	struct pci_dev *pdev = to_pci_dev(device);
896863eac30SLuca Coelho 	struct iwl_trans *trans = pci_get_drvdata(pdev);
897863eac30SLuca Coelho 
898863eac30SLuca Coelho 	IWL_DEBUG_RPM(trans, "completing system suspend\n");
899863eac30SLuca Coelho 
900863eac30SLuca Coelho 	/* This is called as a counterpart to the prepare op.  It is
901863eac30SLuca Coelho 	 * called either when suspending fails or when suspend
902863eac30SLuca Coelho 	 * completed successfully.  Now there's no risk of grabbing
903863eac30SLuca Coelho 	 * the wakelock anymore, so we can release the suspending
904863eac30SLuca Coelho 	 * flag.
905863eac30SLuca Coelho 	 */
906863eac30SLuca Coelho 	trans->suspending = false;
907863eac30SLuca Coelho }
908b3ff1270SLuca Coelho #endif /* CONFIG_IWLWIFI_PCIE_RTPM */
909b3ff1270SLuca Coelho 
910b3ff1270SLuca Coelho static const struct dev_pm_ops iwl_dev_pm_ops = {
911b3ff1270SLuca Coelho 	SET_SYSTEM_SLEEP_PM_OPS(iwl_pci_suspend,
912b3ff1270SLuca Coelho 				iwl_pci_resume)
913b3ff1270SLuca Coelho #ifdef CONFIG_IWLWIFI_PCIE_RTPM
914b3ff1270SLuca Coelho 	SET_RUNTIME_PM_OPS(iwl_pci_runtime_suspend,
915b3ff1270SLuca Coelho 			   iwl_pci_runtime_resume,
916b3ff1270SLuca Coelho 			   NULL)
917863eac30SLuca Coelho 	.prepare = iwl_pci_system_prepare,
918863eac30SLuca Coelho 	.complete = iwl_pci_system_complete,
919b3ff1270SLuca Coelho #endif /* CONFIG_IWLWIFI_PCIE_RTPM */
920b3ff1270SLuca Coelho };
921e705c121SKalle Valo 
922e705c121SKalle Valo #define IWL_PM_OPS	(&iwl_dev_pm_ops)
923e705c121SKalle Valo 
924b3ff1270SLuca Coelho #else /* CONFIG_PM_SLEEP */
925e705c121SKalle Valo 
926e705c121SKalle Valo #define IWL_PM_OPS	NULL
927e705c121SKalle Valo 
928b3ff1270SLuca Coelho #endif /* CONFIG_PM_SLEEP */
929e705c121SKalle Valo 
930e705c121SKalle Valo static struct pci_driver iwl_pci_driver = {
931e705c121SKalle Valo 	.name = DRV_NAME,
932e705c121SKalle Valo 	.id_table = iwl_hw_card_ids,
933e705c121SKalle Valo 	.probe = iwl_pci_probe,
934e705c121SKalle Valo 	.remove = iwl_pci_remove,
935e705c121SKalle Valo 	.driver.pm = IWL_PM_OPS,
936e705c121SKalle Valo };
937e705c121SKalle Valo 
938e705c121SKalle Valo int __must_check iwl_pci_register_driver(void)
939e705c121SKalle Valo {
940e705c121SKalle Valo 	int ret;
941e705c121SKalle Valo 	ret = pci_register_driver(&iwl_pci_driver);
942e705c121SKalle Valo 	if (ret)
943e705c121SKalle Valo 		pr_err("Unable to initialize PCI module\n");
944e705c121SKalle Valo 
945e705c121SKalle Valo 	return ret;
946e705c121SKalle Valo }
947e705c121SKalle Valo 
948e705c121SKalle Valo void iwl_pci_unregister_driver(void)
949e705c121SKalle Valo {
950e705c121SKalle Valo 	pci_unregister_driver(&iwl_pci_driver);
951e705c121SKalle Valo }
952