]> err.no Git - linux-2.6/blobdiff - drivers/net/wireless/rt2x00/rt73usb.c
[PATCH] rt2x00: SW diversity should default to antenna B
[linux-2.6] / drivers / net / wireless / rt2x00 / rt73usb.c
index 3e42759473c3d1e0041f975ae54656fe8b33f88d..18324210c13a2a2e4a525b1ee682c0ebaf4c9571 100644 (file)
@@ -396,8 +396,7 @@ static void rt73usb_config_txpower(struct rt2x00_dev *rt2x00dev,
 }
 
 static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
-                                     const int antenna_tx,
-                                     const int antenna_rx)
+                                     struct antenna_setup *ant)
 {
        u8 r3;
        u8 r4;
@@ -409,8 +408,7 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
 
        rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, 0);
 
-       switch (antenna_rx) {
-       case ANTENNA_SW_DIVERSITY:
+       switch (ant->rx) {
        case ANTENNA_HW_DIVERSITY:
                rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
                rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
@@ -425,6 +423,13 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
                else
                        rt2x00_set_field8(&r77, BBP_R77_PAIR, 3);
                break;
+       case ANTENNA_SW_DIVERSITY:
+               /*
+                * NOTE: We should never come here because rt2x00lib is
+                * supposed to catch this and send us the correct antenna
+                * explicitely. However we are nog going to bug about this.
+                * Instead, just default to antenna B.
+                */
        case ANTENNA_B:
                rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1);
                rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0);
@@ -442,8 +447,7 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
 }
 
 static void rt73usb_config_antenna_2x(struct rt2x00_dev *rt2x00dev,
-                                     const int antenna_tx,
-                                     const int antenna_rx)
+                                     struct antenna_setup *ant)
 {
        u8 r3;
        u8 r4;
@@ -457,8 +461,7 @@ static void rt73usb_config_antenna_2x(struct rt2x00_dev *rt2x00dev,
        rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
                          !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags));
 
-       switch (antenna_rx) {
-       case ANTENNA_SW_DIVERSITY:
+       switch (ant->rx) {
        case ANTENNA_HW_DIVERSITY:
                rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
                break;
@@ -466,6 +469,13 @@ static void rt73usb_config_antenna_2x(struct rt2x00_dev *rt2x00dev,
                rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1);
                rt2x00_set_field8(&r77, BBP_R77_PAIR, 3);
                break;
+       case ANTENNA_SW_DIVERSITY:
+               /*
+                * NOTE: We should never come here because rt2x00lib is
+                * supposed to catch this and send us the correct antenna
+                * explicitely. However we are nog going to bug about this.
+                * Instead, just default to antenna B.
+                */
        case ANTENNA_B:
                rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1);
                rt2x00_set_field8(&r77, BBP_R77_PAIR, 0);
@@ -509,7 +519,7 @@ static const struct antenna_sel antenna_sel_bg[] = {
 };
 
 static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev,
-                                  const int antenna_tx, const int antenna_rx)
+                                  struct antenna_setup *ant)
 {
        const struct antenna_sel *sel;
        unsigned int lna;
@@ -539,10 +549,10 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev,
 
        if (rt2x00_rf(&rt2x00dev->chip, RF5226) ||
            rt2x00_rf(&rt2x00dev->chip, RF5225))
-               rt73usb_config_antenna_5x(rt2x00dev, antenna_tx, antenna_rx);
+               rt73usb_config_antenna_5x(rt2x00dev, ant);
        else if (rt2x00_rf(&rt2x00dev->chip, RF2528) ||
                 rt2x00_rf(&rt2x00dev->chip, RF2527))
-               rt73usb_config_antenna_2x(rt2x00dev, antenna_tx, antenna_rx);
+               rt73usb_config_antenna_2x(rt2x00dev, ant);
 }
 
 static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev,
@@ -586,8 +596,7 @@ static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
        if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL))
                rt73usb_config_txpower(rt2x00dev, libconf->conf->power_level);
        if (flags & CONFIG_UPDATE_ANTENNA)
-               rt73usb_config_antenna(rt2x00dev, libconf->conf->antenna_sel_tx,
-                                      libconf->conf->antenna_sel_rx);
+               rt73usb_config_antenna(rt2x00dev, &libconf->ant);
        if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
                rt73usb_config_duration(rt2x00dev, libconf);
 }
@@ -659,7 +668,8 @@ static void rt73usb_activity_led(struct rt2x00_dev *rt2x00dev, int rssi)
 /*
  * Link tuning
  */
