p4-projects@freebsd.org
[Top] [All Lists]

PERFORCE change 152998 for review

Subject: PERFORCE change 152998 for review
From: Weongyo Jeong
Date: Sat, 15 Nov 2008 10:53:02 GMT
http://perforce.freebsd.org/chv.cgi?CH=152998

Change 152998 by weongyo@weongyo_ws on 2008/11/15 10:52:23

        improve AL2230 RF handling when the device type is zd1211.  After this
        patch the RX/TX performance becomes about 17 ~ 18 Mbps comparing with
        the previous whose values were RX 7 ~ 8Mbps and TX 13 ~ 14 Mbps.

Affected files ...

.. //depot/projects/vap/sys/dev/usb/if_zyd.c#32 edit
.. //depot/projects/vap/sys/dev/usb/if_zydreg.h#12 edit

Differences ...

==== //depot/projects/vap/sys/dev/usb/if_zyd.c#32 (text+ko) ====

@@ -1,6 +1,6 @@
 /*     $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */
 /*     $NetBSD: if_zyd.c,v 1.7 2007/06/21 04:04:29 kiyohara Exp $      */
-/*     $FreeBSD: if_zyd.c 10 2008-11-12 05:15:17Z weongyo $    */
+/*     $FreeBSD: if_zyd.c 11 2008-11-15 10:02:31Z weongyo $    */
 
 /*-
  * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@xxxxxxx>
@@ -257,6 +257,7 @@
 static int     zyd_al2230_init(struct zyd_rf *);
 static int     zyd_al2230_switch_radio(struct zyd_rf *, int);
 static int     zyd_al2230_set_channel(struct zyd_rf *, uint8_t);
+static int     zyd_al2230_set_channel_b(struct zyd_rf *, uint8_t);
 static int     zyd_al2230_init_b(struct zyd_rf *);
 static int     zyd_al7230B_init(struct zyd_rf *);
 static int     zyd_al7230B_switch_radio(struct zyd_rf *, int);
@@ -965,17 +966,52 @@
 #define N(a)   (sizeof(a) / sizeof((a)[0]))
        struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phyini[] = ZYD_AL2230_PHY;
-       static const uint32_t rfini[] = ZYD_AL2230_RF;
+       static const struct zyd_phy_pair phy2230s[] = ZYD_AL2230S_PHY_INIT;
+       static const struct zyd_phy_pair phypll[] = {
+               { ZYD_CR251, 0x2f }, { ZYD_CR251, 0x3f },
+               { ZYD_CR138, 0x28 }, { ZYD_CR203, 0x06 }
+       };
+       static const uint32_t rfini1[] = ZYD_AL2230_RF_PART1;
+       static const uint32_t rfini2[] = ZYD_AL2230_RF_PART2;
+       static const uint32_t rfini3[] = ZYD_AL2230_RF_PART3;
        int i, error;
 
        /* init RF-dependent PHY registers */
        for (i = 0; i < N(phyini); i++)
                zyd_write16_m(sc, phyini[i].reg, phyini[i].val);
 
+       if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0) {
+               for (i = 0; i < N(phy2230s); i++)
+                       zyd_write16_m(sc, phy2230s[i].reg, phy2230s[i].val);
+       }
+
        /* init AL2230 radio */
