iPXE
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
struct  davicom_bss

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()
#define BUFLEN   1536
#define NTXD   2
#define NRXD   4
#define davicom_bufs   NIC_FAKE_BSS ( struct davicom_bss )
#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, void *hwdev)
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_disable (struct nic *nic, void *hwdev __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, davicom_bufs)

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
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

◆ EEPROM_ADDRLEN

#define EEPROM_ADDRLEN   6

Definition at line 61 of file davicom.c.

Referenced by davicom_probe().

◆ EEPROM_SIZE

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

Definition at line 62 of file davicom.c.

Referenced by sundance_probe(), and tulip_probe().

◆ 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.

Referenced by read_eeprom(), read_eeprom(), and read_eeprom().

◆ 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.

Referenced by read_eeprom(), and read_eeprom().

◆ EE_CS

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

Definition at line 76 of file davicom.c.

Referenced by read_eeprom(), and read_eeprom().

◆ EE_DATA_WRITE

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

Definition at line 77 of file davicom.c.

Referenced by read_eeprom(), and read_eeprom().

◆ 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.

Referenced by read_eeprom(), and read_eeprom().

◆ EE_ENB

#define EE_ENB   (0x4800 | EE_CS)

Definition at line 81 of file davicom.c.

Referenced by read_eeprom(), and read_eeprom().

◆ PHY_DATA_0

#define PHY_DATA_0   0x0

Definition at line 84 of file davicom.c.

Referenced by phy_read(), phy_read(), phy_write(), and phy_write().

◆ PHY_DATA_1

#define PHY_DATA_1   0x20000

Definition at line 85 of file davicom.c.

Referenced by phy_read(), phy_read(), phy_write(), and phy_write().

◆ MDCLKH

#define MDCLKH   0x10000

Definition at line 86 of file davicom.c.

Referenced by phy_write_1bit(), and phy_write_1bit().

◆ eeprom_delay

#define eeprom_delay ( )
Value:
inl(ee_addr)
#define inl(io_addr)
Definition io.h:301

Definition at line 91 of file davicom.c.

Referenced by phy_read_1bit(), phy_write_1bit(), and read_eeprom().

◆ BUFLEN

#define BUFLEN   1536

Definition at line 119 of file davicom.c.

Referenced by davicom_init_chain(), davicom_poll(), tulip_init_ring(), and tulip_poll().

◆ NTXD

#define NTXD   2

Definition at line 135 of file davicom.c.

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

◆ NRXD

#define NRXD   4

Definition at line 136 of file davicom.c.

Referenced by davicom_init_chain(), and davicom_poll().

◆ davicom_bufs

#define davicom_bufs   NIC_FAKE_BSS ( struct davicom_bss )

Definition at line 143 of file davicom.c.

Referenced by DRIVER().

◆ txd

◆ txb

◆ rxd

◆ rxb

◆ PCI_VENDOR_ID_DAVICOM

#define PCI_VENDOR_ID_DAVICOM   0x1282

Referenced by davicom_media_chk().

◆ PCI_DEVICE_ID_DM9009

#define PCI_DEVICE_ID_DM9009   0x9009

Referenced by davicom_media_chk().

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};
@ CSR14
Definition davicom.c:57
@ CSR8
Definition davicom.c:56
@ CSR5
Definition davicom.c:55
@ CSR20
Definition davicom.c:57
@ CSR4
Definition davicom.c:55
@ CSR7
Definition davicom.c:56
@ CSR1
Definition davicom.c:55
@ CSR15
Definition davicom.c:57
@ CSR3
Definition davicom.c:55
@ CSR2
Definition davicom.c:55
@ CSR6
Definition davicom.c:56
@ CSR16
Definition davicom.c:57
@ CSR10
Definition davicom.c:56
@ CSR13
Definition davicom.c:57
@ CSR11
Definition davicom.c:56
@ CSR9
Definition davicom.c:56
@ CSR0
Definition davicom.c:55
@ CSR12
Definition davicom.c:57

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL_ANY )

◆ whereami()

void whereami ( const char * str)
inlinestatic

Definition at line 175 of file davicom.c.

176{
177 DBGP("%s\n", str);
178 /* sleep(2); */
179}
#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()

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

Definition at line 378 of file davicom.c.

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}
unsigned long retval
Definition xen.h:46
static unsigned long ioaddr
Definition davicom.c:129
static void whereami(const char *str)
Definition davicom.c:175
#define EE_READ_CMD
Definition davicom.c:71
#define EE_DATA_READ
Definition davicom.c:80
#define EE_DATA_WRITE
Definition davicom.c:77
#define EE_SHIFT_CLK
Definition davicom.c:75
#define eeprom_delay()
Definition davicom.c:91
#define EE_ENB
Definition davicom.c:81
#define EE_CS
Definition davicom.c:76
#define outl(data, io_addr)
Definition io.h:330
static struct command_descriptor read_cmd
"read" command descriptor
Definition nvo_cmd.c:135

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

