1837SN/A/*
21762SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
3837SN/A * All rights reserved.
4837SN/A *
5837SN/A * Redistribution and use in source and binary forms, with or without
6837SN/A * modification, are permitted provided that the following conditions are
7837SN/A * met: redistributions of source code must retain the above copyright
8837SN/A * notice, this list of conditions and the following disclaimer;
9837SN/A * redistributions in binary form must reproduce the above copyright
10837SN/A * notice, this list of conditions and the following disclaimer in the
11837SN/A * documentation and/or other materials provided with the distribution;
12837SN/A * neither the name of the copyright holders nor the names of its
13837SN/A * contributors may be used to endorse or promote products derived from
14837SN/A * this software without specific prior written permission.
15837SN/A *
16837SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17837SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18837SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19837SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20837SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21837SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22837SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23837SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24837SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25837SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26837SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665SN/A *
282665SN/A * Authors: Lisa Hsu
29837SN/A */
30837SN/A
311730SN/A/** @file
32837SN/A * Ethernet device register definitions for the National
33837SN/A * Semiconductor DP83820 Ethernet controller
34837SN/A */
35837SN/A
361057SN/A#ifndef __DEV_NS_GIGE_REG_H__
371057SN/A#define __DEV_NS_GIGE_REG_H__
38837SN/A
391690SN/A/* Device Register Address Map */
405086SN/Aenum DeviceRegisterAddress {
415086SN/A    CR =                0x00,
425086SN/A    CFGR =              0x04,
435086SN/A    MEAR =              0x08,
445086SN/A    PTSCR =             0x0c,
455086SN/A    ISR =               0x10,
465086SN/A    IMR =               0x14,
475086SN/A    IER =               0x18,
485086SN/A    IHR =               0x1c,
495086SN/A    TXDP =              0x20,
505086SN/A    TXDP_HI =           0x24,
515086SN/A    TX_CFG =            0x28,
525086SN/A    GPIOR =             0x2c,
535086SN/A    RXDP =              0x30,
545086SN/A    RXDP_HI =           0x34,
555086SN/A    RX_CFG =            0x38,
565086SN/A    PQCR =              0x3c,
575086SN/A    WCSR =              0x40,
585086SN/A    PCR =               0x44,
595086SN/A    RFCR =              0x48,
605086SN/A    RFDR =              0x4c,
615086SN/A    BRAR =              0x50,
625086SN/A    BRDR =              0x54,
635086SN/A    SRR =               0x58,
645086SN/A    MIBC =              0x5c,
655086SN/A    MIB_START =         0x60,
665086SN/A    MIB_END =           0x88,
675086SN/A    VRCR =              0xbc,
685086SN/A    VTCR =              0xc0,
695086SN/A    VDR =               0xc4,
705086SN/A    CCSR =              0xcc,
715086SN/A    TBICR =             0xe0,
725086SN/A    TBISR =             0xe4,
735086SN/A    TANAR =             0xe8,
745086SN/A    TANLPAR =           0xec,
755086SN/A    TANER =             0xf0,
765086SN/A    TESR =              0xf4,
775086SN/A    M5REG =             0xf8,
785086SN/A    LAST =              0xf8,
795086SN/A    RESERVED =          0xfc
805086SN/A};
81837SN/A
821690SN/A/* Chip Command Register */
835086SN/Aenum ChipCommandRegister {
845086SN/A     CR_TXE =           0x00000001,
855086SN/A     CR_TXD =           0x00000002,
865086SN/A     CR_RXE =           0x00000004,
875086SN/A     CR_RXD =           0x00000008,
885086SN/A     CR_TXR =           0x00000010,
895086SN/A     CR_RXR =           0x00000020,
905086SN/A     CR_SWI =           0x00000080,
915086SN/A     CR_RST =           0x00000100
925086SN/A};
93837SN/A
94837SN/A/* configuration register */
955086SN/Aenum ConfigurationRegisters {
9611294Sandreas.hansson@arm.com     CFGR_ZERO =        0x00000000,
975086SN/A     CFGR_LNKSTS =      0x80000000,
985086SN/A     CFGR_SPDSTS =      0x60000000,
995086SN/A     CFGR_SPDSTS1 =     0x40000000,
1005086SN/A     CFGR_SPDSTS0 =     0x20000000,
1015086SN/A     CFGR_DUPSTS =      0x10000000,
1025086SN/A     CFGR_TBI_EN =      0x01000000,
1035086SN/A     CFGR_RESERVED =    0x0e000000,
1045086SN/A     CFGR_MODE_1000 =   0x00400000,
1055086SN/A     CFGR_AUTO_1000 =   0x00200000,
1065086SN/A     CFGR_PINT_CTL =    0x001c0000,
1075086SN/A     CFGR_PINT_DUPSTS = 0x00100000,
1085086SN/A     CFGR_PINT_LNKSTS = 0x00080000,
1095086SN/A     CFGR_PINT_SPDSTS = 0x00040000,
1105086SN/A     CFGR_TMRTEST =     0x00020000,
1115086SN/A     CFGR_MRM_DIS =     0x00010000,
1125086SN/A     CFGR_MWI_DIS =     0x00008000,
1135086SN/A     CFGR_T64ADDR =     0x00004000,
1145086SN/A     CFGR_PCI64_DET =   0x00002000,
1155086SN/A     CFGR_DATA64_EN =   0x00001000,
1165086SN/A     CFGR_M64ADDR =     0x00000800,
1175086SN/A     CFGR_PHY_RST =     0x00000400,
1185086SN/A     CFGR_PHY_DIS =     0x00000200,
1195086SN/A     CFGR_EXTSTS_EN =   0x00000100,
1205086SN/A     CFGR_REQALG =      0x00000080,
1215086SN/A     CFGR_SB =          0x00000040,
1225086SN/A     CFGR_POW =         0x00000020,
1235086SN/A     CFGR_EXD =         0x00000010,
1245086SN/A     CFGR_PESEL =       0x00000008,
1255086SN/A     CFGR_BROM_DIS =    0x00000004,
1265086SN/A     CFGR_EXT_125 =     0x00000002,
1275086SN/A     CFGR_BEM =         0x00000001
1285086SN/A};
129837SN/A
130837SN/A/* EEPROM access register */
1315086SN/Aenum EEPROMAccessRegister {
1325086SN/A     MEAR_EEDI =        0x00000001,
1335086SN/A     MEAR_EEDO =        0x00000002,
1345086SN/A     MEAR_EECLK =       0x00000004,
1355086SN/A     MEAR_EESEL =       0x00000008,
1365086SN/A     MEAR_MDIO =        0x00000010,
1375086SN/A     MEAR_MDDIR =       0x00000020,
1385086SN/A     MEAR_MDC =         0x00000040,
1395086SN/A};
140837SN/A
141837SN/A/* PCI test control register */
1425086SN/Aenum PCITestControlRegister {
1435086SN/A     PTSCR_EEBIST_FAIL =        0x00000001,
1445086SN/A     PTSCR_EEBIST_EN =          0x00000002,
1455086SN/A     PTSCR_EELOAD_EN =          0x00000004,
1465086SN/A     PTSCR_RBIST_FAIL =         0x000001b8,
1475086SN/A     PTSCR_RBIST_DONE =         0x00000200,
1485086SN/A     PTSCR_RBIST_EN =           0x00000400,
1495086SN/A     PTSCR_RBIST_RST =          0x00002000,
1505086SN/A     PTSCR_RBIST_RDONLY =       0x000003f9
1515086SN/A};
152837SN/A
153837SN/A/* interrupt status register */
1545086SN/Aenum InterruptStatusRegister {
1555086SN/A     ISR_RESERVE =      0x80000000,
1565086SN/A     ISR_TXDESC3 =      0x40000000,
1575086SN/A     ISR_TXDESC2 =      0x20000000,
1585086SN/A     ISR_TXDESC1 =      0x10000000,
1595086SN/A     ISR_TXDESC0 =      0x08000000,
1605086SN/A     ISR_RXDESC3 =      0x04000000,
1615086SN/A     ISR_RXDESC2 =      0x02000000,
1625086SN/A     ISR_RXDESC1 =      0x01000000,
1635086SN/A     ISR_RXDESC0 =      0x00800000,
1645086SN/A     ISR_TXRCMP =       0x00400000,
1655086SN/A     ISR_RXRCMP =       0x00200000,
1665086SN/A     ISR_DPERR =        0x00100000,
1675086SN/A     ISR_SSERR =        0x00080000,
1685086SN/A     ISR_RMABT =        0x00040000,
1695086SN/A     ISR_RTAB =         0x00020000,
1705086SN/A     ISR_RXSOVR =       0x00010000,
1715086SN/A     ISR_HIBINT =       0x00008000,
1725086SN/A     ISR_PHY =          0x00004000,
1735086SN/A     ISR_PME =          0x00002000,
1745086SN/A     ISR_SWI =          0x00001000,
1755086SN/A     ISR_MIB =          0x00000800,
1765086SN/A     ISR_TXURN =        0x00000400,
1775086SN/A     ISR_TXIDLE =       0x00000200,
1785086SN/A     ISR_TXERR =        0x00000100,
1795086SN/A     ISR_TXDESC =       0x00000080,
1805086SN/A     ISR_TXOK =         0x00000040,
1815086SN/A     ISR_RXORN =        0x00000020,
1825086SN/A     ISR_RXIDLE =       0x00000010,
1835086SN/A     ISR_RXEARLY =      0x00000008,
1845086SN/A     ISR_RXERR =        0x00000004,
1855086SN/A     ISR_RXDESC =       0x00000002,
1865086SN/A     ISR_RXOK =         0x00000001,
1875086SN/A     ISR_ALL =          0x7FFFFFFF,
1885086SN/A     ISR_DELAY =        (ISR_TXIDLE|ISR_TXDESC|ISR_TXOK|
1895086SN/A                         ISR_RXIDLE|ISR_RXDESC|ISR_RXOK),
1905086SN/A     ISR_NODELAY =      (ISR_ALL & ~ISR_DELAY),
1915086SN/A     ISR_IMPL =         (ISR_SWI|ISR_TXIDLE|ISR_TXDESC|ISR_TXOK|ISR_RXORN|
1925086SN/A                         ISR_RXIDLE|ISR_RXDESC|ISR_RXOK),
1935086SN/A     ISR_NOIMPL =       (ISR_ALL & ~ISR_IMPL)
1945086SN/A};
195837SN/A
196837SN/A/* transmit configuration register */
1975086SN/Aenum TransmitConfigurationRegister {
1985086SN/A     TX_CFG_CSI =       0x80000000,
1995086SN/A     TX_CFG_HBI =       0x40000000,
2005086SN/A     TX_CFG_MLB =       0x20000000,
2015086SN/A     TX_CFG_ATP =       0x10000000,
2025086SN/A     TX_CFG_ECRETRY =   0x00800000,
2035086SN/A     TX_CFG_BRST_DIS =  0x00080000,
2045086SN/A     TX_CFG_MXDMA1024 = 0x00000000,
2055086SN/A     TX_CFG_MXDMA512 =  0x00700000,
2065086SN/A     TX_CFG_MXDMA256 =  0x00600000,
2075086SN/A     TX_CFG_MXDMA128 =  0x00500000,
2085086SN/A     TX_CFG_MXDMA64 =   0x00400000,
2095086SN/A     TX_CFG_MXDMA32 =   0x00300000,
2105086SN/A     TX_CFG_MXDMA16 =   0x00200000,
2115086SN/A     TX_CFG_MXDMA8 =    0x00100000,
2125086SN/A     TX_CFG_MXDMA =     0x00700000,
213837SN/A
2145086SN/A     TX_CFG_FLTH_MASK = 0x0000ff00,
2155086SN/A     TX_CFG_DRTH_MASK = 0x000000ff
2165086SN/A};
217837SN/A
218837SN/A/*general purpose I/O control register */
2195086SN/Aenum GeneralPurposeIOControlRegister {
2205086SN/A     GPIOR_UNUSED =     0xffff8000,
2215086SN/A     GPIOR_GP5_IN =     0x00004000,
2225086SN/A     GPIOR_GP4_IN =     0x00002000,
2235086SN/A     GPIOR_GP3_IN =     0x00001000,
2245086SN/A     GPIOR_GP2_IN =     0x00000800,
2255086SN/A     GPIOR_GP1_IN =     0x00000400,
2265086SN/A     GPIOR_GP5_OE =     0x00000200,
2275086SN/A     GPIOR_GP4_OE =     0x00000100,
2285086SN/A     GPIOR_GP3_OE =     0x00000080,
2295086SN/A     GPIOR_GP2_OE =     0x00000040,
2305086SN/A     GPIOR_GP1_OE =     0x00000020,
2315086SN/A     GPIOR_GP5_OUT =    0x00000010,
2325086SN/A     GPIOR_GP4_OUT =    0x00000008,
2335086SN/A     GPIOR_GP3_OUT =    0x00000004,
2345086SN/A     GPIOR_GP2_OUT =    0x00000002,
2355086SN/A     GPIOR_GP1_OUT =    0x00000001
2365086SN/A};
237837SN/A
238837SN/A/* receive configuration register */
2395086SN/Aenum ReceiveConfigurationRegister {
2405086SN/A     RX_CFG_AEP =       0x80000000,
2415086SN/A     RX_CFG_ARP =       0x40000000,
2425086SN/A     RX_CFG_STRIPCRC =  0x20000000,
2435086SN/A     RX_CFG_RX_FD =     0x10000000,
2445086SN/A     RX_CFG_ALP =       0x08000000,
2455086SN/A     RX_CFG_AIRL =      0x04000000,
2465086SN/A     RX_CFG_MXDMA512 =  0x00700000,
2475086SN/A     RX_CFG_MXDMA =     0x00700000,
2485086SN/A     RX_CFG_DRTH =      0x0000003e,
2495086SN/A     RX_CFG_DRTH0 =     0x00000002
2505086SN/A};
251837SN/A
252837SN/A/* pause control status register */
2535086SN/Aenum PauseControlStatusRegister {
2545086SN/A     PCR_PSEN =         (1 << 31),
2555086SN/A     PCR_PS_MCAST =     (1 << 30),
2565086SN/A     PCR_PS_DA =        (1 << 29),
2575086SN/A     PCR_STHI_8 =       (3 << 23),
2585086SN/A     PCR_STLO_4 =       (1 << 23),
2595086SN/A     PCR_FFHI_8K =      (3 << 21),
2605086SN/A     PCR_FFLO_4K =      (1 << 21),
2615086SN/A     PCR_PAUSE_CNT =    0xFFFE
2625086SN/A};
263837SN/A
264837SN/A/*receive filter/match control register */
2655086SN/Aenum ReceiveFilterMatchControlRegister {
2665086SN/A     RFCR_RFEN =        0x80000000,
2675086SN/A     RFCR_AAB =         0x40000000,
2685086SN/A     RFCR_AAM =         0x20000000,
2695086SN/A     RFCR_AAU =         0x10000000,
2705086SN/A     RFCR_APM =         0x08000000,
2715086SN/A     RFCR_APAT =        0x07800000,
2725086SN/A     RFCR_APAT3 =       0x04000000,
2735086SN/A     RFCR_APAT2 =       0x02000000,
2745086SN/A     RFCR_APAT1 =       0x01000000,
2755086SN/A     RFCR_APAT0 =       0x00800000,
2765086SN/A     RFCR_AARP =        0x00400000,
2775086SN/A     RFCR_MHEN =        0x00200000,
2785086SN/A     RFCR_UHEN =        0x00100000,
2795086SN/A     RFCR_ULM =         0x00080000,
2805086SN/A     RFCR_RFADDR =      0x000003ff
2815086SN/A};
282837SN/A
283837SN/A/* receive filter/match data register */
2845086SN/Aenum ReceiveFilterMatchDataRegister {
2855086SN/A     RFDR_BMASK =       0x00030000,
2865086SN/A     RFDR_RFDATA0 =     0x000000ff,
2875086SN/A     RFDR_RFDATA1 =     0x0000ff00
2885086SN/A};
289837SN/A
290837SN/A/* management information base control register */
2915086SN/Aenum ManagementInformationBaseControlRegister {
2925086SN/A     MIBC_MIBS =        0x00000008,
2935086SN/A     MIBC_ACLR =        0x00000004,
2945086SN/A     MIBC_FRZ =         0x00000002,
2955086SN/A     MIBC_WRN =         0x00000001
2965086SN/A};
297837SN/A
298837SN/A/* VLAN/IP receive control register */
2995086SN/Aenum VLANIPReceiveControlRegister {
3005086SN/A     VRCR_RUDPE =       0x00000080,
3015086SN/A     VRCR_RTCPE =       0x00000040,
3025086SN/A     VRCR_RIPE =        0x00000020,
3035086SN/A     VRCR_IPEN =        0x00000010,
3045086SN/A     VRCR_DUTF =        0x00000008,
3055086SN/A     VRCR_DVTF =        0x00000004,
3065086SN/A     VRCR_VTREN =       0x00000002,
3075086SN/A     VRCR_VTDEN =       0x00000001
3085086SN/A};
309837SN/A
310837SN/A/* VLAN/IP transmit control register */
3115086SN/Aenum VLANIPTransmitControlRegister {
3125086SN/A     VTCR_PPCHK =       0x00000008,
3135086SN/A     VTCR_GCHK =        0x00000004,
3145086SN/A     VTCR_VPPTI =       0x00000002,
3155086SN/A     VTCR_VGTI =        0x00000001
3165086SN/A};
317837SN/A
318837SN/A/* Clockrun Control/Status Register */
3195086SN/Aenum ClockrunControlStatusRegister {
3205086SN/A     CCSR_CLKRUN_EN =   0x00000001
3215086SN/A};
322837SN/A
323837SN/A/* TBI control register */
3245086SN/Aenum TBIControlRegister {
3255086SN/A     TBICR_MR_LOOPBACK =        0x00004000,
3265086SN/A     TBICR_MR_AN_ENABLE =       0x00001000,
3275086SN/A     TBICR_MR_RESTART_AN =      0x00000200
3285086SN/A};
329837SN/A
330837SN/A/* TBI status register */
3315086SN/Aenum TBIStatusRegister {
3325086SN/A     TBISR_MR_LINK_STATUS =     0x00000020,
3335086SN/A     TBISR_MR_AN_COMPLETE =     0x00000004
3345086SN/A};
335837SN/A
336837SN/A/* TBI auto-negotiation advertisement register */
3375086SN/Aenum TBIAutoNegotiationAdvertisementRegister {
3385086SN/A     TANAR_NP =         0x00008000,
3395086SN/A     TANAR_RF2 =        0x00002000,
3405086SN/A     TANAR_RF1 =        0x00001000,
3415086SN/A     TANAR_PS2 =        0x00000100,
3425086SN/A     TANAR_PS1 =        0x00000080,
3435086SN/A     TANAR_HALF_DUP =   0x00000040,
3445086SN/A     TANAR_FULL_DUP =   0x00000020,
3455086SN/A     TANAR_UNUSED =     0x00000E1F
3465086SN/A};
347837SN/A
3481922SN/A/* M5 control register */
3495086SN/Aenum M5ControlRegister {
3505086SN/A     M5REG_RESERVED =   0xfffffffc,
3515086SN/A     M5REG_RSS =        0x00000004,
3525086SN/A     M5REG_RX_THREAD =  0x00000002,
3535086SN/A     M5REG_TX_THREAD =  0x00000001
3545086SN/A};
3551922SN/A
3561909SN/Astruct ns_desc32 {
3571909SN/A    uint32_t link;    /* link field to next descriptor in linked list */
3581909SN/A    uint32_t bufptr;  /* pointer to the first fragment or buffer */
3591909SN/A    uint32_t cmdsts;  /* command/status field */
3601909SN/A    uint32_t extsts;  /* extended status field for VLAN and IP info */
3611909SN/A};
3621909SN/A
3631909SN/Astruct ns_desc64 {
3641909SN/A    uint64_t link;    /* link field to next descriptor in linked list */
3651909SN/A    uint64_t bufptr;  /* pointer to the first fragment or buffer */
3661909SN/A    uint32_t cmdsts;  /* command/status field */
3671909SN/A    uint32_t extsts;  /* extended status field for VLAN and IP info */
368837SN/A};
369837SN/A
370837SN/A/* cmdsts flags for descriptors */
3715086SN/Aenum CMDSTSFlatsForDescriptors {
3725086SN/A     CMDSTS_OWN =       0x80000000,
3735086SN/A     CMDSTS_MORE =      0x40000000,
3745086SN/A     CMDSTS_INTR =      0x20000000,
3755086SN/A     CMDSTS_ERR =       0x10000000,
3765086SN/A     CMDSTS_OK =        0x08000000,
3775086SN/A     CMDSTS_LEN_MASK =  0x0000ffff,
378837SN/A
3795086SN/A     CMDSTS_DEST_MASK = 0x01800000,
3805086SN/A     CMDSTS_DEST_SELF = 0x00800000,
3815086SN/A     CMDSTS_DEST_MULTI = 0x01000000
3825086SN/A};
383837SN/A
384837SN/A/* extended flags for descriptors */
3855086SN/Aenum ExtendedFlagsForDescriptors {
3865086SN/A     EXTSTS_UDPERR =    0x00400000,
3875086SN/A     EXTSTS_UDPPKT =    0x00200000,
3885086SN/A     EXTSTS_TCPERR =    0x00100000,
3895086SN/A     EXTSTS_TCPPKT =    0x00080000,
3905086SN/A     EXTSTS_IPERR =     0x00040000,
3915086SN/A     EXTSTS_IPPKT =     0x00020000
3925086SN/A};
393837SN/A
394837SN/A/* speed status */
3955086SN/Astatic inline int
3965086SN/ASPDSTS_POLARITY(int lnksts)
3975086SN/A{
3985086SN/A    return (CFGR_SPDSTS1 | CFGR_SPDSTS0 | CFGR_DUPSTS |
39911294Sandreas.hansson@arm.com            (lnksts ? CFGR_LNKSTS : CFGR_ZERO));
4005086SN/A}
401837SN/A
4021057SN/A#endif /* __DEV_NS_GIGE_REG_H__ */
403