iPXE
davicom.c
Go to the documentation of this file.
1 #ifdef ALLMULTI
2 #error multicast support is not yet implemented
3 #endif
4 /*
5  DAVICOM DM9009/DM9102/DM9102A Etherboot Driver V1.00
6 
7  This driver was ported from Marty Connor's Tulip Etherboot driver.
8  Thanks Marty Connor (mdc@etherboot.org)
9 
10  This davicom etherboot driver supports DM9009/DM9102/DM9102A/
11  DM9102A+DM9801/DM9102A+DM9802 NICs.
12 
13  This software may be used and distributed according to the terms
14  of the GNU Public License, incorporated herein by reference.
15 
16 */
17 
18 FILE_LICENCE ( GPL_ANY );
19 
20 /*********************************************************************/
21 /* Revision History */
22 /*********************************************************************/
23 
24 /*
25  19 OCT 2000 Sten 1.00
26  Different half and full duplex mode
27  Do the different programming for DM9801/DM9802
28 
29  12 OCT 2000 Sten 0.90
30  This driver was ported from tulip driver and it
31  has the following difference.
32  Changed symbol tulip/TULIP to davicom/DAVICOM
33  Deleted some code that did not use in this driver.
34  Used chain-strcture to replace ring structure
35  for both TX/RX descriptor.
36  Allocated two tx descriptor.
37  According current media mode to set operating
38  register(CR6)
39 */
40 
41 
42 /*********************************************************************/
43 /* Declarations */
44 /*********************************************************************/
45 
46 #include "etherboot.h"
47 #include "nic.h"
48 #include <ipxe/pci.h>
49 #include <ipxe/ethernet.h>
50 
51 #define TX_TIME_OUT 2*TICKS_PER_SEC
52 
53 /* Register offsets for davicom device */
55  CSR0=0, CSR1=0x08, CSR2=0x10, CSR3=0x18, CSR4=0x20, CSR5=0x28,
56  CSR6=0x30, CSR7=0x38, CSR8=0x40, CSR9=0x48, CSR10=0x50, CSR11=0x58,
57  CSR12=0x60, CSR13=0x68, CSR14=0x70, CSR15=0x78, CSR16=0x80, CSR20=0xA0
58 };
59 
60 /* EEPROM Address width definitions */
61 #define EEPROM_ADDRLEN 6
62 #define EEPROM_SIZE 32 /* 1 << EEPROM_ADDRLEN */
63 /* Used to be 128, but we only need to read enough to get the MAC
64  address at bytes 20..25 */
65 
66 /* Data Read from the EEPROM */
67 static unsigned char ee_data[EEPROM_SIZE];
68 
69 /* The EEPROM commands include the alway-set leading bit. */
70 #define EE_WRITE_CMD (5 << addr_len)
71 #define EE_READ_CMD (6 << addr_len)
72 #define EE_ERASE_CMD (7 << addr_len)
73 
74 /* EEPROM_Ctrl bits. */
75 #define EE_SHIFT_CLK 0x02 /* EEPROM shift clock. */
76 #define EE_CS 0x01 /* EEPROM chip select. */
77 #define EE_DATA_WRITE 0x04 /* EEPROM chip data in. */
78 #define EE_WRITE_0 0x01
79 #define EE_WRITE_1 0x05
80 #define EE_DATA_READ 0x08 /* EEPROM chip data out. */
81 #define EE_ENB (0x4800 | EE_CS)
82 
83 /* Sten 10/11 for phyxcer */
84 #define PHY_DATA_0 0x0
85 #define PHY_DATA_1 0x20000
86 #define MDCLKH 0x10000
87 
88 /* Delay between EEPROM clock transitions. Even at 33Mhz current PCI
89  implementations don't overrun the EEPROM clock. We add a bus
90  turn-around to insure that this remains true. */
91 #define eeprom_delay() inl(ee_addr)
92 
93 /* helpful macro if on a big_endian machine for changing byte order.
94  not strictly needed on Intel
95  Already defined in Etherboot includes
96 #define le16_to_cpu(val) (val)
97 */
98 
99 /* transmit and receive descriptor format */
100 struct txdesc {
101  volatile unsigned long status; /* owner, status */
102  unsigned long buf1sz:11, /* size of buffer 1 */
103  buf2sz:11, /* size of buffer 2 */
104  control:10; /* control bits */
105  const unsigned char *buf1addr; /* buffer 1 address */
106  const unsigned char *buf2addr; /* buffer 2 address */
107 };
108 
109 struct rxdesc {
110  volatile unsigned long status; /* owner, status */
111  unsigned long buf1sz:11, /* size of buffer 1 */
112  buf2sz:11, /* size of buffer 2 */
113  control:10; /* control bits */
114  unsigned char *buf1addr; /* buffer 1 address */
115  unsigned char *buf2addr; /* buffer 2 address */
116 };
117 
118 /* Size of transmit and receive buffers */
119 #define BUFLEN 1536
120 
121 /*********************************************************************/
122 /* Global Storage */
123 /*********************************************************************/
124 
126 
127 /* PCI Bus parameters */
128 static unsigned short vendor, dev_id;
129 static unsigned long ioaddr;
130 
131 /* Note: transmit and receive buffers must be longword aligned and
132  longword divisable */
133 
134 /* transmit descriptor and buffer */
135 #define NTXD 2
136 #define NRXD 4
137 struct davicom_bss {
138  struct txdesc txd[NTXD] __attribute__ ((aligned(4)));
139  unsigned char txb[BUFLEN] __attribute__ ((aligned(4)));
140  struct rxdesc rxd[NRXD] __attribute__ ((aligned(4)));
141  unsigned char rxb[NRXD * BUFLEN] __attribute__ ((aligned(4)));
142 };
143 #define davicom_bufs NIC_FAKE_BSS ( struct davicom_bss )
144 #define txd davicom_bufs.txd
145 #define txb davicom_bufs.txb
146 #define rxd davicom_bufs.rxd
147 #define rxb davicom_bufs.rxb
148 static int rxd_tail;
149 static int TxPtr;
150 
151 
152 /*********************************************************************/
153 /* Function Prototypes */
154 /*********************************************************************/
155 static void whereami(const char *str);
156 static int read_eeprom(unsigned long ioaddr, int location, int addr_len);
157 static int davicom_probe(struct nic *nic,struct pci_device *pci);
158 static void davicom_init_chain(struct nic *nic); /* Sten 10/9 */
159 static void davicom_reset(struct nic *nic);
160 static void davicom_transmit(struct nic *nic, const char *d, unsigned int t,
161  unsigned int s, const char *p);
162 static int davicom_poll(struct nic *nic, int retrieve);
163 static void davicom_disable(struct nic *nic, void *hwdev);
164 static void davicom_wait(unsigned int nticks);
165 static int phy_read(int);
166 static void phy_write(int, u16);
167 static void phy_write_1bit(u32, u32);
168 static int phy_read_1bit(u32);
169 static void davicom_media_chk(struct nic *);
170 
171 
172 /*********************************************************************/
173 /* Utility Routines */
174 /*********************************************************************/
175 static inline void whereami(const char *str)
176 {
177  DBGP("%s\n", str);
178  /* sleep(2); */
179 }
180 
181 static void davicom_wait(unsigned int nticks)
182 {
183  unsigned int to = currticks() + nticks;
184  while (currticks() < to)
185  /* wait */ ;
186 }
187 
188 
189 /*********************************************************************/
190 /* For DAVICOM phyxcer register by MII interface */
191 /*********************************************************************/
192 /*
193  Read a word data from phy register
194 */
195 static int phy_read(int location)
196 {
197  int i, phy_addr=1;
198  u16 phy_data;
199  u32 io_dcr9;
200 
201  whereami("phy_read\n");
202 
203  io_dcr9 = ioaddr + CSR9;
204 
205  /* Send 33 synchronization clock to Phy controller */
206  for (i=0; i<34; i++)
207  phy_write_1bit(io_dcr9, PHY_DATA_1);
208 
209  /* Send start command(01) to Phy */
210  phy_write_1bit(io_dcr9, PHY_DATA_0);
211  phy_write_1bit(io_dcr9, PHY_DATA_1);
212 
213  /* Send read command(10) to Phy */
214  phy_write_1bit(io_dcr9, PHY_DATA_1);
215  phy_write_1bit(io_dcr9, PHY_DATA_0);
216 
217  /* Send Phy address */
218  for (i=0x10; i>0; i=i>>1)
219  phy_write_1bit(io_dcr9, phy_addr&i ? PHY_DATA_1: PHY_DATA_0);
220 
221  /* Send register address */
222  for (i=0x10; i>0; i=i>>1)
223  phy_write_1bit(io_dcr9, location&i ? PHY_DATA_1: PHY_DATA_0);
224 
225  /* Skip transition state */
226  phy_read_1bit(io_dcr9);
227 
228  /* read 16bit data */
229  for (phy_data=0, i=0; i<16; i++) {
230  phy_data<<=1;
231  phy_data|=phy_read_1bit(io_dcr9);
232  }
233 
234  return phy_data;
235 }
236 
237 /*
238  Write a word to Phy register
239 */
240 static void phy_write(int location, u16 phy_data)
241 {
242  u16 i, phy_addr=1;
243  u32 io_dcr9;
244 
245  whereami("phy_write\n");
246 
247  io_dcr9 = ioaddr + CSR9;
248 
249  /* Send 33 synchronization clock to Phy controller */
250  for (i=0; i<34; i++)
251  phy_write_1bit(io_dcr9, PHY_DATA_1);
252 
253  /* Send start command(01) to Phy */
254  phy_write_1bit(io_dcr9, PHY_DATA_0);
255  phy_write_1bit(io_dcr9, PHY_DATA_1);
256 
257  /* Send write command(01) to Phy */
258  phy_write_1bit(io_dcr9, PHY_DATA_0);
259  phy_write_1bit(io_dcr9, PHY_DATA_1);
260 
261  /* Send Phy address */
262  for (i=0x10; i>0; i=i>>1)
263  phy_write_1bit(io_dcr9, phy_addr&i ? PHY_DATA_1: PHY_DATA_0);
264 
265  /* Send register address */
266  for (i=0x10; i>0; i=i>>1)
267  phy_write_1bit(io_dcr9, location&i ? PHY_DATA_1: PHY_DATA_0);
268 
269  /* written trasnition */
270  phy_write_1bit(io_dcr9, PHY_DATA_1);
271  phy_write_1bit(io_dcr9, PHY_DATA_0);
272 
273  /* Write a word data to PHY controller */
274  for (i=0x8000; i>0; i>>=1)
275  phy_write_1bit(io_dcr9, phy_data&i ? PHY_DATA_1: PHY_DATA_0);
276 }
277 
278 /*
279  Write one bit data to Phy Controller
280 */
281 static void phy_write_1bit(u32 ee_addr, u32 phy_data)
282 {
283  whereami("phy_write_1bit\n");
284  outl(phy_data, ee_addr); /* MII Clock Low */
285  eeprom_delay();
286  outl(phy_data|MDCLKH, ee_addr); /* MII Clock High */
287  eeprom_delay();
288  outl(phy_data, ee_addr); /* MII Clock Low */
289  eeprom_delay();
290 }
291 
292 /*
293  Read one bit phy data from PHY controller
294 */
295 static int phy_read_1bit(u32 ee_addr)
296 {
297  int phy_data;
298 
299  whereami("phy_read_1bit\n");
300 
301  outl(0x50000, ee_addr);
302  eeprom_delay();
303 
304  phy_data=(inl(ee_addr)>>19) & 0x1;
305 
306  outl(0x40000, ee_addr);
307  eeprom_delay();
308 
309  return phy_data;
310 }
311 
312 /*
313  DM9801/DM9802 present check and program
314 */
315 static void HPNA_process(void)
316 {
317 
318  if ( (phy_read(3) & 0xfff0) == 0xb900 ) {
319  if ( phy_read(31) == 0x4404 ) {
320  /* DM9801 present */
321  if (phy_read(3) == 0xb901)
322  phy_write(16, 0x5); /* DM9801 E4 */
323  else
324  phy_write(16, 0x1005); /* DM9801 E3 and others */
325  phy_write(25, ((phy_read(24) + 3) & 0xff) | 0xf000);
326  } else {
327  /* DM9802 present */
328  phy_write(16, 0x5);
329  phy_write(25, (phy_read(25) & 0xff00) + 2);
330  }
331  }
332 }
333 
334 /*
335  Sense media mode and set CR6
336 */
337 static void davicom_media_chk(struct nic * nic __unused)
338 {
339  unsigned long to, csr6;
340 
341  csr6 = 0x00200000; /* SF */
342  outl(csr6, ioaddr + CSR6);
343 
344 #define PCI_VENDOR_ID_DAVICOM 0x1282
345 #define PCI_DEVICE_ID_DM9009 0x9009
347  /* Set to 10BaseT mode for DM9009 */
348  phy_write(0, 0);
349  } else {
350  /* For DM9102/DM9102A */
351  to = currticks() + 2 * TICKS_PER_SEC;
352  while ( ((phy_read(1) & 0x24)!=0x24) && (currticks() < to))
353  /* wait */ ;
354 
355  if ( (phy_read(1) & 0x24) == 0x24 ) {
356  if (phy_read(17) & 0xa000)
357  csr6 |= 0x00000200; /* Full Duplex mode */
358  } else
359  csr6 |= 0x00040000; /* Select DM9801/DM9802 when Ethernet link failed */
360  }
361 
362  /* set the chip's operating mode */
363  outl(csr6, ioaddr + CSR6);
364 
365  /* DM9801/DM9802 present check & program */
366  if (csr6 & 0x40000)
367  HPNA_process();
368 }
369 
370 
371 /*********************************************************************/
372 /* EEPROM Reading Code */
373 /*********************************************************************/
374 /* EEPROM routines adapted from the Linux Tulip Code */
375 /* Reading a serial EEPROM is a "bit" grungy, but we work our way
376  through:->.
377 */
378 static int read_eeprom(unsigned long ioaddr, int location, int addr_len)
379 {
380  int i;
381  unsigned short retval = 0;
382  long ee_addr = ioaddr + CSR9;
383  int read_cmd = location | EE_READ_CMD;
384 
385  whereami("read_eeprom\n");
386 
387  outl(EE_ENB & ~EE_CS, ee_addr);
388  outl(EE_ENB, ee_addr);
389 
390  /* Shift the read command bits out. */
391  for (i = 4 + addr_len; i >= 0; i--) {
392  short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
393  outl(EE_ENB | dataval, ee_addr);
394  eeprom_delay();
395  outl(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
396  eeprom_delay();
397  }
398  outl(EE_ENB, ee_addr);
399 
400  for (i = 16; i > 0; i--) {
401  outl(EE_ENB | EE_SHIFT_CLK, ee_addr);
402  eeprom_delay();
403  retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0);
404  outl(EE_ENB, ee_addr);
405  eeprom_delay();
406  }
407 
408  /* Terminate the EEPROM access. */
409  outl(EE_ENB & ~EE_CS, ee_addr);
410  return retval;
411 }
412 
413 /*********************************************************************/
414 /* davicom_init_chain - setup the tx and rx descriptors */
415 /* Sten 10/9 */
416 /*********************************************************************/
417 static void davicom_init_chain(struct nic *nic)
418 {
419  int i;
420 
421  /* setup the transmit descriptor */
422  /* Sten: Set 2 TX descriptor but use one TX buffer because
423  it transmit a packet and wait complete every time. */
424  for (i=0; i<NTXD; i++) {
425  txd[i].buf1addr = (void *)virt_to_bus(&txb[0]); /* Used same TX buffer */
426  txd[i].buf2addr = (void *)virt_to_bus(&txd[i+1]); /* Point to Next TX desc */
427  txd[i].buf1sz = 0;
428  txd[i].buf2sz = 0;
429  txd[i].control = 0x184; /* Begin/End/Chain */
430  txd[i].status = 0x00000000; /* give ownership to Host */
431  }
432 
433  /* construct perfect filter frame with mac address as first match
434  and broadcast address for all others */
435  for (i=0; i<192; i++) txb[i] = 0xFF;
436  txb[0] = nic->node_addr[0];
437  txb[1] = nic->node_addr[1];
438  txb[4] = nic->node_addr[2];
439  txb[5] = nic->node_addr[3];
440  txb[8] = nic->node_addr[4];
441  txb[9] = nic->node_addr[5];
442 
443  /* setup receive descriptor */
444  for (i=0; i<NRXD; i++) {
445  rxd[i].buf1addr = (void *)virt_to_bus(&rxb[i * BUFLEN]);
446  rxd[i].buf2addr = (void *)virt_to_bus(&rxd[i+1]); /* Point to Next RX desc */
447  rxd[i].buf1sz = BUFLEN;
448  rxd[i].buf2sz = 0; /* not used */
449  rxd[i].control = 0x4; /* Chain Structure */
450  rxd[i].status = 0x80000000; /* give ownership to device */
451  }
452 
453  /* Chain the last descriptor to first */
454  txd[NTXD - 1].buf2addr = (void *)virt_to_bus(&txd[0]);
455  rxd[NRXD - 1].buf2addr = (void *)virt_to_bus(&rxd[0]);
456  TxPtr = 0;
457  rxd_tail = 0;
458 }
459 
460 
461 /*********************************************************************/
462 /* davicom_reset - Reset adapter */
463 /*********************************************************************/
464 static void davicom_reset(struct nic *nic)
465 {
466  unsigned long to;
467 
468  whereami("davicom_reset\n");
469 
470  /* Stop Tx and RX */
471  outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
472 
473  /* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
474  outl(0x00000001, ioaddr + CSR0);
475 
477 
478  /* TX/RX descriptor burst */
479  outl(0x0C00000, ioaddr + CSR0); /* Sten 10/9 */
480 
481  /* set up transmit and receive descriptors */
482  davicom_init_chain(nic); /* Sten 10/9 */
483 
484  /* Point to receive descriptor */
485  outl(virt_to_bus(&rxd[0]), ioaddr + CSR3);
486  outl(virt_to_bus(&txd[0]), ioaddr + CSR4); /* Sten 10/9 */
487 
488  /* According phyxcer media mode to set CR6,
489  DM9102/A phyxcer can auto-detect media mode */
491 
492  /* Prepare Setup Frame Sten 10/9 */
493  txd[TxPtr].buf1sz = 192;
494  txd[TxPtr].control = 0x024; /* SF/CE */
495  txd[TxPtr].status = 0x80000000; /* Give ownership to device */
496 
497  /* Start Tx */
498  outl(inl(ioaddr + CSR6) | 0x00002000, ioaddr + CSR6);
499  /* immediate transmit demand */
500  outl(0, ioaddr + CSR1);
501 
502  to = currticks() + TX_TIME_OUT;
503  while ((txd[TxPtr].status & 0x80000000) && (currticks() < to)) /* Sten 10/9 */
504  /* wait */ ;
505 
506  if (currticks() >= to) {
507  DBG ("TX Setup Timeout!\n");
508  }
509  /* Point to next TX descriptor */
510  TxPtr = (++TxPtr >= NTXD) ? 0:TxPtr; /* Sten 10/9 */
511 
512  DBG("txd.status = %lX\n", txd[TxPtr].status);
513  DBG("ticks = %ld\n", currticks() - (to - TX_TIME_OUT));
514  DBG_MORE();
515 
516  /* enable RX */
517  outl(inl(ioaddr + CSR6) | 0x00000002, ioaddr + CSR6);
518  /* immediate poll demand */
519  outl(0, ioaddr + CSR2);
520 }
521 
522 
523 /*********************************************************************/
524 /* eth_transmit - Transmit a frame */
525 /*********************************************************************/
526 static void davicom_transmit(struct nic *nic, const char *d, unsigned int t,
527  unsigned int s, const char *p)
528 {
529  unsigned long to;
530 
531  whereami("davicom_transmit\n");
532 
533  /* Stop Tx */
534  /* outl(inl(ioaddr + CSR6) & ~0x00002000, ioaddr + CSR6); */
535 
536  /* setup ethernet header */
537  memcpy(&txb[0], d, ETH_ALEN); /* DA 6byte */
538  memcpy(&txb[ETH_ALEN], nic->node_addr, ETH_ALEN); /* SA 6byte*/
539  txb[ETH_ALEN*2] = (t >> 8) & 0xFF; /* Frame type: 2byte */
540  txb[ETH_ALEN*2+1] = t & 0xFF;
541  memcpy(&txb[ETH_HLEN], p, s); /* Frame data */
542 
543  /* setup the transmit descriptor */
544  txd[TxPtr].buf1sz = ETH_HLEN+s;
545  txd[TxPtr].control = 0x00000184; /* LS+FS+CE */
546  txd[TxPtr].status = 0x80000000; /* give ownership to device */
547 
548  /* immediate transmit demand */
549  outl(0, ioaddr + CSR1);
550 
551  to = currticks() + TX_TIME_OUT;
552  while ((txd[TxPtr].status & 0x80000000) && (currticks() < to))
553  /* wait */ ;
554 
555  if (currticks() >= to) {
556  DBG ("TX Timeout!\n");
557  }
558 
559  /* Point to next TX descriptor */
560  TxPtr = (++TxPtr >= NTXD) ? 0:TxPtr; /* Sten 10/9 */
561 
562 }
563 
564 /*********************************************************************/
565 /* eth_poll - Wait for a frame */
566 /*********************************************************************/
567 static int davicom_poll(struct nic *nic, int retrieve)
568 {
569  whereami("davicom_poll\n");
570 
571  if (rxd[rxd_tail].status & 0x80000000)
572  return 0;
573 
574  if ( ! retrieve ) return 1;
575 
576  whereami("davicom_poll got one\n");
577 
578  nic->packetlen = (rxd[rxd_tail].status & 0x3FFF0000) >> 16;
579 
580  if( rxd[rxd_tail].status & 0x00008000){
581  rxd[rxd_tail].status = 0x80000000;
582  rxd_tail++;
583  if (rxd_tail == NRXD) rxd_tail = 0;
584  return 0;
585  }
586 
587  /* copy packet to working buffer */
588  /* XXX - this copy could be avoided with a little more work
589  but for now we are content with it because the optimised
590  memcpy is quite fast */
591 
593 
594  /* return the descriptor and buffer to receive ring */
595  rxd[rxd_tail].status = 0x80000000;
596  rxd_tail++;
597  if (rxd_tail == NRXD) rxd_tail = 0;
598 
599  return 1;
600 }
601 
602 /*********************************************************************/
603 /* eth_disable - Disable the interface */
604 /*********************************************************************/
605 static void davicom_disable ( struct nic *nic, void *hwdev __unused ) {
606 
607  whereami("davicom_disable\n");
608 
610 
611  /* disable interrupts */
612  outl(0x00000000, ioaddr + CSR7);
613 
614  /* Stop the chip's Tx and Rx processes. */
615  outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
616 
617  /* Clear the missed-packet counter. */
618  inl(ioaddr + CSR8);
619 }
620 
621 
622 /*********************************************************************/
623 /* eth_irq - enable, disable and force interrupts */
624 /*********************************************************************/
625 static void davicom_irq(struct nic *nic __unused, irq_action_t action __unused)
626 {
627  switch ( action ) {
628  case DISABLE :
629  break;
630  case ENABLE :
631  break;
632  case FORCE :
633  break;
634  }
635 }
636 
637 
638 /*********************************************************************/
639 /* eth_probe - Look for an adapter */
640 /*********************************************************************/
641 static int davicom_probe ( struct nic *nic, struct pci_device *pci ) {
642 
643  unsigned int i;
644 
645  whereami("davicom_probe\n");
646 
647  if (pci->ioaddr == 0)
648  return 0;
649 
650  vendor = pci->vendor;
651  dev_id = pci->device;
652  ioaddr = pci->ioaddr;
653 
654  nic->ioaddr = pci->ioaddr;
655  nic->irqno = 0;
656 
657  /* wakeup chip */
658  pci_write_config_dword(pci, 0x40, 0x00000000);
659 
660  /* Stop the chip's Tx and Rx processes. */
661  outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
662 
663  /* Clear the missed-packet counter. */
664  inl(ioaddr + CSR8);
665 
666  /* Get MAC Address */
667  /* read EEPROM data */
668  for (i = 0; i < sizeof(ee_data)/2; i++)
669  ((unsigned short *)ee_data)[i] =
671 
672  /* extract MAC address from EEPROM buffer */
673  for (i=0; i<ETH_ALEN; i++)
674  nic->node_addr[i] = ee_data[20+i];
675 
676  DBG ( "Davicom %s at IOADDR %4.4lx\n", eth_ntoa ( nic->node_addr ), ioaddr );
677 
678  /* initialize device */
681  return 1;
682 }
683 
684 static struct nic_operations davicom_operations = {
686  .poll = davicom_poll,
687  .transmit = davicom_transmit,
688  .irq = davicom_irq,
689 
690 };
691 
692 static struct pci_device_id davicom_nics[] = {
693 PCI_ROM(0x1282, 0x9009, "davicom9009", "Davicom 9009", 0),
694 PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100", 0),
695 PCI_ROM(0x1282, 0x9102, "davicom9102", "Davicom 9102", 0),
696 PCI_ROM(0x1282, 0x9132, "davicom9132", "Davicom 9132", 0), /* Needs probably some fixing */
697 };
698 
699 PCI_DRIVER ( davicom_driver, davicom_nics, PCI_NO_CLASS );
700 
701 DRIVER ( "DAVICOM", nic_driver, pci_driver, davicom_driver,
703 
704 /*
705  * Local variables:
706  * c-basic-offset: 8
707  * c-indent-level: 8
708  * tab-width: 8
709  * End:
710  */
static int read_eeprom(unsigned long ioaddr, int location, int addr_len)
Definition: davicom.c:378
unsigned char irqno
Definition: nic.h:56
uint16_t u16
Definition: stdint.h:21
#define __attribute__(x)
Definition: compiler.h:10
struct txdesc txd[NTXD]
Definition: davicom.c:138
#define DBG_MORE(...)
Definition: compiler.h:504
#define EE_READ_CMD
Definition: davicom.c:71
Definition: nic.h:35
PCI_DRIVER(davicom_driver, davicom_nics, PCI_NO_CLASS)
Definition: davicom.c:56
Definition: davicom.c:56
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
#define TX_TIME_OUT
Definition: davicom.c:51
DRIVER("DAVICOM", nic_driver, pci_driver, davicom_driver, davicom_probe, davicom_disable, davicom_bufs)
A PCI driver.
Definition: pci.h:251
static void phy_write_1bit(u32, u32)
Definition: davicom.c:281
const unsigned char * buf1addr
Definition: davicom.c:105
#define rxb
Definition: davicom.c:147
Definition: davicom.c:57
static void phy_write(int, u16)
Definition: davicom.c:240
static void HPNA_process(void)
Definition: davicom.c:315
unsigned long ioaddr
I/O address.
Definition: pci.h:225
static int rxd_tail
Definition: davicom.c:148
#define EE_DATA_READ
Definition: davicom.c:80
static unsigned short vendor
Definition: davicom.c:128
#define EEPROM_ADDRLEN
Definition: davicom.c:61
Definition: davicom.c:57
static int phy_read(int)
Definition: davicom.c:195
Definition: davicom.c:55
static unsigned char ee_data[EEPROM_SIZE]
Definition: davicom.c:67
davicom_offsets
Definition: davicom.c:54
static int davicom_poll(struct nic *nic, int retrieve)
Definition: davicom.c:567
#define EE_ENB
Definition: davicom.c:81
Definition: davicom.c:55
static void whereami(const char *str)
Definition: davicom.c:175
int dummy_connect(struct nic *nic __unused)
Definition: legacy.c:175
#define EEPROM_SIZE
Definition: davicom.c:62
Definition: davicom.c:57
Definition: davicom.c:55
Definition: davicom.c:56
volatile unsigned long status
Definition: davicom.c:110
static unsigned long ioaddr
Definition: davicom.c:129
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned int ioaddr
Definition: nic.h:55
unsigned long buf1sz
Definition: davicom.c:111
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
uint16_t device
Device ID.
Definition: pci.h:229
#define ETH_HLEN
Definition: if_ether.h:9
#define DBGP(...)
Definition: compiler.h:532
Ethernet protocol.
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
static struct pci_device_id davicom_nics[]
Definition: davicom.c:692
static struct nic_operations davicom_operations
Definition: davicom.c:125
A 16-bit general register.
Definition: registers.h:24
irq_action_t
Definition: nic.h:34
unsigned long control
Definition: davicom.c:102
#define EE_SHIFT_CLK
Definition: davicom.c:75
Definition: davicom.c:57
static int TxPtr
Definition: davicom.c:149
#define NTXD
Definition: davicom.c:135
unsigned int packetlen
Definition: nic.h:54
#define PCI_DEVICE_ID_DM9009
#define txd
Definition: davicom.c:144
#define outl(data, io_addr)
Definition: io.h:329
#define eeprom_delay()
Definition: davicom.c:91
PCI bus.
unsigned char txb[BUFLEN]
Definition: davicom.c:139
A PCI device.
Definition: pci.h:210
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
#define txb
Definition: davicom.c:145
struct rxdesc rxd[NRXD]
Definition: davicom.c:140
unsigned long buf2sz
Definition: davicom.c:111
static void davicom_irq(struct nic *nic __unused, irq_action_t action __unused)
Definition: davicom.c:625
#define BUFLEN
Definition: davicom.c:119
#define PHY_DATA_0
Definition: davicom.c:84
#define ETH_ALEN
Definition: if_ether.h:8
A PCI device ID list entry.
Definition: pci.h:174
Definition: nic.h:37
#define le16_to_cpu(value)
Definition: byteswap.h:112
Definition: nic.h:49
unsigned char rxb[NRXD *BUFLEN]
Definition: davicom.c:141
Definition: davicom.c:56
uint16_t vendor
Vendor ID.
Definition: pci.h:227
uint8_t status
Status.
Definition: ena.h:16
unsigned long retval
Definition: xen.h:45
Definition: nic.h:36
unsigned long control
Definition: davicom.c:111
#define EE_CS
Definition: davicom.c:76
unsigned char * packet
Definition: nic.h:53
#define MDCLKH
Definition: davicom.c:86
unsigned char * node_addr
Definition: nic.h:52
#define davicom_bufs
Definition: davicom.c:143
Definition: davicom.c:55
unsigned long buf1sz
Definition: davicom.c:102
unsigned long buf2sz
Definition: davicom.c:102
unsigned char * buf2addr
Definition: davicom.c:115
static void davicom_media_chk(struct nic *)
static int davicom_probe(struct nic *nic, struct pci_device *pci)
Definition: davicom.c:641
static void davicom_wait(unsigned int nticks)
Definition: davicom.c:181
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
Definition: davicom.c:55
FILE_LICENCE(GPL_ANY)
unsigned char * buf1addr
Definition: davicom.c:114
#define PHY_DATA_1
Definition: davicom.c:85
static unsigned short dev_id
Definition: davicom.c:128
volatile unsigned long status
Definition: davicom.c:101
Definition: davicom.c:56
static void davicom_disable(struct nic *nic, void *hwdev)
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
struct nic_operations * nic_op
Definition: nic.h:50
static void davicom_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
Definition: davicom.c:526
#define EE_DATA_WRITE
Definition: davicom.c:77
#define PCI_VENDOR_ID_DAVICOM
static int phy_read_1bit(u32)
Definition: davicom.c:295
#define NRXD
Definition: davicom.c:136
static struct command_descriptor read_cmd
"read" command descriptor
Definition: nvo_cmd.c:134
int(* connect)(struct nic *)
Definition: nic.h:69
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:307
Definition: davicom.c:56
Definition: davicom.c:55
static void davicom_reset(struct nic *nic)
Definition: davicom.c:464
Definition: davicom.c:57
uint32_t u32
Definition: stdint.h:23
Definition: davicom.c:57
static void davicom_init_chain(struct nic *nic)
Definition: davicom.c:417
const unsigned char * buf2addr
Definition: davicom.c:106
#define rxd
Definition: davicom.c:146