> Date: Thu, 25 Jul 2013 11:10:21 +0200 (CEST)
> From: Mark Kettenis <[email protected]>
> 
> > Date: Thu, 25 Jul 2013 10:33:12 +0200 (CEST)
> > From: Mark Kettenis <[email protected]>
> > 
> > Looked at your diff, and then noticed that run(4) already had support
> > for the RT3572 MAC/BBP.  It has a few more RT3572-specific bits that
> > match what the Linux driver does.  So I ported them over to ral(4).
> > Could you give the attached diff a go?
> 
> Actually, this diff isn't quite right.  I'll send a new one shortly.

New diff.  Please give this one a shot.

Index: rt2860.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/rt2860.c,v
retrieving revision 1.68
diff -u -p -r1.68 rt2860.c
--- rt2860.c    11 Jun 2013 18:15:53 -0000      1.68
+++ rt2860.c    25 Jul 2013 09:30:13 -0000
@@ -197,6 +197,8 @@ static const struct {
        uint8_t val;
 }  rt3090_def_rf[] = {
        RT3070_DEF_RF
+}, rt3572_def_rf[] = {
+       RT3572_DEF_RF
 };
 
 int
@@ -2158,13 +2160,15 @@ rt2860_select_chan_group(struct rt2860_s
                        rt2860_mcu_bbp_write(sc, 75, 0x50);
                }
        } else {
-               if (sc->ext_5ghz_lna) {
+               if (sc->mac_ver == 0x3572)
+                       rt2860_mcu_bbp_write(sc, 82, 0x94);
+               else
                        rt2860_mcu_bbp_write(sc, 82, 0xf2);
+
+               if (sc->ext_5ghz_lna)
                        rt2860_mcu_bbp_write(sc, 75, 0x46);
-               } else {
-                       rt2860_mcu_bbp_write(sc, 82, 0xf2);
+               else
                        rt2860_mcu_bbp_write(sc, 75, 0x50);
-               }
        }
 
        tmp = RAL_READ(sc, RT2860_TX_BAND_CFG);
@@ -2191,7 +2195,12 @@ rt2860_select_chan_group(struct rt2860_s
                if (sc->mac_ver == 0x3593 && sc->ntxchains > 2)
                        tmp |= RT3593_PA_PE_A2_EN;
        }
-       RAL_WRITE(sc, RT2860_TX_PIN_CFG, tmp);
+       if (sc->mac_ver == 0x3572) {
+               rt3090_rf_write(sc, 8, 0x00);
+               RAL_WRITE(sc, RT2860_TX_PIN_CFG, tmp);
+               rt3090_rf_write(sc, 8, 0x80);
+       } else
+               RAL_WRITE(sc, RT2860_TX_PIN_CFG, tmp);
 
        if (sc->mac_ver == 0x3593) {
                tmp = RAL_READ(sc, RT2860_GPIO_CTRL);
@@ -2215,7 +2224,10 @@ rt2860_select_chan_group(struct rt2860_s
                else
                        agc = 0x2e + sc->lna[0];
        } else {                /* 5GHz band */
-               agc = 0x32 + (sc->lna[group] * 5) / 3;
+               if (sc->mac_ver == 0x3572)
+                       agc = 0x22 + (sc->lna[group] * 5) / 3;
+               else
+                       agc = 0x32 + (sc->lna[group] * 5) / 3;
        }
        rt2860_mcu_bbp_write(sc, 66, agc);
 
@@ -2367,9 +2379,16 @@ rt3090_rf_init(struct rt2860_softc *sc)
        RAL_WRITE(sc, RT3070_GPIO_SWITCH, tmp & ~0x20);
 
        /* initialize RF registers to default value */
-       for (i = 0; i < nitems(rt3090_def_rf); i++) {
-               rt3090_rf_write(sc, rt3090_def_rf[i].reg,
-                   rt3090_def_rf[i].val);
+       if (sc->mac_ver == 0x3572) {
+               for (i = 0; i < nitems(rt3572_def_rf); i++) {
+                       rt3090_rf_write(sc, rt3572_def_rf[i].reg,
+                           rt3572_def_rf[i].val);
+               }
+       } else {
+               for (i = 0; i < nitems(rt3090_def_rf); i++) {
+                       rt3090_rf_write(sc, rt3090_def_rf[i].reg,
+                           rt3090_def_rf[i].val);
+               }
        }
 
        /* select 20MHz bandwidth */

Reply via email to