xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/intel/iwlwifi/iwl-drv.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /******************************************************************************
2*4882a593Smuzhiyun  *
3*4882a593Smuzhiyun  * This file is provided under a dual BSD/GPLv2 license.  When using or
4*4882a593Smuzhiyun  * redistributing this file, you may do so under either license.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * GPL LICENSE SUMMARY
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Copyright(c) 2008 - 2014, 2020 Intel Corporation. All rights reserved.
9*4882a593Smuzhiyun  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or modify
12*4882a593Smuzhiyun  * it under the terms of version 2 of the GNU General Public License as
13*4882a593Smuzhiyun  * published by the Free Software Foundation.
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * This program is distributed in the hope that it will be useful, but
16*4882a593Smuzhiyun  * WITHOUT ANY WARRANTY; without even the implied warranty of
17*4882a593Smuzhiyun  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18*4882a593Smuzhiyun  * General Public License for more details.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * The full GNU General Public License is included in this distribution
21*4882a593Smuzhiyun  * in the file called COPYING.
22*4882a593Smuzhiyun  *
23*4882a593Smuzhiyun  * Contact Information:
24*4882a593Smuzhiyun  *  Intel Linux Wireless <linuxwifi@intel.com>
25*4882a593Smuzhiyun  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  * BSD LICENSE
28*4882a593Smuzhiyun  *
29*4882a593Smuzhiyun  * Copyright(c) 2005 - 2014, 2020 Intel Corporation. All rights reserved.
30*4882a593Smuzhiyun  * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
31*4882a593Smuzhiyun  * All rights reserved.
32*4882a593Smuzhiyun  *
33*4882a593Smuzhiyun  * Redistribution and use in source and binary forms, with or without
34*4882a593Smuzhiyun  * modification, are permitted provided that the following conditions
35*4882a593Smuzhiyun  * are met:
36*4882a593Smuzhiyun  *
37*4882a593Smuzhiyun  *  * Redistributions of source code must retain the above copyright
38*4882a593Smuzhiyun  *    notice, this list of conditions and the following disclaimer.
39*4882a593Smuzhiyun  *  * Redistributions in binary form must reproduce the above copyright
40*4882a593Smuzhiyun  *    notice, this list of conditions and the following disclaimer in
41*4882a593Smuzhiyun  *    the documentation and/or other materials provided with the
42*4882a593Smuzhiyun  *    distribution.
43*4882a593Smuzhiyun  *  * Neither the name Intel Corporation nor the names of its
44*4882a593Smuzhiyun  *    contributors may be used to endorse or promote products derived
45*4882a593Smuzhiyun  *    from this software without specific prior written permission.
46*4882a593Smuzhiyun  *
47*4882a593Smuzhiyun  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48*4882a593Smuzhiyun  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49*4882a593Smuzhiyun  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
50*4882a593Smuzhiyun  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51*4882a593Smuzhiyun  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52*4882a593Smuzhiyun  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53*4882a593Smuzhiyun  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54*4882a593Smuzhiyun  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55*4882a593Smuzhiyun  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56*4882a593Smuzhiyun  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
57*4882a593Smuzhiyun  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58*4882a593Smuzhiyun  *****************************************************************************/
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun #ifndef __iwl_drv_h__
61*4882a593Smuzhiyun #define __iwl_drv_h__
62*4882a593Smuzhiyun #include <linux/export.h>
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun /* for all modules */
65*4882a593Smuzhiyun #define DRV_NAME        "iwlwifi"
66*4882a593Smuzhiyun #define DRV_AUTHOR	"Intel Corporation <linuxwifi@intel.com>"
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun /* radio config bits (actual values from NVM definition) */
69*4882a593Smuzhiyun #define NVM_RF_CFG_DASH_MSK(x)   (x & 0x3)         /* bits 0-1   */
70*4882a593Smuzhiyun #define NVM_RF_CFG_STEP_MSK(x)   ((x >> 2)  & 0x3) /* bits 2-3   */
71*4882a593Smuzhiyun #define NVM_RF_CFG_TYPE_MSK(x)   ((x >> 4)  & 0x3) /* bits 4-5   */
72*4882a593Smuzhiyun #define NVM_RF_CFG_PNUM_MSK(x)   ((x >> 6)  & 0x3) /* bits 6-7   */
73*4882a593Smuzhiyun #define NVM_RF_CFG_TX_ANT_MSK(x) ((x >> 8)  & 0xF) /* bits 8-11  */
74*4882a593Smuzhiyun #define NVM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun #define EXT_NVM_RF_CFG_FLAVOR_MSK(x)   ((x) & 0xF)
77*4882a593Smuzhiyun #define EXT_NVM_RF_CFG_DASH_MSK(x)   (((x) >> 4) & 0xF)
78*4882a593Smuzhiyun #define EXT_NVM_RF_CFG_STEP_MSK(x)   (((x) >> 8) & 0xF)
79*4882a593Smuzhiyun #define EXT_NVM_RF_CFG_TYPE_MSK(x)   (((x) >> 12) & 0xFFF)
80*4882a593Smuzhiyun #define EXT_NVM_RF_CFG_TX_ANT_MSK(x) (((x) >> 24) & 0xF)
81*4882a593Smuzhiyun #define EXT_NVM_RF_CFG_RX_ANT_MSK(x) (((x) >> 28) & 0xF)
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun /**
84*4882a593Smuzhiyun  * DOC: Driver system flows - drv component
85*4882a593Smuzhiyun  *
86*4882a593Smuzhiyun  * This component implements the system flows such as bus enumeration, bus
87*4882a593Smuzhiyun  * removal. Bus dependent parts of system flows (such as iwl_pci_probe) are in
88*4882a593Smuzhiyun  * bus specific files (transport files). This is the code that is common among
89*4882a593Smuzhiyun  * different buses.
90*4882a593Smuzhiyun  *
91*4882a593Smuzhiyun  * This component is also in charge of managing the several implementations of
92*4882a593Smuzhiyun  * the wifi flows: it will allow to have several fw API implementation. These
93*4882a593Smuzhiyun  * different implementations will differ in the way they implement mac80211's
94*4882a593Smuzhiyun  * handlers too.
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun  * The init flow wrt to the drv component looks like this:
97*4882a593Smuzhiyun  * 1) The bus specific component is called from module_init
98*4882a593Smuzhiyun  * 2) The bus specific component registers the bus driver
99*4882a593Smuzhiyun  * 3) The bus driver calls the probe function
100*4882a593Smuzhiyun  * 4) The bus specific component configures the bus
101*4882a593Smuzhiyun  * 5) The bus specific component calls to the drv bus agnostic part
102*4882a593Smuzhiyun  *    (iwl_drv_start)
103*4882a593Smuzhiyun  * 6) iwl_drv_start fetches the fw ASYNC, iwl_req_fw_callback
104*4882a593Smuzhiyun  * 7) iwl_req_fw_callback parses the fw file
105*4882a593Smuzhiyun  * 8) iwl_req_fw_callback starts the wifi implementation to matches the fw
106*4882a593Smuzhiyun  */
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun struct iwl_drv;
109*4882a593Smuzhiyun struct iwl_trans;
110*4882a593Smuzhiyun struct iwl_cfg;
111*4882a593Smuzhiyun /**
112*4882a593Smuzhiyun  * iwl_drv_start - start the drv
113*4882a593Smuzhiyun  *
114*4882a593Smuzhiyun  * @trans_ops: the ops of the transport
115*4882a593Smuzhiyun  *
116*4882a593Smuzhiyun  * starts the driver: fetches the firmware. This should be called by bus
117*4882a593Smuzhiyun  * specific system flows implementations. For example, the bus specific probe
118*4882a593Smuzhiyun  * function should do bus related operations only, and then call to this
119*4882a593Smuzhiyun  * function. It returns the driver object or %NULL if an error occurred.
120*4882a593Smuzhiyun  */
121*4882a593Smuzhiyun struct iwl_drv *iwl_drv_start(struct iwl_trans *trans);
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun /**
124*4882a593Smuzhiyun  * iwl_drv_stop - stop the drv
125*4882a593Smuzhiyun  *
126*4882a593Smuzhiyun  * @drv:
127*4882a593Smuzhiyun  *
128*4882a593Smuzhiyun  * Stop the driver. This should be called by bus specific system flows
129*4882a593Smuzhiyun  * implementations. For example, the bus specific remove function should first
130*4882a593Smuzhiyun  * call this function and then do the bus related operations only.
131*4882a593Smuzhiyun  */
132*4882a593Smuzhiyun void iwl_drv_stop(struct iwl_drv *drv);
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun /*
135*4882a593Smuzhiyun  * exported symbol management
136*4882a593Smuzhiyun  *
137*4882a593Smuzhiyun  * The driver can be split into multiple modules, in which case some symbols
138*4882a593Smuzhiyun  * must be exported for the sub-modules. However, if it's not split and
139*4882a593Smuzhiyun  * everything is built-in, then we can avoid that.
140*4882a593Smuzhiyun  */
141*4882a593Smuzhiyun #ifdef CONFIG_IWLWIFI_OPMODE_MODULAR
142*4882a593Smuzhiyun #define IWL_EXPORT_SYMBOL(sym)	EXPORT_SYMBOL_GPL(sym)
143*4882a593Smuzhiyun #else
144*4882a593Smuzhiyun #define IWL_EXPORT_SYMBOL(sym)
145*4882a593Smuzhiyun #endif
146*4882a593Smuzhiyun 
147*4882a593Smuzhiyun /* max retry for init flow */
148*4882a593Smuzhiyun #define IWL_MAX_INIT_RETRY 2
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun #endif /* __iwl_drv_h__ */
151