iPXE
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)
 FILE_SECBOOT (FORBIDDEN)
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 32 of file rtl8180_sa2400.c.

Referenced by sa2400_write_phy_antenna().

◆ SA2400_DIG_ANAPARAM_PWR1_ON

#define SA2400_DIG_ANAPARAM_PWR1_ON   0x8

Definition at line 33 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().

◆ SA2400_ANA_ANAPARAM_PWR1_ON

#define SA2400_ANA_ANAPARAM_PWR1_ON   0x28

Definition at line 34 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().

◆ SA2400_ANAPARAM_PWR0_ON

#define SA2400_ANAPARAM_PWR0_ON   0x3

Definition at line 35 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().

◆ SA2400_MAX_SENS

#define SA2400_MAX_SENS   85

Definition at line 38 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().

◆ SA2400_REG4_FIRDAC_SHIFT

#define SA2400_REG4_FIRDAC_SHIFT   7

Definition at line 40 of file rtl8180_sa2400.c.

Referenced by sa2400_rf_init().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_ONLY )

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN )

◆ write_sa2400()

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

Definition at line 59 of file rtl8180_sa2400.c.

60{
61 struct rtl818x_priv *priv = dev->priv;
62 u32 phy_config;
63
64 /* MAC will bang bits to the sa2400. sw 3-wire is NOT used */
65 phy_config = 0xb0000000;
66
67 phy_config |= ((u32)(addr & 0xf)) << 24;
68 phy_config |= data & 0xffffff;
69
70 /* This was originally a 32-bit write to a typecast
71 RFPinsOutput, but gcc complained about aliasing rules. -JBO */
72 rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, phy_config & 0xffff);
73 rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, phy_config >> 16);
74
75 mdelay(3);
76}
uint32_t addr
Buffer address.
Definition dwmac.h:9
uint8_t data[48]
Additional event data.
Definition ena.h:11
static void rtl818x_iowrite16(struct rtl818x_priv *priv __unused, u16 *addr, u16 val)
Definition rtl818x.h:337
void * priv
Driver private data.
Definition net80211.h:798
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79
static struct tlan_private * priv
Definition tlan.c:225
#define u32
Definition vga.h:21

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

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

◆ sa2400_write_phy_antenna()

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

Definition at line 78 of file rtl8180_sa2400.c.

79{
80 struct rtl818x_priv *priv = dev->priv;
81 u8 ant = SA2400_ANTENNA;
82
83 if (priv->rfparam & RF_PARAM_ANTBDEFAULT)
84 ant |= BB_ANTENNA_B;
85
86 if (chan == 14)
87 ant |= BB_ANTATTEN_CHAN14;
88
89 rtl818x_write_phy(dev, 0x10, ant);
90
91}
#define u8
Definition igbvf_osdep.h:40
#define SA2400_ANTENNA
void rtl818x_write_phy(struct net80211_device *dev, u8 addr, u32 data)
Definition rtl818x.c:48
#define BB_ANTATTEN_CHAN14
Definition rtl818x.h:205
#define BB_ANTENNA_B
Definition rtl818x.h:206
#define RF_PARAM_ANTBDEFAULT
Definition rtl818x.h:201

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

Referenced by sa2400_rf_init(), and sa2400_rf_set_channel().

◆ sa2400_rf_set_channel()

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

Definition at line 93 of file rtl8180_sa2400.c.

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

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

◆ sa2400_rf_stop()

void sa2400_rf_stop ( struct net80211_device * dev)
static

Definition at line 111 of file rtl8180_sa2400.c.

112{
113 write_sa2400(dev, 4, 0);
114}

References write_sa2400().

◆ sa2400_rf_init()

void sa2400_rf_init ( struct net80211_device * dev)
static

Definition at line 116 of file rtl8180_sa2400.c.

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

References rtl818x_priv::anaparam, ANAPARAM_PWR0_MASK, ANAPARAM_PWR0_SHIFT, ANAPARAM_PWR1_MASK, ANAPARAM_PWR1_SHIFT, ANAPARAM_TXDACOFF_SHIFT, net80211_device::priv, 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(), u32, u8, 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 42 of file rtl8180_sa2400.c.

42 {
43 0x00096c, /* ch1 */
44 0x080970,
45 0x100974,
46 0x180978,
47 0x000980,
48 0x080984,
49 0x100988,
50 0x18098c,
51 0x000994,
52 0x080998,
53 0x10099c,
54 0x1809a0,
55 0x0009a8,
56 0x0009b4, /* ch 14 */
57};

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

Definition at line 212 of file rtl8180_sa2400.c.

212 {
213 .name = "Philips SA2400",
214 .id = 3,
215 .init = sa2400_rf_init,
216 .stop = sa2400_rf_stop,
217 .set_chan = sa2400_rf_set_channel
218};