xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/nxp/mlinux/moal_pcie.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /** @file moal_pcie.h
2  *
3  *  @brief This file contains definitions for PCIE interface.
4  *  driver.
5  *
6  *
7  * Copyright 2014-2021 NXP
8  *
9  * This software file (the File) is distributed by NXP
10  * under the terms of the GNU General Public License Version 2, June 1991
11  * (the License).  You may use, redistribute and/or modify the File in
12  * accordance with the terms and conditions of the License, a copy of which
13  * is available by writing to the Free Software Foundation, Inc.,
14  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
15  * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
16  *
17  * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
19  * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
20  * this warranty disclaimer.
21  *
22  */
23 
24 /********************************************************
25 Change log:
26     02/01/2012: initial version
27 ********************************************************/
28 
29 #ifndef _MOAL_PCIE_H_
30 #define _MOAL_PCIE_H_
31 
32 #define PCIE_VENDOR_ID_MRVL (0x11ab)
33 #define PCIE_VENDOR_ID_V2_MRVL (0x1b4b)
34 #define PCIE_VENDOR_ID_NXP (0x1131)
35 
36 #ifdef PCIE8997
37 /** PCIE device ID for 8997 card */
38 #define PCIE_DEVICE_ID_88W8997P (0x2b42)
39 #endif
40 #ifdef PCIE8897
41 /** PCIE device ID for 8897 card */
42 #define PCIE_DEVICE_ID_88W8897P (0x2b38)
43 #endif
44 
45 #ifdef PCIE9097
46 /** PCIE device ID for 9097 card */
47 #define PCIE_DEVICE_ID_88W9097 (0x2b56)
48 #endif
49 
50 #ifdef PCIE9098
51 /** PCIE device ID for 9098 card FN0 */
52 #define PCIE_DEVICE_ID_88W9098P_FN0 (0x2b43)
53 /** PCIE device ID for 9098 card FN1 */
54 #define PCIE_DEVICE_ID_88W9098P_FN1 (0x2b44)
55 #endif
56 
57 #ifdef PCIENW62X
58 /** PCIE device ID for NW62X card FN0 */
59 #define PCIE_DEVICE_ID_88WNW62X (0x3000)
60 #endif
61 
62 #include <linux/version.h>
63 #include <linux/pci.h>
64 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 17, 0)
65 #include <linux/pcieport_if.h>
66 #endif
67 #include <linux/interrupt.h>
68 
69 #include "moal_main.h"
70 
71 /** Default firmware name */
72 #ifdef PCIE8997
73 #define PCIE8997_DEFAULT_COMBO_FW_NAME "nxp/pcieusb8997_combo_v4.bin"
74 #define PCIEUART8997_DEFAULT_COMBO_FW_NAME "nxp/pcieuart8997_combo_v4.bin"
75 #define PCIEUSB8997_DEFAULT_COMBO_FW_NAME "nxp/pcieusb8997_combo_v4.bin"
76 #define PCIE8997_DEFAULT_WLAN_FW_NAME "nxp/pcie8997_wlan_v4.bin"
77 /** PCIE8997 chip revision ID */
78 #define PCIE8997_A0 0x10
79 #define PCIE8997_A1 0x11
80 #endif /* PCIE8997 */
81 
82 #ifdef PCIE8897
83 #define PCIE8897_DEFAULT_COMBO_FW_NAME "nxp/pcie8897_uapsta.bin"
84 #define PCIE8897_DEFAULT_WLAN_FW_NAME "nxp/pcie8897_wlan.bin"
85 #endif /* PCIE8897*/
86 
87 #ifdef PCIE9098
88 #define PCIE9098_Z1Z2 0x00
89 #define PCIE9098_A0 0x01
90 #define PCIE9098_A1 0x02
91 #define PCIE9098_A2 0x03
92 #define PCIE9098_DEFAULT_COMBO_FW_NAME "nxp/pcieusb9098_combo.bin"
93 #define PCIEUART9098_DEFAULT_COMBO_FW_NAME "nxp/pcieuart9098_combo.bin"
94 #define PCIEUSB9098_DEFAULT_COMBO_FW_NAME "nxp/pcieusb9098_combo.bin"
95 #define PCIEPCIE9098_DEFAULT_COMBO_FW_NAME "nxp/pciepcie9098_combo.bin"
96 #define PCIEUART9098_COMBO_V1_FW_NAME "nxp/pcieuart9098_combo_v1.bin"
97 #define PCIEUSB9098_COMBO_V1_FW_NAME "nxp/pcieusb9098_combo_v1.bin"
98 #define PCIEPCIE9098_COMBO_V1_FW_NAME "nxp/pciepcie9098_combo_v1.bin"
99 #define PCIE9098_DEFAULT_WLAN_FW_NAME "nxp/pcie9098_wlan.bin"
100 #define PCIE9098_WLAN_V1_FW_NAME "nxp/pcie9098_wlan_v1.bin"
101 #endif /* PCIE9098 */
102 
103 #ifdef PCIE9097
104 #define PCIE9097_A0 0x00
105 #define PCIE9097_B0 0x01
106 #define PCIE9097_B1 0x02
107 #define PCIE9097_DEFAULT_COMBO_FW_NAME "nxp/pcieusbiw620_combo.bin"
108 #define PCIEUART9097_DEFAULT_COMBO_FW_NAME "nxp/pcieuartiw620_combo.bin"
109 #define PCIEUSB9097_DEFAULT_COMBO_FW_NAME "nxp/pcieusbiw620_combo.bin"
110 #define PCIEUART9097_COMBO_V1_FW_NAME "nxp/pcieuartiw620_combo_v1.bin"
111 #define PCIEUSB9097_COMBO_V1_FW_NAME "nxp/pcieusbiw620_combo_v1.bin"
112 #define PCIE9097_DEFAULT_WLAN_FW_NAME "nxp/pcieiw620_wlan.bin"
113 #define PCIE9097_WLAN_V1_FW_NAME "nxp/pcieiw620_wlan_v1.bin"
114 #endif /* PCIE9097 */
115 
116 #ifdef PCIENW62X
117 #define PCIENW62X_DEFAULT_COMBO_FW_NAME "nxp/pcieusbnw62x_combo.bin"
118 #define PCIEUARTNW62X_DEFAULT_COMBO_FW_NAME "nxp/pcieuartnw62x_combo.bin"
119 #define PCIEUSBNW62X_DEFAULT_COMBO_FW_NAME "nxp/pcieusbnw62x_combo.bin"
120 #define PCIENW62X_DEFAULT_WLAN_FW_NAME "nxp/pcienw62x_wlan.bin"
121 #endif /* PCIENW62X */
122 
123 #if defined(PCIE9098) || defined(PCIE9097) || defined(PCIENW62X)
124 #define PCIE_NUM_MSIX_VECTORS 32
125 #else
126 #define PCIE_NUM_MSIX_VECTORS 4
127 #endif
128 
129 typedef struct _msix_context {
130 	/** pci_dev structure pointer */
131 	struct pci_dev *dev;
132 	/** message id related to msix vector */
133 	t_u16 msg_id;
134 } msix_context;
135 
136 /** Structure: PCIE service card */
137 typedef struct _pcie_service_card {
138 	/** pci_dev structure pointer */
139 	struct pci_dev *dev;
140 	/** moal_handle structure pointer */
141 	moal_handle *handle;
142 	/** I/O memory regions pointer to the bus */
143 	void __iomem *pci_mmap;
144 	/** I/O memory regions pointer to the bus */
145 	void __iomem *pci_mmap1;
146 #if defined(PCIE)
147 	struct msix_entry msix_entries[PCIE_NUM_MSIX_VECTORS];
148 	msix_context msix_contexts[PCIE_NUM_MSIX_VECTORS];
149 #endif
150 } pcie_service_card, *ppcie_service_card;
151 
152 /** Register to bus driver function */
153 mlan_status woal_pcie_bus_register(void);
154 /** Unregister from bus driver function */
155 void woal_pcie_bus_unregister(void);
156 
157 #endif /* _MOAL_PCIE_H_ */
158