1433d6423SLionel Sambuc /* 2433d6423SLionel Sambuc dp8390.h 3433d6423SLionel Sambuc 4433d6423SLionel Sambuc Created: before Dec 28, 1992 by Philip Homburg 5433d6423SLionel Sambuc */ 6433d6423SLionel Sambuc 7433d6423SLionel Sambuc /* National Semiconductor DP8390 Network Interface Controller. */ 8433d6423SLionel Sambuc 9433d6423SLionel Sambuc /* Page 0, for reading ------------- */ 10433d6423SLionel Sambuc #define DP_CR 0x0 /* Read side of Command Register */ 11433d6423SLionel Sambuc #define DP_CLDA0 0x1 /* Current Local Dma Address 0 */ 12433d6423SLionel Sambuc #define DP_CLDA1 0x2 /* Current Local Dma Address 1 */ 13433d6423SLionel Sambuc #define DP_BNRY 0x3 /* Boundary Pointer */ 14433d6423SLionel Sambuc #define DP_TSR 0x4 /* Transmit Status Register */ 15433d6423SLionel Sambuc #define DP_NCR 0x5 /* Number of Collisions Register */ 16433d6423SLionel Sambuc #define DP_FIFO 0x6 /* Fifo ?? */ 17433d6423SLionel Sambuc #define DP_ISR 0x7 /* Interrupt Status Register */ 18433d6423SLionel Sambuc #define DP_CRDA0 0x8 /* Current Remote Dma Address 0 */ 19433d6423SLionel Sambuc #define DP_CRDA1 0x9 /* Current Remote Dma Address 1 */ 20433d6423SLionel Sambuc #define DP_DUM1 0xA /* unused */ 21433d6423SLionel Sambuc #define DP_DUM2 0xB /* unused */ 22433d6423SLionel Sambuc #define DP_RSR 0xC /* Receive Status Register */ 23433d6423SLionel Sambuc #define DP_CNTR0 0xD /* Tally Counter 0 */ 24433d6423SLionel Sambuc #define DP_CNTR1 0xE /* Tally Counter 1 */ 25433d6423SLionel Sambuc #define DP_CNTR2 0xF /* Tally Counter 2 */ 26433d6423SLionel Sambuc 27433d6423SLionel Sambuc /* Page 0, for writing ------------- */ 28433d6423SLionel Sambuc #define DP_CR 0x0 /* Write side of Command Register */ 29433d6423SLionel Sambuc #define DP_PSTART 0x1 /* Page Start Register */ 30433d6423SLionel Sambuc #define DP_PSTOP 0x2 /* Page Stop Register */ 31433d6423SLionel Sambuc #define DP_BNRY 0x3 /* Boundary Pointer */ 32433d6423SLionel Sambuc #define DP_TPSR 0x4 /* Transmit Page Start Register */ 33433d6423SLionel Sambuc #define DP_TBCR0 0x5 /* Transmit Byte Count Register 0 */ 34433d6423SLionel Sambuc #define DP_TBCR1 0x6 /* Transmit Byte Count Register 1 */ 35433d6423SLionel Sambuc #define DP_ISR 0x7 /* Interrupt Status Register */ 36433d6423SLionel Sambuc #define DP_RSAR0 0x8 /* Remote Start Address Register 0 */ 37433d6423SLionel Sambuc #define DP_RSAR1 0x9 /* Remote Start Address Register 1 */ 38433d6423SLionel Sambuc #define DP_RBCR0 0xA /* Remote Byte Count Register 0 */ 39433d6423SLionel Sambuc #define DP_RBCR1 0xB /* Remote Byte Count Register 1 */ 40433d6423SLionel Sambuc #define DP_RCR 0xC /* Receive Configuration Register */ 41433d6423SLionel Sambuc #define DP_TCR 0xD /* Transmit Configuration Register */ 42433d6423SLionel Sambuc #define DP_DCR 0xE /* Data Configuration Register */ 43433d6423SLionel Sambuc #define DP_IMR 0xF /* Interrupt Mask Register */ 44433d6423SLionel Sambuc 45433d6423SLionel Sambuc /* Page 1, read/write -------------- */ 46433d6423SLionel Sambuc #define DP_CR 0x0 /* Command Register */ 47433d6423SLionel Sambuc #define DP_PAR0 0x1 /* Physical Address Register 0 */ 48433d6423SLionel Sambuc #define DP_PAR1 0x2 /* Physical Address Register 1 */ 49433d6423SLionel Sambuc #define DP_PAR2 0x3 /* Physical Address Register 2 */ 50433d6423SLionel Sambuc #define DP_PAR3 0x4 /* Physical Address Register 3 */ 51433d6423SLionel Sambuc #define DP_PAR4 0x5 /* Physical Address Register 4 */ 52433d6423SLionel Sambuc #define DP_PAR5 0x6 /* Physical Address Register 5 */ 53433d6423SLionel Sambuc #define DP_CURR 0x7 /* Current Page Register */ 54433d6423SLionel Sambuc #define DP_MAR0 0x8 /* Multicast Address Register 0 */ 55433d6423SLionel Sambuc #define DP_MAR1 0x9 /* Multicast Address Register 1 */ 56433d6423SLionel Sambuc #define DP_MAR2 0xA /* Multicast Address Register 2 */ 57433d6423SLionel Sambuc #define DP_MAR3 0xB /* Multicast Address Register 3 */ 58433d6423SLionel Sambuc #define DP_MAR4 0xC /* Multicast Address Register 4 */ 59433d6423SLionel Sambuc #define DP_MAR5 0xD /* Multicast Address Register 5 */ 60433d6423SLionel Sambuc #define DP_MAR6 0xE /* Multicast Address Register 6 */ 61433d6423SLionel Sambuc #define DP_MAR7 0xF /* Multicast Address Register 7 */ 62433d6423SLionel Sambuc 63433d6423SLionel Sambuc /* Bits in dp_cr */ 64433d6423SLionel Sambuc #define CR_STP 0x01 /* Stop: software reset */ 65433d6423SLionel Sambuc #define CR_STA 0x02 /* Start: activate NIC */ 66433d6423SLionel Sambuc #define CR_TXP 0x04 /* Transmit Packet */ 67433d6423SLionel Sambuc #define CR_DMA 0x38 /* Mask for DMA control */ 68433d6423SLionel Sambuc #define CR_DM_NOP 0x00 /* DMA: No Operation */ 69433d6423SLionel Sambuc #define CR_DM_RR 0x08 /* DMA: Remote Read */ 70433d6423SLionel Sambuc #define CR_DM_RW 0x10 /* DMA: Remote Write */ 71433d6423SLionel Sambuc #define CR_DM_SP 0x18 /* DMA: Send Packet */ 72433d6423SLionel Sambuc #define CR_DM_ABORT 0x20 /* DMA: Abort Remote DMA Operation */ 73433d6423SLionel Sambuc #define CR_PS 0xC0 /* Mask for Page Select */ 74433d6423SLionel Sambuc #define CR_PS_P0 0x00 /* Register Page 0 */ 75433d6423SLionel Sambuc #define CR_PS_P1 0x40 /* Register Page 1 */ 76433d6423SLionel Sambuc #define CR_PS_P2 0x80 /* Register Page 2 */ 77433d6423SLionel Sambuc #define CR_PS_T1 0xC0 /* Test Mode Register Map */ 78433d6423SLionel Sambuc 79433d6423SLionel Sambuc /* Bits in dp_isr */ 80433d6423SLionel Sambuc #define ISR_PRX 0x01 /* Packet Received with no errors */ 81433d6423SLionel Sambuc #define ISR_PTX 0x02 /* Packet Transmitted with no errors */ 82433d6423SLionel Sambuc #define ISR_RXE 0x04 /* Receive Error */ 83433d6423SLionel Sambuc #define ISR_TXE 0x08 /* Transmit Error */ 84433d6423SLionel Sambuc #define ISR_OVW 0x10 /* Overwrite Warning */ 85433d6423SLionel Sambuc #define ISR_CNT 0x20 /* Counter Overflow */ 86433d6423SLionel Sambuc #define ISR_RDC 0x40 /* Remote DMA Complete */ 87433d6423SLionel Sambuc #define ISR_RST 0x80 /* Reset Status */ 88433d6423SLionel Sambuc 89433d6423SLionel Sambuc /* Bits in dp_imr */ 90433d6423SLionel Sambuc #define IMR_PRXE 0x01 /* Packet Received iEnable */ 91433d6423SLionel Sambuc #define IMR_PTXE 0x02 /* Packet Transmitted iEnable */ 92433d6423SLionel Sambuc #define IMR_RXEE 0x04 /* Receive Error iEnable */ 93433d6423SLionel Sambuc #define IMR_TXEE 0x08 /* Transmit Error iEnable */ 94433d6423SLionel Sambuc #define IMR_OVWE 0x10 /* Overwrite Warning iEnable */ 95433d6423SLionel Sambuc #define IMR_CNTE 0x20 /* Counter Overflow iEnable */ 96433d6423SLionel Sambuc #define IMR_RDCE 0x40 /* DMA Complete iEnable */ 97433d6423SLionel Sambuc 98433d6423SLionel Sambuc /* Bits in dp_dcr */ 99433d6423SLionel Sambuc #define DCR_WTS 0x01 /* Word Transfer Select */ 100433d6423SLionel Sambuc #define DCR_BYTEWIDE 0x00 /* WTS: byte wide transfers */ 101433d6423SLionel Sambuc #define DCR_WORDWIDE 0x01 /* WTS: word wide transfers */ 102433d6423SLionel Sambuc #define DCR_BOS 0x02 /* Byte Order Select */ 103433d6423SLionel Sambuc #define DCR_LTLENDIAN 0x00 /* BOS: Little Endian */ 104433d6423SLionel Sambuc #define DCR_BIGENDIAN 0x02 /* BOS: Big Endian */ 105433d6423SLionel Sambuc #define DCR_LAS 0x04 /* Long Address Select */ 106433d6423SLionel Sambuc #define DCR_BMS 0x08 /* Burst Mode Select 107433d6423SLionel Sambuc * Called Loopback Select (LS) in 108433d6423SLionel Sambuc * later manuals. Should be set. */ 109433d6423SLionel Sambuc #define DCR_AR 0x10 /* Autoinitialize Remote */ 110433d6423SLionel Sambuc #define DCR_FTS 0x60 /* Fifo Threshold Select */ 111433d6423SLionel Sambuc #define DCR_2BYTES 0x00 /* 2 bytes */ 112433d6423SLionel Sambuc #define DCR_4BYTES 0x40 /* 4 bytes */ 113433d6423SLionel Sambuc #define DCR_8BYTES 0x20 /* 8 bytes */ 114433d6423SLionel Sambuc #define DCR_12BYTES 0x60 /* 12 bytes */ 115433d6423SLionel Sambuc 116433d6423SLionel Sambuc /* Bits in dp_tcr */ 117433d6423SLionel Sambuc #define TCR_CRC 0x01 /* Inhibit CRC */ 118433d6423SLionel Sambuc #define TCR_ELC 0x06 /* Encoded Loopback Control */ 119433d6423SLionel Sambuc #define TCR_NORMAL 0x00 /* ELC: Normal Operation */ 120433d6423SLionel Sambuc #define TCR_INTERNAL 0x02 /* ELC: Internal Loopback */ 121433d6423SLionel Sambuc #define TCR_0EXTERNAL 0x04 /* ELC: External Loopback LPBK=0 */ 122433d6423SLionel Sambuc #define TCR_1EXTERNAL 0x06 /* ELC: External Loopback LPBK=1 */ 123433d6423SLionel Sambuc #define TCR_ATD 0x08 /* Auto Transmit Disable */ 124433d6423SLionel Sambuc #define TCR_OFST 0x10 /* Collision Offset Enable (be nice) */ 125433d6423SLionel Sambuc 126433d6423SLionel Sambuc /* Bits in dp_tsr */ 127433d6423SLionel Sambuc #define TSR_PTX 0x01 /* Packet Transmitted (without error)*/ 128433d6423SLionel Sambuc #define TSR_DFR 0x02 /* Transmit Deferred, reserved in 129433d6423SLionel Sambuc * later manuals. */ 130433d6423SLionel Sambuc #define TSR_COL 0x04 /* Transmit Collided */ 131433d6423SLionel Sambuc #define TSR_ABT 0x08 /* Transmit Aborted */ 132433d6423SLionel Sambuc #define TSR_CRS 0x10 /* Carrier Sense Lost */ 133433d6423SLionel Sambuc #define TSR_FU 0x20 /* FIFO Underrun */ 134433d6423SLionel Sambuc #define TSR_CDH 0x40 /* CD Heartbeat */ 135433d6423SLionel Sambuc #define TSR_OWC 0x80 /* Out of Window Collision */ 136433d6423SLionel Sambuc 137433d6423SLionel Sambuc /* Bits in tp_rcr */ 138433d6423SLionel Sambuc #define RCR_SEP 0x01 /* Save Errored Packets */ 139433d6423SLionel Sambuc #define RCR_AR 0x02 /* Accept Runt Packets */ 140433d6423SLionel Sambuc #define RCR_AB 0x04 /* Accept Broadcast */ 141433d6423SLionel Sambuc #define RCR_AM 0x08 /* Accept Multicast */ 142433d6423SLionel Sambuc #define RCR_PRO 0x10 /* Physical Promiscuous */ 143433d6423SLionel Sambuc #define RCR_MON 0x20 /* Monitor Mode */ 144433d6423SLionel Sambuc 145433d6423SLionel Sambuc /* Bits in dp_rsr */ 146433d6423SLionel Sambuc #define RSR_PRX 0x01 /* Packet Received Intact */ 147433d6423SLionel Sambuc #define RSR_CRC 0x02 /* CRC Error */ 148433d6423SLionel Sambuc #define RSR_FAE 0x04 /* Frame Alignment Error */ 149433d6423SLionel Sambuc #define RSR_FO 0x08 /* FIFO Overrun */ 150433d6423SLionel Sambuc #define RSR_MPA 0x10 /* Missed Packet */ 151433d6423SLionel Sambuc #define RSR_PHY 0x20 /* Multicast Address Match */ 152433d6423SLionel Sambuc #define RSR_DIS 0x40 /* Receiver Disabled */ 153433d6423SLionel Sambuc #define RSR_DFR 0x80 /* In later manuals: Deferring */ 154433d6423SLionel Sambuc 155433d6423SLionel Sambuc typedef struct dp_rcvhdr 156433d6423SLionel Sambuc { 157433d6423SLionel Sambuc u8_t dr_status; /* Copy of rsr */ 158433d6423SLionel Sambuc u8_t dr_next; /* Pointer to next packet */ 159433d6423SLionel Sambuc u8_t dr_rbcl; /* Receive Byte Count Low */ 160433d6423SLionel Sambuc u8_t dr_rbch; /* Receive Byte Count High */ 161433d6423SLionel Sambuc } dp_rcvhdr_t; 162433d6423SLionel Sambuc 163433d6423SLionel Sambuc #define DP_PAGESIZE 256 164433d6423SLionel Sambuc 165433d6423SLionel Sambuc /* Some macros to simplify accessing the dp8390 */ 166433d6423SLionel Sambuc #define inb_reg0(dep, reg) (inb(dep->de_dp8390_port+reg)) 167433d6423SLionel Sambuc #define outb_reg0(dep, reg, data) (outb(dep->de_dp8390_port+reg, data)) 168433d6423SLionel Sambuc #define inb_reg1(dep, reg) (inb(dep->de_dp8390_port+reg)) 169433d6423SLionel Sambuc #define outb_reg1(dep, reg, data) (outb(dep->de_dp8390_port+reg, data)) 170433d6423SLionel Sambuc 171433d6423SLionel Sambuc /* Software interface to the dp8390 driver */ 172433d6423SLionel Sambuc 173433d6423SLionel Sambuc struct dpeth; 174433d6423SLionel Sambuc struct iovec_dat; 175433d6423SLionel Sambuc struct iovec_dat_s; 176433d6423SLionel Sambuc typedef void (*dp_initf_t)(struct dpeth *dep); 177433d6423SLionel Sambuc typedef void (*dp_stopf_t)(struct dpeth *dep); 1783913e490SDavid van Moolenbroek typedef void (*dp_user2nicf_s_t)(struct dpeth *dep, 1793913e490SDavid van Moolenbroek struct netdriver_data *data, int nic_addr, size_t offset, 1803913e490SDavid van Moolenbroek size_t count); 1813913e490SDavid van Moolenbroek typedef void (*dp_nic2userf_s_t)(struct dpeth *dep, 1823913e490SDavid van Moolenbroek struct netdriver_data *data, int nic_addr, size_t offset, 1833913e490SDavid van Moolenbroek size_t count); 184433d6423SLionel Sambuc typedef void (*dp_getblock_t)(struct dpeth *dep, int page, size_t 185433d6423SLionel Sambuc offset, size_t size, void *dst); 186433d6423SLionel Sambuc 187433d6423SLionel Sambuc typedef int irq_hook_t; 188433d6423SLionel Sambuc 189433d6423SLionel Sambuc #define SENDQ_NR 2 /* Maximum size of the send queue */ 190433d6423SLionel Sambuc #define SENDQ_PAGES 6 /* 6 * DP_PAGESIZE >= 1514 bytes */ 191433d6423SLionel Sambuc 192433d6423SLionel Sambuc typedef struct dpeth 193433d6423SLionel Sambuc { 194433d6423SLionel Sambuc /* The de_base_port field is the starting point of the probe. 195433d6423SLionel Sambuc * The conf routine also fills de_linmem and de_irq. If the probe 196433d6423SLionel Sambuc * routine knows the irq and/or memory address because they are 197433d6423SLionel Sambuc * hardwired in the board, the probe should modify these fields. 198433d6423SLionel Sambuc * Futhermore, the probe routine should also fill in de_initf and 199433d6423SLionel Sambuc * de_stopf fields with the appropriate function pointers and set 200433d6423SLionel Sambuc * de_prog_IO iff programmed I/O is to be used. 201433d6423SLionel Sambuc */ 202433d6423SLionel Sambuc port_t de_base_port; 203433d6423SLionel Sambuc phys_bytes de_linmem; 204433d6423SLionel Sambuc char *de_locmem; 205433d6423SLionel Sambuc int de_irq; 206433d6423SLionel Sambuc int de_int_pending; 207433d6423SLionel Sambuc irq_hook_t de_hook; 208433d6423SLionel Sambuc dp_initf_t de_initf; 209433d6423SLionel Sambuc dp_stopf_t de_stopf; 210433d6423SLionel Sambuc int de_prog_IO; 211433d6423SLionel Sambuc 212433d6423SLionel Sambuc /* The initf function fills the following fields. Only cards that do 213433d6423SLionel Sambuc * programmed I/O fill in the de_pata_port field. 214433d6423SLionel Sambuc * In addition, the init routine has to fill in the sendq data 215433d6423SLionel Sambuc * structures. 216433d6423SLionel Sambuc */ 217*f7df02e7SDavid van Moolenbroek netdriver_addr_t de_address; 218433d6423SLionel Sambuc port_t de_dp8390_port; 219433d6423SLionel Sambuc port_t de_data_port; 220433d6423SLionel Sambuc int de_16bit; 221*f7df02e7SDavid van Moolenbroek unsigned int de_ramsize; 222*f7df02e7SDavid van Moolenbroek unsigned int de_offset_page; 223*f7df02e7SDavid van Moolenbroek unsigned int de_startpage; 224*f7df02e7SDavid van Moolenbroek unsigned int de_stoppage; 225433d6423SLionel Sambuc 226433d6423SLionel Sambuc /* PCI config */ 227433d6423SLionel Sambuc char de_pci; /* TRUE iff PCI device */ 228433d6423SLionel Sambuc 229433d6423SLionel Sambuc /* Do it yourself send queue */ 230433d6423SLionel Sambuc struct sendq 231433d6423SLionel Sambuc { 232433d6423SLionel Sambuc int sq_filled; /* this buffer contains a packet */ 233433d6423SLionel Sambuc int sq_size; /* with this size */ 234433d6423SLionel Sambuc int sq_sendpage; /* starting page of the buffer */ 235433d6423SLionel Sambuc } de_sendq[SENDQ_NR]; 236433d6423SLionel Sambuc int de_sendq_nr; 237433d6423SLionel Sambuc int de_sendq_head; /* Enqueue at the head */ 238433d6423SLionel Sambuc int de_sendq_tail; /* Dequeue at the tail */ 239433d6423SLionel Sambuc 240433d6423SLionel Sambuc /* Fields for internal use by the dp8390 driver. */ 241433d6423SLionel Sambuc int de_flags; 242433d6423SLionel Sambuc dp_user2nicf_s_t de_user2nicf_s; 243433d6423SLionel Sambuc dp_nic2userf_s_t de_nic2userf_s; 244433d6423SLionel Sambuc dp_getblock_t de_getblockf; 245433d6423SLionel Sambuc } dpeth_t; 246433d6423SLionel Sambuc 247433d6423SLionel Sambuc #define DEI_DEFAULT 0x8000 248433d6423SLionel Sambuc 2493913e490SDavid van Moolenbroek #define DEF_EMPTY 0x00 2503913e490SDavid van Moolenbroek #define DEF_STOPPED 0x01 251433d6423SLionel Sambuc 2523913e490SDavid van Moolenbroek #define debug 0 253433d6423SLionel Sambuc 254433d6423SLionel Sambuc /* 255433d6423SLionel Sambuc * $PchId: dp8390.h,v 1.10 2005/02/10 17:26:06 philip Exp $ 256433d6423SLionel Sambuc */ 257