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