-static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev)
+static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev,
+                              struct link_qual *qual)
 {
        u32 reg;
 
@@ -667,15 +677,13 @@ static void rt73usb_link_stats(struct rt2x00_dev *rt2x00dev)
         * Update FCS error count from register.
         */
        rt73usb_register_read(rt2x00dev, STA_CSR0, &reg);
-       rt2x00dev->link.rx_failed = rt2x00_get_field32(reg, STA_CSR0_FCS_ERROR);
+       qual->rx_failed = rt2x00_get_field32(reg, STA_CSR0_FCS_ERROR);
 
        /*
         * Update False CCA count from register.
         */
        rt73usb_register_read(rt2x00dev, STA_CSR1, &reg);
-       reg = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
-       rt2x00dev->link.false_cca =
-           rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
+       qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
 }
 
 static void rt73usb_reset_tuner(struct rt2x00_dev *rt2x00dev)
@@ -781,12 +789,12 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
         * r17 does not yet exceed upper limit, continue and base
         * the r17 tuning on the false CCA count.
         */
-       if (rt2x00dev->link.false_cca > 512 && r17 < up_bound) {
+       if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) {
                r17 += 4;
                if (r17 > up_bound)
                        r17 = up_bound;
                rt73usb_bbp_write(rt2x00dev, 17, r17);
-       } else if (rt2x00dev->link.false_cca < 100 && r17 > low_bound) {
+       } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
                r17 -= 4;
                if (r17 < low_bound)
                        r17 = low_bound;
@@ -1251,7 +1259,7 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
 }
 
 static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
-                                  int maxpacket, struct sk_buff *skb)
+                                  struct sk_buff *skb)
 {
        int length;
 
@@ -1260,7 +1268,7 @@ static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
         * but it must _not_ be a multiple of the USB packet size.
         */
        length = roundup(skb->len, 4);
-       length += (4 * !(length % maxpacket));
+       length += (4 * !(length % rt2x00dev->usb_maxpacket));
 
        return length;
 }
@@ -1392,8 +1400,10 @@ static int rt73usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
        rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word);
        if (word == 0xffff) {
                rt2x00_set_field16(&word, EEPROM_ANTENNA_NUM, 2);
-               rt2x00_set_field16(&word, EEPROM_ANTENNA_TX_DEFAULT, 2);
-               rt2x00_set_field16(&word, EEPROM_ANTENNA_RX_DEFAULT, 2);
+               rt2x00_set_field16(&word, EEPROM_ANTENNA_TX_DEFAULT,
+                                  ANTENNA_B);
+               rt2x00_set_field16(&word, EEPROM_ANTENNA_RX_DEFAULT,
+                                  ANTENNA_B);
                rt2x00_set_field16(&word, EEPROM_ANTENNA_FRAME_TYPE, 0);
                rt2x00_set_field16(&word, EEPROM_ANTENNA_DYN_TXAGC, 0);
                rt2x00_set_field16(&word, EEPROM_ANTENNA_HARDWARE_RADIO, 0);
@@ -1486,7 +1496,7 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
        rt73usb_register_read(rt2x00dev, MAC_CSR0, &reg);
        rt2x00_set_chip(rt2x00dev, RT2571, value, reg);
 
-       if (!rt2x00_rev(&rt2x00dev->chip, 0x25730)) {
+       if (!rt2x00_check_rev(&rt2x00dev->chip, 0x25730)) {
                ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
                return -ENODEV;
        }
@@ -1502,9 +1512,9 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
        /*
         * Identify default antenna configuration.
         */
-       rt2x00dev->hw->conf.antenna_sel_tx =
+       rt2x00dev->default_ant.tx =
            rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT);
-       rt2x00dev->hw->conf.antenna_sel_rx =
+       rt2x00dev->default_ant.rx =
            rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT);
 
        /*
@@ -2029,6 +2039,7 @@ static struct usb_device_id rt73usb_device_table[] = {
        { USB_DEVICE(0x050d, 0x7050), USB_DEVICE_DATA(&rt73usb_ops) },
        { USB_DEVICE(0x050d, 0x705a), USB_DEVICE_DATA(&rt73usb_ops) },
        { USB_DEVICE(0x050d, 0x905b), USB_DEVICE_DATA(&rt73usb_ops) },
+       { USB_DEVICE(0x050d, 0x905c), USB_DEVICE_DATA(&rt73usb_ops) },
        /* Billionton */
        { USB_DEVICE(0x1631, 0xc019), USB_DEVICE_DATA(&rt73usb_ops) },
        /* Buffalo */