1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef __NET_TULIP_H__
17#define __NET_TULIP_H__
18
19#include <linux/config.h>
20#include <linux/kernel.h>
21#include <linux/types.h>
22#include <linux/spinlock.h>
23#include <linux/netdevice.h>
24#include <linux/timer.h>
25#include <linux/delay.h>
26#include <asm/io.h>
27#include <asm/irq.h>
28
29
30
31
32#define TULIP_DEBUG 1
33
34
35#ifdef CONFIG_TULIP_MMIO
36# undef USE_IO_OPS
37#else
38# define USE_IO_OPS 1
39#endif
40
41
42
43struct tulip_chip_table {
44 char *chip_name;
45 int io_size;
46 int valid_intrs;
47 int flags;
48 void (*media_timer) (unsigned long data);
49};
50
51
52enum tbl_flag {
53 HAS_MII = 0x0001,
54 HAS_MEDIA_TABLE = 0x0002,
55 CSR12_IN_SROM = 0x0004,
56 ALWAYS_CHECK_MII = 0x0008,
57 HAS_ACPI = 0x0010,
58 MC_HASH_ONLY = 0x0020,
59 HAS_PNICNWAY = 0x0080,
60 HAS_NWAY = 0x0040,
61 HAS_INTR_MITIGATION = 0x0100,
62 IS_ASIX = 0x0200,
63 HAS_8023X = 0x0400,
64 COMET_MAC_ADDR = 0x0800,
65 HAS_PCI_MWI = 0x1000,
66 HAS_PHY_IRQ = 0x2000,
67};
68
69
70
71
72
73enum chips {
74 DC21040 = 0,
75 DC21041 = 1,
76 DC21140 = 2,
77 DC21142 = 3, DC21143 = 3,
78 LC82C168,
79 MX98713,
80 MX98715,
81 MX98725,
82 AX88140,
83 PNIC2,
84 COMET,
85 COMPEX9881,
86 I21145,
87 DM910X,
88 CONEXANT,
89};
90
91
92enum MediaIs {
93 MediaIsFD = 1,
94 MediaAlwaysFD = 2,
95 MediaIsMII = 4,
96 MediaIsFx = 8,
97 MediaIs100 = 16
98};
99
100
101
102
103enum tulip_offsets {
104 CSR0 = 0,
105 CSR1 = 0x08,
106 CSR2 = 0x10,
107 CSR3 = 0x18,
108 CSR4 = 0x20,
109 CSR5 = 0x28,
110 CSR6 = 0x30,
111 CSR7 = 0x38,
112 CSR8 = 0x40,
113 CSR9 = 0x48,
114 CSR10 = 0x50,
115 CSR11 = 0x58,
116 CSR12 = 0x60,
117 CSR13 = 0x68,
118 CSR14 = 0x70,
119 CSR15 = 0x78,
120};
121
122
123enum pci_cfg_driver_reg {
124 CFDD = 0x40,
125 CFDD_Sleep = (1 << 31),
126 CFDD_Snooze = (1 << 30),
127};
128
129
130
131enum status_bits {
132 TimerInt = 0x800,
133 SytemError = 0x2000,
134 TPLnkFail = 0x1000,
135 TPLnkPass = 0x10,
136 NormalIntr = 0x10000,
137 AbnormalIntr = 0x8000,
138 RxJabber = 0x200,
139 RxDied = 0x100,
140 RxNoBuf = 0x80,
141 RxIntr = 0x40,
142 TxFIFOUnderflow = 0x20,
143 TxJabber = 0x08,
144 TxNoBuf = 0x04,
145 TxDied = 0x02,
146 TxIntr = 0x01,
147};
148
149
150enum tulip_mode_bits {
151 TxThreshold = (1 << 22),
152 FullDuplex = (1 << 9),
153 TxOn = 0x2000,
154 AcceptBroadcast = 0x0100,
155 AcceptAllMulticast = 0x0080,
156 AcceptAllPhys = 0x0040,
157 AcceptRunt = 0x0008,
158 RxOn = 0x0002,
159 RxTx = (TxOn | RxOn),
160};
161
162
163enum tulip_busconfig_bits {
164 MWI = (1 << 24),
165 MRL = (1 << 23),
166 MRM = (1 << 21),
167 CALShift = 14,
168 BurstLenShift = 8,
169};
170
171
172
173struct tulip_rx_desc {
174 s32 status;
175 s32 length;
176 u32 buffer1;
177 u32 buffer2;
178};
179
180
181struct tulip_tx_desc {
182 s32 status;
183 s32 length;
184 u32 buffer1;
185 u32 buffer2;
186};
187
188
189enum desc_status_bits {
190 DescOwned = 0x80000000,
191 RxDescFatalErr = 0x8000,
192 RxWholePkt = 0x0300,
193};
194
195
196enum t21143_csr6_bits {
197 csr6_sc = (1<<31),
198 csr6_ra = (1<<30),
199 csr6_ign_dest_msb = (1<<26),
200 csr6_mbo = (1<<25),
201 csr6_scr = (1<<24),
202 csr6_pcs = (1<<23),
203 csr6_ttm = (1<<22),
204 csr6_sf = (1<<21),
205 csr6_hbd = (1<<19),
206 csr6_ps = (1<<18),
207 csr6_ca = (1<<17),
208 csr6_trh = (1<<15),
209 csr6_trl = (1<<14),
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226 csr6_fc = (1<<12),
227 csr6_om_int_loop = (1<<10),
228 csr6_om_ext_loop = (1<<11),
229
230 csr6_fd = (1<<9),
231 csr6_pm = (1<<7),
232 csr6_pr = (1<<6),
233 csr6_sb = (1<<5),
234 csr6_if = (1<<4),
235 csr6_pb = (1<<3),
236 csr6_ho = (1<<2),
237 csr6_hp = (1<<0),
238
239 csr6_mask_capture = (csr6_sc | csr6_ca),
240 csr6_mask_defstate = (csr6_mask_capture | csr6_mbo),
241 csr6_mask_hdcap = (csr6_mask_defstate | csr6_hbd | csr6_ps),
242 csr6_mask_hdcaptt = (csr6_mask_hdcap | csr6_trh | csr6_trl),
243 csr6_mask_fullcap = (csr6_mask_hdcaptt | csr6_fd),
244 csr6_mask_fullpromisc = (csr6_pr | csr6_pm),
245 csr6_mask_filters = (csr6_hp | csr6_ho | csr6_if),
246 csr6_mask_100bt = (csr6_scr | csr6_pcs | csr6_hbd),
247};
248
249
250
251
252
253
254#define TX_RING_SIZE 16
255#define RX_RING_SIZE 32
256
257#define MEDIA_MASK 31
258
259#define PKT_BUF_SZ 1536
260
261#define TULIP_MIN_CACHE_LINE 8
262
263#if defined(__sparc__) || defined(__hppa__)
264
265
266
267
268#define TULIP_MAX_CACHE_LINE 16
269#else
270#define TULIP_MAX_CACHE_LINE 32
271#endif
272
273
274
275
276
277
278
279
280
281
282#define DESC_RING_WRAP 0x02000000
283
284
285#define EEPROM_SIZE 512
286
287
288#define RUN_AT(x) (jiffies + (x))
289
290#if defined(__i386__)
291#define get_u16(ptr) (*(u16 *)(ptr))
292#else
293#define get_u16(ptr) (((u8*)(ptr))[0] + (((u8*)(ptr))[1]<<8))
294#endif
295
296struct medialeaf {
297 u8 type;
298 u8 media;
299 unsigned char *leafdata;
300};
301
302
303struct mediatable {
304 u16 defaultmedia;
305 u8 leafcount;
306 u8 csr12dir;
307 unsigned has_mii:1;
308 unsigned has_nonmii:1;
309 unsigned has_reset:6;
310 u32 csr15dir;
311 u32 csr15val;
312 struct medialeaf mleaf[0];
313};
314
315
316struct mediainfo {
317 struct mediainfo *next;
318 int info_type;
319 int index;
320 unsigned char *info;
321};
322
323struct ring_info {
324 struct sk_buff *skb;
325 dma_addr_t mapping;
326};
327
328
329struct tulip_private {
330 const char *product_name;
331 struct net_device *next_module;
332 struct tulip_rx_desc *rx_ring;
333 struct tulip_tx_desc *tx_ring;
334 dma_addr_t rx_ring_dma;
335 dma_addr_t tx_ring_dma;
336
337 struct ring_info tx_buffers[TX_RING_SIZE];
338
339 struct ring_info rx_buffers[RX_RING_SIZE];
340 u16 setup_frame[96];
341 int chip_id;
342 int revision;
343 int flags;
344 struct net_device_stats stats;
345 struct timer_list timer;
346 u32 mc_filter[2];
347 spinlock_t lock;
348 spinlock_t mii_lock;
349 unsigned int cur_rx, cur_tx;
350 unsigned int dirty_rx, dirty_tx;
351
352#ifdef CONFIG_NET_HW_FLOWCONTROL
353#define RX_A_NBF_STOP 0xffffff3f
354 int fc_bit;
355 int mit_sel;
356 int mit_change;
357#endif
358 unsigned int full_duplex:1;
359 unsigned int full_duplex_lock:1;
360 unsigned int fake_addr:1;
361 unsigned int default_port:4;
362 unsigned int media2:4;
363 unsigned int medialock:1;
364 unsigned int mediasense:1;
365 unsigned int nway:1, nwayset:1;
366 unsigned int csr0;
367 unsigned int csr6;
368 unsigned char eeprom[EEPROM_SIZE];
369 void (*link_change) (struct net_device * dev, int csr5);
370 u16 sym_advertise, mii_advertise;
371 u16 lpar;
372 u16 advertising[4];
373 signed char phys[4], mii_cnt;
374 struct mediatable *mtable;
375 int cur_index;
376 int saved_if_port;
377 struct pci_dev *pdev;
378 int ttimer;
379 int susp_rx;
380 unsigned long nir;
381 unsigned long base_addr;
382 int csr12_shadow;
383 int pad0;
384};
385
386
387struct eeprom_fixup {
388 char *name;
389 unsigned char addr0;
390 unsigned char addr1;
391 unsigned char addr2;
392 u16 newtable[32];
393};
394
395
396
397extern u16 t21142_csr14[];
398void t21142_timer(unsigned long data);
399void t21142_start_nway(struct net_device *dev);
400void t21142_lnk_change(struct net_device *dev, int csr5);
401
402
403
404void pnic2_lnk_change(struct net_device *dev, int csr5);
405void pnic2_timer(unsigned long data);
406void pnic2_start_nway(struct net_device *dev);
407void pnic2_lnk_change(struct net_device *dev, int csr5);
408
409
410void tulip_parse_eeprom(struct net_device *dev);
411int tulip_read_eeprom(long ioaddr, int location, int addr_len);
412
413
414extern unsigned int tulip_max_interrupt_work;
415extern int tulip_rx_copybreak;
416irqreturn_t tulip_interrupt(int irq, void *dev_instance, struct pt_regs *regs);
417int tulip_refill_rx(struct net_device *dev);
418
419
420int tulip_mdio_read(struct net_device *dev, int phy_id, int location);
421void tulip_mdio_write(struct net_device *dev, int phy_id, int location, int value);
422void tulip_select_media(struct net_device *dev, int startup);
423int tulip_check_duplex(struct net_device *dev);
424void tulip_find_mii (struct net_device *dev, int board_idx);
425
426
427void pnic_do_nway(struct net_device *dev);
428void pnic_lnk_change(struct net_device *dev, int csr5);
429void pnic_timer(unsigned long data);
430
431
432void tulip_timer(unsigned long data);
433void mxic_timer(unsigned long data);
434void comet_timer(unsigned long data);
435
436
437extern int tulip_debug;
438extern const char * const medianame[];
439extern const char tulip_media_cap[];
440extern struct tulip_chip_table tulip_tbl[];
441extern u8 t21040_csr13[];
442
443#ifndef USE_IO_OPS
444#undef inb
445#undef inw
446#undef inl
447#undef outb
448#undef outw
449#undef outl
450#define inb(addr) readb((void*)(addr))
451#define inw(addr) readw((void*)(addr))
452#define inl(addr) readl((void*)(addr))
453#define outb(val,addr) writeb((val), (void*)(addr))
454#define outw(val,addr) writew((val), (void*)(addr))
455#define outl(val,addr) writel((val), (void*)(addr))
456#endif
457
458
459
460static inline void tulip_start_rxtx(struct tulip_private *tp)
461{
462 long ioaddr = tp->base_addr;
463 outl(tp->csr6 | RxTx, ioaddr + CSR6);
464 barrier();
465 (void) inl(ioaddr + CSR6);
466}
467
468static inline void tulip_stop_rxtx(struct tulip_private *tp)
469{
470 long ioaddr = tp->base_addr;
471 u32 csr6 = inl(ioaddr + CSR6);
472
473 if (csr6 & RxTx) {
474 outl(csr6 & ~RxTx, ioaddr + CSR6);
475 barrier();
476 (void) inl(ioaddr + CSR6);
477 }
478}
479
480static inline void tulip_restart_rxtx(struct tulip_private *tp)
481{
482 tulip_stop_rxtx(tp);
483 udelay(5);
484 tulip_start_rxtx(tp);
485}
486
487#endif
488