18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. 48c2ecf20Sopenharmony_ci * All rights reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * File: via-velocity.h 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Purpose: Header file to define driver's private structures. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Author: Chuang Liang-Shing, AJ Jiang 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Date: Jan 24, 2003 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#ifndef VELOCITY_H 178c2ecf20Sopenharmony_ci#define VELOCITY_H 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define VELOCITY_TX_CSUM_SUPPORT 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define VELOCITY_NAME "via-velocity" 228c2ecf20Sopenharmony_ci#define VELOCITY_FULL_DRV_NAM "VIA Networking Velocity Family Gigabit Ethernet Adapter Driver" 238c2ecf20Sopenharmony_ci#define VELOCITY_VERSION "1.15" 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define VELOCITY_IO_SIZE 256 268c2ecf20Sopenharmony_ci#define VELOCITY_NAPI_WEIGHT 64 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define PKT_BUF_SZ 1540 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define MAX_UNITS 8 318c2ecf20Sopenharmony_ci#define OPTION_DEFAULT { [0 ... MAX_UNITS-1] = -1} 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define REV_ID_VT6110 (0) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define BYTE_REG_BITS_ON(x,p) do { writeb(readb((p))|(x),(p));} while (0) 368c2ecf20Sopenharmony_ci#define WORD_REG_BITS_ON(x,p) do { writew(readw((p))|(x),(p));} while (0) 378c2ecf20Sopenharmony_ci#define DWORD_REG_BITS_ON(x,p) do { writel(readl((p))|(x),(p));} while (0) 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define BYTE_REG_BITS_IS_ON(x,p) (readb((p)) & (x)) 408c2ecf20Sopenharmony_ci#define WORD_REG_BITS_IS_ON(x,p) (readw((p)) & (x)) 418c2ecf20Sopenharmony_ci#define DWORD_REG_BITS_IS_ON(x,p) (readl((p)) & (x)) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define BYTE_REG_BITS_OFF(x,p) do { writeb(readb((p)) & (~(x)),(p));} while (0) 448c2ecf20Sopenharmony_ci#define WORD_REG_BITS_OFF(x,p) do { writew(readw((p)) & (~(x)),(p));} while (0) 458c2ecf20Sopenharmony_ci#define DWORD_REG_BITS_OFF(x,p) do { writel(readl((p)) & (~(x)),(p));} while (0) 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define BYTE_REG_BITS_SET(x,m,p) do { writeb( (readb((p)) & (~(m))) |(x),(p));} while (0) 488c2ecf20Sopenharmony_ci#define WORD_REG_BITS_SET(x,m,p) do { writew( (readw((p)) & (~(m))) |(x),(p));} while (0) 498c2ecf20Sopenharmony_ci#define DWORD_REG_BITS_SET(x,m,p) do { writel( (readl((p)) & (~(m)))|(x),(p));} while (0) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define VAR_USED(p) do {(p)=(p);} while (0) 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* 548c2ecf20Sopenharmony_ci * Purpose: Structures for MAX RX/TX descriptors. 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define B_OWNED_BY_CHIP 1 598c2ecf20Sopenharmony_ci#define B_OWNED_BY_HOST 0 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* 628c2ecf20Sopenharmony_ci * Bits in the RSR0 register 638c2ecf20Sopenharmony_ci */ 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define RSR_DETAG cpu_to_le16(0x0080) 668c2ecf20Sopenharmony_ci#define RSR_SNTAG cpu_to_le16(0x0040) 678c2ecf20Sopenharmony_ci#define RSR_RXER cpu_to_le16(0x0020) 688c2ecf20Sopenharmony_ci#define RSR_RL cpu_to_le16(0x0010) 698c2ecf20Sopenharmony_ci#define RSR_CE cpu_to_le16(0x0008) 708c2ecf20Sopenharmony_ci#define RSR_FAE cpu_to_le16(0x0004) 718c2ecf20Sopenharmony_ci#define RSR_CRC cpu_to_le16(0x0002) 728c2ecf20Sopenharmony_ci#define RSR_VIDM cpu_to_le16(0x0001) 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* 758c2ecf20Sopenharmony_ci * Bits in the RSR1 register 768c2ecf20Sopenharmony_ci */ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define RSR_RXOK cpu_to_le16(0x8000) // rx OK 798c2ecf20Sopenharmony_ci#define RSR_PFT cpu_to_le16(0x4000) // Perfect filtering address match 808c2ecf20Sopenharmony_ci#define RSR_MAR cpu_to_le16(0x2000) // MAC accept multicast address packet 818c2ecf20Sopenharmony_ci#define RSR_BAR cpu_to_le16(0x1000) // MAC accept broadcast address packet 828c2ecf20Sopenharmony_ci#define RSR_PHY cpu_to_le16(0x0800) // MAC accept physical address packet 838c2ecf20Sopenharmony_ci#define RSR_VTAG cpu_to_le16(0x0400) // 802.1p/1q tagging packet indicator 848c2ecf20Sopenharmony_ci#define RSR_STP cpu_to_le16(0x0200) // start of packet 858c2ecf20Sopenharmony_ci#define RSR_EDP cpu_to_le16(0x0100) // end of packet 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* 888c2ecf20Sopenharmony_ci * Bits in the CSM register 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define CSM_IPOK 0x40 //IP Checksum validation ok 928c2ecf20Sopenharmony_ci#define CSM_TUPOK 0x20 //TCP/UDP Checksum validation ok 938c2ecf20Sopenharmony_ci#define CSM_FRAG 0x10 //Fragment IP datagram 948c2ecf20Sopenharmony_ci#define CSM_IPKT 0x04 //Received an IP packet 958c2ecf20Sopenharmony_ci#define CSM_TCPKT 0x02 //Received a TCP packet 968c2ecf20Sopenharmony_ci#define CSM_UDPKT 0x01 //Received a UDP packet 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci/* 998c2ecf20Sopenharmony_ci * Bits in the TSR0 register 1008c2ecf20Sopenharmony_ci */ 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define TSR0_ABT cpu_to_le16(0x0080) // Tx abort because of excessive collision 1038c2ecf20Sopenharmony_ci#define TSR0_OWT cpu_to_le16(0x0040) // Jumbo frame Tx abort 1048c2ecf20Sopenharmony_ci#define TSR0_OWC cpu_to_le16(0x0020) // Out of window collision 1058c2ecf20Sopenharmony_ci#define TSR0_COLS cpu_to_le16(0x0010) // experience collision in this transmit event 1068c2ecf20Sopenharmony_ci#define TSR0_NCR3 cpu_to_le16(0x0008) // collision retry counter[3] 1078c2ecf20Sopenharmony_ci#define TSR0_NCR2 cpu_to_le16(0x0004) // collision retry counter[2] 1088c2ecf20Sopenharmony_ci#define TSR0_NCR1 cpu_to_le16(0x0002) // collision retry counter[1] 1098c2ecf20Sopenharmony_ci#define TSR0_NCR0 cpu_to_le16(0x0001) // collision retry counter[0] 1108c2ecf20Sopenharmony_ci#define TSR0_TERR cpu_to_le16(0x8000) // 1118c2ecf20Sopenharmony_ci#define TSR0_FDX cpu_to_le16(0x4000) // current transaction is serviced by full duplex mode 1128c2ecf20Sopenharmony_ci#define TSR0_GMII cpu_to_le16(0x2000) // current transaction is serviced by GMII mode 1138c2ecf20Sopenharmony_ci#define TSR0_LNKFL cpu_to_le16(0x1000) // packet serviced during link down 1148c2ecf20Sopenharmony_ci#define TSR0_SHDN cpu_to_le16(0x0400) // shutdown case 1158c2ecf20Sopenharmony_ci#define TSR0_CRS cpu_to_le16(0x0200) // carrier sense lost 1168c2ecf20Sopenharmony_ci#define TSR0_CDH cpu_to_le16(0x0100) // AQE test fail (CD heartbeat) 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci// 1198c2ecf20Sopenharmony_ci// Bits in the TCR0 register 1208c2ecf20Sopenharmony_ci// 1218c2ecf20Sopenharmony_ci#define TCR0_TIC 0x80 // assert interrupt immediately while descriptor has been send complete 1228c2ecf20Sopenharmony_ci#define TCR0_PIC 0x40 // priority interrupt request, INA# is issued over adaptive interrupt scheme 1238c2ecf20Sopenharmony_ci#define TCR0_VETAG 0x20 // enable VLAN tag 1248c2ecf20Sopenharmony_ci#define TCR0_IPCK 0x10 // request IP checksum calculation. 1258c2ecf20Sopenharmony_ci#define TCR0_UDPCK 0x08 // request UDP checksum calculation. 1268c2ecf20Sopenharmony_ci#define TCR0_TCPCK 0x04 // request TCP checksum calculation. 1278c2ecf20Sopenharmony_ci#define TCR0_JMBO 0x02 // indicate a jumbo packet in GMAC side 1288c2ecf20Sopenharmony_ci#define TCR0_CRC 0x01 // disable CRC generation 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci#define TCPLS_NORMAL 3 1318c2ecf20Sopenharmony_ci#define TCPLS_START 2 1328c2ecf20Sopenharmony_ci#define TCPLS_END 1 1338c2ecf20Sopenharmony_ci#define TCPLS_MED 0 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci// max transmit or receive buffer size 1378c2ecf20Sopenharmony_ci#define CB_RX_BUF_SIZE 2048UL // max buffer size 1388c2ecf20Sopenharmony_ci // NOTE: must be multiple of 4 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define CB_MAX_RD_NUM 512 // MAX # of RD 1418c2ecf20Sopenharmony_ci#define CB_MAX_TD_NUM 256 // MAX # of TD 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#define CB_INIT_RD_NUM_3119 128 // init # of RD, for setup VT3119 1448c2ecf20Sopenharmony_ci#define CB_INIT_TD_NUM_3119 64 // init # of TD, for setup VT3119 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci#define CB_INIT_RD_NUM 128 // init # of RD, for setup default 1478c2ecf20Sopenharmony_ci#define CB_INIT_TD_NUM 64 // init # of TD, for setup default 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci// for 3119 1508c2ecf20Sopenharmony_ci#define CB_TD_RING_NUM 4 // # of TD rings. 1518c2ecf20Sopenharmony_ci#define CB_MAX_SEG_PER_PKT 7 // max data seg per packet (Tx) 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci/* 1558c2ecf20Sopenharmony_ci * If collisions excess 15 times , tx will abort, and 1568c2ecf20Sopenharmony_ci * if tx fifo underflow, tx will fail 1578c2ecf20Sopenharmony_ci * we should try to resend it 1588c2ecf20Sopenharmony_ci */ 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci#define CB_MAX_TX_ABORT_RETRY 3 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci/* 1638c2ecf20Sopenharmony_ci * Receive descriptor 1648c2ecf20Sopenharmony_ci */ 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistruct rdesc0 { 1678c2ecf20Sopenharmony_ci __le16 RSR; /* Receive status */ 1688c2ecf20Sopenharmony_ci __le16 len; /* bits 0--13; bit 15 - owner */ 1698c2ecf20Sopenharmony_ci}; 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_cistruct rdesc1 { 1728c2ecf20Sopenharmony_ci __le16 PQTAG; 1738c2ecf20Sopenharmony_ci u8 CSM; 1748c2ecf20Sopenharmony_ci u8 IPKT; 1758c2ecf20Sopenharmony_ci}; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_cienum { 1788c2ecf20Sopenharmony_ci RX_INTEN = cpu_to_le16(0x8000) 1798c2ecf20Sopenharmony_ci}; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistruct rx_desc { 1828c2ecf20Sopenharmony_ci struct rdesc0 rdesc0; 1838c2ecf20Sopenharmony_ci struct rdesc1 rdesc1; 1848c2ecf20Sopenharmony_ci __le32 pa_low; /* Low 32 bit PCI address */ 1858c2ecf20Sopenharmony_ci __le16 pa_high; /* Next 16 bit PCI address (48 total) */ 1868c2ecf20Sopenharmony_ci __le16 size; /* bits 0--14 - frame size, bit 15 - enable int. */ 1878c2ecf20Sopenharmony_ci} __packed; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci/* 1908c2ecf20Sopenharmony_ci * Transmit descriptor 1918c2ecf20Sopenharmony_ci */ 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_cistruct tdesc0 { 1948c2ecf20Sopenharmony_ci __le16 TSR; /* Transmit status register */ 1958c2ecf20Sopenharmony_ci __le16 len; /* bits 0--13 - size of frame, bit 15 - owner */ 1968c2ecf20Sopenharmony_ci}; 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_cistruct tdesc1 { 1998c2ecf20Sopenharmony_ci __le16 vlan; 2008c2ecf20Sopenharmony_ci u8 TCR; 2018c2ecf20Sopenharmony_ci u8 cmd; /* bits 0--1 - TCPLS, bits 4--7 - CMDZ */ 2028c2ecf20Sopenharmony_ci} __packed; 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_cienum { 2058c2ecf20Sopenharmony_ci TD_QUEUE = cpu_to_le16(0x8000) 2068c2ecf20Sopenharmony_ci}; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_cistruct td_buf { 2098c2ecf20Sopenharmony_ci __le32 pa_low; 2108c2ecf20Sopenharmony_ci __le16 pa_high; 2118c2ecf20Sopenharmony_ci __le16 size; /* bits 0--13 - size, bit 15 - queue */ 2128c2ecf20Sopenharmony_ci} __packed; 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_cistruct tx_desc { 2158c2ecf20Sopenharmony_ci struct tdesc0 tdesc0; 2168c2ecf20Sopenharmony_ci struct tdesc1 tdesc1; 2178c2ecf20Sopenharmony_ci struct td_buf td_buf[7]; 2188c2ecf20Sopenharmony_ci}; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_cistruct velocity_rd_info { 2218c2ecf20Sopenharmony_ci struct sk_buff *skb; 2228c2ecf20Sopenharmony_ci dma_addr_t skb_dma; 2238c2ecf20Sopenharmony_ci}; 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci/* 2268c2ecf20Sopenharmony_ci * Used to track transmit side buffers. 2278c2ecf20Sopenharmony_ci */ 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_cistruct velocity_td_info { 2308c2ecf20Sopenharmony_ci struct sk_buff *skb; 2318c2ecf20Sopenharmony_ci int nskb_dma; 2328c2ecf20Sopenharmony_ci dma_addr_t skb_dma[7]; 2338c2ecf20Sopenharmony_ci}; 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_cienum velocity_owner { 2368c2ecf20Sopenharmony_ci OWNED_BY_HOST = 0, 2378c2ecf20Sopenharmony_ci OWNED_BY_NIC = cpu_to_le16(0x8000) 2388c2ecf20Sopenharmony_ci}; 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci/* 2428c2ecf20Sopenharmony_ci * MAC registers and macros. 2438c2ecf20Sopenharmony_ci */ 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci#define MCAM_SIZE 64 2478c2ecf20Sopenharmony_ci#define VCAM_SIZE 64 2488c2ecf20Sopenharmony_ci#define TX_QUEUE_NO 4 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci#define MAX_HW_MIB_COUNTER 32 2518c2ecf20Sopenharmony_ci#define VELOCITY_MIN_MTU (64) 2528c2ecf20Sopenharmony_ci#define VELOCITY_MAX_MTU (9000) 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci/* 2558c2ecf20Sopenharmony_ci * Registers in the MAC 2568c2ecf20Sopenharmony_ci */ 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci#define MAC_REG_PAR 0x00 // physical address 2598c2ecf20Sopenharmony_ci#define MAC_REG_RCR 0x06 2608c2ecf20Sopenharmony_ci#define MAC_REG_TCR 0x07 2618c2ecf20Sopenharmony_ci#define MAC_REG_CR0_SET 0x08 2628c2ecf20Sopenharmony_ci#define MAC_REG_CR1_SET 0x09 2638c2ecf20Sopenharmony_ci#define MAC_REG_CR2_SET 0x0A 2648c2ecf20Sopenharmony_ci#define MAC_REG_CR3_SET 0x0B 2658c2ecf20Sopenharmony_ci#define MAC_REG_CR0_CLR 0x0C 2668c2ecf20Sopenharmony_ci#define MAC_REG_CR1_CLR 0x0D 2678c2ecf20Sopenharmony_ci#define MAC_REG_CR2_CLR 0x0E 2688c2ecf20Sopenharmony_ci#define MAC_REG_CR3_CLR 0x0F 2698c2ecf20Sopenharmony_ci#define MAC_REG_MAR 0x10 2708c2ecf20Sopenharmony_ci#define MAC_REG_CAM 0x10 2718c2ecf20Sopenharmony_ci#define MAC_REG_DEC_BASE_HI 0x18 2728c2ecf20Sopenharmony_ci#define MAC_REG_DBF_BASE_HI 0x1C 2738c2ecf20Sopenharmony_ci#define MAC_REG_ISR_CTL 0x20 2748c2ecf20Sopenharmony_ci#define MAC_REG_ISR_HOTMR 0x20 2758c2ecf20Sopenharmony_ci#define MAC_REG_ISR_TSUPTHR 0x20 2768c2ecf20Sopenharmony_ci#define MAC_REG_ISR_RSUPTHR 0x20 2778c2ecf20Sopenharmony_ci#define MAC_REG_ISR_CTL1 0x21 2788c2ecf20Sopenharmony_ci#define MAC_REG_TXE_SR 0x22 2798c2ecf20Sopenharmony_ci#define MAC_REG_RXE_SR 0x23 2808c2ecf20Sopenharmony_ci#define MAC_REG_ISR 0x24 2818c2ecf20Sopenharmony_ci#define MAC_REG_ISR0 0x24 2828c2ecf20Sopenharmony_ci#define MAC_REG_ISR1 0x25 2838c2ecf20Sopenharmony_ci#define MAC_REG_ISR2 0x26 2848c2ecf20Sopenharmony_ci#define MAC_REG_ISR3 0x27 2858c2ecf20Sopenharmony_ci#define MAC_REG_IMR 0x28 2868c2ecf20Sopenharmony_ci#define MAC_REG_IMR0 0x28 2878c2ecf20Sopenharmony_ci#define MAC_REG_IMR1 0x29 2888c2ecf20Sopenharmony_ci#define MAC_REG_IMR2 0x2A 2898c2ecf20Sopenharmony_ci#define MAC_REG_IMR3 0x2B 2908c2ecf20Sopenharmony_ci#define MAC_REG_TDCSR_SET 0x30 2918c2ecf20Sopenharmony_ci#define MAC_REG_RDCSR_SET 0x32 2928c2ecf20Sopenharmony_ci#define MAC_REG_TDCSR_CLR 0x34 2938c2ecf20Sopenharmony_ci#define MAC_REG_RDCSR_CLR 0x36 2948c2ecf20Sopenharmony_ci#define MAC_REG_RDBASE_LO 0x38 2958c2ecf20Sopenharmony_ci#define MAC_REG_RDINDX 0x3C 2968c2ecf20Sopenharmony_ci#define MAC_REG_TDBASE_LO 0x40 2978c2ecf20Sopenharmony_ci#define MAC_REG_RDCSIZE 0x50 2988c2ecf20Sopenharmony_ci#define MAC_REG_TDCSIZE 0x52 2998c2ecf20Sopenharmony_ci#define MAC_REG_TDINDX 0x54 3008c2ecf20Sopenharmony_ci#define MAC_REG_TDIDX0 0x54 3018c2ecf20Sopenharmony_ci#define MAC_REG_TDIDX1 0x56 3028c2ecf20Sopenharmony_ci#define MAC_REG_TDIDX2 0x58 3038c2ecf20Sopenharmony_ci#define MAC_REG_TDIDX3 0x5A 3048c2ecf20Sopenharmony_ci#define MAC_REG_PAUSE_TIMER 0x5C 3058c2ecf20Sopenharmony_ci#define MAC_REG_RBRDU 0x5E 3068c2ecf20Sopenharmony_ci#define MAC_REG_FIFO_TEST0 0x60 3078c2ecf20Sopenharmony_ci#define MAC_REG_FIFO_TEST1 0x64 3088c2ecf20Sopenharmony_ci#define MAC_REG_CAMADDR 0x68 3098c2ecf20Sopenharmony_ci#define MAC_REG_CAMCR 0x69 3108c2ecf20Sopenharmony_ci#define MAC_REG_GFTEST 0x6A 3118c2ecf20Sopenharmony_ci#define MAC_REG_FTSTCMD 0x6B 3128c2ecf20Sopenharmony_ci#define MAC_REG_MIICFG 0x6C 3138c2ecf20Sopenharmony_ci#define MAC_REG_MIISR 0x6D 3148c2ecf20Sopenharmony_ci#define MAC_REG_PHYSR0 0x6E 3158c2ecf20Sopenharmony_ci#define MAC_REG_PHYSR1 0x6F 3168c2ecf20Sopenharmony_ci#define MAC_REG_MIICR 0x70 3178c2ecf20Sopenharmony_ci#define MAC_REG_MIIADR 0x71 3188c2ecf20Sopenharmony_ci#define MAC_REG_MIIDATA 0x72 3198c2ecf20Sopenharmony_ci#define MAC_REG_SOFT_TIMER0 0x74 3208c2ecf20Sopenharmony_ci#define MAC_REG_SOFT_TIMER1 0x76 3218c2ecf20Sopenharmony_ci#define MAC_REG_CFGA 0x78 3228c2ecf20Sopenharmony_ci#define MAC_REG_CFGB 0x79 3238c2ecf20Sopenharmony_ci#define MAC_REG_CFGC 0x7A 3248c2ecf20Sopenharmony_ci#define MAC_REG_CFGD 0x7B 3258c2ecf20Sopenharmony_ci#define MAC_REG_DCFG0 0x7C 3268c2ecf20Sopenharmony_ci#define MAC_REG_DCFG1 0x7D 3278c2ecf20Sopenharmony_ci#define MAC_REG_MCFG0 0x7E 3288c2ecf20Sopenharmony_ci#define MAC_REG_MCFG1 0x7F 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci#define MAC_REG_TBIST 0x80 3318c2ecf20Sopenharmony_ci#define MAC_REG_RBIST 0x81 3328c2ecf20Sopenharmony_ci#define MAC_REG_PMCC 0x82 3338c2ecf20Sopenharmony_ci#define MAC_REG_STICKHW 0x83 3348c2ecf20Sopenharmony_ci#define MAC_REG_MIBCR 0x84 3358c2ecf20Sopenharmony_ci#define MAC_REG_EERSV 0x85 3368c2ecf20Sopenharmony_ci#define MAC_REG_REVID 0x86 3378c2ecf20Sopenharmony_ci#define MAC_REG_MIBREAD 0x88 3388c2ecf20Sopenharmony_ci#define MAC_REG_BPMA 0x8C 3398c2ecf20Sopenharmony_ci#define MAC_REG_EEWR_DATA 0x8C 3408c2ecf20Sopenharmony_ci#define MAC_REG_BPMD_WR 0x8F 3418c2ecf20Sopenharmony_ci#define MAC_REG_BPCMD 0x90 3428c2ecf20Sopenharmony_ci#define MAC_REG_BPMD_RD 0x91 3438c2ecf20Sopenharmony_ci#define MAC_REG_EECHKSUM 0x92 3448c2ecf20Sopenharmony_ci#define MAC_REG_EECSR 0x93 3458c2ecf20Sopenharmony_ci#define MAC_REG_EERD_DATA 0x94 3468c2ecf20Sopenharmony_ci#define MAC_REG_EADDR 0x96 3478c2ecf20Sopenharmony_ci#define MAC_REG_EMBCMD 0x97 3488c2ecf20Sopenharmony_ci#define MAC_REG_JMPSR0 0x98 3498c2ecf20Sopenharmony_ci#define MAC_REG_JMPSR1 0x99 3508c2ecf20Sopenharmony_ci#define MAC_REG_JMPSR2 0x9A 3518c2ecf20Sopenharmony_ci#define MAC_REG_JMPSR3 0x9B 3528c2ecf20Sopenharmony_ci#define MAC_REG_CHIPGSR 0x9C 3538c2ecf20Sopenharmony_ci#define MAC_REG_TESTCFG 0x9D 3548c2ecf20Sopenharmony_ci#define MAC_REG_DEBUG 0x9E 3558c2ecf20Sopenharmony_ci#define MAC_REG_CHIPGCR 0x9F /* Chip Operation and Diagnostic Control */ 3568c2ecf20Sopenharmony_ci#define MAC_REG_WOLCR0_SET 0xA0 3578c2ecf20Sopenharmony_ci#define MAC_REG_WOLCR1_SET 0xA1 3588c2ecf20Sopenharmony_ci#define MAC_REG_PWCFG_SET 0xA2 3598c2ecf20Sopenharmony_ci#define MAC_REG_WOLCFG_SET 0xA3 3608c2ecf20Sopenharmony_ci#define MAC_REG_WOLCR0_CLR 0xA4 3618c2ecf20Sopenharmony_ci#define MAC_REG_WOLCR1_CLR 0xA5 3628c2ecf20Sopenharmony_ci#define MAC_REG_PWCFG_CLR 0xA6 3638c2ecf20Sopenharmony_ci#define MAC_REG_WOLCFG_CLR 0xA7 3648c2ecf20Sopenharmony_ci#define MAC_REG_WOLSR0_SET 0xA8 3658c2ecf20Sopenharmony_ci#define MAC_REG_WOLSR1_SET 0xA9 3668c2ecf20Sopenharmony_ci#define MAC_REG_WOLSR0_CLR 0xAC 3678c2ecf20Sopenharmony_ci#define MAC_REG_WOLSR1_CLR 0xAD 3688c2ecf20Sopenharmony_ci#define MAC_REG_PATRN_CRC0 0xB0 3698c2ecf20Sopenharmony_ci#define MAC_REG_PATRN_CRC1 0xB2 3708c2ecf20Sopenharmony_ci#define MAC_REG_PATRN_CRC2 0xB4 3718c2ecf20Sopenharmony_ci#define MAC_REG_PATRN_CRC3 0xB6 3728c2ecf20Sopenharmony_ci#define MAC_REG_PATRN_CRC4 0xB8 3738c2ecf20Sopenharmony_ci#define MAC_REG_PATRN_CRC5 0xBA 3748c2ecf20Sopenharmony_ci#define MAC_REG_PATRN_CRC6 0xBC 3758c2ecf20Sopenharmony_ci#define MAC_REG_PATRN_CRC7 0xBE 3768c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK0_0 0xC0 3778c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK0_1 0xC4 3788c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK0_2 0xC8 3798c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK0_3 0xCC 3808c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK1_0 0xD0 3818c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK1_1 0xD4 3828c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK1_2 0xD8 3838c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK1_3 0xDC 3848c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK2_0 0xE0 3858c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK2_1 0xE4 3868c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK2_2 0xE8 3878c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK2_3 0xEC 3888c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK3_0 0xF0 3898c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK3_1 0xF4 3908c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK3_2 0xF8 3918c2ecf20Sopenharmony_ci#define MAC_REG_BYTEMSK3_3 0xFC 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_ci/* 3948c2ecf20Sopenharmony_ci * Bits in the RCR register 3958c2ecf20Sopenharmony_ci */ 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci#define RCR_AS 0x80 3988c2ecf20Sopenharmony_ci#define RCR_AP 0x40 3998c2ecf20Sopenharmony_ci#define RCR_AL 0x20 4008c2ecf20Sopenharmony_ci#define RCR_PROM 0x10 4018c2ecf20Sopenharmony_ci#define RCR_AB 0x08 4028c2ecf20Sopenharmony_ci#define RCR_AM 0x04 4038c2ecf20Sopenharmony_ci#define RCR_AR 0x02 4048c2ecf20Sopenharmony_ci#define RCR_SEP 0x01 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci/* 4078c2ecf20Sopenharmony_ci * Bits in the TCR register 4088c2ecf20Sopenharmony_ci */ 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci#define TCR_TB2BDIS 0x80 4118c2ecf20Sopenharmony_ci#define TCR_COLTMC1 0x08 4128c2ecf20Sopenharmony_ci#define TCR_COLTMC0 0x04 4138c2ecf20Sopenharmony_ci#define TCR_LB1 0x02 /* loopback[1] */ 4148c2ecf20Sopenharmony_ci#define TCR_LB0 0x01 /* loopback[0] */ 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci/* 4178c2ecf20Sopenharmony_ci * Bits in the CR0 register 4188c2ecf20Sopenharmony_ci */ 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_ci#define CR0_TXON 0x00000008UL 4218c2ecf20Sopenharmony_ci#define CR0_RXON 0x00000004UL 4228c2ecf20Sopenharmony_ci#define CR0_STOP 0x00000002UL /* stop MAC, default = 1 */ 4238c2ecf20Sopenharmony_ci#define CR0_STRT 0x00000001UL /* start MAC */ 4248c2ecf20Sopenharmony_ci#define CR0_SFRST 0x00008000UL /* software reset */ 4258c2ecf20Sopenharmony_ci#define CR0_TM1EN 0x00004000UL 4268c2ecf20Sopenharmony_ci#define CR0_TM0EN 0x00002000UL 4278c2ecf20Sopenharmony_ci#define CR0_DPOLL 0x00000800UL /* disable rx/tx auto polling */ 4288c2ecf20Sopenharmony_ci#define CR0_DISAU 0x00000100UL 4298c2ecf20Sopenharmony_ci#define CR0_XONEN 0x00800000UL 4308c2ecf20Sopenharmony_ci#define CR0_FDXTFCEN 0x00400000UL /* full-duplex TX flow control enable */ 4318c2ecf20Sopenharmony_ci#define CR0_FDXRFCEN 0x00200000UL /* full-duplex RX flow control enable */ 4328c2ecf20Sopenharmony_ci#define CR0_HDXFCEN 0x00100000UL /* half-duplex flow control enable */ 4338c2ecf20Sopenharmony_ci#define CR0_XHITH1 0x00080000UL /* TX XON high threshold 1 */ 4348c2ecf20Sopenharmony_ci#define CR0_XHITH0 0x00040000UL /* TX XON high threshold 0 */ 4358c2ecf20Sopenharmony_ci#define CR0_XLTH1 0x00020000UL /* TX pause frame low threshold 1 */ 4368c2ecf20Sopenharmony_ci#define CR0_XLTH0 0x00010000UL /* TX pause frame low threshold 0 */ 4378c2ecf20Sopenharmony_ci#define CR0_GSPRST 0x80000000UL 4388c2ecf20Sopenharmony_ci#define CR0_FORSRST 0x40000000UL 4398c2ecf20Sopenharmony_ci#define CR0_FPHYRST 0x20000000UL 4408c2ecf20Sopenharmony_ci#define CR0_DIAG 0x10000000UL 4418c2ecf20Sopenharmony_ci#define CR0_INTPCTL 0x04000000UL 4428c2ecf20Sopenharmony_ci#define CR0_GINTMSK1 0x02000000UL 4438c2ecf20Sopenharmony_ci#define CR0_GINTMSK0 0x01000000UL 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ci/* 4468c2ecf20Sopenharmony_ci * Bits in the CR1 register 4478c2ecf20Sopenharmony_ci */ 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci#define CR1_SFRST 0x80 /* software reset */ 4508c2ecf20Sopenharmony_ci#define CR1_TM1EN 0x40 4518c2ecf20Sopenharmony_ci#define CR1_TM0EN 0x20 4528c2ecf20Sopenharmony_ci#define CR1_DPOLL 0x08 /* disable rx/tx auto polling */ 4538c2ecf20Sopenharmony_ci#define CR1_DISAU 0x01 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci/* 4568c2ecf20Sopenharmony_ci * Bits in the CR2 register 4578c2ecf20Sopenharmony_ci */ 4588c2ecf20Sopenharmony_ci 4598c2ecf20Sopenharmony_ci#define CR2_XONEN 0x80 4608c2ecf20Sopenharmony_ci#define CR2_FDXTFCEN 0x40 /* full-duplex TX flow control enable */ 4618c2ecf20Sopenharmony_ci#define CR2_FDXRFCEN 0x20 /* full-duplex RX flow control enable */ 4628c2ecf20Sopenharmony_ci#define CR2_HDXFCEN 0x10 /* half-duplex flow control enable */ 4638c2ecf20Sopenharmony_ci#define CR2_XHITH1 0x08 /* TX XON high threshold 1 */ 4648c2ecf20Sopenharmony_ci#define CR2_XHITH0 0x04 /* TX XON high threshold 0 */ 4658c2ecf20Sopenharmony_ci#define CR2_XLTH1 0x02 /* TX pause frame low threshold 1 */ 4668c2ecf20Sopenharmony_ci#define CR2_XLTH0 0x01 /* TX pause frame low threshold 0 */ 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci/* 4698c2ecf20Sopenharmony_ci * Bits in the CR3 register 4708c2ecf20Sopenharmony_ci */ 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_ci#define CR3_GSPRST 0x80 4738c2ecf20Sopenharmony_ci#define CR3_FORSRST 0x40 4748c2ecf20Sopenharmony_ci#define CR3_FPHYRST 0x20 4758c2ecf20Sopenharmony_ci#define CR3_DIAG 0x10 4768c2ecf20Sopenharmony_ci#define CR3_INTPCTL 0x04 4778c2ecf20Sopenharmony_ci#define CR3_GINTMSK1 0x02 4788c2ecf20Sopenharmony_ci#define CR3_GINTMSK0 0x01 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci#define ISRCTL_UDPINT 0x8000 4818c2ecf20Sopenharmony_ci#define ISRCTL_TSUPDIS 0x4000 4828c2ecf20Sopenharmony_ci#define ISRCTL_RSUPDIS 0x2000 4838c2ecf20Sopenharmony_ci#define ISRCTL_PMSK1 0x1000 4848c2ecf20Sopenharmony_ci#define ISRCTL_PMSK0 0x0800 4858c2ecf20Sopenharmony_ci#define ISRCTL_INTPD 0x0400 4868c2ecf20Sopenharmony_ci#define ISRCTL_HCRLD 0x0200 4878c2ecf20Sopenharmony_ci#define ISRCTL_SCRLD 0x0100 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci/* 4908c2ecf20Sopenharmony_ci * Bits in the ISR_CTL1 register 4918c2ecf20Sopenharmony_ci */ 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ci#define ISRCTL1_UDPINT 0x80 4948c2ecf20Sopenharmony_ci#define ISRCTL1_TSUPDIS 0x40 4958c2ecf20Sopenharmony_ci#define ISRCTL1_RSUPDIS 0x20 4968c2ecf20Sopenharmony_ci#define ISRCTL1_PMSK1 0x10 4978c2ecf20Sopenharmony_ci#define ISRCTL1_PMSK0 0x08 4988c2ecf20Sopenharmony_ci#define ISRCTL1_INTPD 0x04 4998c2ecf20Sopenharmony_ci#define ISRCTL1_HCRLD 0x02 5008c2ecf20Sopenharmony_ci#define ISRCTL1_SCRLD 0x01 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci/* 5038c2ecf20Sopenharmony_ci * Bits in the TXE_SR register 5048c2ecf20Sopenharmony_ci */ 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci#define TXESR_TFDBS 0x08 5078c2ecf20Sopenharmony_ci#define TXESR_TDWBS 0x04 5088c2ecf20Sopenharmony_ci#define TXESR_TDRBS 0x02 5098c2ecf20Sopenharmony_ci#define TXESR_TDSTR 0x01 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci/* 5128c2ecf20Sopenharmony_ci * Bits in the RXE_SR register 5138c2ecf20Sopenharmony_ci */ 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci#define RXESR_RFDBS 0x08 5168c2ecf20Sopenharmony_ci#define RXESR_RDWBS 0x04 5178c2ecf20Sopenharmony_ci#define RXESR_RDRBS 0x02 5188c2ecf20Sopenharmony_ci#define RXESR_RDSTR 0x01 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci/* 5218c2ecf20Sopenharmony_ci * Bits in the ISR register 5228c2ecf20Sopenharmony_ci */ 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ci#define ISR_ISR3 0x80000000UL 5258c2ecf20Sopenharmony_ci#define ISR_ISR2 0x40000000UL 5268c2ecf20Sopenharmony_ci#define ISR_ISR1 0x20000000UL 5278c2ecf20Sopenharmony_ci#define ISR_ISR0 0x10000000UL 5288c2ecf20Sopenharmony_ci#define ISR_TXSTLI 0x02000000UL 5298c2ecf20Sopenharmony_ci#define ISR_RXSTLI 0x01000000UL 5308c2ecf20Sopenharmony_ci#define ISR_HFLD 0x00800000UL 5318c2ecf20Sopenharmony_ci#define ISR_UDPI 0x00400000UL 5328c2ecf20Sopenharmony_ci#define ISR_MIBFI 0x00200000UL 5338c2ecf20Sopenharmony_ci#define ISR_SHDNI 0x00100000UL 5348c2ecf20Sopenharmony_ci#define ISR_PHYI 0x00080000UL 5358c2ecf20Sopenharmony_ci#define ISR_PWEI 0x00040000UL 5368c2ecf20Sopenharmony_ci#define ISR_TMR1I 0x00020000UL 5378c2ecf20Sopenharmony_ci#define ISR_TMR0I 0x00010000UL 5388c2ecf20Sopenharmony_ci#define ISR_SRCI 0x00008000UL 5398c2ecf20Sopenharmony_ci#define ISR_LSTPEI 0x00004000UL 5408c2ecf20Sopenharmony_ci#define ISR_LSTEI 0x00002000UL 5418c2ecf20Sopenharmony_ci#define ISR_OVFI 0x00001000UL 5428c2ecf20Sopenharmony_ci#define ISR_FLONI 0x00000800UL 5438c2ecf20Sopenharmony_ci#define ISR_RACEI 0x00000400UL 5448c2ecf20Sopenharmony_ci#define ISR_TXWB1I 0x00000200UL 5458c2ecf20Sopenharmony_ci#define ISR_TXWB0I 0x00000100UL 5468c2ecf20Sopenharmony_ci#define ISR_PTX3I 0x00000080UL 5478c2ecf20Sopenharmony_ci#define ISR_PTX2I 0x00000040UL 5488c2ecf20Sopenharmony_ci#define ISR_PTX1I 0x00000020UL 5498c2ecf20Sopenharmony_ci#define ISR_PTX0I 0x00000010UL 5508c2ecf20Sopenharmony_ci#define ISR_PTXI 0x00000008UL 5518c2ecf20Sopenharmony_ci#define ISR_PRXI 0x00000004UL 5528c2ecf20Sopenharmony_ci#define ISR_PPTXI 0x00000002UL 5538c2ecf20Sopenharmony_ci#define ISR_PPRXI 0x00000001UL 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_ci/* 5568c2ecf20Sopenharmony_ci * Bits in the IMR register 5578c2ecf20Sopenharmony_ci */ 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_ci#define IMR_TXSTLM 0x02000000UL 5608c2ecf20Sopenharmony_ci#define IMR_UDPIM 0x00400000UL 5618c2ecf20Sopenharmony_ci#define IMR_MIBFIM 0x00200000UL 5628c2ecf20Sopenharmony_ci#define IMR_SHDNIM 0x00100000UL 5638c2ecf20Sopenharmony_ci#define IMR_PHYIM 0x00080000UL 5648c2ecf20Sopenharmony_ci#define IMR_PWEIM 0x00040000UL 5658c2ecf20Sopenharmony_ci#define IMR_TMR1IM 0x00020000UL 5668c2ecf20Sopenharmony_ci#define IMR_TMR0IM 0x00010000UL 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci#define IMR_SRCIM 0x00008000UL 5698c2ecf20Sopenharmony_ci#define IMR_LSTPEIM 0x00004000UL 5708c2ecf20Sopenharmony_ci#define IMR_LSTEIM 0x00002000UL 5718c2ecf20Sopenharmony_ci#define IMR_OVFIM 0x00001000UL 5728c2ecf20Sopenharmony_ci#define IMR_FLONIM 0x00000800UL 5738c2ecf20Sopenharmony_ci#define IMR_RACEIM 0x00000400UL 5748c2ecf20Sopenharmony_ci#define IMR_TXWB1IM 0x00000200UL 5758c2ecf20Sopenharmony_ci#define IMR_TXWB0IM 0x00000100UL 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci#define IMR_PTX3IM 0x00000080UL 5788c2ecf20Sopenharmony_ci#define IMR_PTX2IM 0x00000040UL 5798c2ecf20Sopenharmony_ci#define IMR_PTX1IM 0x00000020UL 5808c2ecf20Sopenharmony_ci#define IMR_PTX0IM 0x00000010UL 5818c2ecf20Sopenharmony_ci#define IMR_PTXIM 0x00000008UL 5828c2ecf20Sopenharmony_ci#define IMR_PRXIM 0x00000004UL 5838c2ecf20Sopenharmony_ci#define IMR_PPTXIM 0x00000002UL 5848c2ecf20Sopenharmony_ci#define IMR_PPRXIM 0x00000001UL 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci/* 0x0013FB0FUL = initial value of IMR */ 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci#define INT_MASK_DEF (IMR_PPTXIM|IMR_PPRXIM|IMR_PTXIM|IMR_PRXIM|\ 5898c2ecf20Sopenharmony_ci IMR_PWEIM|IMR_TXWB0IM|IMR_TXWB1IM|IMR_FLONIM|\ 5908c2ecf20Sopenharmony_ci IMR_OVFIM|IMR_LSTEIM|IMR_LSTPEIM|IMR_SRCIM|IMR_MIBFIM|\ 5918c2ecf20Sopenharmony_ci IMR_SHDNIM|IMR_TMR1IM|IMR_TMR0IM|IMR_TXSTLM) 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci/* 5948c2ecf20Sopenharmony_ci * Bits in the TDCSR0/1, RDCSR0 register 5958c2ecf20Sopenharmony_ci */ 5968c2ecf20Sopenharmony_ci 5978c2ecf20Sopenharmony_ci#define TRDCSR_DEAD 0x0008 5988c2ecf20Sopenharmony_ci#define TRDCSR_WAK 0x0004 5998c2ecf20Sopenharmony_ci#define TRDCSR_ACT 0x0002 6008c2ecf20Sopenharmony_ci#define TRDCSR_RUN 0x0001 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci/* 6038c2ecf20Sopenharmony_ci * Bits in the CAMADDR register 6048c2ecf20Sopenharmony_ci */ 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci#define CAMADDR_CAMEN 0x80 6078c2ecf20Sopenharmony_ci#define CAMADDR_VCAMSL 0x40 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ci/* 6108c2ecf20Sopenharmony_ci * Bits in the CAMCR register 6118c2ecf20Sopenharmony_ci */ 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_ci#define CAMCR_PS1 0x80 6148c2ecf20Sopenharmony_ci#define CAMCR_PS0 0x40 6158c2ecf20Sopenharmony_ci#define CAMCR_AITRPKT 0x20 6168c2ecf20Sopenharmony_ci#define CAMCR_AITR16 0x10 6178c2ecf20Sopenharmony_ci#define CAMCR_CAMRD 0x08 6188c2ecf20Sopenharmony_ci#define CAMCR_CAMWR 0x04 6198c2ecf20Sopenharmony_ci#define CAMCR_PS_CAM_MASK 0x40 6208c2ecf20Sopenharmony_ci#define CAMCR_PS_CAM_DATA 0x80 6218c2ecf20Sopenharmony_ci#define CAMCR_PS_MAR 0x00 6228c2ecf20Sopenharmony_ci 6238c2ecf20Sopenharmony_ci/* 6248c2ecf20Sopenharmony_ci * Bits in the MIICFG register 6258c2ecf20Sopenharmony_ci */ 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci#define MIICFG_MPO1 0x80 6288c2ecf20Sopenharmony_ci#define MIICFG_MPO0 0x40 6298c2ecf20Sopenharmony_ci#define MIICFG_MFDC 0x20 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_ci/* 6328c2ecf20Sopenharmony_ci * Bits in the MIISR register 6338c2ecf20Sopenharmony_ci */ 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci#define MIISR_MIDLE 0x80 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci/* 6388c2ecf20Sopenharmony_ci * Bits in the PHYSR0 register 6398c2ecf20Sopenharmony_ci */ 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci#define PHYSR0_PHYRST 0x80 6428c2ecf20Sopenharmony_ci#define PHYSR0_LINKGD 0x40 6438c2ecf20Sopenharmony_ci#define PHYSR0_FDPX 0x10 6448c2ecf20Sopenharmony_ci#define PHYSR0_SPDG 0x08 6458c2ecf20Sopenharmony_ci#define PHYSR0_SPD10 0x04 6468c2ecf20Sopenharmony_ci#define PHYSR0_RXFLC 0x02 6478c2ecf20Sopenharmony_ci#define PHYSR0_TXFLC 0x01 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_ci/* 6508c2ecf20Sopenharmony_ci * Bits in the PHYSR1 register 6518c2ecf20Sopenharmony_ci */ 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_ci#define PHYSR1_PHYTBI 0x01 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_ci/* 6568c2ecf20Sopenharmony_ci * Bits in the MIICR register 6578c2ecf20Sopenharmony_ci */ 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci#define MIICR_MAUTO 0x80 6608c2ecf20Sopenharmony_ci#define MIICR_RCMD 0x40 6618c2ecf20Sopenharmony_ci#define MIICR_WCMD 0x20 6628c2ecf20Sopenharmony_ci#define MIICR_MDPM 0x10 6638c2ecf20Sopenharmony_ci#define MIICR_MOUT 0x08 6648c2ecf20Sopenharmony_ci#define MIICR_MDO 0x04 6658c2ecf20Sopenharmony_ci#define MIICR_MDI 0x02 6668c2ecf20Sopenharmony_ci#define MIICR_MDC 0x01 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_ci/* 6698c2ecf20Sopenharmony_ci * Bits in the MIIADR register 6708c2ecf20Sopenharmony_ci */ 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ci#define MIIADR_SWMPL 0x80 6738c2ecf20Sopenharmony_ci 6748c2ecf20Sopenharmony_ci/* 6758c2ecf20Sopenharmony_ci * Bits in the CFGA register 6768c2ecf20Sopenharmony_ci */ 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci#define CFGA_PMHCTG 0x08 6798c2ecf20Sopenharmony_ci#define CFGA_GPIO1PD 0x04 6808c2ecf20Sopenharmony_ci#define CFGA_ABSHDN 0x02 6818c2ecf20Sopenharmony_ci#define CFGA_PACPI 0x01 6828c2ecf20Sopenharmony_ci 6838c2ecf20Sopenharmony_ci/* 6848c2ecf20Sopenharmony_ci * Bits in the CFGB register 6858c2ecf20Sopenharmony_ci */ 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ci#define CFGB_GTCKOPT 0x80 6888c2ecf20Sopenharmony_ci#define CFGB_MIIOPT 0x40 6898c2ecf20Sopenharmony_ci#define CFGB_CRSEOPT 0x20 6908c2ecf20Sopenharmony_ci#define CFGB_OFSET 0x10 6918c2ecf20Sopenharmony_ci#define CFGB_CRANDOM 0x08 6928c2ecf20Sopenharmony_ci#define CFGB_CAP 0x04 6938c2ecf20Sopenharmony_ci#define CFGB_MBA 0x02 6948c2ecf20Sopenharmony_ci#define CFGB_BAKOPT 0x01 6958c2ecf20Sopenharmony_ci 6968c2ecf20Sopenharmony_ci/* 6978c2ecf20Sopenharmony_ci * Bits in the CFGC register 6988c2ecf20Sopenharmony_ci */ 6998c2ecf20Sopenharmony_ci 7008c2ecf20Sopenharmony_ci#define CFGC_EELOAD 0x80 7018c2ecf20Sopenharmony_ci#define CFGC_BROPT 0x40 7028c2ecf20Sopenharmony_ci#define CFGC_DLYEN 0x20 7038c2ecf20Sopenharmony_ci#define CFGC_DTSEL 0x10 7048c2ecf20Sopenharmony_ci#define CFGC_BTSEL 0x08 7058c2ecf20Sopenharmony_ci#define CFGC_BPS2 0x04 /* bootrom select[2] */ 7068c2ecf20Sopenharmony_ci#define CFGC_BPS1 0x02 /* bootrom select[1] */ 7078c2ecf20Sopenharmony_ci#define CFGC_BPS0 0x01 /* bootrom select[0] */ 7088c2ecf20Sopenharmony_ci 7098c2ecf20Sopenharmony_ci/* 7108c2ecf20Sopenharmony_ci * Bits in the CFGD register 7118c2ecf20Sopenharmony_ci */ 7128c2ecf20Sopenharmony_ci 7138c2ecf20Sopenharmony_ci#define CFGD_IODIS 0x80 7148c2ecf20Sopenharmony_ci#define CFGD_MSLVDACEN 0x40 7158c2ecf20Sopenharmony_ci#define CFGD_CFGDACEN 0x20 7168c2ecf20Sopenharmony_ci#define CFGD_PCI64EN 0x10 7178c2ecf20Sopenharmony_ci#define CFGD_HTMRL4 0x08 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_ci/* 7208c2ecf20Sopenharmony_ci * Bits in the DCFG1 register 7218c2ecf20Sopenharmony_ci */ 7228c2ecf20Sopenharmony_ci 7238c2ecf20Sopenharmony_ci#define DCFG_XMWI 0x8000 7248c2ecf20Sopenharmony_ci#define DCFG_XMRM 0x4000 7258c2ecf20Sopenharmony_ci#define DCFG_XMRL 0x2000 7268c2ecf20Sopenharmony_ci#define DCFG_PERDIS 0x1000 7278c2ecf20Sopenharmony_ci#define DCFG_MRWAIT 0x0400 7288c2ecf20Sopenharmony_ci#define DCFG_MWWAIT 0x0200 7298c2ecf20Sopenharmony_ci#define DCFG_LATMEN 0x0100 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_ci/* 7328c2ecf20Sopenharmony_ci * Bits in the MCFG0 register 7338c2ecf20Sopenharmony_ci */ 7348c2ecf20Sopenharmony_ci 7358c2ecf20Sopenharmony_ci#define MCFG_RXARB 0x0080 7368c2ecf20Sopenharmony_ci#define MCFG_RFT1 0x0020 7378c2ecf20Sopenharmony_ci#define MCFG_RFT0 0x0010 7388c2ecf20Sopenharmony_ci#define MCFG_LOWTHOPT 0x0008 7398c2ecf20Sopenharmony_ci#define MCFG_PQEN 0x0004 7408c2ecf20Sopenharmony_ci#define MCFG_RTGOPT 0x0002 7418c2ecf20Sopenharmony_ci#define MCFG_VIDFR 0x0001 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci/* 7448c2ecf20Sopenharmony_ci * Bits in the MCFG1 register 7458c2ecf20Sopenharmony_ci */ 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_ci#define MCFG_TXARB 0x8000 7488c2ecf20Sopenharmony_ci#define MCFG_TXQBK1 0x0800 7498c2ecf20Sopenharmony_ci#define MCFG_TXQBK0 0x0400 7508c2ecf20Sopenharmony_ci#define MCFG_TXQNOBK 0x0200 7518c2ecf20Sopenharmony_ci#define MCFG_SNAPOPT 0x0100 7528c2ecf20Sopenharmony_ci 7538c2ecf20Sopenharmony_ci/* 7548c2ecf20Sopenharmony_ci * Bits in the PMCC register 7558c2ecf20Sopenharmony_ci */ 7568c2ecf20Sopenharmony_ci 7578c2ecf20Sopenharmony_ci#define PMCC_DSI 0x80 7588c2ecf20Sopenharmony_ci#define PMCC_D2_DIS 0x40 7598c2ecf20Sopenharmony_ci#define PMCC_D1_DIS 0x20 7608c2ecf20Sopenharmony_ci#define PMCC_D3C_EN 0x10 7618c2ecf20Sopenharmony_ci#define PMCC_D3H_EN 0x08 7628c2ecf20Sopenharmony_ci#define PMCC_D2_EN 0x04 7638c2ecf20Sopenharmony_ci#define PMCC_D1_EN 0x02 7648c2ecf20Sopenharmony_ci#define PMCC_D0_EN 0x01 7658c2ecf20Sopenharmony_ci 7668c2ecf20Sopenharmony_ci/* 7678c2ecf20Sopenharmony_ci * Bits in STICKHW 7688c2ecf20Sopenharmony_ci */ 7698c2ecf20Sopenharmony_ci 7708c2ecf20Sopenharmony_ci#define STICKHW_SWPTAG 0x10 7718c2ecf20Sopenharmony_ci#define STICKHW_WOLSR 0x08 7728c2ecf20Sopenharmony_ci#define STICKHW_WOLEN 0x04 7738c2ecf20Sopenharmony_ci#define STICKHW_DS1 0x02 /* R/W by software/cfg cycle */ 7748c2ecf20Sopenharmony_ci#define STICKHW_DS0 0x01 /* suspend well DS write port */ 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_ci/* 7778c2ecf20Sopenharmony_ci * Bits in the MIBCR register 7788c2ecf20Sopenharmony_ci */ 7798c2ecf20Sopenharmony_ci 7808c2ecf20Sopenharmony_ci#define MIBCR_MIBISTOK 0x80 7818c2ecf20Sopenharmony_ci#define MIBCR_MIBISTGO 0x40 7828c2ecf20Sopenharmony_ci#define MIBCR_MIBINC 0x20 7838c2ecf20Sopenharmony_ci#define MIBCR_MIBHI 0x10 7848c2ecf20Sopenharmony_ci#define MIBCR_MIBFRZ 0x08 7858c2ecf20Sopenharmony_ci#define MIBCR_MIBFLSH 0x04 7868c2ecf20Sopenharmony_ci#define MIBCR_MPTRINI 0x02 7878c2ecf20Sopenharmony_ci#define MIBCR_MIBCLR 0x01 7888c2ecf20Sopenharmony_ci 7898c2ecf20Sopenharmony_ci/* 7908c2ecf20Sopenharmony_ci * Bits in the EERSV register 7918c2ecf20Sopenharmony_ci */ 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci#define EERSV_BOOT_RPL ((u8) 0x01) /* Boot method selection for VT6110 */ 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_ci#define EERSV_BOOT_MASK ((u8) 0x06) 7968c2ecf20Sopenharmony_ci#define EERSV_BOOT_INT19 ((u8) 0x00) 7978c2ecf20Sopenharmony_ci#define EERSV_BOOT_INT18 ((u8) 0x02) 7988c2ecf20Sopenharmony_ci#define EERSV_BOOT_LOCAL ((u8) 0x04) 7998c2ecf20Sopenharmony_ci#define EERSV_BOOT_BEV ((u8) 0x06) 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_ci 8028c2ecf20Sopenharmony_ci/* 8038c2ecf20Sopenharmony_ci * Bits in BPCMD 8048c2ecf20Sopenharmony_ci */ 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_ci#define BPCMD_BPDNE 0x80 8078c2ecf20Sopenharmony_ci#define BPCMD_EBPWR 0x02 8088c2ecf20Sopenharmony_ci#define BPCMD_EBPRD 0x01 8098c2ecf20Sopenharmony_ci 8108c2ecf20Sopenharmony_ci/* 8118c2ecf20Sopenharmony_ci * Bits in the EECSR register 8128c2ecf20Sopenharmony_ci */ 8138c2ecf20Sopenharmony_ci 8148c2ecf20Sopenharmony_ci#define EECSR_EMBP 0x40 /* eeprom embedded programming */ 8158c2ecf20Sopenharmony_ci#define EECSR_RELOAD 0x20 /* eeprom content reload */ 8168c2ecf20Sopenharmony_ci#define EECSR_DPM 0x10 /* eeprom direct programming */ 8178c2ecf20Sopenharmony_ci#define EECSR_ECS 0x08 /* eeprom CS pin */ 8188c2ecf20Sopenharmony_ci#define EECSR_ECK 0x04 /* eeprom CK pin */ 8198c2ecf20Sopenharmony_ci#define EECSR_EDI 0x02 /* eeprom DI pin */ 8208c2ecf20Sopenharmony_ci#define EECSR_EDO 0x01 /* eeprom DO pin */ 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_ci/* 8238c2ecf20Sopenharmony_ci * Bits in the EMBCMD register 8248c2ecf20Sopenharmony_ci */ 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_ci#define EMBCMD_EDONE 0x80 8278c2ecf20Sopenharmony_ci#define EMBCMD_EWDIS 0x08 8288c2ecf20Sopenharmony_ci#define EMBCMD_EWEN 0x04 8298c2ecf20Sopenharmony_ci#define EMBCMD_EWR 0x02 8308c2ecf20Sopenharmony_ci#define EMBCMD_ERD 0x01 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ci/* 8338c2ecf20Sopenharmony_ci * Bits in TESTCFG register 8348c2ecf20Sopenharmony_ci */ 8358c2ecf20Sopenharmony_ci 8368c2ecf20Sopenharmony_ci#define TESTCFG_HBDIS 0x80 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci/* 8398c2ecf20Sopenharmony_ci * Bits in CHIPGCR register 8408c2ecf20Sopenharmony_ci */ 8418c2ecf20Sopenharmony_ci 8428c2ecf20Sopenharmony_ci#define CHIPGCR_FCGMII 0x80 /* force GMII (else MII only) */ 8438c2ecf20Sopenharmony_ci#define CHIPGCR_FCFDX 0x40 /* force full duplex */ 8448c2ecf20Sopenharmony_ci#define CHIPGCR_FCRESV 0x20 8458c2ecf20Sopenharmony_ci#define CHIPGCR_FCMODE 0x10 /* enable MAC forced mode */ 8468c2ecf20Sopenharmony_ci#define CHIPGCR_LPSOPT 0x08 8478c2ecf20Sopenharmony_ci#define CHIPGCR_TM1US 0x04 8488c2ecf20Sopenharmony_ci#define CHIPGCR_TM0US 0x02 8498c2ecf20Sopenharmony_ci#define CHIPGCR_PHYINTEN 0x01 8508c2ecf20Sopenharmony_ci 8518c2ecf20Sopenharmony_ci/* 8528c2ecf20Sopenharmony_ci * Bits in WOLCR0 8538c2ecf20Sopenharmony_ci */ 8548c2ecf20Sopenharmony_ci 8558c2ecf20Sopenharmony_ci#define WOLCR_MSWOLEN7 0x0080 /* enable pattern match filtering */ 8568c2ecf20Sopenharmony_ci#define WOLCR_MSWOLEN6 0x0040 8578c2ecf20Sopenharmony_ci#define WOLCR_MSWOLEN5 0x0020 8588c2ecf20Sopenharmony_ci#define WOLCR_MSWOLEN4 0x0010 8598c2ecf20Sopenharmony_ci#define WOLCR_MSWOLEN3 0x0008 8608c2ecf20Sopenharmony_ci#define WOLCR_MSWOLEN2 0x0004 8618c2ecf20Sopenharmony_ci#define WOLCR_MSWOLEN1 0x0002 8628c2ecf20Sopenharmony_ci#define WOLCR_MSWOLEN0 0x0001 8638c2ecf20Sopenharmony_ci#define WOLCR_ARP_EN 0x0001 8648c2ecf20Sopenharmony_ci 8658c2ecf20Sopenharmony_ci/* 8668c2ecf20Sopenharmony_ci * Bits in WOLCR1 8678c2ecf20Sopenharmony_ci */ 8688c2ecf20Sopenharmony_ci 8698c2ecf20Sopenharmony_ci#define WOLCR_LINKOFF_EN 0x0800 /* link off detected enable */ 8708c2ecf20Sopenharmony_ci#define WOLCR_LINKON_EN 0x0400 /* link on detected enable */ 8718c2ecf20Sopenharmony_ci#define WOLCR_MAGIC_EN 0x0200 /* magic packet filter enable */ 8728c2ecf20Sopenharmony_ci#define WOLCR_UNICAST_EN 0x0100 /* unicast filter enable */ 8738c2ecf20Sopenharmony_ci 8748c2ecf20Sopenharmony_ci 8758c2ecf20Sopenharmony_ci/* 8768c2ecf20Sopenharmony_ci * Bits in PWCFG 8778c2ecf20Sopenharmony_ci */ 8788c2ecf20Sopenharmony_ci 8798c2ecf20Sopenharmony_ci#define PWCFG_PHYPWOPT 0x80 /* internal MII I/F timing */ 8808c2ecf20Sopenharmony_ci#define PWCFG_PCISTICK 0x40 /* PCI sticky R/W enable */ 8818c2ecf20Sopenharmony_ci#define PWCFG_WOLTYPE 0x20 /* pulse(1) or button (0) */ 8828c2ecf20Sopenharmony_ci#define PWCFG_LEGCY_WOL 0x10 8838c2ecf20Sopenharmony_ci#define PWCFG_PMCSR_PME_SR 0x08 8848c2ecf20Sopenharmony_ci#define PWCFG_PMCSR_PME_EN 0x04 /* control by PCISTICK */ 8858c2ecf20Sopenharmony_ci#define PWCFG_LEGACY_WOLSR 0x02 /* Legacy WOL_SR shadow */ 8868c2ecf20Sopenharmony_ci#define PWCFG_LEGACY_WOLEN 0x01 /* Legacy WOL_EN shadow */ 8878c2ecf20Sopenharmony_ci 8888c2ecf20Sopenharmony_ci/* 8898c2ecf20Sopenharmony_ci * Bits in WOLCFG 8908c2ecf20Sopenharmony_ci */ 8918c2ecf20Sopenharmony_ci 8928c2ecf20Sopenharmony_ci#define WOLCFG_PMEOVR 0x80 /* for legacy use, force PMEEN always */ 8938c2ecf20Sopenharmony_ci#define WOLCFG_SAM 0x20 /* accept multicast case reset, default=0 */ 8948c2ecf20Sopenharmony_ci#define WOLCFG_SAB 0x10 /* accept broadcast case reset, default=0 */ 8958c2ecf20Sopenharmony_ci#define WOLCFG_SMIIACC 0x08 /* ?? */ 8968c2ecf20Sopenharmony_ci#define WOLCFG_SGENWH 0x02 8978c2ecf20Sopenharmony_ci#define WOLCFG_PHYINTEN 0x01 /* 0:PHYINT trigger enable, 1:use internal MII 8988c2ecf20Sopenharmony_ci to report status change */ 8998c2ecf20Sopenharmony_ci/* 9008c2ecf20Sopenharmony_ci * Bits in WOLSR1 9018c2ecf20Sopenharmony_ci */ 9028c2ecf20Sopenharmony_ci 9038c2ecf20Sopenharmony_ci#define WOLSR_LINKOFF_INT 0x0800 9048c2ecf20Sopenharmony_ci#define WOLSR_LINKON_INT 0x0400 9058c2ecf20Sopenharmony_ci#define WOLSR_MAGIC_INT 0x0200 9068c2ecf20Sopenharmony_ci#define WOLSR_UNICAST_INT 0x0100 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_ci/* 9098c2ecf20Sopenharmony_ci * Ethernet address filter type 9108c2ecf20Sopenharmony_ci */ 9118c2ecf20Sopenharmony_ci 9128c2ecf20Sopenharmony_ci#define PKT_TYPE_NONE 0x0000 /* Turn off receiver */ 9138c2ecf20Sopenharmony_ci#define PKT_TYPE_DIRECTED 0x0001 /* obselete, directed address is always accepted */ 9148c2ecf20Sopenharmony_ci#define PKT_TYPE_MULTICAST 0x0002 9158c2ecf20Sopenharmony_ci#define PKT_TYPE_ALL_MULTICAST 0x0004 9168c2ecf20Sopenharmony_ci#define PKT_TYPE_BROADCAST 0x0008 9178c2ecf20Sopenharmony_ci#define PKT_TYPE_PROMISCUOUS 0x0020 9188c2ecf20Sopenharmony_ci#define PKT_TYPE_LONG 0x2000 /* NOTE.... the definition of LONG is >2048 bytes in our chip */ 9198c2ecf20Sopenharmony_ci#define PKT_TYPE_RUNT 0x4000 9208c2ecf20Sopenharmony_ci#define PKT_TYPE_ERROR 0x8000 /* Accept error packets, e.g. CRC error */ 9218c2ecf20Sopenharmony_ci 9228c2ecf20Sopenharmony_ci/* 9238c2ecf20Sopenharmony_ci * Loopback mode 9248c2ecf20Sopenharmony_ci */ 9258c2ecf20Sopenharmony_ci 9268c2ecf20Sopenharmony_ci#define MAC_LB_NONE 0x00 9278c2ecf20Sopenharmony_ci#define MAC_LB_INTERNAL 0x01 9288c2ecf20Sopenharmony_ci#define MAC_LB_EXTERNAL 0x02 9298c2ecf20Sopenharmony_ci 9308c2ecf20Sopenharmony_ci/* 9318c2ecf20Sopenharmony_ci * Enabled mask value of irq 9328c2ecf20Sopenharmony_ci */ 9338c2ecf20Sopenharmony_ci 9348c2ecf20Sopenharmony_ci#if defined(_SIM) 9358c2ecf20Sopenharmony_ci#define IMR_MASK_VALUE 0x0033FF0FUL /* initial value of IMR 9368c2ecf20Sopenharmony_ci set IMR0 to 0x0F according to spec */ 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci#else 9398c2ecf20Sopenharmony_ci#define IMR_MASK_VALUE 0x0013FB0FUL /* initial value of IMR 9408c2ecf20Sopenharmony_ci ignore MIBFI,RACEI to 9418c2ecf20Sopenharmony_ci reduce intr. frequency 9428c2ecf20Sopenharmony_ci NOTE.... do not enable NoBuf int mask at driver driver 9438c2ecf20Sopenharmony_ci when (1) NoBuf -> RxThreshold = SF 9448c2ecf20Sopenharmony_ci (2) OK -> RxThreshold = original value 9458c2ecf20Sopenharmony_ci */ 9468c2ecf20Sopenharmony_ci#endif 9478c2ecf20Sopenharmony_ci 9488c2ecf20Sopenharmony_ci/* 9498c2ecf20Sopenharmony_ci * Revision id 9508c2ecf20Sopenharmony_ci */ 9518c2ecf20Sopenharmony_ci 9528c2ecf20Sopenharmony_ci#define REV_ID_VT3119_A0 0x00 9538c2ecf20Sopenharmony_ci#define REV_ID_VT3119_A1 0x01 9548c2ecf20Sopenharmony_ci#define REV_ID_VT3216_A0 0x10 9558c2ecf20Sopenharmony_ci 9568c2ecf20Sopenharmony_ci/* 9578c2ecf20Sopenharmony_ci * Max time out delay time 9588c2ecf20Sopenharmony_ci */ 9598c2ecf20Sopenharmony_ci 9608c2ecf20Sopenharmony_ci#define W_MAX_TIMEOUT 0x0FFFU 9618c2ecf20Sopenharmony_ci 9628c2ecf20Sopenharmony_ci 9638c2ecf20Sopenharmony_ci/* 9648c2ecf20Sopenharmony_ci * MAC registers as a structure. Cannot be directly accessed this 9658c2ecf20Sopenharmony_ci * way but generates offsets for readl/writel() calls 9668c2ecf20Sopenharmony_ci */ 9678c2ecf20Sopenharmony_ci 9688c2ecf20Sopenharmony_cistruct mac_regs { 9698c2ecf20Sopenharmony_ci volatile u8 PAR[6]; /* 0x00 */ 9708c2ecf20Sopenharmony_ci volatile u8 RCR; 9718c2ecf20Sopenharmony_ci volatile u8 TCR; 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_ci volatile __le32 CR0Set; /* 0x08 */ 9748c2ecf20Sopenharmony_ci volatile __le32 CR0Clr; /* 0x0C */ 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_ci volatile u8 MARCAM[8]; /* 0x10 */ 9778c2ecf20Sopenharmony_ci 9788c2ecf20Sopenharmony_ci volatile __le32 DecBaseHi; /* 0x18 */ 9798c2ecf20Sopenharmony_ci volatile __le16 DbfBaseHi; /* 0x1C */ 9808c2ecf20Sopenharmony_ci volatile __le16 reserved_1E; 9818c2ecf20Sopenharmony_ci 9828c2ecf20Sopenharmony_ci volatile __le16 ISRCTL; /* 0x20 */ 9838c2ecf20Sopenharmony_ci volatile u8 TXESR; 9848c2ecf20Sopenharmony_ci volatile u8 RXESR; 9858c2ecf20Sopenharmony_ci 9868c2ecf20Sopenharmony_ci volatile __le32 ISR; /* 0x24 */ 9878c2ecf20Sopenharmony_ci volatile __le32 IMR; 9888c2ecf20Sopenharmony_ci 9898c2ecf20Sopenharmony_ci volatile __le32 TDStatusPort; /* 0x2C */ 9908c2ecf20Sopenharmony_ci 9918c2ecf20Sopenharmony_ci volatile __le16 TDCSRSet; /* 0x30 */ 9928c2ecf20Sopenharmony_ci volatile u8 RDCSRSet; 9938c2ecf20Sopenharmony_ci volatile u8 reserved_33; 9948c2ecf20Sopenharmony_ci volatile __le16 TDCSRClr; 9958c2ecf20Sopenharmony_ci volatile u8 RDCSRClr; 9968c2ecf20Sopenharmony_ci volatile u8 reserved_37; 9978c2ecf20Sopenharmony_ci 9988c2ecf20Sopenharmony_ci volatile __le32 RDBaseLo; /* 0x38 */ 9998c2ecf20Sopenharmony_ci volatile __le16 RDIdx; /* 0x3C */ 10008c2ecf20Sopenharmony_ci volatile u8 TQETMR; /* 0x3E, VT3216 and above only */ 10018c2ecf20Sopenharmony_ci volatile u8 RQETMR; /* 0x3F, VT3216 and above only */ 10028c2ecf20Sopenharmony_ci 10038c2ecf20Sopenharmony_ci volatile __le32 TDBaseLo[4]; /* 0x40 */ 10048c2ecf20Sopenharmony_ci 10058c2ecf20Sopenharmony_ci volatile __le16 RDCSize; /* 0x50 */ 10068c2ecf20Sopenharmony_ci volatile __le16 TDCSize; /* 0x52 */ 10078c2ecf20Sopenharmony_ci volatile __le16 TDIdx[4]; /* 0x54 */ 10088c2ecf20Sopenharmony_ci volatile __le16 tx_pause_timer; /* 0x5C */ 10098c2ecf20Sopenharmony_ci volatile __le16 RBRDU; /* 0x5E */ 10108c2ecf20Sopenharmony_ci 10118c2ecf20Sopenharmony_ci volatile __le32 FIFOTest0; /* 0x60 */ 10128c2ecf20Sopenharmony_ci volatile __le32 FIFOTest1; /* 0x64 */ 10138c2ecf20Sopenharmony_ci 10148c2ecf20Sopenharmony_ci volatile u8 CAMADDR; /* 0x68 */ 10158c2ecf20Sopenharmony_ci volatile u8 CAMCR; /* 0x69 */ 10168c2ecf20Sopenharmony_ci volatile u8 GFTEST; /* 0x6A */ 10178c2ecf20Sopenharmony_ci volatile u8 FTSTCMD; /* 0x6B */ 10188c2ecf20Sopenharmony_ci 10198c2ecf20Sopenharmony_ci volatile u8 MIICFG; /* 0x6C */ 10208c2ecf20Sopenharmony_ci volatile u8 MIISR; 10218c2ecf20Sopenharmony_ci volatile u8 PHYSR0; 10228c2ecf20Sopenharmony_ci volatile u8 PHYSR1; 10238c2ecf20Sopenharmony_ci volatile u8 MIICR; 10248c2ecf20Sopenharmony_ci volatile u8 MIIADR; 10258c2ecf20Sopenharmony_ci volatile __le16 MIIDATA; 10268c2ecf20Sopenharmony_ci 10278c2ecf20Sopenharmony_ci volatile __le16 SoftTimer0; /* 0x74 */ 10288c2ecf20Sopenharmony_ci volatile __le16 SoftTimer1; 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci volatile u8 CFGA; /* 0x78 */ 10318c2ecf20Sopenharmony_ci volatile u8 CFGB; 10328c2ecf20Sopenharmony_ci volatile u8 CFGC; 10338c2ecf20Sopenharmony_ci volatile u8 CFGD; 10348c2ecf20Sopenharmony_ci 10358c2ecf20Sopenharmony_ci volatile __le16 DCFG; /* 0x7C */ 10368c2ecf20Sopenharmony_ci volatile __le16 MCFG; 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_ci volatile u8 TBIST; /* 0x80 */ 10398c2ecf20Sopenharmony_ci volatile u8 RBIST; 10408c2ecf20Sopenharmony_ci volatile u8 PMCPORT; 10418c2ecf20Sopenharmony_ci volatile u8 STICKHW; 10428c2ecf20Sopenharmony_ci 10438c2ecf20Sopenharmony_ci volatile u8 MIBCR; /* 0x84 */ 10448c2ecf20Sopenharmony_ci volatile u8 reserved_85; 10458c2ecf20Sopenharmony_ci volatile u8 rev_id; 10468c2ecf20Sopenharmony_ci volatile u8 PORSTS; 10478c2ecf20Sopenharmony_ci 10488c2ecf20Sopenharmony_ci volatile __le32 MIBData; /* 0x88 */ 10498c2ecf20Sopenharmony_ci 10508c2ecf20Sopenharmony_ci volatile __le16 EEWrData; 10518c2ecf20Sopenharmony_ci 10528c2ecf20Sopenharmony_ci volatile u8 reserved_8E; 10538c2ecf20Sopenharmony_ci volatile u8 BPMDWr; 10548c2ecf20Sopenharmony_ci volatile u8 BPCMD; 10558c2ecf20Sopenharmony_ci volatile u8 BPMDRd; 10568c2ecf20Sopenharmony_ci 10578c2ecf20Sopenharmony_ci volatile u8 EECHKSUM; /* 0x92 */ 10588c2ecf20Sopenharmony_ci volatile u8 EECSR; 10598c2ecf20Sopenharmony_ci 10608c2ecf20Sopenharmony_ci volatile __le16 EERdData; /* 0x94 */ 10618c2ecf20Sopenharmony_ci volatile u8 EADDR; 10628c2ecf20Sopenharmony_ci volatile u8 EMBCMD; 10638c2ecf20Sopenharmony_ci 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci volatile u8 JMPSR0; /* 0x98 */ 10668c2ecf20Sopenharmony_ci volatile u8 JMPSR1; 10678c2ecf20Sopenharmony_ci volatile u8 JMPSR2; 10688c2ecf20Sopenharmony_ci volatile u8 JMPSR3; 10698c2ecf20Sopenharmony_ci volatile u8 CHIPGSR; /* 0x9C */ 10708c2ecf20Sopenharmony_ci volatile u8 TESTCFG; 10718c2ecf20Sopenharmony_ci volatile u8 DEBUG; 10728c2ecf20Sopenharmony_ci volatile u8 CHIPGCR; 10738c2ecf20Sopenharmony_ci 10748c2ecf20Sopenharmony_ci volatile __le16 WOLCRSet; /* 0xA0 */ 10758c2ecf20Sopenharmony_ci volatile u8 PWCFGSet; 10768c2ecf20Sopenharmony_ci volatile u8 WOLCFGSet; 10778c2ecf20Sopenharmony_ci 10788c2ecf20Sopenharmony_ci volatile __le16 WOLCRClr; /* 0xA4 */ 10798c2ecf20Sopenharmony_ci volatile u8 PWCFGCLR; 10808c2ecf20Sopenharmony_ci volatile u8 WOLCFGClr; 10818c2ecf20Sopenharmony_ci 10828c2ecf20Sopenharmony_ci volatile __le16 WOLSRSet; /* 0xA8 */ 10838c2ecf20Sopenharmony_ci volatile __le16 reserved_AA; 10848c2ecf20Sopenharmony_ci 10858c2ecf20Sopenharmony_ci volatile __le16 WOLSRClr; /* 0xAC */ 10868c2ecf20Sopenharmony_ci volatile __le16 reserved_AE; 10878c2ecf20Sopenharmony_ci 10888c2ecf20Sopenharmony_ci volatile __le16 PatternCRC[8]; /* 0xB0 */ 10898c2ecf20Sopenharmony_ci volatile __le32 ByteMask[4][4]; /* 0xC0 */ 10908c2ecf20Sopenharmony_ci}; 10918c2ecf20Sopenharmony_ci 10928c2ecf20Sopenharmony_ci 10938c2ecf20Sopenharmony_cienum hw_mib { 10948c2ecf20Sopenharmony_ci HW_MIB_ifRxAllPkts = 0, 10958c2ecf20Sopenharmony_ci HW_MIB_ifRxOkPkts, 10968c2ecf20Sopenharmony_ci HW_MIB_ifTxOkPkts, 10978c2ecf20Sopenharmony_ci HW_MIB_ifRxErrorPkts, 10988c2ecf20Sopenharmony_ci HW_MIB_ifRxRuntOkPkt, 10998c2ecf20Sopenharmony_ci HW_MIB_ifRxRuntErrPkt, 11008c2ecf20Sopenharmony_ci HW_MIB_ifRx64Pkts, 11018c2ecf20Sopenharmony_ci HW_MIB_ifTx64Pkts, 11028c2ecf20Sopenharmony_ci HW_MIB_ifRx65To127Pkts, 11038c2ecf20Sopenharmony_ci HW_MIB_ifTx65To127Pkts, 11048c2ecf20Sopenharmony_ci HW_MIB_ifRx128To255Pkts, 11058c2ecf20Sopenharmony_ci HW_MIB_ifTx128To255Pkts, 11068c2ecf20Sopenharmony_ci HW_MIB_ifRx256To511Pkts, 11078c2ecf20Sopenharmony_ci HW_MIB_ifTx256To511Pkts, 11088c2ecf20Sopenharmony_ci HW_MIB_ifRx512To1023Pkts, 11098c2ecf20Sopenharmony_ci HW_MIB_ifTx512To1023Pkts, 11108c2ecf20Sopenharmony_ci HW_MIB_ifRx1024To1518Pkts, 11118c2ecf20Sopenharmony_ci HW_MIB_ifTx1024To1518Pkts, 11128c2ecf20Sopenharmony_ci HW_MIB_ifTxEtherCollisions, 11138c2ecf20Sopenharmony_ci HW_MIB_ifRxPktCRCE, 11148c2ecf20Sopenharmony_ci HW_MIB_ifRxJumboPkts, 11158c2ecf20Sopenharmony_ci HW_MIB_ifTxJumboPkts, 11168c2ecf20Sopenharmony_ci HW_MIB_ifRxMacControlFrames, 11178c2ecf20Sopenharmony_ci HW_MIB_ifTxMacControlFrames, 11188c2ecf20Sopenharmony_ci HW_MIB_ifRxPktFAE, 11198c2ecf20Sopenharmony_ci HW_MIB_ifRxLongOkPkt, 11208c2ecf20Sopenharmony_ci HW_MIB_ifRxLongPktErrPkt, 11218c2ecf20Sopenharmony_ci HW_MIB_ifTXSQEErrors, 11228c2ecf20Sopenharmony_ci HW_MIB_ifRxNobuf, 11238c2ecf20Sopenharmony_ci HW_MIB_ifRxSymbolErrors, 11248c2ecf20Sopenharmony_ci HW_MIB_ifInRangeLengthErrors, 11258c2ecf20Sopenharmony_ci HW_MIB_ifLateCollisions, 11268c2ecf20Sopenharmony_ci HW_MIB_SIZE 11278c2ecf20Sopenharmony_ci}; 11288c2ecf20Sopenharmony_ci 11298c2ecf20Sopenharmony_cienum chip_type { 11308c2ecf20Sopenharmony_ci CHIP_TYPE_VT6110 = 1, 11318c2ecf20Sopenharmony_ci}; 11328c2ecf20Sopenharmony_ci 11338c2ecf20Sopenharmony_cistruct velocity_info_tbl { 11348c2ecf20Sopenharmony_ci enum chip_type chip_id; 11358c2ecf20Sopenharmony_ci const char *name; 11368c2ecf20Sopenharmony_ci int txqueue; 11378c2ecf20Sopenharmony_ci u32 flags; 11388c2ecf20Sopenharmony_ci}; 11398c2ecf20Sopenharmony_ci 11408c2ecf20Sopenharmony_ci#define mac_hw_mibs_init(regs) {\ 11418c2ecf20Sopenharmony_ci BYTE_REG_BITS_ON(MIBCR_MIBFRZ,&((regs)->MIBCR));\ 11428c2ecf20Sopenharmony_ci BYTE_REG_BITS_ON(MIBCR_MIBCLR,&((regs)->MIBCR));\ 11438c2ecf20Sopenharmony_ci do {}\ 11448c2ecf20Sopenharmony_ci while (BYTE_REG_BITS_IS_ON(MIBCR_MIBCLR,&((regs)->MIBCR)));\ 11458c2ecf20Sopenharmony_ci BYTE_REG_BITS_OFF(MIBCR_MIBFRZ,&((regs)->MIBCR));\ 11468c2ecf20Sopenharmony_ci} 11478c2ecf20Sopenharmony_ci 11488c2ecf20Sopenharmony_ci#define mac_read_isr(regs) readl(&((regs)->ISR)) 11498c2ecf20Sopenharmony_ci#define mac_write_isr(regs, x) writel((x),&((regs)->ISR)) 11508c2ecf20Sopenharmony_ci#define mac_clear_isr(regs) writel(0xffffffffL,&((regs)->ISR)) 11518c2ecf20Sopenharmony_ci 11528c2ecf20Sopenharmony_ci#define mac_write_int_mask(mask, regs) writel((mask),&((regs)->IMR)); 11538c2ecf20Sopenharmony_ci#define mac_disable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Clr)) 11548c2ecf20Sopenharmony_ci#define mac_enable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Set)) 11558c2ecf20Sopenharmony_ci 11568c2ecf20Sopenharmony_ci#define mac_set_dma_length(regs, n) {\ 11578c2ecf20Sopenharmony_ci BYTE_REG_BITS_SET((n),0x07,&((regs)->DCFG));\ 11588c2ecf20Sopenharmony_ci} 11598c2ecf20Sopenharmony_ci 11608c2ecf20Sopenharmony_ci#define mac_set_rx_thresh(regs, n) {\ 11618c2ecf20Sopenharmony_ci BYTE_REG_BITS_SET((n),(MCFG_RFT0|MCFG_RFT1),&((regs)->MCFG));\ 11628c2ecf20Sopenharmony_ci} 11638c2ecf20Sopenharmony_ci 11648c2ecf20Sopenharmony_ci#define mac_rx_queue_run(regs) {\ 11658c2ecf20Sopenharmony_ci writeb(TRDCSR_RUN, &((regs)->RDCSRSet));\ 11668c2ecf20Sopenharmony_ci} 11678c2ecf20Sopenharmony_ci 11688c2ecf20Sopenharmony_ci#define mac_rx_queue_wake(regs) {\ 11698c2ecf20Sopenharmony_ci writeb(TRDCSR_WAK, &((regs)->RDCSRSet));\ 11708c2ecf20Sopenharmony_ci} 11718c2ecf20Sopenharmony_ci 11728c2ecf20Sopenharmony_ci#define mac_tx_queue_run(regs, n) {\ 11738c2ecf20Sopenharmony_ci writew(TRDCSR_RUN<<((n)*4),&((regs)->TDCSRSet));\ 11748c2ecf20Sopenharmony_ci} 11758c2ecf20Sopenharmony_ci 11768c2ecf20Sopenharmony_ci#define mac_tx_queue_wake(regs, n) {\ 11778c2ecf20Sopenharmony_ci writew(TRDCSR_WAK<<(n*4),&((regs)->TDCSRSet));\ 11788c2ecf20Sopenharmony_ci} 11798c2ecf20Sopenharmony_ci 11808c2ecf20Sopenharmony_cistatic inline void mac_eeprom_reload(struct mac_regs __iomem * regs) { 11818c2ecf20Sopenharmony_ci int i=0; 11828c2ecf20Sopenharmony_ci 11838c2ecf20Sopenharmony_ci BYTE_REG_BITS_ON(EECSR_RELOAD,&(regs->EECSR)); 11848c2ecf20Sopenharmony_ci do { 11858c2ecf20Sopenharmony_ci udelay(10); 11868c2ecf20Sopenharmony_ci if (i++>0x1000) 11878c2ecf20Sopenharmony_ci break; 11888c2ecf20Sopenharmony_ci } while (BYTE_REG_BITS_IS_ON(EECSR_RELOAD,&(regs->EECSR))); 11898c2ecf20Sopenharmony_ci} 11908c2ecf20Sopenharmony_ci 11918c2ecf20Sopenharmony_ci/* 11928c2ecf20Sopenharmony_ci * Header for WOL definitions. Used to compute hashes 11938c2ecf20Sopenharmony_ci */ 11948c2ecf20Sopenharmony_ci 11958c2ecf20Sopenharmony_citypedef u8 MCAM_ADDR[ETH_ALEN]; 11968c2ecf20Sopenharmony_ci 11978c2ecf20Sopenharmony_cistruct arp_packet { 11988c2ecf20Sopenharmony_ci u8 dest_mac[ETH_ALEN]; 11998c2ecf20Sopenharmony_ci u8 src_mac[ETH_ALEN]; 12008c2ecf20Sopenharmony_ci __be16 type; 12018c2ecf20Sopenharmony_ci __be16 ar_hrd; 12028c2ecf20Sopenharmony_ci __be16 ar_pro; 12038c2ecf20Sopenharmony_ci u8 ar_hln; 12048c2ecf20Sopenharmony_ci u8 ar_pln; 12058c2ecf20Sopenharmony_ci __be16 ar_op; 12068c2ecf20Sopenharmony_ci u8 ar_sha[ETH_ALEN]; 12078c2ecf20Sopenharmony_ci u8 ar_sip[4]; 12088c2ecf20Sopenharmony_ci u8 ar_tha[ETH_ALEN]; 12098c2ecf20Sopenharmony_ci u8 ar_tip[4]; 12108c2ecf20Sopenharmony_ci} __packed; 12118c2ecf20Sopenharmony_ci 12128c2ecf20Sopenharmony_cistruct _magic_packet { 12138c2ecf20Sopenharmony_ci u8 dest_mac[6]; 12148c2ecf20Sopenharmony_ci u8 src_mac[6]; 12158c2ecf20Sopenharmony_ci __be16 type; 12168c2ecf20Sopenharmony_ci u8 MAC[16][6]; 12178c2ecf20Sopenharmony_ci u8 password[6]; 12188c2ecf20Sopenharmony_ci} __packed; 12198c2ecf20Sopenharmony_ci 12208c2ecf20Sopenharmony_ci/* 12218c2ecf20Sopenharmony_ci * Store for chip context when saving and restoring status. Not 12228c2ecf20Sopenharmony_ci * all fields are saved/restored currently. 12238c2ecf20Sopenharmony_ci */ 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_cistruct velocity_context { 12268c2ecf20Sopenharmony_ci u8 mac_reg[256]; 12278c2ecf20Sopenharmony_ci MCAM_ADDR cam_addr[MCAM_SIZE]; 12288c2ecf20Sopenharmony_ci u16 vcam[VCAM_SIZE]; 12298c2ecf20Sopenharmony_ci u32 cammask[2]; 12308c2ecf20Sopenharmony_ci u32 patcrc[2]; 12318c2ecf20Sopenharmony_ci u32 pattern[8]; 12328c2ecf20Sopenharmony_ci}; 12338c2ecf20Sopenharmony_ci 12348c2ecf20Sopenharmony_ci/* 12358c2ecf20Sopenharmony_ci * Registers in the MII (offset unit is WORD) 12368c2ecf20Sopenharmony_ci */ 12378c2ecf20Sopenharmony_ci 12388c2ecf20Sopenharmony_ci// Marvell 88E1000/88E1000S 12398c2ecf20Sopenharmony_ci#define MII_REG_PSCR 0x10 // PHY specific control register 12408c2ecf20Sopenharmony_ci 12418c2ecf20Sopenharmony_ci// 12428c2ecf20Sopenharmony_ci// Bits in the Silicon revision register 12438c2ecf20Sopenharmony_ci// 12448c2ecf20Sopenharmony_ci 12458c2ecf20Sopenharmony_ci#define TCSR_ECHODIS 0x2000 // 12468c2ecf20Sopenharmony_ci#define AUXCR_MDPPS 0x0004 // 12478c2ecf20Sopenharmony_ci 12488c2ecf20Sopenharmony_ci// Bits in the PLED register 12498c2ecf20Sopenharmony_ci#define PLED_LALBE 0x0004 // 12508c2ecf20Sopenharmony_ci 12518c2ecf20Sopenharmony_ci// Marvell 88E1000/88E1000S Bits in the PHY specific control register (10h) 12528c2ecf20Sopenharmony_ci#define PSCR_ACRSTX 0x0800 // Assert CRS on Transmit 12538c2ecf20Sopenharmony_ci 12548c2ecf20Sopenharmony_ci#define PHYID_CICADA_CS8201 0x000FC410UL 12558c2ecf20Sopenharmony_ci#define PHYID_VT3216_32BIT 0x000FC610UL 12568c2ecf20Sopenharmony_ci#define PHYID_VT3216_64BIT 0x000FC600UL 12578c2ecf20Sopenharmony_ci#define PHYID_MARVELL_1000 0x01410C50UL 12588c2ecf20Sopenharmony_ci#define PHYID_MARVELL_1000S 0x01410C40UL 12598c2ecf20Sopenharmony_ci#define PHYID_ICPLUS_IP101A 0x02430C54UL 12608c2ecf20Sopenharmony_ci#define PHYID_REV_ID_MASK 0x0000000FUL 12618c2ecf20Sopenharmony_ci 12628c2ecf20Sopenharmony_ci#define PHYID_GET_PHY_ID(i) ((i) & ~PHYID_REV_ID_MASK) 12638c2ecf20Sopenharmony_ci 12648c2ecf20Sopenharmony_ci#define MII_REG_BITS_ON(x,i,p) do {\ 12658c2ecf20Sopenharmony_ci u16 w;\ 12668c2ecf20Sopenharmony_ci velocity_mii_read((p),(i),&(w));\ 12678c2ecf20Sopenharmony_ci (w)|=(x);\ 12688c2ecf20Sopenharmony_ci velocity_mii_write((p),(i),(w));\ 12698c2ecf20Sopenharmony_ci} while (0) 12708c2ecf20Sopenharmony_ci 12718c2ecf20Sopenharmony_ci#define MII_REG_BITS_OFF(x,i,p) do {\ 12728c2ecf20Sopenharmony_ci u16 w;\ 12738c2ecf20Sopenharmony_ci velocity_mii_read((p),(i),&(w));\ 12748c2ecf20Sopenharmony_ci (w)&=(~(x));\ 12758c2ecf20Sopenharmony_ci velocity_mii_write((p),(i),(w));\ 12768c2ecf20Sopenharmony_ci} while (0) 12778c2ecf20Sopenharmony_ci 12788c2ecf20Sopenharmony_ci#define MII_REG_BITS_IS_ON(x,i,p) ({\ 12798c2ecf20Sopenharmony_ci u16 w;\ 12808c2ecf20Sopenharmony_ci velocity_mii_read((p),(i),&(w));\ 12818c2ecf20Sopenharmony_ci ((int) ((w) & (x)));}) 12828c2ecf20Sopenharmony_ci 12838c2ecf20Sopenharmony_ci#define MII_GET_PHY_ID(p) ({\ 12848c2ecf20Sopenharmony_ci u32 id;\ 12858c2ecf20Sopenharmony_ci velocity_mii_read((p),MII_PHYSID2,(u16 *) &id);\ 12868c2ecf20Sopenharmony_ci velocity_mii_read((p),MII_PHYSID1,((u16 *) &id)+1);\ 12878c2ecf20Sopenharmony_ci (id);}) 12888c2ecf20Sopenharmony_ci 12898c2ecf20Sopenharmony_ci#define VELOCITY_WOL_MAGIC 0x00000000UL 12908c2ecf20Sopenharmony_ci#define VELOCITY_WOL_PHY 0x00000001UL 12918c2ecf20Sopenharmony_ci#define VELOCITY_WOL_ARP 0x00000002UL 12928c2ecf20Sopenharmony_ci#define VELOCITY_WOL_UCAST 0x00000004UL 12938c2ecf20Sopenharmony_ci#define VELOCITY_WOL_BCAST 0x00000010UL 12948c2ecf20Sopenharmony_ci#define VELOCITY_WOL_MCAST 0x00000020UL 12958c2ecf20Sopenharmony_ci#define VELOCITY_WOL_MAGIC_SEC 0x00000040UL 12968c2ecf20Sopenharmony_ci 12978c2ecf20Sopenharmony_ci/* 12988c2ecf20Sopenharmony_ci * Flags for options 12998c2ecf20Sopenharmony_ci */ 13008c2ecf20Sopenharmony_ci 13018c2ecf20Sopenharmony_ci#define VELOCITY_FLAGS_TAGGING 0x00000001UL 13028c2ecf20Sopenharmony_ci#define VELOCITY_FLAGS_RX_CSUM 0x00000004UL 13038c2ecf20Sopenharmony_ci#define VELOCITY_FLAGS_IP_ALIGN 0x00000008UL 13048c2ecf20Sopenharmony_ci#define VELOCITY_FLAGS_VAL_PKT_LEN 0x00000010UL 13058c2ecf20Sopenharmony_ci 13068c2ecf20Sopenharmony_ci#define VELOCITY_FLAGS_FLOW_CTRL 0x01000000UL 13078c2ecf20Sopenharmony_ci 13088c2ecf20Sopenharmony_ci/* 13098c2ecf20Sopenharmony_ci * Flags for driver status 13108c2ecf20Sopenharmony_ci */ 13118c2ecf20Sopenharmony_ci 13128c2ecf20Sopenharmony_ci#define VELOCITY_FLAGS_OPENED 0x00010000UL 13138c2ecf20Sopenharmony_ci#define VELOCITY_FLAGS_VMNS_CONNECTED 0x00020000UL 13148c2ecf20Sopenharmony_ci#define VELOCITY_FLAGS_VMNS_COMMITTED 0x00040000UL 13158c2ecf20Sopenharmony_ci#define VELOCITY_FLAGS_WOL_ENABLED 0x00080000UL 13168c2ecf20Sopenharmony_ci 13178c2ecf20Sopenharmony_ci/* 13188c2ecf20Sopenharmony_ci * Flags for MII status 13198c2ecf20Sopenharmony_ci */ 13208c2ecf20Sopenharmony_ci 13218c2ecf20Sopenharmony_ci#define VELOCITY_LINK_FAIL 0x00000001UL 13228c2ecf20Sopenharmony_ci#define VELOCITY_SPEED_10 0x00000002UL 13238c2ecf20Sopenharmony_ci#define VELOCITY_SPEED_100 0x00000004UL 13248c2ecf20Sopenharmony_ci#define VELOCITY_SPEED_1000 0x00000008UL 13258c2ecf20Sopenharmony_ci#define VELOCITY_DUPLEX_FULL 0x00000010UL 13268c2ecf20Sopenharmony_ci#define VELOCITY_AUTONEG_ENABLE 0x00000020UL 13278c2ecf20Sopenharmony_ci#define VELOCITY_FORCED_BY_EEPROM 0x00000040UL 13288c2ecf20Sopenharmony_ci 13298c2ecf20Sopenharmony_ci/* 13308c2ecf20Sopenharmony_ci * For velocity_set_media_duplex 13318c2ecf20Sopenharmony_ci */ 13328c2ecf20Sopenharmony_ci 13338c2ecf20Sopenharmony_ci#define VELOCITY_LINK_CHANGE 0x00000001UL 13348c2ecf20Sopenharmony_ci 13358c2ecf20Sopenharmony_cienum speed_opt { 13368c2ecf20Sopenharmony_ci SPD_DPX_AUTO = 0, 13378c2ecf20Sopenharmony_ci SPD_DPX_100_HALF = 1, 13388c2ecf20Sopenharmony_ci SPD_DPX_100_FULL = 2, 13398c2ecf20Sopenharmony_ci SPD_DPX_10_HALF = 3, 13408c2ecf20Sopenharmony_ci SPD_DPX_10_FULL = 4, 13418c2ecf20Sopenharmony_ci SPD_DPX_1000_FULL = 5 13428c2ecf20Sopenharmony_ci}; 13438c2ecf20Sopenharmony_ci 13448c2ecf20Sopenharmony_cienum velocity_init_type { 13458c2ecf20Sopenharmony_ci VELOCITY_INIT_COLD = 0, 13468c2ecf20Sopenharmony_ci VELOCITY_INIT_RESET, 13478c2ecf20Sopenharmony_ci VELOCITY_INIT_WOL 13488c2ecf20Sopenharmony_ci}; 13498c2ecf20Sopenharmony_ci 13508c2ecf20Sopenharmony_cienum velocity_flow_cntl_type { 13518c2ecf20Sopenharmony_ci FLOW_CNTL_DEFAULT = 1, 13528c2ecf20Sopenharmony_ci FLOW_CNTL_TX, 13538c2ecf20Sopenharmony_ci FLOW_CNTL_RX, 13548c2ecf20Sopenharmony_ci FLOW_CNTL_TX_RX, 13558c2ecf20Sopenharmony_ci FLOW_CNTL_DISABLE, 13568c2ecf20Sopenharmony_ci}; 13578c2ecf20Sopenharmony_ci 13588c2ecf20Sopenharmony_cistruct velocity_opt { 13598c2ecf20Sopenharmony_ci int numrx; /* Number of RX descriptors */ 13608c2ecf20Sopenharmony_ci int numtx; /* Number of TX descriptors */ 13618c2ecf20Sopenharmony_ci enum speed_opt spd_dpx; /* Media link mode */ 13628c2ecf20Sopenharmony_ci 13638c2ecf20Sopenharmony_ci int DMA_length; /* DMA length */ 13648c2ecf20Sopenharmony_ci int rx_thresh; /* RX_THRESH */ 13658c2ecf20Sopenharmony_ci int flow_cntl; 13668c2ecf20Sopenharmony_ci int wol_opts; /* Wake on lan options */ 13678c2ecf20Sopenharmony_ci int td_int_count; 13688c2ecf20Sopenharmony_ci int int_works; 13698c2ecf20Sopenharmony_ci int rx_bandwidth_hi; 13708c2ecf20Sopenharmony_ci int rx_bandwidth_lo; 13718c2ecf20Sopenharmony_ci int rx_bandwidth_en; 13728c2ecf20Sopenharmony_ci int rxqueue_timer; 13738c2ecf20Sopenharmony_ci int txqueue_timer; 13748c2ecf20Sopenharmony_ci int tx_intsup; 13758c2ecf20Sopenharmony_ci int rx_intsup; 13768c2ecf20Sopenharmony_ci u32 flags; 13778c2ecf20Sopenharmony_ci}; 13788c2ecf20Sopenharmony_ci 13798c2ecf20Sopenharmony_ci#define AVAIL_TD(p,q) ((p)->options.numtx-((p)->tx.used[(q)])) 13808c2ecf20Sopenharmony_ci 13818c2ecf20Sopenharmony_ci#define GET_RD_BY_IDX(vptr, idx) (vptr->rd_ring[idx]) 13828c2ecf20Sopenharmony_ci 13838c2ecf20Sopenharmony_cistruct velocity_info { 13848c2ecf20Sopenharmony_ci struct device *dev; 13858c2ecf20Sopenharmony_ci struct pci_dev *pdev; 13868c2ecf20Sopenharmony_ci struct net_device *netdev; 13878c2ecf20Sopenharmony_ci int no_eeprom; 13888c2ecf20Sopenharmony_ci 13898c2ecf20Sopenharmony_ci unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 13908c2ecf20Sopenharmony_ci u8 ip_addr[4]; 13918c2ecf20Sopenharmony_ci enum chip_type chip_id; 13928c2ecf20Sopenharmony_ci 13938c2ecf20Sopenharmony_ci struct mac_regs __iomem * mac_regs; 13948c2ecf20Sopenharmony_ci unsigned long memaddr; 13958c2ecf20Sopenharmony_ci unsigned long ioaddr; 13968c2ecf20Sopenharmony_ci 13978c2ecf20Sopenharmony_ci struct tx_info { 13988c2ecf20Sopenharmony_ci int numq; 13998c2ecf20Sopenharmony_ci 14008c2ecf20Sopenharmony_ci /* FIXME: the locality of the data seems rather poor. */ 14018c2ecf20Sopenharmony_ci int used[TX_QUEUE_NO]; 14028c2ecf20Sopenharmony_ci int curr[TX_QUEUE_NO]; 14038c2ecf20Sopenharmony_ci int tail[TX_QUEUE_NO]; 14048c2ecf20Sopenharmony_ci struct tx_desc *rings[TX_QUEUE_NO]; 14058c2ecf20Sopenharmony_ci struct velocity_td_info *infos[TX_QUEUE_NO]; 14068c2ecf20Sopenharmony_ci dma_addr_t pool_dma[TX_QUEUE_NO]; 14078c2ecf20Sopenharmony_ci } tx; 14088c2ecf20Sopenharmony_ci 14098c2ecf20Sopenharmony_ci struct rx_info { 14108c2ecf20Sopenharmony_ci int buf_sz; 14118c2ecf20Sopenharmony_ci 14128c2ecf20Sopenharmony_ci int dirty; 14138c2ecf20Sopenharmony_ci int curr; 14148c2ecf20Sopenharmony_ci u32 filled; 14158c2ecf20Sopenharmony_ci struct rx_desc *ring; 14168c2ecf20Sopenharmony_ci struct velocity_rd_info *info; /* It's an array */ 14178c2ecf20Sopenharmony_ci dma_addr_t pool_dma; 14188c2ecf20Sopenharmony_ci } rx; 14198c2ecf20Sopenharmony_ci 14208c2ecf20Sopenharmony_ci u32 mib_counter[MAX_HW_MIB_COUNTER]; 14218c2ecf20Sopenharmony_ci struct velocity_opt options; 14228c2ecf20Sopenharmony_ci 14238c2ecf20Sopenharmony_ci u32 int_mask; 14248c2ecf20Sopenharmony_ci 14258c2ecf20Sopenharmony_ci u32 flags; 14268c2ecf20Sopenharmony_ci 14278c2ecf20Sopenharmony_ci u32 mii_status; 14288c2ecf20Sopenharmony_ci u32 phy_id; 14298c2ecf20Sopenharmony_ci int multicast_limit; 14308c2ecf20Sopenharmony_ci 14318c2ecf20Sopenharmony_ci u8 vCAMmask[(VCAM_SIZE / 8)]; 14328c2ecf20Sopenharmony_ci u8 mCAMmask[(MCAM_SIZE / 8)]; 14338c2ecf20Sopenharmony_ci 14348c2ecf20Sopenharmony_ci spinlock_t lock; 14358c2ecf20Sopenharmony_ci 14368c2ecf20Sopenharmony_ci int wol_opts; 14378c2ecf20Sopenharmony_ci u8 wol_passwd[6]; 14388c2ecf20Sopenharmony_ci 14398c2ecf20Sopenharmony_ci struct velocity_context context; 14408c2ecf20Sopenharmony_ci 14418c2ecf20Sopenharmony_ci u32 ticks; 14428c2ecf20Sopenharmony_ci u32 ethtool_ops_nesting; 14438c2ecf20Sopenharmony_ci 14448c2ecf20Sopenharmony_ci u8 rev_id; 14458c2ecf20Sopenharmony_ci 14468c2ecf20Sopenharmony_ci struct napi_struct napi; 14478c2ecf20Sopenharmony_ci}; 14488c2ecf20Sopenharmony_ci 14498c2ecf20Sopenharmony_ci/** 14508c2ecf20Sopenharmony_ci * velocity_get_ip - find an IP address for the device 14518c2ecf20Sopenharmony_ci * @vptr: Velocity to query 14528c2ecf20Sopenharmony_ci * 14538c2ecf20Sopenharmony_ci * Dig out an IP address for this interface so that we can 14548c2ecf20Sopenharmony_ci * configure wakeup with WOL for ARP. If there are multiple IP 14558c2ecf20Sopenharmony_ci * addresses on this chain then we use the first - multi-IP WOL is not 14568c2ecf20Sopenharmony_ci * supported. 14578c2ecf20Sopenharmony_ci * 14588c2ecf20Sopenharmony_ci */ 14598c2ecf20Sopenharmony_ci 14608c2ecf20Sopenharmony_cistatic inline int velocity_get_ip(struct velocity_info *vptr) 14618c2ecf20Sopenharmony_ci{ 14628c2ecf20Sopenharmony_ci struct in_device *in_dev; 14638c2ecf20Sopenharmony_ci struct in_ifaddr *ifa; 14648c2ecf20Sopenharmony_ci int res = -ENOENT; 14658c2ecf20Sopenharmony_ci 14668c2ecf20Sopenharmony_ci rcu_read_lock(); 14678c2ecf20Sopenharmony_ci in_dev = __in_dev_get_rcu(vptr->netdev); 14688c2ecf20Sopenharmony_ci if (in_dev != NULL) { 14698c2ecf20Sopenharmony_ci ifa = rcu_dereference(in_dev->ifa_list); 14708c2ecf20Sopenharmony_ci if (ifa != NULL) { 14718c2ecf20Sopenharmony_ci memcpy(vptr->ip_addr, &ifa->ifa_address, 4); 14728c2ecf20Sopenharmony_ci res = 0; 14738c2ecf20Sopenharmony_ci } 14748c2ecf20Sopenharmony_ci } 14758c2ecf20Sopenharmony_ci rcu_read_unlock(); 14768c2ecf20Sopenharmony_ci return res; 14778c2ecf20Sopenharmony_ci} 14788c2ecf20Sopenharmony_ci 14798c2ecf20Sopenharmony_ci/** 14808c2ecf20Sopenharmony_ci * velocity_update_hw_mibs - fetch MIB counters from chip 14818c2ecf20Sopenharmony_ci * @vptr: velocity to update 14828c2ecf20Sopenharmony_ci * 14838c2ecf20Sopenharmony_ci * The velocity hardware keeps certain counters in the hardware 14848c2ecf20Sopenharmony_ci * side. We need to read these when the user asks for statistics 14858c2ecf20Sopenharmony_ci * or when they overflow (causing an interrupt). The read of the 14868c2ecf20Sopenharmony_ci * statistic clears it, so we keep running master counters in user 14878c2ecf20Sopenharmony_ci * space. 14888c2ecf20Sopenharmony_ci */ 14898c2ecf20Sopenharmony_ci 14908c2ecf20Sopenharmony_cistatic inline void velocity_update_hw_mibs(struct velocity_info *vptr) 14918c2ecf20Sopenharmony_ci{ 14928c2ecf20Sopenharmony_ci u32 tmp; 14938c2ecf20Sopenharmony_ci int i; 14948c2ecf20Sopenharmony_ci BYTE_REG_BITS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR)); 14958c2ecf20Sopenharmony_ci 14968c2ecf20Sopenharmony_ci while (BYTE_REG_BITS_IS_ON(MIBCR_MIBFLSH, &(vptr->mac_regs->MIBCR))); 14978c2ecf20Sopenharmony_ci 14988c2ecf20Sopenharmony_ci BYTE_REG_BITS_ON(MIBCR_MPTRINI, &(vptr->mac_regs->MIBCR)); 14998c2ecf20Sopenharmony_ci for (i = 0; i < HW_MIB_SIZE; i++) { 15008c2ecf20Sopenharmony_ci tmp = readl(&(vptr->mac_regs->MIBData)) & 0x00FFFFFFUL; 15018c2ecf20Sopenharmony_ci vptr->mib_counter[i] += tmp; 15028c2ecf20Sopenharmony_ci } 15038c2ecf20Sopenharmony_ci} 15048c2ecf20Sopenharmony_ci 15058c2ecf20Sopenharmony_ci/** 15068c2ecf20Sopenharmony_ci * init_flow_control_register - set up flow control 15078c2ecf20Sopenharmony_ci * @vptr: velocity to configure 15088c2ecf20Sopenharmony_ci * 15098c2ecf20Sopenharmony_ci * Configure the flow control registers for this velocity device. 15108c2ecf20Sopenharmony_ci */ 15118c2ecf20Sopenharmony_ci 15128c2ecf20Sopenharmony_cistatic inline void init_flow_control_register(struct velocity_info *vptr) 15138c2ecf20Sopenharmony_ci{ 15148c2ecf20Sopenharmony_ci struct mac_regs __iomem * regs = vptr->mac_regs; 15158c2ecf20Sopenharmony_ci 15168c2ecf20Sopenharmony_ci /* Set {XHITH1, XHITH0, XLTH1, XLTH0} in FlowCR1 to {1, 0, 1, 1} 15178c2ecf20Sopenharmony_ci depend on RD=64, and Turn on XNOEN in FlowCR1 */ 15188c2ecf20Sopenharmony_ci writel((CR0_XONEN | CR0_XHITH1 | CR0_XLTH1 | CR0_XLTH0), ®s->CR0Set); 15198c2ecf20Sopenharmony_ci writel((CR0_FDXTFCEN | CR0_FDXRFCEN | CR0_HDXFCEN | CR0_XHITH0), ®s->CR0Clr); 15208c2ecf20Sopenharmony_ci 15218c2ecf20Sopenharmony_ci /* Set TxPauseTimer to 0xFFFF */ 15228c2ecf20Sopenharmony_ci writew(0xFFFF, ®s->tx_pause_timer); 15238c2ecf20Sopenharmony_ci 15248c2ecf20Sopenharmony_ci /* Initialize RBRDU to Rx buffer count. */ 15258c2ecf20Sopenharmony_ci writew(vptr->options.numrx, ®s->RBRDU); 15268c2ecf20Sopenharmony_ci} 15278c2ecf20Sopenharmony_ci 15288c2ecf20Sopenharmony_ci 15298c2ecf20Sopenharmony_ci#endif 1530