iPXE
Macros | Functions | Variables
rtl8180_grf5101.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 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
 

Macro Definition Documentation

◆ GRF5101_ANTENNA

#define GRF5101_ANTENNA   0xA3

Definition at line 31 of file rtl8180_grf5101.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_ONLY  )

◆ write_grf5101()

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

Definition at line 40 of file rtl8180_grf5101.c.

41 {
42  struct rtl818x_priv *priv = dev->priv;
43  u32 phy_config;
44 
45  phy_config = grf5101_encode[(data >> 8) & 0xF];
46  phy_config |= grf5101_encode[(data >> 4) & 0xF] << 4;
47  phy_config |= grf5101_encode[data & 0xF] << 8;
48  phy_config |= grf5101_encode[(addr >> 1) & 0xF] << 12;
49  phy_config |= (addr & 1) << 16;
50  phy_config |= grf5101_encode[(data & 0xf000) >> 12] << 24;
51 
52  /* MAC will bang bits to the chip */
53  phy_config |= 0x90000000;
54 
55  /* This was originally a 32-bit write to a typecast
56  RFPinsOutput, but gcc complained about aliasing rules. -JBO */
57  rtl818x_iowrite16(priv, &priv->map->RFPinsOutput, phy_config & 0xffff);
58  rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, phy_config >> 16);
59 
60  mdelay(3);
61 }
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
uint8_t data[48]
Additional event data.
Definition: ena.h:22
static void rtl818x_iowrite16(struct rtl818x_priv *priv __unused, u16 *addr, u16 val)
Definition: rtl818x.h:336
static const int grf5101_encode[]
uint32_t u32
Definition: stdint.h:23

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

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

◆ grf5101_write_phy_antenna()

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

Definition at line 63 of file rtl8180_grf5101.c.

64 {
65  struct rtl818x_priv *priv = dev->priv;
66  u8 ant = GRF5101_ANTENNA;
67 
68  if (priv->rfparam & RF_PARAM_ANTBDEFAULT)
69  ant |= BB_ANTENNA_B;
70 
71  if (chan == 14)
72  ant |= BB_ANTATTEN_CHAN14;
73 
74  rtl818x_write_phy(dev, 0x10, ant);
75 }
void rtl818x_write_phy(struct net80211_device *dev, u8 addr, u32 data)
Definition: rtl818x.c:46
#define BB_ANTENNA_B
Definition: rtl818x.h:205
void * priv
Driver private data.
Definition: net80211.h:798
#define BB_ANTATTEN_CHAN14
Definition: rtl818x.h:204
#define GRF5101_ANTENNA
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, GRF5101_ANTENNA, priv, net80211_device::priv, RF_PARAM_ANTBDEFAULT, and rtl818x_write_phy().

Referenced by grf5101_rf_init(), and grf5101_rf_set_channel().

◆ grf5101_rf_set_channel()

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

Definition at line 77 of file rtl8180_grf5101.c.

79 {
80  struct rtl818x_priv *priv = dev->priv;
81  int channel = channelp->channel_nr;
82  u32 txpw = priv->txpower[channel - 1] & 0xFF;
83  u32 chan = channel - 1;
84 
85  /* set TX power */
86  write_grf5101(dev, 0x15, 0x0);
87  write_grf5101(dev, 0x06, txpw);
88  write_grf5101(dev, 0x15, 0x10);
89  write_grf5101(dev, 0x15, 0x0);
90 
91  /* set frequency */
92  write_grf5101(dev, 0x07, 0x0);
93  write_grf5101(dev, 0x0B, chan);
94  write_grf5101(dev, 0x07, 0x1000);
95 
97 }
uint32_t channel
RNDIS channel.
Definition: netvsc.h:14
void * priv
Driver private data.
Definition: net80211.h:798
static void grf5101_write_phy_antenna(struct net80211_device *dev, short chan)
static struct tlan_private * priv
Definition: tlan.c:224
static void write_grf5101(struct net80211_device *dev, u8 addr, u32 data)
u8 channel_nr
A channel number interpreted according to the band.
Definition: net80211.h:405
uint32_t u32
Definition: stdint.h:23

References channel, net80211_channel::channel_nr, grf5101_write_phy_antenna(), priv, net80211_device::priv, and write_grf5101().

◆ grf5101_rf_stop()

static void grf5101_rf_stop ( struct net80211_device dev)
static

Definition at line 99 of file rtl8180_grf5101.c.

100 {
101  struct rtl818x_priv *priv = dev->priv;
102  u32 anaparam;
103 
104  anaparam = priv->anaparam;
105  anaparam &= 0x000fffff;
106  anaparam |= 0x3f900000;
108 
109  write_grf5101(dev, 0x07, 0x0);
110  write_grf5101(dev, 0x1f, 0x45);
111  write_grf5101(dev, 0x1f, 0x5);
112  write_grf5101(dev, 0x00, 0x8e4);
113 }
void * priv
Driver private data.
Definition: net80211.h:798
static struct tlan_private * priv
Definition: tlan.c:224
static void write_grf5101(struct net80211_device *dev, u8 addr, u32 data)
u32 anaparam
Definition: rtl818x.h:307
void rtl818x_set_anaparam(struct rtl818x_priv *priv, u32 anaparam)
Definition: rtl818x.c:219
uint32_t u32
Definition: stdint.h:23

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

