Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e139dc4a authored by Lilach Edelstein's avatar Lilach Edelstein Committed by Johannes Berg
Browse files

iwlwifi: add iwl_set_bits_mask to transport API



Express iwl_set_bit() and iwl_clear_bit() through iwl_set_bits_mask()
and add the latter to the transport's API in order to allow different
implementation for different transport types in the future.

Signed-off-by: default avatarLilach Edelstein <lilach.edelstein@intel.com>
Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 6690c01d
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -1991,7 +1991,7 @@ static void iwl_nic_config(struct iwl_op_mode *op_mode)
	struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);

	/* SKU Control */
	iwl_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG,
	iwl_trans_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG,
				CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH |
				CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP,
				(CSR_HW_REV_STEP(priv->trans->hw_rev) <<
@@ -2009,10 +2009,11 @@ static void iwl_nic_config(struct iwl_op_mode *op_mode)
			priv->nvm_data->radio_cfg_dash <<
				CSR_HW_IF_CONFIG_REG_POS_PHY_DASH;

		iwl_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG,
		iwl_trans_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG,
					CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE |
					CSR_HW_IF_CONFIG_REG_MSK_PHY_STEP |
				  CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH, reg_val);
					CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH,
					reg_val);

		IWL_INFO(priv, "Radio type=0x%x-0x%x-0x%x\n",
			 priv->nvm_data->radio_cfg_type,
+0 −48
Original line number Diff line number Diff line
@@ -35,54 +35,6 @@

#define IWL_POLL_INTERVAL 10	/* microseconds */

void __iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask)
{
	iwl_write32(trans, reg, iwl_read32(trans, reg) | mask);
}

void __iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
{
	iwl_write32(trans, reg, iwl_read32(trans, reg) & ~mask);
}

void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask)
{
	unsigned long flags;

	spin_lock_irqsave(&trans->reg_lock, flags);
	__iwl_set_bit(trans, reg, mask);
	spin_unlock_irqrestore(&trans->reg_lock, flags);
}
EXPORT_SYMBOL_GPL(iwl_set_bit);

void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
{
	unsigned long flags;

	spin_lock_irqsave(&trans->reg_lock, flags);
	__iwl_clear_bit(trans, reg, mask);
	spin_unlock_irqrestore(&trans->reg_lock, flags);
}
EXPORT_SYMBOL_GPL(iwl_clear_bit);

void iwl_set_bits_mask(struct iwl_trans *trans, u32 reg, u32 mask, u32 value)
{
	unsigned long flags;
	u32 v;

#ifdef CONFIG_IWLWIFI_DEBUG
	WARN_ON_ONCE(value & ~mask);
#endif

	spin_lock_irqsave(&trans->reg_lock, flags);
	v = iwl_read32(trans, reg);
	v &= ~mask;
	v |= value;
	iwl_write32(trans, reg, v);
	spin_unlock_irqrestore(&trans->reg_lock, flags);
}
EXPORT_SYMBOL_GPL(iwl_set_bits_mask);

int iwl_poll_bit(struct iwl_trans *trans, u32 addr,
		 u32 bits, u32 mask, int timeout)
{
+8 −5
Original line number Diff line number Diff line
@@ -51,12 +51,15 @@ static inline u32 iwl_read32(struct iwl_trans *trans, u32 ofs)
	return val;
}

void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask);
void iwl_clear_bit(struct iwl_trans *trans, 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);
static inline void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask)
{
	iwl_trans_set_bits_mask(trans, reg, mask, mask);
}

void iwl_set_bits_mask(struct iwl_trans *trans, u32 reg, u32 mask, u32 value);
static inline void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask)
{
	iwl_trans_set_bits_mask(trans, reg, mask, 0);
}

int iwl_poll_bit(struct iwl_trans *trans, u32 addr,
		 u32 bits, u32 mask, int timeout);
+9 −0
Original line number Diff line number Diff line
@@ -418,6 +418,7 @@ struct iwl_trans;
 * @set_pmi: set the power pmi state
 * @grab_nic_access: wake the NIC to be able to access non-HBUS regs
 * @release_nic_access: let the NIC go to sleep
 * @set_bits_mask - set SRAM register according to value and mask.
 */
struct iwl_trans_ops {

@@ -462,6 +463,8 @@ struct iwl_trans_ops {
	void (*set_pmi)(struct iwl_trans *trans, bool state);
	bool (*grab_nic_access)(struct iwl_trans *trans, bool silent);
	void (*release_nic_access)(struct iwl_trans *trans);
	void (*set_bits_mask)(struct iwl_trans *trans, u32 reg, u32 mask,
			      u32 value);
};

/**
@@ -762,6 +765,12 @@ static inline void iwl_trans_set_pmi(struct iwl_trans *trans, bool state)
	trans->ops->set_pmi(trans, state);
}

static inline void
iwl_trans_set_bits_mask(struct iwl_trans *trans, u32 reg, u32 mask, u32 value)
{
	trans->ops->set_bits_mask(trans, reg, mask, value);
}

#define iwl_trans_grab_nic_access(trans, silent)	\
	__cond_lock(nic_access,				\
		    likely((trans)->ops->grab_nic_access(trans, silent)))
+9 −9
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ static void iwl_mvm_nic_config(struct iwl_op_mode *op_mode)
	reg_val |= CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI;
	reg_val |= CSR_HW_IF_CONFIG_REG_BIT_MAC_SI;

	iwl_set_bits_mask(mvm->trans, CSR_HW_IF_CONFIG_REG,
	iwl_trans_set_bits_mask(mvm->trans, CSR_HW_IF_CONFIG_REG,
				CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH |
				CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP |
				CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE |
Loading