1
2 #ifndef _B44_H
3 #define _B44_H
4
5 #include <linux/brcmphy.h>
6
7
8 #define B44_DEVCTRL 0x0000UL
9 #define DEVCTRL_MPM 0x00000040
10 #define DEVCTRL_PFE 0x00000080
11 #define DEVCTRL_IPP 0x00000400
12 #define DEVCTRL_EPR 0x00008000
13 #define DEVCTRL_PME 0x00001000
14 #define DEVCTRL_PMCE 0x00002000
15 #define DEVCTRL_PADDR 0x0007c000
16 #define DEVCTRL_PADDR_SHIFT 18
17 #define B44_BIST_STAT 0x000CUL
18 #define B44_WKUP_LEN 0x0010UL
19 #define WKUP_LEN_P0_MASK 0x0000007f
20 #define WKUP_LEN_D0 0x00000080
21 #define WKUP_LEN_P1_MASK 0x00007f00
22 #define WKUP_LEN_P1_SHIFT 8
23 #define WKUP_LEN_D1 0x00008000
24 #define WKUP_LEN_P2_MASK 0x007f0000
25 #define WKUP_LEN_P2_SHIFT 16
26 #define WKUP_LEN_D2 0x00000000
27 #define WKUP_LEN_P3_MASK 0x7f000000
28 #define WKUP_LEN_P3_SHIFT 24
29 #define WKUP_LEN_D3 0x80000000
30 #define WKUP_LEN_DISABLE 0x80808080
31 #define WKUP_LEN_ENABLE_TWO 0x80800000
32 #define WKUP_LEN_ENABLE_THREE 0x80000000
33 #define B44_ISTAT 0x0020UL
34 #define ISTAT_LS 0x00000020
35 #define ISTAT_PME 0x00000040
36 #define ISTAT_TO 0x00000080
37 #define ISTAT_DSCE 0x00000400
38 #define ISTAT_DATAE 0x00000800
39 #define ISTAT_DPE 0x00001000
40 #define ISTAT_RDU 0x00002000
41 #define ISTAT_RFO 0x00004000
42 #define ISTAT_TFU 0x00008000
43 #define ISTAT_RX 0x00010000
44 #define ISTAT_TX 0x01000000
45 #define ISTAT_EMAC 0x04000000
46 #define ISTAT_MII_WRITE 0x08000000
47 #define ISTAT_MII_READ 0x10000000
48 #define ISTAT_ERRORS (ISTAT_DSCE|ISTAT_DATAE|ISTAT_DPE|ISTAT_RDU|ISTAT_RFO|ISTAT_TFU)
49 #define B44_IMASK 0x0024UL
50 #define IMASK_DEF (ISTAT_ERRORS | ISTAT_TO | ISTAT_RX | ISTAT_TX)
51 #define B44_GPTIMER 0x0028UL
52 #define B44_ADDR_LO 0x0088UL
53 #define B44_ADDR_HI 0x008CUL
54 #define B44_FILT_ADDR 0x0090UL
55 #define B44_FILT_DATA 0x0094UL
56 #define B44_TXBURST 0x00A0UL
57 #define B44_RXBURST 0x00A4UL
58 #define B44_MAC_CTRL 0x00A8UL
59 #define MAC_CTRL_CRC32_ENAB 0x00000001
60 #define MAC_CTRL_PHY_PDOWN 0x00000004
61 #define MAC_CTRL_PHY_EDET 0x00000008
62 #define MAC_CTRL_PHY_LEDCTRL 0x000000e0
63 #define MAC_CTRL_PHY_LEDCTRL_SHIFT 5
64 #define B44_MAC_FLOW 0x00ACUL
65 #define MAC_FLOW_RX_HI_WATER 0x000000ff
66 #define MAC_FLOW_PAUSE_ENAB 0x00008000
67 #define B44_RCV_LAZY 0x0100UL
68 #define RCV_LAZY_TO_MASK 0x00ffffff
69 #define RCV_LAZY_FC_MASK 0xff000000
70 #define RCV_LAZY_FC_SHIFT 24
71 #define B44_DMATX_CTRL 0x0200UL
72 #define DMATX_CTRL_ENABLE 0x00000001
73 #define DMATX_CTRL_SUSPEND 0x00000002
74 #define DMATX_CTRL_LPBACK 0x00000004
75 #define DMATX_CTRL_FAIRPRIOR 0x00000008
76 #define DMATX_CTRL_FLUSH 0x00000010
77 #define B44_DMATX_ADDR 0x0204UL
78 #define B44_DMATX_PTR 0x0208UL
79 #define B44_DMATX_STAT 0x020CUL
80 #define DMATX_STAT_CDMASK 0x00000fff
81 #define DMATX_STAT_SMASK 0x0000f000
82 #define DMATX_STAT_SDISABLED 0x00000000
83 #define DMATX_STAT_SACTIVE 0x00001000
84 #define DMATX_STAT_SIDLE 0x00002000
85 #define DMATX_STAT_SSTOPPED 0x00003000
86 #define DMATX_STAT_SSUSP 0x00004000
87 #define DMATX_STAT_EMASK 0x000f0000
88 #define DMATX_STAT_ENONE 0x00000000
89 #define DMATX_STAT_EDPE 0x00010000
90 #define DMATX_STAT_EDFU 0x00020000
91 #define DMATX_STAT_EBEBR 0x00030000
92 #define DMATX_STAT_EBEDA 0x00040000
93 #define DMATX_STAT_FLUSHED 0x00100000
94 #define B44_DMARX_CTRL 0x0210UL
95 #define DMARX_CTRL_ENABLE 0x00000001
96 #define DMARX_CTRL_ROMASK 0x000000fe
97 #define DMARX_CTRL_ROSHIFT 1
98 #define B44_DMARX_ADDR 0x0214UL
99 #define B44_DMARX_PTR 0x0218UL
100 #define B44_DMARX_STAT 0x021CUL
101 #define DMARX_STAT_CDMASK 0x00000fff
102 #define DMARX_STAT_SMASK 0x0000f000
103 #define DMARX_STAT_SDISABLED 0x00000000
104 #define DMARX_STAT_SACTIVE 0x00001000
105 #define DMARX_STAT_SIDLE 0x00002000
106 #define DMARX_STAT_SSTOPPED 0x00003000
107 #define DMARX_STAT_EMASK 0x000f0000
108 #define DMARX_STAT_ENONE 0x00000000
109 #define DMARX_STAT_EDPE 0x00010000
110 #define DMARX_STAT_EDFO 0x00020000
111 #define DMARX_STAT_EBEBW 0x00030000
112 #define DMARX_STAT_EBEDA 0x00040000
113 #define B44_DMAFIFO_AD 0x0220UL
114 #define DMAFIFO_AD_OMASK 0x0000ffff
115 #define DMAFIFO_AD_SMASK 0x000f0000
116 #define DMAFIFO_AD_SXDD 0x00000000
117 #define DMAFIFO_AD_SXDP 0x00010000
118 #define DMAFIFO_AD_SRDD 0x00040000
119 #define DMAFIFO_AD_SRDP 0x00050000
120 #define DMAFIFO_AD_SXFD 0x00080000
121 #define DMAFIFO_AD_SXFP 0x00090000
122 #define DMAFIFO_AD_SRFD 0x000c0000
123 #define DMAFIFO_AD_SRFP 0x000c0000
124 #define B44_DMAFIFO_LO 0x0224UL
125 #define B44_DMAFIFO_HI 0x0228UL
126 #define B44_RXCONFIG 0x0400UL
127 #define RXCONFIG_DBCAST 0x00000001
128 #define RXCONFIG_ALLMULTI 0x00000002
129 #define RXCONFIG_NORX_WHILE_TX 0x00000004
130 #define RXCONFIG_PROMISC 0x00000008
131 #define RXCONFIG_LPBACK 0x00000010
132 #define RXCONFIG_FLOW 0x00000020
133 #define RXCONFIG_FLOW_ACCEPT 0x00000040
134 #define RXCONFIG_RFILT 0x00000080
135 #define RXCONFIG_CAM_ABSENT 0x00000100
136 #define B44_RXMAXLEN 0x0404UL
137 #define B44_TXMAXLEN 0x0408UL
138 #define B44_MDIO_CTRL 0x0410UL
139 #define MDIO_CTRL_MAXF_MASK 0x0000007f
140 #define MDIO_CTRL_PREAMBLE 0x00000080
141 #define B44_MDIO_DATA 0x0414UL
142 #define MDIO_DATA_DATA 0x0000ffff
143 #define MDIO_DATA_TA_MASK 0x00030000
144 #define MDIO_DATA_TA_SHIFT 16
145 #define MDIO_TA_VALID 2
146 #define MDIO_DATA_RA_MASK 0x007c0000
147 #define MDIO_DATA_RA_SHIFT 18
148 #define MDIO_DATA_PMD_MASK 0x0f800000
149 #define MDIO_DATA_PMD_SHIFT 23
150 #define MDIO_DATA_OP_MASK 0x30000000
151 #define MDIO_DATA_OP_SHIFT 28
152 #define MDIO_OP_WRITE 1
153 #define MDIO_OP_READ 2
154 #define MDIO_DATA_SB_MASK 0xc0000000
155 #define MDIO_DATA_SB_SHIFT 30
156 #define MDIO_DATA_SB_START 0x40000000
157 #define B44_EMAC_IMASK 0x0418UL
158 #define B44_EMAC_ISTAT 0x041CUL
159 #define EMAC_INT_MII 0x00000001
160 #define EMAC_INT_MIB 0x00000002
161 #define EMAC_INT_FLOW 0x00000003
162 #define B44_CAM_DATA_LO 0x0420UL
163 #define B44_CAM_DATA_HI 0x0424UL
164 #define CAM_DATA_HI_VALID 0x00010000
165 #define B44_CAM_CTRL 0x0428UL
166 #define CAM_CTRL_ENABLE 0x00000001
167 #define CAM_CTRL_MSEL 0x00000002
168 #define CAM_CTRL_READ 0x00000004
169 #define CAM_CTRL_WRITE 0x00000008
170 #define CAM_CTRL_INDEX_MASK 0x003f0000
171 #define CAM_CTRL_INDEX_SHIFT 16
172 #define CAM_CTRL_BUSY 0x80000000
173 #define B44_ENET_CTRL 0x042CUL
174 #define ENET_CTRL_ENABLE 0x00000001
175 #define ENET_CTRL_DISABLE 0x00000002
176 #define ENET_CTRL_SRST 0x00000004
177 #define ENET_CTRL_EPSEL 0x00000008
178 #define B44_TX_CTRL 0x0430UL
179 #define TX_CTRL_DUPLEX 0x00000001
180 #define TX_CTRL_FMODE 0x00000002
181 #define TX_CTRL_SBENAB 0x00000004
182 #define TX_CTRL_SMALL_SLOT 0x00000008
183 #define B44_TX_WMARK 0x0434UL
184 #define B44_MIB_CTRL 0x0438UL
185 #define MIB_CTRL_CLR_ON_READ 0x00000001
186 #define B44_TX_GOOD_O 0x0500UL
187 #define B44_TX_GOOD_P 0x0504UL
188 #define B44_TX_O 0x0508UL
189 #define B44_TX_P 0x050CUL
190 #define B44_TX_BCAST 0x0510UL
191 #define B44_TX_MCAST 0x0514UL
192 #define B44_TX_64 0x0518UL
193 #define B44_TX_65_127 0x051CUL
194 #define B44_TX_128_255 0x0520UL
195 #define B44_TX_256_511 0x0524UL
196 #define B44_TX_512_1023 0x0528UL
197 #define B44_TX_1024_MAX 0x052CUL
198 #define B44_TX_JABBER 0x0530UL
199 #define B44_TX_OSIZE 0x0534UL
200 #define B44_TX_FRAG 0x0538UL
201 #define B44_TX_URUNS 0x053CUL
202 #define B44_TX_TCOLS 0x0540UL
203 #define B44_TX_SCOLS 0x0544UL
204 #define B44_TX_MCOLS 0x0548UL
205 #define B44_TX_ECOLS 0x054CUL
206 #define B44_TX_LCOLS 0x0550UL
207 #define B44_TX_DEFERED 0x0554UL
208 #define B44_TX_CLOST 0x0558UL
209 #define B44_TX_PAUSE 0x055CUL
210 #define B44_RX_GOOD_O 0x0580UL
211 #define B44_RX_GOOD_P 0x0584UL
212 #define B44_RX_O 0x0588UL
213 #define B44_RX_P 0x058CUL
214 #define B44_RX_BCAST 0x0590UL
215 #define B44_RX_MCAST 0x0594UL
216 #define B44_RX_64 0x0598UL
217 #define B44_RX_65_127 0x059CUL
218 #define B44_RX_128_255 0x05A0UL
219 #define B44_RX_256_511 0x05A4UL
220 #define B44_RX_512_1023 0x05A8UL
221 #define B44_RX_1024_MAX 0x05ACUL
222 #define B44_RX_JABBER 0x05B0UL
223 #define B44_RX_OSIZE 0x05B4UL
224 #define B44_RX_FRAG 0x05B8UL
225 #define B44_RX_MISS 0x05BCUL
226 #define B44_RX_CRCA 0x05C0UL
227 #define B44_RX_USIZE 0x05C4UL
228 #define B44_RX_CRC 0x05C8UL
229 #define B44_RX_ALIGN 0x05CCUL
230 #define B44_RX_SYM 0x05D0UL
231 #define B44_RX_PAUSE 0x05D4UL
232 #define B44_RX_NPAUSE 0x05D8UL
233
234
235 #define B44_MII_AUXCTRL 24
236 #define MII_AUXCTRL_DUPLEX 0x0001
237 #define MII_AUXCTRL_SPEED 0x0002
238 #define MII_AUXCTRL_FORCED 0x0004
239 #define B44_MII_ALEDCTRL 26
240 #define MII_ALEDCTRL_ALLMSK 0x7fff
241 #define B44_MII_TLEDCTRL 27
242 #define MII_TLEDCTRL_ENABLE 0x0040
243
244 struct dma_desc {
245 __le32 ctrl;
246 __le32 addr;
247 };
248
249
250
251
252 #define DMA_TABLE_BYTES 4096
253
254 #define DESC_CTRL_LEN 0x00001fff
255 #define DESC_CTRL_CMASK 0x0ff00000
256 #define DESC_CTRL_EOT 0x10000000
257 #define DESC_CTRL_IOC 0x20000000
258 #define DESC_CTRL_EOF 0x40000000
259 #define DESC_CTRL_SOF 0x80000000
260
261 #define RX_COPY_THRESHOLD 256
262
263 struct rx_header {
264 __le16 len;
265 __le16 flags;
266 __le16 pad[12];
267 };
268 #define RX_HEADER_LEN 28
269
270 #define RX_FLAG_OFIFO 0x00000001
271 #define RX_FLAG_CRCERR 0x00000002
272 #define RX_FLAG_SERR 0x00000004
273 #define RX_FLAG_ODD 0x00000008
274 #define RX_FLAG_LARGE 0x00000010
275 #define RX_FLAG_MCAST 0x00000020
276 #define RX_FLAG_BCAST 0x00000040
277 #define RX_FLAG_MISS 0x00000080
278 #define RX_FLAG_LAST 0x00000800
279 #define RX_FLAG_ERRORS (RX_FLAG_ODD | RX_FLAG_SERR | RX_FLAG_CRCERR | RX_FLAG_OFIFO)
280
281 struct ring_info {
282 struct sk_buff *skb;
283 dma_addr_t mapping;
284 };
285
286 #define B44_MCAST_TABLE_SIZE 32
287
288 #define B44_PHY_ADDR_NO_LOCAL_PHY BRCM_PSEUDO_PHY_ADDR
289
290 #define B44_PHY_ADDR_NO_PHY 31
291 #define B44_MDC_RATIO 5000000
292
293 #define B44_STAT_REG_DECLARE \
294 _B44(tx_good_octets) \
295 _B44(tx_good_pkts) \
296 _B44(tx_octets) \
297 _B44(tx_pkts) \
298 _B44(tx_broadcast_pkts) \
299 _B44(tx_multicast_pkts) \
300 _B44(tx_len_64) \
301 _B44(tx_len_65_to_127) \
302 _B44(tx_len_128_to_255) \
303 _B44(tx_len_256_to_511) \
304 _B44(tx_len_512_to_1023) \
305 _B44(tx_len_1024_to_max) \
306 _B44(tx_jabber_pkts) \
307 _B44(tx_oversize_pkts) \
308 _B44(tx_fragment_pkts) \
309 _B44(tx_underruns) \
310 _B44(tx_total_cols) \
311 _B44(tx_single_cols) \
312 _B44(tx_multiple_cols) \
313 _B44(tx_excessive_cols) \
314 _B44(tx_late_cols) \
315 _B44(tx_defered) \
316 _B44(tx_carrier_lost) \
317 _B44(tx_pause_pkts) \
318 _B44(rx_good_octets) \
319 _B44(rx_good_pkts) \
320 _B44(rx_octets) \
321 _B44(rx_pkts) \
322 _B44(rx_broadcast_pkts) \
323 _B44(rx_multicast_pkts) \
324 _B44(rx_len_64) \
325 _B44(rx_len_65_to_127) \
326 _B44(rx_len_128_to_255) \
327 _B44(rx_len_256_to_511) \
328 _B44(rx_len_512_to_1023) \
329 _B44(rx_len_1024_to_max) \
330 _B44(rx_jabber_pkts) \
331 _B44(rx_oversize_pkts) \
332 _B44(rx_fragment_pkts) \
333 _B44(rx_missed_pkts) \
334 _B44(rx_crc_align_errs) \
335 _B44(rx_undersize) \
336 _B44(rx_crc_errs) \
337 _B44(rx_align_errs) \
338 _B44(rx_symbol_errs) \
339 _B44(rx_pause_pkts) \
340 _B44(rx_nonpause_pkts)
341
342
343
344
345
346 struct b44_hw_stats {
347 #define _B44(x) u64 x;
348 B44_STAT_REG_DECLARE
349 #undef _B44
350 struct u64_stats_sync syncp;
351 };
352
353 #define B44_BOARDFLAG_ROBO 0x0010
354 #define B44_BOARDFLAG_ADM 0x0080
355
356 struct ssb_device;
357
358 struct b44 {
359 spinlock_t lock;
360
361 u32 imask, istat;
362
363 struct dma_desc *rx_ring, *tx_ring;
364
365 u32 tx_prod, tx_cons;
366 u32 rx_prod, rx_cons;
367
368 struct ring_info *rx_buffers;
369 struct ring_info *tx_buffers;
370
371 struct napi_struct napi;
372
373 u32 dma_offset;
374 u32 flags;
375 #define B44_FLAG_B0_ANDLATER 0x00000001
376 #define B44_FLAG_BUGGY_TXPTR 0x00000002
377 #define B44_FLAG_REORDER_BUG 0x00000004
378 #define B44_FLAG_PAUSE_AUTO 0x00008000
379 #define B44_FLAG_FULL_DUPLEX 0x00010000
380 #define B44_FLAG_100_BASE_T 0x00020000
381 #define B44_FLAG_TX_PAUSE 0x00040000
382 #define B44_FLAG_RX_PAUSE 0x00080000
383 #define B44_FLAG_FORCE_LINK 0x00100000
384 #define B44_FLAG_ADV_10HALF 0x01000000
385 #define B44_FLAG_ADV_10FULL 0x02000000
386 #define B44_FLAG_ADV_100HALF 0x04000000
387 #define B44_FLAG_ADV_100FULL 0x08000000
388 #define B44_FLAG_EXTERNAL_PHY 0x10000000
389 #define B44_FLAG_RX_RING_HACK 0x20000000
390 #define B44_FLAG_TX_RING_HACK 0x40000000
391 #define B44_FLAG_WOL_ENABLE 0x80000000
392
393 u32 msg_enable;
394
395 struct timer_list timer;
396
397 struct b44_hw_stats hw_stats;
398
399 struct ssb_device *sdev;
400 struct net_device *dev;
401
402 dma_addr_t rx_ring_dma, tx_ring_dma;
403
404 u32 rx_pending;
405 u32 tx_pending;
406 u8 phy_addr;
407 u8 force_copybreak;
408 struct mii_bus *mii_bus;
409 int old_link;
410 struct mii_if_info mii_if;
411 };
412
413 #endif