◆ grf5101_rf_init()

static void grf5101_rf_init ( struct net80211_device dev)
static

Definition at line 115 of file rtl8180_grf5101.c.

116 {
117  struct rtl818x_priv *priv = dev->priv;
118 
119  rtl818x_set_anaparam(priv, priv->anaparam);
120 
121  write_grf5101(dev, 0x1f, 0x0);
122  write_grf5101(dev, 0x1f, 0x0);
123  write_grf5101(dev, 0x1f, 0x40);
124  write_grf5101(dev, 0x1f, 0x60);
125  write_grf5101(dev, 0x1f, 0x61);
126  write_grf5101(dev, 0x1f, 0x61);
127  write_grf5101(dev, 0x00, 0xae4);
128  write_grf5101(dev, 0x1f, 0x1);
129  write_grf5101(dev, 0x1f, 0x41);
130  write_grf5101(dev, 0x1f, 0x61);
131 
132  write_grf5101(dev, 0x01, 0x1a23);
133  write_grf5101(dev, 0x02, 0x4971);
134  write_grf5101(dev, 0x03, 0x41de);
135  write_grf5101(dev, 0x04, 0x2d80);
136  write_grf5101(dev, 0x05, 0x68ff); /* 0x61ff original value */
137  write_grf5101(dev, 0x06, 0x0);
138  write_grf5101(dev, 0x07, 0x0);
139  write_grf5101(dev, 0x08, 0x7533);
140  write_grf5101(dev, 0x09, 0xc401);
141  write_grf5101(dev, 0x0a, 0x0);
142  write_grf5101(dev, 0x0c, 0x1c7);
143  write_grf5101(dev, 0x0d, 0x29d3);
144  write_grf5101(dev, 0x0e, 0x2e8);
145  write_grf5101(dev, 0x10, 0x192);
146  write_grf5101(dev, 0x11, 0x248);
147  write_grf5101(dev, 0x12, 0x0);
148  write_grf5101(dev, 0x13, 0x20c4);
149  write_grf5101(dev, 0x14, 0xf4fc);
150  write_grf5101(dev, 0x15, 0x0);
151  write_grf5101(dev, 0x16, 0x1500);
152 
153  write_grf5101(dev, 0x07, 0x1000);
154 
155  /* baseband configuration */
156  rtl818x_write_phy(dev, 0, 0xa8);
157  rtl818x_write_phy(dev, 3, 0x0);
158  rtl818x_write_phy(dev, 4, 0xc0);
159  rtl818x_write_phy(dev, 5, 0x90);
160  rtl818x_write_phy(dev, 6, 0x1e);
161  rtl818x_write_phy(dev, 7, 0x64);
162 
164 
165  rtl818x_write_phy(dev, 0x11, 0x88);
166 
167  if (rtl818x_ioread8(priv, &priv->map->CONFIG2) &
169  rtl818x_write_phy(dev, 0x12, 0xc0); /* enable ant diversity */
170  else
171  rtl818x_write_phy(dev, 0x12, 0x40); /* disable ant diversity */
172 
173  rtl818x_write_phy(dev, 0x13, 0x90 | priv->csthreshold);
174 
175  rtl818x_write_phy(dev, 0x19, 0x0);
176  rtl818x_write_phy(dev, 0x1a, 0xa0);
177  rtl818x_write_phy(dev, 0x1b, 0x44);
178 }
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
void * priv
Driver private data.
Definition: net80211.h:798
static void grf5101_write_phy_antenna(struct net80211_device *dev, short chan)
static struct tlan_private * priv
Definition: tlan.c:224
static void write_grf5101(struct net80211_device *dev, u8 addr, u32 data)
void rtl818x_set_anaparam(struct rtl818x_priv *priv, u32 anaparam)
Definition: rtl818x.c:219
#define RTL818X_CONFIG2_ANTENNA_DIV
Definition: rtl818x.h:114

References grf5101_write_phy_antenna(), priv, net80211_device::priv, RTL818X_CONFIG2_ANTENNA_DIV, rtl818x_ioread8(), rtl818x_set_anaparam(), rtl818x_write_phy(), and write_grf5101().

Variable Documentation

◆ grf5101_encode

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

◆ __rtl818x_rf_driver

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,
}
static void grf5101_rf_set_channel(struct net80211_device *dev, struct net80211_channel *channelp)
static void grf5101_rf_init(struct net80211_device *dev)
static void grf5101_rf_stop(struct net80211_device *dev)

Definition at line 180 of file rtl8180_grf5101.c.