-       for (i = 0; i < N(rfini); i++) {
-               if ((error = zyd_rfwrite(sc, rfini[i])) != 0)
-                       return (error);
+       for (i = 0; i < N(rfini1); i++) {
+               error = zyd_rfwrite(sc, rfini1[i]);
+               if (error != 0)
+                       goto fail;
+       }
+
+       if (sc->sc_rfrev == ZYD_RF_AL2230S || sc->sc_al2230s != 0)
+               error = zyd_rfwrite(sc, 0x000824);
+       else
+               error = zyd_rfwrite(sc, 0x0005a4);
+       if (error != 0)
+               goto fail;
+
+       for (i = 0; i < N(rfini2); i++) {
+               error = zyd_rfwrite(sc, rfini2[i]);
+               if (error != 0)
+                       goto fail;
+       }
+
+       for (i = 0; i < N(phypll); i++)
+               zyd_write16_m(sc, phypll[i].reg, phypll[i].val);
+
+       for (i = 0; i < N(rfini3); i++) {
+               error = zyd_rfwrite(sc, rfini3[i]);
+               if (error != 0)
+                       goto fail;
        }
 fail:
        return (error);
@@ -1089,10 +1125,40 @@
 #define N(a)   (sizeof(a) / sizeof((a)[0]))
        int error, i;
        struct zyd_softc *sc = rf->rf_sc;
+       static const struct zyd_phy_pair phy1[] = {
+               { ZYD_CR138, 0x28 }, { ZYD_CR203, 0x06 },
+       };
+       static const struct {
+               uint32_t        r1, r2, r3;
+       } rfprog[] = ZYD_AL2230_CHANTABLE;
+
+       error = zyd_rfwrite(sc, rfprog[chan - 1].r1);
+       if (error != 0)
+               goto fail;
+       error = zyd_rfwrite(sc, rfprog[chan - 1].r2);
+       if (error != 0)
+               goto fail;
+       error = zyd_rfwrite(sc, rfprog[chan - 1].r3);
+       if (error != 0)
+               goto fail;
+
+       for (i = 0; i < N(phy1); i++)
+               zyd_write16_m(sc, phy1[i].reg, phy1[i].val);
+fail:
+       return (error);
+#undef N
+}
+
+static int
+zyd_al2230_set_channel_b(struct zyd_rf *rf, uint8_t chan)
+{
+#define N(a)   (sizeof(a) / sizeof((a)[0]))
+       int error, i;
+       struct zyd_softc *sc = rf->rf_sc;
        static const struct zyd_phy_pair phy1[] = ZYD_AL2230_PHY_PART1;
        static const struct {
                uint32_t        r1, r2, r3;
-       } rfprog[] = ZYD_AL2230_CHANTABLE;
+       } rfprog[] = ZYD_AL2230_CHANTABLE_B;
 
        for (i = 0; i < N(phy1); i++)
                zyd_write16_m(sc, phy1[i].reg, phy1[i].val);
@@ -1547,12 +1613,14 @@
                break;
        case ZYD_RF_AL2230:
        case ZYD_RF_AL2230S:
-               if (sc->sc_macrev == ZYD_ZD1211B)
+               if (sc->sc_macrev == ZYD_ZD1211B) {
                        rf->init = zyd_al2230_init_b;
-               else
+                       rf->set_channel = zyd_al2230_set_channel_b;
+               } else {
                        rf->init = zyd_al2230_init;
+                       rf->set_channel = zyd_al2230_set_channel;
+               }
                rf->switch_radio = zyd_al2230_switch_radio;
-               rf->set_channel  = zyd_al2230_set_channel;
                rf->bandedge6    = zyd_al2230_bandedge6;
                rf->width        = 24;  /* 24-bit RF values */
                break;
@@ -1614,6 +1682,7 @@
        int error;
        const struct zyd_phy_pair *phyp;
        struct zyd_rf *rf = &sc->sc_rf;
+       uint16_t val;
 
        /* specify that the plug and play is finished */
        zyd_write32_m(sc, ZYD_MAC_AFTER_PNP, 1);
@@ -1643,6 +1712,10 @@
        phyp = (sc->sc_macrev == ZYD_ZD1211B) ? zyd_def_phyB : zyd_def_phy;
        for (; phyp->reg != 0; phyp++)
                zyd_write16_m(sc, phyp->reg, phyp->val);
+       if (sc->sc_macrev == ZYD_ZD1211 && sc->sc_fix_cr157 != 0) {
+               zyd_read16_m(sc, ZYD_EEPROM_PHY_REG, &val);
+               zyd_write32_m(sc, ZYD_CR157, val >> 8);
+       }
        error = zyd_unlock_phy(sc);
        if (error != 0)
                goto fail;
