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

Go to the source code of this file.

Data Structures

struct  pci_id_info
struct  pci_id_info::match_info
struct  tulip_chip_table
struct  medialeaf
struct  mediatable
struct  mediainfo
struct  tulip_rx_desc
struct  tulip_tx_desc
struct  tulip_private
struct  fixups

Defines

#define TX_TIME_OUT   2*TICKS_PER_SEC
#define get_unaligned(ptr)   (*(ptr))
#define put_unaligned(val, ptr)   ((void)( *(ptr) = (val) ))
#define get_u16(ptr)   (*(u16 *)(ptr))
#define virt_to_le32desc(addr)   virt_to_bus(addr)
#define TULIP_IOTYPE   PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0
#define TULIP_SIZE   0x80
#define FULL_DUPLEX_MAGIC   0x6969
#define MEDIA_MASK   31
#define EEPROM_ADDRLEN   6
#define EEPROM_SIZE   128 /* 2 << 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 eeprom_delay()   inl(ee_addr)
#define BUFLEN   1536
#define DESC_RING_WRAP   0x02000000
#define TX_RING_SIZE   2
#define RX_RING_SIZE   4
#define tx_ring   tulip_bss.tx_ring
#define txb   tulip_bss.txb
#define rx_ring   tulip_bss.rx_ring
#define rxb   tulip_bss.rxb
#define mdio_delay()   inl(mdio_addr)
#define MDIO_SHIFT_CLK   0x10000
#define MDIO_DATA_WRITE0   0x00000
#define MDIO_DATA_WRITE1   0x20000
#define MDIO_ENB   0x00000 /* Ignore the 0x02000 databook setting. */
#define MDIO_ENB_IN   0x40000
#define MDIO_DATA_READ   0x80000

Enumerations

enum  tulip_chips {
  DC21040 = 0, DC21041 = 1, DC21140 = 2, DC21142 = 3,
  DC21143 = 3, LC82C168, MX98713, MX98715,
  MX98725, AX88141, AX88140, PNIC2,
  COMET, COMPEX9881, I21145, XIRCOM,
  SGThomson
}
enum  pci_id_flags_bits {
  PCI_USES_IO = 1, PCI_USES_MEM = 2, PCI_USES_MASTER = 4, PCI_ADDR0 = 0 << 4,
  PCI_ADDR1 = 1 << 4, PCI_ADDR2, PCI_ADDR3 = 3 << 4, PCI_USES_IO = 1,
  PCI_USES_MEM = 2, PCI_USES_MASTER = 4, PCI_ADDR0 = 0<<4, PCI_ADDR1 = 1<<4,
  PCI_ADDR2 = 2<<4, PCI_ADDR3 = 3<<4, PCI_ADDR_64BITS = 0x100, PCI_NO_ACPI_WAKE = 0x200,
  PCI_NO_MIN_LATENCY = 0x400, PCI_UNUSED_IRQ = 0x800
}
enum  tbl_flag {
  HAS_MII = 1, HAS_MEDIA_TABLE = 2, CSR12_IN_SROM = 4, ALWAYS_CHECK_MII = 8,
  HAS_PWRDWN = 0x10, MC_HASH_ONLY = 0x20, HAS_PNICNWAY = 0x80, HAS_NWAY = 0x40,
  HAS_INTR_MITIGATION = 0x100, IS_ASIX = 0x200, HAS_8023X = 0x400
}
enum  MediaIs {
  MediaIsFD = 1, MediaAlwaysFD = 2, MediaIsMII = 4, MediaIsFx = 8,
  MediaIs100 = 16
}
enum  tulip_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
}
enum  status_bits {
  TimerInt = 0x800, TPLnkFail = 0x1000, TPLnkPass = 0x10, NormalIntr = 0x10000,
  AbnormalIntr = 0x8000, RxJabber = 0x200, RxDied = 0x100, RxNoBuf = 0x80,
  RxIntr = 0x40, TxFIFOUnderflow = 0x20, TxJabber = 0x08, TxNoBuf = 0x04,
  TxDied = 0x02, TxIntr = 0x01
}
enum  csr6_mode_bits {
  TxOn = 0x2000, RxOn = 0x0002, FullDuplex = 0x0200, AcceptBroadcast = 0x0100,
  AcceptAllMulticast = 0x0080, AcceptAllPhys = 0x0040, AcceptRunt = 0x0008
}
enum  desc_status_bits {
  DescOwn = 0x8000, DescEndPacket = 0x4000, DescEndRing = 0x2000, LastFrag = 0x80000000,
  DescIntrOnTx = 0x8000, DescIntrOnDMADone = 0x80000000, DisableAlign = 0x00000001, DescOwnded = 0x80000000,
  RxDescFatalErr = 0x8000, RxWholePkt = 0x0300, DescOwn = 0x80000000, DescEndRing = 0x02000000,
  DescUseLink = 0x01000000, DescWholePkt = 0x60000000, DescStartPkt = 0x20000000, DescEndPkt = 0x40000000,
  DescIntr = 0x80000000
}

Functions

 FILE_LICENCE (GPL_ANY)
static int mdio_read (struct nic *nic, int phy_id, int location)
static void mdio_write (struct nic *nic, int phy_id, int location, int value)
static int read_eeprom (unsigned long ioaddr, int location, int addr_len)
static void parse_eeprom (struct nic *nic)
static int tulip_probe (struct nic *nic, struct pci_device *pci)
static void tulip_init_ring (struct nic *nic)
static void tulip_reset (struct nic *nic)
static void tulip_transmit (struct nic *nic, const char *d, unsigned int t, unsigned int s, const char *p)
static int tulip_poll (struct nic *nic, int retrieve)
static void tulip_disable (struct nic *nic)
static void nway_start (struct nic *nic)
static void pnic_do_nway (struct nic *nic)
static void select_media (struct nic *nic, int startup)
static void init_media (struct nic *nic)
static void start_link (struct nic *nic)
static int tulip_check_duplex (struct nic *nic)
static void tulip_wait (unsigned int nticks)
static void whereami (const char *str)
int mdio_read (struct nic *nic __unused, int phy_id, int location)
void mdio_write (struct nic *nic __unused, int phy_id, int location, int value)
static void tulip_init_ring (struct nic *nic __unused)
static void set_rx_mode (struct nic *nic __unused)
static void tulip_irq (struct nic *nic __unused, irq_action_t action __unused)
static void nway_start (struct nic *nic __unused)
static void pnic_do_nway (struct nic *nic __unused)
 PCI_DRIVER (tulip_driver, tulip_nics, PCI_NO_CLASS)
 DRIVER ("Tulip", nic_driver, pci_driver, tulip_driver, tulip_probe, tulip_disable)

Variables

static const int csr0 = 0x01A00000 | 0x8000
static const char *const medianame [32]
static struct pci_id_info pci_id_tbl []
static struct tulip_chip_table tulip_tbl []
static const char media_cap [32]
static u8 t21040_csr13 [] = {2,0x0C,8,4, 4,0,0,0, 0,0,0,0, 4,0,0,0}
static u16 t21041_csr13 [] = { 0xEF01, 0xEF09, 0xEF09, 0xEF01, 0xEF09, }
static u16 t21041_csr14 [] = { 0xFFFF, 0xF7FD, 0xF7FD, 0x7F3F, 0x7F3D, }
static u16 t21041_csr15 [] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, }
static u16 t21142_csr14 [] = { 0xFFFF, 0x0705, 0x0705, 0x0000, 0x7F3D, }
static u32 ioaddr
struct {
   struct tulip_tx_desc   tx_ring [TX_RING_SIZE]
   unsigned char   txb [BUFLEN]
   struct tulip_rx_desc   rx_ring [RX_RING_SIZE]
   unsigned char   rxb [RX_RING_SIZE *BUFLEN]
   struct tulip_private   tpx
__shared
static struct tulip_privatetp
static struct fixups eeprom_fixups []
static const char * block_name []
static struct nic_operations tulip_operations
static struct pci_device_id tulip_nics []

Define Documentation

#define TX_TIME_OUT   2*TICKS_PER_SEC

Definition at line 119 of file tulip.c.

Referenced by tulip_reset(), and tulip_transmit().

#define get_unaligned (   ptr)    (*(ptr))

Definition at line 123 of file tulip.c.

Referenced by parse_eeprom(), and tulip_reset().

#define put_unaligned (   val,
  ptr 
)    ((void)( *(ptr) = (val) ))

Definition at line 124 of file tulip.c.

Referenced by tulip_probe().

#define get_u16 (   ptr)    (*(u16 *)(ptr))

Definition at line 125 of file tulip.c.

Referenced by parse_eeprom(), and select_media().

#define virt_to_le32desc (   addr)    virt_to_bus(addr)

Definition at line 126 of file tulip.c.

Referenced by tulip_init_ring(), tulip_reset(), and tulip_transmit().

Definition at line 128 of file tulip.c.

#define TULIP_SIZE   0x80

Definition at line 129 of file tulip.c.

#define FULL_DUPLEX_MAGIC   0x6969

Definition at line 135 of file tulip.c.

Referenced by select_media().

#define MEDIA_MASK   31

Definition at line 140 of file tulip.c.

Referenced by parse_eeprom().

#define EEPROM_ADDRLEN   6

Definition at line 342 of file tulip.c.

#define EEPROM_SIZE   128 /* 2 << EEPROM_ADDRLEN */

Definition at line 343 of file tulip.c.

Referenced by tulip_probe().

#define EE_WRITE_CMD   (5 << addr_len)

Definition at line 346 of file tulip.c.

#define EE_READ_CMD   (6 << addr_len)

Definition at line 347 of file tulip.c.

Referenced by read_eeprom().

#define EE_ERASE_CMD   (7 << addr_len)

Definition at line 348 of file tulip.c.

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

Definition at line 351 of file tulip.c.

Referenced by read_eeprom().

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

Definition at line 352 of file tulip.c.

Referenced by read_eeprom().

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

Definition at line 353 of file tulip.c.

Referenced by read_eeprom().

#define EE_WRITE_0   0x01

Definition at line 354 of file tulip.c.

#define EE_WRITE_1   0x05

Definition at line 355 of file tulip.c.

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

