iPXE
Data Structures | Macros | Enumerations | Functions | Variables
davicom.c File Reference
#include "etherboot.h"
#include "nic.h"
#include <ipxe/pci.h>
#include <ipxe/ethernet.h>

Go to the source code of this file.

Data Structures

struct  txdesc
 
struct  rxdesc
 

Macros

#define TX_TIME_OUT   2*TICKS_PER_SEC
 
#define EEPROM_ADDRLEN   6
 
#define EEPROM_SIZE   32 /* 1 << EEPROM_ADDRLEN */
 
#define EE_WRITE_CMD   (5 << addr_len)
 
#define EE_READ_CMD   (6 << addr_len)
 
#define EE_ERASE_CMD   (7 << addr_len)
 
#define EE_SHIFT_CLK   0x02 /* EEPROM shift clock. */
 
#define EE_CS   0x01 /* EEPROM chip select. */
 
#define EE_DATA_WRITE   0x04 /* EEPROM chip data in. */
 
#define EE_WRITE_0   0x01
 
#define EE_WRITE_1   0x05
 
#define EE_DATA_READ   0x08 /* EEPROM chip data out. */
 
#define EE_ENB   (0x4800 | EE_CS)
 
#define PHY_DATA_0   0x0
 
#define PHY_DATA_1   0x20000
 
#define MDCLKH   0x10000
 
#define eeprom_delay()   inl(ee_addr)
 
#define BUFLEN   1536
 
#define NTXD   2
 
#define NRXD   4
 
#define txd   davicom_bufs.txd
 
#define txb   davicom_bufs.txb
 
#define rxd   davicom_bufs.rxd
 
#define rxb   davicom_bufs.rxb
 
#define PCI_VENDOR_ID_DAVICOM   0x1282
 
#define PCI_DEVICE_ID_DM9009   0x9009
 

Enumerations

enum  davicom_offsets {
  CSR0 =0, CSR1 =0x08, CSR2 =0x10, CSR3 =0x18,
  CSR4 =0x20, CSR5 =0x28, CSR6 =0x30, CSR7 =0x38,
  CSR8 =0x40, CSR9 =0x48, CSR10 =0x50, CSR11 =0x58,
  CSR12 =0x60, CSR13 =0x68, CSR14 =0x70, CSR15 =0x78,
  CSR16 =0x80, CSR20 =0xA0
}
 

Functions

 FILE_LICENCE (GPL_ANY)
 
static void whereami (const char *str)
 
static int read_eeprom (unsigned long ioaddr, int location, int addr_len)
 
static int davicom_probe (struct nic *nic, struct pci_device *pci)
 
static void davicom_init_chain (struct nic *nic)
 
static void davicom_reset (struct nic *nic)
 
