mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
Merge branch 'wireless-next' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi
This commit is contained in:
@@ -84,13 +84,13 @@ static void iwl1000_set_ct_threshold(struct iwl_priv *priv)
|
||||
static void iwl1000_nic_config(struct iwl_priv *priv)
|
||||
{
|
||||
/* set CSR_HW_CONFIG_REG for uCode use */
|
||||
iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG,
|
||||
iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG,
|
||||
CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
|
||||
CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
|
||||
|
||||
/* Setting digital SVR for 1000 card to 1.32V */
|
||||
/* locking is acquired in iwl_set_bits_mask_prph() function */
|
||||
iwl_set_bits_mask_prph(bus(priv), APMG_DIGITAL_SVR_REG,
|
||||
iwl_set_bits_mask_prph(trans(priv), APMG_DIGITAL_SVR_REG,
|
||||
APMG_SVR_DIGITAL_VOLTAGE_1_32,
|
||||
~APMG_SVR_VOLTAGE_CONFIG_BIT_MSK);
|
||||
}
|
||||
@@ -128,8 +128,6 @@ static int iwl1000_hw_set_hw_params(struct iwl_priv *priv)
|
||||
iwlagn_mod_params.num_of_queues;
|
||||
|
||||
hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
|
||||
priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
|
||||
|
||||
hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE;
|
||||
hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE;
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ static void iwl2000_nic_config(struct iwl_priv *priv)
|
||||
iwl_rf_config(priv);
|
||||
|
||||
if (cfg(priv)->iq_invert)
|
||||
iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG,
|
||||
iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG,
|
||||
CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
|
||||
}
|
||||
|
||||
@@ -124,8 +124,6 @@ static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
|
||||
iwlagn_mod_params.num_of_queues;
|
||||
|
||||
hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
|
||||
priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
|
||||
|
||||
hw_params(priv).max_data_size = IWL60_RTC_DATA_SIZE;
|
||||
hw_params(priv).max_inst_size = IWL60_RTC_INST_SIZE;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ static void iwl5000_nic_config(struct iwl_priv *priv)
|
||||
* (PCIe power is lost before PERST# is asserted),
|
||||
* causing ME FW to lose ownership and not being able to obtain it back.
|
||||
*/
|
||||
iwl_set_bits_mask_prph(bus(priv), APMG_PS_CTRL_REG,
|
||||
iwl_set_bits_mask_prph(trans(priv), APMG_PS_CTRL_REG,
|
||||
APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS,
|
||||
~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS);
|
||||
|
||||
@@ -170,8 +170,6 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
|
||||
iwlagn_mod_params.num_of_queues;
|
||||
|
||||
hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
|
||||
priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
|
||||
|
||||
hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE;
|
||||
hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE;
|
||||
|
||||
@@ -199,8 +197,6 @@ static int iwl5150_hw_set_hw_params(struct iwl_priv *priv)
|
||||
iwlagn_mod_params.num_of_queues;
|
||||
|
||||
hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
|
||||
priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
|
||||
|
||||
hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE;
|
||||
hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE;
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ static void iwl6050_additional_nic_config(struct iwl_priv *priv)
|
||||
{
|
||||
/* Indicate calibration version to uCode. */
|
||||
if (iwl_eeprom_calib_version(priv->shrd) >= 6)
|
||||
iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG,
|
||||
iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG,
|
||||
CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
|
||||
}
|
||||
|
||||
@@ -90,9 +90,9 @@ static void iwl6150_additional_nic_config(struct iwl_priv *priv)
|
||||
{
|
||||
/* Indicate calibration version to uCode. */
|
||||
if (iwl_eeprom_calib_version(priv->shrd) >= 6)
|
||||
iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG,
|
||||
iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG,
|
||||
CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
|
||||
iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG,
|
||||
iwl_set_bit(trans(priv), CSR_GP_DRIVER_REG,
|
||||
CSR_GP_DRIVER_REG_BIT_6050_1x2);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ static void iwl6000_nic_config(struct iwl_priv *priv)
|
||||
/* no locking required for register write */
|
||||
if (cfg(priv)->pa_type == IWL_PA_INTERNAL) {
|
||||
/* 2x2 IPA phy type */
|
||||
iwl_write32(bus(priv), CSR_GP_DRIVER_REG,
|
||||
iwl_write32(trans(priv), CSR_GP_DRIVER_REG,
|
||||
CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
|
||||
}
|
||||
/* do additional nic configuration if needed */
|
||||
@@ -145,8 +145,6 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv)
|
||||
iwlagn_mod_params.num_of_queues;
|
||||
|
||||
hw_params(priv).max_txq_num = cfg(priv)->base_params->num_of_queues;
|
||||
priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
|
||||
|
||||
hw_params(priv).max_data_size = IWL60_RTC_DATA_SIZE;
|
||||
hw_params(priv).max_inst_size = IWL60_RTC_INST_SIZE;
|
||||
|
||||
|
||||
@@ -628,16 +628,16 @@ static int iwlagn_rx_card_state_notif(struct iwl_priv *priv,
|
||||
if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED |
|
||||
CT_CARD_DISABLED)) {
|
||||
|
||||
iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET,
|
||||
iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET,
|
||||
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
|
||||
|
||||
iwl_write_direct32(bus(priv), HBUS_TARG_MBX_C,
|
||||
iwl_write_direct32(trans(priv), HBUS_TARG_MBX_C,
|
||||
HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
|
||||
|
||||
if (!(flags & RXON_CARD_DISABLED)) {
|
||||
iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR,
|
||||
iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR,
|
||||
CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
|
||||
iwl_write_direct32(bus(priv), HBUS_TARG_MBX_C,
|
||||
iwl_write_direct32(trans(priv), HBUS_TARG_MBX_C,
|
||||
HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED);
|
||||
}
|
||||
if (flags & CT_CARD_DISABLED)
|
||||
|
||||
@@ -178,19 +178,19 @@ static void iwl_tt_check_exit_ct_kill(unsigned long data)
|
||||
|
||||
if (tt->state == IWL_TI_CT_KILL) {
|
||||
if (priv->thermal_throttle.ct_kill_toggle) {
|
||||
iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR,
|
||||
iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR,
|
||||
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
|
||||
priv->thermal_throttle.ct_kill_toggle = false;
|
||||
} else {
|
||||
iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET,
|
||||
iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET,
|
||||
CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
|
||||
priv->thermal_throttle.ct_kill_toggle = true;
|
||||
}
|
||||
iwl_read32(bus(priv), CSR_UCODE_DRV_GP1);
|
||||
spin_lock_irqsave(&bus(priv)->reg_lock, flags);
|
||||
if (!iwl_grab_nic_access(bus(priv)))
|
||||
iwl_release_nic_access(bus(priv));
|
||||
spin_unlock_irqrestore(&bus(priv)->reg_lock, flags);
|
||||
iwl_read32(trans(priv), CSR_UCODE_DRV_GP1);
|
||||
spin_lock_irqsave(&trans(priv)->reg_lock, flags);
|
||||
if (!iwl_grab_nic_access(trans(priv)))
|
||||
iwl_release_nic_access(trans(priv));
|
||||
spin_unlock_irqrestore(&trans(priv)->reg_lock, flags);
|
||||
|
||||
/* Reschedule the ct_kill timer to occur in
|
||||
* CT_KILL_EXIT_DURATION seconds to ensure we get a
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -73,8 +73,6 @@ struct iwlagn_ucode_capabilities {
|
||||
|
||||
extern struct ieee80211_ops iwlagn_hw_ops;
|
||||
|
||||
int iwl_reset_ict(struct iwl_trans *trans);
|
||||
|
||||
static inline void iwl_set_calib_hdr(struct iwl_calib_hdr *hdr, u8 cmd)
|
||||
{
|
||||
hdr->op_code = cmd;
|
||||
@@ -109,6 +107,7 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf,
|
||||
int iwlagn_rx_calib_result(struct iwl_priv *priv,
|
||||
struct iwl_rx_mem_buffer *rxb,
|
||||
struct iwl_device_cmd *cmd);
|
||||
void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags);
|
||||
|
||||
/* lib */
|
||||
int iwlagn_send_tx_power(struct iwl_priv *priv);
|
||||
|
||||
@@ -118,88 +118,24 @@
|
||||
struct iwl_shared;
|
||||
struct iwl_bus;
|
||||
|
||||
/**
|
||||
* struct iwl_bus_ops - bus specific operations
|
||||
* @get_pm_support: must returns true if the bus can go to sleep
|
||||
* @apm_config: will be called during the config of the APM
|
||||
* @get_hw_id_string: prints the hw_id in the provided buffer
|
||||
* @get_hw_id: get hw_id in u32
|
||||
* @write8: write a byte to register at offset ofs
|
||||
* @write32: write a dword to register at offset ofs
|
||||
* @wread32: read a dword at register at offset ofs
|
||||
*/
|
||||
struct iwl_bus_ops {
|
||||
bool (*get_pm_support)(struct iwl_bus *bus);
|
||||
void (*apm_config)(struct iwl_bus *bus);
|
||||
void (*get_hw_id_string)(struct iwl_bus *bus, char buf[], int buf_len);
|
||||
u32 (*get_hw_id)(struct iwl_bus *bus);
|
||||
void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val);
|
||||
void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val);
|
||||
u32 (*read32)(struct iwl_bus *bus, u32 ofs);
|
||||
};
|
||||
|
||||
/**
|
||||
* struct iwl_bus - bus common data
|
||||
*
|
||||
* This data is common to all bus layer implementations.
|
||||
*
|
||||
* @dev - pointer to struct device * that represents the device
|
||||
* @ops - pointer to iwl_bus_ops
|
||||
* @shrd - pointer to iwl_shared which holds shared data from the upper layer
|
||||
* NB: for the time being this needs to be set by the upper layer since
|
||||
* it allocates the shared data
|
||||
* @irq - the irq number for the device
|
||||
* @reg_lock - protect hw register access
|
||||
*/
|
||||
struct iwl_bus {
|
||||
struct device *dev;
|
||||
const struct iwl_bus_ops *ops;
|
||||
struct iwl_shared *shrd;
|
||||
|
||||
unsigned int irq;
|
||||
spinlock_t reg_lock;
|
||||
|
||||
/* pointer to bus specific struct */
|
||||
/*Ensure that this pointer will always be aligned to sizeof pointer */
|
||||
char bus_specific[0] __attribute__((__aligned__(sizeof(void *))));
|
||||
};
|
||||
|
||||
static inline bool bus_get_pm_support(struct iwl_bus *bus)
|
||||
{
|
||||
return bus->ops->get_pm_support(bus);
|
||||
}
|
||||
|
||||
static inline void bus_apm_config(struct iwl_bus *bus)
|
||||
{
|
||||
bus->ops->apm_config(bus);
|
||||
}
|
||||
|
||||
static inline void bus_get_hw_id_string(struct iwl_bus *bus, char buf[],
|
||||
int buf_len)
|
||||
{
|
||||
bus->ops->get_hw_id_string(bus, buf, buf_len);
|
||||
}
|
||||
|
||||
static inline u32 bus_get_hw_id(struct iwl_bus *bus)
|
||||
{
|
||||
return bus->ops->get_hw_id(bus);
|
||||
}
|
||||
|
||||
static inline void bus_write8(struct iwl_bus *bus, u32 ofs, u8 val)
|
||||
{
|
||||
bus->ops->write8(bus, ofs, val);
|
||||
}
|
||||
|
||||
static inline void bus_write32(struct iwl_bus *bus, u32 ofs, u32 val)
|
||||
{
|
||||
bus->ops->write32(bus, ofs, val);
|
||||
}
|
||||
|
||||
static inline u32 bus_read32(struct iwl_bus *bus, u32 ofs)
|
||||
{
|
||||
return bus->ops->read32(bus, ofs);
|
||||
}
|
||||
|
||||
/*****************************************************
|
||||
* Bus layer registration functions
|
||||
******************************************************/
|
||||
|
||||
@@ -203,10 +203,9 @@ int iwl_init_geos(struct iwl_priv *priv)
|
||||
|
||||
if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
|
||||
cfg(priv)->sku & EEPROM_SKU_CAP_BAND_52GHZ) {
|
||||
char buf[32];
|
||||
bus_get_hw_id_string(bus(priv), buf, sizeof(buf));
|
||||
IWL_INFO(priv, "Incorrectly detected BG card as ABG. "
|
||||
"Please send your %s to maintainer.\n", buf);
|
||||
"Please send your %s to maintainer.\n",
|
||||
trans(priv)->hw_id_str);
|
||||
cfg(priv)->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ;
|
||||
}
|
||||
|
||||
@@ -883,129 +882,6 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand)
|
||||
}
|
||||
}
|
||||
|
||||
static int iwl_apm_stop_master(struct iwl_priv *priv)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* stop device's busmaster DMA activity */
|
||||
iwl_set_bit(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER);
|
||||
|
||||
ret = iwl_poll_bit(bus(priv), CSR_RESET,
|
||||
CSR_RESET_REG_FLAG_MASTER_DISABLED,
|
||||
CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
|
||||
if (ret)
|
||||
IWL_WARN(priv, "Master Disable Timed Out, 100 usec\n");
|
||||
|
||||
IWL_DEBUG_INFO(priv, "stop master\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void iwl_apm_stop(struct iwl_priv *priv)
|
||||
{
|
||||
IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n");
|
||||
|
||||
clear_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status);
|
||||
|
||||
/* Stop device's DMA activity */
|
||||
iwl_apm_stop_master(priv);
|
||||
|
||||
/* Reset the entire device */
|
||||
iwl_set_bit(bus(priv), CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
|
||||
|
||||
udelay(10);
|
||||
|
||||
/*
|
||||
* Clear "initialization complete" bit to move adapter from
|
||||
* D0A* (powered-up Active) --> D0U* (Uninitialized) state.
|
||||
*/
|
||||
iwl_clear_bit(bus(priv), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Start up NIC's basic functionality after it has been reset
|
||||
* (e.g. after platform boot, or shutdown via iwl_apm_stop())
|
||||
* NOTE: This does not load uCode nor start the embedded processor
|
||||
*/
|
||||
int iwl_apm_init(struct iwl_priv *priv)
|
||||
{
|
||||
int ret = 0;
|
||||
IWL_DEBUG_INFO(priv, "Init card's basic functions\n");
|
||||
|
||||
/*
|
||||
* Use "set_bit" below rather than "write", to preserve any hardware
|
||||
* bits already set by default after reset.
|
||||
*/
|
||||
|
||||
/* Disable L0S exit timer (platform NMI Work/Around) */
|
||||
iwl_set_bit(bus(priv), CSR_GIO_CHICKEN_BITS,
|
||||
CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER);
|
||||
|
||||
/*
|
||||
* Disable L0s without affecting L1;
|
||||
* don't wait for ICH L0s (ICH bug W/A)
|
||||
*/
|
||||
iwl_set_bit(bus(priv), CSR_GIO_CHICKEN_BITS,
|
||||
CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX);
|
||||
|
||||
/* Set FH wait threshold to maximum (HW error during stress W/A) */
|
||||
iwl_set_bit(bus(priv), CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL);
|
||||
|
||||
/*
|
||||
* Enable HAP INTA (interrupt from management bus) to
|
||||
* wake device's PCI Express link L1a -> L0s
|
||||
*/
|
||||
iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG,
|
||||
CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A);
|
||||
|
||||
bus_apm_config(bus(priv));
|
||||
|
||||
/* Configure analog phase-lock-loop before activating to D0A */
|
||||
if (cfg(priv)->base_params->pll_cfg_val)
|
||||
iwl_set_bit(bus(priv), CSR_ANA_PLL_CFG,
|
||||
cfg(priv)->base_params->pll_cfg_val);
|
||||
|
||||
/*
|
||||
* Set "initialization complete" bit to move adapter from
|
||||
* D0U* --> D0A* (powered-up active) state.
|
||||
*/
|
||||
iwl_set_bit(bus(priv), CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
|
||||
|
||||
/*
|
||||
* Wait for clock stabilization; once stabilized, access to
|
||||
* device-internal resources is supported, e.g. iwl_write_prph()
|
||||
* and accesses to uCode SRAM.
|
||||
*/
|
||||
ret = iwl_poll_bit(bus(priv), CSR_GP_CNTRL,
|
||||
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
|
||||
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000);
|
||||
if (ret < 0) {
|
||||
IWL_DEBUG_INFO(priv, "Failed to init the card\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable DMA clock and wait for it to stabilize.
|
||||
*
|
||||
* Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits
|
||||
* do not disable clocks. This preserves any hardware bits already
|
||||
* set by default in "CLK_CTRL_REG" after reset.
|
||||
*/
|
||||
iwl_write_prph(bus(priv), APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT);
|
||||
udelay(20);
|
||||
|
||||
/* Disable L1-Active */
|
||||
iwl_set_bits_prph(bus(priv), APMG_PCIDEV_STT_REG,
|
||||
APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
|
||||
|
||||
set_bit(STATUS_DEVICE_ENABLED, &priv->shrd->status);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -297,12 +297,6 @@ static inline bool iwl_advanced_bt_coexist(struct iwl_priv *priv)
|
||||
cfg(priv)->bt_params->advanced_bt_coexist;
|
||||
}
|
||||
|
||||
static inline void iwl_enable_rfkill_int(struct iwl_priv *priv)
|
||||
{
|
||||
IWL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n");
|
||||
iwl_write32(bus(priv), CSR_INT_MASK, CSR_INT_BIT_RF_KILL);
|
||||
}
|
||||
|
||||
extern bool bt_siso_mode;
|
||||
|
||||
#endif /* __iwl_core_h__ */
|
||||
|
||||
@@ -35,10 +35,10 @@
|
||||
struct iwl_priv;
|
||||
|
||||
/*No matter what is m (priv, bus, trans), this will work */
|
||||
#define IWL_ERR(m, f, a...) dev_err(bus(m)->dev, f, ## a)
|
||||
#define IWL_WARN(m, f, a...) dev_warn(bus(m)->dev, f, ## a)
|
||||
#define IWL_INFO(m, f, a...) dev_info(bus(m)->dev, f, ## a)
|
||||
#define IWL_CRIT(m, f, a...) dev_crit(bus(m)->dev, f, ## a)
|
||||
#define IWL_ERR(m, f, a...) dev_err(trans(m)->dev, f, ## a)
|
||||
#define IWL_WARN(m, f, a...) dev_warn(trans(m)->dev, f, ## a)
|
||||
#define IWL_INFO(m, f, a...) dev_info(trans(m)->dev, f, ## a)
|
||||
#define IWL_CRIT(m, f, a...) dev_crit(trans(m)->dev, f, ## a)
|
||||
|
||||
#define iwl_print_hex_error(m, p, len) \
|
||||
do { \
|
||||
@@ -50,7 +50,7 @@ do { \
|
||||
#define IWL_DEBUG(m, level, fmt, ...) \
|
||||
do { \
|
||||
if (iwl_get_debug_level((m)->shrd) & (level)) \
|
||||
dev_err(bus(m)->dev, "%c %s " fmt, \
|
||||
dev_err(trans(m)->dev, "%c %s " fmt, \
|
||||
in_interrupt() ? 'I' : 'U', __func__, \
|
||||
##__VA_ARGS__); \
|
||||
} while (0)
|
||||
@@ -59,7 +59,7 @@ do { \
|
||||
do { \
|
||||
if (iwl_get_debug_level((m)->shrd) & (level) && \
|
||||
net_ratelimit()) \
|
||||
dev_err(bus(m)->dev, "%c %s " fmt, \
|
||||
dev_err(trans(m)->dev, "%c %s " fmt, \
|
||||
in_interrupt() ? 'I' : 'U', __func__, \
|
||||
##__VA_ARGS__); \
|
||||
} while (0)
|
||||
@@ -74,12 +74,12 @@ do { \
|
||||
#define IWL_DEBUG_QUIET_RFKILL(p, fmt, ...) \
|
||||
do { \
|
||||
if (!iwl_is_rfkill(p->shrd)) \
|
||||
dev_err(bus(p)->dev, "%s%c %s " fmt, \
|
||||
dev_err(trans(p)->dev, "%s%c %s " fmt, \
|
||||
"", \
|
||||
in_interrupt() ? 'I' : 'U', __func__, \
|
||||
##__VA_ARGS__); \
|
||||
else if (iwl_get_debug_level(p->shrd) & IWL_DL_RADIO) \
|
||||
dev_err(bus(p)->dev, "%s%c %s " fmt, \
|
||||
dev_err(trans(p)->dev, "%s%c %s " fmt, \
|
||||
"(RFKILL) ", \
|
||||
in_interrupt() ? 'I' : 'U', __func__, \
|
||||
##__VA_ARGS__); \
|
||||
|
||||
@@ -263,7 +263,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
|
||||
sram = priv->dbgfs_sram_offset & ~0x3;
|
||||
|
||||
/* read the first u32 from sram */
|
||||
val = iwl_read_targ_mem(bus(priv), sram);
|
||||
val = iwl_read_targ_mem(trans(priv), sram);
|
||||
|
||||
for (; len; len--) {
|
||||
/* put the address at the start of every line */
|
||||
@@ -282,7 +282,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
|
||||
if (++offset == 4) {
|
||||
sram += 4;
|
||||
offset = 0;
|
||||
val = iwl_read_targ_mem(bus(priv), sram);
|
||||
val = iwl_read_targ_mem(trans(priv), sram);
|
||||
}
|
||||
|
||||
/* put in extra spaces and split lines for human readability */
|
||||
@@ -2055,7 +2055,7 @@ static ssize_t iwl_dbgfs_power_save_status_read(struct file *file,
|
||||
const size_t bufsz = sizeof(buf);
|
||||
u32 pwrsave_status;
|
||||
|
||||
pwrsave_status = iwl_read32(bus(priv), CSR_GP_CNTRL) &
|
||||
pwrsave_status = iwl_read32(trans(priv), CSR_GP_CNTRL) &
|
||||
CSR_GP_REG_POWER_SAVE_STATUS_MSK;
|
||||
|
||||
pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: ");
|
||||
|
||||
@@ -292,114 +292,6 @@ struct iwl_vif_priv {
|
||||
u8 ibss_bssid_sta_id;
|
||||
};
|
||||
|
||||
/* v1/v2 uCode file layout */
|
||||
struct iwl_ucode_header {
|
||||
__le32 ver; /* major/minor/API/serial */
|
||||
union {
|
||||
struct {
|
||||
__le32 inst_size; /* bytes of runtime code */
|
||||
__le32 data_size; /* bytes of runtime data */
|
||||
__le32 init_size; /* bytes of init code */
|
||||
__le32 init_data_size; /* bytes of init data */
|
||||
__le32 boot_size; /* bytes of bootstrap code */
|
||||
u8 data[0]; /* in same order as sizes */
|
||||
} v1;
|
||||
struct {
|
||||
__le32 build; /* build number */
|
||||
__le32 inst_size; /* bytes of runtime code */
|
||||
__le32 data_size; /* bytes of runtime data */
|
||||
__le32 init_size; /* bytes of init code */
|
||||
__le32 init_data_size; /* bytes of init data */
|
||||
__le32 boot_size; /* bytes of bootstrap code */
|
||||
u8 data[0]; /* in same order as sizes */
|
||||
} v2;
|
||||
} u;
|
||||
};
|
||||
|
||||
/*
|
||||
* new TLV uCode file layout
|
||||
*
|
||||
* The new TLV file format contains TLVs, that each specify
|
||||
* some piece of data. To facilitate "groups", for example
|
||||
* different instruction image with different capabilities,
|
||||
* bundled with the same init image, an alternative mechanism
|
||||
* is provided:
|
||||
* When the alternative field is 0, that means that the item
|
||||
* is always valid. When it is non-zero, then it is only
|
||||
* valid in conjunction with items of the same alternative,
|
||||
* in which case the driver (user) selects one alternative
|
||||
* to use.
|
||||
*/
|
||||
|
||||
enum iwl_ucode_tlv_type {
|
||||
IWL_UCODE_TLV_INVALID = 0, /* unused */
|
||||
IWL_UCODE_TLV_INST = 1,
|
||||
IWL_UCODE_TLV_DATA = 2,
|
||||
IWL_UCODE_TLV_INIT = 3,
|
||||
IWL_UCODE_TLV_INIT_DATA = 4,
|
||||
IWL_UCODE_TLV_BOOT = 5,
|
||||
IWL_UCODE_TLV_PROBE_MAX_LEN = 6, /* a u32 value */
|
||||
IWL_UCODE_TLV_PAN = 7,
|
||||
IWL_UCODE_TLV_RUNT_EVTLOG_PTR = 8,
|
||||
IWL_UCODE_TLV_RUNT_EVTLOG_SIZE = 9,
|
||||
IWL_UCODE_TLV_RUNT_ERRLOG_PTR = 10,
|
||||
IWL_UCODE_TLV_INIT_EVTLOG_PTR = 11,
|
||||
IWL_UCODE_TLV_INIT_EVTLOG_SIZE = 12,
|
||||
IWL_UCODE_TLV_INIT_ERRLOG_PTR = 13,
|
||||
IWL_UCODE_TLV_ENHANCE_SENS_TBL = 14,
|
||||
IWL_UCODE_TLV_PHY_CALIBRATION_SIZE = 15,
|
||||
IWL_UCODE_TLV_WOWLAN_INST = 16,
|
||||
IWL_UCODE_TLV_WOWLAN_DATA = 17,
|
||||
IWL_UCODE_TLV_FLAGS = 18,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum iwl_ucode_tlv_flag - ucode API flags
|
||||
* @IWL_UCODE_TLV_FLAGS_PAN: This is PAN capable microcode; this previously
|
||||
* was a separate TLV but moved here to save space.
|
||||
* @IWL_UCODE_TLV_FLAGS_NEWSCAN: new uCode scan behaviour on hidden SSID,
|
||||
* treats good CRC threshold as a boolean
|
||||
* @IWL_UCODE_TLV_FLAGS_MFP: This uCode image supports MFP (802.11w).
|
||||
* @IWL_UCODE_TLV_FLAGS_P2P: This uCode image supports P2P.
|
||||
*/
|
||||
enum iwl_ucode_tlv_flag {
|
||||
IWL_UCODE_TLV_FLAGS_PAN = BIT(0),
|
||||
IWL_UCODE_TLV_FLAGS_NEWSCAN = BIT(1),
|
||||
IWL_UCODE_TLV_FLAGS_MFP = BIT(2),
|
||||
IWL_UCODE_TLV_FLAGS_P2P = BIT(3),
|
||||
};
|
||||
|
||||
struct iwl_ucode_tlv {
|
||||
__le16 type; /* see above */
|
||||
__le16 alternative; /* see comment */
|
||||
__le32 length; /* not including type/length fields */
|
||||
u8 data[0];
|
||||
} __packed;
|
||||
|
||||
#define IWL_TLV_UCODE_MAGIC 0x0a4c5749
|
||||
|
||||
struct iwl_tlv_ucode_header {
|
||||
/*
|
||||
* The TLV style ucode header is distinguished from
|
||||
* the v1/v2 style header by first four bytes being
|
||||
* zero, as such is an invalid combination of
|
||||
* major/minor/API/serial versions.
|
||||
*/
|
||||
__le32 zero;
|
||||
__le32 magic;
|
||||
u8 human_readable[64];
|
||||
__le32 ver; /* major/minor/API/serial */
|
||||
__le32 build;
|
||||
__le64 alternatives; /* bitmask of valid alternatives */
|
||||
/*
|
||||
* The data contained herein has a TLV layout,
|
||||
* see above for the TLV header and types.
|
||||
* Note that each TLV is padded to a length
|
||||
* that is a multiple of 4 for alignment.
|
||||
*/
|
||||
u8 data[0];
|
||||
};
|
||||
|
||||
struct iwl_sensitivity_ranges {
|
||||
u16 min_nrg_cck;
|
||||
u16 max_nrg_cck;
|
||||
@@ -821,7 +713,6 @@ struct iwl_wipan_noa_data {
|
||||
struct iwl_priv {
|
||||
|
||||
/*data shared among all the driver's layers */
|
||||
struct iwl_shared _shrd;
|
||||
struct iwl_shared *shrd;
|
||||
|
||||
/* ieee device used by generic ieee processing code */
|
||||
|
||||
@@ -156,16 +156,16 @@ static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus)
|
||||
|
||||
for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) {
|
||||
/* Request semaphore */
|
||||
iwl_set_bit(bus, CSR_HW_IF_CONFIG_REG,
|
||||
iwl_set_bit(trans(bus), CSR_HW_IF_CONFIG_REG,
|
||||
CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
|
||||
|
||||
/* See if we got it */
|
||||
ret = iwl_poll_bit(bus, CSR_HW_IF_CONFIG_REG,
|
||||
ret = iwl_poll_bit(trans(bus), CSR_HW_IF_CONFIG_REG,
|
||||
CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
|
||||
CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
|
||||
EEPROM_SEM_TIMEOUT);
|
||||
if (ret >= 0) {
|
||||
IWL_DEBUG_EEPROM(bus,
|
||||
IWL_DEBUG_EEPROM(trans(bus),
|
||||
"Acquired semaphore after %d tries.\n",
|
||||
count+1);
|
||||
return ret;
|
||||
@@ -177,14 +177,15 @@ static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus)
|
||||
|
||||
static void iwl_eeprom_release_semaphore(struct iwl_bus *bus)
|
||||
{
|
||||
iwl_clear_bit(bus, CSR_HW_IF_CONFIG_REG,
|
||||
iwl_clear_bit(trans(bus), CSR_HW_IF_CONFIG_REG,
|
||||
CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
|
||||
|
||||
}
|
||||
|
||||
static int iwl_eeprom_verify_signature(struct iwl_trans *trans)
|
||||
{
|
||||
u32 gp = iwl_read32(bus(trans), CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK;
|
||||
u32 gp = iwl_read32(trans, CSR_EEPROM_GP) &
|
||||
CSR_EEPROM_GP_VALID_MSK;
|
||||
int ret = 0;
|
||||
|
||||
IWL_DEBUG_EEPROM(trans, "EEPROM signature=0x%08x\n", gp);
|
||||
@@ -305,13 +306,13 @@ void iwl_eeprom_get_mac(const struct iwl_shared *shrd, u8 *mac)
|
||||
|
||||
static void iwl_set_otp_access(struct iwl_bus *bus, enum iwl_access_mode mode)
|
||||
{
|
||||
iwl_read32(bus, CSR_OTP_GP_REG);
|
||||
iwl_read32(trans(bus), CSR_OTP_GP_REG);
|
||||
|
||||
if (mode == IWL_OTP_ACCESS_ABSOLUTE)
|
||||
iwl_clear_bit(bus, CSR_OTP_GP_REG,
|
||||
iwl_clear_bit(trans(bus), CSR_OTP_GP_REG,
|
||||
CSR_OTP_GP_REG_OTP_ACCESS_MODE);
|
||||
else
|
||||
iwl_set_bit(bus, CSR_OTP_GP_REG,
|
||||
iwl_set_bit(trans(bus), CSR_OTP_GP_REG,
|
||||
CSR_OTP_GP_REG_OTP_ACCESS_MODE);
|
||||
}
|
||||
|
||||
@@ -332,7 +333,7 @@ static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev)
|
||||
nvm_type = NVM_DEVICE_TYPE_EEPROM;
|
||||
break;
|
||||
default:
|
||||
otpgp = iwl_read32(bus, CSR_OTP_GP_REG);
|
||||
otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG);
|
||||
if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT)
|
||||
nvm_type = NVM_DEVICE_TYPE_OTP;
|
||||
else
|
||||
@@ -347,22 +348,22 @@ static int iwl_init_otp_access(struct iwl_bus *bus)
|
||||
int ret;
|
||||
|
||||
/* Enable 40MHz radio clock */
|
||||
iwl_write32(bus, CSR_GP_CNTRL,
|
||||
iwl_read32(bus, CSR_GP_CNTRL) |
|
||||
iwl_write32(trans(bus), CSR_GP_CNTRL,
|
||||
iwl_read32(trans(bus), CSR_GP_CNTRL) |
|
||||
CSR_GP_CNTRL_REG_FLAG_INIT_DONE);
|
||||
|
||||
/* wait for clock to be ready */
|
||||
ret = iwl_poll_bit(bus, CSR_GP_CNTRL,
|
||||
ret = iwl_poll_bit(trans(bus), CSR_GP_CNTRL,
|
||||
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
|
||||
CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
|
||||
25000);
|
||||
if (ret < 0)
|
||||
IWL_ERR(bus, "Time out access OTP\n");
|
||||
else {
|
||||
iwl_set_bits_prph(bus, APMG_PS_CTRL_REG,
|
||||
iwl_set_bits_prph(trans(bus), APMG_PS_CTRL_REG,
|
||||
APMG_PS_CTRL_VAL_RESET_REQ);
|
||||
udelay(5);
|
||||
iwl_clear_bits_prph(bus, APMG_PS_CTRL_REG,
|
||||
iwl_clear_bits_prph(trans(bus), APMG_PS_CTRL_REG,
|
||||
APMG_PS_CTRL_VAL_RESET_REQ);
|
||||
|
||||
/*
|
||||
@@ -370,7 +371,7 @@ static int iwl_init_otp_access(struct iwl_bus *bus)
|
||||
* this is only applicable for HW with OTP shadow RAM
|
||||
*/
|
||||
if (cfg(bus)->base_params->shadow_ram_support)
|
||||
iwl_set_bit(bus, CSR_DBG_LINK_PWR_MGMT_REG,
|
||||
iwl_set_bit(trans(bus), CSR_DBG_LINK_PWR_MGMT_REG,
|
||||
CSR_RESET_LINK_PWR_MGMT_DISABLED);
|
||||
}
|
||||
return ret;
|
||||
@@ -382,9 +383,9 @@ static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data)
|
||||
u32 r;
|
||||
u32 otpgp;
|
||||
|
||||
iwl_write32(bus, CSR_EEPROM_REG,
|
||||
iwl_write32(trans(bus), CSR_EEPROM_REG,
|
||||
CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
|
||||
ret = iwl_poll_bit(bus, CSR_EEPROM_REG,
|
||||
ret = iwl_poll_bit(trans(bus), CSR_EEPROM_REG,
|
||||
CSR_EEPROM_REG_READ_VALID_MSK,
|
||||
CSR_EEPROM_REG_READ_VALID_MSK,
|
||||
IWL_EEPROM_ACCESS_TIMEOUT);
|
||||
@@ -392,13 +393,13 @@ static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data)
|
||||
IWL_ERR(bus, "Time out reading OTP[%d]\n", addr);
|
||||
return ret;
|
||||
}
|
||||
r = iwl_read32(bus, CSR_EEPROM_REG);
|
||||
r = iwl_read32(trans(bus), CSR_EEPROM_REG);
|
||||
/* check for ECC errors: */
|
||||
otpgp = iwl_read32(bus, CSR_OTP_GP_REG);
|
||||
otpgp = iwl_read32(trans(bus), CSR_OTP_GP_REG);
|
||||
if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) {
|
||||
/* stop in this case */
|
||||
/* set the uncorrectable OTP ECC bit for acknowledgement */
|
||||
iwl_set_bit(bus, CSR_OTP_GP_REG,
|
||||
iwl_set_bit(trans(bus), CSR_OTP_GP_REG,
|
||||
CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
|
||||
IWL_ERR(bus, "Uncorrectable OTP ECC error, abort OTP read\n");
|
||||
return -EINVAL;
|
||||
@@ -406,7 +407,7 @@ static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data)
|
||||
if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) {
|
||||
/* continue in this case */
|
||||
/* set the correctable OTP ECC bit for acknowledgement */
|
||||
iwl_set_bit(bus, CSR_OTP_GP_REG,
|
||||
iwl_set_bit(trans(bus), CSR_OTP_GP_REG,
|
||||
CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK);
|
||||
IWL_ERR(bus, "Correctable OTP ECC error, continue read\n");
|
||||
}
|
||||
@@ -656,7 +657,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
|
||||
{
|
||||
struct iwl_shared *shrd = priv->shrd;
|
||||
__le16 *e;
|
||||
u32 gp = iwl_read32(bus(priv), CSR_EEPROM_GP);
|
||||
u32 gp = iwl_read32(trans(priv), CSR_EEPROM_GP);
|
||||
int sz;
|
||||
int ret;
|
||||
u16 addr;
|
||||
@@ -676,8 +677,6 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
|
||||
}
|
||||
e = (__le16 *)shrd->eeprom;
|
||||
|
||||
iwl_apm_init(priv);
|
||||
|
||||
ret = iwl_eeprom_verify_signature(trans(priv));
|
||||
if (ret < 0) {
|
||||
IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp);
|
||||
@@ -701,11 +700,11 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
|
||||
ret = -ENOENT;
|
||||
goto done;
|
||||
}
|
||||
iwl_write32(bus(priv), CSR_EEPROM_GP,
|
||||
iwl_read32(bus(priv), CSR_EEPROM_GP) &
|
||||
iwl_write32(trans(priv), CSR_EEPROM_GP,
|
||||
iwl_read32(trans(priv), CSR_EEPROM_GP) &
|
||||
~CSR_EEPROM_GP_IF_OWNER_MSK);
|
||||
|
||||
iwl_set_bit(bus(priv), CSR_OTP_GP_REG,
|
||||
iwl_set_bit(trans(priv), CSR_OTP_GP_REG,
|
||||
CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK |
|
||||
CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK);
|
||||
/* traversing the linked list if no shadow ram supported */
|
||||
@@ -730,10 +729,10 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
|
||||
for (addr = 0; addr < sz; addr += sizeof(u16)) {
|
||||
u32 r;
|
||||
|
||||
iwl_write32(bus(priv), CSR_EEPROM_REG,
|
||||
iwl_write32(trans(priv), CSR_EEPROM_REG,
|
||||
CSR_EEPROM_REG_MSK_ADDR & (addr << 1));
|
||||
|
||||
ret = iwl_poll_bit(bus(priv), CSR_EEPROM_REG,
|
||||
ret = iwl_poll_bit(trans(priv), CSR_EEPROM_REG,
|
||||
CSR_EEPROM_REG_READ_VALID_MSK,
|
||||
CSR_EEPROM_REG_READ_VALID_MSK,
|
||||
IWL_EEPROM_ACCESS_TIMEOUT);
|
||||
@@ -741,7 +740,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev)
|
||||
IWL_ERR(priv, "Time out reading EEPROM[%d]\n", addr);
|
||||
goto done;
|
||||
}
|
||||
r = iwl_read32(bus(priv), CSR_EEPROM_REG);
|
||||
r = iwl_read32(trans(priv), CSR_EEPROM_REG);
|
||||
e[addr / 2] = cpu_to_le16(r >> 16);
|
||||
}
|
||||
}
|
||||
@@ -758,8 +757,6 @@ done:
|
||||
err:
|
||||
if (ret)
|
||||
iwl_eeprom_free(priv->shrd);
|
||||
/* Reset chip to save power until we load uCode during "up". */
|
||||
iwl_apm_stop(priv);
|
||||
alloc_err:
|
||||
return ret;
|
||||
}
|
||||
@@ -1072,7 +1069,7 @@ void iwl_rf_config(struct iwl_priv *priv)
|
||||
|
||||
/* write radio config values to register */
|
||||
if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) {
|
||||
iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG,
|
||||
iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG,
|
||||
EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
|
||||
EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
|
||||
EEPROM_RF_CFG_DASH_MSK(radio_cfg));
|
||||
@@ -1084,7 +1081,7 @@ void iwl_rf_config(struct iwl_priv *priv)
|
||||
WARN_ON(1);
|
||||
|
||||
/* set CSR_HW_CONFIG_REG for uCode use */
|
||||
iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG,
|
||||
iwl_set_bit(trans(priv), CSR_HW_IF_CONFIG_REG,
|
||||
CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
|
||||
CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
|
||||
}
|
||||
|
||||
@@ -34,41 +34,41 @@
|
||||
|
||||
#define IWL_POLL_INTERVAL 10 /* microseconds */
|
||||
|
||||
static inline void __iwl_set_bit(struct iwl_bus *bus, u32 reg, u32 mask)
|
||||
static inline void __iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask)
|
||||
{
|
||||
iwl_write32(bus, reg, iwl_read32(bus, reg) | mask);
|
||||
iwl_write32(trans, reg, iwl_read32(trans, reg) | mask);
|
||||
}
|
||||
|
||||
static inline void __iwl_clear_bit(struct iwl_bus *bus, u32 reg, u32 mask)
|
||||
static inline void __iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
|
||||
{
|
||||
iwl_write32(bus, reg, iwl_read32(bus, reg) & ~mask);
|
||||
iwl_write32(trans, reg, iwl_read32(trans, reg) & ~mask);
|
||||
}
|
||||
|
||||
void iwl_set_bit(struct iwl_bus *bus, u32 reg, u32 mask)
|
||||
void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
__iwl_set_bit(bus, reg, mask);
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
__iwl_set_bit(trans, reg, mask);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
}
|
||||
|
||||
void iwl_clear_bit(struct iwl_bus *bus, u32 reg, u32 mask)
|
||||
void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
__iwl_clear_bit(bus, reg, mask);
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
__iwl_clear_bit(trans, reg, mask);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
}
|
||||
|
||||
int iwl_poll_bit(struct iwl_bus *bus, u32 addr,
|
||||
int iwl_poll_bit(struct iwl_trans *trans, u32 addr,
|
||||
u32 bits, u32 mask, int timeout)
|
||||
{
|
||||
int t = 0;
|
||||
|
||||
do {
|
||||
if ((iwl_read32(bus, addr) & mask) == (bits & mask))
|
||||
if ((iwl_read32(trans, addr) & mask) == (bits & mask))
|
||||
return t;
|
||||
udelay(IWL_POLL_INTERVAL);
|
||||
t += IWL_POLL_INTERVAL;
|
||||
@@ -77,14 +77,15 @@ int iwl_poll_bit(struct iwl_bus *bus, u32 addr,
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
int iwl_grab_nic_access_silent(struct iwl_bus *bus)
|
||||
int iwl_grab_nic_access_silent(struct iwl_trans *trans)
|
||||
{
|
||||
int ret;
|
||||
|
||||
lockdep_assert_held(&bus->reg_lock);
|
||||
lockdep_assert_held(&trans->reg_lock);
|
||||
|
||||
/* this bit wakes up the NIC */
|
||||
__iwl_set_bit(bus, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
|
||||
__iwl_set_bit(trans, CSR_GP_CNTRL,
|
||||
CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
|
||||
|
||||
/*
|
||||
* These bits say the device is running, and should keep running for
|
||||
@@ -105,70 +106,70 @@ int iwl_grab_nic_access_silent(struct iwl_bus *bus)
|
||||
* 5000 series and later (including 1000 series) have non-volatile SRAM,
|
||||
* and do not save/restore SRAM when power cycling.
|
||||
*/
|
||||
ret = iwl_poll_bit(bus, CSR_GP_CNTRL,
|
||||
ret = iwl_poll_bit(trans, CSR_GP_CNTRL,
|
||||
CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN,
|
||||
(CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
|
||||
CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000);
|
||||
if (ret < 0) {
|
||||
iwl_write32(bus, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI);
|
||||
iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iwl_grab_nic_access(struct iwl_bus *bus)
|
||||
int iwl_grab_nic_access(struct iwl_trans *trans)
|
||||
{
|
||||
int ret = iwl_grab_nic_access_silent(bus);
|
||||
int ret = iwl_grab_nic_access_silent(trans);
|
||||
if (ret) {
|
||||
u32 val = iwl_read32(bus, CSR_GP_CNTRL);
|
||||
IWL_ERR(bus,
|
||||
u32 val = iwl_read32(trans, CSR_GP_CNTRL);
|
||||
IWL_ERR(trans,
|
||||
"MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void iwl_release_nic_access(struct iwl_bus *bus)
|
||||
void iwl_release_nic_access(struct iwl_trans *trans)
|
||||
{
|
||||
lockdep_assert_held(&bus->reg_lock);
|
||||
__iwl_clear_bit(bus, CSR_GP_CNTRL,
|
||||
lockdep_assert_held(&trans->reg_lock);
|
||||
__iwl_clear_bit(trans, CSR_GP_CNTRL,
|
||||
CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
|
||||
}
|
||||
|
||||
u32 iwl_read_direct32(struct iwl_bus *bus, u32 reg)
|
||||
u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg)
|
||||
{
|
||||
u32 value;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
iwl_grab_nic_access(bus);
|
||||
value = iwl_read32(bus, reg);
|
||||
iwl_release_nic_access(bus);
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
iwl_grab_nic_access(trans);
|
||||
value = iwl_read32(trans, reg);
|
||||
iwl_release_nic_access(trans);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void iwl_write_direct32(struct iwl_bus *bus, u32 reg, u32 value)
|
||||
void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
if (!iwl_grab_nic_access(bus)) {
|
||||
iwl_write32(bus, reg, value);
|
||||
iwl_release_nic_access(bus);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
if (!iwl_grab_nic_access(trans)) {
|
||||
iwl_write32(trans, reg, value);
|
||||
iwl_release_nic_access(trans);
|
||||
}
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
}
|
||||
|
||||
int iwl_poll_direct_bit(struct iwl_bus *bus, u32 addr, u32 mask,
|
||||
int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask,
|
||||
int timeout)
|
||||
{
|
||||
int t = 0;
|
||||
|
||||
do {
|
||||
if ((iwl_read_direct32(bus, addr) & mask) == mask)
|
||||
if ((iwl_read_direct32(trans, addr) & mask) == mask)
|
||||
return t;
|
||||
udelay(IWL_POLL_INTERVAL);
|
||||
t += IWL_POLL_INTERVAL;
|
||||
@@ -177,135 +178,135 @@ int iwl_poll_direct_bit(struct iwl_bus *bus, u32 addr, u32 mask,
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
static inline u32 __iwl_read_prph(struct iwl_bus *bus, u32 reg)
|
||||
static inline u32 __iwl_read_prph(struct iwl_trans *trans, u32 reg)
|
||||
{
|
||||
iwl_write32(bus, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
|
||||
iwl_write32(trans, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
|
||||
rmb();
|
||||
return iwl_read32(bus, HBUS_TARG_PRPH_RDAT);
|
||||
return iwl_read32(trans, HBUS_TARG_PRPH_RDAT);
|
||||
}
|
||||
|
||||
static inline void __iwl_write_prph(struct iwl_bus *bus, u32 addr, u32 val)
|
||||
static inline void __iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val)
|
||||
{
|
||||
iwl_write32(bus, HBUS_TARG_PRPH_WADDR,
|
||||
iwl_write32(trans, HBUS_TARG_PRPH_WADDR,
|
||||
((addr & 0x0000FFFF) | (3 << 24)));
|
||||
wmb();
|
||||
iwl_write32(bus, HBUS_TARG_PRPH_WDAT, val);
|
||||
iwl_write32(trans, HBUS_TARG_PRPH_WDAT, val);
|
||||
}
|
||||
|
||||
u32 iwl_read_prph(struct iwl_bus *bus, u32 reg)
|
||||
u32 iwl_read_prph(struct iwl_trans *trans, u32 reg)
|
||||
{
|
||||
unsigned long flags;
|
||||
u32 val;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
iwl_grab_nic_access(bus);
|
||||
val = __iwl_read_prph(bus, reg);
|
||||
iwl_release_nic_access(bus);
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
iwl_grab_nic_access(trans);
|
||||
val = __iwl_read_prph(trans, reg);
|
||||
iwl_release_nic_access(trans);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
return val;
|
||||
}
|
||||
|
||||
void iwl_write_prph(struct iwl_bus *bus, u32 addr, u32 val)
|
||||
void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
if (!iwl_grab_nic_access(bus)) {
|
||||
__iwl_write_prph(bus, addr, val);
|
||||
iwl_release_nic_access(bus);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
if (!iwl_grab_nic_access(trans)) {
|
||||
__iwl_write_prph(trans, addr, val);
|
||||
iwl_release_nic_access(trans);
|
||||
}
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
}
|
||||
|
||||
void iwl_set_bits_prph(struct iwl_bus *bus, u32 reg, u32 mask)
|
||||
void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
iwl_grab_nic_access(bus);
|
||||
__iwl_write_prph(bus, reg, __iwl_read_prph(bus, reg) | mask);
|
||||
iwl_release_nic_access(bus);
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
iwl_grab_nic_access(trans);
|
||||
__iwl_write_prph(trans, reg, __iwl_read_prph(trans, reg) | mask);
|
||||
iwl_release_nic_access(trans);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
}
|
||||
|
||||
void iwl_set_bits_mask_prph(struct iwl_bus *bus, u32 reg,
|
||||
void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg,
|
||||
u32 bits, u32 mask)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
iwl_grab_nic_access(bus);
|
||||
__iwl_write_prph(bus, reg,
|
||||
(__iwl_read_prph(bus, reg) & mask) | bits);
|
||||
iwl_release_nic_access(bus);
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
iwl_grab_nic_access(trans);
|
||||
__iwl_write_prph(trans, reg,
|
||||
(__iwl_read_prph(trans, reg) & mask) | bits);
|
||||
iwl_release_nic_access(trans);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
}
|
||||
|
||||
void iwl_clear_bits_prph(struct iwl_bus *bus, u32 reg, u32 mask)
|
||||
void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask)
|
||||
{
|
||||
unsigned long flags;
|
||||
u32 val;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
iwl_grab_nic_access(bus);
|
||||
val = __iwl_read_prph(bus, reg);
|
||||
__iwl_write_prph(bus, reg, (val & ~mask));
|
||||
iwl_release_nic_access(bus);
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
iwl_grab_nic_access(trans);
|
||||
val = __iwl_read_prph(trans, reg);
|
||||
__iwl_write_prph(trans, reg, (val & ~mask));
|
||||
iwl_release_nic_access(trans);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
}
|
||||
|
||||
void _iwl_read_targ_mem_words(struct iwl_bus *bus, u32 addr,
|
||||
void _iwl_read_targ_mem_words(struct iwl_trans *trans, u32 addr,
|
||||
void *buf, int words)
|
||||
{
|
||||
unsigned long flags;
|
||||
int offs;
|
||||
u32 *vals = buf;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
iwl_grab_nic_access(bus);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
iwl_grab_nic_access(trans);
|
||||
|
||||
iwl_write32(bus, HBUS_TARG_MEM_RADDR, addr);
|
||||
iwl_write32(trans, HBUS_TARG_MEM_RADDR, addr);
|
||||
rmb();
|
||||
|
||||
for (offs = 0; offs < words; offs++)
|
||||
vals[offs] = iwl_read32(bus, HBUS_TARG_MEM_RDAT);
|
||||
vals[offs] = iwl_read32(trans, HBUS_TARG_MEM_RDAT);
|
||||
|
||||
iwl_release_nic_access(bus);
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
iwl_release_nic_access(trans);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
}
|
||||
|
||||
u32 iwl_read_targ_mem(struct iwl_bus *bus, u32 addr)
|
||||
u32 iwl_read_targ_mem(struct iwl_trans *trans, u32 addr)
|
||||
{
|
||||
u32 value;
|
||||
|
||||
_iwl_read_targ_mem_words(bus, addr, &value, 1);
|
||||
_iwl_read_targ_mem_words(trans, addr, &value, 1);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int _iwl_write_targ_mem_words(struct iwl_bus *bus, u32 addr,
|
||||
int _iwl_write_targ_mem_words(struct iwl_trans *trans, u32 addr,
|
||||
void *buf, int words)
|
||||
{
|
||||
unsigned long flags;
|
||||
int offs, result = 0;
|
||||
u32 *vals = buf;
|
||||
|
||||
spin_lock_irqsave(&bus->reg_lock, flags);
|
||||
if (!iwl_grab_nic_access(bus)) {
|
||||
iwl_write32(bus, HBUS_TARG_MEM_WADDR, addr);
|
||||
spin_lock_irqsave(&trans->reg_lock, flags);
|
||||
if (!iwl_grab_nic_access(trans)) {
|
||||
iwl_write32(trans, HBUS_TARG_MEM_WADDR, addr);
|
||||
wmb();
|
||||
|
||||
for (offs = 0; offs < words; offs++)
|
||||
iwl_write32(bus, HBUS_TARG_MEM_WDAT, vals[offs]);
|
||||
iwl_release_nic_access(bus);
|
||||
iwl_write32(trans, HBUS_TARG_MEM_WDAT, vals[offs]);
|
||||
iwl_release_nic_access(trans);
|
||||
} else
|
||||
result = -EBUSY;
|
||||
spin_unlock_irqrestore(&bus->reg_lock, flags);
|
||||
spin_unlock_irqrestore(&trans->reg_lock, flags);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int iwl_write_targ_mem(struct iwl_bus *bus, u32 addr, u32 val)
|
||||
int iwl_write_targ_mem(struct iwl_trans *trans, u32 addr, u32 val)
|
||||
{
|
||||
return _iwl_write_targ_mem_words(bus, addr, &val, 1);
|
||||
return _iwl_write_targ_mem_words(trans, addr, &val, 1);
|
||||
}
|
||||
|
||||
@@ -31,63 +31,63 @@
|
||||
|
||||
#include "iwl-devtrace.h"
|
||||
#include "iwl-shared.h"
|
||||
#include "iwl-bus.h"
|
||||
#include "iwl-trans.h"
|
||||
|
||||
static inline void iwl_write8(struct iwl_bus *bus, u32 ofs, u8 val)
|
||||
static inline void iwl_write8(struct iwl_trans *trans, u32 ofs, u8 val)
|
||||
{
|
||||
trace_iwlwifi_dev_iowrite8(priv(bus), ofs, val);
|
||||
bus_write8(bus, ofs, val);
|
||||
trace_iwlwifi_dev_iowrite8(priv(trans), ofs, val);
|
||||
iwl_trans_write8(trans, ofs, val);
|
||||
}
|
||||
|
||||
static inline void iwl_write32(struct iwl_bus *bus, u32 ofs, u32 val)
|
||||
static inline void iwl_write32(struct iwl_trans *trans, u32 ofs, u32 val)
|
||||
{
|
||||
trace_iwlwifi_dev_iowrite32(priv(bus), ofs, val);
|
||||
bus_write32(bus, ofs, val);
|
||||
trace_iwlwifi_dev_iowrite32(priv(trans), ofs, val);
|
||||
iwl_trans_write32(trans, ofs, val);
|
||||
}
|
||||
|
||||
static inline u32 iwl_read32(struct iwl_bus *bus, u32 ofs)
|
||||
static inline u32 iwl_read32(struct iwl_trans *trans, u32 ofs)
|
||||
{
|
||||
u32 val = bus_read32(bus, ofs);
|
||||
trace_iwlwifi_dev_ioread32(priv(bus), ofs, val);
|
||||
u32 val = iwl_trans_read32(trans, ofs);
|
||||
trace_iwlwifi_dev_ioread32(priv(trans), ofs, val);
|
||||
return val;
|
||||
}
|
||||
|
||||
void iwl_set_bit(struct iwl_bus *bus, u32 reg, u32 mask);
|
||||
void iwl_clear_bit(struct iwl_bus *bus, u32 reg, u32 mask);
|
||||
void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask);
|
||||
void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask);
|
||||
|
||||
int iwl_poll_bit(struct iwl_bus *bus, u32 addr,
|
||||
int iwl_poll_bit(struct iwl_trans *trans, u32 addr,
|
||||
u32 bits, u32 mask, int timeout);
|
||||
int iwl_poll_direct_bit(struct iwl_bus *bus, u32 addr, u32 mask,
|
||||
int iwl_poll_direct_bit(struct iwl_trans *trans, u32 addr, u32 mask,
|
||||
int timeout);
|
||||
|
||||
int iwl_grab_nic_access_silent(struct iwl_bus *bus);
|
||||
int iwl_grab_nic_access(struct iwl_bus *bus);
|
||||
void iwl_release_nic_access(struct iwl_bus *bus);
|
||||
int iwl_grab_nic_access_silent(struct iwl_trans *trans);
|
||||
int iwl_grab_nic_access(struct iwl_trans *trans);
|
||||
void iwl_release_nic_access(struct iwl_trans *trans);
|
||||
|
||||
u32 iwl_read_direct32(struct iwl_bus *bus, u32 reg);
|
||||
void iwl_write_direct32(struct iwl_bus *bus, u32 reg, u32 value);
|
||||
u32 iwl_read_direct32(struct iwl_trans *trans, u32 reg);
|
||||
void iwl_write_direct32(struct iwl_trans *trans, u32 reg, u32 value);
|
||||
|
||||
|
||||
u32 iwl_read_prph(struct iwl_bus *bus, u32 reg);
|
||||
void iwl_write_prph(struct iwl_bus *bus, u32 addr, u32 val);
|
||||
void iwl_set_bits_prph(struct iwl_bus *bus, u32 reg, u32 mask);
|
||||
void iwl_set_bits_mask_prph(struct iwl_bus *bus, u32 reg,
|
||||
u32 iwl_read_prph(struct iwl_trans *trans, u32 reg);
|
||||
void iwl_write_prph(struct iwl_trans *trans, u32 addr, u32 val);
|
||||
void iwl_set_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask);
|
||||
void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 reg,
|
||||
u32 bits, u32 mask);
|
||||
void iwl_clear_bits_prph(struct iwl_bus *bus, u32 reg, u32 mask);
|
||||
void iwl_clear_bits_prph(struct iwl_trans *trans, u32 reg, u32 mask);
|
||||
|
||||
void _iwl_read_targ_mem_words(struct iwl_bus *bus, u32 addr,
|
||||
void _iwl_read_targ_mem_words(struct iwl_trans *trans, u32 addr,
|
||||
void *buf, int words);
|
||||
|
||||
#define iwl_read_targ_mem_words(bus, addr, buf, bufsize) \
|
||||
#define iwl_read_targ_mem_words(trans, addr, buf, bufsize) \
|
||||
do { \
|
||||
BUILD_BUG_ON((bufsize) % sizeof(u32)); \
|
||||
_iwl_read_targ_mem_words(bus, addr, buf, \
|
||||
_iwl_read_targ_mem_words(trans, addr, buf, \
|
||||
(bufsize) / sizeof(u32));\
|
||||
} while (0)
|
||||
|
||||
int _iwl_write_targ_mem_words(struct iwl_bus *bus, u32 addr,
|
||||
int _iwl_write_targ_mem_words(struct iwl_trans *trans, u32 addr,
|
||||
void *buf, int words);
|
||||
|
||||
u32 iwl_read_targ_mem(struct iwl_bus *bus, u32 addr);
|
||||
int iwl_write_targ_mem(struct iwl_bus *bus, u32 addr, u32 val);
|
||||
u32 iwl_read_targ_mem(struct iwl_trans *trans, u32 addr);
|
||||
int iwl_write_targ_mem(struct iwl_trans *trans, u32 addr, u32 val);
|
||||
#endif
|
||||
|
||||
@@ -71,7 +71,7 @@ static const struct ieee80211_tpt_blink iwl_blink[] = {
|
||||
/* Set led register off */
|
||||
void iwlagn_led_enable(struct iwl_priv *priv)
|
||||
{
|
||||
iwl_write32(bus(priv), CSR_LED_REG, CSR_LED_REG_TRUN_ON);
|
||||
iwl_write32(trans(priv), CSR_LED_REG, CSR_LED_REG_TRUN_ON);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -107,9 +107,10 @@ static int iwl_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd)
|
||||
};
|
||||
u32 reg;
|
||||
|
||||
reg = iwl_read32(bus(priv), CSR_LED_REG);
|
||||
reg = iwl_read32(trans(priv), CSR_LED_REG);
|
||||
if (reg != (reg & CSR_LED_BSM_CTRL_MSK))
|
||||
iwl_write32(bus(priv), CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK);
|
||||
iwl_write32(trans(priv), CSR_LED_REG,
|
||||
reg & CSR_LED_BSM_CTRL_MSK);
|
||||
|
||||
return iwl_trans_send_cmd(trans(priv), &cmd);
|
||||
}
|
||||
@@ -206,7 +207,7 @@ void iwl_leds_init(struct iwl_priv *priv)
|
||||
break;
|
||||
}
|
||||
|
||||
ret = led_classdev_register(bus(priv)->dev, &priv->led);
|
||||
ret = led_classdev_register(trans(priv)->dev, &priv->led);
|
||||
if (ret) {
|
||||
kfree(priv->led.name);
|
||||
return;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <linux/sched.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/firmware.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/if_arp.h>
|
||||
|
||||
@@ -43,6 +42,7 @@
|
||||
|
||||
#include <asm/div64.h>
|
||||
|
||||
#include "iwl-ucode.h"
|
||||
#include "iwl-eeprom.h"
|
||||
#include "iwl-wifi.h"
|
||||
#include "iwl-dev.h"
|
||||
@@ -196,7 +196,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
|
||||
WIPHY_FLAG_IBSS_RSN;
|
||||
|
||||
if (trans(priv)->ucode_wowlan.code.len &&
|
||||
device_can_wakeup(bus(priv)->dev)) {
|
||||
device_can_wakeup(trans(priv)->dev)) {
|
||||
hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT |
|
||||
WIPHY_WOWLAN_DISCONNECT |
|
||||
WIPHY_WOWLAN_EAP_IDENTITY_REQ |
|
||||
@@ -234,7 +234,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
|
||||
priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
|
||||
&priv->bands[IEEE80211_BAND_5GHZ];
|
||||
|
||||
hw->wiphy->hw_version = bus_get_hw_id(bus(priv));
|
||||
hw->wiphy->hw_version = trans(priv)->hw_id;
|
||||
|
||||
iwl_leds_init(priv);
|
||||
|
||||
@@ -346,9 +346,10 @@ static void iwlagn_mac_stop(struct ieee80211_hw *hw)
|
||||
flush_workqueue(priv->shrd->workqueue);
|
||||
|
||||
/* User space software may expect getting rfkill changes
|
||||
* even if interface is down */
|
||||
iwl_write32(bus(priv), CSR_INT, 0xFFFFFFFF);
|
||||
iwl_enable_rfkill_int(priv);
|
||||
* even if interface is down, trans->down will leave the RF
|
||||
* kill interrupt enabled
|
||||
*/
|
||||
iwl_trans_stop_hw(trans(priv));
|
||||
|
||||
IWL_DEBUG_MAC80211(priv, "leave\n");
|
||||
}
|
||||
@@ -405,10 +406,10 @@ static int iwlagn_mac_suspend(struct ieee80211_hw *hw,
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
device_set_wakeup_enable(bus(priv)->dev, true);
|
||||
device_set_wakeup_enable(trans(priv)->dev, true);
|
||||
|
||||
/* Now let the ucode operate on its own */
|
||||
iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET,
|
||||
iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_SET,
|
||||
CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
|
||||
|
||||
goto out;
|
||||
@@ -436,19 +437,19 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
|
||||
IWL_DEBUG_MAC80211(priv, "enter\n");
|
||||
mutex_lock(&priv->shrd->mutex);
|
||||
|
||||
iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR,
|
||||
iwl_write32(trans(priv), CSR_UCODE_DRV_GP1_CLR,
|
||||
CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE);
|
||||
|
||||
base = priv->shrd->device_pointers.error_event_table;
|
||||
if (iwlagn_hw_valid_rtc_data_addr(base)) {
|
||||
spin_lock_irqsave(&bus(priv)->reg_lock, flags);
|
||||
ret = iwl_grab_nic_access_silent(bus(priv));
|
||||
spin_lock_irqsave(&trans(priv)->reg_lock, flags);
|
||||
ret = iwl_grab_nic_access_silent(trans(priv));
|
||||
if (ret == 0) {
|
||||
iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, base);
|
||||
status = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT);
|
||||
iwl_release_nic_access(bus(priv));
|
||||
iwl_write32(trans(priv), HBUS_TARG_MEM_RADDR, base);
|
||||
status = iwl_read32(trans(priv), HBUS_TARG_MEM_RDAT);
|
||||
iwl_release_nic_access(trans(priv));
|
||||
}
|
||||
spin_unlock_irqrestore(&bus(priv)->reg_lock, flags);
|
||||
spin_unlock_irqrestore(&trans(priv)->reg_lock, flags);
|
||||
|
||||
#ifdef CONFIG_IWLWIFI_DEBUGFS
|
||||
if (ret == 0) {
|
||||
@@ -460,7 +461,8 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
|
||||
|
||||
if (priv->wowlan_sram)
|
||||
_iwl_read_targ_mem_words(
|
||||
bus(priv), 0x800000, priv->wowlan_sram,
|
||||
trans(priv), 0x800000,
|
||||
priv->wowlan_sram,
|
||||
trans->ucode_wowlan.data.len / 4);
|
||||
}
|
||||
#endif
|
||||
@@ -471,7 +473,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
|
||||
|
||||
priv->shrd->wowlan = false;
|
||||
|
||||
device_set_wakeup_enable(bus(priv)->dev, false);
|
||||
device_set_wakeup_enable(trans(priv)->dev, false);
|
||||
|
||||
iwlagn_prepare_restart(priv);
|
||||
|
||||
|
||||
@@ -71,112 +71,6 @@
|
||||
#include "iwl-csr.h"
|
||||
#include "iwl-cfg.h"
|
||||
|
||||
/* PCI registers */
|
||||
#define PCI_CFG_RETRY_TIMEOUT 0x041
|
||||
#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
|
||||
#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
|
||||
|
||||
struct iwl_pci_bus {
|
||||
/* basic pci-network driver stuff */
|
||||
struct pci_dev *pci_dev;
|
||||
|
||||
/* pci hardware address support */
|
||||
void __iomem *hw_base;
|
||||
};
|
||||
|
||||
#define IWL_BUS_GET_PCI_BUS(_iwl_bus) \
|
||||
((struct iwl_pci_bus *) ((_iwl_bus)->bus_specific))
|
||||
|
||||
#define IWL_BUS_GET_PCI_DEV(_iwl_bus) \
|
||||
((IWL_BUS_GET_PCI_BUS(_iwl_bus))->pci_dev)
|
||||
|
||||
static u16 iwl_pciexp_link_ctrl(struct iwl_bus *bus)
|
||||
{
|
||||
int pos;
|
||||
u16 pci_lnk_ctl;
|
||||
|
||||
struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus);
|
||||
|
||||
pos = pci_pcie_cap(pci_dev);
|
||||
pci_read_config_word(pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl);
|
||||
return pci_lnk_ctl;
|
||||
}
|
||||
|
||||
static bool iwl_pci_is_pm_supported(struct iwl_bus *bus)
|
||||
{
|
||||
u16 lctl = iwl_pciexp_link_ctrl(bus);
|
||||
|
||||
return !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN);
|
||||
}
|
||||
|
||||
static void iwl_pci_apm_config(struct iwl_bus *bus)
|
||||
{
|
||||
/*
|
||||
* HW bug W/A for instability in PCIe bus L0S->L1 transition.
|
||||
* Check if BIOS (or OS) enabled L1-ASPM on this device.
|
||||
* If so (likely), disable L0S, so device moves directly L0->L1;
|
||||
* costs negligible amount of power savings.
|
||||
* If not (unlikely), enable L0S, so there is at least some
|
||||
* power savings, even without L1.
|
||||
*/
|
||||
u16 lctl = iwl_pciexp_link_ctrl(bus);
|
||||
|
||||
if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) ==
|
||||
PCI_CFG_LINK_CTRL_VAL_L1_EN) {
|
||||
/* L1-ASPM enabled; disable(!) L0S */
|
||||
iwl_set_bit(bus, CSR_GIO_REG,
|
||||
CSR_GIO_REG_VAL_L0S_ENABLED);
|
||||
dev_printk(KERN_INFO, bus->dev, "L1 Enabled; Disabling L0S\n");
|
||||
} else {
|
||||
/* L1-ASPM disabled; enable(!) L0S */
|
||||
iwl_clear_bit(bus, CSR_GIO_REG,
|
||||
CSR_GIO_REG_VAL_L0S_ENABLED);
|
||||
dev_printk(KERN_INFO, bus->dev, "L1 Disabled; Enabling L0S\n");
|
||||
}
|
||||
}
|
||||
|
||||
static void iwl_pci_get_hw_id_string(struct iwl_bus *bus, char buf[],
|
||||
int buf_len)
|
||||
{
|
||||
struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus);
|
||||
|
||||
snprintf(buf, buf_len, "PCI ID: 0x%04X:0x%04X", pci_dev->device,
|
||||
pci_dev->subsystem_device);
|
||||
}
|
||||
|
||||
static u32 iwl_pci_get_hw_id(struct iwl_bus *bus)
|
||||
{
|
||||
struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus);
|
||||
|
||||
return (pci_dev->device << 16) + pci_dev->subsystem_device;
|
||||
}
|
||||
|
||||
static void iwl_pci_write8(struct iwl_bus *bus, u32 ofs, u8 val)
|
||||
{
|
||||
iowrite8(val, IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs);
|
||||
}
|
||||
|
||||
static void iwl_pci_write32(struct iwl_bus *bus, u32 ofs, u32 val)
|
||||
{
|
||||
iowrite32(val, IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs);
|
||||
}
|
||||
|
||||
static u32 iwl_pci_read32(struct iwl_bus *bus, u32 ofs)
|
||||
{
|
||||
u32 val = ioread32(IWL_BUS_GET_PCI_BUS(bus)->hw_base + ofs);
|
||||
return val;
|
||||
}
|
||||
|
||||
static const struct iwl_bus_ops bus_ops_pci = {
|
||||
.get_pm_support = iwl_pci_is_pm_supported,
|
||||
.apm_config = iwl_pci_apm_config,
|
||||
.get_hw_id_string = iwl_pci_get_hw_id_string,
|
||||
.get_hw_id = iwl_pci_get_hw_id,
|
||||
.write8 = iwl_pci_write8,
|
||||
.write32 = iwl_pci_write32,
|
||||
.read32 = iwl_pci_read32,
|
||||
};
|
||||
|
||||
#define IWL_PCI_DEVICE(dev, subdev, cfg) \
|
||||
.vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \
|
||||
.subvendor = PCI_ANY_ID, .subdevice = (subdev), \
|
||||
@@ -362,112 +256,61 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
|
||||
|
||||
/* PCI registers */
|
||||
#define PCI_CFG_RETRY_TIMEOUT 0x041
|
||||
|
||||
static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
{
|
||||
struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
|
||||
struct iwl_bus *bus;
|
||||
struct iwl_pci_bus *pci_bus;
|
||||
u16 pci_cmd;
|
||||
int err;
|
||||
|
||||
bus = kzalloc(sizeof(*bus) + sizeof(*pci_bus), GFP_KERNEL);
|
||||
bus = kzalloc(sizeof(*bus), GFP_KERNEL);
|
||||
if (!bus) {
|
||||
dev_printk(KERN_ERR, &pdev->dev,
|
||||
"Couldn't allocate iwl_pci_bus");
|
||||
err = -ENOMEM;
|
||||
goto out_no_pci;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
pci_bus = IWL_BUS_GET_PCI_BUS(bus);
|
||||
pci_bus->pci_dev = pdev;
|
||||
bus->shrd = kzalloc(sizeof(*bus->shrd), GFP_KERNEL);
|
||||
if (!bus->shrd) {
|
||||
dev_printk(KERN_ERR, &pdev->dev,
|
||||
"Couldn't allocate iwl_shared");
|
||||
err = -ENOMEM;
|
||||
goto out_free_bus;
|
||||
}
|
||||
|
||||
bus->shrd->bus = bus;
|
||||
|
||||
pci_set_drvdata(pdev, bus);
|
||||
|
||||
/* W/A - seems to solve weird behavior. We need to remove this if we
|
||||
* don't want to stay in L1 all the time. This wastes a lot of power */
|
||||
pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 |
|
||||
PCIE_LINK_STATE_CLKPM);
|
||||
|
||||
if (pci_enable_device(pdev)) {
|
||||
err = -ENODEV;
|
||||
goto out_no_pci;
|
||||
#ifdef CONFIG_IWLWIFI_IDI
|
||||
trans(bus) = iwl_trans_idi_alloc(bus->shrd, pdev, ent);
|
||||
if (trans(bus) == NULL) {
|
||||
err = -ENOMEM;
|
||||
goto out_free_bus;
|
||||
}
|
||||
|
||||
pci_set_master(pdev);
|
||||
|
||||
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36));
|
||||
if (!err)
|
||||
err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36));
|
||||
if (err) {
|
||||
err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
||||
if (!err)
|
||||
err = pci_set_consistent_dma_mask(pdev,
|
||||
DMA_BIT_MASK(32));
|
||||
/* both attempts failed: */
|
||||
if (err) {
|
||||
dev_printk(KERN_ERR, bus->dev,
|
||||
"No suitable DMA available.\n");
|
||||
goto out_pci_disable_device;
|
||||
}
|
||||
err = iwl_probe(bus, &trans_ops_idi, cfg);
|
||||
#else
|
||||
trans(bus) = iwl_trans_pcie_alloc(bus->shrd, pdev, ent);
|
||||
if (trans(bus) == NULL) {
|
||||
err = -ENOMEM;
|
||||
goto out_free_bus;
|
||||
}
|
||||
|
||||
err = pci_request_regions(pdev, DRV_NAME);
|
||||
if (err) {
|
||||
dev_printk(KERN_ERR, bus->dev, "pci_request_regions failed");
|
||||
goto out_pci_disable_device;
|
||||
}
|
||||
|
||||
pci_bus->hw_base = pci_iomap(pdev, 0, 0);
|
||||
if (!pci_bus->hw_base) {
|
||||
dev_printk(KERN_ERR, bus->dev, "pci_iomap failed");
|
||||
err = -ENODEV;
|
||||
goto out_pci_release_regions;
|
||||
}
|
||||
|
||||
dev_printk(KERN_INFO, &pdev->dev,
|
||||
"pci_resource_len = 0x%08llx\n",
|
||||
(unsigned long long) pci_resource_len(pdev, 0));
|
||||
dev_printk(KERN_INFO, &pdev->dev,
|
||||
"pci_resource_base = %p\n", pci_bus->hw_base);
|
||||
|
||||
dev_printk(KERN_INFO, &pdev->dev,
|
||||
"HW Revision ID = 0x%X\n", pdev->revision);
|
||||
|
||||
/* We disable the RETRY_TIMEOUT register (0x41) to keep
|
||||
* PCI Tx retries from interfering with C3 CPU state */
|
||||
pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
|
||||
|
||||
err = pci_enable_msi(pdev);
|
||||
if (err)
|
||||
dev_printk(KERN_ERR, &pdev->dev,
|
||||
"pci_enable_msi failed(0X%x)", err);
|
||||
|
||||
/* TODO: Move this away, not needed if not MSI */
|
||||
/* enable rfkill interrupt: hw bug w/a */
|
||||
pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd);
|
||||
if (pci_cmd & PCI_COMMAND_INTX_DISABLE) {
|
||||
pci_cmd &= ~PCI_COMMAND_INTX_DISABLE;
|
||||
pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
|
||||
}
|
||||
|
||||
bus->dev = &pdev->dev;
|
||||
bus->irq = pdev->irq;
|
||||
bus->ops = &bus_ops_pci;
|
||||
|
||||
err = iwl_probe(bus, &trans_ops_pcie, cfg);
|
||||
#endif
|
||||
if (err)
|
||||
goto out_disable_msi;
|
||||
goto out_free_trans;
|
||||
|
||||
return 0;
|
||||
|
||||
out_disable_msi:
|
||||
pci_disable_msi(pdev);
|
||||
pci_iounmap(pdev, pci_bus->hw_base);
|
||||
out_pci_release_regions:
|
||||
out_free_trans:
|
||||
iwl_trans_free(trans(bus));
|
||||
pci_set_drvdata(pdev, NULL);
|
||||
pci_release_regions(pdev);
|
||||
out_pci_disable_device:
|
||||
pci_disable_device(pdev);
|
||||
out_no_pci:
|
||||
out_free_bus:
|
||||
kfree(bus->shrd);
|
||||
kfree(bus);
|
||||
return err;
|
||||
}
|
||||
@@ -475,18 +318,14 @@ out_no_pci:
|
||||
static void __devexit iwl_pci_remove(struct pci_dev *pdev)
|
||||
{
|
||||
struct iwl_bus *bus = pci_get_drvdata(pdev);
|
||||
struct iwl_pci_bus *pci_bus = IWL_BUS_GET_PCI_BUS(bus);
|
||||
struct pci_dev *pci_dev = IWL_BUS_GET_PCI_DEV(bus);
|
||||
struct iwl_shared *shrd = bus->shrd;
|
||||
|
||||
iwl_remove(shrd->priv);
|
||||
iwl_trans_free(shrd->trans);
|
||||
|
||||
pci_disable_msi(pci_dev);
|
||||
pci_iounmap(pci_dev, pci_bus->hw_base);
|
||||
pci_release_regions(pci_dev);
|
||||
pci_disable_device(pci_dev);
|
||||
pci_set_drvdata(pci_dev, NULL);
|
||||
pci_set_drvdata(pdev, NULL);
|
||||
|
||||
kfree(bus->shrd);
|
||||
kfree(bus);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user