2 * NXP Wireless LAN device driver: PCIE and platform specific quirks
4 * This software file (the "File") is distributed by NXP
5 * under the terms of the GNU General Public License Version 2, June 1991
6 * (the "License"). You may use, redistribute and/or modify this File in
7 * accordance with the terms and conditions of the License, a copy of which
8 * is available by writing to the Free Software Foundation, Inc.,
9 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
10 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
12 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
13 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
14 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
15 * this warranty disclaimer.
18 #include <linux/dmi.h>
20 #include "pcie_quirks.h"
22 /* quirk table based on DMI matching */
23 static const struct dmi_system_id mwifiex_quirk_table[] = {
25 .ident = "Surface Pro 4",
27 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
28 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 4"),
30 .driver_data = (void *)QUIRK_FW_RST_D3COLD,
33 .ident = "Surface Pro 5",
35 /* match for SKU here due to generic product name "Surface Pro" */
36 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
37 DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1796"),
39 .driver_data = (void *)QUIRK_FW_RST_D3COLD,
42 .ident = "Surface Pro 5 (LTE)",
44 /* match for SKU here due to generic product name "Surface Pro" */
45 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
46 DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1807"),
48 .driver_data = (void *)QUIRK_FW_RST_D3COLD,
51 .ident = "Surface Pro 6",
53 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
54 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 6"),
56 .driver_data = (void *)QUIRK_FW_RST_D3COLD,
59 .ident = "Surface Book 1",
61 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
62 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book"),
64 .driver_data = (void *)QUIRK_FW_RST_D3COLD,
67 .ident = "Surface Book 2",
69 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
70 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book 2"),
72 .driver_data = (void *)QUIRK_FW_RST_D3COLD,
75 .ident = "Surface Laptop 1",
77 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
78 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop"),
80 .driver_data = (void *)QUIRK_FW_RST_D3COLD,
83 .ident = "Surface Laptop 2",
85 DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
86 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop 2"),
88 .driver_data = (void *)QUIRK_FW_RST_D3COLD,
93 void mwifiex_initialize_quirks(struct pcie_service_card *card)
95 struct pci_dev *pdev = card->dev;
96 const struct dmi_system_id *dmi_id;
98 dmi_id = dmi_first_match(mwifiex_quirk_table);
100 card->quirks = (uintptr_t)dmi_id->driver_data;
103 dev_info(&pdev->dev, "no quirks enabled\n");
104 if (card->quirks & QUIRK_FW_RST_D3COLD)
105 dev_info(&pdev->dev, "quirk reset_d3cold enabled\n");
108 static void mwifiex_pcie_set_power_d3cold(struct pci_dev *pdev)
110 dev_info(&pdev->dev, "putting into D3cold...\n");
112 pci_save_state(pdev);
113 if (pci_is_enabled(pdev))
114 pci_disable_device(pdev);
115 pci_set_power_state(pdev, PCI_D3cold);
118 static int mwifiex_pcie_set_power_d0(struct pci_dev *pdev)
122 dev_info(&pdev->dev, "putting into D0...\n");
124 pci_set_power_state(pdev, PCI_D0);
125 ret = pci_enable_device(pdev);
127 dev_err(&pdev->dev, "pci_enable_device failed\n");
130 pci_restore_state(pdev);
135 int mwifiex_pcie_reset_d3cold_quirk(struct pci_dev *pdev)
137 struct pci_dev *parent_pdev = pci_upstream_bridge(pdev);
140 /* Power-cycle (put into D3cold then D0) */
141 dev_info(&pdev->dev, "Using reset_d3cold quirk to perform FW reset\n");
143 /* We need to perform power-cycle also for bridge of wifi because
144 * on some devices (e.g. Surface Book 1), the OS for some reasons
145 * can't know the real power state of the bridge.
146 * When tried to power-cycle only wifi, the reset failed with the
147 * following dmesg log:
148 * "Cannot transition to power state D0 for parent in D3hot".
150 mwifiex_pcie_set_power_d3cold(pdev);
151 mwifiex_pcie_set_power_d3cold(parent_pdev);
153 ret = mwifiex_pcie_set_power_d0(parent_pdev);
156 ret = mwifiex_pcie_set_power_d0(pdev);