diff options
author | Lilach Edelstein <lilach.edelstein@intel.com> | 2013-01-13 06:31:10 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2013-02-01 05:27:22 -0500 |
commit | e139dc4aebf52a9c88552963b9794fd1dff036f1 (patch) | |
tree | 4ade4541db26cf923a911efb551ded4e5ecb8748 | |
parent | 6690c01d168ecc620139dbd9df8affc2ac8e0683 (diff) |
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: Lilach Edelstein <lilach.edelstein@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/dvm/main.c | 23 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-io.c | 48 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-io.h | 13 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-trans.h | 9 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/mvm/ops.c | 18 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/pcie/trans.c | 48 |
6 files changed, 81 insertions, 78 deletions
diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c index 04b467ff25e1..f5f91644adaa 100644 --- a/drivers/net/wireless/iwlwifi/dvm/main.c +++ b/drivers/net/wireless/iwlwifi/dvm/main.c | |||
@@ -1991,13 +1991,13 @@ static void iwl_nic_config(struct iwl_op_mode *op_mode) | |||
1991 | struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); | 1991 | struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode); |
1992 | 1992 | ||
1993 | /* SKU Control */ | 1993 | /* SKU Control */ |
1994 | iwl_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG, | 1994 | iwl_trans_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG, |
1995 | CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH | | 1995 | CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH | |
1996 | CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP, | 1996 | CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP, |
1997 | (CSR_HW_REV_STEP(priv->trans->hw_rev) << | 1997 | (CSR_HW_REV_STEP(priv->trans->hw_rev) << |
1998 | CSR_HW_IF_CONFIG_REG_POS_MAC_STEP) | | 1998 | CSR_HW_IF_CONFIG_REG_POS_MAC_STEP) | |
1999 | (CSR_HW_REV_DASH(priv->trans->hw_rev) << | 1999 | (CSR_HW_REV_DASH(priv->trans->hw_rev) << |
2000 | CSR_HW_IF_CONFIG_REG_POS_MAC_DASH)); | 2000 | CSR_HW_IF_CONFIG_REG_POS_MAC_DASH)); |
2001 | 2001 | ||
2002 | /* write radio config values to register */ | 2002 | /* write radio config values to register */ |
2003 | if (priv->nvm_data->radio_cfg_type <= EEPROM_RF_CONFIG_TYPE_MAX) { | 2003 | if (priv->nvm_data->radio_cfg_type <= EEPROM_RF_CONFIG_TYPE_MAX) { |
@@ -2009,10 +2009,11 @@ static void iwl_nic_config(struct iwl_op_mode *op_mode) | |||
2009 | priv->nvm_data->radio_cfg_dash << | 2009 | priv->nvm_data->radio_cfg_dash << |
2010 | CSR_HW_IF_CONFIG_REG_POS_PHY_DASH; | 2010 | CSR_HW_IF_CONFIG_REG_POS_PHY_DASH; |
2011 | 2011 | ||
2012 | iwl_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG, | 2012 | iwl_trans_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG, |
2013 | CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE | | 2013 | CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE | |
2014 | CSR_HW_IF_CONFIG_REG_MSK_PHY_STEP | | 2014 | CSR_HW_IF_CONFIG_REG_MSK_PHY_STEP | |
2015 | CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH, reg_val); | 2015 | CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH, |
2016 | reg_val); | ||
2016 | 2017 | ||
2017 | IWL_INFO(priv, "Radio type=0x%x-0x%x-0x%x\n", | 2018 | IWL_INFO(priv, "Radio type=0x%x-0x%x-0x%x\n", |
2018 | priv->nvm_data->radio_cfg_type, | 2019 | priv->nvm_data->radio_cfg_type, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index dbc0122d1770..7ef47389953e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c | |||
@@ -35,54 +35,6 @@ | |||
35 | 35 | ||
36 | #define IWL_POLL_INTERVAL 10 /* microseconds */ | 36 | #define IWL_POLL_INTERVAL 10 /* microseconds */ |
37 | 37 | ||
38 | void __iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask) | ||
39 | { | ||
40 | iwl_write32(trans, reg, iwl_read32(trans, reg) | mask); | ||
41 | } | ||
42 | |||
43 | void __iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask) | ||
44 | { | ||
45 | iwl_write32(trans, reg, iwl_read32(trans, reg) & ~mask); | ||
46 | } | ||
47 | |||
48 | void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask) | ||
49 | { | ||
50 | unsigned long flags; | ||
51 | |||
52 | spin_lock_irqsave(&trans->reg_lock, flags); | ||
53 | __iwl_set_bit(trans, reg, mask); | ||
54 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
55 | } | ||
56 | EXPORT_SYMBOL_GPL(iwl_set_bit); | ||
57 | |||
58 | void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask) | ||
59 | { | ||
60 | unsigned long flags; | ||
61 | |||
62 | spin_lock_irqsave(&trans->reg_lock, flags); | ||
63 | __iwl_clear_bit(trans, reg, mask); | ||
64 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
65 | } | ||
66 | EXPORT_SYMBOL_GPL(iwl_clear_bit); | ||
67 | |||
68 | void iwl_set_bits_mask(struct iwl_trans *trans, u32 reg, u32 mask, u32 value) | ||
69 | { | ||
70 | unsigned long flags; | ||
71 | u32 v; | ||
72 | |||
73 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
74 | WARN_ON_ONCE(value & ~mask); | ||
75 | #endif | ||
76 | |||
77 | spin_lock_irqsave(&trans->reg_lock, flags); | ||
78 | v = iwl_read32(trans, reg); | ||
79 | v &= ~mask; | ||
80 | v |= value; | ||
81 | iwl_write32(trans, reg, v); | ||
82 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
83 | } | ||
84 | EXPORT_SYMBOL_GPL(iwl_set_bits_mask); | ||
85 | |||
86 | int iwl_poll_bit(struct iwl_trans *trans, u32 addr, | 38 | int iwl_poll_bit(struct iwl_trans *trans, u32 addr, |
87 | u32 bits, u32 mask, int timeout) | 39 | u32 bits, u32 mask, int timeout) |
88 | { | 40 | { |
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h index 5d0ce434c908..fd9f5b97fff3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.h +++ b/drivers/net/wireless/iwlwifi/iwl-io.h | |||
@@ -51,12 +51,15 @@ static inline u32 iwl_read32(struct iwl_trans *trans, u32 ofs) | |||
51 | return val; | 51 | return val; |
52 | } | 52 | } |
53 | 53 | ||
54 | void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask); | 54 | static inline void iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask) |
55 | void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask); | 55 | { |
56 | void __iwl_set_bit(struct iwl_trans *trans, u32 reg, u32 mask); | 56 | iwl_trans_set_bits_mask(trans, reg, mask, mask); |
57 | void __iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask); | 57 | } |
58 | 58 | ||
59 | void iwl_set_bits_mask(struct iwl_trans *trans, u32 reg, u32 mask, u32 value); | 59 | static inline void iwl_clear_bit(struct iwl_trans *trans, u32 reg, u32 mask) |
60 | { | ||
61 | iwl_trans_set_bits_mask(trans, reg, mask, 0); | ||
62 | } | ||
60 | 63 | ||
61 | int iwl_poll_bit(struct iwl_trans *trans, u32 addr, | 64 | int iwl_poll_bit(struct iwl_trans *trans, u32 addr, |
62 | u32 bits, u32 mask, int timeout); | 65 | u32 bits, u32 mask, int timeout); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index d4ab24b9d2b4..c2b7e856a726 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h | |||
@@ -418,6 +418,7 @@ struct iwl_trans; | |||
418 | * @set_pmi: set the power pmi state | 418 | * @set_pmi: set the power pmi state |
419 | * @grab_nic_access: wake the NIC to be able to access non-HBUS regs | 419 | * @grab_nic_access: wake the NIC to be able to access non-HBUS regs |
420 | * @release_nic_access: let the NIC go to sleep | 420 | * @release_nic_access: let the NIC go to sleep |
421 | * @set_bits_mask - set SRAM register according to value and mask. | ||
421 | */ | 422 | */ |
422 | struct iwl_trans_ops { | 423 | struct iwl_trans_ops { |
423 | 424 | ||
@@ -462,6 +463,8 @@ struct iwl_trans_ops { | |||
462 | void (*set_pmi)(struct iwl_trans *trans, bool state); | 463 | void (*set_pmi)(struct iwl_trans *trans, bool state); |
463 | bool (*grab_nic_access)(struct iwl_trans *trans, bool silent); | 464 | bool (*grab_nic_access)(struct iwl_trans *trans, bool silent); |
464 | void (*release_nic_access)(struct iwl_trans *trans); | 465 | void (*release_nic_access)(struct iwl_trans *trans); |
466 | void (*set_bits_mask)(struct iwl_trans *trans, u32 reg, u32 mask, | ||
467 | u32 value); | ||
465 | }; | 468 | }; |
466 | 469 | ||
467 | /** | 470 | /** |
@@ -762,6 +765,12 @@ static inline void iwl_trans_set_pmi(struct iwl_trans *trans, bool state) | |||
762 | trans->ops->set_pmi(trans, state); | 765 | trans->ops->set_pmi(trans, state); |
763 | } | 766 | } |
764 | 767 | ||
768 | static inline void | ||
769 | iwl_trans_set_bits_mask(struct iwl_trans *trans, u32 reg, u32 mask, u32 value) | ||
770 | { | ||
771 | trans->ops->set_bits_mask(trans, reg, mask, value); | ||
772 | } | ||
773 | |||
765 | #define iwl_trans_grab_nic_access(trans, silent) \ | 774 | #define iwl_trans_grab_nic_access(trans, silent) \ |
766 | __cond_lock(nic_access, \ | 775 | __cond_lock(nic_access, \ |
767 | likely((trans)->ops->grab_nic_access(trans, silent))) | 776 | likely((trans)->ops->grab_nic_access(trans, silent))) |
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c index e675e4a6707f..983dca3f888a 100644 --- a/drivers/net/wireless/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/iwlwifi/mvm/ops.c | |||
@@ -177,15 +177,15 @@ static void iwl_mvm_nic_config(struct iwl_op_mode *op_mode) | |||
177 | reg_val |= CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI; | 177 | reg_val |= CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI; |
178 | reg_val |= CSR_HW_IF_CONFIG_REG_BIT_MAC_SI; | 178 | reg_val |= CSR_HW_IF_CONFIG_REG_BIT_MAC_SI; |
179 | 179 | ||
180 | iwl_set_bits_mask(mvm->trans, CSR_HW_IF_CONFIG_REG, | 180 | iwl_trans_set_bits_mask(mvm->trans, CSR_HW_IF_CONFIG_REG, |
181 | CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH | | 181 | CSR_HW_IF_CONFIG_REG_MSK_MAC_DASH | |
182 | CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP | | 182 | CSR_HW_IF_CONFIG_REG_MSK_MAC_STEP | |
183 | CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE | | 183 | CSR_HW_IF_CONFIG_REG_MSK_PHY_TYPE | |
184 | CSR_HW_IF_CONFIG_REG_MSK_PHY_STEP | | 184 | CSR_HW_IF_CONFIG_REG_MSK_PHY_STEP | |
185 | CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH | | 185 | CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH | |
186 | CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | | 186 | CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | |
187 | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI, | 187 | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI, |
188 | reg_val); | 188 | reg_val); |
189 | 189 | ||
190 | IWL_DEBUG_INFO(mvm, "Radio type=0x%x-0x%x-0x%x\n", radio_cfg_type, | 190 | IWL_DEBUG_INFO(mvm, "Radio type=0x%x-0x%x-0x%x\n", radio_cfg_type, |
191 | radio_cfg_step, radio_cfg_dash); | 191 | radio_cfg_step, radio_cfg_dash); |
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c index 35685c507b0b..8692494c1c48 100644 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c | |||
@@ -75,6 +75,33 @@ | |||
75 | #include "iwl-agn-hw.h" | 75 | #include "iwl-agn-hw.h" |
76 | #include "internal.h" | 76 | #include "internal.h" |
77 | 77 | ||
78 | static void __iwl_trans_pcie_set_bits_mask(struct iwl_trans *trans, | ||
79 | u32 reg, u32 mask, u32 value) | ||
80 | { | ||
81 | u32 v; | ||
82 | |||
83 | #ifdef CONFIG_IWLWIFI_DEBUG | ||
84 | WARN_ON_ONCE(value & ~mask); | ||
85 | #endif | ||
86 | |||
87 | v = iwl_read32(trans, reg); | ||
88 | v &= ~mask; | ||
89 | v |= value; | ||
90 | iwl_write32(trans, reg, v); | ||
91 | } | ||
92 | |||
93 | static inline void __iwl_trans_pcie_clear_bit(struct iwl_trans *trans, | ||
94 | u32 reg, u32 mask) | ||
95 | { | ||
96 | __iwl_trans_pcie_set_bits_mask(trans, reg, mask, 0); | ||
97 | } | ||
98 | |||
99 | static inline void __iwl_trans_pcie_set_bit(struct iwl_trans *trans, | ||
100 | u32 reg, u32 mask) | ||
101 | { | ||
102 | __iwl_trans_pcie_set_bits_mask(trans, reg, mask, mask); | ||
103 | } | ||
104 | |||
78 | static void iwl_pcie_set_pwr(struct iwl_trans *trans, bool vaux) | 105 | static void iwl_pcie_set_pwr(struct iwl_trans *trans, bool vaux) |
79 | { | 106 | { |
80 | if (vaux && pci_pme_capable(to_pci_dev(trans->dev), PCI_D3cold)) | 107 | if (vaux && pci_pme_capable(to_pci_dev(trans->dev), PCI_D3cold)) |
@@ -786,8 +813,8 @@ static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans, bool silent) | |||
786 | lockdep_assert_held(&trans->reg_lock); | 813 | lockdep_assert_held(&trans->reg_lock); |
787 | 814 | ||
788 | /* this bit wakes up the NIC */ | 815 | /* this bit wakes up the NIC */ |
789 | __iwl_set_bit(trans, CSR_GP_CNTRL, | 816 | __iwl_trans_pcie_set_bit(trans, CSR_GP_CNTRL, |
790 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); | 817 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
791 | 818 | ||
792 | /* | 819 | /* |
793 | * These bits say the device is running, and should keep running for | 820 | * These bits say the device is running, and should keep running for |
@@ -829,8 +856,8 @@ static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans, bool silent) | |||
829 | static void iwl_trans_pcie_release_nic_access(struct iwl_trans *trans) | 856 | static void iwl_trans_pcie_release_nic_access(struct iwl_trans *trans) |
830 | { | 857 | { |
831 | lockdep_assert_held(&trans->reg_lock); | 858 | lockdep_assert_held(&trans->reg_lock); |
832 | __iwl_clear_bit(trans, CSR_GP_CNTRL, | 859 | __iwl_trans_pcie_clear_bit(trans, CSR_GP_CNTRL, |
833 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); | 860 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
834 | /* | 861 | /* |
835 | * Above we read the CSR_GP_CNTRL register, which will flush | 862 | * Above we read the CSR_GP_CNTRL register, which will flush |
836 | * any previous writes, but we need the write that clears the | 863 | * any previous writes, but we need the write that clears the |
@@ -952,6 +979,16 @@ static int iwl_trans_pcie_wait_txq_empty(struct iwl_trans *trans) | |||
952 | return ret; | 979 | return ret; |
953 | } | 980 | } |
954 | 981 | ||
982 | static void iwl_trans_pcie_set_bits_mask(struct iwl_trans *trans, u32 reg, | ||
983 | u32 mask, u32 value) | ||
984 | { | ||
985 | unsigned long flags; | ||
986 | |||
987 | spin_lock_irqsave(&trans->reg_lock, flags); | ||
988 | __iwl_trans_pcie_set_bits_mask(trans, reg, mask, value); | ||
989 | spin_unlock_irqrestore(&trans->reg_lock, flags); | ||
990 | } | ||
991 | |||
955 | static const char *get_fh_string(int cmd) | 992 | static const char *get_fh_string(int cmd) |
956 | { | 993 | { |
957 | #define IWL_CMD(x) case x: return #x | 994 | #define IWL_CMD(x) case x: return #x |
@@ -1405,7 +1442,8 @@ static const struct iwl_trans_ops trans_ops_pcie = { | |||
1405 | .configure = iwl_trans_pcie_configure, | 1442 | .configure = iwl_trans_pcie_configure, |
1406 | .set_pmi = iwl_trans_pcie_set_pmi, | 1443 | .set_pmi = iwl_trans_pcie_set_pmi, |
1407 | .grab_nic_access = iwl_trans_pcie_grab_nic_access, | 1444 | .grab_nic_access = iwl_trans_pcie_grab_nic_access, |
1408 | .release_nic_access = iwl_trans_pcie_release_nic_access | 1445 | .release_nic_access = iwl_trans_pcie_release_nic_access, |
1446 | .set_bits_mask = iwl_trans_pcie_set_bits_mask, | ||
1409 | }; | 1447 | }; |
1410 | 1448 | ||
1411 | struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, | 1449 | struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, |