iPXE
Macros | 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.

Macros

#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
 

Macro Definition Documentation

◆ SA2400_ANTENNA

#define SA2400_ANTENNA   0x91

Definition at line 31 of file rtl8180_sa2400.c.

◆ SA2400_DIG_ANAPARAM_PWR1_ON

#define SA2400_DIG_ANAPARAM_PWR1_ON   0x8

Definition at line 32 of file rtl8180_sa2400.c.

◆ SA2400_ANA_ANAPARAM_PWR1_ON

#define SA2400_ANA_ANAPARAM_PWR1_ON   0x28

Definition at line 33 of file rtl8180_sa2400.c.

◆ SA2400_ANAPARAM_PWR0_ON

#define SA2400_ANAPARAM_PWR0_ON   0x3

Definition at line 34 of file rtl8180_sa2400.c.

◆ SA2400_MAX_SENS

#define SA2400_MAX_SENS   85

Definition at line 37 of file rtl8180_sa2400.c.

◆ SA2400_REG4_FIRDAC_SHIFT

#define SA2400_REG4_FIRDAC_SHIFT   7

Definition at line 39 of file rtl8180_sa2400.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_ONLY  )

◆ write_sa2400()

static void write_sa2400 ( struct net80211_device dev,
u8  addr,
u32  data 
)
static

Definition at line 58 of file rtl8180_sa2400.c.

59 {
60  struct rtl818x_priv *priv = dev->priv;
61  u32 phy_config;
62 
63  /* MAC will bang bits to the sa2400. sw 3-wire is NOT used */
64  phy_config = 0xb0000000;
65 
66  phy_config |= ((u32)(addr & 0xf)) << 24;
67  phy_config |= data & 0xffffff;
68 
69  /* This was originally a 32-bit write to a typecast
70  RFPinsOutput, but gcc complained about aliasing rules. -JBO */
71  rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, phy_config & 0xffff);
72  rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, phy_config >> 16);
73 
74  mdelay(3);
75 }
#define u32
Definition: vga.h:21
void * priv
Driver private data.
Definition: net80211.h:798
u32 addr
Definition: sky2.h:8
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
static struct tlan_private * priv
Definition: tlan.c:224
static void rtl818x_iowrite16(struct rtl818x_priv *priv __unused, u16 *addr, u16 val)
Definition: rtl818x.h:336
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
uint32_t u32
Definition: stdint.h:23

References addr, data, mdelay(), priv, net80211_device::priv, rtl818x_iowrite16(), and u32.

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

◆ sa2400_write_phy_antenna()

static void sa2400_write_phy_antenna ( struct net80211_device dev,
short  chan 
)
static

Definition at line 77 of file rtl8180_sa2400.c.

78 {
79  struct rtl818x_priv *priv = dev->priv;
80  u8 ant = SA2400_ANTENNA;
81 
82  if (priv->rfparam & RF_PARAM_ANTBDEFAULT)
83  ant |= BB_ANTENNA_B;
84 
85  if (chan == 14)
86  ant |= BB_ANTATTEN_CHAN14;
87 
88  rtl818x_write_phy(dev, 0x10, ant);
89 
90 }
void rtl818x_write_phy(struct net80211_device *dev, u8 addr, u32 data)
Definition: rtl818x.c:46
#define BB_ANTENNA_B
Definition: rtl818x.h:205
#define SA2400_ANTENNA
void * priv
Driver private data.
Definition: net80211.h:798
#define BB_ANTATTEN_CHAN14
Definition: rtl818x.h:204
static struct tlan_private * priv
Definition: tlan.c:224
#define RF_PARAM_ANTBDEFAULT
Definition: rtl818x.h:200
uint8_t u8
Definition: stdint.h:19

References BB_ANTATTEN_CHAN14, BB_ANTENNA_B, priv, net80211_device::priv, RF_PARAM_ANTBDEFAULT, rtl818x_write_phy(), and SA2400_ANTENNA.

Referenced by sa2400_rf_init(), and sa2400_rf_set_channel().

◆ sa2400_rf_set_channel()