@@ -2739,12 +2812,12 @@
 
                device_printf(sc->sc_dev,
                    "HMAC ZD1211%s, FW %02x.%02x, RF %s S%x, PA%x LED %x "
-                   "BE%x NP%x Gain%x\n",
+                   "BE%x NP%x Gain%x F%x\n",
                    (sc->sc_macrev == ZYD_ZD1211) ? "": "B",
                    sc->sc_fwrev >> 8, sc->sc_fwrev & 0xff,
                    zyd_rf_name(sc->sc_rfrev), sc->sc_al2230s, sc->sc_parev,
                    sc->sc_ledtype, sc->sc_bandedge6, sc->sc_newphy,
-                   sc->sc_cckgain);
+                   sc->sc_cckgain, sc->sc_fix_cr157);
 
                /* read regulatory domain (currently unused) */
                zyd_read32_m(sc, ZYD_EEPROM_SUBID, &val);

==== //depot/projects/vap/sys/dev/usb/if_zydreg.h#12 (text+ko) ====

@@ -1,6 +1,6 @@
 /*     $OpenBSD: if_zydreg.h,v 1.19 2006/11/30 19:28:07 damien Exp $   */
 /*     $NetBSD: if_zydreg.h,v 1.2 2007/06/16 11:18:45 kiyohara Exp $   */
-/*     $FreeBSD: if_zydreg.h 8 2008-11-11 05:00:00Z weongyo $  */
+/*     $FreeBSD: if_zydreg.h 12 2008-11-15 10:47:30Z weongyo $ */
 
 /*-
  * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@xxxxxxx>
@@ -128,8 +128,8 @@
 #define ZYD_EEPROM_PWR_CAL     0xf81f /* Calibration */
 #define ZYD_EEPROM_PWR_INT     0xf827 /* Calibration */
 #define ZYD_EEPROM_ALLOWEDCHAN 0xf82f /* Allowed CH mask, 1 bit each */
-#define ZYD_EEPROM_PHY_REG     0xf831 /* PHY registers */
 #define ZYD_EEPROM_DEVICE_VER  0xf837 /* Device version */
+#define ZYD_EEPROM_PHY_REG     0xf83c /* PHY registers */
 #define ZYD_EEPROM_36M_CAL     0xf83f /* Calibration */
 #define ZYD_EEPROM_11A_INT     0xf847 /* Interpolation */
 #define ZYD_EEPROM_48M_CAL     0xf84f /* Calibration */
@@ -422,7 +422,7 @@
 #define ZYD_CR255              0x93fc
 
 /* copied nearly verbatim from the Linux driver rewrite */