Definition at line 356 of file tulip.c.

Referenced by read_eeprom().

#define EE_ENB   (0x4800 | EE_CS)

Definition at line 357 of file tulip.c.

Referenced by read_eeprom().

#define eeprom_delay ( )    inl(ee_addr)

Definition at line 362 of file tulip.c.

Referenced by read_eeprom().

#define BUFLEN   1536

Definition at line 365 of file tulip.c.

Referenced by tulip_init_ring(), and tulip_poll().

#define DESC_RING_WRAP   0x02000000

Definition at line 374 of file tulip.c.

Referenced by tulip_init_ring().

#define TX_RING_SIZE   2

Definition at line 427 of file tulip.c.

#define RX_RING_SIZE   4

Definition at line 428 of file tulip.c.

Referenced by tulip_init_ring(), and tulip_poll().

#define tx_ring   tulip_bss.tx_ring

Definition at line 436 of file tulip.c.

#define txb   tulip_bss.txb

Definition at line 437 of file tulip.c.

#define rx_ring   tulip_bss.rx_ring

Definition at line 438 of file tulip.c.

#define rxb   tulip_bss.rxb

Definition at line 439 of file tulip.c.

#define mdio_delay ( )    inl(mdio_addr)

Definition at line 538 of file tulip.c.

Referenced by mdio_read(), and mdio_write().

#define MDIO_SHIFT_CLK   0x10000

Definition at line 543 of file tulip.c.

Referenced by mdio_read(), and mdio_write().

#define MDIO_DATA_WRITE0   0x00000

Definition at line 544 of file tulip.c.

#define MDIO_DATA_WRITE1   0x20000

Definition at line 545 of file tulip.c.

Referenced by mdio_read(), and mdio_write().

#define MDIO_ENB   0x00000 /* Ignore the 0x02000 databook setting. */

Definition at line 546 of file tulip.c.

Referenced by mdio_read(), and mdio_write().

#define MDIO_ENB_IN   0x40000

Definition at line 547 of file tulip.c.

Referenced by mdio_read(), and mdio_write().

#define MDIO_DATA_READ   0x80000

Definition at line 548 of file tulip.c.

Referenced by mdio_read().


Enumeration Type Documentation

Enumerator:
DC21040 
DC21041 
DC21140 
DC21142 
DC21143 
LC82C168 
MX98713 
MX98715 
MX98725 
AX88141 
AX88140 
PNIC2 
COMET 
COMPEX9881 
I21145 
XIRCOM 
SGThomson 

Definition at line 150 of file tulip.c.

Enumerator:
PCI_USES_IO 
PCI_USES_MEM 
PCI_USES_MASTER 
PCI_ADDR0 
PCI_ADDR1 
PCI_ADDR2 
PCI_ADDR3 
PCI_USES_IO 
PCI_USES_MEM 
PCI_USES_MASTER 
PCI_ADDR0 
PCI_ADDR1 
PCI_ADDR2 
PCI_ADDR3 
PCI_ADDR_64BITS 
PCI_NO_ACPI_WAKE 
PCI_NO_MIN_LATENCY 
PCI_UNUSED_IRQ 

Definition at line 156 of file tulip.c.

                       {
    /* Set PCI command register bits before calling probe1(). */
    PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
    /* Read and map the single following PCI BAR. */
    PCI_ADDR0=0<<4, PCI_ADDR1=1<<4, PCI_ADDR2=2<<4, PCI_ADDR3=3<<4,
    PCI_ADDR_64BITS=0x100, PCI_NO_ACPI_WAKE=0x200, PCI_NO_MIN_LATENCY=0x400,
    PCI_UNUSED_IRQ=0x800,
};
enum tbl_flag
Enumerator:
HAS_MII 
HAS_MEDIA_TABLE 
CSR12_IN_SROM 
ALWAYS_CHECK_MII 
HAS_PWRDWN 
MC_HASH_ONLY 
HAS_PNICNWAY 
HAS_NWAY 
HAS_INTR_MITIGATION 
IS_ASIX 
HAS_8023X 

Definition at line 234 of file tulip.c.

              {
    HAS_MII=1, HAS_MEDIA_TABLE=2, CSR12_IN_SROM=4, ALWAYS_CHECK_MII=8,
    HAS_PWRDWN=0x10, MC_HASH_ONLY=0x20, /* Hash-only multicast filter. */
    HAS_PNICNWAY=0x80, HAS_NWAY=0x40,   /* Uses internal NWay xcvr. */
    HAS_INTR_MITIGATION=0x100, IS_ASIX=0x200, HAS_8023X=0x400,
};
enum MediaIs
Enumerator:
MediaIsFD 
MediaAlwaysFD 
MediaIsMII 
MediaIsFx 
MediaIs100 

Definition at line 271 of file tulip.c.

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

Definition at line 294 of file tulip.c.

                   {
    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
};
Enumerator:
TimerInt 
TPLnkFail 
TPLnkPass 
NormalIntr 
AbnormalIntr 
RxJabber 
RxDied 
RxNoBuf 
RxIntr 
TxFIFOUnderflow 
TxJabber 
TxNoBuf 
TxDied 
TxIntr 

Definition at line 301 of file tulip.c.

                 {
    TimerInt=0x800, TPLnkFail=0x1000, TPLnkPass=0x10,
    NormalIntr=0x10000, AbnormalIntr=0x8000,
    RxJabber=0x200, RxDied=0x100, RxNoBuf=0x80, RxIntr=0x40,
    TxFIFOUnderflow=0x20, TxJabber=0x08, TxNoBuf=0x04, TxDied=0x02, TxIntr=0x01,
};
Enumerator:
TxOn 
RxOn 
FullDuplex 
AcceptBroadcast 
AcceptAllMulticast 
AcceptAllPhys 
AcceptRunt 

Definition at line 309 of file tulip.c.

                    {
        TxOn=0x2000, RxOn=0x0002, FullDuplex=0x0200,
        AcceptBroadcast=0x0100, AcceptAllMulticast=0x0080,
        AcceptAllPhys=0x0040, AcceptRunt=0x0008,
};
Enumerator:
DescOwn 
DescEndPacket 
DescEndRing 
LastFrag 
DescIntrOnTx 
DescIntrOnDMADone 
DisableAlign 
DescOwnded 
RxDescFatalErr 
RxWholePkt 
DescOwn 
DescEndRing 
DescUseLink 
DescWholePkt 
DescStartPkt 
DescEndPkt 
DescIntr 

Definition at line 316 of file tulip.c.

                      {
    DescOwnded=0x80000000, RxDescFatalErr=0x8000, RxWholePkt=0x0300,
};

Function Documentation

FILE_LICENCE ( GPL_ANY  )
static int mdio_read ( struct nic nic,
int  phy_id,
int  location 
) [static]
static void mdio_write ( struct nic nic,
int  phy_id,
int  location,
int  value 
) [static]
static int read_eeprom ( unsigned long  ioaddr,
int  location,
int  addr_len 
) [static]

Definition at line 676 of file tulip.c.

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

Referenced by tulip_probe().

