iPXE
dmfe.c
Go to the documentation of this file.
1/**************************************************************************
2*
3* dmfe.c -- Etherboot device driver for the Davicom
4* DM9102/DM9102A/DM9102A+DM9801/DM9102A+DM9802 NIC fast ethernet card
5*
6* Written 2003-2003 by Timothy Legge <tlegge@rogers.com>
7*
8* This program is free software; you can redistribute it and/or modify
9* it under the terms of the GNU General Public License as published by
10* the Free Software Foundation; either version 2 of the License, or
11* (at your option) any later version.
12*
13* This program is distributed in the hope that it will be useful,
14* but WITHOUT ANY WARRANTY; without even the implied warranty of
15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16* GNU General Public License for more details.
17*
18* You should have received a copy of the GNU General Public License
19* along with this program; if not, write to the Free Software
20* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21* 02110-1301, USA.
22*
23* Portions of this code based on:
24*
25* dmfe.c: A Davicom DM9102/DM9102A/DM9102A+DM9801/DM9102A+DM9802
26* NIC fast ethernet driver for Linux.
27* Copyright (C) 1997 Sten Wang
28* (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
29*
30*
31* REVISION HISTORY:
32* ================
33* v1.0 10-02-2004 timlegge Boots ltsp needs cleanup
34*
35* Indent Options: indent -kr -i8
36*
37*
38***************************************************************************/
39
40FILE_LICENCE ( GPL2_OR_LATER );
41
42/* to get some global routines like printf */
43#include "etherboot.h"
44/* to get the interface to the body of the program */
45#include "nic.h"
46/* to get the PCI support functions, if this is a PCI NIC */
47#include <ipxe/pci.h>
48#include <ipxe/ethernet.h>
49
50/* #define EDEBUG 1 */
51#ifdef EDEBUG
52#define dprintf(x) printf x
53#else
54#define dprintf(x)
55#endif
56
57/* Condensed operations for readability. */
58#define virt_to_le32desc(addr) cpu_to_le32(virt_to_bus(addr))
59#define le32desc_to_virt(addr) bus_to_virt(le32_to_cpu(addr))
60
61/* Board/System/Debug information/definition ---------------- */
62#define PCI_DM9132_ID 0x91321282 /* Davicom DM9132 ID */
63#define PCI_DM9102_ID 0x91021282 /* Davicom DM9102 ID */
64#define PCI_DM9100_ID 0x91001282 /* Davicom DM9100 ID */
65#define PCI_DM9009_ID 0x90091282 /* Davicom DM9009 ID */
66
67#define DM9102_IO_SIZE 0x80
68#define DM9102A_IO_SIZE 0x100
69#define TX_MAX_SEND_CNT 0x1 /* Maximum tx packet per time */
70#define TX_DESC_CNT 0x10 /* Allocated Tx descriptors */
71#define RX_DESC_CNT 0x20 /* Allocated Rx descriptors */
72#define TX_FREE_DESC_CNT (TX_DESC_CNT - 2) /* Max TX packet count */
73#define TX_WAKE_DESC_CNT (TX_DESC_CNT - 3) /* TX wakeup count */
74#define DESC_ALL_CNT (TX_DESC_CNT + RX_DESC_CNT)
75#define TX_BUF_ALLOC 0x600
76#define RX_ALLOC_SIZE 0x620
77#define DM910X_RESET 1
78#define CR0_DEFAULT 0x00E00000 /* TX & RX burst mode */
79#define CR6_DEFAULT 0x00080000 /* HD */
80#define CR7_DEFAULT 0x180c1
81#define CR15_DEFAULT 0x06 /* TxJabber RxWatchdog */
82#define TDES0_ERR_MASK 0x4302 /* TXJT, LC, EC, FUE */
83#define MAX_PACKET_SIZE 1514
84#define DMFE_MAX_MULTICAST 14
85#define RX_COPY_SIZE 100
86#define MAX_CHECK_PACKET 0x8000
87#define DM9801_NOISE_FLOOR 8
88#define DM9802_NOISE_FLOOR 5
89
90#define DMFE_10MHF 0
91#define DMFE_100MHF 1
92#define DMFE_10MFD 4
93#define DMFE_100MFD 5
94#define DMFE_AUTO 8
95#define DMFE_1M_HPNA 0x10
96
97#define DMFE_TXTH_72 0x400000 /* TX TH 72 byte */
98#define DMFE_TXTH_96 0x404000 /* TX TH 96 byte */
99#define DMFE_TXTH_128 0x0000 /* TX TH 128 byte */
100#define DMFE_TXTH_256 0x4000 /* TX TH 256 byte */
101#define DMFE_TXTH_512 0x8000 /* TX TH 512 byte */
102#define DMFE_TXTH_1K 0xC000 /* TX TH 1K byte */
103
104#define DMFE_TIMER_WUT (jiffies + HZ * 1) /* timer wakeup time : 1 second */
105#define DMFE_TX_TIMEOUT ((3*HZ)/2) /* tx packet time-out time 1.5 s" */
106#define DMFE_TX_KICK (HZ/2) /* tx packet Kick-out time 0.5 s" */
107
108#define DMFE_DBUG(dbug_now, msg, value) if (dmfe_debug || (dbug_now)) printk(KERN_ERR DRV_NAME ": %s %lx\n", (msg), (long) (value))
109
110#define SHOW_MEDIA_TYPE(mode) printk(KERN_ERR DRV_NAME ": Change Speed to %sMhz %s duplex\n",mode & 1 ?"100":"10", mode & 4 ? "full":"half");
111
112
113/* CR9 definition: SROM/MII */
114#define CR9_SROM_READ 0x4800
115#define CR9_SRCS 0x1
116#define CR9_SRCLK 0x2
117#define CR9_CRDOUT 0x8
118#define SROM_DATA_0 0x0
119#define SROM_DATA_1 0x4
120#define PHY_DATA_1 0x20000
121#define PHY_DATA_0 0x00000
122#define MDCLKH 0x10000
123
124#define PHY_POWER_DOWN 0x800
125
126#define SROM_V41_CODE 0x14
127
128#define SROM_CLK_WRITE(data, ioaddr) outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr);udelay(5);outl(data|CR9_SROM_READ|CR9_SRCS|CR9_SRCLK,ioaddr);udelay(5);outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr);udelay(5);
129
130#define __CHK_IO_SIZE(pci_id, dev_rev) ( ((pci_id)==PCI_DM9132_ID) || ((dev_rev) >= 0x02000030) ) ? DM9102A_IO_SIZE: DM9102_IO_SIZE
131#define CHK_IO_SIZE(pci_dev, dev_rev) __CHK_IO_SIZE(((pci_dev)->device << 16) | (pci_dev)->vendor, dev_rev)
132
133/* Sten Check */
134#define DEVICE net_device
135
136/* Structure/enum declaration ------------------------------- */
137struct tx_desc {
138 u32 tdes0, tdes1, tdes2, tdes3; /* Data for the card */
139 void * tx_buf_ptr; /* Data for us */
141} __attribute__ ((aligned(32)));
142
143struct rx_desc {
144 u32 rdes0, rdes1, rdes2, rdes3; /* Data for the card */
145 void * rx_skb_ptr; /* Data for us */
147} __attribute__ ((aligned(32)));
148
149static struct dmfe_private {
150 u32 chip_id; /* Chip vendor/Device ID */
151 u32 chip_revision; /* Chip revision */
153// u32 cr5_data;
157
158 u16 HPNA_command; /* For HPNA register 16 */
159 u16 HPNA_timer; /* For HPNA remote device check */
160 u16 NIC_capability; /* NIC media capability */
161 u16 PHY_reg4; /* Saved Phyxcer register 4 value */
162
163 u8 HPNA_present; /* 0:none, 1:DM9801, 2:DM9802 */
164 u8 chip_type; /* Keep DM9102A chip type */
165 u8 media_mode; /* user specify media mode */
166 u8 op_mode; /* real work media mode */
168 u8 dm910x_chk_mode; /* Operating mode check */
169
170 /* NIC SROM data */
171 unsigned char srom[128];
172 /* Etherboot Only */
176
177static struct dmfe_private *db;
178
180 DCR0 = 0x00, DCR1 = 0x08, DCR2 = 0x10, DCR3 = 0x18, DCR4 = 0x20,
181 DCR5 = 0x28, DCR6 = 0x30, DCR7 = 0x38, DCR8 = 0x40, DCR9 = 0x48,
182 DCR10 = 0x50, DCR11 = 0x58, DCR12 = 0x60, DCR13 = 0x68, DCR14 =
183 0x70,
184 DCR15 = 0x78
185};
186
188 CR6_RXSC = 0x2, CR6_PBF = 0x8, CR6_PM = 0x40, CR6_PAM = 0x80,
189 CR6_FDM = 0x200, CR6_TXSC = 0x2000, CR6_STI = 0x100000,
190 CR6_SFT = 0x200000, CR6_RXA = 0x40000000, CR6_NO_PURGE = 0x20000000
191};
192
193/* Global variable declaration ----------------------------- */
195
196static unsigned char dmfe_media_mode = DMFE_AUTO;
198
199/* For module input parameter */
200static u8 chkmode = 1;
201static u8 HPNA_mode; /* Default: Low Power/High Speed */
202static u8 HPNA_rx_cmd; /* Default: Disable Rx remote command */
203static u8 HPNA_tx_cmd; /* Default: Don't issue remote command */
204static u8 HPNA_NoiseFloor; /* Default: HPNA NoiseFloor */
205static u8 SF_mode; /* Special Function: 1:VLAN, 2:RX Flow Control
206 4: TX pause packet */
207
208
209/**********************************************
210* Descriptor Ring and Buffer defination
211***********************************************/
212struct dmfe_bss {
213 struct tx_desc txd[TX_DESC_CNT] __attribute__ ((aligned(32)));
214 unsigned char txb[TX_BUF_ALLOC * TX_DESC_CNT]
215 __attribute__ ((aligned(32)));
216 struct rx_desc rxd[RX_DESC_CNT] __attribute__ ((aligned(32)));
218 __attribute__ ((aligned(32)));
219};
220#define dmfe_bufs NIC_FAKE_BSS ( struct dmfe_bss )
221#define txd dmfe_bufs.txd
222#define txb dmfe_bufs.txb
223#define rxd dmfe_bufs.rxd
224#define rxb dmfe_bufs.rxb
225
226/* NIC specific static variables go here */
227static long int BASE;
228
229static u16 read_srom_word(long ioaddr, int offset);
230static void dmfe_init_dm910x(struct nic *nic);
231static void dmfe_descriptor_init(struct nic *, unsigned long ioaddr);
232static void update_cr6(u32, unsigned long);
233static void send_filter_frame(struct nic *nic);
234static void dm9132_id_table(struct nic *nic);
235
236static u16 phy_read(unsigned long, u8, u8, u32);
237static void phy_write(unsigned long, u8, u8, u16, u32);
238static void phy_write_1bit(unsigned long, u32);
239static u16 phy_read_1bit(unsigned long);
240static void dmfe_set_phyxcer(struct nic *nic);
241
242static void dmfe_parse_srom(struct nic *nic);
243static void dmfe_program_DM9801(struct nic *nic, int);
244static void dmfe_program_DM9802(struct nic *nic);
245
246static void dmfe_reset(struct nic *nic)
247{
248 /* system variable init */
249 db->cr6_data = CR6_DEFAULT | dmfe_cr6_user_set;
250
251 db->NIC_capability = 0xf; /* All capability */
252 db->PHY_reg4 = 0x1e0;
253
254 /* CR6 operation mode decision */
255 if (!chkmode || (db->chip_id == PCI_DM9132_ID) ||
256 (db->chip_revision >= 0x02000030)) {
257 db->cr6_data |= DMFE_TXTH_256;
258 db->cr0_data = CR0_DEFAULT;
259 db->dm910x_chk_mode = 4; /* Enter the normal mode */
260 } else {
261 db->cr6_data |= CR6_SFT; /* Store & Forward mode */
262 db->cr0_data = 0;
263 db->dm910x_chk_mode = 1; /* Enter the check mode */
264 }
265 /* Initialize DM910X board */
267
268 return;
269}
270
271/* Initialize DM910X board
272 * Reset DM910X board
273 * Initialize TX/Rx descriptor chain structure
274 * Send the set-up frame
275 * Enable Tx/Rx machine
276 */
277
278static void dmfe_init_dm910x(struct nic *nic)
279{
280 unsigned long ioaddr = BASE;
281
282 /* Reset DM910x MAC controller */
283 outl(DM910X_RESET, ioaddr + DCR0); /* RESET MAC */
284 udelay(100);
285 outl(db->cr0_data, ioaddr + DCR0);
286 udelay(5);
287
288 /* Phy addr : DM910(A)2/DM9132/9801, phy address = 1 */
289 db->phy_addr = 1;
290
291 /* Parser SROM and media mode */
293 db->media_mode = dmfe_media_mode;
294
295 /* RESET Phyxcer Chip by GPR port bit 7 */
296 outl(0x180, ioaddr + DCR12); /* Let bit 7 output port */
297 if (db->chip_id == PCI_DM9009_ID) {
298 outl(0x80, ioaddr + DCR12); /* Issue RESET signal */
299 mdelay(300); /* Delay 300 ms */
300 }
301 outl(0x0, ioaddr + DCR12); /* Clear RESET signal */
302
303 /* Process Phyxcer Media Mode */
304 if (!(db->media_mode & 0x10)) /* Force 1M mode */
306
307 /* Media Mode Process */
308 if (!(db->media_mode & DMFE_AUTO))
309 db->op_mode = db->media_mode; /* Force Mode */
310
311 /* Initiliaze Transmit/Receive descriptor and CR3/4 */
313
314 /* tx descriptor start pointer */
315 outl(virt_to_le32desc(&txd[0]), ioaddr + DCR4); /* TX DESC address */
316
317 /* rx descriptor start pointer */
318 outl(virt_to_le32desc(&rxd[0]), ioaddr + DCR3); /* RX DESC address */
319
320 /* Init CR6 to program DM910x operation */
321 update_cr6(db->cr6_data, ioaddr);
322
323 /* Send setup frame */
324 if (db->chip_id == PCI_DM9132_ID) {
325 dm9132_id_table(nic); /* DM9132 */
326 } else {
327 send_filter_frame(nic); /* DM9102/DM9102A */
328 }
329
330 /* Init CR7, interrupt active bit */
331 db->cr7_data = CR7_DEFAULT;
332 outl(db->cr7_data, ioaddr + DCR7);
333 /* Init CR15, Tx jabber and Rx watchdog timer */
334 outl(db->cr15_data, ioaddr + DCR15);
335 /* Enable DM910X Tx/Rx function */
336 db->cr6_data |= CR6_RXSC | CR6_TXSC | 0x40000;
337 update_cr6(db->cr6_data, ioaddr);
338}
339#ifdef EDEBUG
340void hex_dump(const char *data, const unsigned int len);
341#endif
342/**************************************************************************
343POLL - Wait for a frame
344***************************************************************************/
345static int dmfe_poll(struct nic *nic, int retrieve)
346{
347 u32 rdes0;
348 int entry = db->cur_rx % RX_DESC_CNT;
349 int rxlen;
350 rdes0 = le32_to_cpu(rxd[entry].rdes0);
351 if (rdes0 & 0x80000000)
352 return 0;
353
354 if (!retrieve)
355 return 1;
356
357 if ((rdes0 & 0x300) != 0x300) {
358 /* A packet without First/Last flag */
359 printf("strange Packet\n");
360 rxd[entry].rdes0 = cpu_to_le32(0x80000000);
361 return 0;
362 } else {
363 /* A packet with First/Last flag */
364 rxlen = ((rdes0 >> 16) & 0x3fff) - 4;
365 /* error summary bit check */
366 if (rdes0 & 0x8000) {
367 printf("Error\n");
368 return 0;
369 }
370 if (!(rdes0 & 0x8000) ||
371 ((db->cr6_data & CR6_PM) && (rxlen > 6))) {
372 if (db->dm910x_chk_mode & 1)
373 printf("Silly check mode\n");
374
376 memcpy(nic->packet, rxb + (entry * RX_ALLOC_SIZE),
377 nic->packetlen);
378 }
379 }
380 rxd[entry].rdes0 = cpu_to_le32(0x80000000);
381 db->cur_rx++;
382 return 1;
383}
384
385static void dmfe_irq(struct nic *nic __unused, irq_action_t action __unused)
386{
387 switch ( action ) {
388 case DISABLE :
389 break;
390 case ENABLE :
391 break;
392 case FORCE :
393 break;
394 }
395}
396
397/**************************************************************************
398TRANSMIT - Transmit a frame
399***************************************************************************/
400static void dmfe_transmit(struct nic *nic,
401 const char *dest, /* Destination */
402 unsigned int type, /* Type */
403 unsigned int size, /* size */
404 const char *packet) /* Packet */
405{
406 u16 nstype;
407 u8 *ptxb;
408
409 ptxb = &txb[db->cur_tx];
410
411 /* Stop Tx */
412 outl(0, BASE + DCR7);
413 memcpy(ptxb, dest, ETH_ALEN);
415 nstype = htons((u16) type);
416 memcpy(ptxb + 2 * ETH_ALEN, (u8 *) & nstype, 2);
417 memcpy(ptxb + ETH_HLEN, packet, size);
418
419 size += ETH_HLEN;
420 while (size < ETH_ZLEN)
421 ptxb[size++] = '\0';
422
423 /* setup the transmit descriptor */
424 txd[db->cur_tx].tdes1 = cpu_to_le32(0xe1000000 | size);
425 txd[db->cur_tx].tdes0 = cpu_to_le32(0x80000000); /* give ownership to device */
426
427 /* immediate transmit demand */
428 outl(0x1, BASE + DCR1);
429 outl(db->cr7_data, BASE + DCR7);
430
431 /* Point to next TX descriptor */
432 db->cur_tx++;
433 db->cur_tx = db->cur_tx % TX_DESC_CNT;
434}
435
436/**************************************************************************
437DISABLE - Turn off ethernet interface
438***************************************************************************/
439static void dmfe_disable ( struct nic *nic __unused, void *hwdev __unused ) {
440 /* Reset & stop DM910X board */
442 udelay(5);
443 phy_write(BASE, db->phy_addr, 0, 0x8000, db->chip_id);
444
445}
446
447/**************************************************************************
448PROBE - Look for an adapter, this routine's visible to the outside
449***************************************************************************/
450
451#define board_found 1
452#define valid_link 0
453static int dmfe_probe ( struct nic *nic, struct pci_device *pci ) {
454
455 uint32_t dev_rev, pci_pmr;
456 int i;
457
458 if (pci->ioaddr == 0)
459 return 0;
460
461 BASE = pci->ioaddr;
462 printf("dmfe.c: Found %s Vendor=0x%hX Device=0x%hX\n",
463 pci->id->name, pci->vendor, pci->device);
464
465 /* Read Chip revision */
466 pci_read_config_dword(pci, PCI_REVISION, &dev_rev);
467 dprintf(("Revision %lX\n", dev_rev));
468
469 /* point to private storage */
470 db = &dfx;
471
472 db->chip_id = ((u32) pci->device << 16) | pci->vendor;
474 db->chip_revision = dev_rev;
475
476 pci_read_config_dword(pci, 0x50, &pci_pmr);
477 pci_pmr &= 0x70000;
478 if ((pci_pmr == 0x10000) && (dev_rev == 0x02000031))
479 db->chip_type = 1; /* DM9102A E3 */
480 else
481 db->chip_type = 0;
482
483 dprintf(("Chip type : %d\n", db->chip_type));
484
485 /* read 64 word srom data */
486 for (i = 0; i < 64; i++)
487 ((u16 *) db->srom)[i] = cpu_to_le16(read_srom_word(BASE, i));
488
489 /* Set Node address */
490 for (i = 0; i < 6; i++)
491 nic->node_addr[i] = db->srom[20 + i];
492
493 /* Print out some hardware info */
494 DBG ( "%s: %s at ioaddr %4.4lx\n",
495 pci->id->name, eth_ntoa ( nic->node_addr ), BASE );
496
497 /* Set the card as PCI Bus Master */
499
501
502 nic->irqno = 0;
503 nic->ioaddr = pci->ioaddr;
504
505 /* point to NIC specific routines */
507
508 return 1;
509}
510
511/*
512 * Initialize transmit/Receive descriptor
513 * Using Chain structure, and allocate Tx/Rx buffer
514 */
515
516static void dmfe_descriptor_init(struct nic *nic __unused, unsigned long ioaddr)
517{
518 int i;
519 db->cur_tx = 0;
520 db->cur_rx = 0;
521
522 /* tx descriptor start pointer */
523 outl(virt_to_le32desc(&txd[0]), ioaddr + DCR4); /* TX DESC address */
524
525 /* rx descriptor start pointer */
526 outl(virt_to_le32desc(&rxd[0]), ioaddr + DCR3); /* RX DESC address */
527
528 /* Init Transmit chain */
529 for (i = 0; i < TX_DESC_CNT; i++) {
530 txd[i].tx_buf_ptr = &txb[i];
531 txd[i].tdes0 = cpu_to_le32(0);
532 txd[i].tdes1 = cpu_to_le32(0x81000000); /* IC, chain */
533 txd[i].tdes2 = cpu_to_le32(virt_to_bus(&txb[i]));
534 txd[i].tdes3 = cpu_to_le32(virt_to_bus(&txd[i + 1]));
535 txd[i].next_tx_desc = &txd[i + 1];
536 }
537 /* Mark the last entry as wrapping the ring */
538 txd[i - 1].tdes3 = virt_to_le32desc(&txd[0]);
539 txd[i - 1].next_tx_desc = &txd[0];
540
541 /* receive descriptor chain */
542 for (i = 0; i < RX_DESC_CNT; i++) {
543 rxd[i].rx_skb_ptr = &rxb[i * RX_ALLOC_SIZE];
544 rxd[i].rdes0 = cpu_to_le32(0x80000000);
545 rxd[i].rdes1 = cpu_to_le32(0x01000600);
546 rxd[i].rdes2 =
548 rxd[i].rdes3 = cpu_to_le32(virt_to_bus(&rxd[i + 1]));
549 rxd[i].next_rx_desc = &rxd[i + 1];
550 }
551 /* Mark the last entry as wrapping the ring */
552 rxd[i - 1].rdes3 = cpu_to_le32(virt_to_bus(&rxd[0]));
553 rxd[i - 1].next_rx_desc = &rxd[0];
554
555}
556
557/*
558 * Update CR6 value
559 * Firstly stop DM910X , then written value and start
560 */
561
562static void update_cr6(u32 cr6_data, unsigned long ioaddr)
563{
564 u32 cr6_tmp;
565
566 cr6_tmp = cr6_data & ~0x2002; /* stop Tx/Rx */
567 outl(cr6_tmp, ioaddr + DCR6);
568 udelay(5);
569 outl(cr6_data, ioaddr + DCR6);
570 udelay(5);
571}
572
573
574/*
575 * Send a setup frame for DM9132
576 * This setup frame initialize DM910X address filter mode
577*/
578
579static void dm9132_id_table(struct nic *nic __unused)
580{
581#ifdef LINUX
582 u16 *addrptr;
583 u8 dmi_addr[8];
584 unsigned long ioaddr = BASE + 0xc0; /* ID Table */
585 u32 hash_val;
586 u16 i, hash_table[4];
587#endif
588 dprintf(("dm9132_id_table\n"));
589
590 printf("FIXME: This function is broken. If you have this card contact "
591 "Timothy Legge at the etherboot-user list\n");
592
593#ifdef LINUX
594 //DMFE_DBUG(0, "dm9132_id_table()", 0);
595
596 /* Node address */
597 addrptr = (u16 *) nic->node_addr;
598 outw(addrptr[0], ioaddr);
599 ioaddr += 4;
600 outw(addrptr[1], ioaddr);
601 ioaddr += 4;
602 outw(addrptr[2], ioaddr);
603 ioaddr += 4;
604
605 /* Clear Hash Table */
606 for (i = 0; i < 4; i++)
607 hash_table[i] = 0x0;
608
609 /* broadcast address */
610 hash_table[3] = 0x8000;
611
612 /* the multicast address in Hash Table : 64 bits */
613 for (mcptr = mc_list, i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
614 hash_val = cal_CRC((char *) mcptr->dmi_addr, 6, 0) & 0x3f;
615 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
616 }
617
618 /* Write the hash table to MAC MD table */
619 for (i = 0; i < 4; i++, ioaddr += 4)
620 outw(hash_table[i], ioaddr);
621#endif
622}
623
624
625/*
626 * Send a setup frame for DM9102/DM9102A
627 * This setup frame initialize DM910X address filter mode
628 */
629
630static void send_filter_frame(struct nic *nic)
631{
632
633 u8 *ptxb;
634 int i;
635
636 dprintf(("send_filter_frame\n"));
637 /* point to the current txb incase multiple tx_rings are used */
638 ptxb = &txb[db->cur_tx];
639
640 /* construct perfect filter frame with mac address as first match
641 and broadcast address for all others */
642 for (i = 0; i < 192; i++)
643 ptxb[i] = 0xFF;
644 ptxb[0] = nic->node_addr[0];
645 ptxb[1] = nic->node_addr[1];
646 ptxb[4] = nic->node_addr[2];
647 ptxb[5] = nic->node_addr[3];
648 ptxb[8] = nic->node_addr[4];
649 ptxb[9] = nic->node_addr[5];
650
651 /* prepare the setup frame */
652 txd[db->cur_tx].tdes1 = cpu_to_le32(0x890000c0);
653 txd[db->cur_tx].tdes0 = cpu_to_le32(0x80000000);
654 update_cr6(db->cr6_data | 0x2000, BASE);
655 outl(0x1, BASE + DCR1); /* Issue Tx polling */
656 update_cr6(db->cr6_data, BASE);
657 db->cur_tx++;
658}
659
660/*
661 * Read one word data from the serial ROM
662 */
663
665{
666 int i;
667 u16 srom_data = 0;
668 long cr9_ioaddr = ioaddr + DCR9;
669
670 outl(CR9_SROM_READ, cr9_ioaddr);
671 outl(CR9_SROM_READ | CR9_SRCS, cr9_ioaddr);
672
673 /* Send the Read Command 110b */
674 SROM_CLK_WRITE(SROM_DATA_1, cr9_ioaddr);
675 SROM_CLK_WRITE(SROM_DATA_1, cr9_ioaddr);
676 SROM_CLK_WRITE(SROM_DATA_0, cr9_ioaddr);
677
678 /* Send the offset */
679 for (i = 5; i >= 0; i--) {
680 srom_data =
681 (offset & (1 << i)) ? SROM_DATA_1 : SROM_DATA_0;
682 SROM_CLK_WRITE(srom_data, cr9_ioaddr);
683 }
684
685 outl(CR9_SROM_READ | CR9_SRCS, cr9_ioaddr);
686
687 for (i = 16; i > 0; i--) {
688 outl(CR9_SROM_READ | CR9_SRCS | CR9_SRCLK, cr9_ioaddr);
689 udelay(5);
690 srom_data =
691 (srom_data << 1) | ((inl(cr9_ioaddr) & CR9_CRDOUT) ? 1
692 : 0);
693 outl(CR9_SROM_READ | CR9_SRCS, cr9_ioaddr);
694 udelay(5);
695 }
696
697 outl(CR9_SROM_READ, cr9_ioaddr);
698 return srom_data;
699}
700
701
702/*
703 * Auto sense the media mode
704 */
705
706#if 0 /* not used */
707static u8 dmfe_sense_speed(struct nic *nic __unused)
708{
709 u8 ErrFlag = 0;
710 u16 phy_mode;
711
712 /* CR6 bit18=0, select 10/100M */
713 update_cr6((db->cr6_data & ~0x40000), BASE);
714
715 phy_mode = phy_read(BASE, db->phy_addr, 1, db->chip_id);
716 phy_mode = phy_read(BASE, db->phy_addr, 1, db->chip_id);
717
718 if ((phy_mode & 0x24) == 0x24) {
719 if (db->chip_id == PCI_DM9132_ID) /* DM9132 */
720 phy_mode =
721 phy_read(BASE, db->phy_addr, 7,
722 db->chip_id) & 0xf000;
723 else /* DM9102/DM9102A */
724 phy_mode =
725 phy_read(BASE, db->phy_addr, 17,
726 db->chip_id) & 0xf000;
727 /* printk(DRV_NAME ": Phy_mode %x ",phy_mode); */
728 switch (phy_mode) {
729 case 0x1000:
730 db->op_mode = DMFE_10MHF;
731 break;
732 case 0x2000:
733 db->op_mode = DMFE_10MFD;
734 break;
735 case 0x4000:
736 db->op_mode = DMFE_100MHF;
737 break;
738 case 0x8000:
739 db->op_mode = DMFE_100MFD;
740 break;
741 default:
742 db->op_mode = DMFE_10MHF;
743 ErrFlag = 1;
744 break;
745 }
746 } else {
747 db->op_mode = DMFE_10MHF;
748 //DMFE_DBUG(0, "Link Failed :", phy_mode);
749 ErrFlag = 1;
750 }
751
752 return ErrFlag;
753}
754#endif
755
756/*
757 * Set 10/100 phyxcer capability
758 * AUTO mode : phyxcer register4 is NIC capability
759 * Force mode: phyxcer register4 is the force media
760 */
761
762static void dmfe_set_phyxcer(struct nic *nic __unused)
763{
764 u16 phy_reg;
765
766 /* Select 10/100M phyxcer */
767 db->cr6_data &= ~0x40000;
768 update_cr6(db->cr6_data, BASE);
769
770 /* DM9009 Chip: Phyxcer reg18 bit12=0 */
771 if (db->chip_id == PCI_DM9009_ID) {
772 phy_reg =
773 phy_read(BASE, db->phy_addr, 18,
774 db->chip_id) & ~0x1000;
775 phy_write(BASE, db->phy_addr, 18, phy_reg, db->chip_id);
776 }
777
778 /* Phyxcer capability setting */
779 phy_reg = phy_read(BASE, db->phy_addr, 4, db->chip_id) & ~0x01e0;
780
781 if (db->media_mode & DMFE_AUTO) {
782 /* AUTO Mode */
783 phy_reg |= db->PHY_reg4;
784 } else {
785 /* Force Mode */
786 switch (db->media_mode) {
787 case DMFE_10MHF:
788 phy_reg |= 0x20;
789 break;
790 case DMFE_10MFD:
791 phy_reg |= 0x40;
792 break;
793 case DMFE_100MHF:
794 phy_reg |= 0x80;
795 break;
796 case DMFE_100MFD:
797 phy_reg |= 0x100;
798 break;
799 }
800 if (db->chip_id == PCI_DM9009_ID)
801 phy_reg &= 0x61;
802 }
803
804 /* Write new capability to Phyxcer Reg4 */
805 if (!(phy_reg & 0x01e0)) {
806 phy_reg |= db->PHY_reg4;
807 db->media_mode |= DMFE_AUTO;
808 }
809 phy_write(BASE, db->phy_addr, 4, phy_reg, db->chip_id);
810
811 /* Restart Auto-Negotiation */
812 if (db->chip_type && (db->chip_id == PCI_DM9102_ID))
813 phy_write(BASE, db->phy_addr, 0, 0x1800, db->chip_id);
814 if (!db->chip_type)
815 phy_write(BASE, db->phy_addr, 0, 0x1200, db->chip_id);
816}
817
818
819/*
820 * Process op-mode
821 * AUTO mode : PHY controller in Auto-negotiation Mode
822 * Force mode: PHY controller in force mode with HUB
823 * N-way force capability with SWITCH
824 */
825
826#if 0 /* not used */
827static void dmfe_process_mode(struct nic *nic __unused)
828{
829 u16 phy_reg;
830
831 /* Full Duplex Mode Check */
832 if (db->op_mode & 0x4)
833 db->cr6_data |= CR6_FDM; /* Set Full Duplex Bit */
834 else
835 db->cr6_data &= ~CR6_FDM; /* Clear Full Duplex Bit */
836
837 /* Transciver Selection */
838 if (db->op_mode & 0x10) /* 1M HomePNA */
839 db->cr6_data |= 0x40000; /* External MII select */
840 else
841 db->cr6_data &= ~0x40000; /* Internal 10/100 transciver */
842
843 update_cr6(db->cr6_data, BASE);
844
845 /* 10/100M phyxcer force mode need */
846 if (!(db->media_mode & 0x18)) {
847 /* Forece Mode */
848 phy_reg = phy_read(BASE, db->phy_addr, 6, db->chip_id);
849 if (!(phy_reg & 0x1)) {
850 /* parter without N-Way capability */
851 phy_reg = 0x0;
852 switch (db->op_mode) {
853 case DMFE_10MHF:
854 phy_reg = 0x0;
855 break;
856 case DMFE_10MFD:
857 phy_reg = 0x100;
858 break;
859 case DMFE_100MHF:
860 phy_reg = 0x2000;
861 break;
862 case DMFE_100MFD:
863 phy_reg = 0x2100;
864 break;
865 }
866 phy_write(BASE, db->phy_addr, 0, phy_reg,
867 db->chip_id);
868 if (db->chip_type
869 && (db->chip_id == PCI_DM9102_ID))
870 mdelay(20);
871 phy_write(BASE, db->phy_addr, 0, phy_reg,
872 db->chip_id);
873 }
874 }
875}
876#endif
877
878/*
879 * Write a word to Phy register
880 */
881
882static void phy_write(unsigned long iobase, u8 phy_addr, u8 offset,
883 u16 phy_data, u32 chip_id)
884{
885 u16 i;
886 unsigned long ioaddr;
887
888 if (chip_id == PCI_DM9132_ID) {
889 ioaddr = iobase + 0x80 + offset * 4;
890 outw(phy_data, ioaddr);
891 } else {
892 /* DM9102/DM9102A Chip */
893 ioaddr = iobase + DCR9;
894
895 /* Send 33 synchronization clock to Phy controller */
896 for (i = 0; i < 35; i++)
898
899 /* Send start command(01) to Phy */
902
903 /* Send write command(01) to Phy */
906
907 /* Send Phy address */
908 for (i = 0x10; i > 0; i = i >> 1)
910 phy_addr & i ? PHY_DATA_1 :
911 PHY_DATA_0);
912
913 /* Send register address */
914 for (i = 0x10; i > 0; i = i >> 1)
916 offset & i ? PHY_DATA_1 :
917 PHY_DATA_0);
918
919 /* written trasnition */
922
923 /* Write a word data to PHY controller */
924 for (i = 0x8000; i > 0; i >>= 1)
926 phy_data & i ? PHY_DATA_1 :
927 PHY_DATA_0);
928 }
929}
930
931
932/*
933 * Read a word data from phy register
934 */
935
936static u16 phy_read(unsigned long iobase, u8 phy_addr, u8 offset,
937 u32 chip_id)
938{
939 int i;
940 u16 phy_data;
941 unsigned long ioaddr;
942
943 if (chip_id == PCI_DM9132_ID) {
944 /* DM9132 Chip */
945 ioaddr = iobase + 0x80 + offset * 4;
946 phy_data = inw(ioaddr);
947 } else {
948 /* DM9102/DM9102A Chip */
949 ioaddr = iobase + DCR9;
950
951 /* Send 33 synchronization clock to Phy controller */
952 for (i = 0; i < 35; i++)
954
955 /* Send start command(01) to Phy */
958
959 /* Send read command(10) to Phy */
962
963 /* Send Phy address */
964 for (i = 0x10; i > 0; i = i >> 1)
966 phy_addr & i ? PHY_DATA_1 :
967 PHY_DATA_0);
968
969 /* Send register address */
970 for (i = 0x10; i > 0; i = i >> 1)
972 offset & i ? PHY_DATA_1 :
973 PHY_DATA_0);
974
975 /* Skip transition state */
977
978 /* read 16bit data */
979 for (phy_data = 0, i = 0; i < 16; i++) {
980 phy_data <<= 1;
981 phy_data |= phy_read_1bit(ioaddr);
982 }
983 }
984
985 return phy_data;
986}
987
988
989/*
990 * Write one bit data to Phy Controller
991 */
992
993static void phy_write_1bit(unsigned long ioaddr, u32 phy_data)
994{
995 outl(phy_data, ioaddr); /* MII Clock Low */
996 udelay(1);
997 outl(phy_data | MDCLKH, ioaddr); /* MII Clock High */
998 udelay(1);
999 outl(phy_data, ioaddr); /* MII Clock Low */
1000 udelay(1);
1001}
1002
1003
1004/*
1005 * Read one bit phy data from PHY controller
1006 */
1007
1008static u16 phy_read_1bit(unsigned long ioaddr)
1009{
1010 u16 phy_data;
1011
1012 outl(0x50000, ioaddr);
1013 udelay(1);
1014 phy_data = (inl(ioaddr) >> 19) & 0x1;
1015 outl(0x40000, ioaddr);
1016 udelay(1);
1017
1018 return phy_data;
1019}
1020
1021
1022/*
1023 * Parser SROM and media mode
1024 */
1025
1026static void dmfe_parse_srom(struct nic *nic)
1027{
1028 unsigned char *srom = db->srom;
1029 int dmfe_mode, tmp_reg;
1030
1031 /* Init CR15 */
1032 db->cr15_data = CR15_DEFAULT;
1033
1034 /* Check SROM Version */
1035 if (((int) srom[18] & 0xff) == SROM_V41_CODE) {
1036 /* SROM V4.01 */
1037 /* Get NIC support media mode */
1038 db->NIC_capability = *(u16 *) (srom + 34);
1039 db->PHY_reg4 = 0;
1040 for (tmp_reg = 1; tmp_reg < 0x10; tmp_reg <<= 1) {
1041 switch (db->NIC_capability & tmp_reg) {
1042 case 0x1:
1043 db->PHY_reg4 |= 0x0020;
1044 break;
1045 case 0x2:
1046 db->PHY_reg4 |= 0x0040;
1047 break;
1048 case 0x4:
1049 db->PHY_reg4 |= 0x0080;
1050 break;
1051 case 0x8:
1052 db->PHY_reg4 |= 0x0100;
1053 break;
1054 }
1055 }
1056
1057 /* Media Mode Force or not check */
1058 dmfe_mode = *((int *) srom + 34) & *((int *) srom + 36);
1059 switch (dmfe_mode) {
1060 case 0x4:
1062 break; /* 100MHF */
1063 case 0x2:
1065 break; /* 10MFD */
1066 case 0x8:
1068 break; /* 100MFD */
1069 case 0x100:
1070 case 0x200:
1072 break; /* HomePNA */
1073 }
1074
1075 /* Special Function setting */
1076 /* VLAN function */
1077 if ((SF_mode & 0x1) || (srom[43] & 0x80))
1078 db->cr15_data |= 0x40;
1079
1080 /* Flow Control */
1081 if ((SF_mode & 0x2) || (srom[40] & 0x1))
1082 db->cr15_data |= 0x400;
1083
1084 /* TX pause packet */
1085 if ((SF_mode & 0x4) || (srom[40] & 0xe))
1086 db->cr15_data |= 0x9800;
1087 }
1088
1089 /* Parse HPNA parameter */
1090 db->HPNA_command = 1;
1091
1092 /* Accept remote command or not */
1093 if (HPNA_rx_cmd == 0)
1094 db->HPNA_command |= 0x8000;
1095
1096 /* Issue remote command & operation mode */
1097 if (HPNA_tx_cmd == 1)
1098 switch (HPNA_mode) { /* Issue Remote Command */
1099 case 0:
1100 db->HPNA_command |= 0x0904;
1101 break;
1102 case 1:
1103 db->HPNA_command |= 0x0a00;
1104 break;
1105 case 2:
1106 db->HPNA_command |= 0x0506;
1107 break;
1108 case 3:
1109 db->HPNA_command |= 0x0602;
1110 break;
1111 } else
1112 switch (HPNA_mode) { /* Don't Issue */
1113 case 0:
1114 db->HPNA_command |= 0x0004;
1115 break;
1116 case 1:
1117 db->HPNA_command |= 0x0000;
1118 break;
1119 case 2:
1120 db->HPNA_command |= 0x0006;
1121 break;
1122 case 3:
1123 db->HPNA_command |= 0x0002;
1124 break;
1125 }
1126
1127 /* Check DM9801 or DM9802 present or not */
1128 db->HPNA_present = 0;
1129 update_cr6(db->cr6_data | 0x40000, BASE);
1130 tmp_reg = phy_read(BASE, db->phy_addr, 3, db->chip_id);
1131 if ((tmp_reg & 0xfff0) == 0xb900) {
1132 /* DM9801 or DM9802 present */
1133 db->HPNA_timer = 8;
1134 if (phy_read(BASE, db->phy_addr, 31, db->chip_id) ==
1135 0x4404) {
1136 /* DM9801 HomeRun */
1137 db->HPNA_present = 1;
1138 dmfe_program_DM9801(nic, tmp_reg);
1139 } else {
1140 /* DM9802 LongRun */
1141 db->HPNA_present = 2;
1143 }
1144 }
1145
1146}
1147
1148/*
1149 * Init HomeRun DM9801
1150 */
1151
1152static void dmfe_program_DM9801(struct nic *nic __unused, int HPNA_rev)
1153{
1154 u32 reg17, reg25;
1155
1156 if (!HPNA_NoiseFloor)
1158 switch (HPNA_rev) {
1159 case 0xb900: /* DM9801 E3 */
1160 db->HPNA_command |= 0x1000;
1161 reg25 = phy_read(BASE, db->phy_addr, 24, db->chip_id);
1162 reg25 = ((reg25 + HPNA_NoiseFloor) & 0xff) | 0xf000;
1163 reg17 = phy_read(BASE, db->phy_addr, 17, db->chip_id);
1164 break;
1165 case 0xb901: /* DM9801 E4 */
1166 reg25 = phy_read(BASE, db->phy_addr, 25, db->chip_id);
1167 reg25 = (reg25 & 0xff00) + HPNA_NoiseFloor;
1168 reg17 = phy_read(BASE, db->phy_addr, 17, db->chip_id);
1169 reg17 = (reg17 & 0xfff0) + HPNA_NoiseFloor + 3;
1170 break;
1171 case 0xb902: /* DM9801 E5 */
1172 case 0xb903: /* DM9801 E6 */
1173 default:
1174 db->HPNA_command |= 0x1000;
1175 reg25 = phy_read(BASE, db->phy_addr, 25, db->chip_id);
1176 reg25 = (reg25 & 0xff00) + HPNA_NoiseFloor - 5;
1177 reg17 = phy_read(BASE, db->phy_addr, 17, db->chip_id);
1178 reg17 = (reg17 & 0xfff0) + HPNA_NoiseFloor;
1179 break;
1180 }
1181 phy_write(BASE, db->phy_addr, 16, db->HPNA_command, db->chip_id);
1182 phy_write(BASE, db->phy_addr, 17, reg17, db->chip_id);
1183 phy_write(BASE, db->phy_addr, 25, reg25, db->chip_id);
1184}
1185
1186
1187/*
1188 * Init HomeRun DM9802
1189 */
1190
1192{
1193 u32 phy_reg;
1194
1195 if (!HPNA_NoiseFloor)
1197 phy_write(BASE, db->phy_addr, 16, db->HPNA_command, db->chip_id);
1198 phy_reg = phy_read(BASE, db->phy_addr, 25, db->chip_id);
1199 phy_reg = (phy_reg & 0xff00) + HPNA_NoiseFloor;
1200 phy_write(BASE, db->phy_addr, 25, phy_reg, db->chip_id);
1201}
1202
1203static struct nic_operations dmfe_operations = {
1204 .connect = dummy_connect,
1205 .poll = dmfe_poll,
1206 .transmit = dmfe_transmit,
1207 .irq = dmfe_irq,
1208
1209};
1210
1211static struct pci_device_id dmfe_nics[] = {
1212 PCI_ROM(0x1282, 0x9009, "dmfe9009", "Davicom 9009", 0),
1213 PCI_ROM(0x1282, 0x9100, "dmfe9100", "Davicom 9100", 0),
1214 PCI_ROM(0x1282, 0x9102, "dmfe9102", "Davicom 9102", 0),
1215 PCI_ROM(0x1282, 0x9132, "dmfe9132", "Davicom 9132", 0), /* Needs probably some fixing */
1216};
1217
1218PCI_DRIVER ( dmfe_driver, dmfe_nics, PCI_NO_CLASS );
1219
1220DRIVER ( "DMFE/PCI", nic_driver, pci_driver, dmfe_driver,
1222
1223/*
1224 * Local variables:
1225 * c-basic-offset: 8
1226 * c-indent-level: 8
1227 * tab-width: 8
1228 * End:
1229 */
#define BASE
Definition 3c595.h:69
unsigned int uint32_t
Definition stdint.h:12
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
Definition string.h:151
#define RX_DESC_CNT
Definition bnx2.h:3884
#define TX_DESC_CNT
Definition bnx2.h:3880
uint16_t offset
Offset to command line.
Definition bzimage.h:3
static unsigned long ioaddr
Definition davicom.c:129
#define PHY_DATA_1
Definition davicom.c:85
#define rxb
Definition davicom.c:147
#define txb
Definition davicom.c:145
#define txd
Definition davicom.c:144
#define MDCLKH
Definition davicom.c:86
#define rxd
Definition davicom.c:146
#define PHY_DATA_0
Definition davicom.c:84
static unsigned char dmfe_media_mode
Definition dmfe.c:196
#define CR9_CRDOUT
Definition dmfe.c:117
static void phy_write_1bit(unsigned long, u32)
Definition dmfe.c:993
static u8 HPNA_mode
Definition dmfe.c:201
#define DMFE_100MHF
Definition dmfe.c:91
static void send_filter_frame(struct nic *nic)
Definition dmfe.c:630
static void update_cr6(u32, unsigned long)
Definition dmfe.c:562
static void dm9132_id_table(struct nic *nic)
#define DM9802_NOISE_FLOOR
Definition dmfe.c:88
static void dmfe_disable(struct nic *nic __unused, void *hwdev __unused)
Definition dmfe.c:439
static void phy_write(unsigned long, u8, u8, u16, u32)
Definition dmfe.c:882
static struct dmfe_private * db
Definition dmfe.c:177
#define PCI_DM9009_ID
Definition dmfe.c:65
static void dmfe_transmit(struct nic *nic, const char *dest, unsigned int type, unsigned int size, const char *packet)
Definition dmfe.c:400
static struct nic_operations dmfe_operations
Definition dmfe.c:194
static struct dmfe_private dfx
#define DMFE_10MHF
Definition dmfe.c:90
dmfe_CR6_bits
Definition dmfe.c:187
@ CR6_PAM
Definition dmfe.c:188
@ CR6_RXSC
Definition dmfe.c:188
@ CR6_STI
Definition dmfe.c:189
@ CR6_SFT
Definition dmfe.c:190
@ CR6_PM
Definition dmfe.c:188
@ CR6_RXA
Definition dmfe.c:190
@ CR6_PBF
Definition dmfe.c:188
@ CR6_TXSC
Definition dmfe.c:189
@ CR6_FDM
Definition dmfe.c:189
@ CR6_NO_PURGE
Definition dmfe.c:190
static void dmfe_reset(struct nic *nic)
Definition dmfe.c:246
#define CR15_DEFAULT
Definition dmfe.c:81
#define virt_to_le32desc(addr)
Definition dmfe.c:58
static void dmfe_parse_srom(struct nic *nic)
Definition dmfe.c:1026
static u16 read_srom_word(long ioaddr, int offset)
Definition dmfe.c:664
dmfe_offsets
Definition dmfe.c:179
@ DCR7
Definition dmfe.c:181
@ DCR9
Definition dmfe.c:181
@ DCR15
Definition dmfe.c:184
@ DCR10
Definition dmfe.c:182
@ DCR14
Definition dmfe.c:182
@ DCR11
Definition dmfe.c:182
@ DCR12
Definition dmfe.c:182
@ DCR1
Definition dmfe.c:180
@ DCR8
Definition dmfe.c:181
@ DCR5
Definition dmfe.c:181
@ DCR0
Definition dmfe.c:180
@ DCR2
Definition dmfe.c:180
@ DCR3
Definition dmfe.c:180
@ DCR4
Definition dmfe.c:180
@ DCR13
Definition dmfe.c:182
@ DCR6
Definition dmfe.c:181
static int dmfe_poll(struct nic *nic, int retrieve)
Definition dmfe.c:345
static void dmfe_irq(struct nic *nic __unused, irq_action_t action __unused)
Definition dmfe.c:385
#define DMFE_1M_HPNA
Definition dmfe.c:95
#define DM9801_NOISE_FLOOR
Definition dmfe.c:87
static u8 HPNA_tx_cmd
Definition dmfe.c:203
static struct pci_device_id dmfe_nics[]
Definition dmfe.c:1211
#define CR0_DEFAULT
Definition dmfe.c:78
static int dmfe_probe(struct nic *nic, struct pci_device *pci)
Definition dmfe.c:453
#define SROM_V41_CODE
Definition dmfe.c:126
#define dprintf(x)
Definition dmfe.c:54
#define CR9_SROM_READ
Definition dmfe.c:114
#define RX_ALLOC_SIZE
Definition dmfe.c:76
static u16 phy_read_1bit(unsigned long)
Definition dmfe.c:1008
#define SROM_DATA_1
Definition dmfe.c:119
#define CR9_SRCLK
Definition dmfe.c:116
static u8 HPNA_rx_cmd
Definition dmfe.c:202
static void dmfe_program_DM9802(struct nic *nic)
#define PCI_DM9102_ID
Definition dmfe.c:63
#define dmfe_bufs
Definition dmfe.c:220
static void dmfe_program_DM9801(struct nic *nic, int)
#define TX_BUF_ALLOC
Definition dmfe.c:75
static u8 SF_mode
Definition dmfe.c:205
static void dmfe_init_dm910x(struct nic *nic)
Definition dmfe.c:278
#define DMFE_TXTH_256
Definition dmfe.c:100
#define DMFE_AUTO
Definition dmfe.c:94
#define CR7_DEFAULT
Definition dmfe.c:80
#define SROM_CLK_WRITE(data, ioaddr)
Definition dmfe.c:128
#define SROM_DATA_0
Definition dmfe.c:118
#define DMFE_10MFD
Definition dmfe.c:92
#define DM910X_RESET
Definition dmfe.c:77
static u32 dmfe_cr6_user_set
Definition dmfe.c:197
static void dmfe_set_phyxcer(struct nic *nic)
static void dmfe_descriptor_init(struct nic *, unsigned long ioaddr)
#define RX_DESC_CNT
Definition dmfe.c:71
static u16 phy_read(unsigned long, u8, u8, u32)
Definition dmfe.c:936
static u8 chkmode
Definition dmfe.c:200
#define CR6_DEFAULT
Definition dmfe.c:79
static u8 HPNA_NoiseFloor
Definition dmfe.c:204
#define PCI_DM9132_ID
Definition dmfe.c:62
#define TX_DESC_CNT
Definition dmfe.c:70
#define CR9_SRCS
Definition dmfe.c:115
#define DMFE_100MFD
Definition dmfe.c:93
ring len
Length.
Definition dwmac.h:226
uint32_t type
Operating system type.
Definition ena.h:1
uint8_t data[48]
Additional event data.
Definition ena.h:11
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition ethernet.c:176
Ethernet protocol.
#define __unused
Declare a variable or data structure as unused.
Definition compiler.h:573
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
uint16_t size
Buffer size.
Definition dwmac.h:3
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define ETH_ZLEN
Definition if_ether.h:11
#define ETH_ALEN
Definition if_ether.h:9
#define ETH_HLEN
Definition if_ether.h:10
#define u8
Definition igbvf_osdep.h:40
#define le32_to_cpu(value)
Definition byteswap.h:114
#define cpu_to_le32(value)
Definition byteswap.h:108
#define htons(value)
Definition byteswap.h:136
#define cpu_to_le16(value)
Definition byteswap.h:107
#define __attribute__(x)
Definition compiler.h:10
#define inw(io_addr)
Definition io.h:292
#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
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int dummy_connect(struct nic *nic __unused)
Definition legacy.c:175
#define DRIVER(_name_text, _unused2, _unused3, _name, _probe, _disable, _fake_bss)
Definition nic.h:220
irq_action_t
Definition nic.h:34
@ FORCE
Definition nic.h:37
@ ENABLE
Definition nic.h:36
@ DISABLE
Definition nic.h:35
#define PCI_DRIVER(_name, _ids, _class)
Definition nic.h:105
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
Definition pci.c:241
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
Definition pci.c:97
PCI bus.
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308
#define PCI_REVISION
PCI revision.
Definition pci.h:45
#define PCI_BASE_ADDRESS_0
Definition pci.h:63
@ rxlen
Definition sis900.h:35
unsigned char txb[TX_BUF_ALLOC *TX_DESC_CNT]
Definition dmfe.c:215
unsigned char rxb[RX_ALLOC_SIZE *RX_DESC_CNT]
Definition dmfe.c:218
struct rx_desc rxd[RX_DESC_CNT]
Definition dmfe.c:216
struct tx_desc txd[TX_DESC_CNT]
Definition dmfe.c:213
u16 PHY_reg4
Definition dmfe.c:161
u32 cr0_data
Definition dmfe.c:152
u8 phy_addr
Definition dmfe.c:167
u8 cur_tx
Definition dmfe.c:173
u8 media_mode
Definition dmfe.c:165
u8 cur_rx
Definition dmfe.c:174
u32 chip_id
Definition dmfe.c:150
u32 cr7_data
Definition dmfe.c:155
u8 HPNA_present
Definition dmfe.c:163
u8 op_mode
Definition dmfe.c:166
u32 chip_revision
Definition dmfe.c:151
u32 cr6_data
Definition dmfe.c:154
unsigned char srom[128]
Definition dmfe.c:171
u8 chip_type
Definition dmfe.c:164
u16 NIC_capability
Definition dmfe.c:160
u16 HPNA_command
Definition dmfe.c:158
u8 dm910x_chk_mode
Definition dmfe.c:168
u32 cr15_data
Definition dmfe.c:156
u16 HPNA_timer
Definition dmfe.c:159
Definition nic.h:49
unsigned char * packet
Definition nic.h:53
unsigned char * node_addr
Definition nic.h:52
unsigned int packetlen
Definition nic.h:54
unsigned char irqno
Definition nic.h:56
unsigned int ioaddr
Definition nic.h:55
struct nic_operations * nic_op
Definition nic.h:50
A PCI device ID list entry.
Definition pci.h:175
const char * name
Name.
Definition pci.h:177
A PCI device.
Definition pci.h:211
unsigned long ioaddr
I/O address.
Definition pci.h:226
struct pci_device_id * id
Driver device ID.
Definition pci.h:248
uint16_t vendor
Vendor ID.
Definition pci.h:228
uint16_t device
Device ID.
Definition pci.h:230
A PCI driver.
Definition pci.h:252
u32 rdes1
Definition dmfe.c:144
u32 rdes2
Definition dmfe.c:144
struct rx_desc * next_rx_desc
Definition dmfe.c:146
void * rx_skb_ptr
Definition dmfe.c:145
u32 rdes3
Definition dmfe.c:144
u32 rdes0
Definition dmfe.c:144
u32 tdes1
Definition dmfe.c:138
u32 tdes3
Definition dmfe.c:138
u32 tdes0
Definition dmfe.c:138
struct tx_desc * next_tx_desc
Definition dmfe.c:140
u32 tdes2
Definition dmfe.c:138
void * tx_buf_ptr
Definition dmfe.c:139
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition timer.c:61
#define u16
Definition vga.h:20
#define u32
Definition vga.h:21
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465