1bfcc09ddSBjoern A. Zeeb /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2bfcc09ddSBjoern A. Zeeb /* 39af1bba4SBjoern A. Zeeb * Copyright (C) 2005-2014, 2020-2021, 2023 Intel Corporation 4bfcc09ddSBjoern A. Zeeb * Copyright (C) 2013-2014 Intel Mobile Communications GmbH 5bfcc09ddSBjoern A. Zeeb */ 6bfcc09ddSBjoern A. Zeeb #ifndef __iwl_drv_h__ 7bfcc09ddSBjoern A. Zeeb #define __iwl_drv_h__ 8bfcc09ddSBjoern A. Zeeb #include <linux/export.h> 9*a4128aadSBjoern A. Zeeb #include <kunit/visibility.h> 10bfcc09ddSBjoern A. Zeeb 11bfcc09ddSBjoern A. Zeeb /* for all modules */ 12bfcc09ddSBjoern A. Zeeb #define DRV_NAME "iwlwifi" 13bfcc09ddSBjoern A. Zeeb 14bfcc09ddSBjoern A. Zeeb /* radio config bits (actual values from NVM definition) */ 15bfcc09ddSBjoern A. Zeeb #define NVM_RF_CFG_DASH_MSK(x) (x & 0x3) /* bits 0-1 */ 16bfcc09ddSBjoern A. Zeeb #define NVM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ 17bfcc09ddSBjoern A. Zeeb #define NVM_RF_CFG_TYPE_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ 18bfcc09ddSBjoern A. Zeeb #define NVM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ 19bfcc09ddSBjoern A. Zeeb #define NVM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ 20bfcc09ddSBjoern A. Zeeb #define NVM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ 21bfcc09ddSBjoern A. Zeeb 22bfcc09ddSBjoern A. Zeeb #define EXT_NVM_RF_CFG_FLAVOR_MSK(x) ((x) & 0xF) 23bfcc09ddSBjoern A. Zeeb #define EXT_NVM_RF_CFG_DASH_MSK(x) (((x) >> 4) & 0xF) 24bfcc09ddSBjoern A. Zeeb #define EXT_NVM_RF_CFG_STEP_MSK(x) (((x) >> 8) & 0xF) 25bfcc09ddSBjoern A. Zeeb #define EXT_NVM_RF_CFG_TYPE_MSK(x) (((x) >> 12) & 0xFFF) 26bfcc09ddSBjoern A. Zeeb #define EXT_NVM_RF_CFG_TX_ANT_MSK(x) (((x) >> 24) & 0xF) 27bfcc09ddSBjoern A. Zeeb #define EXT_NVM_RF_CFG_RX_ANT_MSK(x) (((x) >> 28) & 0xF) 28bfcc09ddSBjoern A. Zeeb 29bfcc09ddSBjoern A. Zeeb /** 30bfcc09ddSBjoern A. Zeeb * DOC: Driver system flows - drv component 31bfcc09ddSBjoern A. Zeeb * 32bfcc09ddSBjoern A. Zeeb * This component implements the system flows such as bus enumeration, bus 33bfcc09ddSBjoern A. Zeeb * removal. Bus dependent parts of system flows (such as iwl_pci_probe) are in 34bfcc09ddSBjoern A. Zeeb * bus specific files (transport files). This is the code that is common among 35bfcc09ddSBjoern A. Zeeb * different buses. 36bfcc09ddSBjoern A. Zeeb * 37bfcc09ddSBjoern A. Zeeb * This component is also in charge of managing the several implementations of 38bfcc09ddSBjoern A. Zeeb * the wifi flows: it will allow to have several fw API implementation. These 39bfcc09ddSBjoern A. Zeeb * different implementations will differ in the way they implement mac80211's 40bfcc09ddSBjoern A. Zeeb * handlers too. 41bfcc09ddSBjoern A. Zeeb 42bfcc09ddSBjoern A. Zeeb * The init flow wrt to the drv component looks like this: 43bfcc09ddSBjoern A. Zeeb * 1) The bus specific component is called from module_init 44bfcc09ddSBjoern A. Zeeb * 2) The bus specific component registers the bus driver 45bfcc09ddSBjoern A. Zeeb * 3) The bus driver calls the probe function 46bfcc09ddSBjoern A. Zeeb * 4) The bus specific component configures the bus 47bfcc09ddSBjoern A. Zeeb * 5) The bus specific component calls to the drv bus agnostic part 48bfcc09ddSBjoern A. Zeeb * (iwl_drv_start) 49bfcc09ddSBjoern A. Zeeb * 6) iwl_drv_start fetches the fw ASYNC, iwl_req_fw_callback 50bfcc09ddSBjoern A. Zeeb * 7) iwl_req_fw_callback parses the fw file 51bfcc09ddSBjoern A. Zeeb * 8) iwl_req_fw_callback starts the wifi implementation to matches the fw 52bfcc09ddSBjoern A. Zeeb */ 53bfcc09ddSBjoern A. Zeeb 54bfcc09ddSBjoern A. Zeeb struct iwl_drv; 55bfcc09ddSBjoern A. Zeeb struct iwl_trans; 56bfcc09ddSBjoern A. Zeeb struct iwl_cfg; 57bfcc09ddSBjoern A. Zeeb /** 58bfcc09ddSBjoern A. Zeeb * iwl_drv_start - start the drv 59bfcc09ddSBjoern A. Zeeb * 60*a4128aadSBjoern A. Zeeb * @trans: the transport 61bfcc09ddSBjoern A. Zeeb * 62bfcc09ddSBjoern A. Zeeb * starts the driver: fetches the firmware. This should be called by bus 63bfcc09ddSBjoern A. Zeeb * specific system flows implementations. For example, the bus specific probe 64bfcc09ddSBjoern A. Zeeb * function should do bus related operations only, and then call to this 65bfcc09ddSBjoern A. Zeeb * function. It returns the driver object or %NULL if an error occurred. 66bfcc09ddSBjoern A. Zeeb */ 67bfcc09ddSBjoern A. Zeeb struct iwl_drv *iwl_drv_start(struct iwl_trans *trans); 68bfcc09ddSBjoern A. Zeeb 69bfcc09ddSBjoern A. Zeeb /** 70bfcc09ddSBjoern A. Zeeb * iwl_drv_stop - stop the drv 71bfcc09ddSBjoern A. Zeeb * 72bfcc09ddSBjoern A. Zeeb * @drv: 73bfcc09ddSBjoern A. Zeeb * 74bfcc09ddSBjoern A. Zeeb * Stop the driver. This should be called by bus specific system flows 75bfcc09ddSBjoern A. Zeeb * implementations. For example, the bus specific remove function should first 76bfcc09ddSBjoern A. Zeeb * call this function and then do the bus related operations only. 77bfcc09ddSBjoern A. Zeeb */ 78bfcc09ddSBjoern A. Zeeb void iwl_drv_stop(struct iwl_drv *drv); 79bfcc09ddSBjoern A. Zeeb 80bfcc09ddSBjoern A. Zeeb /* 81bfcc09ddSBjoern A. Zeeb * exported symbol management 82bfcc09ddSBjoern A. Zeeb * 83bfcc09ddSBjoern A. Zeeb * The driver can be split into multiple modules, in which case some symbols 84bfcc09ddSBjoern A. Zeeb * must be exported for the sub-modules. However, if it's not split and 85bfcc09ddSBjoern A. Zeeb * everything is built-in, then we can avoid that. 86bfcc09ddSBjoern A. Zeeb */ 87bfcc09ddSBjoern A. Zeeb #ifdef CONFIG_IWLWIFI_OPMODE_MODULAR 88d9836fb4SBjoern A. Zeeb #define IWL_EXPORT_SYMBOL(sym) EXPORT_SYMBOL_NS_GPL(sym, IWLWIFI) 89bfcc09ddSBjoern A. Zeeb #else 90bfcc09ddSBjoern A. Zeeb #define IWL_EXPORT_SYMBOL(sym) 91bfcc09ddSBjoern A. Zeeb #endif 92bfcc09ddSBjoern A. Zeeb 93*a4128aadSBjoern A. Zeeb #if IS_ENABLED(CONFIG_IWLWIFI_KUNIT_TESTS) 94*a4128aadSBjoern A. Zeeb #define EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(sym) EXPORT_SYMBOL_IF_KUNIT(sym) 95*a4128aadSBjoern A. Zeeb #define VISIBLE_IF_IWLWIFI_KUNIT 96*a4128aadSBjoern A. Zeeb #else 97*a4128aadSBjoern A. Zeeb #define EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(sym) 98*a4128aadSBjoern A. Zeeb #define VISIBLE_IF_IWLWIFI_KUNIT static 99*a4128aadSBjoern A. Zeeb #endif 100d9836fb4SBjoern A. Zeeb 1019af1bba4SBjoern A. Zeeb #define FW_NAME_PRE_BUFSIZE 64 1029af1bba4SBjoern A. Zeeb struct iwl_trans; 1039af1bba4SBjoern A. Zeeb const char *iwl_drv_get_fwname_pre(struct iwl_trans *trans, char *buf); 1049af1bba4SBjoern A. Zeeb 105bfcc09ddSBjoern A. Zeeb #endif /* __iwl_drv_h__ */ 106