{
    int i;
    unsigned short retval = 0;
    long ee_addr = ioaddr + CSR9;
    int read_cmd = location | EE_READ_CMD;

    whereami("read_eeprom\n");

    outl(EE_ENB & ~EE_CS, ee_addr);
    outl(EE_ENB, ee_addr);

    /* Shift the read command bits out. */
    for (i = 4 + addr_len; i >= 0; i--) {
        short dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0;
        outl(EE_ENB | dataval, ee_addr);
        eeprom_delay();
        outl(EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
        eeprom_delay();
    }
    outl(EE_ENB, ee_addr);

    for (i = 16; i > 0; i--) {
        outl(EE_ENB | EE_SHIFT_CLK, ee_addr);
        eeprom_delay();
        retval = (retval << 1) | ((inl(ee_addr) & EE_DATA_READ) ? 1 : 0);
        outl(EE_ENB, ee_addr);
        eeprom_delay();
    }

    /* Terminate the EEPROM access. */
    outl(EE_ENB & ~EE_CS, ee_addr);
    return retval;
}
static void parse_eeprom ( struct nic nic) [static]

Definition at line 715 of file tulip.c.

References fixups::addr0, fixups::addr1, fixups::addr2, bp, tulip_private::chip_id, count, CSR12_IN_SROM, mediatable::csr12dir, mediatable::csr15dir, mediatable::csr15val, DBG, DBG2, DC21041, mediatable::defaultmedia, ee_data, tulip_private::eeprom, eeprom_fixups, tulip_private::flags, get_u16, get_unaligned, mediatable::has_mii, mediatable::has_nonmii, mediatable::has_reset, mediatable::leafcount, medialeaf::leafdata, media, medialeaf::media, MEDIA_MASK, tulip_private::media_table_storage, medianame, memcpy(), mediatable::mleaf, tulip_private::mtable, fixups::name, name, tulip_private::nic_name, NULL, tulip_private::sym_advertise, medialeaf::type, and whereami().

Referenced by tulip_probe().

{
    unsigned char *p, *ee_data = tp->eeprom;
    int new_advertise = 0;
    int i;

    whereami("parse_eeprom\n");

    tp->mtable = NULL;
    /* Detect an old-style (SA only) EEPROM layout:
       memcmp(ee_data, ee_data+16, 8). */
    for (i = 0; i < 8; i ++)
        if (ee_data[i] != ee_data[16+i])
            break;
    if (i >= 8) {
        /* Do a fix-up based on the vendor half of the station address. */
        for (i = 0; eeprom_fixups[i].name; i++) {
            if (nic->node_addr[0] == eeprom_fixups[i].addr0
                &&  nic->node_addr[1] == eeprom_fixups[i].addr1
                &&  nic->node_addr[2] == eeprom_fixups[i].addr2) {
                if (nic->node_addr[2] == 0xE8  &&  ee_data[0x1a] == 0x55)
                    i++;                /* An Accton EN1207, not an outlaw Maxtech. */
                memcpy(ee_data + 26, eeprom_fixups[i].newtable,
                       sizeof(eeprom_fixups[i].newtable));
                DBG("%s: Old format EEPROM on '%s' board.\n%s: Using substitute media control info.\n",
                       tp->nic_name, eeprom_fixups[i].name, tp->nic_name);
                break;
            }
        }
        if (eeprom_fixups[i].name == NULL) { /* No fixup found. */
            DBG("%s: Old style EEPROM with no media selection information.\n",
                   tp->nic_name);
            return;
        }
    }

    if (ee_data[19] > 1) {
        DBG("%s:  Multiport cards (%d ports) may not work correctly.\n",
               tp->nic_name, ee_data[19]);
    }

    p = (void *)ee_data + ee_data[27];

    if (ee_data[27] == 0) {             /* No valid media table. */
            DBG2("%s:  No Valid Media Table. ee_data[27] = %hhX\n",
                 tp->nic_name, ee_data[27]);
    } else if (tp->chip_id == DC21041) {
        int media = get_u16(p);
        int count = p[2];
        p += 3;

        DBG("%s: 21041 Media table, default media %hX (%s).\n",
               tp->nic_name, media,
               media & 0x0800 ? "Autosense" : medianame[media & 15]);
        for (i = 0; i < count; i++) {
            unsigned char media_block = *p++;
            int media_code = media_block & MEDIA_MASK;
            if (media_block & 0x40)
                p += 6;
            switch(media_code) {
            case 0: new_advertise |= 0x0020; break;
            case 4: new_advertise |= 0x0040; break;
            }
            DBG("%s:  21041 media #%d, %s.\n",
                   tp->nic_name, media_code, medianame[media_code]);
        }
    } else {
        unsigned char csr12dir = 0;
        int count;
        struct mediatable *mtable;
        u16 media = get_u16(p);

        p += 2;
        if (tp->flags & CSR12_IN_SROM)
            csr12dir = *p++;
        count = *p++;

        tp->mtable = mtable = (struct mediatable *)&tp->media_table_storage[0];

        mtable->defaultmedia = media;
        mtable->leafcount = count;
        mtable->csr12dir = csr12dir;
        mtable->has_nonmii = mtable->has_mii = mtable->has_reset = 0;
        mtable->csr15dir = mtable->csr15val = 0;

        DBG("%s:  EEPROM default media type %s.\n", tp->nic_name,
               media & 0x0800 ? "Autosense" : medianame[media & MEDIA_MASK]);

        for (i = 0; i < count; i++) {
            struct medialeaf *leaf = &mtable->mleaf[i];

            if ((p[0] & 0x80) == 0) { /* 21140 Compact block. */
                leaf->type = 0;
                leaf->media = p[0] & 0x3f;
                leaf->leafdata = p;
                if ((p[2] & 0x61) == 0x01)      /* Bogus, but Znyx boards do it. */
                    mtable->has_mii = 1;
                p += 4;
            } else {
                switch(leaf->type = p[1]) {
                case 5:
                    mtable->has_reset = i;
                    leaf->media = p[2] & 0x0f;
                    break;
                case 1: case 3:
                    mtable->has_mii = 1;
                    leaf->media = 11;
                    break;
                case 2:
                    if ((p[2] & 0x3f) == 0) {
                        u32 base15 = (p[2] & 0x40) ? get_u16(p + 7) : 0x0008;
                        u16 *p1 = (u16 *)(p + (p[2] & 0x40 ? 9 : 3));
                        mtable->csr15dir = (get_unaligned(p1 + 0)<<16) + base15;
                        mtable->csr15val = (get_unaligned(p1 + 1)<<16) + base15;
                    }
                    /* Fall through. */
                case 0: case 4:
                    mtable->has_nonmii = 1;
                    leaf->media = p[2] & MEDIA_MASK;
                    switch (leaf->media) {
                    case 0: new_advertise |= 0x0020; break;
                    case 4: new_advertise |= 0x0040; break;
                    case 3: new_advertise |= 0x0080; break;
                    case 5: new_advertise |= 0x0100; break;
                    case 6: new_advertise |= 0x0200; break;
                    }
                    break;
                default:
                    leaf->media = 19;
                }
                leaf->leafdata = p + 2;
                p += (p[0] & 0x3f) + 1;
            }
            if (leaf->media == 11) {
                unsigned char *bp = leaf->leafdata;
                DBG2("%s:  MII interface PHY %d, setup/reset sequences %d/%d long, capabilities %hhX %hhX.\n",
                     tp->nic_name, bp[0], bp[1], bp[2 + bp[1]*2],
                     bp[5 + bp[2 + bp[1]*2]*2], bp[4 + bp[2 + bp[1]*2]*2]);
            }
            DBG("%s:  Index #%d - Media %s (#%d) described "
                   "by a %s (%d) block.\n",
                   tp->nic_name, i, medianame[leaf->media], leaf->media,
                   leaf->type < 6 ? block_name[leaf->type] : "UNKNOWN",
                   leaf->type);
        }
        if (new_advertise)
            tp->sym_advertise = new_advertise;
    }
}
static int tulip_probe ( struct nic nic,
struct pci_device pci 
) [static]

Definition at line 1173 of file tulip.c.

References adjust_pci_device(), tulip_private::chip_id, chip_idx, tulip_chip_table::chip_name, COMET, csr0, tulip_private::csr0, CSR5, CSR6, CSR7, CSR8, CSR9, DBG, DBG2, DC21040, DC21041, DC21143, tulip_private::default_port, tulip_private::dev_id, pci_device::device, pci_id_info::drv_flags, ee_data, tulip_private::eeprom, EEPROM_SIZE, ETH_ALEN, eth_ntoa(), tulip_chip_table::flags, tulip_private::flags, HAS_8023X, HAS_MEDIA_TABLE, HAS_PWRDWN, pci_id_info::id, pci_device::id, tulip_private::if_port, inl(), pci_device::ioaddr, ioaddr, IS_ASIX, LC82C168, le16_to_cpu, media_cap, MediaIsMII, memcpy(), tulip_private::mii_advertise, pci_id_info::name, pci_device_id::name, name, tulip_private::nic_name, outl(), parse_eeprom(), pci_id_info::match_info::pci, tulip_private::pci_id_idx, pci_id_info::match_info::pci_mask, pci_read_config_byte(), PCI_REVISION, pci_write_config_dword(), put_unaligned, read_eeprom(), tulip_private::revision, start_link(), TICKS_PER_SEC, tulip_operations, tulip_reset(), tulip_tbl, tulip_wait(), value, pci_device::vendor, tulip_private::vendor_id, and whereami().

                                                                   {

    u32 i;
    u8  chip_rev;
    u8 ee_data[EEPROM_SIZE];
    unsigned short sum;
    int chip_idx;
    static unsigned char last_phys_addr[ETH_ALEN] = {0x00, 'L', 'i', 'n', 'u', 'x'};

    if (pci->ioaddr == 0)
        return 0;

    ioaddr         = pci->ioaddr;
    nic->ioaddr    = pci->ioaddr & ~3;
    nic->irqno     = 0;

    /* point to private storage */
    tp = &tulip_bss.tpx;

    tp->vendor_id  = pci->vendor;
    tp->dev_id     = pci->device;
    tp->nic_name   = pci->id->name;

    tp->if_port = 0;
    tp->default_port = 0;

    adjust_pci_device(pci);

    /* disable interrupts */
    outl(0x00000000, ioaddr + CSR7);

    /* Stop the chip's Tx and Rx processes. */
    outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);

    /* Clear the missed-packet counter. */
    inl(ioaddr + CSR8);

    DBG("\n");                /* so we start on a fresh line */
    whereami("tulip_probe\n");

    DBG2 ("%s: Looking for Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
          tp->vendor_id, tp->dev_id);

    /* Figure out which chip we're dealing with */
    i = 0;
    chip_idx = -1;
  
    while (pci_id_tbl[i].name) {
        if ( (((u32) tp->dev_id << 16) | tp->vendor_id) == 
             (pci_id_tbl[i].id.pci & pci_id_tbl[i].id.pci_mask) ) {
            chip_idx = pci_id_tbl[i].drv_flags;
            break;
        }
        i++;
    }

    if (chip_idx == -1) {
        DBG ("%s: Unknown Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
                tp->vendor_id, tp->dev_id);
        return 0;
    }

    tp->pci_id_idx = i;
    tp->flags = tulip_tbl[chip_idx].flags;

    DBG2 ("%s: tp->pci_id_idx == %d,  name == %s\n", tp->nic_name,
          tp->pci_id_idx, pci_id_tbl[tp->pci_id_idx].name);
    DBG2 ("%s: chip_idx == %d, name == %s\n", tp->nic_name, chip_idx,
          tulip_tbl[chip_idx].chip_name);
  
    /* Bring the 21041/21143 out of sleep mode.
       Caution: Snooze mode does not work with some boards! */
    if (tp->flags & HAS_PWRDWN)
        pci_write_config_dword(pci, 0x40, 0x00000000);

    if (inl(ioaddr + CSR5) == 0xFFFFFFFF) {
        DBG("%s: The Tulip chip at %X is not functioning.\n",
               tp->nic_name, (unsigned int) ioaddr);
        return 0;
    }
   
    pci_read_config_byte(pci, PCI_REVISION, &chip_rev);

    DBG("%s: [chip: %s] rev %d at %hX\n", tp->nic_name,
           tulip_tbl[chip_idx].chip_name, chip_rev, (unsigned int) ioaddr);
    DBG("%s: Vendor=%hX  Device=%hX", tp->nic_name, tp->vendor_id, tp->dev_id);

    if (chip_idx == DC21041  &&  inl(ioaddr + CSR9) & 0x8000) {
        DBG(" 21040 compatible mode.");
        chip_idx = DC21040;
    }

    DBG("\n");

    /* The SROM/EEPROM interface varies dramatically. */
    sum = 0;
    if (chip_idx == DC21040) {
        outl(0, ioaddr + CSR9);         /* Reset the pointer with a dummy write. */
        for (i = 0; i < ETH_ALEN; i++) {
            int value, boguscnt = 100000;
            do
                value = inl(ioaddr + CSR9);
            while (value < 0  && --boguscnt > 0);
            nic->node_addr[i] = value;
            sum += value & 0xff;
        }
    } else if (chip_idx == LC82C168) {
        for (i = 0; i < 3; i++) {
            int value, boguscnt = 100000;
            outl(0x600 | i, ioaddr + 0x98);
            do
                value = inl(ioaddr + CSR9);
            while (value < 0  && --boguscnt > 0);
            put_unaligned(le16_to_cpu(value), ((u16*)nic->node_addr) + i);
            sum += value & 0xffff;
        }
    } else if (chip_idx == COMET) {
        /* No need to read the EEPROM. */
        put_unaligned(inl(ioaddr + 0xA4), (u32 *)nic->node_addr);
        put_unaligned(inl(ioaddr + 0xA8), (u16 *)(nic->node_addr + 4));
        for (i = 0; i < ETH_ALEN; i ++)
            sum += nic->node_addr[i];
    } else {
        /* A serial EEPROM interface, we read now and sort it out later. */
        int sa_offset = 0;
        int ee_addr_size = read_eeprom(ioaddr, 0xff, 8) & 0x40000 ? 8 : 6;

        for (i = 0; i < sizeof(ee_data)/2; i++)
            ((u16 *)ee_data)[i] =
                le16_to_cpu(read_eeprom(ioaddr, i, ee_addr_size));

        /* DEC now has a specification (see Notes) but early board makers
           just put the address in the first EEPROM locations. */
        /* This does  memcmp(eedata, eedata+16, 8) */
        for (i = 0; i < 8; i ++)
            if (ee_data[i] != ee_data[16+i])
                sa_offset = 20;
        if (ee_data[0] == 0xff  &&  ee_data[1] == 0xff &&  ee_data[2] == 0) {
            sa_offset = 2;              /* Grrr, damn Matrox boards. */
        }
        for (i = 0; i < ETH_ALEN; i ++) {
            nic->node_addr[i] = ee_data[i + sa_offset];
            sum += ee_data[i + sa_offset];
        }
    }
    /* Lite-On boards have the address byte-swapped. */
    if ((nic->node_addr[0] == 0xA0  ||  nic->node_addr[0] == 0xC0)
        &&  nic->node_addr[1] == 0x00)
        for (i = 0; i < ETH_ALEN; i+=2) {
            char tmp = nic->node_addr[i];
            nic->node_addr[i] = nic->node_addr[i+1];
            nic->node_addr[i+1] = tmp;
        }

    if (sum == 0  || sum == ETH_ALEN*0xff) {
        DBG("%s: EEPROM not present!\n", tp->nic_name);
        for (i = 0; i < ETH_ALEN-1; i++)
            nic->node_addr[i] = last_phys_addr[i];
        nic->node_addr[i] = last_phys_addr[i] + 1;
    }

    for (i = 0; i < ETH_ALEN; i++)
        last_phys_addr[i] = nic->node_addr[i];

    DBG ( "%s: %s at ioaddr %hX\n", tp->nic_name, eth_ntoa ( nic->node_addr ), 
          (unsigned int) ioaddr );

    tp->chip_id = chip_idx;
    tp->revision = chip_rev;
    tp->csr0 = csr0;

    /* BugFixes: The 21143-TD hangs with PCI Write-and-Invalidate cycles.
       And the ASIX must have a burst limit or horrible things happen. */
    if (chip_idx == DC21143  &&  chip_rev == 65)
        tp->csr0 &= ~0x01000000;
    else if (tp->flags & IS_ASIX)
        tp->csr0 |= 0x2000;

    if (media_cap[tp->default_port] & MediaIsMII) {
        static const u16 media2advert[] = { 0x20, 0x40, 0x03e0, 0x60,
                                            0x80, 0x100, 0x200 };
        tp->mii_advertise = media2advert[tp->default_port - 9];
        tp->mii_advertise |= (tp->flags & HAS_8023X); /* Matching bits! */
    }

    /* This is logically part of the probe routine, but too complex
       to write inline. */
    if (tp->flags & HAS_MEDIA_TABLE) {
        memcpy(tp->eeprom, ee_data, sizeof(tp->eeprom));
        parse_eeprom(nic);
    }

    start_link(nic);

    /* reset the device and make ready for tx and rx of packets */
    tulip_reset(nic);
    nic->nic_op = &tulip_operations;

    /* give the board a chance to reset before returning */
    tulip_wait(4*TICKS_PER_SEC);

    return 1;
}
static void tulip_init_ring ( struct nic nic) [static]

