diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2018-10-12 06:16:17 -0400 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2018-10-13 11:39:40 -0400 |
commit | 032c08f4c675b9a61888055703eca06118a92a3f (patch) | |
tree | 2ae6336f2d87f08182ab391b4def8ba6f7b54d8f /drivers/net/wireless | |
parent | 7859c543b65d4621d22dbfd7d884fc0d417a1722 (diff) |
mt76: move mt76x02_phy_set_bw in mt76x02-lib module
Move mt76x02_phy_set_bw routine in mt76x02_phy.c since
it is shared between mt76x0 and mt76x2 drivers and remove
duplicated code
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | 29 | ||||
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | 26 | ||||
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x02_phy.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x2/phy.c | 26 | ||||
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c | 2 |
7 files changed, 30 insertions, 57 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c index 7c30ba47c7f4..3bc6d7b0914a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/phy.c | |||
@@ -214,33 +214,6 @@ int mt76x0_wait_bbp_ready(struct mt76x02_dev *dev) | |||
214 | return 0; | 214 | return 0; |
215 | } | 215 | } |
216 | 216 | ||
217 | static void | ||
218 | mt76x0_bbp_set_ctrlch(struct mt76x02_dev *dev, enum nl80211_chan_width width, | ||
219 | u8 ctrl) | ||
220 | { | ||
221 | int core_val, agc_val; | ||
222 | |||
223 | switch (width) { | ||
224 | case NL80211_CHAN_WIDTH_80: | ||
225 | core_val = 3; | ||
226 | agc_val = 7; | ||
227 | break; | ||
228 | case NL80211_CHAN_WIDTH_40: | ||
229 | core_val = 2; | ||
230 | agc_val = 3; | ||
231 | break; | ||
232 | default: | ||
233 | core_val = 0; | ||
234 | agc_val = 1; | ||
235 | break; | ||
236 | } | ||
237 | |||
238 | mt76_rmw_field(dev, MT_BBP(CORE, 1), MT_BBP_CORE_R1_BW, core_val); | ||
239 | mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_BW, agc_val); | ||
240 | mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_CTRL_CHAN, ctrl); | ||
241 | mt76_rmw_field(dev, MT_BBP(TXBE, 0), MT_BBP_TXBE_R0_CTRL_CHAN, ctrl); | ||
242 | } | ||
243 | |||
244 | static void mt76x0_vco_cal(struct mt76x02_dev *dev, u8 channel) | 217 | static void mt76x0_vco_cal(struct mt76x02_dev *dev, u8 channel) |
245 | { | 218 | { |
246 | u8 val; | 219 | u8 val; |
@@ -681,7 +654,7 @@ int mt76x0_phy_set_channel(struct mt76x02_dev *dev, | |||
681 | } | 654 | } |
682 | 655 | ||
683 | mt76x0_bbp_set_bw(dev, chandef->width); | 656 | mt76x0_bbp_set_bw(dev, chandef->width); |
684 | mt76x0_bbp_set_ctrlch(dev, chandef->width, ch_group_index); | 657 | mt76x02_phy_set_bw(dev, chandef->width, ch_group_index); |
685 | mt76x0_mac_set_ctrlch(dev, ch_group_index & 1); | 658 | mt76x0_mac_set_ctrlch(dev, ch_group_index & 1); |
686 | mt76x0_ant_select(dev); | 659 | mt76x0_ant_select(dev); |
687 | 660 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c index c398471b6376..3de7170db111 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.c | |||
@@ -178,3 +178,29 @@ int mt76x02_phy_get_min_avg_rssi(struct mt76x02_dev *dev) | |||
178 | return min_rssi; | 178 | return min_rssi; |
179 | } | 179 | } |
180 | EXPORT_SYMBOL_GPL(mt76x02_phy_get_min_avg_rssi); | 180 | EXPORT_SYMBOL_GPL(mt76x02_phy_get_min_avg_rssi); |
181 | |||
182 | void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl) | ||
183 | { | ||
184 | int core_val, agc_val; | ||
185 | |||
186 | switch (width) { | ||
187 | case NL80211_CHAN_WIDTH_80: | ||
188 | core_val = 3; | ||
189 | agc_val = 7; | ||
190 | break; | ||
191 | case NL80211_CHAN_WIDTH_40: | ||
192 | core_val = 2; | ||
193 | agc_val = 3; | ||
194 | break; | ||
195 | default: | ||
196 | core_val = 0; | ||
197 | agc_val = 1; | ||
198 | break; | ||
199 | } | ||
200 | |||
201 | mt76_rmw_field(dev, MT_BBP(CORE, 1), MT_BBP_CORE_R1_BW, core_val); | ||
202 | mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_BW, agc_val); | ||
203 | mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_CTRL_CHAN, ctrl); | ||
204 | mt76_rmw_field(dev, MT_BBP(TXBE, 0), MT_BBP_TXBE_R0_CTRL_CHAN, ctrl); | ||
205 | } | ||
206 | EXPORT_SYMBOL_GPL(mt76x02_phy_set_bw); | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h index c370b4cc68ee..e0ca44ed5081 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_phy.h | |||
@@ -26,5 +26,6 @@ int mt76x02_get_max_rate_power(struct mt76_rate_power *r); | |||
26 | void mt76x02_phy_set_rxpath(struct mt76x02_dev *dev); | 26 | void mt76x02_phy_set_rxpath(struct mt76x02_dev *dev); |
27 | void mt76x02_phy_set_txdac(struct mt76x02_dev *dev); | 27 | void mt76x02_phy_set_txdac(struct mt76x02_dev *dev); |
28 | int mt76x02_phy_get_min_avg_rssi(struct mt76x02_dev *dev); | 28 | int mt76x02_phy_get_min_avg_rssi(struct mt76x02_dev *dev); |
29 | void mt76x02_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl); | ||
29 | 30 | ||
30 | #endif /* __MT76x02_PHY_H */ | 31 | #endif /* __MT76x02_PHY_H */ |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h index cbec8c6f1b2d..8b18acafedb2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/mt76x2.h | |||
@@ -100,7 +100,6 @@ void mt76x2_phy_set_txpower_regs(struct mt76x02_dev *dev, | |||
100 | enum nl80211_band band); | 100 | enum nl80211_band band); |
101 | void mt76x2_configure_tx_delay(struct mt76x02_dev *dev, | 101 | void mt76x2_configure_tx_delay(struct mt76x02_dev *dev, |
102 | enum nl80211_band band, u8 bw); | 102 | enum nl80211_band band, u8 bw); |
103 | void mt76x2_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl); | ||
104 | void mt76x2_phy_set_band(struct mt76x02_dev *dev, int band, bool primary_upper); | 103 | void mt76x2_phy_set_band(struct mt76x02_dev *dev, int band, bool primary_upper); |
105 | void mt76x2_apply_gain_adj(struct mt76x02_dev *dev); | 104 | void mt76x2_apply_gain_adj(struct mt76x02_dev *dev); |
106 | 105 | ||
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c index dbb63d4c3bad..991db4f48d94 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/pci_phy.c | |||
@@ -338,7 +338,7 @@ int mt76x2_phy_set_channel(struct mt76x02_dev *dev, | |||
338 | mt76x2_phy_set_txpower(dev); | 338 | mt76x2_phy_set_txpower(dev); |
339 | 339 | ||
340 | mt76x2_phy_set_band(dev, chan->band, ch_group_index & 1); | 340 | mt76x2_phy_set_band(dev, chan->band, ch_group_index & 1); |
341 | mt76x2_phy_set_bw(dev, chandef->width, ch_group_index); | 341 | mt76x02_phy_set_bw(dev, chandef->width, ch_group_index); |
342 | 342 | ||
343 | mt76_rmw(dev, MT_EXT_CCA_CFG, | 343 | mt76_rmw(dev, MT_EXT_CCA_CFG, |
344 | (MT_EXT_CCA_CFG_CCA0 | | 344 | (MT_EXT_CCA_CFG_CCA0 | |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c index fd077e8d8dcb..dcb3381cab91 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/phy.c | |||
@@ -210,32 +210,6 @@ void mt76x2_configure_tx_delay(struct mt76x02_dev *dev, | |||
210 | } | 210 | } |
211 | EXPORT_SYMBOL_GPL(mt76x2_configure_tx_delay); | 211 | EXPORT_SYMBOL_GPL(mt76x2_configure_tx_delay); |
212 | 212 | ||
213 | void mt76x2_phy_set_bw(struct mt76x02_dev *dev, int width, u8 ctrl) | ||
214 | { | ||
215 | int core_val, agc_val; | ||
216 | |||
217 | switch (width) { | ||
218 | case NL80211_CHAN_WIDTH_80: | ||
219 | core_val = 3; | ||
220 | agc_val = 7; | ||
221 | break; | ||
222 | case NL80211_CHAN_WIDTH_40: | ||
223 | core_val = 2; | ||
224 | agc_val = 3; | ||
225 | break; | ||
226 | default: | ||
227 | core_val = 0; | ||
228 | agc_val = 1; | ||
229 | break; | ||
230 | } | ||
231 | |||
232 | mt76_rmw_field(dev, MT_BBP(CORE, 1), MT_BBP_CORE_R1_BW, core_val); | ||
233 | mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_BW, agc_val); | ||
234 | mt76_rmw_field(dev, MT_BBP(AGC, 0), MT_BBP_AGC_R0_CTRL_CHAN, ctrl); | ||
235 | mt76_rmw_field(dev, MT_BBP(TXBE, 0), MT_BBP_TXBE_R0_CTRL_CHAN, ctrl); | ||
236 | } | ||
237 | EXPORT_SYMBOL_GPL(mt76x2_phy_set_bw); | ||
238 | |||
239 | void mt76x2_phy_set_band(struct mt76x02_dev *dev, int band, bool primary_upper) | 213 | void mt76x2_phy_set_band(struct mt76x02_dev *dev, int band, bool primary_upper) |
240 | { | 214 | { |
241 | switch (band) { | 215 | switch (band) { |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c index 422114de695a..ff2fd71a0c14 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/usb_phy.c | |||
@@ -156,7 +156,7 @@ int mt76x2u_phy_set_channel(struct mt76x02_dev *dev, | |||
156 | mt76x2_phy_set_txpower(dev); | 156 | mt76x2_phy_set_txpower(dev); |
157 | 157 | ||
158 | mt76x2_phy_set_band(dev, chan->band, ch_group_index & 1); | 158 | mt76x2_phy_set_band(dev, chan->band, ch_group_index & 1); |
159 | mt76x2_phy_set_bw(dev, chandef->width, ch_group_index); | 159 | mt76x02_phy_set_bw(dev, chandef->width, ch_group_index); |
160 | 160 | ||
161 | mt76_rmw(dev, MT_EXT_CCA_CFG, | 161 | mt76_rmw(dev, MT_EXT_CCA_CFG, |
162 | (MT_EXT_CCA_CFG_CCA0 | | 162 | (MT_EXT_CCA_CFG_CCA0 | |