diff options
author | Michael Buesch <mb@bu3sch.de> | 2009-01-31 13:34:53 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-02-09 15:03:48 -0500 |
commit | 24b5bcc6aef46346edd69becf62d2125c0b3208e (patch) | |
tree | 28e7d0168fd3383c00f3e46c42609af7d243ad4a /drivers/net/wireless/b43/phy_lp.c | |
parent | 6c1bb9276c492c803611e63fa6fab8276c02ee70 (diff) |
b43: Add LP 2062 radio init
This adds initialization code for the 2062 radio.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43/phy_lp.c')
-rw-r--r-- | drivers/net/wireless/b43/phy_lp.c | 111 |
1 files changed, 108 insertions, 3 deletions
diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c index 3c7be8308587..99cc9739aced 100644 --- a/drivers/net/wireless/b43/phy_lp.c +++ b/drivers/net/wireless/b43/phy_lp.c | |||
@@ -91,7 +91,7 @@ static void lpphy_baseband_rev2plus_init(struct b43_wldev *dev) | |||
91 | b43_phy_set(dev, B43_PHY_OFDM(0x10A), 0x1); | 91 | b43_phy_set(dev, B43_PHY_OFDM(0x10A), 0x1); |
92 | b43_phy_maskset(dev, B43_LPPHY_CCKLMSSTEPSIZE, 0xFF01, 0x10); | 92 | b43_phy_maskset(dev, B43_LPPHY_CCKLMSSTEPSIZE, 0xFF01, 0x10); |
93 | b43_phy_maskset(dev, B43_PHY_OFDM(0xDF), 0xFF00, 0xF4); | 93 | b43_phy_maskset(dev, B43_PHY_OFDM(0xDF), 0xFF00, 0xF4); |
94 | b43_phy_maskset(dev, B43_PHY_OFDM(0xDF), 0x00FF, 0xF100);//FIXME specs are different | 94 | b43_phy_maskset(dev, B43_PHY_OFDM(0xDF), 0x00FF, 0xF100); |
95 | b43_phy_write(dev, B43_LPPHY_CLIPTHRESH, 0x48); | 95 | b43_phy_write(dev, B43_LPPHY_CLIPTHRESH, 0x48); |
96 | b43_phy_maskset(dev, B43_LPPHY_HIGAINDB, 0xFF00, 0x46); | 96 | b43_phy_maskset(dev, B43_LPPHY_HIGAINDB, 0xFF00, 0x46); |
97 | b43_phy_maskset(dev, B43_PHY_OFDM(0xE4), 0xFF00, 0x10); | 97 | b43_phy_maskset(dev, B43_PHY_OFDM(0xE4), 0xFF00, 0x10); |
@@ -155,11 +155,114 @@ static void lpphy_baseband_init(struct b43_wldev *dev) | |||
155 | lpphy_baseband_rev0_1_init(dev); | 155 | lpphy_baseband_rev0_1_init(dev); |
156 | } | 156 | } |
157 | 157 | ||
158 | static void lpphy_radio_init(struct b43_wldev *dev) | 158 | struct b2062_freqdata { |
159 | u16 freq; | ||
160 | u8 data[6]; | ||
161 | }; | ||
162 | |||
163 | /* Initialize the 2062 radio. */ | ||
164 | static void lpphy_2062_init(struct b43_wldev *dev) | ||
165 | { | ||
166 | u32 crystalfreq, pdiv, tmp, ref; | ||
167 | unsigned int i; | ||
168 | const struct b2062_freqdata *fd = NULL; | ||
169 | |||
170 | static const struct b2062_freqdata freqdata_tab[] = { | ||
171 | { .freq = 12000, .data[0] = 6, .data[1] = 6, .data[2] = 6, | ||
172 | .data[3] = 6, .data[4] = 10, .data[5] = 6, }, | ||
173 | { .freq = 13000, .data[0] = 4, .data[1] = 4, .data[2] = 4, | ||
174 | .data[3] = 4, .data[4] = 11, .data[5] = 7, }, | ||
175 | { .freq = 14400, .data[0] = 3, .data[1] = 3, .data[2] = 3, | ||
176 | .data[3] = 3, .data[4] = 12, .data[5] = 7, }, | ||
177 | { .freq = 16200, .data[0] = 3, .data[1] = 3, .data[2] = 3, | ||
178 | .data[3] = 3, .data[4] = 13, .data[5] = 8, }, | ||
179 | { .freq = 18000, .data[0] = 2, .data[1] = 2, .data[2] = 2, | ||
180 | .data[3] = 2, .data[4] = 14, .data[5] = 8, }, | ||
181 | { .freq = 19200, .data[0] = 1, .data[1] = 1, .data[2] = 1, | ||
182 | .data[3] = 1, .data[4] = 14, .data[5] = 9, }, | ||
183 | }; | ||
184 | |||
185 | b2062_upload_init_table(dev); | ||
186 | |||
187 | b43_radio_write(dev, B2062_N_TX_CTL3, 0); | ||
188 | b43_radio_write(dev, B2062_N_TX_CTL4, 0); | ||
189 | b43_radio_write(dev, B2062_N_TX_CTL5, 0); | ||
190 | b43_radio_write(dev, B2062_N_PDN_CTL0, 0x40); | ||
191 | b43_radio_write(dev, B2062_N_PDN_CTL0, 0); | ||
192 | b43_radio_write(dev, B2062_N_CALIB_TS, 0x10); | ||
193 | b43_radio_write(dev, B2062_N_CALIB_TS, 0); | ||
194 | if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) | ||
195 | b43_radio_set(dev, B2062_N_TSSI_CTL0, 0x1); | ||
196 | else | ||
197 | b43_radio_mask(dev, B2062_N_TSSI_CTL0, ~0x1); | ||
198 | |||
199 | crystalfreq = 0;//FIXME | ||
200 | |||
201 | if (crystalfreq >= 30000000) { | ||
202 | pdiv = 1; | ||
203 | b43_radio_mask(dev, B2062_S_RFPLL_CTL1, 0xFFFB); | ||
204 | } else { | ||
205 | pdiv = 2; | ||
206 | b43_radio_set(dev, B2062_S_RFPLL_CTL1, 0x4); | ||
207 | } | ||
208 | |||
209 | tmp = (800000000 * pdiv + crystalfreq) / (32000000 * pdiv); | ||
210 | tmp = (tmp - 1) & 0xFF; | ||
211 | b43_radio_write(dev, B2062_S_RFPLL_CTL18, tmp); | ||
212 | |||
213 | tmp = (2 * crystalfreq + 1000000 * pdiv) / (2000000 * pdiv); | ||
214 | tmp = ((tmp & 0xFF) - 1) & 0xFFFF; | ||
215 | b43_radio_write(dev, B2062_S_RFPLL_CTL19, tmp); | ||
216 | |||
217 | ref = (1000 * pdiv + 2 * crystalfreq) / (2000 * pdiv); | ||
218 | ref &= 0xFFFF; | ||
219 | for (i = 0; i < ARRAY_SIZE(freqdata_tab); i++) { | ||
220 | if (ref < freqdata_tab[i].freq) { | ||
221 | fd = &freqdata_tab[i]; | ||
222 | break; | ||
223 | } | ||
224 | } | ||
225 | if (B43_WARN_ON(!fd)) | ||
226 | return; | ||
227 | |||
228 | b43_radio_write(dev, B2062_S_RFPLL_CTL8, | ||
229 | ((u16)(fd->data[1]) << 4) | fd->data[0]); | ||
230 | b43_radio_write(dev, B2062_S_RFPLL_CTL9, | ||
231 | ((u16)(fd->data[3]) << 4) | fd->data[2]);//FIXME specs are different | ||
232 | b43_radio_write(dev, B2062_S_RFPLL_CTL10, fd->data[4]); | ||
233 | b43_radio_write(dev, B2062_S_RFPLL_CTL11, fd->data[5]); | ||
234 | } | ||
235 | |||
236 | /* Initialize the 2063 radio. */ | ||
237 | static void lpphy_2063_init(struct b43_wldev *dev) | ||
159 | { | 238 | { |
160 | //TODO | 239 | //TODO |
161 | } | 240 | } |
162 | 241 | ||
242 | static void lpphy_sync_stx(struct b43_wldev *dev) | ||
243 | { | ||
244 | //TODO | ||
245 | } | ||
246 | |||
247 | static void lpphy_radio_init(struct b43_wldev *dev) | ||
248 | { | ||
249 | /* The radio is attached through the 4wire bus. */ | ||
250 | b43_phy_set(dev, B43_LPPHY_FOURWIRE_CTL, 0x2); | ||
251 | udelay(1); | ||
252 | b43_phy_mask(dev, B43_LPPHY_FOURWIRE_CTL, 0xFFFD); | ||
253 | udelay(1); | ||
254 | |||
255 | if (dev->phy.rev < 2) { | ||
256 | lpphy_2062_init(dev); | ||
257 | } else { | ||
258 | lpphy_2063_init(dev); | ||
259 | lpphy_sync_stx(dev); | ||
260 | b43_phy_write(dev, B43_PHY_OFDM(0xF0), 0x5F80); | ||
261 | b43_phy_write(dev, B43_PHY_OFDM(0xF1), 0); | ||
262 | //TODO Do something on the backplane | ||
263 | } | ||
264 | } | ||
265 | |||
163 | static int b43_lpphy_op_init(struct b43_wldev *dev) | 266 | static int b43_lpphy_op_init(struct b43_wldev *dev) |
164 | { | 267 | { |
165 | /* TODO: band SPROM */ | 268 | /* TODO: band SPROM */ |
@@ -222,7 +325,9 @@ static int b43_lpphy_op_switch_channel(struct b43_wldev *dev, | |||
222 | 325 | ||
223 | static unsigned int b43_lpphy_op_get_default_chan(struct b43_wldev *dev) | 326 | static unsigned int b43_lpphy_op_get_default_chan(struct b43_wldev *dev) |
224 | { | 327 | { |
225 | return 1; /* Default to channel 1 */ | 328 | if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) |
329 | return 1; | ||
330 | return 36; | ||
226 | } | 331 | } |
227 | 332 | ||
228 | static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) | 333 | static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) |