Referenced by tulip_reset().

static void tulip_reset ( struct nic nic) [static]

Definition at line 923 of file tulip.c.

References tulip_private::chip_id, COMET, cpu_to_le32, CSR0, tulip_private::csr0, CSR1, CSR13, CSR14, CSR3, CSR4, CSR6, tulip_private::csr6, currticks(), DBG, tulip_private::flags, get_unaligned, mediatable::has_mii, init_media(), inl(), ioaddr, IS_ASIX, LC82C168, MC_HASH_ONLY, tulip_private::mii_cnt, tulip_private::mtable, tulip_private::nic_name, outl(), PNIC2, rx_ring, set_rx_mode(), status, tulip_check_duplex(), tulip_init_ring(), tulip_wait(), tx_ring, TX_TIME_OUT, txb, virt_to_le32desc, and whereami().

Referenced by tulip_disable(), and tulip_probe().

{
    int i;
    unsigned long to;

    whereami("tulip_reset\n");

    /* Stop Tx and RX */
    outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);

    /* On some chip revs we must set the MII/SYM port before the reset!? */
    if (tp->mii_cnt  ||  (tp->mtable  &&  tp->mtable->has_mii)) {
        outl(0x814C0000, ioaddr + CSR6);
    }
 
    /* Reset the chip, holding bit 0 set at least 50 PCI cycles. */
    outl(0x00000001, ioaddr + CSR0);
    tulip_wait(1);

    /* turn off reset and set cache align=16lword, burst=unlimit */
    outl(tp->csr0, ioaddr + CSR0);

    /*  Wait the specified 50 PCI cycles after a reset */
    tulip_wait(1);

    /* set up transmit and receive descriptors */
    tulip_init_ring(nic);

    if (tp->chip_id == PNIC2) {
        u32 addr_high = (nic->node_addr[1]<<8) + (nic->node_addr[0]<<0);
        /* This address setting does not appear to impact chip operation?? */
        outl((nic->node_addr[5]<<8) + nic->node_addr[4] +
             (nic->node_addr[3]<<24) + (nic->node_addr[2]<<16),
             ioaddr + 0xB0);
        outl(addr_high + (addr_high<<16), ioaddr + 0xB8);
    }

    /* MC_HASH_ONLY boards don't support setup packets */
    if (tp->flags & MC_HASH_ONLY) {
        u32 addr_low = cpu_to_le32(get_unaligned((u32 *)nic->node_addr));
        u32 addr_high = cpu_to_le32(get_unaligned((u16 *)(nic->node_addr+4)));

        /* clear multicast hash filters and setup MAC address filters */
        if (tp->flags & IS_ASIX) {
            outl(0, ioaddr + CSR13);
            outl(addr_low,  ioaddr + CSR14);
            outl(1, ioaddr + CSR13);
            outl(addr_high, ioaddr + CSR14);
            outl(2, ioaddr + CSR13);
            outl(0, ioaddr + CSR14);
            outl(3, ioaddr + CSR13);
            outl(0, ioaddr + CSR14);
        } else if (tp->chip_id == COMET) {
            outl(addr_low,  ioaddr + 0xA4);
            outl(addr_high, ioaddr + 0xA8);
            outl(0, ioaddr + 0xAC);
            outl(0, ioaddr + 0xB0);
        }
    } else {
        /* for other boards we send a setup packet to initialize
           the filters */
        u32 tx_flags = 0x08000000 | 192;

        /* construct perfect filter frame with mac address as first match
           and broadcast address for all others */
        for (i=0; i<192; i++) 
            txb[i] = 0xFF;
        txb[0] = nic->node_addr[0];
        txb[1] = nic->node_addr[1];
        txb[4] = nic->node_addr[2];
        txb[5] = nic->node_addr[3];
        txb[8] = nic->node_addr[4];
        txb[9] = nic->node_addr[5];

        tx_ring[0].length  = cpu_to_le32(tx_flags);
        tx_ring[0].buffer1 = virt_to_le32desc(&txb[0]);
        tx_ring[0].status  = cpu_to_le32(0x80000000);
    }

    /* Point to rx and tx descriptors */
    outl(virt_to_le32desc(&rx_ring[0]), ioaddr + CSR3);
    outl(virt_to_le32desc(&tx_ring[0]), ioaddr + CSR4);

    init_media(nic);

    /* set the chip's operating mode (but don't turn on xmit and recv yet) */
    outl((tp->csr6 & ~0x00002002), ioaddr + CSR6);

    /* send setup packet for cards that support it */
    if (!(tp->flags & MC_HASH_ONLY)) {
        /* enable transmit  wait for completion */
        outl(tp->csr6 | 0x00002000, ioaddr + CSR6);
        /* immediate transmit demand */
        outl(0, ioaddr + CSR1);

        to = currticks() + TX_TIME_OUT;
        while ((tx_ring[0].status & 0x80000000) && (currticks() < to))
            /* wait */ ;

        if (currticks() >= to) {
            DBG ("%s: TX Setup Timeout.\n", tp->nic_name);
        }
    }

    if (tp->chip_id == LC82C168)
        tulip_check_duplex(nic);

    set_rx_mode(nic);   
        
    /* enable transmit and receive */
    outl(tp->csr6 | 0x00002002, ioaddr + CSR6);
}
static void tulip_transmit ( struct nic nic,
const char *  d,
unsigned int  t,
unsigned int  s,
const char *  p 
) [static]

Definition at line 1040 of file tulip.c.

References cpu_to_le32, CSR1, CSR4, CSR6, currticks(), DBG, DBG2, ETH_ALEN, ETH_HLEN, ETH_ZLEN, htons, inl(), ioaddr, memcpy(), tulip_private::nic_name, outl(), status, tx_ring, TX_TIME_OUT, txb, virt_to_le32desc, and whereami().

