Author: kevlo
Date: Tue May 17 06:04:33 2016
New Revision: 300006
URL: https://svnweb.freebsd.org/changeset/base/300006

Log:
  The EEPROM is lying about antennas.  Don't hardcode things based on the chip
  version which is not what the vendor driver happens to do.

Modified:
  head/sys/dev/ral/rt2860.c
  head/sys/dev/ral/rt2860reg.h
  head/sys/dev/ral/rt2860var.h

Modified: head/sys/dev/ral/rt2860.c
==============================================================================
--- head/sys/dev/ral/rt2860.c   Tue May 17 05:05:30 2016        (r300005)
+++ head/sys/dev/ral/rt2860.c   Tue May 17 06:04:33 2016        (r300006)
@@ -165,7 +165,7 @@ static void rt2860_delete_key(struct iee
                    struct ieee80211_node *, struct ieee80211_key *);
 #endif
 static int8_t  rt2860_rssi2dbm(struct rt2860_softc *, uint8_t, uint8_t);
-static const char *rt2860_get_rf(uint8_t);
+static const char *rt2860_get_rf(uint16_t);
 static int     rt2860_read_eeprom(struct rt2860_softc *,
                    uint8_t macaddr[IEEE80211_ADDR_LEN]);
 static int     rt2860_bbp_init(struct rt2860_softc *);
@@ -3307,7 +3307,7 @@ b4inc(uint32_t b32, int8_t delta)
 }
 
 static const char *
