18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Advanced Micro Devices Inc. AMD8111E Linux Network Driver 48c2ecf20Sopenharmony_ci * Copyright (C) 2003 Advanced Micro Devices 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciModule Name: 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci amd8111e.h 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciAbstract: 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci AMD8111 based 10/100 Ethernet Controller driver definitions. 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciEnvironment: 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci Kernel Mode 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ciRevision History: 208c2ecf20Sopenharmony_ci 3.0.0 218c2ecf20Sopenharmony_ci Initial Revision. 228c2ecf20Sopenharmony_ci 3.0.1 238c2ecf20Sopenharmony_ci*/ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#ifndef _AMD811E_H 268c2ecf20Sopenharmony_ci#define _AMD811E_H 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* Command style register access 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ciRegisters CMD0, CMD2, CMD3,CMD7 and INTEN0 uses a write access technique called command style access. It allows the write to selected bits of this register without altering the bits that are not selected. Command style registers are divided into 4 bytes that can be written independently. Higher order bit of each byte is the value bit that specifies the value that will be written into the selected bits of register. 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cieg., if the value 10011010b is written into the least significant byte of a command style register, bits 1,3 and 4 of the register will be set to 1, and the other bits will not be altered. If the value 00011010b is written into the same byte, bits 1,3 and 4 will be cleared to 0 and the other bits will not be altered. 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci*/ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* Offset for Memory Mapped Registers. */ 378c2ecf20Sopenharmony_ci/* 32 bit registers */ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define ASF_STAT 0x00 /* ASF status register */ 408c2ecf20Sopenharmony_ci#define CHIPID 0x04 /* Chip ID register */ 418c2ecf20Sopenharmony_ci#define MIB_DATA 0x10 /* MIB data register */ 428c2ecf20Sopenharmony_ci#define MIB_ADDR 0x14 /* MIB address register */ 438c2ecf20Sopenharmony_ci#define STAT0 0x30 /* Status0 register */ 448c2ecf20Sopenharmony_ci#define INT0 0x38 /* Interrupt0 register */ 458c2ecf20Sopenharmony_ci#define INTEN0 0x40 /* Interrupt0 enable register*/ 468c2ecf20Sopenharmony_ci#define CMD0 0x48 /* Command0 register */ 478c2ecf20Sopenharmony_ci#define CMD2 0x50 /* Command2 register */ 488c2ecf20Sopenharmony_ci#define CMD3 0x54 /* Command3 resiter */ 498c2ecf20Sopenharmony_ci#define CMD7 0x64 /* Command7 register */ 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define CTRL1 0x6C /* Control1 register */ 528c2ecf20Sopenharmony_ci#define CTRL2 0x70 /* Control2 register */ 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define XMT_RING_LIMIT 0x7C /* Transmit ring limit register */ 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define AUTOPOLL0 0x88 /* Auto-poll0 register */ 578c2ecf20Sopenharmony_ci#define AUTOPOLL1 0x8A /* Auto-poll1 register */ 588c2ecf20Sopenharmony_ci#define AUTOPOLL2 0x8C /* Auto-poll2 register */ 598c2ecf20Sopenharmony_ci#define AUTOPOLL3 0x8E /* Auto-poll3 register */ 608c2ecf20Sopenharmony_ci#define AUTOPOLL4 0x90 /* Auto-poll4 register */ 618c2ecf20Sopenharmony_ci#define AUTOPOLL5 0x92 /* Auto-poll5 register */ 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define AP_VALUE 0x98 /* Auto-poll value register */ 648c2ecf20Sopenharmony_ci#define DLY_INT_A 0xA8 /* Group A delayed interrupt register */ 658c2ecf20Sopenharmony_ci#define DLY_INT_B 0xAC /* Group B delayed interrupt register */ 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define FLOW_CONTROL 0xC8 /* Flow control register */ 688c2ecf20Sopenharmony_ci#define PHY_ACCESS 0xD0 /* PHY access register */ 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define STVAL 0xD8 /* Software timer value register */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define XMT_RING_BASE_ADDR0 0x100 /* Transmit ring0 base addr register */ 738c2ecf20Sopenharmony_ci#define XMT_RING_BASE_ADDR1 0x108 /* Transmit ring1 base addr register */ 748c2ecf20Sopenharmony_ci#define XMT_RING_BASE_ADDR2 0x110 /* Transmit ring2 base addr register */ 758c2ecf20Sopenharmony_ci#define XMT_RING_BASE_ADDR3 0x118 /* Transmit ring2 base addr register */ 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define RCV_RING_BASE_ADDR0 0x120 /* Transmit ring0 base addr register */ 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci#define PMAT0 0x190 /* OnNow pattern register0 */ 808c2ecf20Sopenharmony_ci#define PMAT1 0x194 /* OnNow pattern register1 */ 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* 16bit registers */ 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define XMT_RING_LEN0 0x140 /* Transmit Ring0 length register */ 858c2ecf20Sopenharmony_ci#define XMT_RING_LEN1 0x144 /* Transmit Ring1 length register */ 868c2ecf20Sopenharmony_ci#define XMT_RING_LEN2 0x148 /* Transmit Ring2 length register */ 878c2ecf20Sopenharmony_ci#define XMT_RING_LEN3 0x14C /* Transmit Ring3 length register */ 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define RCV_RING_LEN0 0x150 /* Receive Ring0 length register */ 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define SRAM_SIZE 0x178 /* SRAM size register */ 928c2ecf20Sopenharmony_ci#define SRAM_BOUNDARY 0x17A /* SRAM boundary register */ 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* 48bit register */ 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#define PADR 0x160 /* Physical address register */ 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define IFS1 0x18C /* Inter-frame spacing Part1 register */ 998c2ecf20Sopenharmony_ci#define IFS 0x18D /* Inter-frame spacing register */ 1008c2ecf20Sopenharmony_ci#define IPG 0x18E /* Inter-frame gap register */ 1018c2ecf20Sopenharmony_ci/* 64bit register */ 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#define LADRF 0x168 /* Logical address filter register */ 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci/* Register Bit Definitions */ 1078c2ecf20Sopenharmony_citypedef enum { 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci ASF_INIT_DONE = (1 << 1), 1108c2ecf20Sopenharmony_ci ASF_INIT_PRESENT = (1 << 0), 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci}STAT_ASF_BITS; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_citypedef enum { 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci MIB_CMD_ACTIVE = (1 << 15 ), 1178c2ecf20Sopenharmony_ci MIB_RD_CMD = (1 << 13 ), 1188c2ecf20Sopenharmony_ci MIB_CLEAR = (1 << 12 ), 1198c2ecf20Sopenharmony_ci MIB_ADDRESS = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)| 1208c2ecf20Sopenharmony_ci (1 << 4) | (1 << 5), 1218c2ecf20Sopenharmony_ci}MIB_ADDR_BITS; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_citypedef enum { 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci PMAT_DET = (1 << 12), 1278c2ecf20Sopenharmony_ci MP_DET = (1 << 11), 1288c2ecf20Sopenharmony_ci LC_DET = (1 << 10), 1298c2ecf20Sopenharmony_ci SPEED_MASK = (1 << 9)|(1 << 8)|(1 << 7), 1308c2ecf20Sopenharmony_ci FULL_DPLX = (1 << 6), 1318c2ecf20Sopenharmony_ci LINK_STATS = (1 << 5), 1328c2ecf20Sopenharmony_ci AUTONEG_COMPLETE = (1 << 4), 1338c2ecf20Sopenharmony_ci MIIPD = (1 << 3), 1348c2ecf20Sopenharmony_ci RX_SUSPENDED = (1 << 2), 1358c2ecf20Sopenharmony_ci TX_SUSPENDED = (1 << 1), 1368c2ecf20Sopenharmony_ci RUNNING = (1 << 0), 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci}STAT0_BITS; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define PHY_SPEED_10 0x2 1418c2ecf20Sopenharmony_ci#define PHY_SPEED_100 0x3 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci/* INT0 0x38, 32bit register */ 1448c2ecf20Sopenharmony_citypedef enum { 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci INTR = (1 << 31), 1478c2ecf20Sopenharmony_ci PCSINT = (1 << 28), 1488c2ecf20Sopenharmony_ci LCINT = (1 << 27), 1498c2ecf20Sopenharmony_ci APINT5 = (1 << 26), 1508c2ecf20Sopenharmony_ci APINT4 = (1 << 25), 1518c2ecf20Sopenharmony_ci APINT3 = (1 << 24), 1528c2ecf20Sopenharmony_ci TINT_SUM = (1 << 23), 1538c2ecf20Sopenharmony_ci APINT2 = (1 << 22), 1548c2ecf20Sopenharmony_ci APINT1 = (1 << 21), 1558c2ecf20Sopenharmony_ci APINT0 = (1 << 20), 1568c2ecf20Sopenharmony_ci MIIPDTINT = (1 << 19), 1578c2ecf20Sopenharmony_ci MCCINT = (1 << 17), 1588c2ecf20Sopenharmony_ci MREINT = (1 << 16), 1598c2ecf20Sopenharmony_ci RINT_SUM = (1 << 15), 1608c2ecf20Sopenharmony_ci SPNDINT = (1 << 14), 1618c2ecf20Sopenharmony_ci MPINT = (1 << 13), 1628c2ecf20Sopenharmony_ci SINT = (1 << 12), 1638c2ecf20Sopenharmony_ci TINT3 = (1 << 11), 1648c2ecf20Sopenharmony_ci TINT2 = (1 << 10), 1658c2ecf20Sopenharmony_ci TINT1 = (1 << 9), 1668c2ecf20Sopenharmony_ci TINT0 = (1 << 8), 1678c2ecf20Sopenharmony_ci UINT = (1 << 7), 1688c2ecf20Sopenharmony_ci STINT = (1 << 4), 1698c2ecf20Sopenharmony_ci RINT0 = (1 << 0), 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci}INT0_BITS; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_citypedef enum { 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_ci VAL3 = (1 << 31), /* VAL bit for byte 3 */ 1768c2ecf20Sopenharmony_ci VAL2 = (1 << 23), /* VAL bit for byte 2 */ 1778c2ecf20Sopenharmony_ci VAL1 = (1 << 15), /* VAL bit for byte 1 */ 1788c2ecf20Sopenharmony_ci VAL0 = (1 << 7), /* VAL bit for byte 0 */ 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci}VAL_BITS; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_citypedef enum { 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci /* VAL3 */ 1858c2ecf20Sopenharmony_ci LCINTEN = (1 << 27), 1868c2ecf20Sopenharmony_ci APINT5EN = (1 << 26), 1878c2ecf20Sopenharmony_ci APINT4EN = (1 << 25), 1888c2ecf20Sopenharmony_ci APINT3EN = (1 << 24), 1898c2ecf20Sopenharmony_ci /* VAL2 */ 1908c2ecf20Sopenharmony_ci APINT2EN = (1 << 22), 1918c2ecf20Sopenharmony_ci APINT1EN = (1 << 21), 1928c2ecf20Sopenharmony_ci APINT0EN = (1 << 20), 1938c2ecf20Sopenharmony_ci MIIPDTINTEN = (1 << 19), 1948c2ecf20Sopenharmony_ci MCCIINTEN = (1 << 18), 1958c2ecf20Sopenharmony_ci MCCINTEN = (1 << 17), 1968c2ecf20Sopenharmony_ci MREINTEN = (1 << 16), 1978c2ecf20Sopenharmony_ci /* VAL1 */ 1988c2ecf20Sopenharmony_ci SPNDINTEN = (1 << 14), 1998c2ecf20Sopenharmony_ci MPINTEN = (1 << 13), 2008c2ecf20Sopenharmony_ci TINTEN3 = (1 << 11), 2018c2ecf20Sopenharmony_ci SINTEN = (1 << 12), 2028c2ecf20Sopenharmony_ci TINTEN2 = (1 << 10), 2038c2ecf20Sopenharmony_ci TINTEN1 = (1 << 9), 2048c2ecf20Sopenharmony_ci TINTEN0 = (1 << 8), 2058c2ecf20Sopenharmony_ci /* VAL0 */ 2068c2ecf20Sopenharmony_ci STINTEN = (1 << 4), 2078c2ecf20Sopenharmony_ci RINTEN0 = (1 << 0), 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci INTEN0_CLEAR = 0x1F7F7F1F, /* Command style register */ 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci}INTEN0_BITS; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_citypedef enum { 2148c2ecf20Sopenharmony_ci /* VAL2 */ 2158c2ecf20Sopenharmony_ci RDMD0 = (1 << 16), 2168c2ecf20Sopenharmony_ci /* VAL1 */ 2178c2ecf20Sopenharmony_ci TDMD3 = (1 << 11), 2188c2ecf20Sopenharmony_ci TDMD2 = (1 << 10), 2198c2ecf20Sopenharmony_ci TDMD1 = (1 << 9), 2208c2ecf20Sopenharmony_ci TDMD0 = (1 << 8), 2218c2ecf20Sopenharmony_ci /* VAL0 */ 2228c2ecf20Sopenharmony_ci UINTCMD = (1 << 6), 2238c2ecf20Sopenharmony_ci RX_FAST_SPND = (1 << 5), 2248c2ecf20Sopenharmony_ci TX_FAST_SPND = (1 << 4), 2258c2ecf20Sopenharmony_ci RX_SPND = (1 << 3), 2268c2ecf20Sopenharmony_ci TX_SPND = (1 << 2), 2278c2ecf20Sopenharmony_ci INTREN = (1 << 1), 2288c2ecf20Sopenharmony_ci RUN = (1 << 0), 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci CMD0_CLEAR = 0x000F0F7F, /* Command style register */ 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci}CMD0_BITS; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_citypedef enum { 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci /* VAL3 */ 2378c2ecf20Sopenharmony_ci CONDUIT_MODE = (1 << 29), 2388c2ecf20Sopenharmony_ci /* VAL2 */ 2398c2ecf20Sopenharmony_ci RPA = (1 << 19), 2408c2ecf20Sopenharmony_ci DRCVPA = (1 << 18), 2418c2ecf20Sopenharmony_ci DRCVBC = (1 << 17), 2428c2ecf20Sopenharmony_ci PROM = (1 << 16), 2438c2ecf20Sopenharmony_ci /* VAL1 */ 2448c2ecf20Sopenharmony_ci ASTRP_RCV = (1 << 13), 2458c2ecf20Sopenharmony_ci RCV_DROP0 = (1 << 12), 2468c2ecf20Sopenharmony_ci EMBA = (1 << 11), 2478c2ecf20Sopenharmony_ci DXMT2PD = (1 << 10), 2488c2ecf20Sopenharmony_ci LTINTEN = (1 << 9), 2498c2ecf20Sopenharmony_ci DXMTFCS = (1 << 8), 2508c2ecf20Sopenharmony_ci /* VAL0 */ 2518c2ecf20Sopenharmony_ci APAD_XMT = (1 << 6), 2528c2ecf20Sopenharmony_ci DRTY = (1 << 5), 2538c2ecf20Sopenharmony_ci INLOOP = (1 << 4), 2548c2ecf20Sopenharmony_ci EXLOOP = (1 << 3), 2558c2ecf20Sopenharmony_ci REX_RTRY = (1 << 2), 2568c2ecf20Sopenharmony_ci REX_UFLO = (1 << 1), 2578c2ecf20Sopenharmony_ci REX_LCOL = (1 << 0), 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci CMD2_CLEAR = 0x3F7F3F7F, /* Command style register */ 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci}CMD2_BITS; 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_citypedef enum { 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci /* VAL3 */ 2668c2ecf20Sopenharmony_ci ASF_INIT_DONE_ALIAS = (1 << 29), 2678c2ecf20Sopenharmony_ci /* VAL2 */ 2688c2ecf20Sopenharmony_ci JUMBO = (1 << 21), 2698c2ecf20Sopenharmony_ci VSIZE = (1 << 20), 2708c2ecf20Sopenharmony_ci VLONLY = (1 << 19), 2718c2ecf20Sopenharmony_ci VL_TAG_DEL = (1 << 18), 2728c2ecf20Sopenharmony_ci /* VAL1 */ 2738c2ecf20Sopenharmony_ci EN_PMGR = (1 << 14), 2748c2ecf20Sopenharmony_ci INTLEVEL = (1 << 13), 2758c2ecf20Sopenharmony_ci FORCE_FULL_DUPLEX = (1 << 12), 2768c2ecf20Sopenharmony_ci FORCE_LINK_STATUS = (1 << 11), 2778c2ecf20Sopenharmony_ci APEP = (1 << 10), 2788c2ecf20Sopenharmony_ci MPPLBA = (1 << 9), 2798c2ecf20Sopenharmony_ci /* VAL0 */ 2808c2ecf20Sopenharmony_ci RESET_PHY_PULSE = (1 << 2), 2818c2ecf20Sopenharmony_ci RESET_PHY = (1 << 1), 2828c2ecf20Sopenharmony_ci PHY_RST_POL = (1 << 0), 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci}CMD3_BITS; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_citypedef enum { 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci /* VAL0 */ 2908c2ecf20Sopenharmony_ci PMAT_SAVE_MATCH = (1 << 4), 2918c2ecf20Sopenharmony_ci PMAT_MODE = (1 << 3), 2928c2ecf20Sopenharmony_ci MPEN_SW = (1 << 1), 2938c2ecf20Sopenharmony_ci LCMODE_SW = (1 << 0), 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci CMD7_CLEAR = 0x0000001B /* Command style register */ 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci}CMD7_BITS; 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_citypedef enum { 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci RESET_PHY_WIDTH = (0xF << 16) | (0xF<< 20), /* 0x00FF0000 */ 3038c2ecf20Sopenharmony_ci XMTSP_MASK = (1 << 9) | (1 << 8), /* 9:8 */ 3048c2ecf20Sopenharmony_ci XMTSP_128 = (1 << 9), /* 9 */ 3058c2ecf20Sopenharmony_ci XMTSP_64 = (1 << 8), 3068c2ecf20Sopenharmony_ci CACHE_ALIGN = (1 << 4), 3078c2ecf20Sopenharmony_ci BURST_LIMIT_MASK = (0xF << 0 ), 3088c2ecf20Sopenharmony_ci CTRL1_DEFAULT = 0x00010111, 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_ci}CTRL1_BITS; 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_citypedef enum { 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci FMDC_MASK = (1 << 9)|(1 << 8), /* 9:8 */ 3158c2ecf20Sopenharmony_ci XPHYRST = (1 << 7), 3168c2ecf20Sopenharmony_ci XPHYANE = (1 << 6), 3178c2ecf20Sopenharmony_ci XPHYFD = (1 << 5), 3188c2ecf20Sopenharmony_ci XPHYSP = (1 << 4) | (1 << 3), /* 4:3 */ 3198c2ecf20Sopenharmony_ci APDW_MASK = (1 << 2) | (1 << 1) | (1 << 0), /* 2:0 */ 3208c2ecf20Sopenharmony_ci 3218c2ecf20Sopenharmony_ci}CTRL2_BITS; 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci/* XMT_RING_LIMIT 0x7C, 32bit register */ 3248c2ecf20Sopenharmony_citypedef enum { 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci XMT_RING2_LIMIT = (0xFF << 16), /* 23:16 */ 3278c2ecf20Sopenharmony_ci XMT_RING1_LIMIT = (0xFF << 8), /* 15:8 */ 3288c2ecf20Sopenharmony_ci XMT_RING0_LIMIT = (0xFF << 0), /* 7:0 */ 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci}XMT_RING_LIMIT_BITS; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_citypedef enum { 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci AP_REG0_EN = (1 << 15), 3358c2ecf20Sopenharmony_ci AP_REG0_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */ 3368c2ecf20Sopenharmony_ci AP_PHY0_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */ 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci}AUTOPOLL0_BITS; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci/* AUTOPOLL1 0x8A, 16bit register */ 3418c2ecf20Sopenharmony_citypedef enum { 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci AP_REG1_EN = (1 << 15), 3448c2ecf20Sopenharmony_ci AP_REG1_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */ 3458c2ecf20Sopenharmony_ci AP_PRE_SUP1 = (1 << 6), 3468c2ecf20Sopenharmony_ci AP_PHY1_DFLT = (1 << 5), 3478c2ecf20Sopenharmony_ci AP_PHY1_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */ 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci}AUTOPOLL1_BITS; 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_citypedef enum { 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci AP_REG2_EN = (1 << 15), 3558c2ecf20Sopenharmony_ci AP_REG2_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */ 3568c2ecf20Sopenharmony_ci AP_PRE_SUP2 = (1 << 6), 3578c2ecf20Sopenharmony_ci AP_PHY2_DFLT = (1 << 5), 3588c2ecf20Sopenharmony_ci AP_PHY2_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */ 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci}AUTOPOLL2_BITS; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_citypedef enum { 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci AP_REG3_EN = (1 << 15), 3658c2ecf20Sopenharmony_ci AP_REG3_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */ 3668c2ecf20Sopenharmony_ci AP_PRE_SUP3 = (1 << 6), 3678c2ecf20Sopenharmony_ci AP_PHY3_DFLT = (1 << 5), 3688c2ecf20Sopenharmony_ci AP_PHY3_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */ 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_ci}AUTOPOLL3_BITS; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_citypedef enum { 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci AP_REG4_EN = (1 << 15), 3768c2ecf20Sopenharmony_ci AP_REG4_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */ 3778c2ecf20Sopenharmony_ci AP_PRE_SUP4 = (1 << 6), 3788c2ecf20Sopenharmony_ci AP_PHY4_DFLT = (1 << 5), 3798c2ecf20Sopenharmony_ci AP_PHY4_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */ 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci}AUTOPOLL4_BITS; 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_citypedef enum { 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_ci AP_REG5_EN = (1 << 15), 3878c2ecf20Sopenharmony_ci AP_REG5_ADDR_MASK = (0xF << 8) |(1 << 12),/* 12:8 */ 3888c2ecf20Sopenharmony_ci AP_PRE_SUP5 = (1 << 6), 3898c2ecf20Sopenharmony_ci AP_PHY5_DFLT = (1 << 5), 3908c2ecf20Sopenharmony_ci AP_PHY5_ADDR_MASK = (0xF << 0) |(1 << 4),/* 4:0 */ 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_ci}AUTOPOLL5_BITS; 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci/* AP_VALUE 0x98, 32bit ragister */ 3988c2ecf20Sopenharmony_citypedef enum { 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci AP_VAL_ACTIVE = (1 << 31), 4018c2ecf20Sopenharmony_ci AP_VAL_RD_CMD = ( 1 << 29), 4028c2ecf20Sopenharmony_ci AP_ADDR = (1 << 18)|(1 << 17)|(1 << 16), /* 18:16 */ 4038c2ecf20Sopenharmony_ci AP_VAL = (0xF << 0) | (0xF << 4) |( 0xF << 8) | 4048c2ecf20Sopenharmony_ci (0xF << 12), /* 15:0 */ 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci}AP_VALUE_BITS; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_citypedef enum { 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci DLY_INT_A_R3 = (1 << 31), 4118c2ecf20Sopenharmony_ci DLY_INT_A_R2 = (1 << 30), 4128c2ecf20Sopenharmony_ci DLY_INT_A_R1 = (1 << 29), 4138c2ecf20Sopenharmony_ci DLY_INT_A_R0 = (1 << 28), 4148c2ecf20Sopenharmony_ci DLY_INT_A_T3 = (1 << 27), 4158c2ecf20Sopenharmony_ci DLY_INT_A_T2 = (1 << 26), 4168c2ecf20Sopenharmony_ci DLY_INT_A_T1 = (1 << 25), 4178c2ecf20Sopenharmony_ci DLY_INT_A_T0 = ( 1 << 24), 4188c2ecf20Sopenharmony_ci EVENT_COUNT_A = (0xF << 16) | (0x1 << 20),/* 20:16 */ 4198c2ecf20Sopenharmony_ci MAX_DELAY_TIME_A = (0xF << 0) | (0xF << 4) | (1 << 8)| 4208c2ecf20Sopenharmony_ci (1 << 9) | (1 << 10), /* 10:0 */ 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci}DLY_INT_A_BITS; 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_citypedef enum { 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci DLY_INT_B_R3 = (1 << 31), 4278c2ecf20Sopenharmony_ci DLY_INT_B_R2 = (1 << 30), 4288c2ecf20Sopenharmony_ci DLY_INT_B_R1 = (1 << 29), 4298c2ecf20Sopenharmony_ci DLY_INT_B_R0 = (1 << 28), 4308c2ecf20Sopenharmony_ci DLY_INT_B_T3 = (1 << 27), 4318c2ecf20Sopenharmony_ci DLY_INT_B_T2 = (1 << 26), 4328c2ecf20Sopenharmony_ci DLY_INT_B_T1 = (1 << 25), 4338c2ecf20Sopenharmony_ci DLY_INT_B_T0 = ( 1 << 24), 4348c2ecf20Sopenharmony_ci EVENT_COUNT_B = (0xF << 16) | (0x1 << 20),/* 20:16 */ 4358c2ecf20Sopenharmony_ci MAX_DELAY_TIME_B = (0xF << 0) | (0xF << 4) | (1 << 8)| 4368c2ecf20Sopenharmony_ci (1 << 9) | (1 << 10), /* 10:0 */ 4378c2ecf20Sopenharmony_ci}DLY_INT_B_BITS; 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_ci/* FLOW_CONTROL 0xC8, 32bit register */ 4418c2ecf20Sopenharmony_citypedef enum { 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci PAUSE_LEN_CHG = (1 << 30), 4448c2ecf20Sopenharmony_ci FTPE = (1 << 22), 4458c2ecf20Sopenharmony_ci FRPE = (1 << 21), 4468c2ecf20Sopenharmony_ci NAPA = (1 << 20), 4478c2ecf20Sopenharmony_ci NPA = (1 << 19), 4488c2ecf20Sopenharmony_ci FIXP = ( 1 << 18), 4498c2ecf20Sopenharmony_ci FCCMD = ( 1 << 16), 4508c2ecf20Sopenharmony_ci PAUSE_LEN = (0xF << 0) | (0xF << 4) |( 0xF << 8) | (0xF << 12), /* 15:0 */ 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_ci}FLOW_CONTROL_BITS; 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci/* PHY_ ACCESS 0xD0, 32bit register */ 4558c2ecf20Sopenharmony_citypedef enum { 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci PHY_CMD_ACTIVE = (1 << 31), 4588c2ecf20Sopenharmony_ci PHY_WR_CMD = (1 << 30), 4598c2ecf20Sopenharmony_ci PHY_RD_CMD = (1 << 29), 4608c2ecf20Sopenharmony_ci PHY_RD_ERR = (1 << 28), 4618c2ecf20Sopenharmony_ci PHY_PRE_SUP = (1 << 27), 4628c2ecf20Sopenharmony_ci PHY_ADDR = (1 << 21) | (1 << 22) | (1 << 23)| 4638c2ecf20Sopenharmony_ci (1 << 24) |(1 << 25),/* 25:21 */ 4648c2ecf20Sopenharmony_ci PHY_REG_ADDR = (1 << 16) | (1 << 17) | (1 << 18)| (1 << 19) | (1 << 20),/* 20:16 */ 4658c2ecf20Sopenharmony_ci PHY_DATA = (0xF << 0)|(0xF << 4) |(0xF << 8)| 4668c2ecf20Sopenharmony_ci (0xF << 12),/* 15:0 */ 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci}PHY_ACCESS_BITS; 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci/* PMAT0 0x190, 32bit register */ 4728c2ecf20Sopenharmony_citypedef enum { 4738c2ecf20Sopenharmony_ci PMR_ACTIVE = (1 << 31), 4748c2ecf20Sopenharmony_ci PMR_WR_CMD = (1 << 30), 4758c2ecf20Sopenharmony_ci PMR_RD_CMD = (1 << 29), 4768c2ecf20Sopenharmony_ci PMR_BANK = (1 <<28), 4778c2ecf20Sopenharmony_ci PMR_ADDR = (0xF << 16)|(1 << 20)|(1 << 21)| 4788c2ecf20Sopenharmony_ci (1 << 22),/* 22:16 */ 4798c2ecf20Sopenharmony_ci PMR_B4 = (0xF << 0) | (0xF << 4),/* 15:0 */ 4808c2ecf20Sopenharmony_ci}PMAT0_BITS; 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_ci/* PMAT1 0x194, 32bit register */ 4848c2ecf20Sopenharmony_citypedef enum { 4858c2ecf20Sopenharmony_ci PMR_B3 = (0xF << 24) | (0xF <<28),/* 31:24 */ 4868c2ecf20Sopenharmony_ci PMR_B2 = (0xF << 16) |(0xF << 20),/* 23:16 */ 4878c2ecf20Sopenharmony_ci PMR_B1 = (0xF << 8) | (0xF <<12), /* 15:8 */ 4888c2ecf20Sopenharmony_ci PMR_B0 = (0xF << 0)|(0xF << 4),/* 7:0 */ 4898c2ecf20Sopenharmony_ci}PMAT1_BITS; 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci/************************************************************************/ 4928c2ecf20Sopenharmony_ci/* */ 4938c2ecf20Sopenharmony_ci/* MIB counter definitions */ 4948c2ecf20Sopenharmony_ci/* */ 4958c2ecf20Sopenharmony_ci/************************************************************************/ 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_ci#define rcv_miss_pkts 0x00 4988c2ecf20Sopenharmony_ci#define rcv_octets 0x01 4998c2ecf20Sopenharmony_ci#define rcv_broadcast_pkts 0x02 5008c2ecf20Sopenharmony_ci#define rcv_multicast_pkts 0x03 5018c2ecf20Sopenharmony_ci#define rcv_undersize_pkts 0x04 5028c2ecf20Sopenharmony_ci#define rcv_oversize_pkts 0x05 5038c2ecf20Sopenharmony_ci#define rcv_fragments 0x06 5048c2ecf20Sopenharmony_ci#define rcv_jabbers 0x07 5058c2ecf20Sopenharmony_ci#define rcv_unicast_pkts 0x08 5068c2ecf20Sopenharmony_ci#define rcv_alignment_errors 0x09 5078c2ecf20Sopenharmony_ci#define rcv_fcs_errors 0x0A 5088c2ecf20Sopenharmony_ci#define rcv_good_octets 0x0B 5098c2ecf20Sopenharmony_ci#define rcv_mac_ctrl 0x0C 5108c2ecf20Sopenharmony_ci#define rcv_flow_ctrl 0x0D 5118c2ecf20Sopenharmony_ci#define rcv_pkts_64_octets 0x0E 5128c2ecf20Sopenharmony_ci#define rcv_pkts_65to127_octets 0x0F 5138c2ecf20Sopenharmony_ci#define rcv_pkts_128to255_octets 0x10 5148c2ecf20Sopenharmony_ci#define rcv_pkts_256to511_octets 0x11 5158c2ecf20Sopenharmony_ci#define rcv_pkts_512to1023_octets 0x12 5168c2ecf20Sopenharmony_ci#define rcv_pkts_1024to1518_octets 0x13 5178c2ecf20Sopenharmony_ci#define rcv_unsupported_opcode 0x14 5188c2ecf20Sopenharmony_ci#define rcv_symbol_errors 0x15 5198c2ecf20Sopenharmony_ci#define rcv_drop_pkts_ring1 0x16 5208c2ecf20Sopenharmony_ci#define rcv_drop_pkts_ring2 0x17 5218c2ecf20Sopenharmony_ci#define rcv_drop_pkts_ring3 0x18 5228c2ecf20Sopenharmony_ci#define rcv_drop_pkts_ring4 0x19 5238c2ecf20Sopenharmony_ci#define rcv_jumbo_pkts 0x1A 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci#define xmt_underrun_pkts 0x20 5268c2ecf20Sopenharmony_ci#define xmt_octets 0x21 5278c2ecf20Sopenharmony_ci#define xmt_packets 0x22 5288c2ecf20Sopenharmony_ci#define xmt_broadcast_pkts 0x23 5298c2ecf20Sopenharmony_ci#define xmt_multicast_pkts 0x24 5308c2ecf20Sopenharmony_ci#define xmt_collisions 0x25 5318c2ecf20Sopenharmony_ci#define xmt_unicast_pkts 0x26 5328c2ecf20Sopenharmony_ci#define xmt_one_collision 0x27 5338c2ecf20Sopenharmony_ci#define xmt_multiple_collision 0x28 5348c2ecf20Sopenharmony_ci#define xmt_deferred_transmit 0x29 5358c2ecf20Sopenharmony_ci#define xmt_late_collision 0x2A 5368c2ecf20Sopenharmony_ci#define xmt_excessive_defer 0x2B 5378c2ecf20Sopenharmony_ci#define xmt_loss_carrier 0x2C 5388c2ecf20Sopenharmony_ci#define xmt_excessive_collision 0x2D 5398c2ecf20Sopenharmony_ci#define xmt_back_pressure 0x2E 5408c2ecf20Sopenharmony_ci#define xmt_flow_ctrl 0x2F 5418c2ecf20Sopenharmony_ci#define xmt_pkts_64_octets 0x30 5428c2ecf20Sopenharmony_ci#define xmt_pkts_65to127_octets 0x31 5438c2ecf20Sopenharmony_ci#define xmt_pkts_128to255_octets 0x32 5448c2ecf20Sopenharmony_ci#define xmt_pkts_256to511_octets 0x33 5458c2ecf20Sopenharmony_ci#define xmt_pkts_512to1023_octets 0x34 5468c2ecf20Sopenharmony_ci#define xmt_pkts_1024to1518_octet 0x35 5478c2ecf20Sopenharmony_ci#define xmt_oversize_pkts 0x36 5488c2ecf20Sopenharmony_ci#define xmt_jumbo_pkts 0x37 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ci/* Driver definitions */ 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_ci#define PCI_VENDOR_ID_AMD 0x1022 5548c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_AMD8111E_7462 0x7462 5558c2ecf20Sopenharmony_ci 5568c2ecf20Sopenharmony_ci#define MAX_UNITS 8 /* Maximum number of devices possible */ 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci#define NUM_TX_BUFFERS 32 /* Number of transmit buffers */ 5598c2ecf20Sopenharmony_ci#define NUM_RX_BUFFERS 32 /* Number of receive buffers */ 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci#define TX_BUFF_MOD_MASK 31 /* (NUM_TX_BUFFERS -1) */ 5628c2ecf20Sopenharmony_ci#define RX_BUFF_MOD_MASK 31 /* (NUM_RX_BUFFERS -1) */ 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci#define NUM_TX_RING_DR 32 5658c2ecf20Sopenharmony_ci#define NUM_RX_RING_DR 32 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci#define TX_RING_DR_MOD_MASK 31 /* (NUM_TX_RING_DR -1) */ 5688c2ecf20Sopenharmony_ci#define RX_RING_DR_MOD_MASK 31 /* (NUM_RX_RING_DR -1) */ 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_ci#define MAX_FILTER_SIZE 64 /* Maximum multicast address */ 5718c2ecf20Sopenharmony_ci#define AMD8111E_MIN_MTU 60 5728c2ecf20Sopenharmony_ci#define AMD8111E_MAX_MTU 9000 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci#define PKT_BUFF_SZ 1536 5758c2ecf20Sopenharmony_ci#define MIN_PKT_LEN 60 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci#define AMD8111E_TX_TIMEOUT (3 * HZ)/* 3 sec */ 5788c2ecf20Sopenharmony_ci#define SOFT_TIMER_FREQ 0xBEBC /* 0.5 sec */ 5798c2ecf20Sopenharmony_ci#define DELAY_TIMER_CONV 50 /* msec to 10 usec conversion. 5808c2ecf20Sopenharmony_ci Only 500 usec resolution */ 5818c2ecf20Sopenharmony_ci#define OPTION_VLAN_ENABLE 0x0001 5828c2ecf20Sopenharmony_ci#define OPTION_JUMBO_ENABLE 0x0002 5838c2ecf20Sopenharmony_ci#define OPTION_MULTICAST_ENABLE 0x0004 5848c2ecf20Sopenharmony_ci#define OPTION_WOL_ENABLE 0x0008 5858c2ecf20Sopenharmony_ci#define OPTION_WAKE_MAGIC_ENABLE 0x0010 5868c2ecf20Sopenharmony_ci#define OPTION_WAKE_PHY_ENABLE 0x0020 5878c2ecf20Sopenharmony_ci#define OPTION_INTR_COAL_ENABLE 0x0040 5888c2ecf20Sopenharmony_ci#define OPTION_DYN_IPG_ENABLE 0x0080 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci#define PHY_REG_ADDR_MASK 0x1f 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_ci/* ipg parameters */ 5938c2ecf20Sopenharmony_ci#define DEFAULT_IPG 0x60 5948c2ecf20Sopenharmony_ci#define IFS1_DELTA 36 5958c2ecf20Sopenharmony_ci#define IPG_CONVERGE_JIFFIES (HZ/2) 5968c2ecf20Sopenharmony_ci#define IPG_STABLE_TIME 5 5978c2ecf20Sopenharmony_ci#define MIN_IPG 96 5988c2ecf20Sopenharmony_ci#define MAX_IPG 255 5998c2ecf20Sopenharmony_ci#define IPG_STEP 16 6008c2ecf20Sopenharmony_ci#define CSTATE 1 6018c2ecf20Sopenharmony_ci#define SSTATE 2 6028c2ecf20Sopenharmony_ci 6038c2ecf20Sopenharmony_ci/* Assume contoller gets data 10 times the maximum processing time */ 6048c2ecf20Sopenharmony_ci#define REPEAT_CNT 10 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci/* amd8111e descriptor flag definitions */ 6078c2ecf20Sopenharmony_citypedef enum { 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_ci OWN_BIT = (1 << 15), 6108c2ecf20Sopenharmony_ci ADD_FCS_BIT = (1 << 13), 6118c2ecf20Sopenharmony_ci LTINT_BIT = (1 << 12), 6128c2ecf20Sopenharmony_ci STP_BIT = (1 << 9), 6138c2ecf20Sopenharmony_ci ENP_BIT = (1 << 8), 6148c2ecf20Sopenharmony_ci KILL_BIT = (1 << 6), 6158c2ecf20Sopenharmony_ci TCC_VLAN_INSERT = (1 << 1), 6168c2ecf20Sopenharmony_ci TCC_VLAN_REPLACE = (1 << 1) |( 1<< 0), 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_ci}TX_FLAG_BITS; 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_citypedef enum { 6218c2ecf20Sopenharmony_ci ERR_BIT = (1 << 14), 6228c2ecf20Sopenharmony_ci FRAM_BIT = (1 << 13), 6238c2ecf20Sopenharmony_ci OFLO_BIT = (1 << 12), 6248c2ecf20Sopenharmony_ci CRC_BIT = (1 << 11), 6258c2ecf20Sopenharmony_ci PAM_BIT = (1 << 6), 6268c2ecf20Sopenharmony_ci LAFM_BIT = (1 << 5), 6278c2ecf20Sopenharmony_ci BAM_BIT = (1 << 4), 6288c2ecf20Sopenharmony_ci TT_VLAN_TAGGED = (1 << 3) |(1 << 2),/* 0x000 */ 6298c2ecf20Sopenharmony_ci TT_PRTY_TAGGED = (1 << 3),/* 0x0008 */ 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_ci}RX_FLAG_BITS; 6328c2ecf20Sopenharmony_ci 6338c2ecf20Sopenharmony_ci#define RESET_RX_FLAGS 0x0000 6348c2ecf20Sopenharmony_ci#define TT_MASK 0x000c 6358c2ecf20Sopenharmony_ci#define TCC_MASK 0x0003 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci/* driver ioctl parameters */ 6388c2ecf20Sopenharmony_ci#define AMD8111E_REG_DUMP_LEN 13*sizeof(u32) 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci/* amd8111e descriptor format */ 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_cistruct amd8111e_tx_dr{ 6438c2ecf20Sopenharmony_ci 6448c2ecf20Sopenharmony_ci __le16 buff_count; /* Size of the buffer pointed by this descriptor */ 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci __le16 tx_flags; 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci __le16 tag_ctrl_info; 6498c2ecf20Sopenharmony_ci 6508c2ecf20Sopenharmony_ci __le16 tag_ctrl_cmd; 6518c2ecf20Sopenharmony_ci 6528c2ecf20Sopenharmony_ci __le32 buff_phy_addr; 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci __le32 reserved; 6558c2ecf20Sopenharmony_ci}; 6568c2ecf20Sopenharmony_ci 6578c2ecf20Sopenharmony_cistruct amd8111e_rx_dr{ 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci __le32 reserved; 6608c2ecf20Sopenharmony_ci 6618c2ecf20Sopenharmony_ci __le16 msg_count; /* Received message len */ 6628c2ecf20Sopenharmony_ci 6638c2ecf20Sopenharmony_ci __le16 tag_ctrl_info; 6648c2ecf20Sopenharmony_ci 6658c2ecf20Sopenharmony_ci __le16 buff_count; /* Len of the buffer pointed by descriptor. */ 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ci __le16 rx_flags; 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_ci __le32 buff_phy_addr; 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_ci}; 6728c2ecf20Sopenharmony_cistruct amd8111e_link_config{ 6738c2ecf20Sopenharmony_ci 6748c2ecf20Sopenharmony_ci#define SPEED_INVALID 0xffff 6758c2ecf20Sopenharmony_ci#define DUPLEX_INVALID 0xff 6768c2ecf20Sopenharmony_ci#define AUTONEG_INVALID 0xff 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci unsigned long orig_phy_option; 6798c2ecf20Sopenharmony_ci u16 speed; 6808c2ecf20Sopenharmony_ci u8 duplex; 6818c2ecf20Sopenharmony_ci u8 autoneg; 6828c2ecf20Sopenharmony_ci u8 reserved; /* 32bit alignment */ 6838c2ecf20Sopenharmony_ci}; 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_cienum coal_type{ 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ci NO_COALESCE, 6888c2ecf20Sopenharmony_ci LOW_COALESCE, 6898c2ecf20Sopenharmony_ci MEDIUM_COALESCE, 6908c2ecf20Sopenharmony_ci HIGH_COALESCE, 6918c2ecf20Sopenharmony_ci 6928c2ecf20Sopenharmony_ci}; 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_cienum coal_mode{ 6958c2ecf20Sopenharmony_ci RX_INTR_COAL, 6968c2ecf20Sopenharmony_ci TX_INTR_COAL, 6978c2ecf20Sopenharmony_ci DISABLE_COAL, 6988c2ecf20Sopenharmony_ci ENABLE_COAL, 6998c2ecf20Sopenharmony_ci 7008c2ecf20Sopenharmony_ci}; 7018c2ecf20Sopenharmony_ci#define MAX_TIMEOUT 40 7028c2ecf20Sopenharmony_ci#define MAX_EVENT_COUNT 31 7038c2ecf20Sopenharmony_cistruct amd8111e_coalesce_conf{ 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci unsigned int rx_timeout; 7068c2ecf20Sopenharmony_ci unsigned int rx_event_count; 7078c2ecf20Sopenharmony_ci unsigned long rx_packets; 7088c2ecf20Sopenharmony_ci unsigned long rx_prev_packets; 7098c2ecf20Sopenharmony_ci unsigned long rx_bytes; 7108c2ecf20Sopenharmony_ci unsigned long rx_prev_bytes; 7118c2ecf20Sopenharmony_ci unsigned int rx_coal_type; 7128c2ecf20Sopenharmony_ci 7138c2ecf20Sopenharmony_ci unsigned int tx_timeout; 7148c2ecf20Sopenharmony_ci unsigned int tx_event_count; 7158c2ecf20Sopenharmony_ci unsigned long tx_packets; 7168c2ecf20Sopenharmony_ci unsigned long tx_prev_packets; 7178c2ecf20Sopenharmony_ci unsigned long tx_bytes; 7188c2ecf20Sopenharmony_ci unsigned long tx_prev_bytes; 7198c2ecf20Sopenharmony_ci unsigned int tx_coal_type; 7208c2ecf20Sopenharmony_ci 7218c2ecf20Sopenharmony_ci}; 7228c2ecf20Sopenharmony_cistruct ipg_info{ 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_ci unsigned int ipg_state; 7258c2ecf20Sopenharmony_ci unsigned int ipg; 7268c2ecf20Sopenharmony_ci unsigned int current_ipg; 7278c2ecf20Sopenharmony_ci unsigned int col_cnt; 7288c2ecf20Sopenharmony_ci unsigned int diff_col_cnt; 7298c2ecf20Sopenharmony_ci unsigned int timer_tick; 7308c2ecf20Sopenharmony_ci unsigned int prev_ipg; 7318c2ecf20Sopenharmony_ci struct timer_list ipg_timer; 7328c2ecf20Sopenharmony_ci}; 7338c2ecf20Sopenharmony_ci 7348c2ecf20Sopenharmony_cistruct amd8111e_priv{ 7358c2ecf20Sopenharmony_ci 7368c2ecf20Sopenharmony_ci struct amd8111e_tx_dr* tx_ring; 7378c2ecf20Sopenharmony_ci struct amd8111e_rx_dr* rx_ring; 7388c2ecf20Sopenharmony_ci dma_addr_t tx_ring_dma_addr; /* tx descriptor ring base address */ 7398c2ecf20Sopenharmony_ci dma_addr_t rx_ring_dma_addr; /* rx descriptor ring base address */ 7408c2ecf20Sopenharmony_ci const char *name; 7418c2ecf20Sopenharmony_ci struct pci_dev *pci_dev; /* Ptr to the associated pci_dev */ 7428c2ecf20Sopenharmony_ci struct net_device* amd8111e_net_dev; /* ptr to associated net_device */ 7438c2ecf20Sopenharmony_ci /* Transmit and receive skbs */ 7448c2ecf20Sopenharmony_ci struct sk_buff *tx_skbuff[NUM_TX_BUFFERS]; 7458c2ecf20Sopenharmony_ci struct sk_buff *rx_skbuff[NUM_RX_BUFFERS]; 7468c2ecf20Sopenharmony_ci /* Transmit and receive dma mapped addr */ 7478c2ecf20Sopenharmony_ci dma_addr_t tx_dma_addr[NUM_TX_BUFFERS]; 7488c2ecf20Sopenharmony_ci dma_addr_t rx_dma_addr[NUM_RX_BUFFERS]; 7498c2ecf20Sopenharmony_ci /* Reg memory mapped address */ 7508c2ecf20Sopenharmony_ci void __iomem *mmio; 7518c2ecf20Sopenharmony_ci 7528c2ecf20Sopenharmony_ci struct napi_struct napi; 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_ci spinlock_t lock; /* Guard lock */ 7558c2ecf20Sopenharmony_ci unsigned long rx_idx, tx_idx; /* The next free ring entry */ 7568c2ecf20Sopenharmony_ci unsigned long tx_complete_idx; 7578c2ecf20Sopenharmony_ci unsigned long tx_ring_complete_idx; 7588c2ecf20Sopenharmony_ci unsigned long tx_ring_idx; 7598c2ecf20Sopenharmony_ci unsigned int rx_buff_len; /* Buffer length of rx buffers */ 7608c2ecf20Sopenharmony_ci int options; /* Options enabled/disabled for the device */ 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_ci unsigned long ext_phy_option; 7638c2ecf20Sopenharmony_ci int ext_phy_addr; 7648c2ecf20Sopenharmony_ci u32 ext_phy_id; 7658c2ecf20Sopenharmony_ci 7668c2ecf20Sopenharmony_ci struct amd8111e_link_config link_config; 7678c2ecf20Sopenharmony_ci int pm_cap; 7688c2ecf20Sopenharmony_ci 7698c2ecf20Sopenharmony_ci struct net_device *next; 7708c2ecf20Sopenharmony_ci int mii; 7718c2ecf20Sopenharmony_ci struct mii_if_info mii_if; 7728c2ecf20Sopenharmony_ci char opened; 7738c2ecf20Sopenharmony_ci unsigned int drv_rx_errors; 7748c2ecf20Sopenharmony_ci struct amd8111e_coalesce_conf coal_conf; 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_ci struct ipg_info ipg_data; 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci}; 7798c2ecf20Sopenharmony_ci 7808c2ecf20Sopenharmony_ci/* kernel provided writeq does not write 64 bits into the amd8111e device register instead writes only higher 32bits data into lower 32bits of the register. 7818c2ecf20Sopenharmony_ciBUG? */ 7828c2ecf20Sopenharmony_ci#define amd8111e_writeq(_UlData,_memMap) \ 7838c2ecf20Sopenharmony_ci writel(*(u32*)(&_UlData), _memMap); \ 7848c2ecf20Sopenharmony_ci writel(*(u32*)((u8*)(&_UlData)+4), _memMap+4) 7858c2ecf20Sopenharmony_ci 7868c2ecf20Sopenharmony_ci/* maps the external speed options to internal value */ 7878c2ecf20Sopenharmony_citypedef enum { 7888c2ecf20Sopenharmony_ci SPEED_AUTONEG, 7898c2ecf20Sopenharmony_ci SPEED10_HALF, 7908c2ecf20Sopenharmony_ci SPEED10_FULL, 7918c2ecf20Sopenharmony_ci SPEED100_HALF, 7928c2ecf20Sopenharmony_ci SPEED100_FULL, 7938c2ecf20Sopenharmony_ci}EXT_PHY_OPTION; 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_cistatic int card_idx; 7968c2ecf20Sopenharmony_cistatic int speed_duplex[MAX_UNITS] = { 0, }; 7978c2ecf20Sopenharmony_cistatic bool coalesce[MAX_UNITS] = { [ 0 ... MAX_UNITS-1] = true }; 7988c2ecf20Sopenharmony_cistatic bool dynamic_ipg[MAX_UNITS] = { [ 0 ... MAX_UNITS-1] = false }; 7998c2ecf20Sopenharmony_cistatic unsigned int chip_version; 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_ci#endif /* _AMD8111E_H */ 8028c2ecf20Sopenharmony_ci 803