{
    u16 nstype;
    u32 to;
    u32 csr6 = inl(ioaddr + CSR6);

    whereami("tulip_transmit\n");

    /* Disable Tx */
    outl(csr6 & ~0x00002000, ioaddr + CSR6);

    memcpy(txb, d, ETH_ALEN);
    memcpy(txb + ETH_ALEN, nic->node_addr, ETH_ALEN);
    nstype = htons((u16) t);
    memcpy(txb + 2 * ETH_ALEN, (u8 *)&nstype, 2);
    memcpy(txb + ETH_HLEN, p, s);

    s += ETH_HLEN;
    s &= 0x0FFF;

    /* pad to minimum packet size */
    while (s < ETH_ZLEN)  
        txb[s++] = '\0';

    DBG2("%s: sending %d bytes ethtype %hX\n", tp->nic_name, s, t);
        
    /* setup the transmit descriptor */
    /* 0x60000000 = no interrupt on completion */
    tx_ring[0].length = cpu_to_le32(0x60000000 | s);
    tx_ring[0].status = cpu_to_le32(0x80000000);

    /* Point to transmit descriptor */
    outl(virt_to_le32desc(&tx_ring[0]), ioaddr + CSR4);

    /* Enable Tx */
    outl(csr6 | 0x00002000, ioaddr + CSR6);
    /* immediate transmit demand */
    outl(0, ioaddr + CSR1);

    to = currticks() + TX_TIME_OUT;
    while ((tx_ring[0].status & 0x80000000) && (currticks() < to))
        /* wait */ ;

    if (currticks() >= to) {
        DBG ("TX Timeout!\n");
    }

    /* Disable Tx */
    outl(csr6 & ~0x00002000, ioaddr + CSR6);
}
static int tulip_poll ( struct nic nic,
int  retrieve 
) [static]

Definition at line 1095 of file tulip.c.

References BUFLEN, tulip_private::cur_rx, memcpy(), rx_ring, RX_RING_SIZE, rxb, and whereami().

{

    whereami("tulip_poll\n");

    /* no packet waiting. packet still owned by NIC */
    if (rx_ring[tp->cur_rx].status & 0x80000000)
        return 0;

    if ( ! retrieve ) return 1;

    whereami("tulip_poll got one\n");

    nic->packetlen = (rx_ring[tp->cur_rx].status & 0x3FFF0000) >> 16;

    /* if we get a corrupted packet. throw it away and move on */
    if (rx_ring[tp->cur_rx].status & 0x00008000) {
        /* return the descriptor and buffer to receive ring */
        rx_ring[tp->cur_rx].status = 0x80000000;
        tp->cur_rx = (tp->cur_rx + 1) % RX_RING_SIZE;
        return 0;
    }

    /* copy packet to working buffer */
    memcpy(nic->packet, rxb + tp->cur_rx * BUFLEN, nic->packetlen);

    /* return the descriptor and buffer to receive ring */
    rx_ring[tp->cur_rx].status = 0x80000000;
    tp->cur_rx = (tp->cur_rx + 1) % RX_RING_SIZE;

    return 1;
}
static void tulip_disable ( struct nic nic) [static]

Definition at line 1131 of file tulip.c.

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

                                              {

    whereami("tulip_disable\n");

    tulip_reset(nic);

    /* disable interrupts */
    outl(0x00000000, ioaddr + CSR7);

    /* Stop the chip's Tx and Rx processes. */
    outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);

    /* Clear the missed-packet counter. */
    inl(ioaddr + CSR8);
}
static void nway_start ( struct nic nic) [static]

Referenced by init_media(), and start_link().

static void pnic_do_nway ( struct nic nic) [static]

Referenced by init_media().

static void select_media ( struct nic nic,
int  startup 
) [static]

Definition at line 1672 of file tulip.c.

References tulip_private::advertising, tulip_private::chip_id, CSR11, CSR12, mediatable::csr12dir, CSR13, CSR14, CSR15, tulip_private::csr6, tulip_private::cur_index, DBG, DBG2, DC21040, DC21041, tulip_private::default_port, tulip_private::full_duplex, FULL_DUPLEX_MAGIC, get_u16, mediatable::has_reset, tulip_private::if_port, inl(), ioaddr, LC82C168, medialeaf::leafdata, mdio_write(), media_cap, MediaAlwaysFD, MediaIsFx, MediaIsMII, tulip_private::medialock, medianame, tulip_private::mii_advertise, tulip_private::mii_cnt, mediatable::mleaf, tulip_private::mtable, tulip_private::nic_name, outl(), tulip_private::phys, port, t21040_csr13, t21041_csr13, t21041_csr14, t21041_csr15, t21142_csr14, medialeaf::type, and whereami().

Referenced by init_media(), and start_link().

{
    struct mediatable *mtable = tp->mtable;
    u32 new_csr6;
    int i;

    whereami("select_media\n");

    if (mtable) {
        struct medialeaf *mleaf = &mtable->mleaf[tp->cur_index];
        unsigned char *p = mleaf->leafdata;
        switch (mleaf->type) {
        case 0:                                 /* 21140 non-MII xcvr. */
            DBG2("%s: Using a 21140 non-MII transceiver"
                 " with control setting %hhX.\n",
                 tp->nic_name, p[1]);
            tp->if_port = p[0];
            if (startup)
                outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
            outl(p[1], ioaddr + CSR12);
            new_csr6 = 0x02000000 | ((p[2] & 0x71) << 18);
            break;
        case 2: case 4: {
            u16 setup[5];
            u32 csr13val, csr14val, csr15dir, csr15val;
            for (i = 0; i < 5; i++)
                setup[i] = get_u16(&p[i*2 + 1]);

            tp->if_port = p[0] & 15;
            if (media_cap[tp->if_port] & MediaAlwaysFD)
                tp->full_duplex = 1;

            if (startup && mtable->has_reset) {
                struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
                unsigned char *rst = rleaf->leafdata;
                DBG2("%s: Resetting the transceiver.\n",
                     tp->nic_name);
                for (i = 0; i < rst[0]; i++)
                    outl(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
            }
            DBG2("%s: 21143 non-MII %s transceiver control %hX/%hX.\n",
                 tp->nic_name, medianame[tp->if_port], setup[0], setup[1]);
            if (p[0] & 0x40) {  /* SIA (CSR13-15) setup values are provided. */
                csr13val = setup[0];
                csr14val = setup[1];
                csr15dir = (setup[3]<<16) | setup[2];
                csr15val = (setup[4]<<16) | setup[2];
                outl(0, ioaddr + CSR13);
                outl(csr14val, ioaddr + CSR14);
                outl(csr15dir, ioaddr + CSR15); /* Direction */
                outl(csr15val, ioaddr + CSR15); /* Data */
                outl(csr13val, ioaddr + CSR13);
            } else {
                csr13val = 1;
                csr14val = 0x0003FF7F;
                csr15dir = (setup[0]<<16) | 0x0008;
                csr15val = (setup[1]<<16) | 0x0008;
                if (tp->if_port <= 4)
                    csr14val = t21142_csr14[tp->if_port];
                if (startup) {
                    outl(0, ioaddr + CSR13);
                    outl(csr14val, ioaddr + CSR14);
                }
                outl(csr15dir, ioaddr + CSR15); /* Direction */
                outl(csr15val, ioaddr + CSR15); /* Data */
                if (startup) outl(csr13val, ioaddr + CSR13);
            }
            DBG2("%s:  Setting CSR15 to %X/%X.\n",
                 tp->nic_name, csr15dir, csr15val);
            if (mleaf->type == 4)
                new_csr6 = 0x82020000 | ((setup[2] & 0x71) << 18);
            else
                new_csr6 = 0x82420000;
            break;
        }
        case 1: case 3: {
            int phy_num = p[0];
            int init_length = p[1];
            u16 *misc_info;

            tp->if_port = 11;
            new_csr6 = 0x020E0000;
            if (mleaf->type == 3) {     /* 21142 */
                u16 *init_sequence = (u16*)(p+2);
                u16 *reset_sequence = &((u16*)(p+3))[init_length];
                int reset_length = p[2 + init_length*2];
                misc_info = reset_sequence + reset_length;
                if (startup)
                    for (i = 0; i < reset_length; i++)
                        outl(get_u16(&reset_sequence[i]) << 16, ioaddr + CSR15);
                for (i = 0; i < init_length; i++)
                    outl(get_u16(&init_sequence[i]) << 16, ioaddr + CSR15);
            } else {
                u8 *init_sequence = p + 2;
                u8 *reset_sequence = p + 3 + init_length;
                int reset_length = p[2 + init_length];
                misc_info = (u16*)(reset_sequence + reset_length);
                if (startup) {
                    outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
                    for (i = 0; i < reset_length; i++)
                        outl(reset_sequence[i], ioaddr + CSR12);
                }
                for (i = 0; i < init_length; i++)
                    outl(init_sequence[i], ioaddr + CSR12);
            }
            tp->advertising[phy_num] = get_u16(&misc_info[1]) | 1;
            if (startup < 2) {
                if (tp->mii_advertise == 0)
                    tp->mii_advertise = tp->advertising[phy_num];
                DBG2("%s:  Advertising %hX on MII %d.\n",
                     tp->nic_name, tp->mii_advertise, tp->phys[phy_num]);
                mdio_write(nic, tp->phys[phy_num], 4, tp->mii_advertise);
            }
            break;
        }
        default:
            DBG("%s:  Invalid media table selection %d.\n",
                   tp->nic_name, mleaf->type);
            new_csr6 = 0x020E0000;
        }
        DBG2("%s: Using media type %s, CSR12 is %hhX.\n",
             tp->nic_name, medianame[tp->if_port],
             inl(ioaddr + CSR12) & 0xff);
    } else if (tp->chip_id == DC21041) {
        int port = tp->if_port <= 4 ? tp->if_port : 0;
        DBG2("%s: 21041 using media %s, CSR12 is %hX.\n",
             tp->nic_name, medianame[port == 3 ? 12: port],
             inl(ioaddr + CSR12));
        outl(0x00000000, ioaddr + CSR13); /* Reset the serial interface */
        outl(t21041_csr14[port], ioaddr + CSR14);
        outl(t21041_csr15[port], ioaddr + CSR15);
        outl(t21041_csr13[port], ioaddr + CSR13);
        new_csr6 = 0x80020000;
    } else if (tp->chip_id == LC82C168) {
        if (startup && ! tp->medialock)
            tp->if_port = tp->mii_cnt ? 11 : 0;
        DBG2("%s: PNIC PHY status is %hX, media %s.\n",
             tp->nic_name, inl(ioaddr + 0xB8), medianame[tp->if_port]);
        if (tp->mii_cnt) {
            new_csr6 = 0x810C0000;
            outl(0x0001, ioaddr + CSR15);
            outl(0x0201B07A, ioaddr + 0xB8);
        } else if (startup) {
            /* Start with 10mbps to do autonegotiation. */
            outl(0x32, ioaddr + CSR12);
            new_csr6 = 0x00420000;
            outl(0x0001B078, ioaddr + 0xB8);
            outl(0x0201B078, ioaddr + 0xB8);
        } else if (tp->if_port == 3  ||  tp->if_port == 5) {
            outl(0x33, ioaddr + CSR12);
            new_csr6 = 0x01860000;
            /* Trigger autonegotiation. */
            outl(startup ? 0x0201F868 : 0x0001F868, ioaddr + 0xB8);
        } else {
            outl(0x32, ioaddr + CSR12);
            new_csr6 = 0x00420000;
            outl(0x1F078, ioaddr + 0xB8);
        }
    } else if (tp->chip_id == DC21040) {                                        /* 21040 */
        /* Turn on the xcvr interface. */
        int csr12 = inl(ioaddr + CSR12);
        DBG2("%s: 21040 media type is %s, CSR12 is %hhX.\n",
             tp->nic_name, medianame[tp->if_port], csr12);
        if (media_cap[tp->if_port] & MediaAlwaysFD)
            tp->full_duplex = 1;
        new_csr6 = 0x20000;
        /* Set the full duplux match frame. */
        outl(FULL_DUPLEX_MAGIC, ioaddr + CSR11);
        outl(0x00000000, ioaddr + CSR13); /* Reset the serial interface */
        if (t21040_csr13[tp->if_port] & 8) {
            outl(0x0705, ioaddr + CSR14);
            outl(0x0006, ioaddr + CSR15);
        } else {
            outl(0xffff, ioaddr + CSR14);
            outl(0x0000, ioaddr + CSR15);
        }
        outl(0x8f01 | t21040_csr13[tp->if_port], ioaddr + CSR13);
    } else {                                    /* Unknown chip type with no media table. */
        if (tp->default_port == 0)
            tp->if_port = tp->mii_cnt ? 11 : 3;
        if (media_cap[tp->if_port] & MediaIsMII) {
            new_csr6 = 0x020E0000;
        } else if (media_cap[tp->if_port] & MediaIsFx) {
            new_csr6 = 0x028600000;
        } else
            new_csr6 = 0x038600000;
        DBG2("%s: No media description table, assuming "
             "%s transceiver, CSR12 %hhX.\n",
             tp->nic_name, medianame[tp->if_port],
             inl(ioaddr + CSR12));
    }

    tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0);
    return;
}
static void init_media ( struct nic nic) [static]