static void sa2400_rf_set_channel ( struct net80211_device dev,
struct net80211_channel channelp 
)
static

Definition at line 92 of file rtl8180_sa2400.c.

94 {
95  struct rtl818x_priv *priv = dev->priv;
96  int channel = channelp->channel_nr;
97  u32 txpw = priv->txpower[channel - 1] & 0xFF;
98  u32 chan = sa2400_chan[channel - 1];
99 
100  write_sa2400(dev, 7, txpw);
101 
103 
104  write_sa2400(dev, 0, chan);
105  write_sa2400(dev, 1, 0xbb50);
106  write_sa2400(dev, 2, 0x80);
107  write_sa2400(dev, 3, 0);
108 }
static void sa2400_write_phy_antenna(struct net80211_device *dev, short chan)
static void write_sa2400(struct net80211_device *dev, u8 addr, u32 data)
uint32_t channel
RNDIS channel.
Definition: netvsc.h:14
void * priv
Driver private data.
Definition: net80211.h:798
static struct tlan_private * priv
Definition: tlan.c:224
u8 channel_nr
A channel number interpreted according to the band.
Definition: net80211.h:405
uint32_t u32
Definition: stdint.h:23
static const u32 sa2400_chan[]

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

◆ sa2400_rf_stop()

static void sa2400_rf_stop ( struct net80211_device dev)
static

Definition at line 110 of file rtl8180_sa2400.c.

111 {
112  write_sa2400(dev, 4, 0);
113 }
static void write_sa2400(struct net80211_device *dev, u8 addr, u32 data)

References write_sa2400().

◆ sa2400_rf_init()

static void sa2400_rf_init ( struct net80211_device dev)
static

Definition at line 115 of file rtl8180_sa2400.c.

