diff options
author | Mattias Nissler <mattias.nissler@gmx.de> | 2007-10-27 07:42:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:03:01 -0500 |
commit | 2676c94d4e5994f92e57fa3ea680f1d652049d03 (patch) | |
tree | 877a40fa5f64ed3e6faec9c45642d0dc23ca6225 /drivers/net/wireless/rt2x00/rt73usb.c | |
parent | 50794638dc8bcd94b48b10b8bf4381f1049f93cf (diff) |
rt2x00: Rework rt73 antenna selection
This patch changes rt73 antenna selection to what I believe is the correct way.
It also fixes a small selection bug that switched the antennas by accident.
Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt73usb.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt73usb.c | 78 |
1 files changed, 25 insertions, 53 deletions
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index 6b6649624470..0cc815000d62 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -399,6 +399,7 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev, | |||
399 | u8 r3; | 399 | u8 r3; |
400 | u8 r4; | 400 | u8 r4; |
401 | u8 r77; | 401 | u8 r77; |
402 | u8 temp; | ||
402 | 403 | ||
403 | rt73usb_bbp_read(rt2x00dev, 3, &r3); | 404 | rt73usb_bbp_read(rt2x00dev, 3, &r3); |
404 | rt73usb_bbp_read(rt2x00dev, 4, &r4); | 405 | rt73usb_bbp_read(rt2x00dev, 4, &r4); |
@@ -407,37 +408,22 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev, | |||
407 | rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, 0); | 408 | rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, 0); |
408 | 409 | ||
409 | /* | 410 | /* |
410 | * Configure the TX antenna. | ||
411 | */ | ||
412 | switch (ant->tx) { | ||
413 | case ANTENNA_A: | ||
414 | rt2x00_set_field8(&r77, BBP_R77_TX_ANTENNA, 0); | ||
415 | break; | ||
416 | case ANTENNA_SW_DIVERSITY: | ||
417 | case ANTENNA_HW_DIVERSITY: | ||
418 | /* | ||
419 | * NOTE: We should never come here because rt2x00lib is | ||
420 | * supposed to catch this and send us the correct antenna | ||
421 | * explicitely. However we are nog going to bug about this. | ||
422 | * Instead, just default to antenna B. | ||
423 | */ | ||
424 | case ANTENNA_B: | ||
425 | rt2x00_set_field8(&r77, BBP_R77_TX_ANTENNA, 3); | ||
426 | break; | ||
427 | } | ||
428 | |||
429 | /* | ||
430 | * Configure the RX antenna. | 411 | * Configure the RX antenna. |
431 | */ | 412 | */ |
432 | switch (ant->rx) { | 413 | switch (ant->rx) { |
433 | case ANTENNA_HW_DIVERSITY: | 414 | case ANTENNA_HW_DIVERSITY: |
434 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2); | 415 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); |
435 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, | 416 | temp = !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags) |
436 | (rt2x00dev->curr_hwmode != HWMODE_A)); | 417 | && (rt2x00dev->curr_hwmode != HWMODE_A); |
418 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, temp); | ||
437 | break; | 419 | break; |
438 | case ANTENNA_A: | 420 | case ANTENNA_A: |
439 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1); | 421 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); |
440 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); | 422 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); |
423 | if (rt2x00dev->curr_hwmode == HWMODE_A) | ||
424 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); | ||
425 | else | ||
426 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); | ||
441 | break; | 427 | break; |
442 | case ANTENNA_SW_DIVERSITY: | 428 | case ANTENNA_SW_DIVERSITY: |
443 | /* | 429 | /* |
@@ -447,8 +433,12 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev, | |||
447 | * Instead, just default to antenna B. | 433 | * Instead, just default to antenna B. |
448 | */ | 434 | */ |
449 | case ANTENNA_B: | 435 | case ANTENNA_B: |
450 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1); | 436 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); |
451 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); | 437 | rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); |
438 | if (rt2x00dev->curr_hwmode == HWMODE_A) | ||
439 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); | ||
440 | else | ||
441 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); | ||
452 | break; | 442 | break; |
453 | } | 443 | } |
454 | 444 | ||
@@ -473,34 +463,15 @@ static void rt73usb_config_antenna_2x(struct rt2x00_dev *rt2x00dev, | |||
473 | !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags)); | 463 | !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags)); |
474 | 464 | ||
475 | /* | 465 | /* |
476 | * Configure the TX antenna. | ||
477 | */ | ||
478 | switch (ant->tx) { | ||
479 | case ANTENNA_A: | ||
480 | rt2x00_set_field8(&r77, BBP_R77_TX_ANTENNA, 0); | ||
481 | break; | ||
482 | case ANTENNA_SW_DIVERSITY: | ||
483 | case ANTENNA_HW_DIVERSITY: | ||
484 | /* | ||
485 | * NOTE: We should never come here because rt2x00lib is | ||
486 | * supposed to catch this and send us the correct antenna | ||
487 | * explicitely. However we are nog going to bug about this. | ||
488 | * Instead, just default to antenna B. | ||
489 | */ | ||
490 | case ANTENNA_B: | ||
491 | rt2x00_set_field8(&r77, BBP_R77_TX_ANTENNA, 3); | ||
492 | break; | ||
493 | } | ||
494 | |||
495 | /* | ||
496 | * Configure the RX antenna. | 466 | * Configure the RX antenna. |
497 | */ | 467 | */ |
498 | switch (ant->rx) { | 468 | switch (ant->rx) { |
499 | case ANTENNA_HW_DIVERSITY: | 469 | case ANTENNA_HW_DIVERSITY: |
500 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2); | 470 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); |
501 | break; | 471 | break; |
502 | case ANTENNA_A: | 472 | case ANTENNA_A: |
503 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1); | 473 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); |
474 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); | ||
504 | break; | 475 | break; |
505 | case ANTENNA_SW_DIVERSITY: | 476 | case ANTENNA_SW_DIVERSITY: |
506 | /* | 477 | /* |
@@ -510,7 +481,8 @@ static void rt73usb_config_antenna_2x(struct rt2x00_dev *rt2x00dev, | |||
510 | * Instead, just default to antenna B. | 481 | * Instead, just default to antenna B. |
511 | */ | 482 | */ |
512 | case ANTENNA_B: | 483 | case ANTENNA_B: |
513 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1); | 484 | rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); |
485 | rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); | ||
514 | break; | 486 | break; |
515 | } | 487 | } |
516 | 488 | ||
@@ -558,8 +530,6 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
558 | unsigned int i; | 530 | unsigned int i; |
559 | u32 reg; | 531 | u32 reg; |
560 | 532 | ||
561 | rt73usb_register_read(rt2x00dev, PHY_CSR0, ®); | ||
562 | |||
563 | if (rt2x00dev->curr_hwmode == HWMODE_A) { | 533 | if (rt2x00dev->curr_hwmode == HWMODE_A) { |
564 | sel = antenna_sel_a; | 534 | sel = antenna_sel_a; |
565 | lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); | 535 | lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); |
@@ -568,15 +538,17 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
568 | lna = test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags); | 538 | lna = test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags); |
569 | } | 539 | } |
570 | 540 | ||
541 | for (i = 0; i < ARRAY_SIZE(antenna_sel_a); i++) | ||
542 | rt73usb_bbp_write(rt2x00dev, sel[i].word, sel[i].value[lna]); | ||
543 | |||
544 | rt73usb_register_read(rt2x00dev, PHY_CSR0, ®); | ||
545 | |||
571 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_BG, | 546 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_BG, |
572 | (rt2x00dev->curr_hwmode == HWMODE_B || | 547 | (rt2x00dev->curr_hwmode == HWMODE_B || |
573 | rt2x00dev->curr_hwmode == HWMODE_G)); | 548 | rt2x00dev->curr_hwmode == HWMODE_G)); |
574 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_A, | 549 | rt2x00_set_field32(®, PHY_CSR0_PA_PE_A, |
575 | (rt2x00dev->curr_hwmode == HWMODE_A)); | 550 | (rt2x00dev->curr_hwmode == HWMODE_A)); |
576 | 551 | ||
577 | for (i = 0; i < ARRAY_SIZE(antenna_sel_a); i++) | ||
578 | rt73usb_bbp_write(rt2x00dev, sel[i].word, sel[i].value[lna]); | ||
579 | |||
580 | rt73usb_register_write(rt2x00dev, PHY_CSR0, reg); | 552 | rt73usb_register_write(rt2x00dev, PHY_CSR0, reg); |
581 | 553 | ||
582 | if (rt2x00_rf(&rt2x00dev->chip, RF5226) || | 554 | if (rt2x00_rf(&rt2x00dev->chip, RF5226) || |