static void davicom_transmit (struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
 
static int davicom_poll (struct nic *nic, int retrieve)
 
static void davicom_disable (struct nic *nic)
 
static void davicom_wait (unsigned int nticks)
 
static int phy_read (int)
 
static void phy_write (int, u16)
 
static void phy_write_1bit (u32, u32)
 
static int phy_read_1bit (u32)
 
static void davicom_media_chk (struct nic *)
 
static void HPNA_process (void)
 
static void davicom_media_chk (struct nic *nic __unused)
 
static void davicom_irq (struct nic *nic __unused, irq_action_t action __unused)
 
 PCI_DRIVER (davicom_driver, davicom_nics, PCI_NO_CLASS)
 
 DRIVER ("DAVICOM", nic_driver, pci_driver, davicom_driver, davicom_probe, davicom_disable)
 

Variables

static unsigned char ee_data [EEPROM_SIZE]
 
static struct nic_operations davicom_operations
 
static unsigned short vendor
 
static unsigned short dev_id
 
static unsigned long ioaddr
 
struct {
   struct txdesc   txd [NTXD]
 
   unsigned char   txb [BUFLEN]
 
   struct rxdesc   rxd [NRXD]
 
   unsigned char   rxb [NRXD *BUFLEN]
 
__shared
 
static int rxd_tail
 
static int TxPtr
 
static struct pci_device_id davicom_nics []
 

Macro Definition Documentation

◆ TX_TIME_OUT

#define TX_TIME_OUT   2*TICKS_PER_SEC

Definition at line 51 of file davicom.c.

◆ EEPROM_ADDRLEN

#define EEPROM_ADDRLEN   6

Definition at line 61 of file davicom.c.

◆ EEPROM_SIZE

#define EEPROM_SIZE   32 /* 1 << EEPROM_ADDRLEN */

Definition at line 62 of file davicom.c.

◆ EE_WRITE_CMD

#define EE_WRITE_CMD   (5 << addr_len)

Definition at line 70 of file davicom.c.

◆ EE_READ_CMD

#define EE_READ_CMD   (6 << addr_len)

Definition at line 71 of file davicom.c.

◆ EE_ERASE_CMD

#define EE_ERASE_CMD   (7 << addr_len)

Definition at line 72 of file davicom.c.

◆ EE_SHIFT_CLK

#define EE_SHIFT_CLK   0x02 /* EEPROM shift clock. */

Definition at line 75 of file davicom.c.

◆ EE_CS

#define EE_CS   0x01 /* EEPROM chip select. */

Definition at line 76 of file davicom.c.

◆ EE_DATA_WRITE

#define EE_DATA_WRITE   0x04 /* EEPROM chip data in. */

Definition at line 77 of file davicom.c.

◆ EE_WRITE_0

#define EE_WRITE_0   0x01

Definition at line 78 of file davicom.c.

◆ EE_WRITE_1

#define EE_WRITE_1   0x05

Definition at line 79 of file davicom.c.

◆ EE_DATA_READ

#define EE_DATA_READ   0x08 /* EEPROM chip data out. */

Definition at line 80 of file davicom.c.

◆ EE_ENB

#define EE_ENB   (0x4800 | EE_CS)

Definition at line 81 of file davicom.c.

◆ PHY_DATA_0

#define PHY_DATA_0   0x0

Definition at line 84 of file davicom.c.

◆ PHY_DATA_1

#define PHY_DATA_1   0x20000

Definition at line 85 of file davicom.c.

◆ MDCLKH

#define MDCLKH   0x10000

Definition at line 86 of file davicom.c.

◆ eeprom_delay

#define eeprom_delay ( )    inl(ee_addr)

Definition at line 91 of file davicom.c.

◆ BUFLEN

#define BUFLEN   1536

Definition at line 119 of file davicom.c.

◆ NTXD

#define NTXD   2

Definition at line 135 of file davicom.c.

◆ NRXD

#define NRXD   4

Definition at line 136 of file davicom.c.

◆ txd

#define txd   davicom_bufs.txd

Definition at line 143 of file davicom.c.

◆ txb

#define txb   davicom_bufs.txb

Definition at line 144 of file davicom.c.

◆ rxd

#define rxd   davicom_bufs.rxd

Definition at line 145 of file davicom.c.

◆ rxb

#define rxb   davicom_bufs.rxb

Definition at line 146 of file davicom.c.

◆ PCI_VENDOR_ID_DAVICOM

#define PCI_VENDOR_ID_DAVICOM   0x1282

◆ PCI_DEVICE_ID_DM9009

#define PCI_DEVICE_ID_DM9009   0x9009

Enumeration Type Documentation

◆ davicom_offsets

Enumerator
CSR0 
CSR1 
CSR2 
CSR3 
CSR4 
CSR5 
CSR6 
CSR7 
CSR8 
CSR9 
CSR10 
CSR11 
CSR12 
CSR13 
CSR14 
CSR15 
CSR16 
CSR20 

Definition at line 54 of file davicom.c.

54  {
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 };
Definition: davicom.c:56
Definition: davicom.c:56
Definition: davicom.c:57
Definition: davicom.c:57
Definition: davicom.c:55
Definition: davicom.c:55
Definition: davicom.c:57
Definition: davicom.c:55
Definition: davicom.c:56
Definition: davicom.c:57
Definition: davicom.c:56
Definition: davicom.c:55
Definition: davicom.c:55
Definition: davicom.c:56
Definition: davicom.c:56
Definition: davicom.c:55
Definition: davicom.c:57
Definition: davicom.c:57

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL_ANY  )

◆ whereami()

static void whereami ( const char *  str)
inlinestatic

Definition at line 174 of file davicom.c.

175 {
176  DBGP("%s\n", str);
177  /* sleep(2); */
178 }
#define DBGP(...)
Definition: compiler.h:532

References DBGP.

Referenced by davicom_disable(), davicom_poll(), davicom_probe(), davicom_reset(), davicom_transmit(), phy_read(), phy_read_1bit(), phy_write(), phy_write_1bit(), and read_eeprom().

◆ read_eeprom()

static int read_eeprom ( unsigned long  ioaddr,
int  location,
int  addr_len 
)
static

Definition at line 377 of file davicom.c.

378 {
379  int i;
380  unsigned short retval = 0;
381  long ee_addr = ioaddr + CSR9;
382  int read_cmd = location | EE_READ_CMD;
383 
384  whereami("read_eeprom\n");
385 
386  outl(EE_ENB & ~EE_CS, ee_addr);
387  outl(EE_ENB, ee_addr);
388 
389  /* Shift the read command bits out. */
390  for (i = 4 + addr_len; i >= 0; i--) {
391  short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
392  outl(EE_ENB | dataval, ee_addr);
393  eeprom_delay();
394  outl(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
395  eeprom_delay();
396  }
397  outl(EE_ENB, ee_addr);
398 
399  for (i = 16; i > 0; i--) {
400  outl(EE_ENB | EE_SHIFT_CLK, ee_addr);
401  eeprom_delay();
402  retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0);
403  outl(EE_ENB, ee_addr);
404  eeprom_delay();
405  }
406 
407  /* Terminate the EEPROM access. */
408  outl(EE_ENB & ~EE_CS, ee_addr);
409  return retval;
410 }
#define EE_READ_CMD
Definition: davicom.c:71
Definition: davicom.c:56
#define EE_DATA_READ
Definition: davicom.c:80
#define EE_ENB
Definition: davicom.c:81
static void whereami(const char *str)
Definition: davicom.c:174
static unsigned long ioaddr
Definition: davicom.c:129
#define EE_SHIFT_CLK
Definition: davicom.c:75
#define outl(data, io_addr)
Definition: io.h:329
#define eeprom_delay()
Definition: davicom.c:91
unsigned long retval
Definition: xen.h:45
#define EE_CS
Definition: davicom.c:76
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
#define EE_DATA_WRITE
Definition: davicom.c:77

References CSR9, EE_CS, EE_DATA_READ, EE_DATA_WRITE, EE_ENB, EE_READ_CMD, EE_SHIFT_CLK, eeprom_delay, inl(), ioaddr, outl, retval, and whereami().

Referenced by davicom_probe(), and epic100_probe().

◆ davicom_probe()

static int davicom_probe ( struct nic nic,
struct pci_device pci 
)
static

Definition at line 640 of file davicom.c.

640  {
641 
642  unsigned int i;
643 
644  whereami("davicom_probe\n");
645 
646  if (pci->ioaddr == 0)
647  return 0;
648 
649  vendor = pci->vendor;
650  dev_id = pci->device;
651  ioaddr = pci->ioaddr;
652 
653  nic->ioaddr = pci->ioaddr;
654  nic->irqno = 0;
655 
656  /* wakeup chip */
657  pci_write_config_dword(pci, 0x40, 0x00000000);
658 
659  /* Stop the chip's Tx and Rx processes. */
660  outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
661 
662  /* Clear the missed-packet counter. */
663  inl(ioaddr + CSR8);
664 
665  /* Get MAC Address */
666  /* read EEPROM data */
667  for (i = 0; i < sizeof(ee_data)/2; i++)
668  ((unsigned short *)ee_data)[i] =
670 
671  /* extract MAC address from EEPROM buffer */
672  for (i=0; i<ETH_ALEN; i++)
673  nic->node_addr[i] = ee_data[20+i];
674 
675  DBG ( "Davicom %s at IOADDR %4.4lx\n", eth_ntoa ( nic->node_addr ), ioaddr );
676 
677  /* initialize device */
680  return 1;
681 }
static int read_eeprom(unsigned long ioaddr, int location, int addr_len)
Definition: davicom.c:377
unsigned char irqno
Definition: nic.h:56
unsigned long ioaddr
I/O address.
Definition: pci.h:200
static unsigned short vendor
Definition: davicom.c:128
#define EEPROM_ADDRLEN
Definition: davicom.c:61
static unsigned char ee_data[EEPROM_SIZE]
Definition: davicom.c:67
static void whereami(const char *str)
Definition: davicom.c:174
Definition: davicom.c:56
static unsigned long ioaddr
Definition: davicom.c:129
unsigned int ioaddr
Definition: nic.h:55
uint16_t device
Device ID.
Definition: pci.h:204
static struct nic_operations davicom_operations
Definition: davicom.c:125
#define outl(data, io_addr)
Definition: io.h:329
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
#define ETH_ALEN
Definition: if_ether.h:8
#define le16_to_cpu(value)
Definition: byteswap.h:112
Definition: nic.h:49
uint16_t vendor
Vendor ID.
Definition: pci.h:202
unsigned char * node_addr
Definition: nic.h:52
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.
static unsigned short dev_id
Definition: davicom.c:128
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
struct nic_operations * nic_op
Definition: nic.h:50
Definition: davicom.c:56
static void davicom_reset(struct nic *nic)
Definition: davicom.c:463

References CSR6, CSR8, davicom_operations, davicom_reset(), DBG, dev_id, pci_device::device, ee_data, EEPROM_ADDRLEN, ETH_ALEN, eth_ntoa(), inl(), nic::ioaddr, ioaddr, pci_device::ioaddr, nic::irqno, le16_to_cpu, nic::nic_op, nic::node_addr, outl, pci_write_config_dword(), read_eeprom(), vendor, pci_device::vendor, and whereami().

◆ davicom_init_chain()

static void davicom_init_chain ( struct nic nic)
static

Definition at line 416 of file davicom.c.

417 {
418  int i;
419 
420  /* setup the transmit descriptor */
421  /* Sten: Set 2 TX descriptor but use one TX buffer because
422  it transmit a packet and wait complete every time. */
423  for (i=0; i<NTXD; i++) {
424  txd[i].buf1addr = (void *)virt_to_bus(&txb[0]); /* Used same TX buffer */
425  txd[i].buf2addr = (void *)virt_to_bus(&txd[i+1]); /* Point to Next TX desc */
426  txd[i].buf1sz = 0;
427  txd[i].buf2sz = 0;
428  txd[i].control = 0x184; /* Begin/End/Chain */
429  txd[i].status = 0x00000000; /* give ownership to Host */
430  }
431 
432  /* construct perfect filter frame with mac address as first match
433  and broadcast address for all others */
434  for (i=0; i<192; i++) txb[i] = 0xFF;
435  txb[0] = nic->node_addr[0];
436  txb[1] = nic->node_addr[1];
437  txb[4] = nic->node_addr[2];
438  txb[5] = nic->node_addr[3];
439  txb[8] = nic->node_addr[4];
440  txb[9] = nic->node_addr[5];
441 
442  /* setup receive descriptor */
443  for (i=0; i<NRXD; i++) {
444  rxd[i].buf1addr = (void *)virt_to_bus(&rxb[i * BUFLEN]);
445  rxd[i].buf2addr = (void *)virt_to_bus(&rxd[i+1]); /* Point to Next RX desc */
446  rxd[i].buf1sz = BUFLEN;
447  rxd[i].buf2sz = 0; /* not used */
448  rxd[i].control = 0x4; /* Chain Structure */
449  rxd[i].status = 0x80000000; /* give ownership to device */
450  }
451 
452  /* Chain the last descriptor to first */
453  txd[NTXD - 1].buf2addr = (void *)virt_to_bus(&txd[0]);
454  rxd[NRXD - 1].buf2addr = (void *)virt_to_bus(&rxd[0]);
455  TxPtr = 0;
456  rxd_tail = 0;
457 }
#define rxb
Definition: davicom.c:146
static int rxd_tail
Definition: davicom.c:147
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
static int TxPtr
Definition: davicom.c:148
#define NTXD
Definition: davicom.c:135
#define txd
Definition: davicom.c:143
#define txb
Definition: davicom.c:144
#define BUFLEN
Definition: davicom.c:119
Definition: nic.h:49
unsigned char * node_addr
Definition: nic.h:52
#define NRXD
Definition: davicom.c:136
#define rxd
Definition: davicom.c:145

References BUFLEN, nic::node_addr, NRXD, NTXD, rxb, rxd, rxd_tail, txb, txd, TxPtr, and virt_to_bus().

Referenced by davicom_reset().

◆ davicom_reset()

static void davicom_reset ( struct nic nic)
static

Definition at line 463 of file davicom.c.

464 {
465  unsigned long to;
466 
467  whereami("davicom_reset\n");
468 
469  /* Stop Tx and RX */
470  outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
471 
472  /* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
473  outl(0x00000001, ioaddr + CSR0);
474 
476 
477  /* TX/RX descriptor burst */
478  outl(0x0C00000, ioaddr + CSR0); /* Sten 10/9 */
479 
480  /* set up transmit and receive descriptors */
481  davicom_init_chain(nic); /* Sten 10/9 */
482 
483  /* Point to receive descriptor */
484  outl(virt_to_bus(&rxd[0]), ioaddr + CSR3);
485  outl(virt_to_bus(&txd[0]), ioaddr + CSR4); /* Sten 10/9 */
486 
487  /* According phyxcer media mode to set CR6,
488  DM9102/A phyxcer can auto-detect media mode */
490 
491  /* Prepare Setup Frame Sten 10/9 */
492  txd[TxPtr].buf1sz = 192;
493  txd[TxPtr].control = 0x024; /* SF/CE */
494  txd[TxPtr].status = 0x80000000; /* Give ownership to device */
495 
496  /* Start Tx */
497  outl(inl(ioaddr + CSR6) | 0x00002000, ioaddr + CSR6);
498  /* immediate transmit demand */
499  outl(0, ioaddr + CSR1);
500 
501  to = currticks() + TX_TIME_OUT;
502  while ((txd[TxPtr].status & 0x80000000) && (currticks() < to)) /* Sten 10/9 */
503  /* wait */ ;
504 
505  if (currticks() >= to) {
506  DBG ("TX Setup Timeout!\n");
507  }
508  /* Point to next TX descriptor */
509  TxPtr = (++TxPtr >= NTXD) ? 0:TxPtr; /* Sten 10/9 */
510 
511  DBG("txd.status = %lX\n", txd[TxPtr].status);
512  DBG("ticks = %ld\n", currticks() - (to - TX_TIME_OUT));
513  DBG_MORE();
514 
515  /* enable RX */
516  outl(inl(ioaddr + CSR6) | 0x00000002, ioaddr + CSR6);
517  /* immediate poll demand */
518  outl(0, ioaddr + CSR2);
519 }
#define DBG_MORE(...)
Definition: compiler.h:504
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
#define TX_TIME_OUT
Definition: davicom.c:51
Definition: davicom.c:55
static void whereami(const char *str)
Definition: davicom.c:174
Definition: davicom.c:55
Definition: davicom.c:56
uint8_t status
Status.
Definition: ena.h:16
static unsigned long ioaddr
Definition: davicom.c:129
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition: io.h:183
static int TxPtr
Definition: davicom.c:148
#define NTXD
Definition: davicom.c:135
#define txd
Definition: davicom.c:143
#define outl(data, io_addr)
Definition: io.h:329
Definition: nic.h:49
Definition: davicom.c:55
static void davicom_media_chk(struct nic *)
static void davicom_wait(unsigned int nticks)
Definition: davicom.c:180
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
Definition: davicom.c:55
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
Definition: davicom.c:55
static void davicom_init_chain(struct nic *nic)
Definition: davicom.c:416
#define rxd
Definition: davicom.c:145

References CSR0, CSR1, CSR2, CSR3, CSR4, CSR6, currticks(), davicom_init_chain(), davicom_media_chk(), davicom_wait(), DBG, DBG_MORE, inl(), ioaddr, NTXD, outl, rxd, status, TICKS_PER_SEC, TX_TIME_OUT, txd, TxPtr, virt_to_bus(), and whereami().

Referenced by davicom_disable(), and davicom_probe().

◆ davicom_transmit()

static void davicom_transmit ( struct nic nic,
const char *  d,
unsigned int  t,
unsigned int  s,
const char *  p 
)
static

Definition at line 525 of file davicom.c.

527 {
528  unsigned long to;
529 
530  whereami("davicom_transmit\n");
531 
532  /* Stop Tx */
533  /* outl(inl(ioaddr + CSR6) & ~0x00002000, ioaddr + CSR6); */
534 
535  /* setup ethernet header */
536  memcpy(&txb[0], d, ETH_ALEN); /* DA 6byte */
537  memcpy(&txb[ETH_ALEN], nic->node_addr, ETH_ALEN); /* SA 6byte*/
538  txb[ETH_ALEN*2] = (t >> 8) & 0xFF; /* Frame type: 2byte */
539  txb[ETH_ALEN*2+1] = t & 0xFF;
540  memcpy(&txb[ETH_HLEN], p, s); /* Frame data */
541 
542  /* setup the transmit descriptor */
543  txd[TxPtr].buf1sz = ETH_HLEN+s;
544  txd[TxPtr].control = 0x00000184; /* LS+FS+CE */
545  txd[TxPtr].status = 0x80000000; /* give ownership to device */
546 
547  /* immediate transmit demand */
548  outl(0, ioaddr + CSR1);
549 
550  to = currticks() + TX_TIME_OUT;
551  while ((txd[TxPtr].status & 0x80000000) && (currticks() < to))
552  /* wait */ ;
553 
554  if (currticks() >= to) {
555  DBG ("TX Timeout!\n");
556  }
557 
558  /* Point to next TX descriptor */
559  TxPtr = (++TxPtr >= NTXD) ? 0:TxPtr; /* Sten 10/9 */
560 
561 }
#define TX_TIME_OUT
Definition: davicom.c:51
static void whereami(const char *str)
Definition: davicom.c:174
uint8_t status
Status.
Definition: ena.h:16
static unsigned long ioaddr
Definition: davicom.c:129
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define ETH_HLEN
Definition: if_ether.h:9
static int TxPtr
Definition: davicom.c:148
#define NTXD
Definition: davicom.c:135
#define txd
Definition: davicom.c:143
#define outl(data, io_addr)
Definition: io.h:329
#define txb
Definition: davicom.c:144
#define ETH_ALEN
Definition: if_ether.h:8
Definition: nic.h:49
unsigned char * node_addr
Definition: nic.h:52
uint32_t d
Definition: md4.c:31
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
Definition: davicom.c:55

References CSR1, currticks(), d, DBG, ETH_ALEN, ETH_HLEN, ioaddr, memcpy(), nic::node_addr, NTXD, outl, status, TX_TIME_OUT, txb, txd, TxPtr, and whereami().

◆ davicom_poll()

static int davicom_poll ( struct nic nic,
int  retrieve 
)
static

Definition at line 566 of file davicom.c.

567 {
568  whereami("davicom_poll\n");
569 
570  if (rxd[rxd_tail].status & 0x80000000)
571  return 0;
572 
573  if ( ! retrieve ) return 1;
574 
575  whereami("davicom_poll got one\n");
576 
577  nic->packetlen = (rxd[rxd_tail].status & 0x3FFF0000) >> 16;
578 
579  if( rxd[rxd_tail].status & 0x00008000){
580  rxd[rxd_tail].status = 0x80000000;
581  rxd_tail++;
582  if (rxd_tail == NRXD) rxd_tail = 0;
583  return 0;
584  }
585 
586  /* copy packet to working buffer */
587  /* XXX - this copy could be avoided with a little more work
588  but for now we are content with it because the optimised
589  memcpy is quite fast */
590 
592 
593  /* return the descriptor and buffer to receive ring */
594  rxd[rxd_tail].status = 0x80000000;
595  rxd_tail++;
596  if (rxd_tail == NRXD) rxd_tail = 0;
597 
598  return 1;
599 }
#define rxb
Definition: davicom.c:146
static int rxd_tail
Definition: davicom.c:147
static void whereami(const char *str)
Definition: davicom.c:174
uint8_t status
Status.
Definition: ena.h:16
void * memcpy(void *dest, const void *src, size_t len) __nonnull
unsigned int packetlen
Definition: nic.h:54
#define BUFLEN
Definition: davicom.c:119
Definition: nic.h:49
unsigned char * packet
Definition: nic.h:53
#define NRXD
Definition: davicom.c:136
#define rxd
Definition: davicom.c:145

References BUFLEN, memcpy(), NRXD, nic::packet, nic::packetlen, rxb, rxd, rxd_tail, status, and whereami().

◆ davicom_disable()

static void davicom_disable ( struct nic nic)
static

Definition at line 604 of file davicom.c.

604  {
605 
606  whereami("davicom_disable\n");
607 
609 
610  /* disable interrupts */
611  outl(0x00000000, ioaddr + CSR7);
612 
613  /* Stop the chip's Tx and Rx processes. */
614  outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
615 
616  /* Clear the missed-packet counter. */
617  inl(ioaddr + CSR8);
618 }
static void whereami(const char *str)
Definition: davicom.c:174
Definition: davicom.c:56
static unsigned long ioaddr
Definition: davicom.c:129
#define outl(data, io_addr)
Definition: io.h:329
Definition: nic.h:49
Definition: davicom.c:56
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.
Definition: davicom.c:56
static void davicom_reset(struct nic *nic)
Definition: davicom.c:463

References CSR6, CSR7, CSR8, davicom_reset(), inl(), ioaddr, outl, and whereami().

◆ davicom_wait()

static void davicom_wait ( unsigned int  nticks)
static

Definition at line 180 of file davicom.c.

181 {
182  unsigned int to = currticks() + nticks;
183  while (currticks() < to)
184  /* wait */ ;
185 }
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42

References currticks().

Referenced by davicom_reset().

◆ phy_read()

static int phy_read ( int  location)
static

Definition at line 194 of file davicom.c.

195 {
196  int i, phy_addr=1;
197  u16 phy_data;
198  u32 io_dcr9;
199 
200  whereami("phy_read\n");
201 
202  io_dcr9 = ioaddr + CSR9;
203 
204  /* Send 33 synchronization clock to Phy controller */
205  for (i=0; i<34; i++)
206  phy_write_1bit(io_dcr9, PHY_DATA_1);
207 
208  /* Send start command(01) to Phy */
209  phy_write_1bit(io_dcr9, PHY_DATA_0);
210  phy_write_1bit(io_dcr9, PHY_DATA_1);
211 
212  /* Send read command(10) to Phy */
213  phy_write_1bit(io_dcr9, PHY_DATA_1);
214  phy_write_1bit(io_dcr9, PHY_DATA_0);
215 
216  /* Send Phy address */
217  for (i=0x10; i>0; i=i>>1)
218  phy_write_1bit(io_dcr9, phy_addr&i ? PHY_DATA_1: PHY_DATA_0);
219 
220  /* Send register address */
221  for (i=0x10; i>0; i=i>>1)
222  phy_write_1bit(io_dcr9, location&i ? PHY_DATA_1: PHY_DATA_0);
223 
224  /* Skip transition state */
225  phy_read_1bit(io_dcr9);
226 
227  /* read 16bit data */
228  for (phy_data=0, i=0; i<16; i++) {
229  phy_data<<=1;
230  phy_data|=phy_read_1bit(io_dcr9);
231  }
232 
233  return phy_data;
234 }
uint16_t u16
Definition: stdint.h:21
Definition: davicom.c:56
static void phy_write_1bit(u32, u32)
Definition: davicom.c:280
static void whereami(const char *str)
Definition: davicom.c:174
static unsigned long ioaddr
Definition: davicom.c:129
#define PHY_DATA_0
Definition: davicom.c:84
#define PHY_DATA_1
Definition: davicom.c:85
static int phy_read_1bit(u32)
Definition: davicom.c:294
uint32_t u32
Definition: stdint.h:23

References CSR9, ioaddr, PHY_DATA_0, PHY_DATA_1, phy_read_1bit(), phy_write_1bit(), and whereami().

Referenced by davicom_media_chk(), and HPNA_process().

◆ phy_write()

static void phy_write ( int  location,
u16  phy_data 
)
static

Definition at line 239 of file davicom.c.

240 {
241  u16 i, phy_addr=1;
242  u32 io_dcr9;
243 
244  whereami("phy_write\n");
245 
246  io_dcr9 = ioaddr + CSR9;
247 
248  /* Send 33 synchronization clock to Phy controller */
249  for (i=0; i<34; i++)
250  phy_write_1bit(io_dcr9, PHY_DATA_1);
251 
252  /* Send start command(01) to Phy */
253  phy_write_1bit(io_dcr9, PHY_DATA_0);
254  phy_write_1bit(io_dcr9, PHY_DATA_1);
255 
256  /* Send write command(01) to Phy */
257  phy_write_1bit(io_dcr9, PHY_DATA_0);
258  phy_write_1bit(io_dcr9, PHY_DATA_1);
259 
260  /* Send Phy address */
261  for (i=0x10; i>0; i=i>>1)
262  phy_write_1bit(io_dcr9, phy_addr&i ? PHY_DATA_1: PHY_DATA_0);
263 
264  /* Send register address */
265  for (i=0x10; i>0; i=i>>1)
266  phy_write_1bit(io_dcr9, location&i ? PHY_DATA_1: PHY_DATA_0);
267 
268  /* written trasnition */
269  phy_write_1bit(io_dcr9, PHY_DATA_1);
270  phy_write_1bit(io_dcr9, PHY_DATA_0);
271 
272  /* Write a word data to PHY controller */
273  for (i=0x8000; i>0; i>>=1)
274  phy_write_1bit(io_dcr9, phy_data&i ? PHY_DATA_1: PHY_DATA_0);
275 }
uint16_t u16
Definition: stdint.h:21
Definition: davicom.c:56
static void phy_write_1bit(u32, u32)
Definition: davicom.c:280
static void whereami(const char *str)
Definition: davicom.c:174
static unsigned long ioaddr
Definition: davicom.c:129
#define PHY_DATA_0
Definition: davicom.c:84
#define PHY_DATA_1
Definition: davicom.c:85
uint32_t u32
Definition: stdint.h:23

References CSR9, ioaddr, PHY_DATA_0, PHY_DATA_1, phy_write_1bit(), and whereami().

Referenced by davicom_media_chk(), and HPNA_process().

◆ phy_write_1bit()

static void phy_write_1bit ( u32  ee_addr,
u32  phy_data 
)
static

Definition at line 280 of file davicom.c.

281 {
282  whereami("phy_write_1bit\n");
283  outl(phy_data, ee_addr); /* MII Clock Low */
284  eeprom_delay();
285  outl(phy_data|MDCLKH, ee_addr); /* MII Clock High */
286  eeprom_delay();
287  outl(phy_data, ee_addr); /* MII Clock Low */
288  eeprom_delay();
289 }
static void whereami(const char *str)
Definition: davicom.c:174
#define outl(data, io_addr)
Definition: io.h:329
#define eeprom_delay()
Definition: davicom.c:91
#define MDCLKH
Definition: davicom.c:86

References eeprom_delay, MDCLKH, outl, and whereami().

Referenced by phy_read(), and phy_write().

◆ phy_read_1bit()

static int phy_read_1bit ( u32  ee_addr)
static

Definition at line 294 of file davicom.c.

295 {
296  int phy_data;
297 
298  whereami("phy_read_1bit\n");
299 
300  outl(0x50000, ee_addr);
301  eeprom_delay();
302 
303  phy_data=(inl(ee_addr)>>19) & 0x1;
304 
305  outl(0x40000, ee_addr);
306  eeprom_delay();
307 
308  return phy_data;
309 }
static void whereami(const char *str)
Definition: davicom.c:174
#define outl(data, io_addr)
Definition: io.h:329
#define eeprom_delay()
Definition: davicom.c:91
uint32_t inl(volatile uint32_t *io_addr)
Read 32-bit dword from I/O-mapped device.

References eeprom_delay, inl(), outl, and whereami().

Referenced by phy_read().

◆ davicom_media_chk() [1/2]

static void davicom_media_chk ( struct nic )
static

Referenced by davicom_reset().

◆ HPNA_process()

static void HPNA_process ( void  )
static

Definition at line 314 of file davicom.c.

315 {
316 
317  if ( (phy_read(3) & 0xfff0) == 0xb900 ) {
318  if ( phy_read(31) == 0x4404 ) {
319  /* DM9801 present */
320  if (phy_read(3) == 0xb901)
321  phy_write(16, 0x5); /* DM9801 E4 */
322  else
323  phy_write(16, 0x1005); /* DM9801 E3 and others */
324  phy_write(25, ((phy_read(24) + 3) & 0xff) | 0xf000);
325  } else {
326  /* DM9802 present */
327  phy_write(16, 0x5);
328  phy_write(25, (phy_read(25) & 0xff00) + 2);
329  }
330  }
331 }
static void phy_write(int, u16)
Definition: davicom.c:239
static int phy_read(int)
Definition: davicom.c:194

References phy_read(), and phy_write().

Referenced by davicom_media_chk().

◆ davicom_media_chk() [2/2]

static void davicom_media_chk ( struct nic *nic  __unused)
static

Definition at line 336 of file davicom.c.

337 {
338  unsigned long to, csr6;
339 
340  csr6 = 0x00200000; /* SF */
341  outl(csr6, ioaddr + CSR6);
342 
343 #define PCI_VENDOR_ID_DAVICOM 0x1282
344 #define PCI_DEVICE_ID_DM9009 0x9009
346  /* Set to 10BaseT mode for DM9009 */
347  phy_write(0, 0);
348  } else {
349  /* For DM9102/DM9102A */
350  to = currticks() + 2 * TICKS_PER_SEC;
351  while ( ((phy_read(1) & 0x24)!=0x24) && (currticks() < to))
352  /* wait */ ;
353 
354  if ( (phy_read(1) & 0x24) == 0x24 ) {
355  if (phy_read(17) & 0xa000)
356  csr6 |= 0x00000200; /* Full Duplex mode */
357  } else
358  csr6 |= 0x00040000; /* Select DM9801/DM9802 when Ethernet link failed */
359  }
360 
361  /* set the chip's operating mode */
362  outl(csr6, ioaddr + CSR6);
363 
364  /* DM9801/DM9802 present check & program */
365  if (csr6 & 0x40000)
366  HPNA_process();
367 }
#define TICKS_PER_SEC
Number of ticks per second.
Definition: timer.h:15
static void phy_write(int, u16)
Definition: davicom.c:239
static void HPNA_process(void)
Definition: davicom.c:314
static unsigned short vendor
Definition: davicom.c:128
static int phy_read(int)
Definition: davicom.c:194
Definition: davicom.c:56
static unsigned long ioaddr
Definition: davicom.c:129
#define PCI_DEVICE_ID_DM9009
#define outl(data, io_addr)
Definition: io.h:329
static unsigned short dev_id
Definition: davicom.c:128
unsigned long currticks(void)
Get current system time in ticks.
Definition: timer.c:42
#define PCI_VENDOR_ID_DAVICOM