Referenced by davicom_probe(), and epic100_probe().

◆ davicom_probe()

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

Definition at line 641 of file davicom.c.

641 {
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}
static unsigned char ee_data[EEPROM_SIZE]
Definition davicom.c:67
static unsigned short vendor
Definition davicom.c:128
static void davicom_reset(struct nic *nic)
Definition davicom.c:464
static unsigned short dev_id
Definition davicom.c:128
static struct nic_operations davicom_operations
Definition davicom.c:125
#define EEPROM_ADDRLEN
Definition davicom.c:61
static int read_eeprom(unsigned long ioaddr, int location, int addr_len)
Definition davicom.c:378
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition ethernet.c:176
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define ETH_ALEN
Definition if_ether.h:9
#define le16_to_cpu(value)
Definition byteswap.h:113
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
Definition nic.h:49
unsigned char * node_addr
Definition nic.h:52
unsigned char irqno
Definition nic.h:56
unsigned int ioaddr
Definition nic.h:55
struct nic_operations * nic_op
Definition nic.h:50
unsigned long ioaddr
I/O address.
Definition pci.h:226
uint16_t vendor
Vendor ID.
Definition pci.h:228
uint16_t device
Device ID.
Definition pci.h:230

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

Referenced by DRIVER().

◆ davicom_init_chain()

void davicom_init_chain ( struct nic * nic)
static

Definition at line 417 of file davicom.c.

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}
#define NTXD
Definition davicom.c:135
#define rxb
Definition davicom.c:147
static int rxd_tail
Definition davicom.c:148
#define txb
Definition davicom.c:145
#define NRXD
Definition davicom.c:136
#define txd
Definition davicom.c:144
static int TxPtr
Definition davicom.c:149
#define rxd
Definition davicom.c:146
#define BUFLEN
Definition davicom.c:119
static __always_inline unsigned long virt_to_bus(volatile const void *addr)
Convert virtual address to a bus address.
Definition io.h:184

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

Referenced by davicom_reset().

◆ davicom_reset()

void davicom_reset ( struct nic * nic)
static

Definition at line 464 of file davicom.c.

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}
#define TX_TIME_OUT
Definition davicom.c:51
static void davicom_init_chain(struct nic *nic)
Definition davicom.c:417
static void davicom_media_chk(struct nic *)
static void davicom_wait(unsigned int nticks)
Definition davicom.c:181
uint8_t status
Status.
Definition ena.h:5
#define DBG_MORE(...)
Definition compiler.h:504
#define TICKS_PER_SEC
Number of ticks per second.
Definition timer.h:16
unsigned long currticks(void)
Get current system time in ticks.
Definition timer.c:43

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()

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

Definition at line 526 of file davicom.c.

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}
#define ETH_HLEN
Definition if_ether.h:10
void * memcpy(void *dest, const void *src, size_t len) __nonnull

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

◆ davicom_poll()

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

Definition at line 567 of file davicom.c.

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}
unsigned char * packet
Definition nic.h:53
unsigned int packetlen
Definition nic.h:54

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

◆ davicom_disable() [1/2]

void davicom_disable ( struct nic * nic,
void * hwdev )
static

References u16, and u32.

Referenced by DRIVER().

◆ davicom_wait()

void davicom_wait ( unsigned int nticks)
static

Definition at line 181 of file davicom.c.

182{
183 unsigned int to = currticks() + nticks;
184 while (currticks() < to)
185 /* wait */ ;
186}

References currticks().

Referenced by davicom_reset().

◆ phy_read()

int phy_read ( int location)
static

Definition at line 195 of file davicom.c.

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}
#define PHY_DATA_1
Definition davicom.c:85
static void phy_write_1bit(u32, u32)
Definition davicom.c:281
static int phy_read_1bit(u32)
Definition davicom.c:295
#define PHY_DATA_0
Definition davicom.c:84
#define u16
Definition vga.h:20
#define u32
Definition vga.h:21

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

Referenced by davicom_media_chk(), and HPNA_process().

◆ phy_write()

void phy_write ( int location,
u16 phy_data )
static

Definition at line 240 of file davicom.c.

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}

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

Referenced by davicom_media_chk(), and HPNA_process().

◆ phy_write_1bit()

void phy_write_1bit ( u32 ee_addr,
u32 phy_data )
static

Definition at line 281 of file davicom.c.

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}
#define MDCLKH
Definition davicom.c:86

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

Referenced by phy_read(), and phy_write().

◆ phy_read_1bit()

int phy_read_1bit ( u32 ee_addr)
static

Definition at line 295 of file davicom.c.

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}

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

Referenced by phy_read().

