diff options
Diffstat (limited to 'drivers/net/wireless/b43/phy_lp.c')
-rw-r--r-- | drivers/net/wireless/b43/phy_lp.c | 129 |
1 files changed, 70 insertions, 59 deletions
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c index 2d3a5d812c42..1ab00b034cbd 100644 --- a/drivers/net/wireless/b43/phy_lp.c +++ b/drivers/net/wireless/b43/phy_lp.c | |||
@@ -182,8 +182,8 @@ static void lpphy_adjust_gain_table(struct b43_wldev *dev, u32 freq) | |||
182 | temp[1] = temp[0] + 0x1000; | 182 | temp[1] = temp[0] + 0x1000; |
183 | temp[2] = temp[0] + 0x2000; | 183 | temp[2] = temp[0] + 0x2000; |
184 | 184 | ||
185 | b43_lptab_write_bulk(dev, B43_LPTAB16(12, 0), 3, temp); | ||
186 | b43_lptab_write_bulk(dev, B43_LPTAB16(13, 0), 3, temp); | 185 | b43_lptab_write_bulk(dev, B43_LPTAB16(13, 0), 3, temp); |
186 | b43_lptab_write_bulk(dev, B43_LPTAB16(12, 0), 3, temp); | ||
187 | } | 187 | } |
188 | 188 | ||
189 | static void lpphy_table_init(struct b43_wldev *dev) | 189 | static void lpphy_table_init(struct b43_wldev *dev) |
@@ -223,8 +223,8 @@ static void lpphy_baseband_rev0_1_init(struct b43_wldev *dev) | |||
223 | b43_phy_maskset(dev, B43_LPPHY_VERYLOWGAINDB, 0xFF00, 0x0006); | 223 | b43_phy_maskset(dev, B43_LPPHY_VERYLOWGAINDB, 0xFF00, 0x0006); |
224 | b43_phy_mask(dev, B43_LPPHY_RX_RADIO_CTL, 0xFFFE); | 224 | b43_phy_mask(dev, B43_LPPHY_RX_RADIO_CTL, 0xFFFE); |
225 | b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xFFE0, 0x0005); | 225 | b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xFFE0, 0x0005); |
226 | b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xFC10, 0x0180); | 226 | b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0xFC1F, 0x0180); |
227 | b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0x83FF, 0x3800); | 227 | b43_phy_maskset(dev, B43_LPPHY_CLIPCTRTHRESH, 0x83FF, 0x3C00); |
228 | b43_phy_maskset(dev, B43_LPPHY_GAINDIRECTMISMATCH, 0xFFF0, 0x0005); | 228 | b43_phy_maskset(dev, B43_LPPHY_GAINDIRECTMISMATCH, 0xFFF0, 0x0005); |
229 | b43_phy_maskset(dev, B43_LPPHY_GAIN_MISMATCH_LIMIT, 0xFFC0, 0x001A); | 229 | b43_phy_maskset(dev, B43_LPPHY_GAIN_MISMATCH_LIMIT, 0xFFC0, 0x001A); |
230 | b43_phy_maskset(dev, B43_LPPHY_CRS_ED_THRESH, 0xFF00, 0x00B3); | 230 | b43_phy_maskset(dev, B43_LPPHY_CRS_ED_THRESH, 0xFF00, 0x00B3); |
@@ -234,19 +234,15 @@ static void lpphy_baseband_rev0_1_init(struct b43_wldev *dev) | |||
234 | if ((bus->sprom.boardflags_lo & B43_BFL_FEM) && | 234 | if ((bus->sprom.boardflags_lo & B43_BFL_FEM) && |
235 | ((b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) || | 235 | ((b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) || |
236 | (bus->sprom.boardflags_hi & B43_BFH_PAREF))) { | 236 | (bus->sprom.boardflags_hi & B43_BFH_PAREF))) { |
237 | /* TODO: | 237 | ssb_pmu_set_ldo_voltage(&bus->chipco, LDO_PAREF, 0x28); |
238 | * Set the LDO voltage to 0x0028 - FIXME: What is this? | 238 | ssb_pmu_set_ldo_paref(&bus->chipco, true); |
239 | * Call sb_pmu_set_ldo_voltage with 4 and the LDO voltage | ||
240 | * as arguments | ||
241 | * Call sb_pmu_paref_ldo_enable with argument TRUE | ||
242 | */ | ||
243 | if (dev->phy.rev == 0) { | 239 | if (dev->phy.rev == 0) { |
244 | b43_phy_maskset(dev, B43_LPPHY_LP_RF_SIGNAL_LUT, | 240 | b43_phy_maskset(dev, B43_LPPHY_LP_RF_SIGNAL_LUT, |
245 | 0xFFCF, 0x0010); | 241 | 0xFFCF, 0x0010); |
246 | } | 242 | } |
247 | b43_lptab_write(dev, B43_LPTAB16(11, 7), 60); | 243 | b43_lptab_write(dev, B43_LPTAB16(11, 7), 60); |
248 | } else { | 244 | } else { |
249 | //TODO: Call ssb_pmu_paref_ldo_enable with argument FALSE | 245 | ssb_pmu_set_ldo_paref(&bus->chipco, false); |
250 | b43_phy_maskset(dev, B43_LPPHY_LP_RF_SIGNAL_LUT, | 246 | b43_phy_maskset(dev, B43_LPPHY_LP_RF_SIGNAL_LUT, |
251 | 0xFFCF, 0x0020); | 247 | 0xFFCF, 0x0020); |
252 | b43_lptab_write(dev, B43_LPTAB16(11, 7), 100); | 248 | b43_lptab_write(dev, B43_LPTAB16(11, 7), 100); |
@@ -340,11 +336,11 @@ static void lpphy_baseband_rev0_1_init(struct b43_wldev *dev) | |||
340 | if (dev->phy.rev == 1) { | 336 | if (dev->phy.rev == 1) { |
341 | tmp = b43_phy_read(dev, B43_LPPHY_CLIPCTRTHRESH); | 337 | tmp = b43_phy_read(dev, B43_LPPHY_CLIPCTRTHRESH); |
342 | tmp2 = (tmp & 0x03E0) >> 5; | 338 | tmp2 = (tmp & 0x03E0) >> 5; |
343 | tmp2 |= tmp << 5; | 339 | tmp2 |= tmp2 << 5; |
344 | b43_phy_write(dev, B43_LPPHY_4C3, tmp2); | 340 | b43_phy_write(dev, B43_LPPHY_4C3, tmp2); |
345 | tmp = b43_phy_read(dev, B43_LPPHY_OFDMSYNCTHRESH0); | 341 | tmp = b43_phy_read(dev, B43_LPPHY_GAINDIRECTMISMATCH); |
346 | tmp2 = (tmp & 0x1F00) >> 8; | 342 | tmp2 = (tmp & 0x1F00) >> 8; |
347 | tmp2 |= tmp << 5; | 343 | tmp2 |= tmp2 << 5; |
348 | b43_phy_write(dev, B43_LPPHY_4C4, tmp2); | 344 | b43_phy_write(dev, B43_LPPHY_4C4, tmp2); |
349 | tmp = b43_phy_read(dev, B43_LPPHY_VERYLOWGAINDB); | 345 | tmp = b43_phy_read(dev, B43_LPPHY_VERYLOWGAINDB); |
350 | tmp2 = tmp & 0x00FF; | 346 | tmp2 = tmp & 0x00FF; |
@@ -705,7 +701,7 @@ static void lpphy_set_rc_cap(struct b43_wldev *dev) | |||
705 | u8 rc_cap = (lpphy->rc_cap & 0x1F) >> 1; | 701 | u8 rc_cap = (lpphy->rc_cap & 0x1F) >> 1; |
706 | 702 | ||
707 | if (dev->phy.rev == 1) //FIXME check channel 14! | 703 | if (dev->phy.rev == 1) //FIXME check channel 14! |
708 | rc_cap = max_t(u8, rc_cap + 5, 15); | 704 | rc_cap = min_t(u8, rc_cap + 5, 15); |
709 | 705 | ||
710 | b43_radio_write(dev, B2062_N_RXBB_CALIB2, | 706 | b43_radio_write(dev, B2062_N_RXBB_CALIB2, |
711 | max_t(u8, lpphy->rc_cap - 4, 0x80)); | 707 | max_t(u8, lpphy->rc_cap - 4, 0x80)); |
@@ -761,7 +757,7 @@ static void lpphy_disable_crs(struct b43_wldev *dev, bool user) | |||
761 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x3); | 757 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x3); |
762 | b43_phy_mask(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFFB); | 758 | b43_phy_mask(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFFB); |
763 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x4); | 759 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x4); |
764 | b43_phy_mask(dev, B43_LPPHY_RF_OVERRIDE_0, 0xFFF7); | 760 | b43_phy_mask(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFF7); |
765 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x8); | 761 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x8); |
766 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0x10); | 762 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0x10); |
767 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x10); | 763 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x10); |
@@ -956,7 +952,7 @@ static void lpphy_run_ddfs(struct b43_wldev *dev, int i_on, int q_on, | |||
956 | b43_phy_maskset(dev, B43_LPPHY_AFE_DDFS, 0xFF9F, scale_idx << 5); | 952 | b43_phy_maskset(dev, B43_LPPHY_AFE_DDFS, 0xFF9F, scale_idx << 5); |
957 | b43_phy_mask(dev, B43_LPPHY_AFE_DDFS, 0xFFFB); | 953 | b43_phy_mask(dev, B43_LPPHY_AFE_DDFS, 0xFFFB); |
958 | b43_phy_set(dev, B43_LPPHY_AFE_DDFS, 0x2); | 954 | b43_phy_set(dev, B43_LPPHY_AFE_DDFS, 0x2); |
959 | b43_phy_set(dev, B43_LPPHY_AFE_DDFS, 0x20); | 955 | b43_phy_set(dev, B43_LPPHY_LP_PHY_CTL, 0x20); |
960 | } | 956 | } |
961 | 957 | ||
962 | static bool lpphy_rx_iq_est(struct b43_wldev *dev, u16 samples, u8 time, | 958 | static bool lpphy_rx_iq_est(struct b43_wldev *dev, u16 samples, u8 time, |
@@ -968,7 +964,7 @@ static bool lpphy_rx_iq_est(struct b43_wldev *dev, u16 samples, u8 time, | |||
968 | b43_phy_write(dev, B43_LPPHY_IQ_NUM_SMPLS_ADDR, samples); | 964 | b43_phy_write(dev, B43_LPPHY_IQ_NUM_SMPLS_ADDR, samples); |
969 | b43_phy_maskset(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFF00, time); | 965 | b43_phy_maskset(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFF00, time); |
970 | b43_phy_mask(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFEFF); | 966 | b43_phy_mask(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFEFF); |
971 | b43_phy_set(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0xFDFF); | 967 | b43_phy_set(dev, B43_LPPHY_IQ_ENABLE_WAIT_TIME_ADDR, 0x200); |
972 | 968 | ||
973 | for (i = 0; i < 500; i++) { | 969 | for (i = 0; i < 500; i++) { |
974 | if (!(b43_phy_read(dev, | 970 | if (!(b43_phy_read(dev, |
@@ -1008,6 +1004,7 @@ static int lpphy_loopback(struct b43_wldev *dev) | |||
1008 | 1004 | ||
1009 | b43_phy_maskset(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFFC, 0x3); | 1005 | b43_phy_maskset(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0xFFFC, 0x3); |
1010 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x3); | 1006 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x3); |
1007 | b43_phy_set(dev, B43_LPPHY_AFE_CTL_OVR, 1); | ||
1011 | b43_phy_mask(dev, B43_LPPHY_AFE_CTL_OVRVAL, 0xFFFE); | 1008 | b43_phy_mask(dev, B43_LPPHY_AFE_CTL_OVRVAL, 0xFFFE); |
1012 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x800); | 1009 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_0, 0x800); |
1013 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0x800); | 1010 | b43_phy_set(dev, B43_LPPHY_RF_OVERRIDE_VAL_0, 0x800); |
@@ -1031,9 +1028,10 @@ static int lpphy_loopback(struct b43_wldev *dev) | |||
1031 | return index; | 1028 | return index; |
1032 | } | 1029 | } |
1033 | 1030 | ||
1031 | /* Fixed-point division algorithm using only integer math. */ | ||
1034 | static u32 lpphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision) | 1032 | static u32 lpphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision) |
1035 | { | 1033 | { |
1036 | u32 quotient, remainder, rbit, roundup, tmp; | 1034 | u32 quotient, remainder; |
1037 | 1035 | ||
1038 | if (divisor == 0) | 1036 | if (divisor == 0) |
1039 | return 0; | 1037 | return 0; |
@@ -1041,20 +1039,16 @@ static u32 lpphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision) | |||
1041 | quotient = dividend / divisor; | 1039 | quotient = dividend / divisor; |
1042 | remainder = dividend % divisor; | 1040 | remainder = dividend % divisor; |
1043 | 1041 | ||
1044 | rbit = divisor & 0x1; | 1042 | while (precision > 0) { |
1045 | roundup = (divisor >> 1) + rbit; | ||
1046 | |||
1047 | while (precision != 0) { | ||
1048 | tmp = remainder - roundup; | ||
1049 | quotient <<= 1; | 1043 | quotient <<= 1; |
1050 | if (remainder >= roundup) | 1044 | if (remainder << 1 >= divisor) { |
1051 | remainder = (tmp << 1) + rbit; | 1045 | quotient++; |
1052 | else | 1046 | remainder = (remainder << 1) - divisor; |
1053 | remainder <<= 1; | 1047 | } |
1054 | precision--; | 1048 | precision--; |
1055 | } | 1049 | } |
1056 | 1050 | ||
1057 | if (remainder >= roundup) | 1051 | if (remainder << 1 >= divisor) |
1058 | quotient++; | 1052 | quotient++; |
1059 | 1053 | ||
1060 | return quotient; | 1054 | return quotient; |
@@ -1137,9 +1131,9 @@ static void lpphy_set_tx_power_control(struct b43_wldev *dev, | |||
1137 | } | 1131 | } |
1138 | if (dev->phy.rev >= 2) { | 1132 | if (dev->phy.rev >= 2) { |
1139 | if (mode == B43_LPPHY_TXPCTL_HW) | 1133 | if (mode == B43_LPPHY_TXPCTL_HW) |
1140 | b43_phy_maskset(dev, B43_PHY_OFDM(0xD0), 0xFD, 0x2); | 1134 | b43_phy_set(dev, B43_PHY_OFDM(0xD0), 0x2); |
1141 | else | 1135 | else |
1142 | b43_phy_maskset(dev, B43_PHY_OFDM(0xD0), 0xFD, 0); | 1136 | b43_phy_mask(dev, B43_PHY_OFDM(0xD0), 0xFFFD); |
1143 | } | 1137 | } |
1144 | lpphy_write_tx_pctl_mode_to_hardware(dev); | 1138 | lpphy_write_tx_pctl_mode_to_hardware(dev); |
1145 | } | 1139 | } |
@@ -1171,7 +1165,7 @@ static void lpphy_rev0_1_rc_calib(struct b43_wldev *dev) | |||
1171 | err = b43_lpphy_op_switch_channel(dev, 7); | 1165 | err = b43_lpphy_op_switch_channel(dev, 7); |
1172 | if (err) { | 1166 | if (err) { |
1173 | b43dbg(dev->wl, | 1167 | b43dbg(dev->wl, |
1174 | "RC calib: Failed to switch to channel 7, error = %d", | 1168 | "RC calib: Failed to switch to channel 7, error = %d\n", |
1175 | err); | 1169 | err); |
1176 | } | 1170 | } |
1177 | old_txg_ovr = !!(b43_phy_read(dev, B43_LPPHY_AFE_CTL_OVR) & 0x40); | 1171 | old_txg_ovr = !!(b43_phy_read(dev, B43_LPPHY_AFE_CTL_OVR) & 0x40); |
@@ -1213,7 +1207,7 @@ static void lpphy_rev0_1_rc_calib(struct b43_wldev *dev) | |||
1213 | mean_sq_pwr = ideal_pwr - normal_pwr; | 1207 | mean_sq_pwr = ideal_pwr - normal_pwr; |
1214 | mean_sq_pwr *= mean_sq_pwr; | 1208 | mean_sq_pwr *= mean_sq_pwr; |
1215 | inner_sum += mean_sq_pwr; | 1209 | inner_sum += mean_sq_pwr; |
1216 | if ((i = 128) || (inner_sum < mean_sq_pwr_min)) { | 1210 | if ((i == 128) || (inner_sum < mean_sq_pwr_min)) { |
1217 | lpphy->rc_cap = i; | 1211 | lpphy->rc_cap = i; |
1218 | mean_sq_pwr_min = inner_sum; | 1212 | mean_sq_pwr_min = inner_sum; |
1219 | } | 1213 | } |
@@ -1506,6 +1500,14 @@ static void b43_lpphy_op_write(struct b43_wldev *dev, u16 reg, u16 value) | |||
1506 | b43_write16(dev, B43_MMIO_PHY_DATA, value); | 1500 | b43_write16(dev, B43_MMIO_PHY_DATA, value); |
1507 | } | 1501 | } |
1508 | 1502 | ||
1503 | static void b43_lpphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask, | ||
1504 | u16 set) | ||
1505 | { | ||
1506 | b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); | ||
1507 | b43_write16(dev, B43_MMIO_PHY_DATA, | ||
1508 | (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set); | ||
1509 | } | ||
1510 | |||
1509 | static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg) | 1511 | static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg) |
1510 | { | 1512 | { |
1511 | /* Register 1 is a 32-bit register. */ | 1513 | /* Register 1 is a 32-bit register. */ |
@@ -1922,8 +1924,8 @@ static void lpphy_b2062_reset_pll_bias(struct b43_wldev *dev) | |||
1922 | 1924 | ||
1923 | static void lpphy_b2062_vco_calib(struct b43_wldev *dev) | 1925 | static void lpphy_b2062_vco_calib(struct b43_wldev *dev) |
1924 | { | 1926 | { |
1925 | b43_phy_write(dev, B2062_S_RFPLL_CTL21, 0x42); | 1927 | b43_radio_write(dev, B2062_S_RFPLL_CTL21, 0x42); |
1926 | b43_phy_write(dev, B2062_S_RFPLL_CTL21, 0x62); | 1928 | b43_radio_write(dev, B2062_S_RFPLL_CTL21, 0x62); |
1927 | udelay(200); | 1929 | udelay(200); |
1928 | } | 1930 | } |
1929 | 1931 | ||
@@ -1982,7 +1984,7 @@ static int lpphy_b2062_tune(struct b43_wldev *dev, | |||
1982 | tmp6 = tmp5 / tmp4; | 1984 | tmp6 = tmp5 / tmp4; |
1983 | tmp7 = tmp5 % tmp4; | 1985 | tmp7 = tmp5 % tmp4; |
1984 | b43_radio_write(dev, B2062_S_RFPLL_CTL29, tmp6 + ((2 * tmp7) / tmp4)); | 1986 | b43_radio_write(dev, B2062_S_RFPLL_CTL29, tmp6 + ((2 * tmp7) / tmp4)); |
1985 | tmp8 = b43_phy_read(dev, B2062_S_RFPLL_CTL19); | 1987 | tmp8 = b43_radio_read(dev, B2062_S_RFPLL_CTL19); |
1986 | tmp9 = ((2 * tmp3 * (tmp8 + 1)) + (3 * tmp1)) / (6 * tmp1); | 1988 | tmp9 = ((2 * tmp3 * (tmp8 + 1)) + (3 * tmp1)) / (6 * tmp1); |
1987 | b43_radio_write(dev, B2062_S_RFPLL_CTL23, (tmp9 >> 8) + 16); | 1989 | b43_radio_write(dev, B2062_S_RFPLL_CTL23, (tmp9 >> 8) + 16); |
1988 | b43_radio_write(dev, B2062_S_RFPLL_CTL24, tmp9 & 0xFF); | 1990 | b43_radio_write(dev, B2062_S_RFPLL_CTL24, tmp9 & 0xFF); |
@@ -2021,17 +2023,17 @@ static void lpphy_b2063_vco_calib(struct b43_wldev *dev) | |||
2021 | { | 2023 | { |
2022 | u16 tmp; | 2024 | u16 tmp; |
2023 | 2025 | ||
2024 | b43_phy_mask(dev, B2063_PLL_SP1, ~0x40); | 2026 | b43_radio_mask(dev, B2063_PLL_SP1, ~0x40); |
2025 | tmp = b43_phy_read(dev, B2063_PLL_JTAG_CALNRST) & 0xF8; | 2027 | tmp = b43_radio_read(dev, B2063_PLL_JTAG_CALNRST) & 0xF8; |
2026 | b43_phy_write(dev, B2063_PLL_JTAG_CALNRST, tmp); | 2028 | b43_radio_write(dev, B2063_PLL_JTAG_CALNRST, tmp); |
2027 | udelay(1); | 2029 | udelay(1); |
2028 | b43_phy_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x4); | 2030 | b43_radio_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x4); |
2029 | udelay(1); | 2031 | udelay(1); |
2030 | b43_phy_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x6); | 2032 | b43_radio_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x6); |
2031 | udelay(1); | 2033 | udelay(1); |
2032 | b43_phy_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x7); | 2034 | b43_radio_write(dev, B2063_PLL_JTAG_CALNRST, tmp | 0x7); |
2033 | udelay(300); | 2035 | udelay(300); |
2034 | b43_phy_set(dev, B2063_PLL_SP1, 0x40); | 2036 | b43_radio_set(dev, B2063_PLL_SP1, 0x40); |
2035 | } | 2037 | } |
2036 | 2038 | ||
2037 | static int lpphy_b2063_tune(struct b43_wldev *dev, | 2039 | static int lpphy_b2063_tune(struct b43_wldev *dev, |
@@ -2126,31 +2128,31 @@ static int lpphy_b2063_tune(struct b43_wldev *dev, | |||
2126 | scale = 0; | 2128 | scale = 0; |
2127 | tmp5 = ((tmp4 + (tmp3 >> 1)) / tmp3) - 8; | 2129 | tmp5 = ((tmp4 + (tmp3 >> 1)) / tmp3) - 8; |
2128 | } | 2130 | } |
2129 | b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_CP2, 0xFFC0, tmp5); | 2131 | b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_CP2, 0xFFC0, tmp5); |
2130 | b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_CP2, 0xFFBF, scale << 6); | 2132 | b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_CP2, 0xFFBF, scale << 6); |
2131 | 2133 | ||
2132 | tmp6 = lpphy_qdiv_roundup(100 * val1, val3, 16); | 2134 | tmp6 = lpphy_qdiv_roundup(100 * val1, val3, 16); |
2133 | tmp6 *= (tmp5 * 8) * (scale + 1); | 2135 | tmp6 *= (tmp5 * 8) * (scale + 1); |
2134 | if (tmp6 > 150) | 2136 | if (tmp6 > 150) |
2135 | tmp6 = 0; | 2137 | tmp6 = 0; |
2136 | 2138 | ||
2137 | b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_CP3, 0xFFE0, tmp6); | 2139 | b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_CP3, 0xFFE0, tmp6); |
2138 | b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_CP3, 0xFFDF, scale << 5); | 2140 | b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_CP3, 0xFFDF, scale << 5); |
2139 | 2141 | ||
2140 | b43_phy_maskset(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0xFFFB, 0x4); | 2142 | b43_radio_maskset(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0xFFFB, 0x4); |
2141 | if (crystal_freq > 26000000) | 2143 | if (crystal_freq > 26000000) |
2142 | b43_phy_set(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0x2); | 2144 | b43_radio_set(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0x2); |
2143 | else | 2145 | else |
2144 | b43_phy_mask(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0xFD); | 2146 | b43_radio_mask(dev, B2063_PLL_JTAG_PLL_XTAL_12, 0xFD); |
2145 | 2147 | ||
2146 | if (val1 == 45) | 2148 | if (val1 == 45) |
2147 | b43_phy_set(dev, B2063_PLL_JTAG_PLL_VCO1, 0x2); | 2149 | b43_radio_set(dev, B2063_PLL_JTAG_PLL_VCO1, 0x2); |
2148 | else | 2150 | else |
2149 | b43_phy_mask(dev, B2063_PLL_JTAG_PLL_VCO1, 0xFD); | 2151 | b43_radio_mask(dev, B2063_PLL_JTAG_PLL_VCO1, 0xFD); |
2150 | 2152 | ||
2151 | b43_phy_set(dev, B2063_PLL_SP2, 0x3); | 2153 | b43_radio_set(dev, B2063_PLL_SP2, 0x3); |
2152 | udelay(1); | 2154 | udelay(1); |
2153 | b43_phy_mask(dev, B2063_PLL_SP2, 0xFFFC); | 2155 | b43_radio_mask(dev, B2063_PLL_SP2, 0xFFFC); |
2154 | lpphy_b2063_vco_calib(dev); | 2156 | lpphy_b2063_vco_calib(dev); |
2155 | b43_radio_write(dev, B2063_COMM15, old_comm15); | 2157 | b43_radio_write(dev, B2063_COMM15, old_comm15); |
2156 | 2158 | ||
@@ -2160,10 +2162,9 @@ static int lpphy_b2063_tune(struct b43_wldev *dev, | |||
2160 | static int b43_lpphy_op_switch_channel(struct b43_wldev *dev, | 2162 | static int b43_lpphy_op_switch_channel(struct b43_wldev *dev, |
2161 | unsigned int new_channel) | 2163 | unsigned int new_channel) |
2162 | { | 2164 | { |
2165 | struct b43_phy_lp *lpphy = dev->phy.lp; | ||
2163 | int err; | 2166 | int err; |
2164 | 2167 | ||
2165 | b43_write16(dev, B43_MMIO_CHANNEL, new_channel); | ||
2166 | |||
2167 | if (dev->phy.radio_ver == 0x2063) { | 2168 | if (dev->phy.radio_ver == 0x2063) { |
2168 | err = lpphy_b2063_tune(dev, new_channel); | 2169 | err = lpphy_b2063_tune(dev, new_channel); |
2169 | if (err) | 2170 | if (err) |
@@ -2176,6 +2177,9 @@ static int b43_lpphy_op_switch_channel(struct b43_wldev *dev, | |||
2176 | lpphy_adjust_gain_table(dev, channel2freq_lp(new_channel)); | 2177 | lpphy_adjust_gain_table(dev, channel2freq_lp(new_channel)); |
2177 | } | 2178 | } |
2178 | 2179 | ||
2180 | lpphy->channel = new_channel; | ||
2181 | b43_write16(dev, B43_MMIO_CHANNEL, new_channel); | ||
2182 | |||
2179 | return 0; | 2183 | return 0; |
2180 | } | 2184 | } |
2181 | 2185 | ||
@@ -2187,10 +2191,9 @@ static int b43_lpphy_op_init(struct b43_wldev *dev) | |||
2187 | lpphy_baseband_init(dev); | 2191 | lpphy_baseband_init(dev); |
2188 | lpphy_radio_init(dev); | 2192 | lpphy_radio_init(dev); |
2189 | lpphy_calibrate_rc(dev); | 2193 | lpphy_calibrate_rc(dev); |
2190 | err = b43_lpphy_op_switch_channel(dev, | 2194 | err = b43_lpphy_op_switch_channel(dev, 7); |
2191 | b43_lpphy_op_get_default_chan(dev)); | ||
2192 | if (err) { | 2195 | if (err) { |
2193 | b43dbg(dev->wl, "Switch to init channel failed, error = %d.\n", | 2196 | b43dbg(dev->wl, "Switch to channel 7 failed, error = %d.\n", |
2194 | err); | 2197 | err); |
2195 | } | 2198 | } |
2196 | lpphy_tx_pctl_init(dev); | 2199 | lpphy_tx_pctl_init(dev); |
@@ -2202,7 +2205,14 @@ static int b43_lpphy_op_init(struct b43_wldev *dev) | |||
2202 | 2205 | ||
2203 | static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) | 2206 | static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) |
2204 | { | 2207 | { |
2205 | //TODO | 2208 | if (dev->phy.rev >= 2) |
2209 | return; // rev2+ doesn't support antenna diversity | ||
2210 | |||
2211 | if (B43_WARN_ON(antenna > B43_ANTENNA_AUTO1)) | ||
2212 | return; | ||
2213 | |||
2214 | b43_phy_maskset(dev, B43_LPPHY_CRSGAIN_CTL, 0xFFFD, antenna & 0x2); | ||
2215 | b43_phy_maskset(dev, B43_LPPHY_CRSGAIN_CTL, 0xFFFE, antenna & 0x1); | ||
2206 | } | 2216 | } |
2207 | 2217 | ||
2208 | static void b43_lpphy_op_adjust_txpower(struct b43_wldev *dev) | 2218 | static void b43_lpphy_op_adjust_txpower(struct b43_wldev *dev) |
@@ -2224,6 +2234,7 @@ const struct b43_phy_operations b43_phyops_lp = { | |||
2224 | .init = b43_lpphy_op_init, | 2234 | .init = b43_lpphy_op_init, |
2225 | .phy_read = b43_lpphy_op_read, | 2235 | .phy_read = b43_lpphy_op_read, |
2226 | .phy_write = b43_lpphy_op_write, | 2236 | .phy_write = b43_lpphy_op_write, |
2237 | .phy_maskset = b43_lpphy_op_maskset, | ||
2227 | .radio_read = b43_lpphy_op_radio_read, | 2238 | .radio_read = b43_lpphy_op_radio_read, |
2228 | .radio_write = b43_lpphy_op_radio_write, | 2239 | .radio_write = b43_lpphy_op_radio_write, |
2229 | .software_rfkill = b43_lpphy_op_software_rfkill, | 2240 | .software_rfkill = b43_lpphy_op_software_rfkill, |