iPXE
Defines | Functions | Variables
rtl8180_sa2400.c File Reference
#include <unistd.h>
#include <ipxe/pci.h>
#include <ipxe/net80211.h>
#include "rtl818x.h"

Go to the source code of this file.

Defines

#define SA2400_ANTENNA   0x91
#define SA2400_DIG_ANAPARAM_PWR1_ON   0x8
#define SA2400_ANA_ANAPARAM_PWR1_ON   0x28
#define SA2400_ANAPARAM_PWR0_ON   0x3
#define SA2400_MAX_SENS   85
#define SA2400_REG4_FIRDAC_SHIFT   7

Functions

 FILE_LICENCE (GPL2_ONLY)
static void write_sa2400 (struct net80211_device *dev, u8 addr, u32 data)
static void sa2400_write_phy_antenna (struct net80211_device *dev, short chan)
static void sa2400_rf_set_channel (struct net80211_device *dev, struct net80211_channel *channelp)
static void sa2400_rf_stop (struct net80211_device *dev)
static void sa2400_rf_init (struct net80211_device *dev)

Variables

static const u32 sa2400_chan []
struct rtl818x_rf_ops sa2400_rf_ops __rtl818x_rf_driver

Define Documentation

#define SA2400_ANTENNA   0x91

Definition at line 31 of file rtl8180_sa2400.c.

Referenced by sa2400_write_phy_antenna().

#define SA2400_DIG_ANAPARAM_PWR1_ON   0x8

Definition at line 32 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().

#define SA2400_ANA_ANAPARAM_PWR1_ON   0x28

Definition at line 33 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().

#define SA2400_ANAPARAM_PWR0_ON   0x3

Definition at line 34 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().

#define SA2400_MAX_SENS   85

Definition at line 37 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().

#define SA2400_REG4_FIRDAC_SHIFT   7

Definition at line 39 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().


Function Documentation

FILE_LICENCE ( GPL2_ONLY  )
static void write_sa2400 ( struct net80211_device dev,
u8  addr,
u32  data 
) [static]

Definition at line 58 of file rtl8180_sa2400.c.

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

Referenced by sa2400_rf_init(), sa2400_rf_set_channel(), and sa2400_rf_stop().

{
        struct rtl818x_priv *priv = dev->priv;
        u32 phy_config;

        /* MAC will bang bits to the sa2400. sw 3-wire is NOT used */
        phy_config = 0xb0000000;

        phy_config |= ((u32)(addr & 0xf)) << 24;
        phy_config |= data & 0xffffff;

        /* This was originally a 32-bit write to a typecast
           RFPinsOutput, but gcc complained about aliasing rules. -JBO */
        rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, phy_config & 0xffff);
        rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, phy_config >> 16);

        mdelay(3);
}
static void sa2400_write_phy_antenna ( struct net80211_device dev,
short  chan 
) [static]
static void sa2400_rf_set_channel ( struct net80211_device dev,
struct net80211_channel channelp 
) [static]

Definition at line 92 of file rtl8180_sa2400.c.

References channel, net80211_channel::channel_nr, priv, net80211_device::priv, sa2400_chan, sa2400_write_phy_antenna(), rtl818x_priv::txpower, and write_sa2400().

{
        struct rtl818x_priv *priv = dev->priv;
        int channel = channelp->channel_nr;
        u32 txpw = priv->txpower[channel - 1] & 0xFF;
        u32 chan = sa2400_chan[channel - 1];

        write_sa2400(dev, 7, txpw);

        sa2400_write_phy_antenna(dev, channel);

        write_sa2400(dev, 0, chan);
        write_sa2400(dev, 1, 0xbb50);
        write_sa2400(dev, 2, 0x80);
        write_sa2400(dev, 3, 0);
}
static void sa2400_rf_stop ( struct net80211_device dev) [static]

Definition at line 110 of file rtl8180_sa2400.c.

References write_sa2400().

{
        write_sa2400(dev, 4, 0);
}
static void sa2400_rf_init ( struct net80211_device dev) [static]

Definition at line 115 of file rtl8180_sa2400.c.

References rtl818x_priv::anaparam, ANAPARAM_PWR0_MASK, ANAPARAM_PWR0_SHIFT, ANAPARAM_PWR1_MASK, ANAPARAM_PWR1_SHIFT, ANAPARAM_TXDACOFF_SHIFT, rtl818x_csr::CONFIG2, rtl818x_priv::csthreshold, rtl818x_priv::map, priv, net80211_device::priv, RF_PARAM_ANALOGPHY, rtl818x_priv::rfparam, RTL818X_CONFIG2_ANTENNA_DIV, rtl818x_ioread32(), rtl818x_ioread8(), rtl818x_iowrite32(), rtl818x_set_anaparam(), RTL818X_TX_CONF_LOOPBACK_CONT, rtl818x_write_phy(), SA2400_ANA_ANAPARAM_PWR1_ON, SA2400_ANAPARAM_PWR0_ON, sa2400_chan, SA2400_DIG_ANAPARAM_PWR1_ON, SA2400_MAX_SENS, SA2400_REG4_FIRDAC_SHIFT, sa2400_write_phy_antenna(), rtl818x_csr::TX_CONF, and write_sa2400().