◆ davicom_media_chk() [1/2]

void davicom_media_chk ( struct nic * )
static

Referenced by davicom_reset().

◆ HPNA_process()

void HPNA_process ( void )
static

Definition at line 315 of file davicom.c.

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}
static void phy_write(int, u16)
Definition davicom.c:240
static int phy_read(int)
Definition davicom.c:195

References phy_read(), and phy_write().

Referenced by davicom_media_chk().

◆ davicom_media_chk() [2/2]

void davicom_media_chk ( struct nic *nic __unused)
static

Definition at line 337 of file davicom.c.

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}
#define PCI_VENDOR_ID_DAVICOM
#define PCI_DEVICE_ID_DM9009
static void HPNA_process(void)
Definition davicom.c:315

References __unused, 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_disable() [2/2]

void davicom_disable ( struct nic * nic,
void *hwdev __unused )
static

Definition at line 605 of file davicom.c.

605 {
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}

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

◆ davicom_irq()

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

Definition at line 625 of file davicom.c.

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

References __unused, DISABLE, ENABLE, and FORCE.

◆ PCI_DRIVER()

PCI_DRIVER ( davicom_driver ,
davicom_nics ,
PCI_NO_CLASS  )

References davicom_nics.

◆ DRIVER()

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

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

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:567
static void davicom_irq(struct nic *nic __unused, irq_action_t action __unused)
Definition davicom.c:625
static void davicom_transmit(struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
Definition davicom.c:526
int dummy_connect(struct nic *nic __unused)
Definition legacy.c:175

Definition at line 125 of file davicom.c.

Referenced by davicom_probe().

◆ vendor

◆ dev_id

unsigned short dev_id
static

Definition at line 128 of file davicom.c.

Referenced by davicom_media_chk(), davicom_probe(), and sis900_probe().

◆ ioaddr

unsigned long ioaddr
static

Definition at line 129 of file davicom.c.

Referenced by __mdio_cmd(), a3c90x_internal_IssueCommand(), check_duplex(), 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_descriptor_init(), dmfe_init_dm910x(), eepro_probe1(), eeprom_rdy(), eeprom_read(), epic100_probe(), 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(), init_media(), mdio_read(), mdio_read(), mdio_read_latched(), mdio_write(), mdio_write(), 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(), nway_start(), 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(), phy_read_1bit(), phy_write(), phy_write(), phy_write_1bit(), pnic_do_nway(), read_eeprom(), read_eeprom(), read_eeprom(), read_srom_word(), reg_delay(), select_media(), set_rx_mode(), set_rx_mode(), 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_irq_mask_and_ack(), sis190_mii_probe(), sis190_mii_probe_88e1111_fixup(), sis190_phy_task(), sis190_poll(), sis190_read_eeprom(), sis190_remove(), sis190_set_rx_mode(), sis190_set_speed_auto(), sis190_soft_reset(), sis190_transmit(), sis635_get_mac_addr(), sis900_check_mode(), sis900_disable(), sis900_init(), sis900_init_rxd(), sis900_init_rxfilter(), sis900_init_txd(), sis900_irq(), sis900_mdio_read(), sis900_poll(), sis900_probe(), sis900_read_eeprom(), sis900_reset(), sis900_set_rx_mode(), sis900_transmit(), sis96x_get_mac_addr(), smc9000_probe_addr(), smc_detect_phy(), smc_phy_configure(), smc_read_phy_register(), smc_reset(), smc_write_phy_register(), start_link(), t509_activate(), t509_deactivate_and_reset_tag(), tulip_disable(), tulip_probe(), tulip_reset(), tulip_transmit(), 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(), vring_kick(), w89c840_disable(), w89c840_poll(), w89c840_probe(), w89c840_reset(), and w89c840_transmit().

◆ rxd_tail

int rxd_tail
static

Definition at line 148 of file davicom.c.

Referenced by davicom_init_chain(), and davicom_poll().

◆ TxPtr

int TxPtr
static

Definition at line 149 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, 0x9009, "davicom9009", "Davicom 9009", 0),
PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100", 0),
PCI_ROM(0x1282, 0x9102, "davicom9102", "Davicom 9102", 0),
PCI_ROM(0x1282, 0x9132, "davicom9132", "Davicom 9132", 0),
}
#define PCI_ROM(_vendor, _device, _name, _description, _data)
Definition pci.h:308

Definition at line 692 of file davicom.c.

692 {
693PCI_ROM(0x1282, 0x9009, "davicom9009", "Davicom 9009", 0),
694PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100", 0),
695PCI_ROM(0x1282, 0x9102, "davicom9102", "Davicom 9102", 0),
696PCI_ROM(0x1282, 0x9132, "davicom9132", "Davicom 9132", 0), /* Needs probably some fixing */
697};

Referenced by PCI_DRIVER().