162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2005-2014, 2020-2021, 2023 Intel Corporation
462306a36Sopenharmony_ci * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef __iwl_drv_h__
762306a36Sopenharmony_ci#define __iwl_drv_h__
862306a36Sopenharmony_ci#include <linux/export.h>
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/* for all modules */
1162306a36Sopenharmony_ci#define DRV_NAME        "iwlwifi"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* radio config bits (actual values from NVM definition) */
1462306a36Sopenharmony_ci#define NVM_RF_CFG_DASH_MSK(x)   (x & 0x3)         /* bits 0-1   */
1562306a36Sopenharmony_ci#define NVM_RF_CFG_STEP_MSK(x)   ((x >> 2)  & 0x3) /* bits 2-3   */
1662306a36Sopenharmony_ci#define NVM_RF_CFG_TYPE_MSK(x)   ((x >> 4)  & 0x3) /* bits 4-5   */
1762306a36Sopenharmony_ci#define NVM_RF_CFG_PNUM_MSK(x)   ((x >> 6)  & 0x3) /* bits 6-7   */
1862306a36Sopenharmony_ci#define NVM_RF_CFG_TX_ANT_MSK(x) ((x >> 8)  & 0xF) /* bits 8-11  */
1962306a36Sopenharmony_ci#define NVM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define EXT_NVM_RF_CFG_FLAVOR_MSK(x)   ((x) & 0xF)
2262306a36Sopenharmony_ci#define EXT_NVM_RF_CFG_DASH_MSK(x)   (((x) >> 4) & 0xF)
2362306a36Sopenharmony_ci#define EXT_NVM_RF_CFG_STEP_MSK(x)   (((x) >> 8) & 0xF)
2462306a36Sopenharmony_ci#define EXT_NVM_RF_CFG_TYPE_MSK(x)   (((x) >> 12) & 0xFFF)
2562306a36Sopenharmony_ci#define EXT_NVM_RF_CFG_TX_ANT_MSK(x) (((x) >> 24) & 0xF)
2662306a36Sopenharmony_ci#define EXT_NVM_RF_CFG_RX_ANT_MSK(x) (((x) >> 28) & 0xF)
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/**
2962306a36Sopenharmony_ci * DOC: Driver system flows - drv component
3062306a36Sopenharmony_ci *
3162306a36Sopenharmony_ci * This component implements the system flows such as bus enumeration, bus
3262306a36Sopenharmony_ci * removal. Bus dependent parts of system flows (such as iwl_pci_probe) are in
3362306a36Sopenharmony_ci * bus specific files (transport files). This is the code that is common among
3462306a36Sopenharmony_ci * different buses.
3562306a36Sopenharmony_ci *
3662306a36Sopenharmony_ci * This component is also in charge of managing the several implementations of
3762306a36Sopenharmony_ci * the wifi flows: it will allow to have several fw API implementation. These
3862306a36Sopenharmony_ci * different implementations will differ in the way they implement mac80211's
3962306a36Sopenharmony_ci * handlers too.
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci * The init flow wrt to the drv component looks like this:
4262306a36Sopenharmony_ci * 1) The bus specific component is called from module_init
4362306a36Sopenharmony_ci * 2) The bus specific component registers the bus driver
4462306a36Sopenharmony_ci * 3) The bus driver calls the probe function
4562306a36Sopenharmony_ci * 4) The bus specific component configures the bus
4662306a36Sopenharmony_ci * 5) The bus specific component calls to the drv bus agnostic part
4762306a36Sopenharmony_ci *    (iwl_drv_start)
4862306a36Sopenharmony_ci * 6) iwl_drv_start fetches the fw ASYNC, iwl_req_fw_callback
4962306a36Sopenharmony_ci * 7) iwl_req_fw_callback parses the fw file
5062306a36Sopenharmony_ci * 8) iwl_req_fw_callback starts the wifi implementation to matches the fw
5162306a36Sopenharmony_ci */
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_cistruct iwl_drv;
5462306a36Sopenharmony_cistruct iwl_trans;
5562306a36Sopenharmony_cistruct iwl_cfg;
5662306a36Sopenharmony_ci/**
5762306a36Sopenharmony_ci * iwl_drv_start - start the drv
5862306a36Sopenharmony_ci *
5962306a36Sopenharmony_ci * @trans_ops: the ops of the transport
6062306a36Sopenharmony_ci *
6162306a36Sopenharmony_ci * starts the driver: fetches the firmware. This should be called by bus
6262306a36Sopenharmony_ci * specific system flows implementations. For example, the bus specific probe
6362306a36Sopenharmony_ci * function should do bus related operations only, and then call to this
6462306a36Sopenharmony_ci * function. It returns the driver object or %NULL if an error occurred.
6562306a36Sopenharmony_ci */
6662306a36Sopenharmony_cistruct iwl_drv *iwl_drv_start(struct iwl_trans *trans);
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci/**
6962306a36Sopenharmony_ci * iwl_drv_stop - stop the drv
7062306a36Sopenharmony_ci *
7162306a36Sopenharmony_ci * @drv:
7262306a36Sopenharmony_ci *
7362306a36Sopenharmony_ci * Stop the driver. This should be called by bus specific system flows
7462306a36Sopenharmony_ci * implementations. For example, the bus specific remove function should first
7562306a36Sopenharmony_ci * call this function and then do the bus related operations only.
7662306a36Sopenharmony_ci */
7762306a36Sopenharmony_civoid iwl_drv_stop(struct iwl_drv *drv);
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci/*
8062306a36Sopenharmony_ci * exported symbol management
8162306a36Sopenharmony_ci *
8262306a36Sopenharmony_ci * The driver can be split into multiple modules, in which case some symbols
8362306a36Sopenharmony_ci * must be exported for the sub-modules. However, if it's not split and
8462306a36Sopenharmony_ci * everything is built-in, then we can avoid that.
8562306a36Sopenharmony_ci */
8662306a36Sopenharmony_ci#ifdef CONFIG_IWLWIFI_OPMODE_MODULAR
8762306a36Sopenharmony_ci#define IWL_EXPORT_SYMBOL(sym)	EXPORT_SYMBOL_NS_GPL(sym, IWLWIFI)
8862306a36Sopenharmony_ci#else
8962306a36Sopenharmony_ci#define IWL_EXPORT_SYMBOL(sym)
9062306a36Sopenharmony_ci#endif
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci/* max retry for init flow */
9362306a36Sopenharmony_ci#define IWL_MAX_INIT_RETRY 2
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define FW_NAME_PRE_BUFSIZE	64
9662306a36Sopenharmony_cistruct iwl_trans;
9762306a36Sopenharmony_ciconst char *iwl_drv_get_fwname_pre(struct iwl_trans *trans, char *buf);
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#endif /* __iwl_drv_h__ */
100