116 {
117  struct rtl818x_priv *priv = dev->priv;
118  u32 anaparam, txconf;
119  u8 firdac;
120  int analogphy = priv->rfparam & RF_PARAM_ANALOGPHY;
121 
122  anaparam = priv->anaparam;
126 
127  if (analogphy) {
129  firdac = 0;
130  } else {
133  firdac = 1 << SA2400_REG4_FIRDAC_SHIFT;
134  }
135 
137 
138  write_sa2400(dev, 0, sa2400_chan[0]);
139  write_sa2400(dev, 1, 0xbb50);
140  write_sa2400(dev, 2, 0x80);
141  write_sa2400(dev, 3, 0);
142  write_sa2400(dev, 4, 0x19340 | firdac);
143  write_sa2400(dev, 5, 0x1dfb | (SA2400_MAX_SENS - 54) << 15);
144  write_sa2400(dev, 4, 0x19348 | firdac); /* calibrate VCO */
145 
146  if (!analogphy)
147  write_sa2400(dev, 4, 0x1938c); /*???*/
148 
149  write_sa2400(dev, 4, 0x19340 | firdac);
150 
151  write_sa2400(dev, 0, sa2400_chan[0]);
152  write_sa2400(dev, 1, 0xbb50);
153  write_sa2400(dev, 2, 0x80);
154  write_sa2400(dev, 3, 0);
155  write_sa2400(dev, 4, 0x19344 | firdac); /* calibrate filter */
156 
157  /* new from rtl8180 embedded driver (rtl8181 project) */
158  write_sa2400(dev, 6, 0x13ff | (1 << 23)); /* MANRX */
159  write_sa2400(dev, 8, 0); /* VCO */
160 
161  if (analogphy) {
163  (1 << ANAPARAM_TXDACOFF_SHIFT));
164 
165  txconf = rtl818x_ioread32(priv, &priv->map->TX_CONF);
166  rtl818x_iowrite32(priv, &priv->map->TX_CONF,
168 
169  write_sa2400(dev, 4, 0x19341); /* calibrates DC */
170 
171  /* a 5us delay is required here,
172  * we rely on the 3ms delay introduced in write_sa2400 */
173 
174  write_sa2400(dev, 4, 0x19345);
175 
176  /* a 20us delay is required here,
177  * we rely on the 3ms delay introduced in write_sa2400 */
178 
179  rtl818x_iowrite32(priv, &priv->map->TX_CONF, txconf);
180 
182  }
183  /* end new code */
184 
185  write_sa2400(dev, 4, 0x19341 | firdac); /* RTX MODE */
186 
187  /* baseband configuration */
188  rtl818x_write_phy(dev, 0, 0x98);
189  rtl818x_write_phy(dev, 3, 0x38);
190  rtl818x_write_phy(dev, 4, 0xe0);
191  rtl818x_write_phy(dev, 5, 0x90);
192  rtl818x_write_phy(dev, 6, 0x1a);
193  rtl818x_write_phy(dev, 7, 0x64);
194 
195  sa2400_write_phy_antenna(dev, 1);
196 
197  rtl818x_write_phy(dev, 0x11, 0x80);
198 
199  if (rtl818x_ioread8(priv, &priv->map->CONFIG2) &
201  rtl818x_write_phy(dev, 0x12, 0xc7); /* enable ant diversity */
202  else
203  rtl818x_write_phy(dev, 0x12, 0x47); /* disable ant diversity */
204 
205  rtl818x_write_phy(dev, 0x13, 0x90 | priv->csthreshold);
206 
207  rtl818x_write_phy(dev, 0x19, 0x0);
208  rtl818x_write_phy(dev, 0x1a, 0xa0);
209 }
#define SA2400_DIG_ANAPARAM_PWR1_ON
void rtl818x_write_phy(struct net80211_device *dev, u8 addr, u32 data)
Definition: rtl818x.c:46
static u8 rtl818x_ioread8(struct rtl818x_priv *priv __unused, u8 *addr)
Definition: rtl818x.h:315
static void sa2400_write_phy_antenna(struct net80211_device *dev, short chan)
#define SA2400_MAX_SENS
static void write_sa2400(struct net80211_device *dev, u8 addr, u32 data)
static void rtl818x_iowrite32(struct rtl818x_priv *priv __unused, u32 *addr, u32 val)
Definition: rtl818x.h:342
#define ANAPARAM_PWR0_SHIFT
Definition: rtl818x.h:213
#define ANAPARAM_PWR1_MASK
Definition: rtl818x.h:216
#define RTL818X_TX_CONF_LOOPBACK_CONT
Definition: rtl818x.h:69
void * priv
Driver private data.
Definition: net80211.h:798
#define ANAPARAM_PWR1_SHIFT
Definition: rtl818x.h:215
#define SA2400_ANAPARAM_PWR0_ON
#define ANAPARAM_PWR0_MASK
Definition: rtl818x.h:214
#define SA2400_REG4_FIRDAC_SHIFT
static struct tlan_private * priv
Definition: tlan.c:224
#define SA2400_ANA_ANAPARAM_PWR1_ON
u32 anaparam
Definition: rtl818x.h:307
void rtl818x_set_anaparam(struct rtl818x_priv *priv, u32 anaparam)
Definition: rtl818x.c:219
#define RF_PARAM_ANALOGPHY
Definition: rtl818x.h:199
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
#define ANAPARAM_TXDACOFF_SHIFT
Definition: rtl818x.h:212
#define RTL818X_CONFIG2_ANTENNA_DIV
Definition: rtl818x.h:114
static u32 rtl818x_ioread32(struct rtl818x_priv *priv __unused, u32 *addr)
Definition: rtl818x.h:325
static const u32 sa2400_chan[]

References rtl818x_priv::anaparam, ANAPARAM_PWR0_MASK, ANAPARAM_PWR0_SHIFT, ANAPARAM_PWR1_MASK, ANAPARAM_PWR1_SHIFT, ANAPARAM_TXDACOFF_SHIFT, priv, net80211_device::priv, RF_PARAM_ANALOGPHY, 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(), and write_sa2400().

Variable Documentation

◆ sa2400_chan

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().

◆ __rtl818x_rf_driver

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,
}
static void sa2400_rf_init(struct net80211_device *dev)
static void sa2400_rf_set_channel(struct net80211_device *dev, struct net80211_channel *channelp)
static void sa2400_rf_stop(struct net80211_device *dev)

Definition at line 211 of file rtl8180_sa2400.c.