-#define ZYD_DEF_PHY                                                    \
+#define        ZYD_DEF_PHY                                                     
\
 {                                                                      \
        { ZYD_CR0,   0x0a }, { ZYD_CR1,   0x06 }, { ZYD_CR2,   0x26 },  \
        { ZYD_CR3,   0x38 }, { ZYD_CR4,   0x80 }, { ZYD_CR9,   0xa0 },  \
@@ -438,7 +438,7 @@
        { ZYD_CR37,  0x00 }, { ZYD_CR38,  0x38 }, { ZYD_CR39,  0x0c },  \
        { ZYD_CR40,  0x84 }, { ZYD_CR41,  0x2a }, { ZYD_CR42,  0x80 },  \
        { ZYD_CR43,  0x10 }, { ZYD_CR44,  0x12 }, { ZYD_CR46,  0xff },  \
-       { ZYD_CR47,  0x08 }, { ZYD_CR48,  0x26 }, { ZYD_CR49,  0x5b },  \
+       { ZYD_CR47,  0x1e }, { ZYD_CR48,  0x26 }, { ZYD_CR49,  0x5b },  \
        { ZYD_CR64,  0xd0 }, { ZYD_CR65,  0x04 }, { ZYD_CR66,  0x58 },  \
        { ZYD_CR67,  0xc9 }, { ZYD_CR68,  0x88 }, { ZYD_CR69,  0x41 },  \
        { ZYD_CR70,  0x23 }, { ZYD_CR71,  0x10 }, { ZYD_CR72,  0xff },  \
@@ -460,7 +460,7 @@
        { ZYD_CR5,   0x00 }, { ZYD_CR6,   0x00 }, { ZYD_CR7,   0x00 },  \
        { ZYD_CR8,   0x00 }, { ZYD_CR9,   0x20 }, { ZYD_CR12,  0xf0 },  \
        { ZYD_CR20,  0x0e }, { ZYD_CR21,  0x0e }, { ZYD_CR27,  0x10 },  \
-       { ZYD_CR44,  0x33 }, { ZYD_CR47,  0x30 }, { ZYD_CR83,  0x24 },  \
+       { ZYD_CR44,  0x33 }, { ZYD_CR47,  0x1E }, { ZYD_CR83,  0x24 },  \
        { ZYD_CR84,  0x04 }, { ZYD_CR85,  0x00 }, { ZYD_CR86,  0x0C },  \
        { ZYD_CR87,  0x12 }, { ZYD_CR88,  0x0C }, { ZYD_CR89,  0x00 },  \
        { ZYD_CR90,  0x10 }, { ZYD_CR91,  0x08 }, { ZYD_CR93,  0x00 },  \
@@ -471,19 +471,18 @@
        { ZYD_CR111, 0x27 }, { ZYD_CR112, 0x27 }, { ZYD_CR113, 0x27 },  \
        { ZYD_CR114, 0x27 }, { ZYD_CR115, 0x26 }, { ZYD_CR116, 0x24 },  \
        { ZYD_CR117, 0xfc }, { ZYD_CR118, 0xfa }, { ZYD_CR120, 0x4f },  \
-       { ZYD_CR123, 0x27 }, { ZYD_CR125, 0xaa }, { ZYD_CR127, 0x03 },  \
-       { ZYD_CR128, 0x14 }, { ZYD_CR129, 0x12 }, { ZYD_CR130, 0x10 },  \
-       { ZYD_CR131, 0x0C }, { ZYD_CR136, 0xdf }, { ZYD_CR137, 0x40 },  \
-       { ZYD_CR138, 0xa0 }, { ZYD_CR139, 0xb0 }, { ZYD_CR140, 0x99 },  \
-       { ZYD_CR141, 0x82 }, { ZYD_CR142, 0x54 }, { ZYD_CR143, 0x1c },  \
-       { ZYD_CR144, 0x6c }, { ZYD_CR147, 0x07 }, { ZYD_CR148, 0x4c },  \
-       { ZYD_CR149, 0x50 }, { ZYD_CR150, 0x0e }, { ZYD_CR151, 0x18 },  \
-       { ZYD_CR160, 0xfe }, { ZYD_CR161, 0xee }, { ZYD_CR162, 0xaa },  \
-       { ZYD_CR163, 0xfa }, { ZYD_CR164, 0xfa }, { ZYD_CR165, 0xea },  \
-       { ZYD_CR166, 0xbe }, { ZYD_CR167, 0xbe }, { ZYD_CR168, 0x6a },  \
-       { ZYD_CR169, 0xba }, { ZYD_CR170, 0xba }, { ZYD_CR171, 0xba },  \
-       { ZYD_CR204, 0x7d }, { ZYD_CR203, 0x30 },                       \
-       { 0, 0 }                                                        \
+       { ZYD_CR125, 0xaa }, { ZYD_CR127, 0x03 }, { ZYD_CR128, 0x14 },  \
+       { ZYD_CR129, 0x12 }, { ZYD_CR130, 0x10 }, { ZYD_CR131, 0x0C },  \
+       { ZYD_CR136, 0xdf }, { ZYD_CR137, 0x40 }, { ZYD_CR138, 0xa0 },  \
+       { ZYD_CR139, 0xb0 }, { ZYD_CR140, 0x99 }, { ZYD_CR141, 0x82 },  \
+       { ZYD_CR142, 0x54 }, { ZYD_CR143, 0x1c }, { ZYD_CR144, 0x6c },  \
+       { ZYD_CR147, 0x07 }, { ZYD_CR148, 0x4c }, { ZYD_CR149, 0x50 },  \
+       { ZYD_CR150, 0x0e }, { ZYD_CR151, 0x18 }, { ZYD_CR160, 0xfe },  \
+       { ZYD_CR161, 0xee }, { ZYD_CR162, 0xaa }, { ZYD_CR163, 0xfa },  \
+       { ZYD_CR164, 0xfa }, { ZYD_CR165, 0xea }, { ZYD_CR166, 0xbe },  \
+       { ZYD_CR167, 0xbe }, { ZYD_CR168, 0x6a }, { ZYD_CR169, 0xba },  \
+       { ZYD_CR170, 0xba }, { ZYD_CR171, 0xba }, { ZYD_CR204, 0x7d },  \
+       { ZYD_CR203, 0x30 }, { 0, 0}                                    \
 }
 
 #define ZYD_DEF_PHYB                                                   \