Definition at line 1525 of file tulip.c.

References AX88140, AX88141, tulip_private::chip_id, COMET, COMPEX9881, CSR12, CSR13, CSR14, CSR15, CSR5, CSR6, tulip_private::csr6, tulip_private::cur_index, DBG, DBG2, DC21041, DC21142, DC21143, tulip_private::default_port, mediatable::defaultmedia, tulip_private::full_duplex, tulip_private::if_port, inl(), inw(), ioaddr, LC82C168, mediatable::leafcount, mdio_read(), medialeaf::media, media_cap, MediaAlwaysFD, MediaIsMII, medianame, tulip_private::mii_cnt, mediatable::mleaf, tulip_private::mtable, MX98713, MX98715, MX98725, tulip_private::nic_name, NULL, nway_start(), tulip_private::nwayset, outl(), tulip_private::phys, PNIC2, pnic_do_nway(), tulip_private::saved_if_port, select_media(), TPLnkPass, and whereami().

Referenced by tulip_reset().

{
    int i;

    whereami("init_media\n");

    tp->saved_if_port = tp->if_port;
    if (tp->if_port == 0)
        tp->if_port = tp->default_port;

    /* Allow selecting a default media. */
    i = 0;
    if (tp->mtable == NULL)
        goto media_picked;
    if (tp->if_port) {
        int looking_for = media_cap[tp->if_port] & MediaIsMII ? 11 :
            (tp->if_port == 12 ? 0 : tp->if_port);
        for (i = 0; i < tp->mtable->leafcount; i++)
            if (tp->mtable->mleaf[i].media == looking_for) {
                DBG("%s: Using user-specified media %s.\n",
                       tp->nic_name, medianame[tp->if_port]);
                goto media_picked;
            }
    }
    if ((tp->mtable->defaultmedia & 0x0800) == 0) {
        int looking_for = tp->mtable->defaultmedia & 15;
        for (i = 0; i < tp->mtable->leafcount; i++)
            if (tp->mtable->mleaf[i].media == looking_for) {
                DBG("%s: Using EEPROM-set media %s.\n",
                       tp->nic_name, medianame[looking_for]);
                goto media_picked;
            }
    }
    /* Start sensing first non-full-duplex media. */
    for (i = tp->mtable->leafcount - 1;
         (media_cap[tp->mtable->mleaf[i].media] & MediaAlwaysFD) && i > 0; i--)
        ;
 media_picked:

    tp->csr6 = 0;
    tp->cur_index = i;
    tp->nwayset = 0;

    if (tp->if_port) {
        if (tp->chip_id == DC21143  &&  media_cap[tp->if_port] & MediaIsMII) {
            /* We must reset the media CSRs when we force-select MII mode. */
            outl(0x0000, ioaddr + CSR13);
            outl(0x0000, ioaddr + CSR14);
            outl(0x0008, ioaddr + CSR15);
        }
        select_media(nic, 1);
        return;
    }
    switch(tp->chip_id) {
    case DC21041:
        /* tp->nway = 1;*/
        nway_start(nic);
        break;
    case DC21142:
        if (tp->mii_cnt) {
            select_media(nic, 1);
            DBG2("%s: Using MII transceiver %d, status %hX.\n",
                 tp->nic_name, tp->phys[0], mdio_read(nic, tp->phys[0], 1));
            outl(0x82020000, ioaddr + CSR6);
            tp->csr6 = 0x820E0000;
            tp->if_port = 11;
            outl(0x0000, ioaddr + CSR13);
            outl(0x0000, ioaddr + CSR14);
        } else
            nway_start(nic);
        break;
    case PNIC2:
        nway_start(nic);
        break;
    case LC82C168:
        if (tp->mii_cnt) {
            tp->if_port = 11;
            tp->csr6 = 0x814C0000 | (tp->full_duplex ? 0x0200 : 0);
            outl(0x0001, ioaddr + CSR15);
        } else if (inl(ioaddr + CSR5) & TPLnkPass)
            pnic_do_nway(nic);
        else {
            /* Start with 10mbps to do autonegotiation. */
            outl(0x32, ioaddr + CSR12);
            tp->csr6 = 0x00420000;
            outl(0x0001B078, ioaddr + 0xB8);
            outl(0x0201B078, ioaddr + 0xB8);
        }
        break;
    case MX98713: case COMPEX9881:
        tp->if_port = 0;
        tp->csr6 = 0x01880000 | (tp->full_duplex ? 0x0200 : 0);
        outl(0x0f370000 | inw(ioaddr + 0x80), ioaddr + 0x80);
        break;
    case MX98715: case MX98725:
        /* Provided by BOLO, Macronix - 12/10/1998. */
        tp->if_port = 0;
        tp->csr6 = 0x01a80200;
        outl(0x0f370000 | inw(ioaddr + 0x80), ioaddr + 0x80);
        outl(0x11000 | inw(ioaddr + 0xa0), ioaddr + 0xa0);
        break;
    case COMET:
        /* Enable automatic Tx underrun recovery */
        outl(inl(ioaddr + 0x88) | 1, ioaddr + 0x88);
        tp->if_port = 0;
        tp->csr6 = 0x00040000;
        break;
    case AX88140: case AX88141:
        tp->csr6 = tp->mii_cnt ? 0x00040100 : 0x00000100;
        break;
    default:
        select_media(nic, 1);
    }
}
static void start_link ( struct nic nic) [static]

Definition at line 1377 of file tulip.c.

References tulip_private::advertising, ALWAYS_CHECK_MII, tulip_private::chip_id, COMET, COMPEX9881, CSR12, mediatable::csr12dir, CSR13, CSR14, CSR15, CSR6, tulip_private::cur_index, DBG, DC21040, DC21041, DC21140, DC21142, tulip_private::default_port, tulip_private::flags, tulip_private::full_duplex, HAS_MII, mediatable::has_mii, tulip_private::if_port, inl(), ioaddr, LC82C168, mediatable::leafcount, mdio_read(), mdio_write(), medialeaf::media, media_cap, MediaIs100, MediaIsMII, tulip_private::mii_advertise, tulip_private::mii_cnt, mediatable::mleaf, tulip_private::mtable, MX98713, MX98715, MX98725, tulip_private::nic_name, tulip_private::nway, nway_start(), tulip_private::nwayset, outl(), phy, tulip_private::phys, PNIC2, tulip_private::saved_if_port, select_media(), tulip_private::sym_advertise, and whereami().

Referenced by tulip_probe().

