rtl8180_grf5101.c File Reference

#include <unistd.h>
#include <gpxe/pci.h>
#include <gpxe/net80211.h>
#include "rtl818x.h"

Go to the source code of this file.

Defines

#define GRF5101_ANTENNA   0xA3

Functions

 FILE_LICENCE (GPL2_ONLY)
static void write_grf5101 (struct net80211_device *dev, u8 addr, u32 data)
static void grf5101_write_phy_antenna (struct net80211_device *dev, short chan)
static void grf5101_rf_set_channel (struct net80211_device *dev, struct net80211_channel *channelp)
static void grf5101_rf_stop (struct net80211_device *dev)
static void grf5101_rf_init (struct net80211_device *dev)

Variables

static const int grf5101_encode []
struct rtl818x_rf_ops
grf5101_rf_ops 
__rtl818x_rf_driver


Define Documentation

#define GRF5101_ANTENNA   0xA3

Definition at line 31 of file rtl8180_grf5101.c.

Referenced by grf5101_write_phy_antenna().


Function Documentation

FILE_LICENCE ( GPL2_ONLY   ) 

static void write_grf5101 ( struct net80211_device dev,
u8  addr,
u32  data 
) [static]

Definition at line 40 of file rtl8180_grf5101.c.

References grf5101_encode, rtl818x_priv::map, mdelay(), net80211_device::priv, priv, rtl818x_csr::RFPinsEnable, rtl818x_csr::RFPinsOutput, rtl818x_iowrite16(), and u32.

Referenced by grf5101_rf_init(), grf5101_rf_set_channel(), and grf5101_rf_stop().

00041 {
00042         struct rtl818x_priv *priv = dev->priv;
00043         u32 phy_config;
00044 
00045         phy_config =  grf5101_encode[(data >> 8) & 0xF];
00046         phy_config |= grf5101_encode[(data >> 4) & 0xF] << 4;
00047         phy_config |= grf5101_encode[data & 0xF] << 8;
00048         phy_config |= grf5101_encode[(addr >> 1) & 0xF] << 12;
00049         phy_config |= (addr & 1) << 16;
00050         phy_config |= grf5101_encode[(data & 0xf000) >> 12] << 24;
00051 
00052         /* MAC will bang bits to the chip */
00053         phy_config |= 0x90000000;
00054 
00055         /* This was originally a 32-bit write to a typecast
00056            RFPinsOutput, but gcc complained about aliasing rules. -JBO */
00057         rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, phy_config & 0xffff);
00058         rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, phy_config >> 16);
00059 
00060         mdelay(3);
00061 }

static void grf5101_write_phy_antenna ( struct net80211_device dev,
short  chan 
) [static]

Definition at line 63 of file rtl8180_grf5101.c.

References BB_ANTATTEN_CHAN14, BB_ANTENNA_B, GRF5101_ANTENNA, net80211_device::priv, priv, RF_PARAM_ANTBDEFAULT, rtl818x_priv::rfparam, rtl818x_write_phy(), and u8.

Referenced by grf5101_rf_init(), and grf5101_rf_set_channel().

00064 {
00065         struct rtl818x_priv *priv = dev->priv;
00066         u8 ant = GRF5101_ANTENNA;
00067 
00068         if (priv->rfparam & RF_PARAM_ANTBDEFAULT)
00069                 ant |= BB_ANTENNA_B;
00070 
00071         if (chan == 14)
00072                 ant |= BB_ANTATTEN_CHAN14;
00073 
00074         rtl818x_write_phy(dev, 0x10, ant);
00075 }

static void grf5101_rf_set_channel ( struct net80211_device dev,
struct net80211_channel channelp 
) [static]

Definition at line 77 of file rtl8180_grf5101.c.

References net80211_channel::channel_nr, grf5101_write_phy_antenna(), net80211_device::priv, priv, rtl818x_priv::txpower, u32, and write_grf5101().

00079 {
00080         struct rtl818x_priv *priv = dev->priv;
00081         int channel = channelp->channel_nr;
00082         u32 txpw = priv->txpower[channel - 1] & 0xFF;
00083         u32 chan = channel - 1;
00084 
00085         /* set TX power */
00086         write_grf5101(dev, 0x15, 0x0);
00087         write_grf5101(dev, 0x06, txpw);
00088         write_grf5101(dev, 0x15, 0x10);
00089         write_grf5101(dev, 0x15, 0x0);
00090 
00091         /* set frequency */
00092         write_grf5101(dev, 0x07, 0x0);
00093         write_grf5101(dev, 0x0B, chan);
00094         write_grf5101(dev, 0x07, 0x1000);
00095 
00096         grf5101_write_phy_antenna(dev, channel);
00097 }

static void grf5101_rf_stop ( struct net80211_device dev  )  [static]

Definition at line 99 of file rtl8180_grf5101.c.

References rtl818x_priv::anaparam, net80211_device::priv, priv, rtl818x_set_anaparam(), u32, and write_grf5101().