References CSR6, currticks(), dev_id, HPNA_process(), ioaddr, outl, PCI_DEVICE_ID_DM9009, PCI_VENDOR_ID_DAVICOM, phy_read(), phy_write(), TICKS_PER_SEC, and vendor.

◆ davicom_irq()

static void davicom_irq ( struct nic *nic  __unused,
irq_action_t action  __unused 
)
static

Definition at line 624 of file davicom.c.

625 {
626  switch ( action ) {
627  case DISABLE :
628  break;
629  case ENABLE :
630  break;
631  case FORCE :
632  break;
633  }
634 }
Definition: nic.h:35
Definition: nic.h:37
Definition: nic.h:36

References DISABLE, ENABLE, and FORCE.

◆ PCI_DRIVER()

PCI_DRIVER ( davicom_driver  ,
davicom_nics  ,
PCI_NO_CLASS   
)

◆ DRIVER()

DRIVER ( "DAVICOM"  ,
nic_driver  ,
pci_driver  ,
davicom_driver  ,
davicom_probe  ,
davicom_disable   
)

Variable Documentation

◆ ee_data

unsigned char ee_data[EEPROM_SIZE]
static

Definition at line 67 of file davicom.c.

Referenced by davicom_probe(), parse_eeprom(), sundance_probe(), and tulip_probe().

