aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2500usb.c
diff options
context:
space:
mode:
authorIvo van Doorn <IvDoorn@gmail.com>2007-10-06 07:34:52 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:55:15 -0400
commit5c58ee51ff8c0aca74c225e0263bc5dd2b917781 (patch)
treea08e875dade8a6f55d45419b728b2b077cec6dc0 /drivers/net/wireless/rt2x00/rt2500usb.c
parent4f5af6eb3d17f8e343597ea99d97eb2f2905b2fb (diff)
[PATCH] rt2x00: Reorganize configuration handler
Reorganize configuration handling by creating a extra structure which contains precalculated values based on the mac80211 values which are usefull for all individual drivers. This also fixes the preamble configuration problem, up untill now preamble was never configured since by default the rate->val value was used when changing the mode. Now rate->val will only be used to set the basic rate mask. The preamble configuration will now be done correctly through the erp_ie_changed callback function. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2500usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c112
1 files changed, 45 insertions, 67 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index ef8dffbdffed..45f8f744a12d 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -302,54 +302,39 @@ static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type,
302 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg); 302 rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
303} 303}
304 304
305static void rt2500usb_config_rate(struct rt2x00_dev *rt2x00dev, const int rate) 305static void rt2500usb_config_preamble(struct rt2x00_dev *rt2x00dev,
306 const int short_preamble,
307 const int ack_timeout,
308 const int ack_consume_time)
306{ 309{
307 struct ieee80211_conf *conf = &rt2x00dev->hw->conf;
308 u16 reg; 310 u16 reg;
309 u16 value;
310 u16 preamble;
311
312 if (DEVICE_GET_RATE_FIELD(rate, PREAMBLE))
313 preamble = SHORT_PREAMBLE;
314 else
315 preamble = PREAMBLE;
316 311
317 reg = DEVICE_GET_RATE_FIELD(rate, RATEMASK) & DEV_BASIC_RATEMASK; 312 /*
318 313 * When in atomic context, reschedule and let rt2x00lib
319 rt2500usb_register_write(rt2x00dev, TXRX_CSR11, reg); 314 * call this function again.
315 */
316 if (in_atomic()) {
317 queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->config_work);
318 return;
319 }
320 320
321 rt2500usb_register_read(rt2x00dev, TXRX_CSR1, &reg); 321 rt2500usb_register_read(rt2x00dev, TXRX_CSR1, &reg);
322 value = ((conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) ? 322 rt2x00_set_field16(&reg, TXRX_CSR1_ACK_TIMEOUT, ack_timeout);
323 SHORT_DIFS : DIFS) +
324 PLCP + preamble + get_duration(ACK_SIZE, 10);
325 rt2x00_set_field16(&reg, TXRX_CSR1_ACK_TIMEOUT, value);
326 rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg); 323 rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg);
327 324
328 rt2500usb_register_read(rt2x00dev, TXRX_CSR10, &reg); 325 rt2500usb_register_read(rt2x00dev, TXRX_CSR10, &reg);
329 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE, 326 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE,
330 (preamble == SHORT_PREAMBLE)); 327 !!short_preamble);
331 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg); 328 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg);
332} 329}
333 330
334static void rt2500usb_config_phymode(struct rt2x00_dev *rt2x00dev, 331static void rt2500usb_config_phymode(struct rt2x00_dev *rt2x00dev,
335 const int phymode) 332 const int phymode,
333 const int basic_rate_mask)
336{ 334{
337 struct ieee80211_hw_mode *mode; 335 rt2500usb_register_write(rt2x00dev, TXRX_CSR11, basic_rate_mask);
338 struct ieee80211_rate *rate;
339 336
340 if (phymode == MODE_IEEE80211A) 337 if (phymode == HWMODE_B) {
341 rt2x00dev->curr_hwmode = HWMODE_A;
342 else if (phymode == MODE_IEEE80211B)
343 rt2x00dev->curr_hwmode = HWMODE_B;
344 else
345 rt2x00dev->curr_hwmode = HWMODE_G;
346
347 mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode];
348 rate = &mode->rates[mode->num_rates - 1];
349
350 rt2500usb_config_rate(rt2x00dev, rate->val2);
351
352 if (phymode == MODE_IEEE80211B) {
353 rt2500usb_register_write(rt2x00dev, MAC_CSR11, 0x000b); 338 rt2500usb_register_write(rt2x00dev, MAC_CSR11, 0x000b);
354 rt2500usb_register_write(rt2x00dev, MAC_CSR12, 0x0040); 339 rt2500usb_register_write(rt2x00dev, MAC_CSR12, 0x0040);
355 } else { 340 } else {
@@ -359,20 +344,12 @@ static void rt2500usb_config_phymode(struct rt2x00_dev *rt2x00dev,
359} 344}
360 345
361static void rt2500usb_config_channel(struct rt2x00_dev *rt2x00dev, 346static void rt2500usb_config_channel(struct rt2x00_dev *rt2x00dev,
362 const int index, const int channel, 347 struct rf_channel *rf, const int txpower)
363 const int txpower)
364{ 348{
365 struct rf_channel reg;
366
367 /*
368 * Fill rf_reg structure.
369 */
370 memcpy(&reg, &rt2x00dev->spec.channels[index], sizeof(reg));
371
372 /* 349 /*
373 * Set TXpower. 350 * Set TXpower.
374 */ 351 */
375 rt2x00_set_field32(&reg.rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower)); 352 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
376 353
377 /* 354 /*
378 * For RT2525E we should first set the channel to half band higher. 355 * For RT2525E we should first set the channel to half band higher.
@@ -385,16 +362,16 @@ static void rt2500usb_config_channel(struct rt2x00_dev *rt2x00dev,
385 0x00000902, 0x00000906 362 0x00000902, 0x00000906
386 }; 363 };
387 364
388 rt2500usb_rf_write(rt2x00dev, 2, vals[channel - 1]); 365 rt2500usb_rf_write(rt2x00dev, 2, vals[rf->channel - 1]);
389 if (reg.rf4) 366 if (rf->rf4)
390 rt2500usb_rf_write(rt2x00dev, 4, reg.rf4); 367 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
391 } 368 }
392 369
393 rt2500usb_rf_write(rt2x00dev, 1, reg.rf1); 370 rt2500usb_rf_write(rt2x00dev, 1, rf->rf1);
394 rt2500usb_rf_write(rt2x00dev, 2, reg.rf2); 371 rt2500usb_rf_write(rt2x00dev, 2, rf->rf2);
395 rt2500usb_rf_write(rt2x00dev, 3, reg.rf3); 372 rt2500usb_rf_write(rt2x00dev, 3, rf->rf3);
396 if (reg.rf4) 373 if (rf->rf4)
397 rt2500usb_rf_write(rt2x00dev, 4, reg.rf4); 374 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
398} 375}
399 376
400static void rt2500usb_config_txpower(struct rt2x00_dev *rt2x00dev, 377static void rt2500usb_config_txpower(struct rt2x00_dev *rt2x00dev,
@@ -484,38 +461,37 @@ static void rt2500usb_config_antenna(struct rt2x00_dev *rt2x00dev,
484} 461}
485 462
486static void rt2500usb_config_duration(struct rt2x00_dev *rt2x00dev, 463static void rt2500usb_config_duration(struct rt2x00_dev *rt2x00dev,
487 const int short_slot_time, 464 struct rt2x00lib_conf *libconf)
488 const int beacon_int)
489{ 465{
490 u16 reg; 466 u16 reg;
491 467
492 rt2500usb_register_write(rt2x00dev, MAC_CSR10, 468 rt2500usb_register_write(rt2x00dev, MAC_CSR10, libconf->slot_time);
493 short_slot_time ? SHORT_SLOT_TIME : SLOT_TIME);
494 469
495 rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg); 470 rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg);
496 rt2x00_set_field16(&reg, TXRX_CSR18_INTERVAL, beacon_int * 4); 471 rt2x00_set_field16(&reg, TXRX_CSR18_INTERVAL,
472 libconf->conf->beacon_int * 4);
497 rt2500usb_register_write(rt2x00dev, TXRX_CSR18, reg); 473 rt2500usb_register_write(rt2x00dev, TXRX_CSR18, reg);
498} 474}
499 475
500static void rt2500usb_config(struct rt2x00_dev *rt2x00dev, 476static void rt2500usb_config(struct rt2x00_dev *rt2x00dev,
501 const unsigned int flags, 477 const unsigned int flags,
502 struct ieee80211_conf *conf) 478 struct rt2x00lib_conf *libconf)
503{ 479{
504 int short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME;
505
506 if (flags & CONFIG_UPDATE_PHYMODE) 480 if (flags & CONFIG_UPDATE_PHYMODE)
507 rt2500usb_config_phymode(rt2x00dev, conf->phymode); 481 rt2500usb_config_phymode(rt2x00dev, libconf->phymode,
482 libconf->basic_rates);
508 if (flags & CONFIG_UPDATE_CHANNEL) 483 if (flags & CONFIG_UPDATE_CHANNEL)
509 rt2500usb_config_channel(rt2x00dev, conf->channel_val, 484 rt2500usb_config_channel(rt2x00dev, &libconf->rf,
510 conf->channel, conf->power_level); 485 libconf->conf->power_level);
511 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) 486 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL))
512 rt2500usb_config_txpower(rt2x00dev, conf->power_level); 487 rt2500usb_config_txpower(rt2x00dev,
488 libconf->conf->power_level);
513 if (flags & CONFIG_UPDATE_ANTENNA) 489 if (flags & CONFIG_UPDATE_ANTENNA)
514 rt2500usb_config_antenna(rt2x00dev, conf->antenna_sel_tx, 490 rt2500usb_config_antenna(rt2x00dev,
515 conf->antenna_sel_rx); 491 libconf->conf->antenna_sel_tx,
492 libconf->conf->antenna_sel_rx);
516 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 493 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
517 rt2500usb_config_duration(rt2x00dev, short_slot_time, 494 rt2500usb_config_duration(rt2x00dev, libconf);
518 conf->beacon_int);
519} 495}
520 496
521/* 497/*
@@ -1733,6 +1709,7 @@ static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1733 .config_interface = rt2x00mac_config_interface, 1709 .config_interface = rt2x00mac_config_interface,
1734 .configure_filter = rt2500usb_configure_filter, 1710 .configure_filter = rt2500usb_configure_filter,
1735 .get_stats = rt2x00mac_get_stats, 1711 .get_stats = rt2x00mac_get_stats,
1712 .erp_ie_changed = rt2x00mac_erp_ie_changed,
1736 .conf_tx = rt2x00mac_conf_tx, 1713 .conf_tx = rt2x00mac_conf_tx,
1737 .get_tx_stats = rt2x00mac_get_tx_stats, 1714 .get_tx_stats = rt2x00mac_get_tx_stats,
1738 .beacon_update = rt2500usb_beacon_update, 1715 .beacon_update = rt2500usb_beacon_update,
@@ -1754,6 +1731,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1754 .config_mac_addr = rt2500usb_config_mac_addr, 1731 .config_mac_addr = rt2500usb_config_mac_addr,
1755 .config_bssid = rt2500usb_config_bssid, 1732 .config_bssid = rt2500usb_config_bssid,
1756 .config_type = rt2500usb_config_type, 1733 .config_type = rt2500usb_config_type,
1734 .config_preamble = rt2500usb_config_preamble,
1757 .config = rt2500usb_config, 1735 .config = rt2500usb_config,
1758}; 1736};
1759 1737