{
    int i;

    whereami("start_link\n");

    if ((tp->flags & ALWAYS_CHECK_MII) ||
        (tp->mtable  &&  tp->mtable->has_mii) ||
        ( ! tp->mtable  &&  (tp->flags & HAS_MII))) {
        unsigned int phy, phy_idx;
        if (tp->mtable  &&  tp->mtable->has_mii) {
            for (i = 0; i < tp->mtable->leafcount; i++)
                if (tp->mtable->mleaf[i].media == 11) {
                    tp->cur_index = i;
                    tp->saved_if_port = tp->if_port;
                    select_media(nic, 2);
                    tp->if_port = tp->saved_if_port;
                    break;
                }
        }

        /* Find the connected MII xcvrs. */
        for (phy = 0, phy_idx = 0; phy < 32 && phy_idx < sizeof(tp->phys);
             phy++) {
            int mii_status = mdio_read(nic, phy, 1);
            if ((mii_status & 0x8301) == 0x8001 ||
                ((mii_status & 0x8000) == 0  && (mii_status & 0x7800) != 0)) {
                int mii_reg0 = mdio_read(nic, phy, 0);
                int mii_advert = mdio_read(nic, phy, 4);
                int to_advert;

                if (tp->mii_advertise)
                    to_advert = tp->mii_advertise;
                else if (tp->advertising[phy_idx])
                    to_advert = tp->advertising[phy_idx];
                else                    /* Leave unchanged. */
                    tp->mii_advertise = to_advert = mii_advert;

                tp->phys[phy_idx++] = phy;
                DBG("%s:  MII transceiver %d config %hX status %hX advertising %hX.\n",
                       tp->nic_name, phy, mii_reg0, mii_status, mii_advert);
                                /* Fixup for DLink with miswired PHY. */
                if (mii_advert != to_advert) {
                    DBG("%s:  Advertising %hX on PHY %d previously advertising %hX.\n",
                           tp->nic_name, to_advert, phy, mii_advert);
                    mdio_write(nic, phy, 4, to_advert);
                }
                                /* Enable autonegotiation: some boards default to off. */
                mdio_write(nic, phy, 0, mii_reg0 |
                           (tp->full_duplex ? 0x1100 : 0x1000) |
                           (media_cap[tp->default_port]&MediaIs100 ? 0x2000:0));
            }
        }
        tp->mii_cnt = phy_idx;
        if (tp->mtable  &&  tp->mtable->has_mii  &&  phy_idx == 0) {
            DBG("%s: ***WARNING***: No MII transceiver found!\n",
                   tp->nic_name);
            tp->phys[0] = 1;
        }
    }

    /* Reset the xcvr interface and turn on heartbeat. */
    switch (tp->chip_id) {
    case DC21040:
        outl(0x00000000, ioaddr + CSR13);
        outl(0x00000004, ioaddr + CSR13);
        break;
    case DC21041:
        /* This is nway_start(). */
        if (tp->sym_advertise == 0)
            tp->sym_advertise = 0x0061;
        outl(0x00000000, ioaddr + CSR13);
        outl(0xFFFFFFFF, ioaddr + CSR14);
        outl(0x00000008, ioaddr + CSR15); /* Listen on AUI also. */
        outl(inl(ioaddr + CSR6) | 0x0200, ioaddr + CSR6);
        outl(0x0000EF01, ioaddr + CSR13);
        break;
    case DC21140: default:
        if (tp->mtable)
            outl(tp->mtable->csr12dir | 0x100, ioaddr + CSR12);
        break;
    case DC21142:
    case PNIC2:
        if (tp->mii_cnt  ||  media_cap[tp->if_port] & MediaIsMII) {
            outl(0x82020000, ioaddr + CSR6);
            outl(0x0000, ioaddr + CSR13);
            outl(0x0000, ioaddr + CSR14);
            outl(0x820E0000, ioaddr + CSR6);
        } else
            nway_start(nic);
        break;
    case LC82C168:
        if ( ! tp->mii_cnt) {
            tp->nway = 1;
            tp->nwayset = 0;
            outl(0x00420000, ioaddr + CSR6);
            outl(0x30, ioaddr + CSR12);
            outl(0x0001F078, ioaddr + 0xB8);
            outl(0x0201F078, ioaddr + 0xB8); /* Turn on autonegotiation. */
        }
        break;
    case MX98713: case COMPEX9881:
        outl(0x00000000, ioaddr + CSR6);
        outl(0x000711C0, ioaddr + CSR14); /* Turn on NWay. */
        outl(0x00000001, ioaddr + CSR13);
        break;
    case MX98715: case MX98725:
        outl(0x01a80000, ioaddr + CSR6);
        outl(0xFFFFFFFF, ioaddr + CSR14);
        outl(0x00001000, ioaddr + CSR12);
        break;
    case COMET:
        /* No initialization necessary. */
        break;
    }
}
static int tulip_check_duplex ( struct nic nic) [static]

Definition at line 1874 of file tulip.c.

References tulip_private::advertising, tulip_private::csr6, DBG, DBG2, tulip_private::full_duplex, mdio_read(), tulip_private::nic_name, and tulip_private::phys.

Referenced by tulip_reset().

{
        unsigned int bmsr, lpa, negotiated, new_csr6;

        bmsr = mdio_read(nic, tp->phys[0], 1);
        lpa = mdio_read(nic, tp->phys[0], 5);

        DBG2("%s: MII status %#x, Link partner report %#x.\n",
             tp->nic_name, bmsr, lpa);

        if (bmsr == 0xffff)
                return -2;
        if ((bmsr & 4) == 0) { 
                int new_bmsr = mdio_read(nic, tp->phys[0], 1); 
                if ((new_bmsr & 4) == 0) { 
                        DBG2("%s: No link beat on the MII interface,"
                             " status %#x.\n", tp->nic_name,
                             new_bmsr);
                        return -1;
                }
        }
        tp->full_duplex = lpa & 0x140;

        new_csr6 = tp->csr6;
        negotiated = lpa & tp->advertising[0];

        if(negotiated & 0x380) new_csr6 &= ~0x400000; 
        else                   new_csr6 |= 0x400000;
        if (tp->full_duplex)   new_csr6 |= 0x200; 
        else                   new_csr6 &= ~0x200;

        if (new_csr6 != tp->csr6) {
                tp->csr6 = new_csr6;

                DBG("%s: Setting %s-duplex based on MII"
                    "#%d link partner capability of %#x.\n",
                    tp->nic_name,
                    tp->full_duplex ? "full" : "half",
                    tp->phys[0], lpa);
                return 1;
        }

        return 0;
}
static void tulip_wait ( unsigned int  nticks) [static]

Definition at line 518 of file tulip.c.

References currticks().

Referenced by tulip_probe(), and tulip_reset().

{
    unsigned int to = currticks() + nticks;
    while (currticks() < to)
        /* wait */ ;
}
static void whereami ( const char *  str) [static]
int mdio_read ( struct nic *nic  __unused,
int  phy_id,
int  location 
)

Definition at line 555 of file tulip.c.

References tulip_private::chip_id, COMET, CSR9, inl(), ioaddr, LC82C168, MDIO_DATA_READ, MDIO_DATA_WRITE1, mdio_delay, MDIO_ENB, MDIO_ENB_IN, MDIO_SHIFT_CLK, outl(), and whereami().

