1c8befdd5SWarner Losh /*- 2df57947fSPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 3df57947fSPedro F. Giffuni * 4c8befdd5SWarner Losh * Copyright (c) 1997, 1998, 1999 5c8befdd5SWarner Losh * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 6c8befdd5SWarner Losh * 7c8befdd5SWarner Losh * Redistribution and use in source and binary forms, with or without 8c8befdd5SWarner Losh * modification, are permitted provided that the following conditions 9c8befdd5SWarner Losh * are met: 10c8befdd5SWarner Losh * 1. Redistributions of source code must retain the above copyright 11c8befdd5SWarner Losh * notice, this list of conditions and the following disclaimer. 12c8befdd5SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 13c8befdd5SWarner Losh * notice, this list of conditions and the following disclaimer in the 14c8befdd5SWarner Losh * documentation and/or other materials provided with the distribution. 15c8befdd5SWarner Losh * 3. All advertising materials mentioning features or use of this software 16c8befdd5SWarner Losh * must display the following acknowledgement: 17c8befdd5SWarner Losh * This product includes software developed by Bill Paul. 18c8befdd5SWarner Losh * 4. Neither the name of the author nor the names of any co-contributors 19c8befdd5SWarner Losh * may be used to endorse or promote products derived from this software 20c8befdd5SWarner Losh * without specific prior written permission. 21c8befdd5SWarner Losh * 22c8befdd5SWarner Losh * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 23c8befdd5SWarner Losh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24c8befdd5SWarner Losh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25c8befdd5SWarner Losh * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 26c8befdd5SWarner Losh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27c8befdd5SWarner Losh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28c8befdd5SWarner Losh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29c8befdd5SWarner Losh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30c8befdd5SWarner Losh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31c8befdd5SWarner Losh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32c8befdd5SWarner Losh * THE POSSIBILITY OF SUCH DAMAGE. 33c8befdd5SWarner Losh */ 34c8befdd5SWarner Losh 35c8befdd5SWarner Losh /* 36c8befdd5SWarner Losh * Sundance PCI device/vendor ID for the 37c8befdd5SWarner Losh * ST201 chip. 38c8befdd5SWarner Losh */ 39c8befdd5SWarner Losh #define ST_VENDORID 0x13F0 40c8befdd5SWarner Losh #define ST_DEVICEID_ST201_1 0x0200 41c8befdd5SWarner Losh #define ST_DEVICEID_ST201_2 0x0201 42c8befdd5SWarner Losh 43c8befdd5SWarner Losh /* 44c8befdd5SWarner Losh * D-Link PCI device/vendor ID for the DL10050[AB] chip 45c8befdd5SWarner Losh */ 46c8befdd5SWarner Losh #define DL_VENDORID 0x1186 47c8befdd5SWarner Losh #define DL_DEVICEID_DL10050 0x1002 48c8befdd5SWarner Losh 49c8befdd5SWarner Losh /* 50c8befdd5SWarner Losh * Register definitions for the Sundance Technologies ST201 PCI 51c8befdd5SWarner Losh * fast ethernet controller. The register space is 128 bytes long and 52c8befdd5SWarner Losh * can be accessed using either PCI I/O space or PCI memory mapping. 53c8befdd5SWarner Losh * There are 32-bit, 16-bit and 8-bit registers. 54c8befdd5SWarner Losh */ 55c8befdd5SWarner Losh 56c8befdd5SWarner Losh #define STE_DMACTL 0x00 57c8befdd5SWarner Losh #define STE_TX_DMALIST_PTR 0x04 58c8befdd5SWarner Losh #define STE_TX_DMABURST_THRESH 0x08 59c8befdd5SWarner Losh #define STE_TX_DMAURG_THRESH 0x09 60c8befdd5SWarner Losh #define STE_TX_DMAPOLL_PERIOD 0x0A 61c8befdd5SWarner Losh #define STE_RX_DMASTATUS 0x0C 62c8befdd5SWarner Losh #define STE_RX_DMALIST_PTR 0x10 63c8befdd5SWarner Losh #define STE_RX_DMABURST_THRESH 0x14 64c8befdd5SWarner Losh #define STE_RX_DMAURG_THRESH 0x15 65c8befdd5SWarner Losh #define STE_RX_DMAPOLL_PERIOD 0x16 6695a3c23bSPyun YongHyeon #define STE_COUNTDOWN 0x18 67c8befdd5SWarner Losh #define STE_DEBUGCTL 0x1A 68c8befdd5SWarner Losh #define STE_ASICCTL 0x30 69c8befdd5SWarner Losh #define STE_EEPROM_DATA 0x34 70c8befdd5SWarner Losh #define STE_EEPROM_CTL 0x36 71c8befdd5SWarner Losh #define STE_FIFOCTL 0x3A 72c8befdd5SWarner Losh #define STE_TX_STARTTHRESH 0x3C 73c8befdd5SWarner Losh #define STE_RX_EARLYTHRESH 0x3E 74c8befdd5SWarner Losh #define STE_EXT_ROMADDR 0x40 75c8befdd5SWarner Losh #define STE_EXT_ROMDATA 0x44 76c8befdd5SWarner Losh #define STE_WAKE_EVENT 0x45 77c8befdd5SWarner Losh #define STE_TX_STATUS 0x46 78c8befdd5SWarner Losh #define STE_TX_FRAMEID 0x47 79c8befdd5SWarner Losh #define STE_ISR_ACK 0x4A 80c8befdd5SWarner Losh #define STE_IMR 0x4C 81c8befdd5SWarner Losh #define STE_ISR 0x4E 82c8befdd5SWarner Losh #define STE_MACCTL0 0x50 83c8befdd5SWarner Losh #define STE_MACCTL1 0x52 84c8befdd5SWarner Losh #define STE_PAR0 0x54 85c8befdd5SWarner Losh #define STE_PAR1 0x56 86c8befdd5SWarner Losh #define STE_PAR2 0x58 87c8befdd5SWarner Losh #define STE_MAX_FRAMELEN 0x5A 88c8befdd5SWarner Losh #define STE_RX_MODE 0x5C 89c8befdd5SWarner Losh #define STE_TX_RECLAIM_THRESH 0x5D 90c8befdd5SWarner Losh #define STE_PHYCTL 0x5E 91c8befdd5SWarner Losh #define STE_MAR0 0x60 92c8befdd5SWarner Losh #define STE_MAR1 0x62 93c8befdd5SWarner Losh #define STE_MAR2 0x64 94c8befdd5SWarner Losh #define STE_MAR3 0x66 95c8befdd5SWarner Losh 968657caa6SPyun YongHyeon #define STE_STAT_RX_OCTETS_LO 0x68 978657caa6SPyun YongHyeon #define STE_STAT_RX_OCTETS_HI 0x6A 988657caa6SPyun YongHyeon #define STE_STAT_TX_OCTETS_LO 0x6C 998657caa6SPyun YongHyeon #define STE_STAT_TX_OCTETS_HI 0x6E 1008657caa6SPyun YongHyeon #define STE_STAT_TX_FRAMES 0x70 1018657caa6SPyun YongHyeon #define STE_STAT_RX_FRAMES 0x72 1028657caa6SPyun YongHyeon #define STE_STAT_CARRIER_ERR 0x74 1038657caa6SPyun YongHyeon #define STE_STAT_LATE_COLLS 0x75 1048657caa6SPyun YongHyeon #define STE_STAT_MULTI_COLLS 0x76 1058657caa6SPyun YongHyeon #define STE_STAT_SINGLE_COLLS 0x77 1068657caa6SPyun YongHyeon #define STE_STAT_TX_DEFER 0x78 1078657caa6SPyun YongHyeon #define STE_STAT_RX_LOST 0x79 1088657caa6SPyun YongHyeon #define STE_STAT_TX_EXDEFER 0x7A 1098657caa6SPyun YongHyeon #define STE_STAT_TX_ABORT 0x7B 1108657caa6SPyun YongHyeon #define STE_STAT_TX_BCAST 0x7C 1118657caa6SPyun YongHyeon #define STE_STAT_RX_BCAST 0x7D 1128657caa6SPyun YongHyeon #define STE_STAT_TX_MCAST 0x7E 1138657caa6SPyun YongHyeon #define STE_STAT_RX_MCAST 0x7F 114c8befdd5SWarner Losh 115c8befdd5SWarner Losh #define STE_DMACTL_RXDMA_STOPPED 0x00000001 116c8befdd5SWarner Losh #define STE_DMACTL_TXDMA_CMPREQ 0x00000002 117c8befdd5SWarner Losh #define STE_DMACTL_TXDMA_STOPPED 0x00000004 118c8befdd5SWarner Losh #define STE_DMACTL_RXDMA_COMPLETE 0x00000008 119c8befdd5SWarner Losh #define STE_DMACTL_TXDMA_COMPLETE 0x00000010 120c8befdd5SWarner Losh #define STE_DMACTL_RXDMA_STALL 0x00000100 121c8befdd5SWarner Losh #define STE_DMACTL_RXDMA_UNSTALL 0x00000200 122c8befdd5SWarner Losh #define STE_DMACTL_TXDMA_STALL 0x00000400 123c8befdd5SWarner Losh #define STE_DMACTL_TXDMA_UNSTALL 0x00000800 124c8befdd5SWarner Losh #define STE_DMACTL_TXDMA_INPROG 0x00004000 125c8befdd5SWarner Losh #define STE_DMACTL_DMA_HALTINPROG 0x00008000 126c8befdd5SWarner Losh #define STE_DMACTL_RXEARLY_ENABLE 0x00020000 127c8befdd5SWarner Losh #define STE_DMACTL_COUNTDOWN_SPEED 0x00040000 128c8befdd5SWarner Losh #define STE_DMACTL_COUNTDOWN_MODE 0x00080000 129c8befdd5SWarner Losh #define STE_DMACTL_MWI_DISABLE 0x00100000 130c8befdd5SWarner Losh #define STE_DMACTL_RX_DISCARD_OFLOWS 0x00400000 131c8befdd5SWarner Losh #define STE_DMACTL_COUNTDOWN_ENABLE 0x00800000 132c8befdd5SWarner Losh #define STE_DMACTL_TARGET_ABORT 0x40000000 133c8befdd5SWarner Losh #define STE_DMACTL_MASTER_ABORT 0x80000000 134c8befdd5SWarner Losh 135c8befdd5SWarner Losh /* 136c8befdd5SWarner Losh * TX DMA burst thresh is the number of 32-byte blocks that 137c8befdd5SWarner Losh * must be loaded into the TX Fifo before a TXDMA burst request 138c8befdd5SWarner Losh * will be issued. 139c8befdd5SWarner Losh */ 140c8befdd5SWarner Losh #define STE_TXDMABURST_THRESH 0x1F 141c8befdd5SWarner Losh 142c8befdd5SWarner Losh /* 143c8befdd5SWarner Losh * The number of 32-byte blocks in the TX FIFO falls below the 144c8befdd5SWarner Losh * TX DMA urgent threshold, a TX DMA urgent request will be 145c8befdd5SWarner Losh * generated. 146c8befdd5SWarner Losh */ 147c8befdd5SWarner Losh #define STE_TXDMAURG_THRESH 0x3F 148c8befdd5SWarner Losh 149c8befdd5SWarner Losh /* 150c8befdd5SWarner Losh * Number of 320ns intervals between polls of the TXDMA next 151c8befdd5SWarner Losh * descriptor pointer (if we're using polling mode). 152c8befdd5SWarner Losh */ 153c8befdd5SWarner Losh #define STE_TXDMA_POLL_PERIOD 0x7F 154c8befdd5SWarner Losh 155c8befdd5SWarner Losh #define STE_RX_DMASTATUS_FRAMELEN 0x00001FFF 156c8befdd5SWarner Losh #define STE_RX_DMASTATUS_RXERR 0x00004000 157c8befdd5SWarner Losh #define STE_RX_DMASTATUS_DMADONE 0x00008000 158c8befdd5SWarner Losh #define STE_RX_DMASTATUS_FIFO_OFLOW 0x00010000 159c8befdd5SWarner Losh #define STE_RX_DMASTATUS_RUNT 0x00020000 160c8befdd5SWarner Losh #define STE_RX_DMASTATUS_ALIGNERR 0x00040000 161c8befdd5SWarner Losh #define STE_RX_DMASTATUS_CRCERR 0x00080000 162c8befdd5SWarner Losh #define STE_RX_DMASTATUS_GIANT 0x00100000 163c8befdd5SWarner Losh #define STE_RX_DMASTATUS_DRIBBLE 0x00800000 164c8befdd5SWarner Losh #define STE_RX_DMASTATUS_DMA_OFLOW 0x01000000 165c8befdd5SWarner Losh 166c8befdd5SWarner Losh /* 167c8befdd5SWarner Losh * RX DMA burst thresh is the number of 32-byte blocks that 168c8befdd5SWarner Losh * must be present in the RX FIFO before a RXDMA bus master 169c8befdd5SWarner Losh * request will be issued. 170c8befdd5SWarner Losh */ 171c8befdd5SWarner Losh #define STE_RXDMABURST_THRESH 0xFF 172c8befdd5SWarner Losh 173c8befdd5SWarner Losh /* 174c8befdd5SWarner Losh * The number of 32-byte blocks in the RX FIFO falls below the 175c8befdd5SWarner Losh * RX DMA urgent threshold, a RX DMA urgent request will be 176c8befdd5SWarner Losh * generated. 177c8befdd5SWarner Losh */ 178c8befdd5SWarner Losh #define STE_RXDMAURG_THRESH 0x1F 179c8befdd5SWarner Losh 180c8befdd5SWarner Losh /* 181c8befdd5SWarner Losh * Number of 320ns intervals between polls of the RXDMA complete 182c8befdd5SWarner Losh * bit in the status field on the current RX descriptor (if we're 183c8befdd5SWarner Losh * using polling mode). 184c8befdd5SWarner Losh */ 185c8befdd5SWarner Losh #define STE_RXDMA_POLL_PERIOD 0x7F 186c8befdd5SWarner Losh 187c8befdd5SWarner Losh #define STE_DEBUGCTL_GPIO0_CTL 0x0001 188c8befdd5SWarner Losh #define STE_DEBUGCTL_GPIO1_CTL 0x0002 189c8befdd5SWarner Losh #define STE_DEBUGCTL_GPIO0_DATA 0x0004 190c8befdd5SWarner Losh #define STE_DEBUGCTL_GPIO1_DATA 0x0008 191c8befdd5SWarner Losh 192c8befdd5SWarner Losh #define STE_ASICCTL_ROMSIZE 0x00000002 193c8befdd5SWarner Losh #define STE_ASICCTL_TX_LARGEPKTS 0x00000004 194c8befdd5SWarner Losh #define STE_ASICCTL_RX_LARGEPKTS 0x00000008 195c8befdd5SWarner Losh #define STE_ASICCTL_EXTROM_DISABLE 0x00000010 196c8befdd5SWarner Losh #define STE_ASICCTL_PHYSPEED_10 0x00000020 197c8befdd5SWarner Losh #define STE_ASICCTL_PHYSPEED_100 0x00000040 198c8befdd5SWarner Losh #define STE_ASICCTL_PHYMEDIA 0x00000080 199c8befdd5SWarner Losh #define STE_ASICCTL_FORCEDCONFIG 0x00000700 200c8befdd5SWarner Losh #define STE_ASICCTL_D3RESET_DISABLE 0x00000800 201c8befdd5SWarner Losh #define STE_ASICCTL_SPEEDUPMODE 0x00002000 202c8befdd5SWarner Losh #define STE_ASICCTL_LEDMODE 0x00004000 203c8befdd5SWarner Losh #define STE_ASICCTL_RSTOUT_POLARITY 0x00008000 204c8befdd5SWarner Losh #define STE_ASICCTL_GLOBAL_RESET 0x00010000 205c8befdd5SWarner Losh #define STE_ASICCTL_RX_RESET 0x00020000 206c8befdd5SWarner Losh #define STE_ASICCTL_TX_RESET 0x00040000 207c8befdd5SWarner Losh #define STE_ASICCTL_DMA_RESET 0x00080000 208c8befdd5SWarner Losh #define STE_ASICCTL_FIFO_RESET 0x00100000 209c8befdd5SWarner Losh #define STE_ASICCTL_NETWORK_RESET 0x00200000 210c8befdd5SWarner Losh #define STE_ASICCTL_HOST_RESET 0x00400000 211c8befdd5SWarner Losh #define STE_ASICCTL_AUTOINIT_RESET 0x00800000 212c8befdd5SWarner Losh #define STE_ASICCTL_EXTRESET_RESET 0x01000000 213c8befdd5SWarner Losh #define STE_ASICCTL_SOFTINTR 0x02000000 214c8befdd5SWarner Losh #define STE_ASICCTL_RESET_BUSY 0x04000000 215c8befdd5SWarner Losh 216c8befdd5SWarner Losh #define STE_EECTL_ADDR 0x00FF 217c8befdd5SWarner Losh #define STE_EECTL_OPCODE 0x0300 218c8befdd5SWarner Losh #define STE_EECTL_BUSY 0x1000 219c8befdd5SWarner Losh 220c8befdd5SWarner Losh #define STE_EEOPCODE_WRITE 0x0100 221c8befdd5SWarner Losh #define STE_EEOPCODE_READ 0x0200 222c8befdd5SWarner Losh #define STE_EEOPCODE_ERASE 0x0300 223c8befdd5SWarner Losh 224c8befdd5SWarner Losh #define STE_FIFOCTL_RAMTESTMODE 0x0001 225c8befdd5SWarner Losh #define STE_FIFOCTL_OVERRUNMODE 0x0200 226c8befdd5SWarner Losh #define STE_FIFOCTL_RXFIFOFULL 0x0800 227c8befdd5SWarner Losh #define STE_FIFOCTL_TX_BUSY 0x4000 228c8befdd5SWarner Losh #define STE_FIFOCTL_RX_BUSY 0x8000 229c8befdd5SWarner Losh 230c8befdd5SWarner Losh /* 231c8befdd5SWarner Losh * The number of bytes that must in present in the TX FIFO before 232c8befdd5SWarner Losh * transmission begins. Value should be in increments of 4 bytes. 233c8befdd5SWarner Losh */ 234c8befdd5SWarner Losh #define STE_TXSTART_THRESH 0x1FFC 235c8befdd5SWarner Losh 236c8befdd5SWarner Losh /* 237c8befdd5SWarner Losh * Number of bytes that must be present in the RX FIFO before 238c8befdd5SWarner Losh * an RX EARLY interrupt is generated. 239c8befdd5SWarner Losh */ 240c8befdd5SWarner Losh #define STE_RXEARLY_THRESH 0x1FFC 241c8befdd5SWarner Losh 242c8befdd5SWarner Losh #define STE_WAKEEVENT_WAKEPKT_ENB 0x01 243c8befdd5SWarner Losh #define STE_WAKEEVENT_MAGICPKT_ENB 0x02 244c8befdd5SWarner Losh #define STE_WAKEEVENT_LINKEVT_ENB 0x04 245c8befdd5SWarner Losh #define STE_WAKEEVENT_WAKEPOLARITY 0x08 246c8befdd5SWarner Losh #define STE_WAKEEVENT_WAKEPKTEVENT 0x10 247c8befdd5SWarner Losh #define STE_WAKEEVENT_MAGICPKTEVENT 0x20 248c8befdd5SWarner Losh #define STE_WAKEEVENT_LINKEVENT 0x40 249c8befdd5SWarner Losh #define STE_WAKEEVENT_WAKEONLAN_ENB 0x80 250c8befdd5SWarner Losh 251c8befdd5SWarner Losh #define STE_TXSTATUS_RECLAIMERR 0x02 252c8befdd5SWarner Losh #define STE_TXSTATUS_STATSOFLOW 0x04 253c8befdd5SWarner Losh #define STE_TXSTATUS_EXCESSCOLLS 0x08 254c8befdd5SWarner Losh #define STE_TXSTATUS_UNDERRUN 0x10 255c8befdd5SWarner Losh #define STE_TXSTATUS_TXINTR_REQ 0x40 256c8befdd5SWarner Losh #define STE_TXSTATUS_TXDONE 0x80 257c8befdd5SWarner Losh 25881598b3eSPyun YongHyeon #define STE_ERR_BITS "\20" \ 25981598b3eSPyun YongHyeon "\2RECLAIM\3STSOFLOW" \ 26081598b3eSPyun YongHyeon "\4EXCESSCOLLS\5UNDERRUN" \ 26181598b3eSPyun YongHyeon "\6INTREQ\7DONE" 26281598b3eSPyun YongHyeon 263c8befdd5SWarner Losh #define STE_ISRACK_INTLATCH 0x0001 264c8befdd5SWarner Losh #define STE_ISRACK_HOSTERR 0x0002 265c8befdd5SWarner Losh #define STE_ISRACK_TX_DONE 0x0004 266c8befdd5SWarner Losh #define STE_ISRACK_MACCTL_FRAME 0x0008 267c8befdd5SWarner Losh #define STE_ISRACK_RX_DONE 0x0010 268c8befdd5SWarner Losh #define STE_ISRACK_RX_EARLY 0x0020 269c8befdd5SWarner Losh #define STE_ISRACK_SOFTINTR 0x0040 270c8befdd5SWarner Losh #define STE_ISRACK_STATS_OFLOW 0x0080 271c8befdd5SWarner Losh #define STE_ISRACK_LINKEVENT 0x0100 272c8befdd5SWarner Losh #define STE_ISRACK_TX_DMADONE 0x0200 273c8befdd5SWarner Losh #define STE_ISRACK_RX_DMADONE 0x0400 274c8befdd5SWarner Losh 275c8befdd5SWarner Losh #define STE_IMR_HOSTERR 0x0002 276c8befdd5SWarner Losh #define STE_IMR_TX_DONE 0x0004 277c8befdd5SWarner Losh #define STE_IMR_MACCTL_FRAME 0x0008 278c8befdd5SWarner Losh #define STE_IMR_RX_DONE 0x0010 279c8befdd5SWarner Losh #define STE_IMR_RX_EARLY 0x0020 280c8befdd5SWarner Losh #define STE_IMR_SOFTINTR 0x0040 281c8befdd5SWarner Losh #define STE_IMR_STATS_OFLOW 0x0080 282c8befdd5SWarner Losh #define STE_IMR_LINKEVENT 0x0100 283c8befdd5SWarner Losh #define STE_IMR_TX_DMADONE 0x0200 284c8befdd5SWarner Losh #define STE_IMR_RX_DMADONE 0x0400 285c8befdd5SWarner Losh 286c8befdd5SWarner Losh #define STE_INTRS \ 287c8befdd5SWarner Losh (STE_IMR_RX_DMADONE|STE_IMR_TX_DMADONE| \ 288fabbaac5SPyun YongHyeon STE_IMR_TX_DONE|STE_IMR_SOFTINTR| \ 289fabbaac5SPyun YongHyeon STE_IMR_HOSTERR) 290c8befdd5SWarner Losh 291c8befdd5SWarner Losh #define STE_ISR_INTLATCH 0x0001 292c8befdd5SWarner Losh #define STE_ISR_HOSTERR 0x0002 293c8befdd5SWarner Losh #define STE_ISR_TX_DONE 0x0004 294c8befdd5SWarner Losh #define STE_ISR_MACCTL_FRAME 0x0008 295c8befdd5SWarner Losh #define STE_ISR_RX_DONE 0x0010 296c8befdd5SWarner Losh #define STE_ISR_RX_EARLY 0x0020 297c8befdd5SWarner Losh #define STE_ISR_SOFTINTR 0x0040 298c8befdd5SWarner Losh #define STE_ISR_STATS_OFLOW 0x0080 299c8befdd5SWarner Losh #define STE_ISR_LINKEVENT 0x0100 300c8befdd5SWarner Losh #define STE_ISR_TX_DMADONE 0x0200 301c8befdd5SWarner Losh #define STE_ISR_RX_DMADONE 0x0400 302c8befdd5SWarner Losh 303c8befdd5SWarner Losh /* 304c8befdd5SWarner Losh * Note: the Sundance manual gives the impression that the's 305c8befdd5SWarner Losh * only one 32-bit MACCTL register. In fact, there are two 306c8befdd5SWarner Losh * 16-bit registers side by side, and you have to access them 307c8befdd5SWarner Losh * separately. 308c8befdd5SWarner Losh */ 309c8befdd5SWarner Losh #define STE_MACCTL0_IPG 0x0003 310c8befdd5SWarner Losh #define STE_MACCTL0_FULLDUPLEX 0x0020 311c8befdd5SWarner Losh #define STE_MACCTL0_RX_GIANTS 0x0040 312c8befdd5SWarner Losh #define STE_MACCTL0_FLOWCTL_ENABLE 0x0100 313c8befdd5SWarner Losh #define STE_MACCTL0_RX_FCS 0x0200 314c8befdd5SWarner Losh #define STE_MACCTL0_FIFOLOOPBK 0x0400 315c8befdd5SWarner Losh #define STE_MACCTL0_MACLOOPBK 0x0800 316c8befdd5SWarner Losh 317c8befdd5SWarner Losh #define STE_MACCTL1_COLLDETECT 0x0001 318c8befdd5SWarner Losh #define STE_MACCTL1_CARRSENSE 0x0002 319c8befdd5SWarner Losh #define STE_MACCTL1_TX_BUSY 0x0004 320c8befdd5SWarner Losh #define STE_MACCTL1_TX_ERROR 0x0008 321c8befdd5SWarner Losh #define STE_MACCTL1_STATS_ENABLE 0x0020 322c8befdd5SWarner Losh #define STE_MACCTL1_STATS_DISABLE 0x0040 323c8befdd5SWarner Losh #define STE_MACCTL1_STATS_ENABLED 0x0080 324c8befdd5SWarner Losh #define STE_MACCTL1_TX_ENABLE 0x0100 325c8befdd5SWarner Losh #define STE_MACCTL1_TX_DISABLE 0x0200 326c8befdd5SWarner Losh #define STE_MACCTL1_TX_ENABLED 0x0400 327c8befdd5SWarner Losh #define STE_MACCTL1_RX_ENABLE 0x0800 328c8befdd5SWarner Losh #define STE_MACCTL1_RX_DISABLE 0x1000 329c8befdd5SWarner Losh #define STE_MACCTL1_RX_ENABLED 0x2000 330c8befdd5SWarner Losh #define STE_MACCTL1_PAUSED 0x4000 331c8befdd5SWarner Losh 332c8befdd5SWarner Losh #define STE_IPG_96BT 0x00000000 333c8befdd5SWarner Losh #define STE_IPG_128BT 0x00000001 334c8befdd5SWarner Losh #define STE_IPG_224BT 0x00000002 335c8befdd5SWarner Losh #define STE_IPG_544BT 0x00000003 336c8befdd5SWarner Losh 337c8befdd5SWarner Losh #define STE_RXMODE_UNICAST 0x01 338c8befdd5SWarner Losh #define STE_RXMODE_ALLMULTI 0x02 339c8befdd5SWarner Losh #define STE_RXMODE_BROADCAST 0x04 340c8befdd5SWarner Losh #define STE_RXMODE_PROMISC 0x08 341c8befdd5SWarner Losh #define STE_RXMODE_MULTIHASH 0x10 342c8befdd5SWarner Losh #define STE_RXMODE_ALLIPMULTI 0x20 343c8befdd5SWarner Losh 344c8befdd5SWarner Losh #define STE_PHYCTL_MCLK 0x01 345c8befdd5SWarner Losh #define STE_PHYCTL_MDATA 0x02 346c8befdd5SWarner Losh #define STE_PHYCTL_MDIR 0x04 347c8befdd5SWarner Losh #define STE_PHYCTL_CLK25_DISABLE 0x08 348c8befdd5SWarner Losh #define STE_PHYCTL_DUPLEXPOLARITY 0x10 349c8befdd5SWarner Losh #define STE_PHYCTL_DUPLEXSTAT 0x20 350c8befdd5SWarner Losh #define STE_PHYCTL_SPEEDSTAT 0x40 351c8befdd5SWarner Losh #define STE_PHYCTL_LINKSTAT 0x80 352c8befdd5SWarner Losh 353fabbaac5SPyun YongHyeon #define STE_TIMER_TICKS 32 354fabbaac5SPyun YongHyeon #define STE_TIMER_USECS(x) ((x * 10) / STE_TIMER_TICKS) 355fabbaac5SPyun YongHyeon 356fabbaac5SPyun YongHyeon #define STE_IM_RX_TIMER_MIN 0 357fabbaac5SPyun YongHyeon #define STE_IM_RX_TIMER_MAX 209712 358fabbaac5SPyun YongHyeon #define STE_IM_RX_TIMER_DEFAULT 150 359fabbaac5SPyun YongHyeon 360c8befdd5SWarner Losh /* 361c8befdd5SWarner Losh * EEPROM offsets. 362c8befdd5SWarner Losh */ 363c8befdd5SWarner Losh #define STE_EEADDR_CONFIGPARM 0x00 364c8befdd5SWarner Losh #define STE_EEADDR_ASICCTL 0x02 365c8befdd5SWarner Losh #define STE_EEADDR_SUBSYS_ID 0x04 366c8befdd5SWarner Losh #define STE_EEADDR_SUBVEN_ID 0x08 367c8befdd5SWarner Losh 368c8befdd5SWarner Losh #define STE_EEADDR_NODE0 0x10 369c8befdd5SWarner Losh #define STE_EEADDR_NODE1 0x12 370c8befdd5SWarner Losh #define STE_EEADDR_NODE2 0x14 371c8befdd5SWarner Losh 372c8befdd5SWarner Losh /* PCI registers */ 373c8befdd5SWarner Losh #define STE_PCI_VENDOR_ID 0x00 374c8befdd5SWarner Losh #define STE_PCI_DEVICE_ID 0x02 375c8befdd5SWarner Losh #define STE_PCI_COMMAND 0x04 376c8befdd5SWarner Losh #define STE_PCI_STATUS 0x06 377c8befdd5SWarner Losh #define STE_PCI_CLASSCODE 0x09 378c8befdd5SWarner Losh #define STE_PCI_LATENCY_TIMER 0x0D 379c8befdd5SWarner Losh #define STE_PCI_HEADER_TYPE 0x0E 380c8befdd5SWarner Losh #define STE_PCI_LOIO 0x10 381c8befdd5SWarner Losh #define STE_PCI_LOMEM 0x14 382c8befdd5SWarner Losh #define STE_PCI_BIOSROM 0x30 383c8befdd5SWarner Losh #define STE_PCI_INTLINE 0x3C 384c8befdd5SWarner Losh #define STE_PCI_INTPIN 0x3D 385c8befdd5SWarner Losh #define STE_PCI_MINGNT 0x3E 386c8befdd5SWarner Losh #define STE_PCI_MINLAT 0x0F 387c8befdd5SWarner Losh 388c8befdd5SWarner Losh #define STE_PCI_CAPID 0x50 /* 8 bits */ 389c8befdd5SWarner Losh #define STE_PCI_NEXTPTR 0x51 /* 8 bits */ 390c8befdd5SWarner Losh #define STE_PCI_PWRMGMTCAP 0x52 /* 16 bits */ 391c8befdd5SWarner Losh #define STE_PCI_PWRMGMTCTRL 0x54 /* 16 bits */ 392c8befdd5SWarner Losh 393c8befdd5SWarner Losh #define STE_PSTATE_MASK 0x0003 394c8befdd5SWarner Losh #define STE_PSTATE_D0 0x0000 395c8befdd5SWarner Losh #define STE_PSTATE_D1 0x0002 396c8befdd5SWarner Losh #define STE_PSTATE_D2 0x0002 397c8befdd5SWarner Losh #define STE_PSTATE_D3 0x0003 398c8befdd5SWarner Losh #define STE_PME_EN 0x0010 399c8befdd5SWarner Losh #define STE_PME_STATUS 0x8000 400c8befdd5SWarner Losh 4018657caa6SPyun YongHyeon struct ste_hw_stats { 4028657caa6SPyun YongHyeon uint64_t rx_bytes; 4038657caa6SPyun YongHyeon uint32_t rx_frames; 4048657caa6SPyun YongHyeon uint32_t rx_bcast_frames; 4058657caa6SPyun YongHyeon uint32_t rx_mcast_frames; 4068657caa6SPyun YongHyeon uint32_t rx_lost_frames; 4078657caa6SPyun YongHyeon uint64_t tx_bytes; 4088657caa6SPyun YongHyeon uint32_t tx_frames; 4098657caa6SPyun YongHyeon uint32_t tx_bcast_frames; 4108657caa6SPyun YongHyeon uint32_t tx_mcast_frames; 4118657caa6SPyun YongHyeon uint32_t tx_carrsense_errs; 4128657caa6SPyun YongHyeon uint32_t tx_single_colls; 4138657caa6SPyun YongHyeon uint32_t tx_multi_colls; 4148657caa6SPyun YongHyeon uint32_t tx_late_colls; 4158657caa6SPyun YongHyeon uint32_t tx_frames_defered; 4168657caa6SPyun YongHyeon uint32_t tx_excess_defers; 4178657caa6SPyun YongHyeon uint32_t tx_abort; 418c8befdd5SWarner Losh }; 419c8befdd5SWarner Losh 420c8befdd5SWarner Losh struct ste_frag { 42156af54f2SPyun YongHyeon uint32_t ste_addr; 42256af54f2SPyun YongHyeon uint32_t ste_len; 423c8befdd5SWarner Losh }; 424c8befdd5SWarner Losh 425c8befdd5SWarner Losh #define STE_FRAG_LAST 0x80000000 426c8befdd5SWarner Losh #define STE_FRAG_LEN 0x00001FFF 427c8befdd5SWarner Losh 428a1b2c209SPyun YongHyeon /* 429a1b2c209SPyun YongHyeon * A TFD is 16 to 512 bytes in length which means it can have up to 126 430a1b2c209SPyun YongHyeon * fragments for a single Tx frame. Since most frames used in stack have 431a1b2c209SPyun YongHyeon * 3-4 fragments supporting 8 fragments would be enough for normal 432a1b2c209SPyun YongHyeon * operation. If we encounter more than 8 fragments we'll collapse them 433a1b2c209SPyun YongHyeon * into a frame that has less than or equal to 8 fragments. Each buffer 434a1b2c209SPyun YongHyeon * address of a fragment has no alignment limitation. 435a1b2c209SPyun YongHyeon */ 436c8befdd5SWarner Losh #define STE_MAXFRAGS 8 437c8befdd5SWarner Losh 438c8befdd5SWarner Losh struct ste_desc { 43956af54f2SPyun YongHyeon uint32_t ste_next; 44056af54f2SPyun YongHyeon uint32_t ste_ctl; 441c8befdd5SWarner Losh struct ste_frag ste_frags[STE_MAXFRAGS]; 442c8befdd5SWarner Losh }; 443c8befdd5SWarner Losh 444a1b2c209SPyun YongHyeon /* 445a1b2c209SPyun YongHyeon * A RFD has the same structure of TFD which in turn means hardware 446a1b2c209SPyun YongHyeon * supports scatter operation in Rx buffer. Since we just allocate Rx 447a1b2c209SPyun YongHyeon * buffer with m_getcl(9) there is no fragmentation at all so use 448a1b2c209SPyun YongHyeon * single fragment for RFD. 449a1b2c209SPyun YongHyeon */ 450c8befdd5SWarner Losh struct ste_desc_onefrag { 45156af54f2SPyun YongHyeon uint32_t ste_next; 45256af54f2SPyun YongHyeon uint32_t ste_status; 453c8befdd5SWarner Losh struct ste_frag ste_frag; 454c8befdd5SWarner Losh }; 455c8befdd5SWarner Losh 456c8befdd5SWarner Losh #define STE_TXCTL_WORDALIGN 0x00000003 457a1b2c209SPyun YongHyeon #define STE_TXCTL_ALIGN_DIS 0x00000001 458c8befdd5SWarner Losh #define STE_TXCTL_FRAMEID 0x000003FC 459c8befdd5SWarner Losh #define STE_TXCTL_NOCRC 0x00002000 460c8befdd5SWarner Losh #define STE_TXCTL_TXINTR 0x00008000 461c8befdd5SWarner Losh #define STE_TXCTL_DMADONE 0x00010000 462c8befdd5SWarner Losh #define STE_TXCTL_DMAINTR 0x80000000 463c8befdd5SWarner Losh 464c8befdd5SWarner Losh #define STE_RXSTAT_FRAMELEN 0x00001FFF 465c8befdd5SWarner Losh #define STE_RXSTAT_FRAME_ERR 0x00004000 466c8befdd5SWarner Losh #define STE_RXSTAT_DMADONE 0x00008000 467c8befdd5SWarner Losh #define STE_RXSTAT_FIFO_OFLOW 0x00010000 468c8befdd5SWarner Losh #define STE_RXSTAT_RUNT 0x00020000 469c8befdd5SWarner Losh #define STE_RXSTAT_ALIGNERR 0x00040000 470c8befdd5SWarner Losh #define STE_RXSTAT_CRCERR 0x00080000 471c8befdd5SWarner Losh #define STE_RXSTAT_GIANT 0x00100000 472c8befdd5SWarner Losh #define STE_RXSTAT_DRIBBLEBITS 0x00800000 473c8befdd5SWarner Losh #define STE_RXSTAT_DMA_OFLOW 0x01000000 474c8befdd5SWarner Losh #define STE_RXATAT_ONEBUF 0x10000000 475c8befdd5SWarner Losh 476a1b2c209SPyun YongHyeon #define STE_RX_BYTES(x) ((x) & STE_RXSTAT_FRAMELEN) 477a1b2c209SPyun YongHyeon 478c8befdd5SWarner Losh /* 479c8befdd5SWarner Losh * register space access macros 480c8befdd5SWarner Losh */ 481c8befdd5SWarner Losh #define CSR_WRITE_4(sc, reg, val) \ 482ec89b8a8SPyun YongHyeon bus_write_4((sc)->ste_res, reg, val) 483c8befdd5SWarner Losh #define CSR_WRITE_2(sc, reg, val) \ 484ec89b8a8SPyun YongHyeon bus_write_2((sc)->ste_res, reg, val) 485c8befdd5SWarner Losh #define CSR_WRITE_1(sc, reg, val) \ 486ec89b8a8SPyun YongHyeon bus_write_1((sc)->ste_res, reg, val) 487c8befdd5SWarner Losh 488c8befdd5SWarner Losh #define CSR_READ_4(sc, reg) \ 489ec89b8a8SPyun YongHyeon bus_read_4((sc)->ste_res, reg) 490c8befdd5SWarner Losh #define CSR_READ_2(sc, reg) \ 491ec89b8a8SPyun YongHyeon bus_read_2((sc)->ste_res, reg) 492c8befdd5SWarner Losh #define CSR_READ_1(sc, reg) \ 493ec89b8a8SPyun YongHyeon bus_read_1((sc)->ste_res, reg) 494c8befdd5SWarner Losh 4958c1093fcSMarius Strobl #define CSR_BARRIER(sc, reg, length, flags) \ 4968c1093fcSMarius Strobl bus_barrier((sc)->ste_res, reg, length, flags) 4978c1093fcSMarius Strobl 498a1b2c209SPyun YongHyeon #define STE_DESC_ALIGN 8 499a1b2c209SPyun YongHyeon #define STE_RX_LIST_CNT 128 500a1b2c209SPyun YongHyeon #define STE_TX_LIST_CNT 128 501a1b2c209SPyun YongHyeon #define STE_RX_LIST_SZ \ 502a1b2c209SPyun YongHyeon (sizeof(struct ste_desc_onefrag) * STE_RX_LIST_CNT) 503a1b2c209SPyun YongHyeon #define STE_TX_LIST_SZ \ 504a1b2c209SPyun YongHyeon (sizeof(struct ste_desc) * STE_TX_LIST_CNT) 505a1b2c209SPyun YongHyeon #define STE_ADDR_LO(x) ((uint64_t)(x) & 0xFFFFFFFF) 506a1b2c209SPyun YongHyeon #define STE_ADDR_HI(x) ((uint64_t)(x) >> 32) 507a1b2c209SPyun YongHyeon 508ae49e7a6SPyun YongHyeon /* 509ae49e7a6SPyun YongHyeon * Since Tx status can hold up to 31 status bytes we should 510ae49e7a6SPyun YongHyeon * check Tx status before controller fills it up. Otherwise 511ae49e7a6SPyun YongHyeon * Tx MAC stalls. 512ae49e7a6SPyun YongHyeon */ 513ae49e7a6SPyun YongHyeon #define STE_TX_INTR_FRAMES 16 514a1b2c209SPyun YongHyeon #define STE_TX_TIMEOUT 5 515c8befdd5SWarner Losh #define STE_TIMEOUT 1000 516c8befdd5SWarner Losh #define STE_MIN_FRAMELEN 60 517c8befdd5SWarner Losh #define STE_PACKET_SIZE 1536 518c8befdd5SWarner Losh #define STE_INC(x, y) (x) = (x + 1) % y 519a1b2c209SPyun YongHyeon #define STE_DEC(x, y) (x) = ((x) + ((y) - 1)) % (y) 520c8befdd5SWarner Losh #define STE_NEXT(x, y) (x + 1) % y 521c8befdd5SWarner Losh 522c8befdd5SWarner Losh struct ste_type { 52356af54f2SPyun YongHyeon uint16_t ste_vid; 52456af54f2SPyun YongHyeon uint16_t ste_did; 5258c1093fcSMarius Strobl const char *ste_name; 526c8befdd5SWarner Losh }; 527c8befdd5SWarner Losh 528c8befdd5SWarner Losh struct ste_list_data { 529a1b2c209SPyun YongHyeon struct ste_desc_onefrag *ste_rx_list; 530a1b2c209SPyun YongHyeon bus_addr_t ste_rx_list_paddr; 531a1b2c209SPyun YongHyeon struct ste_desc *ste_tx_list; 532a1b2c209SPyun YongHyeon bus_addr_t ste_tx_list_paddr; 533c8befdd5SWarner Losh }; 534c8befdd5SWarner Losh 535c8befdd5SWarner Losh struct ste_chain { 536c8befdd5SWarner Losh struct ste_desc *ste_ptr; 537c8befdd5SWarner Losh struct mbuf *ste_mbuf; 538c8befdd5SWarner Losh struct ste_chain *ste_next; 53956af54f2SPyun YongHyeon uint32_t ste_phys; 540a1b2c209SPyun YongHyeon bus_dmamap_t ste_map; 541c8befdd5SWarner Losh }; 542c8befdd5SWarner Losh 543c8befdd5SWarner Losh struct ste_chain_onefrag { 544c8befdd5SWarner Losh struct ste_desc_onefrag *ste_ptr; 545c8befdd5SWarner Losh struct mbuf *ste_mbuf; 546c8befdd5SWarner Losh struct ste_chain_onefrag *ste_next; 547a1b2c209SPyun YongHyeon bus_dmamap_t ste_map; 548c8befdd5SWarner Losh }; 549c8befdd5SWarner Losh 550c8befdd5SWarner Losh struct ste_chain_data { 551a1b2c209SPyun YongHyeon bus_dma_tag_t ste_parent_tag; 552a1b2c209SPyun YongHyeon bus_dma_tag_t ste_rx_tag; 553a1b2c209SPyun YongHyeon bus_dma_tag_t ste_tx_tag; 554a1b2c209SPyun YongHyeon bus_dma_tag_t ste_rx_list_tag; 555a1b2c209SPyun YongHyeon bus_dmamap_t ste_rx_list_map; 556a1b2c209SPyun YongHyeon bus_dma_tag_t ste_tx_list_tag; 557a1b2c209SPyun YongHyeon bus_dmamap_t ste_tx_list_map; 558a1b2c209SPyun YongHyeon bus_dmamap_t ste_rx_sparemap; 559c8befdd5SWarner Losh struct ste_chain_onefrag ste_rx_chain[STE_RX_LIST_CNT]; 560c8befdd5SWarner Losh struct ste_chain ste_tx_chain[STE_TX_LIST_CNT]; 561c8befdd5SWarner Losh struct ste_chain_onefrag *ste_rx_head; 562a1b2c209SPyun YongHyeon struct ste_chain *ste_last_tx; 563c8befdd5SWarner Losh int ste_tx_prod; 564c8befdd5SWarner Losh int ste_tx_cons; 565a1b2c209SPyun YongHyeon int ste_tx_cnt; 566c8befdd5SWarner Losh }; 567c8befdd5SWarner Losh 568c8befdd5SWarner Losh struct ste_softc { 569*6712df3aSJustin Hibbits if_t ste_ifp; 570c8befdd5SWarner Losh struct resource *ste_res; 571c0270e60SPyun YongHyeon int ste_res_id; 572c0270e60SPyun YongHyeon int ste_res_type; 573c8befdd5SWarner Losh struct resource *ste_irq; 574c8befdd5SWarner Losh void *ste_intrhand; 575c8befdd5SWarner Losh struct ste_type *ste_info; 576c8befdd5SWarner Losh device_t ste_miibus; 577c8befdd5SWarner Losh device_t ste_dev; 578c8befdd5SWarner Losh int ste_tx_thresh; 5794465097bSPyun YongHyeon int ste_flags; 5804465097bSPyun YongHyeon #define STE_FLAG_ONE_PHY 0x0001 5814465097bSPyun YongHyeon #define STE_FLAG_LINK 0x8000 582c8befdd5SWarner Losh int ste_if_flags; 5837cf545d0SJohn Baldwin int ste_timer; 584fabbaac5SPyun YongHyeon int ste_int_rx_act; 585fabbaac5SPyun YongHyeon int ste_int_rx_mod; 586a1b2c209SPyun YongHyeon struct ste_list_data ste_ldata; 587c8befdd5SWarner Losh struct ste_chain_data ste_cdata; 58810f695eeSPyun YongHyeon struct callout ste_callout; 5898657caa6SPyun YongHyeon struct ste_hw_stats ste_stats; 590c8befdd5SWarner Losh struct mtx ste_mtx; 591c8befdd5SWarner Losh }; 592c8befdd5SWarner Losh 593c8befdd5SWarner Losh #define STE_LOCK(_sc) mtx_lock(&(_sc)->ste_mtx) 594c8befdd5SWarner Losh #define STE_UNLOCK(_sc) mtx_unlock(&(_sc)->ste_mtx) 595c8befdd5SWarner Losh #define STE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->ste_mtx, MA_OWNED) 596