@@ -669,12 +668,20 @@
        { ZYD_CR203, 0x06 }, { ZYD_CR240, 0x80 },                       \
 }
 
-#define ZYD_AL2230_RF                                                  \
+#define ZYD_AL2230_RF_PART1                                            \
+{                                                                      \
+       0x03f790, 0x033331, 0x00000d, 0x0b3331, 0x03b812, 0x00fff3      \
+}
+
+#define ZYD_AL2230_RF_PART2                                            \
 {                                                                      \
-       0x03f790, 0x033331, 0x00000d, 0x0b3331, 0x03b812, 0x00fff3,     \
        0x000da4, 0x0f4dc5, 0x0805b6, 0x011687, 0x000688, 0x0403b9,     \
-       0x00dbba, 0x00099b, 0x0bdffc, 0x00000d, 0x00500f, 0x00d00f,     \
-       0x004c0f, 0x00540f, 0x00700f, 0x00500f                          \
+       0x00dbba, 0x00099b, 0x0bdffc, 0x00000d, 0x00500f                \
+}
+
+#define ZYD_AL2230_RF_PART3                                            \
+{                                                                      \
+       0x00d00f, 0x004c0f, 0x00540f, 0x00700f, 0x00500f                \
 }
 
 #define ZYD_AL2230_RF_B                                                        
\
@@ -702,6 +709,24 @@
 
 #define ZYD_AL2230_CHANTABLE                   \
 {                                              \
+       { 0x03f790, 0x033331, 0x00000d },       \
+       { 0x03f790, 0x0b3331, 0x00000d },       \
+       { 0x03e790, 0x033331, 0x00000d },       \
+       { 0x03e790, 0x0b3331, 0x00000d },       \
+       { 0x03f7a0, 0x033331, 0x00000d },       \
+       { 0x03f7a0, 0x0b3331, 0x00000d },       \
+       { 0x03e7a0, 0x033331, 0x00000d },       \
+       { 0x03e7a0, 0x0b3331, 0x00000d },       \
+       { 0x03f7b0, 0x033331, 0x00000d },       \
+       { 0x03f7b0, 0x0b3331, 0x00000d },       \
+       { 0x03e7b0, 0x033331, 0x00000d },       \
+       { 0x03e7b0, 0x0b3331, 0x00000d },       \
+       { 0x03f7c0, 0x033331, 0x00000d },       \
+       { 0x03e7c0, 0x066661, 0x00000d }        \
+}
+
+#define ZYD_AL2230_CHANTABLE_B                 \
+{                                              \
        { 0x09efc0, 0x8cccc0, 0xb00000 },       \
        { 0x09efc0, 0x8cccd0, 0xb00000 },       \
        { 0x09e7c0, 0x8cccc0, 0xb00000 },       \
_______________________________________________
p4-projects@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/p4-projects
To unsubscribe, send any mail to "p4-projects-unsubscribe@xxxxxxxxxxx"

<Prev in Thread] Current Thread [Next in Thread>
  • PERFORCE change 152998 for review, Weongyo Jeong <=