{
    int i;
    int read_cmd = (0xf6 << 10) | (phy_id << 5) | location;
    int retval = 0;
    long mdio_addr = ioaddr + CSR9;

    whereami("mdio_read\n");

    if (tp->chip_id == LC82C168) {
        int i = 1000;
        outl(0x60020000 + (phy_id<<23) + (location<<18), ioaddr + 0xA0);
        inl(ioaddr + 0xA0);
        inl(ioaddr + 0xA0);
        while (--i > 0)
            if ( ! ((retval = inl(ioaddr + 0xA0)) & 0x80000000))
                return retval & 0xffff;
        return 0xffff;
    }

    if (tp->chip_id == COMET) {
        if (phy_id == 1) {
            if (location < 7)
                return inl(ioaddr + 0xB4 + (location<<2));
            else if (location == 17)
                return inl(ioaddr + 0xD0);
            else if (location >= 29 && location <= 31)
                return inl(ioaddr + 0xD4 + ((location-29)<<2));
        }
        return 0xffff;
    }

    /* Establish sync by sending at least 32 logic ones. */
    for (i = 32; i >= 0; i--) {
        outl(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
        mdio_delay();
        outl(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
        mdio_delay();
    }
    /* Shift the read command bits out. */
    for (i = 15; i >= 0; i--) {
        int dataval = (read_cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;

        outl(MDIO_ENB | dataval, mdio_addr);
        mdio_delay();
        outl(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
        mdio_delay();
    }
    /* Read the two transition, 16 data, and wire-idle bits. */
    for (i = 19; i > 0; i--) {
        outl(MDIO_ENB_IN, mdio_addr);
        mdio_delay();
        retval = (retval << 1) | ((inl(mdio_addr) & MDIO_DATA_READ) ? 1 : 0);
        outl(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
        mdio_delay();
    }
    return (retval>>1) & 0xffff;
}
void mdio_write ( struct nic *nic  __unused,
int  phy_id,
int  location,
int  value 
)

Definition at line 614 of file tulip.c.

References tulip_private::chip_id, cmd, COMET, CSR9, inl(), ioaddr, LC82C168, MDIO_DATA_WRITE1, mdio_delay, MDIO_ENB, MDIO_ENB_IN, MDIO_SHIFT_CLK, outl(), and whereami().

{
    int i;
    int cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
    long mdio_addr = ioaddr + CSR9;

    whereami("mdio_write\n");

    if (tp->chip_id == LC82C168) {
        int i = 1000;
        outl(cmd, ioaddr + 0xA0);
        do
            if ( ! (inl(ioaddr + 0xA0) & 0x80000000))
                break;
        while (--i > 0);
        return;
    }

    if (tp->chip_id == COMET) {
        if (phy_id != 1)
            return;
        if (location < 7)
            outl(value, ioaddr + 0xB4 + (location<<2));
        else if (location == 17)
            outl(value, ioaddr + 0xD0);
        else if (location >= 29 && location <= 31)
            outl(value, ioaddr + 0xD4 + ((location-29)<<2));
        return;
    }

    /* Establish sync by sending 32 logic ones. */
    for (i = 32; i >= 0; i--) {
        outl(MDIO_ENB | MDIO_DATA_WRITE1, mdio_addr);
        mdio_delay();
        outl(MDIO_ENB | MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);
        mdio_delay();
    }
    /* Shift the command bits out. */
    for (i = 31; i >= 0; i--) {
        int dataval = (cmd & (1 << i)) ? MDIO_DATA_WRITE1 : 0;
        outl(MDIO_ENB | dataval, mdio_addr);
        mdio_delay();
        outl(MDIO_ENB | dataval | MDIO_SHIFT_CLK, mdio_addr);
        mdio_delay();
    }
    /* Clear out extra bits. */
    for (i = 2; i > 0; i--) {
        outl(MDIO_ENB_IN, mdio_addr);
        mdio_delay();
        outl(MDIO_ENB_IN | MDIO_SHIFT_CLK, mdio_addr);
        mdio_delay();
    }
}
static void tulip_init_ring ( struct nic *nic  __unused) [static]

Definition at line 869 of file tulip.c.

References BUFLEN, cpu_to_le32, tulip_private::cur_rx, DESC_RING_WRAP, rx_ring, RX_RING_SIZE, rxb, tx_ring, txb, virt_to_le32desc, and whereami().

{
    int i;

    whereami("tulip_init_ring\n");

    tp->cur_rx = 0;

    for (i = 0; i < RX_RING_SIZE; i++) {
        rx_ring[i].status  = cpu_to_le32(0x80000000);
        rx_ring[i].length  = cpu_to_le32(BUFLEN);
        rx_ring[i].buffer1 = virt_to_le32desc(&rxb[i * BUFLEN]);
        rx_ring[i].buffer2 = virt_to_le32desc(&rx_ring[i+1]);
    }
    /* Mark the last entry as wrapping the ring. */
    rx_ring[i-1].length    = cpu_to_le32(DESC_RING_WRAP | BUFLEN);
    rx_ring[i-1].buffer2   = virt_to_le32desc(&rx_ring[0]);

    /* We only use 1 transmit buffer, but we use 2 descriptors so
       transmit engines have somewhere to point to if they feel the need */

    tx_ring[0].status  = 0x00000000;
    tx_ring[0].buffer1 = virt_to_le32desc(&txb[0]);
    tx_ring[0].buffer2 = virt_to_le32desc(&tx_ring[1]);

    /* this descriptor should never get used, since it will never be owned
       by the machine (status will always == 0) */
    tx_ring[1].status  = 0x00000000;
    tx_ring[1].buffer1 = virt_to_le32desc(&txb[0]);
    tx_ring[1].buffer2 = virt_to_le32desc(&tx_ring[0]);

    /* Mark the last entry as wrapping the ring, though this should never happen */
    tx_ring[1].length  = cpu_to_le32(DESC_RING_WRAP | BUFLEN);
}
static void set_rx_mode ( struct nic *nic  __unused) [static]

Definition at line 905 of file tulip.c.

References AcceptAllMulticast, CSR6, tulip_private::csr6, inl(), ioaddr, and outl().

Referenced by tulip_reset().

                                                  {
        int csr6 = inl(ioaddr + CSR6) & ~0x00D5;

        tp->csr6 &= ~0x00D5;
 
        /* !IFF_PROMISC */
        tp->csr6 |= AcceptAllMulticast;
        csr6 |= AcceptAllMulticast;

        outl(csr6, ioaddr + CSR6);

        
        
}
static void tulip_irq ( struct nic *nic  __unused,
irq_action_t action  __unused 
) [static]

Definition at line 1150 of file tulip.c.

{
  switch ( action ) {
  case DISABLE :
    break;
  case ENABLE :
    break;
  case FORCE :
    break;
  }
}
static void nway_start ( struct nic *nic  __unused) [static]

Definition at line 1494 of file tulip.c.

References tulip_private::chip_id, CSR12, CSR13, CSR14, CSR15, mediatable::csr15dir, mediatable::csr15val, CSR6, tulip_private::csr6, DBG2, DC21041, tulip_private::if_port, ioaddr, tulip_private::lpar, tulip_private::mediasense, tulip_private::mtable, tulip_private::nic_name, tulip_private::nway, tulip_private::nwayset, outl(), outw(), PNIC2, tulip_private::sym_advertise, and whereami().

{
    int csr14 = ((tp->sym_advertise & 0x0780) << 9)  |
        ((tp->sym_advertise&0x0020)<<1) | 0xffbf;

    whereami("nway_start\n");

    tp->if_port = 0;
    tp->nway = tp->mediasense = 1;
    tp->nwayset = tp->lpar = 0;
    if (tp->chip_id == PNIC2) {
        tp->csr6 = 0x01000000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
        return;
    }
    DBG2("%s: Restarting internal NWay autonegotiation, %X.\n",
         tp->nic_name, csr14);
    outl(0x0001, ioaddr + CSR13);
    outl(csr14, ioaddr + CSR14);
    tp->csr6 = 0x82420000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
    outl(tp->csr6, ioaddr + CSR6);
    if (tp->mtable  &&  tp->mtable->csr15dir) {
        outl(tp->mtable->csr15dir, ioaddr + CSR15);
        outl(tp->mtable->csr15val, ioaddr + CSR15);
    } else if (tp->chip_id != PNIC2)
        outw(0x0008, ioaddr + CSR15);
    if (tp->chip_id == DC21041)                 /* Trigger NWAY. */
        outl(0xEF01, ioaddr + CSR12);
    else
        outl(0x1301, ioaddr + CSR12);
}
static void pnic_do_nway ( struct nic *nic  __unused) [static]

Definition at line 1640 of file tulip.c.

References CSR12, CSR6, tulip_private::csr6, DBG2, tulip_private::full_duplex, tulip_private::if_port, inl(), ioaddr, medianame, tulip_private::nic_name, tulip_private::nwayset, outl(), and whereami().

{
    u32 phy_reg = inl(ioaddr + 0xB8);
    u32 new_csr6 = tp->csr6 & ~0x40C40200;

    whereami("pnic_do_nway\n");

    if (phy_reg & 0x78000000) { /* Ignore baseT4 */
        if (phy_reg & 0x20000000)               tp->if_port = 5;
        else if (phy_reg & 0x40000000)  tp->if_port = 3;
        else if (phy_reg & 0x10000000)  tp->if_port = 4;
        else if (phy_reg & 0x08000000)  tp->if_port = 0;
        tp->nwayset = 1;
        new_csr6 = (tp->if_port & 1) ? 0x01860000 : 0x00420000;
        outl(0x32 | (tp->if_port & 1), ioaddr + CSR12);
        if (tp->if_port & 1)
            outl(0x1F868, ioaddr + 0xB8);
        if (phy_reg & 0x30000000) {
            tp->full_duplex = 1;
            new_csr6 |= 0x00000200;
        }
        DBG2("%s: PNIC autonegotiated status %X, %s.\n",
             tp->nic_name, phy_reg, medianame[tp->if_port]);
        if (tp->csr6 != new_csr6) {
            tp->csr6 = new_csr6;
            outl(tp->csr6 | 0x0002, ioaddr + CSR6);     /* Restart Tx */
            outl(tp->csr6 | 0x2002, ioaddr + CSR6);
        }
    }
}
PCI_DRIVER ( tulip_driver  ,
tulip_nics  ,
PCI_NO_CLASS   
)
DRIVER ( "Tulip"  ,
nic_driver  ,
pci_driver  ,
tulip_driver  ,
tulip_probe  ,
tulip_disable   
)

Variable Documentation

const int csr0 = 0x01A00000 | 0x8000 [static]

Definition at line 137 of file tulip.c.

Referenced by tulip_probe().

const char* const medianame[32] [static]
Initial value:
 {
    "10baseT", "10base2", "AUI", "100baseTx",
    "10baseT-FDX", "100baseTx-FDX", "100baseT4", "100baseFx",
    "100baseFx-FDX", "MII 10baseT", "MII 10baseT-FDX", "MII",
    "10baseT(forced)", "MII 100baseTx", "MII 100baseTx-FDX", "MII 100baseT4",
    "MII 100baseFx-HDX", "MII 100baseFx-FDX", "Home-PNA 1Mbps", "Invalid-19",
}

Definition at line 141 of file tulip.c.

Referenced by init_media(), parse_eeprom(), pnic_do_nway(), and select_media().

struct pci_id_info pci_id_tbl[] [static]

Definition at line 176 of file tulip.c.

struct tulip_chip_table tulip_tbl[] [static]

Referenced by tulip_probe().

const char media_cap[32] [static]
Initial value:
{0,0,0,16,  3,19,16,24,  27,4,7,5, 0,20,23,20, 20,31,0,0, }

Definition at line 275 of file tulip.c.

Referenced by init_media(), select_media(), start_link(), and tulip_probe().

u8 t21040_csr13[] = {2,0x0C,8,4, 4,0,0,0, 0,0,0,0, 4,0,0,0} [static]

Definition at line 277 of file tulip.c.

Referenced by select_media().

u16 t21041_csr13[] = { 0xEF01, 0xEF09, 0xEF09, 0xEF01, 0xEF09, } [static]

Definition at line 280 of file tulip.c.

Referenced by select_media().

u16 t21041_csr14[] = { 0xFFFF, 0xF7FD, 0xF7FD, 0x7F3F, 0x7F3D, } [static]

Definition at line 281 of file tulip.c.

Referenced by select_media().

u16 t21041_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, } [static]

Definition at line 282 of file tulip.c.

Referenced by select_media().

u16 t21142_csr14[] = { 0xFFFF, 0x0705, 0x0705, 0x0000, 0x7F3D, } [static]

Definition at line 287 of file tulip.c.

Referenced by select_media().

u32 ioaddr [static]

Definition at line 430 of file tulip.c.

unsigned char txb[BUFLEN]

Definition at line 431 of file tulip.c.

Definition at line 432 of file tulip.c.

unsigned char rxb[RX_RING_SIZE *BUFLEN]

Definition at line 433 of file tulip.c.

Definition at line 434 of file tulip.c.

struct { ... } __shared
struct tulip_private* tp [static]
struct fixups eeprom_fixups[] [static]

Referenced by parse_eeprom().

const char* block_name[] [static]
Initial value:
 {"21140 non-MII", "21140 MII PHY",
                                    "21142 Serial PHY", "21142 MII PHY", "21143 SYM PHY", "21143 reset method"}

Definition at line 480 of file tulip.c.

struct nic_operations tulip_operations [static]
Initial value:
 {
        .connect        = dummy_connect,
        .poll           = tulip_poll,
        .transmit       = tulip_transmit,
        .irq            = tulip_irq,

}

Definition at line 1162 of file tulip.c.

Referenced by tulip_probe().

struct pci_device_id tulip_nics[] [static]

Definition at line 1919 of file tulip.c.