{
        struct rtl818x_priv *priv = dev->priv;
        u32 anaparam, txconf;
        u8 firdac;
        int analogphy = priv->rfparam & RF_PARAM_ANALOGPHY;

        anaparam = priv->anaparam;
        anaparam &= ~(1 << ANAPARAM_TXDACOFF_SHIFT);
        anaparam &= ~ANAPARAM_PWR1_MASK;
        anaparam &= ~ANAPARAM_PWR0_MASK;

        if (analogphy) {
                anaparam |= SA2400_ANA_ANAPARAM_PWR1_ON << ANAPARAM_PWR1_SHIFT;
                firdac = 0;
        } else {
                anaparam |= (SA2400_DIG_ANAPARAM_PWR1_ON << ANAPARAM_PWR1_SHIFT);
                anaparam |= (SA2400_ANAPARAM_PWR0_ON << ANAPARAM_PWR0_SHIFT);
                firdac = 1 << SA2400_REG4_FIRDAC_SHIFT;
        }

        rtl818x_set_anaparam(priv, anaparam);

        write_sa2400(dev, 0, sa2400_chan[0]);
        write_sa2400(dev, 1, 0xbb50);
        write_sa2400(dev, 2, 0x80);
        write_sa2400(dev, 3, 0);
        write_sa2400(dev, 4, 0x19340 | firdac);
        write_sa2400(dev, 5, 0x1dfb | (SA2400_MAX_SENS - 54) << 15);
        write_sa2400(dev, 4, 0x19348 | firdac); /* calibrate VCO */

        if (!analogphy)
                write_sa2400(dev, 4, 0x1938c); /*???*/

        write_sa2400(dev, 4, 0x19340 | firdac);

        write_sa2400(dev, 0, sa2400_chan[0]);
        write_sa2400(dev, 1, 0xbb50);
        write_sa2400(dev, 2, 0x80);
        write_sa2400(dev, 3, 0);
        write_sa2400(dev, 4, 0x19344 | firdac); /* calibrate filter */

        /* new from rtl8180 embedded driver (rtl8181 project) */
        write_sa2400(dev, 6, 0x13ff | (1 << 23)); /* MANRX */
        write_sa2400(dev, 8, 0); /* VCO */

        if (analogphy) {
                rtl818x_set_anaparam(priv, anaparam |
                                     (1 << ANAPARAM_TXDACOFF_SHIFT));

                txconf = rtl818x_ioread32(priv, &priv->map->TX_CONF);
                rtl818x_iowrite32(priv, &priv->map->TX_CONF,
                        txconf | RTL818X_TX_CONF_LOOPBACK_CONT);

                write_sa2400(dev, 4, 0x19341); /* calibrates DC */

                /* a 5us delay is required here,
                 * we rely on the 3ms delay introduced in write_sa2400 */

                write_sa2400(dev, 4, 0x19345);

                /* a 20us delay is required here,
                 * we rely on the 3ms delay introduced in write_sa2400 */

                rtl818x_iowrite32(priv, &priv->map->TX_CONF, txconf);

                rtl818x_set_anaparam(priv, anaparam);
        }
        /* end new code */

        write_sa2400(dev, 4, 0x19341 | firdac); /* RTX MODE */

        /* baseband configuration */
        rtl818x_write_phy(dev, 0, 0x98);
        rtl818x_write_phy(dev, 3, 0x38);
        rtl818x_write_phy(dev, 4, 0xe0);
        rtl818x_write_phy(dev, 5, 0x90);
        rtl818x_write_phy(dev, 6, 0x1a);
        rtl818x_write_phy(dev, 7, 0x64);

        sa2400_write_phy_antenna(dev, 1);

        rtl818x_write_phy(dev, 0x11, 0x80);

        if (rtl818x_ioread8(priv, &priv->map->CONFIG2) &
            RTL818X_CONFIG2_ANTENNA_DIV)
                rtl818x_write_phy(dev, 0x12, 0xc7); /* enable ant diversity */
        else
                rtl818x_write_phy(dev, 0x12, 0x47); /* disable ant diversity */

        rtl818x_write_phy(dev, 0x13, 0x90 | priv->csthreshold);

        rtl818x_write_phy(dev, 0x19, 0x0);
        rtl818x_write_phy(dev, 0x1a, 0xa0);
}

Variable Documentation

const u32 sa2400_chan[] [static]
Initial value:
 {
        0x00096c, 
        0x080970,
        0x100974,
        0x180978,
        0x000980,
        0x080984,
        0x100988,
        0x18098c,
        0x000994,
        0x080998,
        0x10099c,
        0x1809a0,
        0x0009a8,
        0x0009b4, 
}

Definition at line 41 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init(), and sa2400_rf_set_channel().

struct rtl818x_rf_ops sa2400_rf_ops __rtl818x_rf_driver
Initial value:
 {
        .name           = "Philips SA2400",
        .id             = 3,
        .init           = sa2400_rf_init,
        .stop           = sa2400_rf_stop,
        .set_chan       = sa2400_rf_set_channel
}

Definition at line 211 of file rtl8180_sa2400.c.