◆ davicom_operations

static struct nic_operations davicom_operations
static
Initial value:
= {
.connect = dummy_connect,
.poll = davicom_poll,
.transmit = davicom_transmit,
.irq = davicom_irq,
}
static int davicom_poll(struct nic *nic, int retrieve)
Definition: davicom.c:566
int dummy_connect(struct nic *nic __unused)
Definition: legacy.c:151
static void davicom_irq(struct nic *nic __unused, irq_action_t action __unused)
Definition: davicom.c:624
static void davicom_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
Definition: davicom.c:525

Definition at line 125 of file davicom.c.

Referenced by davicom_probe().

◆ vendor

unsigned short vendor
static

Definition at line 128 of file davicom.c.

Referenced by davicom_media_chk(), and davicom_probe().

◆ dev_id

unsigned short dev_id
static

Definition at line 128 of file davicom.c.

Referenced by davicom_media_chk(), and davicom_probe().

◆ ioaddr

unsigned long ioaddr
static

Definition at line 129 of file davicom.c.

Referenced by a3c90x_internal_IssueCommand(), corkscrew_found_device(), corkscrew_probe1(), cs89x0_probe_addr(), davicom_disable(), davicom_media_chk(), davicom_probe(), davicom_reset(), davicom_transmit(), dm9132_id_table(), dmfe_descriptor_init(), dmfe_init_dm910x(), eepro_probe1(), eeprom_rdy(), eeprom_read(), forcedeth_link_status(), forcedeth_map_regs(), forcedeth_open(), forcedeth_poll(), forcedeth_probe(), forcedeth_transmit(), get_e(), ifec_mdio_read(), ifec_mdio_write(), ifec_net_close(), ifec_net_irq(), ifec_net_transmit(), ifec_reset(), ifec_scb_cmd(), ifec_tx_wake(), mdio_read(), mdio_read_latched(), mdio_write(), mii_rw(), ne_probe1(), nv_disable_hw_interrupts(), nv_enable_hw_interrupts(), nv_init_rings(), nv_mac_reset(), nv_mgmt_acquire_sema(), nv_mgmt_get_version(), nv_mgmt_release_sema(), nv_setup_mac_addr(), nv_setup_phy(), nv_start_rx(), nv_start_tx(), nv_stop_rx(), nv_stop_tx(), nv_txrx_gate(), nv_txrx_reset(), nv_update_linkspeed(), nv_update_pause(), pci_push(), pcnet32_chip_detect(), pcnet32_close(), pcnet32_hw_start(), pcnet32_irq_disable(), pcnet32_irq_enable(), pcnet32_mdio_read(), pcnet32_mdio_write(), pcnet32_open(), pcnet32_poll(), pcnet32_probe(), pcnet32_remove(), pcnet32_set_ops(), pcnet32_setup_if_duplex(), pcnet32_setup_mac_addr(), pcnet32_setup_probe_phy(), pcnet32_transmit(), phy_init(), phy_read(), phy_read_1bit(), phy_write(), phy_write_1bit(), read_eeprom(), read_srom_word(), reg_delay(), sis190_asic_down(), sis190_default_phy(), sis190_down(), sis190_get_mac_addr_from_eeprom(), sis190_hw_start(), sis190_init_board(), sis190_init_phy(), sis190_init_rxfilter(), sis190_irq(), sis190_mii_probe(), sis190_mii_probe_88e1111_fixup(), sis190_phy_task(), sis190_poll(), sis190_remove(), sis190_set_rx_mode(), sis190_set_speed_auto(), sis190_soft_reset(), sis190_transmit(), smc9000_probe_addr(), smc_detect_phy(), smc_phy_configure(), smc_read_phy_register(), smc_reset(), smc_write_phy_register(), t509_activate(), t509_deactivate_and_reset_tag(), update_cr6(), virtnet_open_legacy(), virtnet_probe_legacy(), vp_del_vq(), vp_find_vq(), vp_get(), vp_get_features(), vp_get_isr(), vp_get_status(), vp_notify(), vp_reset(), vp_set_features(), vp_set_status(), and vring_kick().

◆ txd

struct txdesc txd[NTXD]

Definition at line 138 of file davicom.c.

◆ txb

unsigned char txb[BUFLEN]

Definition at line 139 of file davicom.c.

◆ rxd

struct rxdesc rxd[NRXD]

Definition at line 140 of file davicom.c.

◆ rxb

unsigned char rxb[NRXD *BUFLEN]

Definition at line 141 of file davicom.c.

◆ __shared

struct { ... } __shared

◆ rxd_tail

int rxd_tail
static

Definition at line 147 of file davicom.c.

Referenced by davicom_init_chain(), and davicom_poll().

◆ TxPtr

int TxPtr
static

Definition at line 148 of file davicom.c.

Referenced by davicom_init_chain(), davicom_reset(), and davicom_transmit().

◆ davicom_nics

struct pci_device_id davicom_nics[]
static
Initial value:
= {
PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100", 0),
PCI_ROM(0x1282, 0x9102, "davicom9102", "Davicom 9102", 0),
PCI_ROM(0x1282, 0x9009, "davicom9009", "Davicom 9009", 0),
PCI_ROM(0x1282, 0x9132, "davicom9132", "Davicom 9132", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition: pci.h:283

Definition at line 691 of file davicom.c.