diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/net/wireless/b43/phy_n.c | 87 |
1 files changed, 85 insertions, 2 deletions
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index d08feffdce68..e21526f2f24c 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c | |||
| @@ -1151,6 +1151,89 @@ static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev) | |||
| 1151 | } | 1151 | } |
| 1152 | } | 1152 | } |
| 1153 | 1153 | ||
| 1154 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetTxGain */ | ||
| 1155 | static struct nphy_txgains b43_nphy_get_tx_gains(struct b43_wldev *dev) | ||
| 1156 | { | ||
| 1157 | struct b43_phy_n *nphy = dev->phy.n; | ||
| 1158 | |||
| 1159 | u16 curr_gain[2]; | ||
| 1160 | struct nphy_txgains target; | ||
| 1161 | const u32 *table = NULL; | ||
| 1162 | |||
| 1163 | if (nphy->txpwrctrl == 0) { | ||
| 1164 | int i; | ||
| 1165 | |||
| 1166 | if (nphy->hang_avoid) | ||
| 1167 | b43_nphy_stay_in_carrier_search(dev, true); | ||
| 1168 | /* TODO: Read an N PHY Table with ID 7, length 2, | ||
| 1169 | offset 0x110, width 16, and curr_gain */ | ||
| 1170 | if (nphy->hang_avoid) | ||
| 1171 | b43_nphy_stay_in_carrier_search(dev, false); | ||
| 1172 | |||
| 1173 | for (i = 0; i < 2; ++i) { | ||
| 1174 | if (dev->phy.rev >= 3) { | ||
| 1175 | target.ipa[i] = curr_gain[i] & 0x000F; | ||
| 1176 | target.pad[i] = (curr_gain[i] & 0x00F0) >> 4; | ||
| 1177 | target.pga[i] = (curr_gain[i] & 0x0F00) >> 8; | ||
| 1178 | target.txgm[i] = (curr_gain[i] & 0x7000) >> 12; | ||
| 1179 | } else { | ||
| 1180 | target.ipa[i] = curr_gain[i] & 0x0003; | ||
| 1181 | target.pad[i] = (curr_gain[i] & 0x000C) >> 2; | ||
| 1182 | target.pga[i] = (curr_gain[i] & 0x0070) >> 4; | ||
| 1183 | target.txgm[i] = (curr_gain[i] & 0x0380) >> 7; | ||
| 1184 | } | ||
| 1185 | } | ||
| 1186 | } else { | ||
| 1187 | int i; | ||
| 1188 | u16 index[2]; | ||
| 1189 | index[0] = (b43_phy_read(dev, B43_NPHY_C1_TXPCTL_STAT) & | ||
| 1190 | B43_NPHY_TXPCTL_STAT_BIDX) >> | ||
| 1191 | B43_NPHY_TXPCTL_STAT_BIDX_SHIFT; | ||
| 1192 | index[1] = (b43_phy_read(dev, B43_NPHY_C2_TXPCTL_STAT) & | ||
| 1193 | B43_NPHY_TXPCTL_STAT_BIDX) >> | ||
| 1194 | B43_NPHY_TXPCTL_STAT_BIDX_SHIFT; | ||
| 1195 | |||
| 1196 | for (i = 0; i < 2; ++i) { | ||
| 1197 | if (dev->phy.rev >= 3) { | ||
| 1198 | enum ieee80211_band band = | ||
| 1199 | b43_current_band(dev->wl); | ||
| 1200 | |||
| 1201 | if ((nphy->ipa2g_on && | ||
| 1202 | band == IEEE80211_BAND_2GHZ) || | ||
| 1203 | (nphy->ipa5g_on && | ||
| 1204 | band == IEEE80211_BAND_5GHZ)) { | ||
| 1205 | table = b43_nphy_get_ipa_gain_table(dev); | ||
| 1206 | } else { | ||
| 1207 | if (band == IEEE80211_BAND_5GHZ) { | ||
| 1208 | if (dev->phy.rev == 3) | ||
| 1209 | table = b43_ntab_tx_gain_rev3_5ghz; | ||
| 1210 | else if (dev->phy.rev == 4) | ||
| 1211 | table = b43_ntab_tx_gain_rev4_5ghz; | ||
| 1212 | else | ||
| 1213 | table = b43_ntab_tx_gain_rev5plus_5ghz; | ||
| 1214 | } else { | ||
| 1215 | table = b43_ntab_tx_gain_rev3plus_2ghz; | ||
| 1216 | } | ||
| 1217 | } | ||
| 1218 | |||
| 1219 | target.ipa[i] = (table[index[i]] >> 16) & 0xF; | ||
| 1220 | target.pad[i] = (table[index[i]] >> 20) & 0xF; | ||
| 1221 | target.pga[i] = (table[index[i]] >> 24) & 0xF; | ||
| 1222 | target.txgm[i] = (table[index[i]] >> 28) & 0xF; | ||
| 1223 | } else { | ||
| 1224 | table = b43_ntab_tx_gain_rev0_1_2; | ||
| 1225 | |||
| 1226 | target.ipa[i] = (table[index[i]] >> 16) & 0x3; | ||
| 1227 | target.pad[i] = (table[index[i]] >> 18) & 0x3; | ||
| 1228 | target.pga[i] = (table[index[i]] >> 20) & 0x7; | ||
| 1229 | target.txgm[i] = (table[index[i]] >> 23) & 0x7; | ||
| 1230 | } | ||
| 1231 | } | ||
| 1232 | } | ||
| 1233 | |||
| 1234 | return target; | ||
| 1235 | } | ||
| 1236 | |||
| 1154 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreCal */ | 1237 | /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RestoreCal */ |
| 1155 | static void b43_nphy_restore_cal(struct b43_wldev *dev) | 1238 | static void b43_nphy_restore_cal(struct b43_wldev *dev) |
| 1156 | { | 1239 | { |
| @@ -1376,7 +1459,7 @@ int b43_phy_initn(struct b43_wldev *dev) | |||
| 1376 | do_cal = false; | 1459 | do_cal = false; |
| 1377 | 1460 | ||
| 1378 | if (do_cal) { | 1461 | if (do_cal) { |
| 1379 | /* target = b43_nphy_get_tx_gains(dev); */ | 1462 | target = b43_nphy_get_tx_gains(dev); |
| 1380 | 1463 | ||
| 1381 | if (nphy->antsel_type == 2) | 1464 | if (nphy->antsel_type == 2) |
| 1382 | ;/*TODO NPHY Superswitch Init with argument 1*/ | 1465 | ;/*TODO NPHY Superswitch Init with argument 1*/ |
| @@ -1388,7 +1471,7 @@ int b43_phy_initn(struct b43_wldev *dev) | |||
| 1388 | nphy->cal_orig_pwr_idx[1] = | 1471 | nphy->cal_orig_pwr_idx[1] = |
| 1389 | nphy->txpwrindex[1].index_internal; | 1472 | nphy->txpwrindex[1].index_internal; |
| 1390 | /* TODO N PHY Pre Calibrate TX Gain */ | 1473 | /* TODO N PHY Pre Calibrate TX Gain */ |
| 1391 | /*target = b43_nphy_get_tx_gains(dev)*/ | 1474 | target = b43_nphy_get_tx_gains(dev); |
| 1392 | } | 1475 | } |
| 1393 | } | 1476 | } |
| 1394 | } | 1477 | } |
