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 /drivers/net/wireless/iwlwifi/pcie | |
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>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/pcie')
-rw-r--r-- | drivers/net/wireless/iwlwifi/pcie/trans.c | 48 |
1 files changed, 43 insertions, 5 deletions
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, |