iPXE
rtl818x.h
Go to the documentation of this file.
1/*
2 * Definitions for RTL818x hardware
3 *
4 * Copyright 2007 Michael Wu <flamingice@sourmilk.net>
5 * Copyright 2007 Andrea Merello <andreamrl@tiscali.it>
6 *
7 * Modified for iPXE, June 2009, by Joshua Oreman <oremanj@rwcr.net>
8 *
9 * Based on the r8187 driver, which is:
10 * Copyright 2005 Andrea Merello <andreamrl@tiscali.it>, et al.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#ifndef RTL818X_H
18#define RTL818X_H
19
20#include <ipxe/spi_bit.h>
21#include <ipxe/tables.h>
22#include <ipxe/net80211.h>
23
24FILE_LICENCE(GPL2_ONLY);
25FILE_SECBOOT(FORBIDDEN);
26
28 u8 MAC[6];
30 u32 MAR[2];
46#define RTL818X_CMD_TX_ENABLE (1 << 2)
47#define RTL818X_CMD_RX_ENABLE (1 << 3)
48#define RTL818X_CMD_RESET (1 << 4)
52#define RTL818X_INT_RX_OK (1 << 0)
53#define RTL818X_INT_RX_ERR (1 << 1)
54#define RTL818X_INT_TXL_OK (1 << 2)
55#define RTL818X_INT_TXL_ERR (1 << 3)
56#define RTL818X_INT_RX_DU (1 << 4)
57#define RTL818X_INT_RX_FO (1 << 5)
58#define RTL818X_INT_TXN_OK (1 << 6)
59#define RTL818X_INT_TXN_ERR (1 << 7)
60#define RTL818X_INT_TXH_OK (1 << 8)
61#define RTL818X_INT_TXH_ERR (1 << 9)
62#define RTL818X_INT_TXB_OK (1 << 10)
63#define RTL818X_INT_TXB_ERR (1 << 11)
64#define RTL818X_INT_ATIM (1 << 12)
65#define RTL818X_INT_BEACON (1 << 13)
66#define RTL818X_INT_TIME_OUT (1 << 14)
67#define RTL818X_INT_TX_FO (1 << 15)
69#define RTL818X_TX_CONF_LOOPBACK_MAC (1 << 17)
70#define RTL818X_TX_CONF_LOOPBACK_CONT (3 << 17)
71#define RTL818X_TX_CONF_NO_ICV (1 << 19)
72#define RTL818X_TX_CONF_DISCW (1 << 20)
73#define RTL818X_TX_CONF_SAT_HWPLCP (1 << 24)
74#define RTL818X_TX_CONF_R8180_ABCD (2 << 25)
75#define RTL818X_TX_CONF_R8180_F (3 << 25)
76#define RTL818X_TX_CONF_R8185_ABC (4 << 25)
77#define RTL818X_TX_CONF_R8185_D (5 << 25)
78#define RTL818X_TX_CONF_R8187vD (5 << 25)
79#define RTL818X_TX_CONF_R8187vD_B (6 << 25)
80#define RTL818X_TX_CONF_HWVER_MASK (7 << 25)
81#define RTL818X_TX_CONF_DISREQQSIZE (1 << 28)
82#define RTL818X_TX_CONF_PROBE_DTS (1 << 29)
83#define RTL818X_TX_CONF_HW_SEQNUM (1 << 30)
84#define RTL818X_TX_CONF_CW_MIN (1 << 31)
86#define RTL818X_RX_CONF_MONITOR (1 << 0)
87#define RTL818X_RX_CONF_NICMAC (1 << 1)
88#define RTL818X_RX_CONF_MULTICAST (1 << 2)
89#define RTL818X_RX_CONF_BROADCAST (1 << 3)
90#define RTL818X_RX_CONF_FCS (1 << 5)
91#define RTL818X_RX_CONF_DATA (1 << 18)
92#define RTL818X_RX_CONF_CTRL (1 << 19)
93#define RTL818X_RX_CONF_MGMT (1 << 20)
94#define RTL818X_RX_CONF_ADDR3 (1 << 21)
95#define RTL818X_RX_CONF_PM (1 << 22)
96#define RTL818X_RX_CONF_BSSID (1 << 23)
97#define RTL818X_RX_CONF_RX_AUTORESETPHY (1 << 28)
98#define RTL818X_RX_CONF_CSDM1 (1 << 29)
99#define RTL818X_RX_CONF_CSDM2 (1 << 30)
100#define RTL818X_RX_CONF_ONLYERLPKT (1 << 31)
104#define RTL818X_EEPROM_CMD_READ (1 << 0)
105#define RTL818X_EEPROM_CMD_WRITE (1 << 1)
106#define RTL818X_EEPROM_CMD_CK (1 << 2)
107#define RTL818X_EEPROM_CMD_CS (1 << 3)
108#define RTL818X_EEPROM_CMD_NORMAL (0 << 6)
109#define RTL818X_EEPROM_CMD_LOAD (1 << 6)
110#define RTL818X_EEPROM_CMD_PROGRAM (2 << 6)
111#define RTL818X_EEPROM_CMD_CONFIG (3 << 6)
115#define RTL818X_CONFIG2_ANTENNA_DIV (1 << 6)
118#define RTL818X_MSR_NO_LINK (0 << 2)
119#define RTL818X_MSR_ADHOC (1 << 2)
120#define RTL818X_MSR_INFRA (2 << 2)
121#define RTL818X_MSR_MASTER (3 << 2)
122#define RTL818X_MSR_ENEDCA (4 << 2)
124#define RTL818X_CONFIG3_ANAPARAM_WRITE (1 << 6)
125#define RTL818X_CONFIG3_GNT_SELECT (1 << 7)
127#define RTL818X_CONFIG4_POWEROFF (1 << 6)
128#define RTL818X_CONFIG4_VCOOFF (1 << 7)
142 u8 PHY[4];
155#define RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT (1 << 0)
156#define RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT (1 << 1)
157#define RTL818X_TX_AGC_CTL_FEEDBACK_ANT (1 << 2)
169#define RTL818X_CW_CONF_PERPACKET_CW_SHIFT (1 << 0)
170#define RTL818X_CW_CONF_PERPACKET_RETRY_SHIFT (1 << 1)
173#define RTL818X_RATE_FALLBACK_ENABLE (1 << 7)
183/* RTL818X_R8187B_*: magic numbers from ioregisters */
184#define RTL818X_R8187B_B 0
185#define RTL818X_R8187B_D 1
186#define RTL818X_R8187B_E 2
196} __attribute__((packed));
197
198#define MAX_RX_SIZE IEEE80211_MAX_FRAME_LEN
199
200#define RF_PARAM_ANALOGPHY (1 << 0)
201#define RF_PARAM_ANTBDEFAULT (1 << 1)
202#define RF_PARAM_CARRIERSENSE1 (1 << 2)
203#define RF_PARAM_CARRIERSENSE2 (1 << 3)
204
205#define BB_ANTATTEN_CHAN14 0x0C
206#define BB_ANTENNA_B 0x40
207
208#define BB_HOST_BANG (1 << 30)
209#define BB_HOST_BANG_EN (1 << 2)
210#define BB_HOST_BANG_CLK (1 << 1)
211#define BB_HOST_BANG_DATA 1
212
213#define ANAPARAM_TXDACOFF_SHIFT 27
214#define ANAPARAM_PWR0_SHIFT 28
215#define ANAPARAM_PWR0_MASK (0x07 << ANAPARAM_PWR0_SHIFT)
216#define ANAPARAM_PWR1_SHIFT 20
217#define ANAPARAM_PWR1_MASK (0x7F << ANAPARAM_PWR1_SHIFT)
218
219#define RTL818X_RX_RING_SIZE 8 /* doesn't have to be a power of 2 */
220#define RTL818X_TX_RING_SIZE 8 /* nor this [but 2^n is very slightly faster] */
221#define RTL818X_RING_ALIGN 256
222
223#define RTL818X_MAX_RETRIES 4
224
238
252
271
275 union {
278 };
279} __attribute__ ((packed));
280
283 const struct rtl818x_rf_ops *rf;
284 int rf_flag; /* whatever RF driver wishes to use it for */
287
290
293 unsigned int rx_idx; /* next desc to be filled by card */
295
298 unsigned int tx_cons; /* next desc to be filled by card */
299 unsigned int tx_prod; /* next desc to be filled by driver */
301
304
306
307 int r8185;
311};
312
314void rtl818x_set_anaparam(struct rtl818x_priv *priv, u32 anaparam);
315
317{
318 return inb(addr);
319}
320
322{
323 return inw(addr);
324}
325
327{
328 return inl(addr);
329}
330
331static inline void rtl818x_iowrite8(struct rtl818x_priv *priv __unused,
332 u8 *addr, u8 val)
333{
334 outb(val, addr);
335}
336
337static inline void rtl818x_iowrite16(struct rtl818x_priv *priv __unused,
338 u16 *addr, u16 val)
339{
340 outw(val, addr);
341}
342
343static inline void rtl818x_iowrite32(struct rtl818x_priv *priv __unused,
344 u32 *addr, u32 val)
345{
346 outl(val, addr);
347}
348
349#define RTL818X_RF_DRIVERS __table(struct rtl818x_rf_ops, "rtl818x_rf_drivers")
350#define __rtl818x_rf_driver __table_entry(RTL818X_RF_DRIVERS, 01)
351
353 char *name;
354 u8 id; /* as identified in EEPROM */
355 void (*init)(struct net80211_device *dev);
356 void (*stop)(struct net80211_device *dev);
357 void (*set_chan)(struct net80211_device *dev, struct net80211_channel *chan);
358 void (*conf_erp)(struct net80211_device *dev); /* set based on dev->erp_flags */
359};
360
361extern int rtl818x_probe(struct pci_device *pdev );
362extern void rtl818x_remove(struct pci_device *pdev);
363
364#endif /* RTL818X_H */
uint32_t addr
Buffer address.
Definition dwmac.h:9
uint8_t data[48]
Additional event data.
Definition ena.h:11
#define __unused
Declare a variable or data structure as unused.
Definition compiler.h:573
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define u8
Definition igbvf_osdep.h:40
#define __attribute__(x)
Definition compiler.h:10
#define inw(io_addr)
Definition io.h:292
#define outb(data, io_addr)
Definition io.h:310
#define outw(data, io_addr)
Definition io.h:320
#define inl(io_addr)
Definition io.h:301
#define outl(data, io_addr)
Definition io.h:330
#define inb(io_addr)
Definition io.h:283
void __asmcall int val
Definition setjmp.h:12
uint64_t u64
Definition stdint.h:26
The iPXE 802.11 MAC layer.
int rtl818x_probe(struct pci_device *pdev)
Definition rtl818x.c:654
void rtl818x_remove(struct pci_device *pdev)
Definition rtl818x.c:829
rtl818x_tx_desc_flags
Definition rtl818x.h:225
@ RTL818X_TX_DESC_FLAG_RTS
Definition rtl818x.h:232
@ RTL818X_TX_DESC_FLAG_CTS
Definition rtl818x.h:231
@ RTL818X_TX_DESC_FLAG_NO_ENC
Definition rtl818x.h:226
@ RTL818X_TX_DESC_FLAG_RX_UNDER
Definition rtl818x.h:229
@ RTL818X_TX_DESC_FLAG_LS
Definition rtl818x.h:233
@ RTL818X_TX_DESC_FLAG_TX_OK
Definition rtl818x.h:227
@ RTL818X_TX_DESC_FLAG_FS
Definition rtl818x.h:234
@ RTL818X_TX_DESC_FLAG_SPLCP
Definition rtl818x.h:228
@ RTL818X_TX_DESC_FLAG_OWN
Definition rtl818x.h:236
@ RTL818X_TX_DESC_FLAG_DMA
Definition rtl818x.h:235
@ RTL818X_TX_DESC_FLAG_MOREFRAG
Definition rtl818x.h:230
static void rtl818x_iowrite8(struct rtl818x_priv *priv __unused, u8 *addr, u8 val)
Definition rtl818x.h:331
#define RTL818X_TX_RING_SIZE
Definition rtl818x.h:220
rtl818x_rx_desc_flags
Definition rtl818x.h:253
@ RTL818X_RX_DESC_FLAG_SPLCP
Definition rtl818x.h:263
@ RTL818X_RX_DESC_FLAG_FOF
Definition rtl818x.h:264
@ RTL818X_RX_DESC_FLAG_QOS
Definition rtl818x.h:261
@ RTL818X_RX_DESC_FLAG_RX_ERR
Definition rtl818x.h:257
@ RTL818X_RX_DESC_FLAG_PM
Definition rtl818x.h:256
@ RTL818X_RX_DESC_FLAG_MCAST
Definition rtl818x.h:260
@ RTL818X_RX_DESC_FLAG_BCAST
Definition rtl818x.h:258
@ RTL818X_RX_DESC_FLAG_FS
Definition rtl818x.h:267
@ RTL818X_RX_DESC_FLAG_OWN
Definition rtl818x.h:269
@ RTL818X_RX_DESC_FLAG_EOR
Definition rtl818x.h:268
@ RTL818X_RX_DESC_FLAG_DMA_FAIL
Definition rtl818x.h:265
@ RTL818X_RX_DESC_FLAG_CRC32_ERR
Definition rtl818x.h:255
@ RTL818X_RX_DESC_FLAG_PAM
Definition rtl818x.h:259
@ RTL818X_RX_DESC_FLAG_ICV_ERR
Definition rtl818x.h:254
@ RTL818X_RX_DESC_FLAG_TRSW
Definition rtl818x.h:262
@ RTL818X_RX_DESC_FLAG_LS
Definition rtl818x.h:266
void rtl818x_write_phy(struct net80211_device *dev, u8 addr, u32 data)
Definition rtl818x.c:48
static u8 rtl818x_ioread8(struct rtl818x_priv *priv __unused, u8 *addr)
Definition rtl818x.h:316
void rtl818x_set_anaparam(struct rtl818x_priv *priv, u32 anaparam)
Definition rtl818x.c:221
static void rtl818x_iowrite16(struct rtl818x_priv *priv __unused, u16 *addr, u16 val)
Definition rtl818x.h:337
static void rtl818x_iowrite32(struct rtl818x_priv *priv __unused, u32 *addr, u32 val)
Definition rtl818x.h:343
static u16 rtl818x_ioread16(struct rtl818x_priv *priv __unused, u16 *addr)
Definition rtl818x.h:321
#define RTL818X_RX_RING_SIZE
Definition rtl818x.h:219
static u32 rtl818x_ioread32(struct rtl818x_priv *priv __unused, u32 *addr)
Definition rtl818x.h:326
SPI bit-bashing interface.
A persistent I/O buffer.
Definition iobuf.h:38
An 802.11 RF channel.
Definition net80211.h:386
Structure encapsulating the complete state of an 802.11 device.
Definition net80211.h:787
A PCI device.
Definition pci.h:211
struct device dev
Generic device.
Definition pci.h:213
u8 EEPROM_CMD
Definition rtl818x.h:103
u16 ATIM_WND
Definition rtl818x.h:136
u8 CARRIER_SENSE_COUNTER
Definition rtl818x.h:140
u16 INT_STATUS
Definition rtl818x.h:51
u8 RATE_FALLBACK
Definition rtl818x.h:172
u16 TID_AC_MAP
Definition rtl818x.h:188
u16 RFPinsOutput
Definition rtl818x.h:143
u8 reserved_4[4]
Definition rtl818x.h:49
u8 reserved_17[24]
Definition rtl818x.h:175
u16 INT_MASK
Definition rtl818x.h:50
u32 RF_TIMING
Definition rtl818x.h:148
u32 HSSI_PARA
Definition rtl818x.h:152
u32 RF_PARA
Definition rtl818x.h:147
u16 TALLY_CNT
Definition rtl818x.h:194
u8 reserved_18[2]
Definition rtl818x.h:178
u32 TNPDA
Definition rtl818x.h:38
u16 BEACON_INTERVAL
Definition rtl818x.h:135
u8 reserved_21[5]
Definition rtl818x.h:191
u8 BSSID[6]
Definition rtl818x.h:41
u8 TX_ANTENNA
Definition rtl818x.h:160
u8 TX_DMA_POLLING
Definition rtl818x.h:177
u32 TLPDA
Definition rtl818x.h:37
u8 reserved_12[2]
Definition rtl818x.h:151
u8 TX_GAIN_OFDM
Definition rtl818x.h:159
u8 reserved_22[4]
Definition rtl818x.h:193
u32 INT_TIMEOUT
Definition rtl818x.h:101
u32 ANAPARAM2
Definition rtl818x.h:133
u8 RESP_RATE
Definition rtl818x.h:42
u8 reserved_14[16]
Definition rtl818x.h:161
u16 RFPinsSelect
Definition rtl818x.h:145
u32 THPDA
Definition rtl818x.h:39
u32 TSFT[2]
Definition rtl818x.h:36
u8 reserved_3[1]
Definition rtl818x.h:44
u8 reserved_2[4]
Definition rtl818x.h:35
u8 reserved_9[2]
Definition rtl818x.h:130
u8 reserved_16[5]
Definition rtl818x.h:167
u8 PHY[4]
Definition rtl818x.h:142
u32 MAR[2]
Definition rtl818x.h:30
u16 INT_MIG
Definition rtl818x.h:182
u32 TX_CONF
Definition rtl818x.h:68
u32 RX_CONF
Definition rtl818x.h:85
u8 reserved_1
Definition rtl818x.h:32
u32 ANAPARAM
Definition rtl818x.h:116
u8 TX_FIFO_COUNT
Definition rtl818x.h:33
u8 TX_GAIN_CCK
Definition rtl818x.h:158
u8 reserved_13[4]
Definition rtl818x.h:153
u8 reserved_11[2]
Definition rtl818x.h:141
u16 RFPinsEnable
Definition rtl818x.h:144
u8 reserved_20[4]
Definition rtl818x.h:189
u8 MAC[6]
Definition rtl818x.h:28
u8 reserved_15[3]
Definition rtl818x.h:163
u8 reserved_19[3]
Definition rtl818x.h:181
u16 ATIMTR_INTERVAL
Definition rtl818x.h:138
u16 RFPinsInput
Definition rtl818x.h:146
u8 reserved_0[2]
Definition rtl818x.h:29
u16 BEACON_INTERVAL_TIME
Definition rtl818x.h:137
u8 TX_AGC_CTL
Definition rtl818x.h:154
u8 ACM_CONTROL
Definition rtl818x.h:174
u8 RX_FIFO_COUNT
Definition rtl818x.h:31
u8 reserved_10[12]
Definition rtl818x.h:134
struct rtl818x_rx_desc * rx_ring
Definition rtl818x.h:291
unsigned int tx_prod
Definition rtl818x.h:299
struct io_buffer * rx_buf[RTL818X_RX_RING_SIZE]
Definition rtl818x.h:294
struct spi_bit_basher spibit
Definition rtl818x.h:288
struct pci_device * pdev
Definition rtl818x.h:302
const struct rtl818x_rf_ops * rf
Definition rtl818x.h:283
struct rtl818x_csr * map
Definition rtl818x.h:282
u16 txpower[14]
Definition rtl818x.h:305
u32 tx_ring_dma
Definition rtl818x.h:297
unsigned int rx_idx
Definition rtl818x.h:293
struct io_buffer * tx_buf[RTL818X_TX_RING_SIZE]
Definition rtl818x.h:300
struct spi_device eeprom
Definition rtl818x.h:289
struct rtl818x_tx_desc * tx_ring
Definition rtl818x.h:296
u32 rx_ring_dma
Definition rtl818x.h:292
unsigned int tx_cons
Definition rtl818x.h:298
int hw_rtscts_rate
Definition rtl818x.h:286
void(* stop)(struct net80211_device *dev)
Definition rtl818x.h:356
void(* init)(struct net80211_device *dev)
Definition rtl818x.h:355
char * name
Definition rtl818x.h:353
void(* conf_erp)(struct net80211_device *dev)
Definition rtl818x.h:358
void(* set_chan)(struct net80211_device *dev, struct net80211_channel *chan)
Definition rtl818x.h:357
u32 reserved[2]
Definition rtl818x.h:250
A bit-bashing SPI bus.
Definition spi_bit.h:17
An SPI device.
Definition spi.h:87
Linker tables.
static struct tlan_private * priv
Definition tlan.c:225
#define u16
Definition vga.h:20
#define u32
Definition vga.h:21