186d7f5d3SJohn Marino /* 286d7f5d3SJohn Marino * Copyright (c) 1997, 1998 386d7f5d3SJohn Marino * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 486d7f5d3SJohn Marino * 586d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without 686d7f5d3SJohn Marino * modification, are permitted provided that the following conditions 786d7f5d3SJohn Marino * are met: 886d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright 986d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer. 1086d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 1186d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the 1286d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution. 1386d7f5d3SJohn Marino * 3. All advertising materials mentioning features or use of this software 1486d7f5d3SJohn Marino * must display the following acknowledgement: 1586d7f5d3SJohn Marino * This product includes software developed by Bill Paul. 1686d7f5d3SJohn Marino * 4. Neither the name of the author nor the names of any co-contributors 1786d7f5d3SJohn Marino * may be used to endorse or promote products derived from this software 1886d7f5d3SJohn Marino * without specific prior written permission. 1986d7f5d3SJohn Marino * 2086d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 2186d7f5d3SJohn Marino * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2286d7f5d3SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2386d7f5d3SJohn Marino * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 2486d7f5d3SJohn Marino * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2586d7f5d3SJohn Marino * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2686d7f5d3SJohn Marino * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2786d7f5d3SJohn Marino * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2886d7f5d3SJohn Marino * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2986d7f5d3SJohn Marino * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 3086d7f5d3SJohn Marino * THE POSSIBILITY OF SUCH DAMAGE. 3186d7f5d3SJohn Marino * 3286d7f5d3SJohn Marino * $FreeBSD: src/sys/pci/if_tlreg.h,v 1.15 1999/09/19 22:39:24 wpaul Exp $ 3386d7f5d3SJohn Marino * $DragonFly: src/sys/dev/netif/tl/if_tlreg.h,v 1.5 2005/06/14 12:38:04 joerg Exp $ 3486d7f5d3SJohn Marino */ 3586d7f5d3SJohn Marino 3686d7f5d3SJohn Marino 3786d7f5d3SJohn Marino struct tl_type { 3886d7f5d3SJohn Marino u_int16_t tl_vid; 3986d7f5d3SJohn Marino u_int16_t tl_did; 4086d7f5d3SJohn Marino char *tl_name; 4186d7f5d3SJohn Marino }; 4286d7f5d3SJohn Marino 4386d7f5d3SJohn Marino /* 4486d7f5d3SJohn Marino * ThunderLAN TX/RX list format. The TX and RX lists are pretty much 4586d7f5d3SJohn Marino * identical: the list begins with a 32-bit forward pointer which points 4686d7f5d3SJohn Marino * at the next list in the chain, followed by 16 bits for the total 4786d7f5d3SJohn Marino * frame size, and a 16 bit status field. This is followed by a series 4886d7f5d3SJohn Marino * of 10 32-bit data count/data address pairs that point to the fragments 4986d7f5d3SJohn Marino * that make up the complete frame. 5086d7f5d3SJohn Marino */ 5186d7f5d3SJohn Marino 5286d7f5d3SJohn Marino #define TL_MAXFRAGS 10 5386d7f5d3SJohn Marino #define TL_RX_LIST_CNT 64 5486d7f5d3SJohn Marino #define TL_TX_LIST_CNT 128 5586d7f5d3SJohn Marino #define TL_MIN_FRAMELEN 64 5686d7f5d3SJohn Marino 5786d7f5d3SJohn Marino struct tl_frag { 5886d7f5d3SJohn Marino u_int32_t tlist_dcnt; 5986d7f5d3SJohn Marino u_int32_t tlist_dadr; 6086d7f5d3SJohn Marino }; 6186d7f5d3SJohn Marino 6286d7f5d3SJohn Marino struct tl_list { 6386d7f5d3SJohn Marino u_int32_t tlist_fptr; /* phys address of next list */ 6486d7f5d3SJohn Marino u_int16_t tlist_cstat; /* status word */ 6586d7f5d3SJohn Marino u_int16_t tlist_frsize; /* size of data in frame */ 6686d7f5d3SJohn Marino struct tl_frag tl_frag[TL_MAXFRAGS]; 6786d7f5d3SJohn Marino }; 6886d7f5d3SJohn Marino 6986d7f5d3SJohn Marino /* 7086d7f5d3SJohn Marino * This is a special case of an RX list. By setting the One_Frag 7186d7f5d3SJohn Marino * bit in the NETCONFIG register, the driver can force the ThunderLAN 7286d7f5d3SJohn Marino * chip to use only one fragment when DMAing RX frames. 7386d7f5d3SJohn Marino */ 7486d7f5d3SJohn Marino 7586d7f5d3SJohn Marino struct tl_list_onefrag { 7686d7f5d3SJohn Marino u_int32_t tlist_fptr; 7786d7f5d3SJohn Marino u_int16_t tlist_cstat; 7886d7f5d3SJohn Marino u_int16_t tlist_frsize; 7986d7f5d3SJohn Marino struct tl_frag tl_frag; 8086d7f5d3SJohn Marino }; 8186d7f5d3SJohn Marino 8286d7f5d3SJohn Marino struct tl_list_data { 8386d7f5d3SJohn Marino struct tl_list_onefrag tl_rx_list[TL_RX_LIST_CNT]; 8486d7f5d3SJohn Marino struct tl_list tl_tx_list[TL_TX_LIST_CNT]; 8586d7f5d3SJohn Marino unsigned char tl_pad[TL_MIN_FRAMELEN]; 8686d7f5d3SJohn Marino }; 8786d7f5d3SJohn Marino 8886d7f5d3SJohn Marino struct tl_chain { 8986d7f5d3SJohn Marino struct tl_list *tl_ptr; 9086d7f5d3SJohn Marino struct mbuf *tl_mbuf; 9186d7f5d3SJohn Marino struct tl_chain *tl_next; 9286d7f5d3SJohn Marino }; 9386d7f5d3SJohn Marino 9486d7f5d3SJohn Marino struct tl_chain_onefrag { 9586d7f5d3SJohn Marino struct tl_list_onefrag *tl_ptr; 9686d7f5d3SJohn Marino struct mbuf *tl_mbuf; 9786d7f5d3SJohn Marino struct tl_chain_onefrag *tl_next; 9886d7f5d3SJohn Marino }; 9986d7f5d3SJohn Marino 10086d7f5d3SJohn Marino struct tl_chain_data { 10186d7f5d3SJohn Marino struct tl_chain_onefrag tl_rx_chain[TL_RX_LIST_CNT]; 10286d7f5d3SJohn Marino struct tl_chain tl_tx_chain[TL_TX_LIST_CNT]; 10386d7f5d3SJohn Marino 10486d7f5d3SJohn Marino struct tl_chain_onefrag *tl_rx_head; 10586d7f5d3SJohn Marino struct tl_chain_onefrag *tl_rx_tail; 10686d7f5d3SJohn Marino 10786d7f5d3SJohn Marino struct tl_chain *tl_tx_head; 10886d7f5d3SJohn Marino struct tl_chain *tl_tx_tail; 10986d7f5d3SJohn Marino struct tl_chain *tl_tx_free; 11086d7f5d3SJohn Marino }; 11186d7f5d3SJohn Marino 11286d7f5d3SJohn Marino struct tl_softc { 11386d7f5d3SJohn Marino struct arpcom arpcom; /* interface info */ 11486d7f5d3SJohn Marino struct ifmedia ifmedia; /* media info */ 11586d7f5d3SJohn Marino bus_space_handle_t tl_bhandle; 11686d7f5d3SJohn Marino bus_space_tag_t tl_btag; 11786d7f5d3SJohn Marino void *tl_intrhand; 11886d7f5d3SJohn Marino struct resource *tl_irq; 11986d7f5d3SJohn Marino struct resource *tl_res; 12086d7f5d3SJohn Marino device_t tl_miibus; 12186d7f5d3SJohn Marino struct tl_type *tl_dinfo; /* ThunderLAN adapter info */ 12286d7f5d3SJohn Marino u_int8_t tl_eeaddr; 12386d7f5d3SJohn Marino struct tl_list_data *tl_ldata; /* TX/RX lists and mbufs */ 12486d7f5d3SJohn Marino struct tl_chain_data tl_cdata; 12586d7f5d3SJohn Marino u_int8_t tl_txeoc; 12686d7f5d3SJohn Marino u_int8_t tl_bitrate; 12786d7f5d3SJohn Marino int tl_if_flags; 12886d7f5d3SJohn Marino struct callout tl_stat_timer; 12986d7f5d3SJohn Marino }; 13086d7f5d3SJohn Marino 13186d7f5d3SJohn Marino /* 13286d7f5d3SJohn Marino * Transmit interrupt threshold. 13386d7f5d3SJohn Marino */ 13486d7f5d3SJohn Marino #define TX_THR 0x00000004 13586d7f5d3SJohn Marino 13686d7f5d3SJohn Marino /* 13786d7f5d3SJohn Marino * General constants that are fun to know. 13886d7f5d3SJohn Marino * 13986d7f5d3SJohn Marino * The ThunderLAN controller is made by Texas Instruments. The 14086d7f5d3SJohn Marino * manual indicates that if the EEPROM checksum fails, the PCI 14186d7f5d3SJohn Marino * vendor and device ID registers will be loaded with TI-specific 14286d7f5d3SJohn Marino * values. 14386d7f5d3SJohn Marino */ 14486d7f5d3SJohn Marino #define TI_VENDORID 0x104C 14586d7f5d3SJohn Marino #define TI_DEVICEID_THUNDERLAN 0x0500 14686d7f5d3SJohn Marino 14786d7f5d3SJohn Marino /* 14886d7f5d3SJohn Marino * These are the PCI vendor and device IDs for Compaq ethernet 14986d7f5d3SJohn Marino * adapters based on the ThunderLAN controller. 15086d7f5d3SJohn Marino */ 15186d7f5d3SJohn Marino #define COMPAQ_VENDORID 0x0E11 15286d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETEL_10_100 0xAE32 15386d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETEL_UNKNOWN 0xAE33 15486d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETEL_10 0xAE34 15586d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETFLEX_3P_INTEGRATED 0xAE35 15686d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETEL_10_100_DUAL 0xAE40 15786d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETEL_10_100_PROLIANT 0xAE43 15886d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETEL_10_100_EMBEDDED 0xB011 15986d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETEL_10_T2_UTP_COAX 0xB012 16086d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETEL_10_100_TX_UTP 0xB030 16186d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETFLEX_3P 0xF130 16286d7f5d3SJohn Marino #define COMPAQ_DEVICEID_NETFLEX_3P_BNC 0xF150 16386d7f5d3SJohn Marino 16486d7f5d3SJohn Marino /* 16586d7f5d3SJohn Marino * These are the PCI vendor and device IDs for Olicom 16686d7f5d3SJohn Marino * adapters based on the ThunderLAN controller. 16786d7f5d3SJohn Marino */ 16886d7f5d3SJohn Marino #define OLICOM_VENDORID 0x108D 16986d7f5d3SJohn Marino #define OLICOM_DEVICEID_OC2183 0x0013 17086d7f5d3SJohn Marino #define OLICOM_DEVICEID_OC2325 0x0012 17186d7f5d3SJohn Marino #define OLICOM_DEVICEID_OC2326 0x0014 17286d7f5d3SJohn Marino 17386d7f5d3SJohn Marino /* 17486d7f5d3SJohn Marino * PCI low memory base and low I/O base 17586d7f5d3SJohn Marino */ 17686d7f5d3SJohn Marino #define TL_PCI_LOIO 0x10 17786d7f5d3SJohn Marino #define TL_PCI_LOMEM 0x14 17886d7f5d3SJohn Marino 17986d7f5d3SJohn Marino /* 18086d7f5d3SJohn Marino * PCI latency timer (it's actually 0x0D, but we want a value 18186d7f5d3SJohn Marino * that's longword aligned). 18286d7f5d3SJohn Marino */ 18386d7f5d3SJohn Marino #define TL_PCI_LATENCY_TIMER 0x0C 18486d7f5d3SJohn Marino 18586d7f5d3SJohn Marino #define TL_DIO_ADDR_INC 0x8000 /* Increment addr on each read */ 18686d7f5d3SJohn Marino #define TL_DIO_RAM_SEL 0x4000 /* RAM address select */ 18786d7f5d3SJohn Marino #define TL_DIO_ADDR_MASK 0x3FFF /* address bits mask */ 18886d7f5d3SJohn Marino 18986d7f5d3SJohn Marino /* 19086d7f5d3SJohn Marino * Interrupt types 19186d7f5d3SJohn Marino */ 19286d7f5d3SJohn Marino #define TL_INTR_INVALID 0x0 19386d7f5d3SJohn Marino #define TL_INTR_TXEOF 0x1 19486d7f5d3SJohn Marino #define TL_INTR_STATOFLOW 0x2 19586d7f5d3SJohn Marino #define TL_INTR_RXEOF 0x3 19686d7f5d3SJohn Marino #define TL_INTR_DUMMY 0x4 19786d7f5d3SJohn Marino #define TL_INTR_TXEOC 0x5 19886d7f5d3SJohn Marino #define TL_INTR_ADCHK 0x6 19986d7f5d3SJohn Marino #define TL_INTR_RXEOC 0x7 20086d7f5d3SJohn Marino 20186d7f5d3SJohn Marino #define TL_INT_MASK 0x001C 20286d7f5d3SJohn Marino #define TL_VEC_MASK 0x1FE0 20386d7f5d3SJohn Marino /* 20486d7f5d3SJohn Marino * Host command register bits 20586d7f5d3SJohn Marino */ 20686d7f5d3SJohn Marino #define TL_CMD_GO 0x80000000 20786d7f5d3SJohn Marino #define TL_CMD_STOP 0x40000000 20886d7f5d3SJohn Marino #define TL_CMD_ACK 0x20000000 20986d7f5d3SJohn Marino #define TL_CMD_CHSEL7 0x10000000 21086d7f5d3SJohn Marino #define TL_CMD_CHSEL6 0x08000000 21186d7f5d3SJohn Marino #define TL_CMD_CHSEL5 0x04000000 21286d7f5d3SJohn Marino #define TL_CMD_CHSEL4 0x02000000 21386d7f5d3SJohn Marino #define TL_CMD_CHSEL3 0x01000000 21486d7f5d3SJohn Marino #define TL_CMD_CHSEL2 0x00800000 21586d7f5d3SJohn Marino #define TL_CMD_CHSEL1 0x00400000 21686d7f5d3SJohn Marino #define TL_CMD_CHSEL0 0x00200000 21786d7f5d3SJohn Marino #define TL_CMD_EOC 0x00100000 21886d7f5d3SJohn Marino #define TL_CMD_RT 0x00080000 21986d7f5d3SJohn Marino #define TL_CMD_NES 0x00040000 22086d7f5d3SJohn Marino #define TL_CMD_ZERO0 0x00020000 22186d7f5d3SJohn Marino #define TL_CMD_ZERO1 0x00010000 22286d7f5d3SJohn Marino #define TL_CMD_ADRST 0x00008000 22386d7f5d3SJohn Marino #define TL_CMD_LDTMR 0x00004000 22486d7f5d3SJohn Marino #define TL_CMD_LDTHR 0x00002000 22586d7f5d3SJohn Marino #define TL_CMD_REQINT 0x00001000 22686d7f5d3SJohn Marino #define TL_CMD_INTSOFF 0x00000800 22786d7f5d3SJohn Marino #define TL_CMD_INTSON 0x00000400 22886d7f5d3SJohn Marino #define TL_CMD_RSVD0 0x00000200 22986d7f5d3SJohn Marino #define TL_CMD_RSVD1 0x00000100 23086d7f5d3SJohn Marino #define TL_CMD_ACK7 0x00000080 23186d7f5d3SJohn Marino #define TL_CMD_ACK6 0x00000040 23286d7f5d3SJohn Marino #define TL_CMD_ACK5 0x00000020 23386d7f5d3SJohn Marino #define TL_CMD_ACK4 0x00000010 23486d7f5d3SJohn Marino #define TL_CMD_ACK3 0x00000008 23586d7f5d3SJohn Marino #define TL_CMD_ACK2 0x00000004 23686d7f5d3SJohn Marino #define TL_CMD_ACK1 0x00000002 23786d7f5d3SJohn Marino #define TL_CMD_ACK0 0x00000001 23886d7f5d3SJohn Marino 23986d7f5d3SJohn Marino #define TL_CMD_CHSEL_MASK 0x01FE0000 24086d7f5d3SJohn Marino #define TL_CMD_ACK_MASK 0xFF 24186d7f5d3SJohn Marino 24286d7f5d3SJohn Marino /* 24386d7f5d3SJohn Marino * EEPROM address where station address resides. 24486d7f5d3SJohn Marino */ 24586d7f5d3SJohn Marino #define TL_EEPROM_EADDR 0x83 24686d7f5d3SJohn Marino #define TL_EEPROM_EADDR2 0x99 24786d7f5d3SJohn Marino #define TL_EEPROM_EADDR3 0xAF 24886d7f5d3SJohn Marino #define TL_EEPROM_EADDR_OC 0xF8 /* Olicom cards use a different 24986d7f5d3SJohn Marino address than Compaqs. */ 25086d7f5d3SJohn Marino /* 25186d7f5d3SJohn Marino * ThunderLAN host command register offsets. 25286d7f5d3SJohn Marino * (Can be accessed either by IO ports or memory map.) 25386d7f5d3SJohn Marino */ 25486d7f5d3SJohn Marino #define TL_HOSTCMD 0x00 25586d7f5d3SJohn Marino #define TL_CH_PARM 0x04 25686d7f5d3SJohn Marino #define TL_DIO_ADDR 0x08 25786d7f5d3SJohn Marino #define TL_HOST_INT 0x0A 25886d7f5d3SJohn Marino #define TL_DIO_DATA 0x0C 25986d7f5d3SJohn Marino 26086d7f5d3SJohn Marino /* 26186d7f5d3SJohn Marino * ThunderLAN internal registers 26286d7f5d3SJohn Marino */ 26386d7f5d3SJohn Marino #define TL_NETCMD 0x00 26486d7f5d3SJohn Marino #define TL_NETSIO 0x01 26586d7f5d3SJohn Marino #define TL_NETSTS 0x02 26686d7f5d3SJohn Marino #define TL_NETMASK 0x03 26786d7f5d3SJohn Marino 26886d7f5d3SJohn Marino #define TL_NETCONFIG 0x04 26986d7f5d3SJohn Marino #define TL_MANTEST 0x06 27086d7f5d3SJohn Marino 27186d7f5d3SJohn Marino #define TL_VENID_LSB 0x08 27286d7f5d3SJohn Marino #define TL_VENID_MSB 0x09 27386d7f5d3SJohn Marino #define TL_DEVID_LSB 0x0A 27486d7f5d3SJohn Marino #define TL_DEVID_MSB 0x0B 27586d7f5d3SJohn Marino 27686d7f5d3SJohn Marino #define TL_REVISION 0x0C 27786d7f5d3SJohn Marino #define TL_SUBCLASS 0x0D 27886d7f5d3SJohn Marino #define TL_MINLAT 0x0E 27986d7f5d3SJohn Marino #define TL_MAXLAT 0x0F 28086d7f5d3SJohn Marino 28186d7f5d3SJohn Marino #define TL_AREG0_B5 0x10 28286d7f5d3SJohn Marino #define TL_AREG0_B4 0x11 28386d7f5d3SJohn Marino #define TL_AREG0_B3 0x12 28486d7f5d3SJohn Marino #define TL_AREG0_B2 0x13 28586d7f5d3SJohn Marino 28686d7f5d3SJohn Marino #define TL_AREG0_B1 0x14 28786d7f5d3SJohn Marino #define TL_AREG0_B0 0x15 28886d7f5d3SJohn Marino #define TL_AREG1_B5 0x16 28986d7f5d3SJohn Marino #define TL_AREG1_B4 0x17 29086d7f5d3SJohn Marino 29186d7f5d3SJohn Marino #define TL_AREG1_B3 0x18 29286d7f5d3SJohn Marino #define TL_AREG1_B2 0x19 29386d7f5d3SJohn Marino #define TL_AREG1_B1 0x1A 29486d7f5d3SJohn Marino #define TL_AREG1_B0 0x1B 29586d7f5d3SJohn Marino 29686d7f5d3SJohn Marino #define TL_AREG2_B5 0x1C 29786d7f5d3SJohn Marino #define TL_AREG2_B4 0x1D 29886d7f5d3SJohn Marino #define TL_AREG2_B3 0x1E 29986d7f5d3SJohn Marino #define TL_AREG2_B2 0x1F 30086d7f5d3SJohn Marino 30186d7f5d3SJohn Marino #define TL_AREG2_B1 0x20 30286d7f5d3SJohn Marino #define TL_AREG2_B0 0x21 30386d7f5d3SJohn Marino #define TL_AREG3_B5 0x22 30486d7f5d3SJohn Marino #define TL_AREG3_B4 0x23 30586d7f5d3SJohn Marino 30686d7f5d3SJohn Marino #define TL_AREG3_B3 0x24 30786d7f5d3SJohn Marino #define TL_AREG3_B2 0x25 30886d7f5d3SJohn Marino #define TL_AREG3_B1 0x26 30986d7f5d3SJohn Marino #define TL_AREG3_B0 0x27 31086d7f5d3SJohn Marino 31186d7f5d3SJohn Marino #define TL_HASH1 0x28 31286d7f5d3SJohn Marino #define TL_HASH2 0x2C 31386d7f5d3SJohn Marino #define TL_TXGOODFRAMES 0x30 31486d7f5d3SJohn Marino #define TL_TXUNDERRUN 0x33 31586d7f5d3SJohn Marino #define TL_RXGOODFRAMES 0x34 31686d7f5d3SJohn Marino #define TL_RXOVERRUN 0x37 31786d7f5d3SJohn Marino #define TL_DEFEREDTX 0x38 31886d7f5d3SJohn Marino #define TL_CRCERROR 0x3A 31986d7f5d3SJohn Marino #define TL_CODEERROR 0x3B 32086d7f5d3SJohn Marino #define TL_MULTICOLTX 0x3C 32186d7f5d3SJohn Marino #define TL_SINGLECOLTX 0x3E 32286d7f5d3SJohn Marino #define TL_EXCESSIVECOL 0x40 32386d7f5d3SJohn Marino #define TL_LATECOL 0x41 32486d7f5d3SJohn Marino #define TL_CARRIERLOSS 0x42 32586d7f5d3SJohn Marino #define TL_ACOMMIT 0x43 32686d7f5d3SJohn Marino #define TL_LDREG 0x44 32786d7f5d3SJohn Marino #define TL_BSIZEREG 0x45 32886d7f5d3SJohn Marino #define TL_MAXRX 0x46 32986d7f5d3SJohn Marino 33086d7f5d3SJohn Marino /* 33186d7f5d3SJohn Marino * ThunderLAN SIO register bits 33286d7f5d3SJohn Marino */ 33386d7f5d3SJohn Marino #define TL_SIO_MINTEN 0x80 33486d7f5d3SJohn Marino #define TL_SIO_ECLOK 0x40 33586d7f5d3SJohn Marino #define TL_SIO_ETXEN 0x20 33686d7f5d3SJohn Marino #define TL_SIO_EDATA 0x10 33786d7f5d3SJohn Marino #define TL_SIO_NMRST 0x08 33886d7f5d3SJohn Marino #define TL_SIO_MCLK 0x04 33986d7f5d3SJohn Marino #define TL_SIO_MTXEN 0x02 34086d7f5d3SJohn Marino #define TL_SIO_MDATA 0x01 34186d7f5d3SJohn Marino 34286d7f5d3SJohn Marino /* 34386d7f5d3SJohn Marino * Thunderlan NETCONFIG bits 34486d7f5d3SJohn Marino */ 34586d7f5d3SJohn Marino #define TL_CFG_RCLKTEST 0x8000 34686d7f5d3SJohn Marino #define TL_CFG_TCLKTEST 0x4000 34786d7f5d3SJohn Marino #define TL_CFG_BITRATE 0x2000 34886d7f5d3SJohn Marino #define TL_CFG_RXCRC 0x1000 34986d7f5d3SJohn Marino #define TL_CFG_PEF 0x0800 35086d7f5d3SJohn Marino #define TL_CFG_ONEFRAG 0x0400 35186d7f5d3SJohn Marino #define TL_CFG_ONECHAN 0x0200 35286d7f5d3SJohn Marino #define TL_CFG_MTEST 0x0100 35386d7f5d3SJohn Marino #define TL_CFG_PHYEN 0x0080 35486d7f5d3SJohn Marino #define TL_CFG_MACSEL6 0x0040 35586d7f5d3SJohn Marino #define TL_CFG_MACSEL5 0x0020 35686d7f5d3SJohn Marino #define TL_CFG_MACSEL4 0x0010 35786d7f5d3SJohn Marino #define TL_CFG_MACSEL3 0x0008 35886d7f5d3SJohn Marino #define TL_CFG_MACSEL2 0x0004 35986d7f5d3SJohn Marino #define TL_CFG_MACSEL1 0x0002 36086d7f5d3SJohn Marino #define TL_CFG_MACSEL0 0x0001 36186d7f5d3SJohn Marino 36286d7f5d3SJohn Marino /* 36386d7f5d3SJohn Marino * ThunderLAN NETSTS bits 36486d7f5d3SJohn Marino */ 36586d7f5d3SJohn Marino #define TL_STS_MIRQ 0x80 36686d7f5d3SJohn Marino #define TL_STS_HBEAT 0x40 36786d7f5d3SJohn Marino #define TL_STS_TXSTOP 0x20 36886d7f5d3SJohn Marino #define TL_STS_RXSTOP 0x10 36986d7f5d3SJohn Marino 37086d7f5d3SJohn Marino /* 37186d7f5d3SJohn Marino * ThunderLAN NETCMD bits 37286d7f5d3SJohn Marino */ 37386d7f5d3SJohn Marino #define TL_CMD_NRESET 0x80 37486d7f5d3SJohn Marino #define TL_CMD_NWRAP 0x40 37586d7f5d3SJohn Marino #define TL_CMD_CSF 0x20 37686d7f5d3SJohn Marino #define TL_CMD_CAF 0x10 37786d7f5d3SJohn Marino #define TL_CMD_NOBRX 0x08 37886d7f5d3SJohn Marino #define TL_CMD_DUPLEX 0x04 37986d7f5d3SJohn Marino #define TL_CMD_TRFRAM 0x02 38086d7f5d3SJohn Marino #define TL_CMD_TXPACE 0x01 38186d7f5d3SJohn Marino 38286d7f5d3SJohn Marino /* 38386d7f5d3SJohn Marino * ThunderLAN NETMASK bits 38486d7f5d3SJohn Marino */ 38586d7f5d3SJohn Marino #define TL_MASK_MASK7 0x80 38686d7f5d3SJohn Marino #define TL_MASK_MASK6 0x40 38786d7f5d3SJohn Marino #define TL_MASK_MASK5 0x20 38886d7f5d3SJohn Marino #define TL_MASK_MASK4 0x10 38986d7f5d3SJohn Marino 39086d7f5d3SJohn Marino /* 39186d7f5d3SJohn Marino * MII frame format 39286d7f5d3SJohn Marino */ 39386d7f5d3SJohn Marino #ifdef ANSI_DOESNT_ALLOW_BITFIELDS 39486d7f5d3SJohn Marino struct tl_mii_frame { 39586d7f5d3SJohn Marino u_int16_t mii_stdelim:2, 39686d7f5d3SJohn Marino mii_opcode:2, 39786d7f5d3SJohn Marino mii_phyaddr:5, 39886d7f5d3SJohn Marino mii_regaddr:5, 39986d7f5d3SJohn Marino mii_turnaround:2; 40086d7f5d3SJohn Marino u_int16_t mii_data; 40186d7f5d3SJohn Marino }; 40286d7f5d3SJohn Marino #else 40386d7f5d3SJohn Marino struct tl_mii_frame { 40486d7f5d3SJohn Marino u_int8_t mii_stdelim; 40586d7f5d3SJohn Marino u_int8_t mii_opcode; 40686d7f5d3SJohn Marino u_int8_t mii_phyaddr; 40786d7f5d3SJohn Marino u_int8_t mii_regaddr; 40886d7f5d3SJohn Marino u_int8_t mii_turnaround; 40986d7f5d3SJohn Marino u_int16_t mii_data; 41086d7f5d3SJohn Marino }; 41186d7f5d3SJohn Marino #endif 41286d7f5d3SJohn Marino /* 41386d7f5d3SJohn Marino * MII constants 41486d7f5d3SJohn Marino */ 41586d7f5d3SJohn Marino #define TL_MII_STARTDELIM 0x01 41686d7f5d3SJohn Marino #define TL_MII_READOP 0x02 41786d7f5d3SJohn Marino #define TL_MII_WRITEOP 0x01 41886d7f5d3SJohn Marino #define TL_MII_TURNAROUND 0x02 41986d7f5d3SJohn Marino 42086d7f5d3SJohn Marino #define TL_LAST_FRAG 0x80000000 42186d7f5d3SJohn Marino #define TL_CSTAT_UNUSED 0x8000 42286d7f5d3SJohn Marino #define TL_CSTAT_FRAMECMP 0x4000 42386d7f5d3SJohn Marino #define TL_CSTAT_READY 0x3000 42486d7f5d3SJohn Marino #define TL_CSTAT_UNUSED13 0x2000 42586d7f5d3SJohn Marino #define TL_CSTAT_UNUSED12 0x1000 42686d7f5d3SJohn Marino #define TL_CSTAT_EOC 0x0800 42786d7f5d3SJohn Marino #define TL_CSTAT_RXERROR 0x0400 42886d7f5d3SJohn Marino #define TL_CSTAT_PASSCRC 0x0200 42986d7f5d3SJohn Marino #define TL_CSTAT_DPRIO 0x0100 43086d7f5d3SJohn Marino 43186d7f5d3SJohn Marino #define TL_FRAME_MASK 0x00FFFFFF 43286d7f5d3SJohn Marino #define tl_tx_goodframes(x) (x.tl_txstat & TL_FRAME_MASK) 43386d7f5d3SJohn Marino #define tl_tx_underrun(x) ((x.tl_txstat & ~TL_FRAME_MASK) >> 24) 43486d7f5d3SJohn Marino #define tl_rx_goodframes(x) (x.tl_rxstat & TL_FRAME_MASK) 43586d7f5d3SJohn Marino #define tl_rx_overrun(x) ((x.tl_rxstat & ~TL_FRAME_MASK) >> 24) 43686d7f5d3SJohn Marino 43786d7f5d3SJohn Marino struct tl_stats { 43886d7f5d3SJohn Marino u_int32_t tl_txstat; 43986d7f5d3SJohn Marino u_int32_t tl_rxstat; 44086d7f5d3SJohn Marino u_int16_t tl_deferred; 44186d7f5d3SJohn Marino u_int8_t tl_crc_errors; 44286d7f5d3SJohn Marino u_int8_t tl_code_errors; 44386d7f5d3SJohn Marino u_int16_t tl_tx_multi_collision; 44486d7f5d3SJohn Marino u_int16_t tl_tx_single_collision; 44586d7f5d3SJohn Marino u_int8_t tl_excessive_collision; 44686d7f5d3SJohn Marino u_int8_t tl_late_collision; 44786d7f5d3SJohn Marino u_int8_t tl_carrier_loss; 44886d7f5d3SJohn Marino u_int8_t acommit; 44986d7f5d3SJohn Marino }; 45086d7f5d3SJohn Marino 45186d7f5d3SJohn Marino /* 45286d7f5d3SJohn Marino * ACOMMIT register bits. These are used only when a bitrate 45386d7f5d3SJohn Marino * PHY is selected ('bitrate' bit in netconfig register is set). 45486d7f5d3SJohn Marino */ 45586d7f5d3SJohn Marino #define TL_AC_MTXER 0x01 /* reserved */ 45686d7f5d3SJohn Marino #define TL_AC_MTXD1 0x02 /* 0 == 10baseT 1 == AUI */ 45786d7f5d3SJohn Marino #define TL_AC_MTXD2 0x04 /* loopback disable */ 45886d7f5d3SJohn Marino #define TL_AC_MTXD3 0x08 /* full duplex disable */ 45986d7f5d3SJohn Marino 46086d7f5d3SJohn Marino #define TL_AC_TXTHRESH 0xF0 46186d7f5d3SJohn Marino #define TL_AC_TXTHRESH_16LONG 0x00 46286d7f5d3SJohn Marino #define TL_AC_TXTHRESH_32LONG 0x10 46386d7f5d3SJohn Marino #define TL_AC_TXTHRESH_64LONG 0x20 46486d7f5d3SJohn Marino #define TL_AC_TXTHRESH_128LONG 0x30 46586d7f5d3SJohn Marino #define TL_AC_TXTHRESH_256LONG 0x40 46686d7f5d3SJohn Marino #define TL_AC_TXTHRESH_WHOLEPKT 0x50 46786d7f5d3SJohn Marino 46886d7f5d3SJohn Marino /* 46986d7f5d3SJohn Marino * PCI burst size register (TL_BSIZEREG). 47086d7f5d3SJohn Marino */ 47186d7f5d3SJohn Marino #define TL_RXBURST 0x0F 47286d7f5d3SJohn Marino #define TL_TXBURST 0xF0 47386d7f5d3SJohn Marino 47486d7f5d3SJohn Marino #define TL_RXBURST_4LONG 0x00 47586d7f5d3SJohn Marino #define TL_RXBURST_8LONG 0x01 47686d7f5d3SJohn Marino #define TL_RXBURST_16LONG 0x02 47786d7f5d3SJohn Marino #define TL_RXBURST_32LONG 0x03 47886d7f5d3SJohn Marino #define TL_RXBURST_64LONG 0x04 47986d7f5d3SJohn Marino #define TL_RXBURST_128LONG 0x05 48086d7f5d3SJohn Marino 48186d7f5d3SJohn Marino #define TL_TXBURST_4LONG 0x00 48286d7f5d3SJohn Marino #define TL_TXBURST_8LONG 0x10 48386d7f5d3SJohn Marino #define TL_TXBURST_16LONG 0x20 48486d7f5d3SJohn Marino #define TL_TXBURST_32LONG 0x30 48586d7f5d3SJohn Marino #define TL_TXBURST_64LONG 0x40 48686d7f5d3SJohn Marino #define TL_TXBURST_128LONG 0x50 48786d7f5d3SJohn Marino 48886d7f5d3SJohn Marino /* 48986d7f5d3SJohn Marino * register space access macros 49086d7f5d3SJohn Marino */ 49186d7f5d3SJohn Marino #define CSR_WRITE_4(sc, reg, val) \ 49286d7f5d3SJohn Marino bus_space_write_4(sc->tl_btag, sc->tl_bhandle, reg, val) 49386d7f5d3SJohn Marino #define CSR_WRITE_2(sc, reg, val) \ 49486d7f5d3SJohn Marino bus_space_write_2(sc->tl_btag, sc->tl_bhandle, reg, val) 49586d7f5d3SJohn Marino #define CSR_WRITE_1(sc, reg, val) \ 49686d7f5d3SJohn Marino bus_space_write_1(sc->tl_btag, sc->tl_bhandle, reg, val) 49786d7f5d3SJohn Marino 49886d7f5d3SJohn Marino #define CSR_READ_4(sc, reg) \ 49986d7f5d3SJohn Marino bus_space_read_4(sc->tl_btag, sc->tl_bhandle, reg) 50086d7f5d3SJohn Marino #define CSR_READ_2(sc, reg) \ 50186d7f5d3SJohn Marino bus_space_read_2(sc->tl_btag, sc->tl_bhandle, reg) 50286d7f5d3SJohn Marino #define CSR_READ_1(sc, reg) \ 50386d7f5d3SJohn Marino bus_space_read_1(sc->tl_btag, sc->tl_bhandle, reg) 50486d7f5d3SJohn Marino 50586d7f5d3SJohn Marino #define CMD_PUT(sc, x) CSR_WRITE_4(sc, TL_HOSTCMD, x) 50686d7f5d3SJohn Marino #define CMD_SET(sc, x) \ 50786d7f5d3SJohn Marino CSR_WRITE_4(sc, TL_HOSTCMD, CSR_READ_4(sc, TL_HOSTCMD) | (x)) 50886d7f5d3SJohn Marino #define CMD_CLR(sc, x) \ 50986d7f5d3SJohn Marino CSR_WRITE_4(sc, TL_HOSTCMD, CSR_READ_4(sc, TL_HOSTCMD) & ~(x)) 51086d7f5d3SJohn Marino 51186d7f5d3SJohn Marino /* 51286d7f5d3SJohn Marino * ThunderLAN adapters typically have a serial EEPROM containing 51386d7f5d3SJohn Marino * configuration information. The main reason we're interested in 51486d7f5d3SJohn Marino * it is because it also contains the adapters's station address. 51586d7f5d3SJohn Marino * 51686d7f5d3SJohn Marino * Access to the EEPROM is a bit goofy since it is a serial device: 51786d7f5d3SJohn Marino * you have to do reads and writes one bit at a time. The state of 51886d7f5d3SJohn Marino * the DATA bit can only change while the CLOCK line is held low. 51986d7f5d3SJohn Marino * Transactions work basically like this: 52086d7f5d3SJohn Marino * 52186d7f5d3SJohn Marino * 1) Send the EEPROM_START sequence to prepare the EEPROM for 52286d7f5d3SJohn Marino * accepting commands. This pulls the clock high, sets 52386d7f5d3SJohn Marino * the data bit to 0, enables transmission to the EEPROM, 52486d7f5d3SJohn Marino * pulls the data bit up to 1, then pulls the clock low. 52586d7f5d3SJohn Marino * The idea is to do a 0 to 1 transition of the data bit 52686d7f5d3SJohn Marino * while the clock pin is held high. 52786d7f5d3SJohn Marino * 52886d7f5d3SJohn Marino * 2) To write a bit to the EEPROM, set the TXENABLE bit, then 52986d7f5d3SJohn Marino * set the EDATA bit to send a 1 or clear it to send a 0. 53086d7f5d3SJohn Marino * Finally, set and then clear ECLOK. Strobing the clock 53186d7f5d3SJohn Marino * transmits the bit. After 8 bits have been written, the 53286d7f5d3SJohn Marino * EEPROM should respond with an ACK, which should be read. 53386d7f5d3SJohn Marino * 53486d7f5d3SJohn Marino * 3) To read a bit from the EEPROM, clear the TXENABLE bit, 53586d7f5d3SJohn Marino * then set ECLOK. The bit can then be read by reading EDATA. 53686d7f5d3SJohn Marino * ECLOCK should then be cleared again. This can be repeated 53786d7f5d3SJohn Marino * 8 times to read a whole byte, after which the 53886d7f5d3SJohn Marino * 53986d7f5d3SJohn Marino * 4) We need to send the address byte to the EEPROM. For this 54086d7f5d3SJohn Marino * we have to send the write control byte to the EEPROM to 54186d7f5d3SJohn Marino * tell it to accept data. The byte is 0xA0. The EEPROM should 54286d7f5d3SJohn Marino * ack this. The address byte can be send after that. 54386d7f5d3SJohn Marino * 54486d7f5d3SJohn Marino * 5) Now we have to tell the EEPROM to send us data. For that we 54586d7f5d3SJohn Marino * have to transmit the read control byte, which is 0xA1. This 54686d7f5d3SJohn Marino * byte should also be acked. We can then read the data bits 54786d7f5d3SJohn Marino * from the EEPROM. 54886d7f5d3SJohn Marino * 54986d7f5d3SJohn Marino * 6) When we're all finished, send the EEPROM_STOP sequence. 55086d7f5d3SJohn Marino * 55186d7f5d3SJohn Marino * Note that we use the ThunderLAN's NetSio register to access the 55286d7f5d3SJohn Marino * EEPROM, however there is an alternate method. There is a PCI NVRAM 55386d7f5d3SJohn Marino * register at PCI offset 0xB4 which can also be used with minor changes. 55486d7f5d3SJohn Marino * The difference is that access to PCI registers via pci_conf_read() 55586d7f5d3SJohn Marino * and pci_conf_write() is done using programmed I/O, which we want to 55686d7f5d3SJohn Marino * avoid. 55786d7f5d3SJohn Marino */ 55886d7f5d3SJohn Marino 55986d7f5d3SJohn Marino /* 56086d7f5d3SJohn Marino * Note that EEPROM_START leaves transmission enabled. 56186d7f5d3SJohn Marino */ 56286d7f5d3SJohn Marino #define EEPROM_START \ 56386d7f5d3SJohn Marino tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ECLOK); /* Pull clock pin high */\ 56486d7f5d3SJohn Marino tl_dio_setbit(sc, TL_NETSIO, TL_SIO_EDATA); /* Set DATA bit to 1 */ \ 56586d7f5d3SJohn Marino tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ETXEN); /* Enable xmit to write bit */\ 56686d7f5d3SJohn Marino tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_EDATA); /* Pull DATA bit to 0 again */\ 56786d7f5d3SJohn Marino tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ECLOK); /* Pull clock low again */ 56886d7f5d3SJohn Marino 56986d7f5d3SJohn Marino /* 57086d7f5d3SJohn Marino * EEPROM_STOP ends access to the EEPROM and clears the ETXEN bit so 57186d7f5d3SJohn Marino * that no further data can be written to the EEPROM I/O pin. 57286d7f5d3SJohn Marino */ 57386d7f5d3SJohn Marino #define EEPROM_STOP \ 57486d7f5d3SJohn Marino tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ETXEN); /* Disable xmit */ \ 57586d7f5d3SJohn Marino tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_EDATA); /* Pull DATA to 0 */ \ 57686d7f5d3SJohn Marino tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ECLOK); /* Pull clock high */ \ 57786d7f5d3SJohn Marino tl_dio_setbit(sc, TL_NETSIO, TL_SIO_ETXEN); /* Enable xmit */ \ 57886d7f5d3SJohn Marino tl_dio_setbit(sc, TL_NETSIO, TL_SIO_EDATA); /* Toggle DATA to 1 */ \ 57986d7f5d3SJohn Marino tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ETXEN); /* Disable xmit. */ \ 58086d7f5d3SJohn Marino tl_dio_clrbit(sc, TL_NETSIO, TL_SIO_ECLOK); /* Pull clock low again */ 58186d7f5d3SJohn Marino 58286d7f5d3SJohn Marino 58386d7f5d3SJohn Marino /* 58486d7f5d3SJohn Marino * Microchip Technology 24Cxx EEPROM control bytes 58586d7f5d3SJohn Marino */ 58686d7f5d3SJohn Marino #define EEPROM_CTL_READ 0xA1 /* 0101 0001 */ 58786d7f5d3SJohn Marino #define EEPROM_CTL_WRITE 0xA0 /* 0101 0000 */ 588