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 
24 FILE_LICENCE(GPL2_ONLY);
25 
26 struct rtl818x_csr {
27  u8 MAC[6];
29  u32 MAR[2];
35  u32 TSFT[2];
40  u8 BSSID[6];
45 #define RTL818X_CMD_TX_ENABLE (1 << 2)
46 #define RTL818X_CMD_RX_ENABLE (1 << 3)
47 #define RTL818X_CMD_RESET (1 << 4)
51 #define RTL818X_INT_RX_OK (1 << 0)
52 #define RTL818X_INT_RX_ERR (1 << 1)
53 #define RTL818X_INT_TXL_OK (1 << 2)
54 #define RTL818X_INT_TXL_ERR (1 << 3)
55 #define RTL818X_INT_RX_DU (1 << 4)
56 #define RTL818X_INT_RX_FO (1 << 5)
57 #define RTL818X_INT_TXN_OK (1 << 6)
58 #define RTL818X_INT_TXN_ERR (1 << 7)
59 #define RTL818X_INT_TXH_OK (1 << 8)
60 #define RTL818X_INT_TXH_ERR (1 << 9)
61 #define RTL818X_INT_TXB_OK (1 << 10)
62 #define RTL818X_INT_TXB_ERR (1 << 11)
63 #define RTL818X_INT_ATIM (1 << 12)
64 #define RTL818X_INT_BEACON (1 << 13)
65 #define RTL818X_INT_TIME_OUT (1 << 14)
66 #define RTL818X_INT_TX_FO (1 << 15)
68 #define RTL818X_TX_CONF_LOOPBACK_MAC (1 << 17)
69 #define RTL818X_TX_CONF_LOOPBACK_CONT (3 << 17)
70 #define RTL818X_TX_CONF_NO_ICV (1 << 19)
71 #define RTL818X_TX_CONF_DISCW (1 << 20)
72 #define RTL818X_TX_CONF_SAT_HWPLCP (1 << 24)
73 #define RTL818X_TX_CONF_R8180_ABCD (2 << 25)
74 #define RTL818X_TX_CONF_R8180_F (3 << 25)
75 #define RTL818X_TX_CONF_R8185_ABC (4 << 25)
76 #define RTL818X_TX_CONF_R8185_D (5 << 25)
77 #define RTL818X_TX_CONF_R8187vD (5 << 25)
78 #define RTL818X_TX_CONF_R8187vD_B (6 << 25)
79 #define RTL818X_TX_CONF_HWVER_MASK (7 << 25)
80 #define RTL818X_TX_CONF_DISREQQSIZE (1 << 28)
81 #define RTL818X_TX_CONF_PROBE_DTS (1 << 29)
82 #define RTL818X_TX_CONF_HW_SEQNUM (1 << 30)
83 #define RTL818X_TX_CONF_CW_MIN (1 << 31)
85 #define RTL818X_RX_CONF_MONITOR (1 << 0)
86 #define RTL818X_RX_CONF_NICMAC (1 << 1)
87 #define RTL818X_RX_CONF_MULTICAST (1 << 2)
88 #define RTL818X_RX_CONF_BROADCAST (1 << 3)
89 #define RTL818X_RX_CONF_FCS (1 << 5)
90 #define RTL818X_RX_CONF_DATA (1 << 18)
91 #define RTL818X_RX_CONF_CTRL (1 << 19)
92 #define RTL818X_RX_CONF_MGMT (1 << 20)
93 #define RTL818X_RX_CONF_ADDR3 (1 << 21)
94 #define RTL818X_RX_CONF_PM (1 << 22)
95 #define RTL818X_RX_CONF_BSSID (1 << 23)
96 #define RTL818X_RX_CONF_RX_AUTORESETPHY (1 << 28)
97 #define RTL818X_RX_CONF_CSDM1 (1 << 29)
98 #define RTL818X_RX_CONF_CSDM2 (1 << 30)
99 #define RTL818X_RX_CONF_ONLYERLPKT (1 << 31)
103 #define RTL818X_EEPROM_CMD_READ (1 << 0)
104 #define RTL818X_EEPROM_CMD_WRITE (1 << 1)
105 #define RTL818X_EEPROM_CMD_CK (1 << 2)
106 #define RTL818X_EEPROM_CMD_CS (1 << 3)
107 #define RTL818X_EEPROM_CMD_NORMAL (0 << 6)
108 #define RTL818X_EEPROM_CMD_LOAD (1 << 6)
109 #define RTL818X_EEPROM_CMD_PROGRAM (2 << 6)
110 #define RTL818X_EEPROM_CMD_CONFIG (3 << 6)
114 #define RTL818X_CONFIG2_ANTENNA_DIV (1 << 6)
117 #define RTL818X_MSR_NO_LINK (0 << 2)
118 #define RTL818X_MSR_ADHOC (1 << 2)
119 #define RTL818X_MSR_INFRA (2 << 2)
120 #define RTL818X_MSR_MASTER (3 << 2)
121 #define RTL818X_MSR_ENEDCA (4 << 2)
123 #define RTL818X_CONFIG3_ANAPARAM_WRITE (1 << 6)
124 #define RTL818X_CONFIG3_GNT_SELECT (1 << 7)
126 #define RTL818X_CONFIG4_POWEROFF (1 << 6)
127 #define RTL818X_CONFIG4_VCOOFF (1 << 7)
141  u8 PHY[4];
154 #define RTL818X_TX_AGC_CTL_PERPACKET_GAIN_SHIFT (1 << 0)
155 #define RTL818X_TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT (1 << 1)
156 #define RTL818X_TX_AGC_CTL_FEEDBACK_ANT (1 << 2)
168 #define RTL818X_CW_CONF_PERPACKET_CW_SHIFT (1 << 0)
169 #define RTL818X_CW_CONF_PERPACKET_RETRY_SHIFT (1 << 1)
172 #define RTL818X_RATE_FALLBACK_ENABLE (1 << 7)
182 /* RTL818X_R8187B_*: magic numbers from ioregisters */
183 #define RTL818X_R8187B_B 0
184 #define RTL818X_R8187B_D 1
185 #define RTL818X_R8187B_E 2
195 } __attribute__((packed));
196 
197 #define MAX_RX_SIZE IEEE80211_MAX_FRAME_LEN
198 
199 #define RF_PARAM_ANALOGPHY (1 << 0)
200 #define RF_PARAM_ANTBDEFAULT (1 << 1)
201 #define RF_PARAM_CARRIERSENSE1 (1 << 2)
202 #define RF_PARAM_CARRIERSENSE2 (1 << 3)
203 
204 #define BB_ANTATTEN_CHAN14 0x0C
205 #define BB_ANTENNA_B 0x40
206 
207 #define BB_HOST_BANG (1 << 30)
208 #define BB_HOST_BANG_EN (1 << 2)
209 #define BB_HOST_BANG_CLK (1 << 1)
210 #define BB_HOST_BANG_DATA 1
211 
212 #define ANAPARAM_TXDACOFF_SHIFT 27
213 #define ANAPARAM_PWR0_SHIFT 28
214 #define ANAPARAM_PWR0_MASK (0x07 << ANAPARAM_PWR0_SHIFT)
215 #define ANAPARAM_PWR1_SHIFT 20
216 #define ANAPARAM_PWR1_MASK (0x7F << ANAPARAM_PWR1_SHIFT)
217 
218 #define RTL818X_RX_RING_SIZE 8 /* doesn't have to be a power of 2 */
219 #define RTL818X_TX_RING_SIZE 8 /* nor this [but 2^n is very slightly faster] */
220 #define RTL818X_RING_ALIGN 256
221 
222 #define RTL818X_MAX_RETRIES 4
223 
236 };
237 
250 } __attribute__ ((packed));
251 
260  RTL818X_RX_DESC_FLAG_QOS = (1 << 19), /* RTL8187(B) only */
261  RTL818X_RX_DESC_FLAG_TRSW = (1 << 24), /* RTL8187(B) only */
269 };
270 
274  union {
277  };
278 } __attribute__ ((packed));
279 
280 struct rtl818x_priv {
281  struct rtl818x_csr *map;
282  const struct rtl818x_rf_ops *rf;
283  int rf_flag; /* whatever RF driver wishes to use it for */
284  int hw_rate;
286 
289 
292  unsigned int rx_idx; /* next desc to be filled by card */
294 
297  unsigned int tx_cons; /* next desc to be filled by card */
298  unsigned int tx_prod; /* next desc to be filled by driver */
300 
301  struct pci_device *pdev;
303 
305 
306  int r8185;
310 };
311 
313 void rtl818x_set_anaparam(struct rtl818x_priv *priv, u32 anaparam);
314 
316 {
317  return inb(addr);
318 }
319 
321 {
322  return inw(addr);
323 }
324 
326 {
327  return inl(addr);
328 }
329 
330 static inline void rtl818x_iowrite8(struct rtl818x_priv *priv __unused,
331  u8 *addr, u8 val)
332 {
333  outb(val, addr);
334 }
335 
336 static inline void rtl818x_iowrite16(struct rtl818x_priv *priv __unused,
337  u16 *addr, u16 val)
338 {
339  outw(val, addr);
340 }
341 
342 static inline void rtl818x_iowrite32(struct rtl818x_priv *priv __unused,
343  u32 *addr, u32 val)
344 {
345  outl(val, addr);
346 }
347 
348 #define RTL818X_RF_DRIVERS __table(struct rtl818x_rf_ops, "rtl818x_rf_drivers")
349 #define __rtl818x_rf_driver __table_entry(RTL818X_RF_DRIVERS, 01)
350 
352  char *name;
353  u8 id; /* as identified in EEPROM */
354  void (*init)(struct net80211_device *dev);
355  void (*stop)(struct net80211_device *dev);
356  void (*set_chan)(struct net80211_device *dev, struct net80211_channel *chan);
357  void (*conf_erp)(struct net80211_device *dev); /* set based on dev->erp_flags */
358 };
359 
360 extern int rtl818x_probe(struct pci_device *pdev );
361 extern void rtl818x_remove(struct pci_device *pdev);
362 
363 #endif /* RTL818X_H */
FILE_LICENCE(GPL2_ONLY)
uint16_t u16
Definition: stdint.h:21
#define __attribute__(x)
Definition: compiler.h:10
struct rtl818x_csr * map
Definition: rtl818x.h:281
int hw_rate
Definition: rtl818x.h:284
u8 BSSID[6]
Definition: rtl818x.h:40
u32 THPDA
Definition: rtl818x.h:38
u16 RFPinsOutput
Definition: rtl818x.h:142
u8 GP_ENABLE
Definition: rtl818x.h:148
char * name
Definition: rtl818x.h:352
uint16_t inw(volatile uint16_t *io_addr)
Read 16-bit word from I/O-mapped device.
static u8 rtl818x_ioread8(struct rtl818x_priv *priv __unused, u8 *addr)
Definition: rtl818x.h:315
void(* stop)(struct net80211_device *dev)
Definition: rtl818x.h:355
struct io_buffer * rx_buf[RTL818X_RX_RING_SIZE]
Definition: rtl818x.h:293
#define outw(data, io_addr)
Definition: io.h:319
void(* conf_erp)(struct net80211_device *dev)
Definition: rtl818x.h:357
unsigned int rx_idx
Definition: rtl818x.h:292
u16 txpower[14]
Definition: rtl818x.h:304
SPI bit-bashing interface.
void rtl818x_set_anaparam(struct rtl818x_priv *priv, u32 anaparam)
Definition: rtl818x.c:219
u16 INT_STATUS
Definition: rtl818x.h:50
static void rtl818x_iowrite8(struct rtl818x_priv *priv __unused, u8 *addr, u8 val)
Definition: rtl818x.h:330
u32 next_tx_desc
Definition: rtl818x.h:244
u8 MAC[6]
Definition: rtl818x.h:27
u8 reserved_22[4]
Definition: rtl818x.h:192
u16 FEMR
Definition: rtl818x.h:191
int hw_rtscts_rate
Definition: rtl818x.h:285
u16 INT_MASK
Definition: rtl818x.h:49
u32 tx_ring_dma
Definition: rtl818x.h:296
u16 TID_AC_MAP
Definition: rtl818x.h:187
u8 reserved_0[2]
Definition: rtl818x.h:28
u8 reserved_11[2]
Definition: rtl818x.h:140
u8 CONFIG3
Definition: rtl818x.h:122
u32 TLPDA
Definition: rtl818x.h:36
u8 RATE_FALLBACK
Definition: rtl818x.h:171
unsigned int tx_prod
Definition: rtl818x.h:298
u8 reserved_2[4]
Definition: rtl818x.h:34
u8 TX_GAIN_OFDM
Definition: rtl818x.h:158
u8 reserved_19[3]
Definition: rtl818x.h:180
struct rtl818x_rx_desc * rx_ring
Definition: rtl818x.h:290
u8 CONFIG4
Definition: rtl818x.h:125
u8 RETRY_CTR
Definition: rtl818x.h:179
u8 reserved_10[12]
Definition: rtl818x.h:133
struct io_buffer * tx_buf[RTL818X_TX_RING_SIZE]
Definition: rtl818x.h:299
struct device dev
Generic device.
Definition: pci.h:189
u32 TBDA
Definition: rtl818x.h:101
rtl818x_rx_desc_flags
Definition: rtl818x.h:252
u8 BQREQ
Definition: rtl818x.h:33
u32 rx_ring_dma
Definition: rtl818x.h:291
u32 RF_PARA
Definition: rtl818x.h:146
u8 reserved_3[1]
Definition: rtl818x.h:43
u8 reserved_20[4]
Definition: rtl818x.h:188
u8 reserved_15[3]
Definition: rtl818x.h:162
static void rtl818x_iowrite32(struct rtl818x_priv *priv __unused, u32 *addr, u32 val)
Definition: rtl818x.h:342
eeprom
Definition: 3c90x.h:232
u8 reserved_13[4]
Definition: rtl818x.h:152
rtl818x_tx_desc_flags
Definition: rtl818x.h:224
u16 BEACON_INTERVAL_TIME
Definition: rtl818x.h:136
u32 RX_CONF
Definition: rtl818x.h:84
u16 ATIM_WND
Definition: rtl818x.h:135
u8 CW_CONF
Definition: rtl818x.h:167
u8 TX_AGC_CTL
Definition: rtl818x.h:153
void rtl818x_remove(struct pci_device *pdev)
Definition: rtl818x.c:827
u8 TX_ANTENNA
Definition: rtl818x.h:159
u16 RFPinsSelect
Definition: rtl818x.h:144
u8 reserved_12[2]
Definition: rtl818x.h:150
u8 reserved_18[2]
Definition: rtl818x.h:177
uint64_t u64
Definition: stdint.h:25
u8 TX_GAIN_CCK
Definition: rtl818x.h:157
A bit-bashing SPI bus.
Definition: spi_bit.h:16
u8 reserved_1
Definition: rtl818x.h:31
u8 CONFIG2
Definition: rtl818x.h:113
u8 PHY[4]
Definition: rtl818x.h:141
u32 TX_CONF
Definition: rtl818x.h:67
u8 RESP_RATE
Definition: rtl818x.h:41
The iPXE 802.11 MAC layer.
u16 BEACON_INTERVAL
Definition: rtl818x.h:134
#define outl(data, io_addr)
Definition: io.h:329
A PCI device.
Definition: pci.h:187
u32 HSSI_PARA
Definition: rtl818x.h:151
Structure encapsulating the complete state of an 802.11 device.
Definition: net80211.h:786
u8 csthreshold
Definition: rtl818x.h:309
An 802.11 RF channel.
Definition: net80211.h:385
u8 CARRIER_SENSE_COUNTER
Definition: rtl818x.h:139
u8 PHY_DELAY
Definition: rtl818x.h:138
u32 TNPDA
Definition: rtl818x.h:37
u32 addr
Definition: sky2.h:8
struct spi_bit_basher spibit
Definition: rtl818x.h:287
u16 TALLY_CNT
Definition: rtl818x.h:193
u16 BRSR
Definition: rtl818x.h:39
u8 ACM_CONTROL
Definition: rtl818x.h:173
uint8_t inb(volatile uint8_t *io_addr)
Read byte from I/O-mapped device.
u8 reserved_14[16]
Definition: rtl818x.h:160
u8 ANAPARAM3
Definition: rtl818x.h:189
const struct rtl818x_rf_ops * rf
Definition: rtl818x.h:282
void rtl818x_write_phy(struct net80211_device *dev, u8 addr, u32 data)
Definition: rtl818x.c:46
void __asmcall int val
Definition: setjmp.h:28
u8 WPA_CONF
Definition: rtl818x.h:161
u16 RFPinsEnable
Definition: rtl818x.h:143
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
#define RTL818X_RX_RING_SIZE
Definition: rtl818x.h:218
u32 rx_conf
Definition: rtl818x.h:302
u8 CONFIG5
Definition: rtl818x.h:175
void(* init)(struct net80211_device *dev)
Definition: rtl818x.h:354
u8 TX_DMA_POLLING
Definition: rtl818x.h:176
#define outb(data, io_addr)
Definition: io.h:309
unsigned int tx_cons
Definition: rtl818x.h:297
int rtl818x_probe(struct pci_device *pdev)
Definition: rtl818x.c:652
static struct tlan_private * priv
Definition: tlan.c:224
u32 ANAPARAM2
Definition: rtl818x.h:132
u8 TALLY_SEL
Definition: rtl818x.h:194
u32 ANAPARAM
Definition: rtl818x.h:115
u16 RFPinsInput
Definition: rtl818x.h:145
u8 reserved_21[5]
Definition: rtl818x.h:190
u8 CONFIG0
Definition: rtl818x.h:111
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
u16 rfparam
Definition: rtl818x.h:308
u16 INT_MIG
Definition: rtl818x.h:181
u32 RF_TIMING
Definition: rtl818x.h:147
Linker tables.
u8 reserved_16[5]
Definition: rtl818x.h:166
u16 ATIMTR_INTERVAL
Definition: rtl818x.h:137
An SPI device.
Definition: spi.h:86
static void rtl818x_iowrite16(struct rtl818x_priv *priv __unused, u16 *addr, u16 val)
Definition: rtl818x.h:336
u8 CONFIG1
Definition: rtl818x.h:112
u8 RX_FIFO_COUNT
Definition: rtl818x.h:30
u8 reserved_4[4]
Definition: rtl818x.h:48
u32 RDSAR
Definition: rtl818x.h:186
u8 SECURITY
Definition: rtl818x.h:131
u32 anaparam
Definition: rtl818x.h:307
#define RTL818X_TX_RING_SIZE
Definition: rtl818x.h:219
u32 MAR[2]
Definition: rtl818x.h:29
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
u8 EEPROM_CMD
Definition: rtl818x.h:102
void(* set_chan)(struct net80211_device *dev, struct net80211_channel *chan)
Definition: rtl818x.h:356
static u16 rtl818x_ioread16(struct rtl818x_priv *priv __unused, u16 *addr)
Definition: rtl818x.h:320
int rf_flag
Definition: rtl818x.h:283
struct rtl818x_tx_desc * tx_ring
Definition: rtl818x.h:295
u32 TSFT[2]
Definition: rtl818x.h:35
u8 reserved_17[24]
Definition: rtl818x.h:174
u32 INT_TIMEOUT
Definition: rtl818x.h:100
u32 reserved[2]
Definition: rtl818x.h:249
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
u8 TX_FIFO_COUNT
Definition: rtl818x.h:32
u8 reserved_9[2]
Definition: rtl818x.h:129
static u32 rtl818x_ioread32(struct rtl818x_priv *priv __unused, u32 *addr)
Definition: rtl818x.h:325
u8 PGSELECT
Definition: rtl818x.h:130
struct pci_device * pdev
Definition: rtl818x.h:301
u16 rts_duration
Definition: rtl818x.h:240
A persistent I/O buffer.
Definition: iobuf.h:32