-rt2860_get_rf(uint8_t rev)
+rt2860_get_rf(uint16_t rev)
 {
        switch (rev) {
        case RT2860_RF_2820:    return "RT2820";
@@ -3321,6 +3321,7 @@ rt2860_get_rf(uint8_t rev)
        case RT3070_RF_3052:    return "RT3052";
        case RT3070_RF_3320:    return "RT3320";
        case RT3070_RF_3053:    return "RT3053";
+       case RT5390_RF_5360:    return "RT5360";
        case RT5390_RF_5390:    return "RT5390";
        default:                return "unknown";
        }
@@ -3343,9 +3344,11 @@ rt2860_read_eeprom(struct rt2860_softc *
                        sc->sc_srom_read = rt3090_efuse_read_2;
        }
 
+#ifdef RAL_DEBUG
        /* read EEPROM version */
        val = rt2860_srom_read(sc, RT2860_EEPROM_VERSION);
        DPRINTF(("EEPROM rev=%d, FAE=%d\n", val >> 8, val & 0xff));
+#endif
 
        /* read MAC address */
        val = rt2860_srom_read(sc, RT2860_EEPROM_MAC01);
@@ -3358,9 +3361,11 @@ rt2860_read_eeprom(struct rt2860_softc *
        macaddr[4] = val & 0xff;
        macaddr[5] = val >> 8;
 
+#ifdef RAL_DEBUG
        /* read country code */
        val = rt2860_srom_read(sc, RT2860_EEPROM_COUNTRY);
        DPRINTF(("EEPROM region code=0x%04x\n", val));
+#endif
 
        /* read vendor BBP settings */
        for (i = 0; i < 8; i++) {
@@ -3402,39 +3407,12 @@ rt2860_read_eeprom(struct rt2860_softc *
 
        /* read RF information */
        val = rt2860_srom_read(sc, RT2860_EEPROM_ANTENNA);
-       if (val == 0xffff) {
-               DPRINTF(("invalid EEPROM antenna info, using default\n"));
-               if (sc->mac_ver >= 0x5390) {
-                       /* default to RF5390 */
-                       sc->rf_rev = RT5390_RF_5390;
-                       sc->ntxchains = (sc->mac_ver == 0x5392) ? 2 : 1;
-                       sc->nrxchains = (sc->mac_ver == 0x5392) ? 2 : 1;
-               } else if (sc->mac_ver == 0x3593) {
-                       /* default to RF3053 3T3R */
-                       sc->rf_rev = RT3070_RF_3053;
-                       sc->ntxchains = 3;
-                       sc->nrxchains = 3;
-               } else if (sc->mac_ver >= 0x3071) {
-                       /* default to RF3020 1T1R */
-                       sc->rf_rev = RT3070_RF_3020;
-                       sc->ntxchains = 1;
-                       sc->nrxchains = 1;
-               } else {
-                       /* default to RF2820 1T2R */
-                       sc->rf_rev = RT2860_RF_2820;
-                       sc->ntxchains = 1;
-                       sc->nrxchains = 2;
-               }
-       } else {
+       if (sc->mac_ver >= 0x5390)
+               sc->rf_rev = rt2860_srom_read(sc, RT2860_EEPROM_CHIPID);
+       else
                sc->rf_rev = (val >> 8) & 0xf;
-               if (sc->mac_ver >= 0x5390) {
-                       sc->ntxchains = (sc->mac_ver == 0x5392) ? 2 : 1;
-                       sc->nrxchains = (sc->mac_ver == 0x5392) ? 2 : 1;
-               } else {
-                       sc->ntxchains = (val >> 4) & 0xf;
-                       sc->nrxchains = val & 0xf;
-               }
-       }
+       sc->ntxchains = (val >> 4) & 0xf;
+       sc->nrxchains = val & 0xf;
        DPRINTF(("EEPROM RF rev=0x%02x chains=%dT%dR\n",
            sc->rf_rev, sc->ntxchains, sc->nrxchains));
 

Modified: head/sys/dev/ral/rt2860reg.h
==============================================================================
--- head/sys/dev/ral/rt2860reg.h        Tue May 17 05:05:30 2016        
(r300005)
+++ head/sys/dev/ral/rt2860reg.h        Tue May 17 06:04:33 2016        
(r300006)
@@ -900,18 +900,19 @@ struct rt2860_rxwi {
 #define RT2860_RF3     1
 #define RT2860_RF4     3
 
-#define RT2860_RF_2820 1       /* 2T3R */
-#define RT2860_RF_2850 2       /* dual-band 2T3R */
-#define RT2860_RF_2720 3       /* 1T2R */
-#define RT2860_RF_2750 4       /* dual-band 1T2R */
-#define RT3070_RF_3020 5       /* 1T1R */
-#define RT3070_RF_2020 6       /* b/g */
-#define RT3070_RF_3021 7       /* 1T2R */
-#define RT3070_RF_3022 8       /* 2T2R */
-#define RT3070_RF_3052 9       /* dual-band 2T2R */
-#define RT3070_RF_3320 11      /* 1T1R */
-#define RT3070_RF_3053 13      /* dual-band 3T3R */
-#define RT5390_RF_5390 15      /* b/g/n */
+#define RT2860_RF_2820 0x0001  /* 2T3R */
+#define RT2860_RF_2850 0x0002  /* dual-band 2T3R */
+#define RT2860_RF_2720 0x0003  /* 1T2R */
+#define RT2860_RF_2750 0x0004  /* dual-band 1T2R */
+#define RT3070_RF_3020 0x0005  /* 1T1R */
+#define RT3070_RF_2020 0x0006  /* b/g */
+#define RT3070_RF_3021 0x0007  /* 1T2R */
+#define RT3070_RF_3022 0x0008  /* 2T2R */
+#define RT3070_RF_3052 0x0009  /* dual-band 2T2R */
+#define RT3070_RF_3320 0x000b  /* 1T1R */
+#define RT3070_RF_3053 0x000d  /* dual-band 3T3R */
+#define RT5390_RF_5360 0x5360  /* 1T1R */
+#define RT5390_RF_5390 0x5390  /* 1T1R */
 
 /* USB commands for RT2870 only */
 #define RT2870_RESET           1
@@ -922,6 +923,7 @@ struct rt2860_rxwi {
 
 #define RT2860_EEPROM_DELAY    1       /* minimum hold time (microsecond) */
 
+#define RT2860_EEPROM_CHIPID           0x00
 #define RT2860_EEPROM_VERSION          0x01
 #define RT2860_EEPROM_MAC01            0x02
 #define RT2860_EEPROM_MAC23            0x03

Modified: head/sys/dev/ral/rt2860var.h
==============================================================================
--- head/sys/dev/ral/rt2860var.h        Tue May 17 05:05:30 2016        
(r300005)
+++ head/sys/dev/ral/rt2860var.h        Tue May 17 06:04:33 2016        
(r300006)
@@ -159,7 +159,7 @@ struct rt2860_softc {
 
        uint16_t                        mac_ver;
        uint16_t                        mac_rev;
-       uint8_t                         rf_rev;
+       uint16_t                        rf_rev;
        uint8_t                         freq;
        uint8_t                         ntxchains;
        uint8_t                         nrxchains;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to