00100 {
00101         struct rtl818x_priv *priv = dev->priv;
00102         u32 anaparam;
00103 
00104         anaparam = priv->anaparam;
00105         anaparam &= 0x000fffff;
00106         anaparam |= 0x3f900000;
00107         rtl818x_set_anaparam(priv, anaparam);
00108 
00109         write_grf5101(dev, 0x07, 0x0);
00110         write_grf5101(dev, 0x1f, 0x45);
00111         write_grf5101(dev, 0x1f, 0x5);
00112         write_grf5101(dev, 0x00, 0x8e4);
00113 }

static void grf5101_rf_init ( struct net80211_device dev  )  [static]

Definition at line 115 of file rtl8180_grf5101.c.

References rtl818x_priv::anaparam, rtl818x_csr::CONFIG2, rtl818x_priv::csthreshold, grf5101_write_phy_antenna(), rtl818x_priv::map, net80211_device::priv, priv, RTL818X_CONFIG2_ANTENNA_DIV, rtl818x_ioread8(), rtl818x_set_anaparam(), rtl818x_write_phy(), and write_grf5101().

00116 {
00117         struct rtl818x_priv *priv = dev->priv;
00118 
00119         rtl818x_set_anaparam(priv, priv->anaparam);
00120 
00121         write_grf5101(dev, 0x1f, 0x0);
00122         write_grf5101(dev, 0x1f, 0x0);
00123         write_grf5101(dev, 0x1f, 0x40);
00124         write_grf5101(dev, 0x1f, 0x60);
00125         write_grf5101(dev, 0x1f, 0x61);
00126         write_grf5101(dev, 0x1f, 0x61);
00127         write_grf5101(dev, 0x00, 0xae4);
00128         write_grf5101(dev, 0x1f, 0x1);
00129         write_grf5101(dev, 0x1f, 0x41);
00130         write_grf5101(dev, 0x1f, 0x61);
00131 
00132         write_grf5101(dev, 0x01, 0x1a23);
00133         write_grf5101(dev, 0x02, 0x4971);
00134         write_grf5101(dev, 0x03, 0x41de);
00135         write_grf5101(dev, 0x04, 0x2d80);
00136         write_grf5101(dev, 0x05, 0x68ff);       /* 0x61ff original value */
00137         write_grf5101(dev, 0x06, 0x0);
00138         write_grf5101(dev, 0x07, 0x0);
00139         write_grf5101(dev, 0x08, 0x7533);
00140         write_grf5101(dev, 0x09, 0xc401);
00141         write_grf5101(dev, 0x0a, 0x0);
00142         write_grf5101(dev, 0x0c, 0x1c7);
00143         write_grf5101(dev, 0x0d, 0x29d3);
00144         write_grf5101(dev, 0x0e, 0x2e8);
00145         write_grf5101(dev, 0x10, 0x192);
00146         write_grf5101(dev, 0x11, 0x248);
00147         write_grf5101(dev, 0x12, 0x0);
00148         write_grf5101(dev, 0x13, 0x20c4);
00149         write_grf5101(dev, 0x14, 0xf4fc);
00150         write_grf5101(dev, 0x15, 0x0);
00151         write_grf5101(dev, 0x16, 0x1500);
00152 
00153         write_grf5101(dev, 0x07, 0x1000);
00154 
00155         /* baseband configuration */
00156         rtl818x_write_phy(dev, 0, 0xa8);
00157         rtl818x_write_phy(dev, 3, 0x0);
00158         rtl818x_write_phy(dev, 4, 0xc0);
00159         rtl818x_write_phy(dev, 5, 0x90);
00160         rtl818x_write_phy(dev, 6, 0x1e);
00161         rtl818x_write_phy(dev, 7, 0x64);
00162 
00163         grf5101_write_phy_antenna(dev, 1);
00164 
00165         rtl818x_write_phy(dev, 0x11, 0x88);
00166 
00167         if (rtl818x_ioread8(priv, &priv->map->CONFIG2) &
00168             RTL818X_CONFIG2_ANTENNA_DIV)
00169                 rtl818x_write_phy(dev, 0x12, 0xc0); /* enable ant diversity */
00170         else
00171                 rtl818x_write_phy(dev, 0x12, 0x40); /* disable ant diversity */
00172 
00173         rtl818x_write_phy(dev, 0x13, 0x90 | priv->csthreshold);
00174 
00175         rtl818x_write_phy(dev, 0x19, 0x0);
00176         rtl818x_write_phy(dev, 0x1a, 0xa0);
00177         rtl818x_write_phy(dev, 0x1b, 0x44);
00178 }


Variable Documentation

const int grf5101_encode[] [static]

Initial value:

 {
        0x0, 0x8, 0x4, 0xC,
        0x2, 0xA, 0x6, 0xE,
        0x1, 0x9, 0x5, 0xD,
        0x3, 0xB, 0x7, 0xF
}

Definition at line 33 of file rtl8180_grf5101.c.

Referenced by write_grf5101().

struct rtl818x_rf_ops grf5101_rf_ops __rtl818x_rf_driver

Initial value:

 {
        .name           = "GCT GRF5101",
        .id             = 5,
        .init           = grf5101_rf_init,
        .stop           = grf5101_rf_stop,
        .set_chan       = grf5101_rf_set_channel
}

Definition at line 180 of file rtl8180_grf5101.c.


Generated on Tue Apr 6 20:01:38 2010 for gPXE by  doxygen 1.5.7.1