Home | History | Annotate | Line # | Download | only in ic
dwc_gmac_reg.h revision 1.8
      1 /*-
      2  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
      3  * All rights reserved.
      4  *
      5  * This code is derived from software contributed to The NetBSD Foundation
      6  * by Matt Thomas of 3am Software Foundry and Martin Husemann.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27  * POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 
     30 #define	AWIN_GMAC_MAC_CONF		0x0000
     31 #define	AWIN_GMAC_MAC_FFILT		0x0004
     32 #define	AWIN_GMAC_MAC_HTHIGH		0x0008
     33 #define	AWIN_GMAC_MAC_HTLOW		0x000c
     34 #define	AWIN_GMAC_MAC_MIIADDR		0x0010
     35 #define	AWIN_GMAC_MAC_MIIDATA		0x0014
     36 #define	AWIN_GMAC_MAC_FLOWCTRL		0x0018
     37 #define	AWIN_GMAC_MAC_VLANTAG		0x001c
     38 #define	AWIN_GMAC_MAC_VERSION		0x0020	/* not always implemented? */
     39 #define	AWIN_GMAC_MAC_INTR		0x0038
     40 #define	AWIN_GMAC_MAC_INTMASK		0x003c
     41 #define	AWIN_GMAC_MAC_ADDR0HI		0x0040
     42 #define	AWIN_GMAC_MAC_ADDR0LO		0x0044
     43 #define	AWIN_GMAC_MII_STATUS		0x00D8
     44 
     45 #define	AWIN_GMAC_MAC_CONF_FRAMEBURST	__BIT(21) /* allow TX frameburst when
     46 						     in half duplex mode */
     47 #define	AWIN_GMAC_MAC_CONF_MIISEL	__BIT(15) /* select MII phy */
     48 #define	AWIN_GMAC_MAC_CONF_FES100	__BIT(14) /* 100 mbit mode */
     49 #define	AWIN_GMAC_MAC_CONF_DISABLERXOWN	__BIT(13) /* do not receive our own
     50 						     TX frames in half duplex
     51 						     mode */
     52 #define	AWIN_GMAC_MAC_CONF_FULLDPLX	__BIT(11) /* select full duplex */
     53 #define	AWIN_GMAC_MAC_CONF_TXENABLE	__BIT(3)  /* enable TX dma engine */
     54 #define	AWIN_GMAC_MAC_CONF_RXENABLE	__BIT(2)  /* enable RX dma engine */
     55 
     56 #define	AWIN_GMAC_MAC_FFILT_PM		__BIT(4) /* promiscious multicast */
     57 #define	AWIN_GMAC_MAC_FFILT_HMC		__BIT(2) /* multicast hash compare */
     58 #define	AWIN_GMAC_MAC_FFILT_HUC		__BIT(1) /* unicast hash compare */
     59 #define	AWIN_GMAC_MAC_FFILT_PR		__BIT(0) /* promiscious mode */
     60 
     61 #define	AWIN_GMAC_MAC_INT_LPI		__BIT(10)
     62 #define	AWIN_GMAC_MAC_INT_TSI		__BIT(9)
     63 #define	AWIN_GMAC_MAC_INT_ANEG		__BIT(2)
     64 #define	AWIN_GMAC_MAC_INT_LINKCHG	__BIT(1)
     65 #define	AWIN_GMAC_MAC_INT_RGSMII	__BIT(0)
     66 
     67 #define	AWIN_GMAC_DMA_BUSMODE		0x1000
     68 #define	AWIN_GMAC_DMA_TXPOLL		0x1004
     69 #define	AWIN_GMAC_DMA_RXPOLL		0x1008
     70 #define	AWIN_GMAC_DMA_RX_ADDR		0x100c
     71 #define	AWIN_GMAC_DMA_TX_ADDR		0x1010
     72 #define	AWIN_GMAC_DMA_STATUS		0x1014
     73 #define	AWIN_GMAC_DMA_OPMODE		0x1018
     74 #define	AWIN_GMAC_DMA_INTENABLE		0x101c
     75 #define	AWIN_GMAC_DMA_CUR_TX_DESC	0x1048
     76 #define	AWIN_GMAC_DMA_CUR_RX_DESC	0x104c
     77 #define	AWIN_GMAC_DMA_CUR_TX_BUFADDR	0x1050
     78 #define	AWIN_GMAC_DMA_CUR_RX_BUFADDR	0x1054
     79 #define	AWIN_GMAC_DMA_HWFEATURES	0x1058	/* not always implemented? */
     80 
     81 #define	GMAC_MII_PHY_SHIFT		11
     82 #define	GMAC_MII_PHY_MASK		__BITS(15,11)
     83 #define	GMAC_MII_REG_SHIFT		6
     84 #define	GMAC_MII_REG_MASK		__BITS(10,6)
     85 
     86 #define	GMAC_MII_BUSY			__BIT(0)
     87 #define	GMAC_MII_WRITE			__BIT(1)
     88 #define	GMAC_MII_CLK_60_100M_DIV42	0x0
     89 #define	GMAC_MII_CLK_100_150M_DIV62	0x1
     90 #define	GMAC_MII_CLK_25_35M_DIV16	0x2
     91 #define	GMAC_MII_CLK_35_60M_DIV26	0x3
     92 #define	GMAC_MII_CLK_150_250M_DIV102	0x4
     93 #define	GMAC_MII_CLK_250_300M_DIV124	0x5
     94 #define	GMAC_MII_CLK_DIV4		0x8
     95 #define	GMAC_MII_CLK_DIV6		0x9
     96 #define	GMAC_MII_CLK_DIV8		0xa
     97 #define	GMAC_MII_CLK_DIV10		0xb
     98 #define	GMAC_MII_CLK_DIV12		0xc
     99 #define	GMAC_MII_CLK_DIV14		0xd
    100 #define	GMAC_MII_CLK_DIV16		0xe
    101 #define	GMAC_MII_CLK_DIV18		0xf
    102 #define	GMAC_MII_CLKMASK		__BITS(5,2)
    103 
    104 #define	GMAC_BUSMODE_FIXEDBURST		__BIT(16)
    105 #define	GMAC_BUSMODE_PRIORXTX		__BITS(15,14)
    106 #define	GMAC_BUSMODE_PRIORXTX_41	3
    107 #define	GMAC_BUSMODE_PRIORXTX_31	2
    108 #define	GMAC_BUSMODE_PRIORXTX_21	1
    109 #define	GMAC_BUSMODE_PRIORXTX_11	0
    110 #define	GMCA_BUSMODE_PBL		__BITS(13,8) /* possible DMA
    111 						        burst len */
    112 #define	GMAC_BUSMODE_RESET		__BIT(0)
    113 
    114 #define	AWIN_GMAC_MII_IRQ		__BIT(0)
    115 
    116 
    117 #define	GMAC_DMA_OP_STOREFORWARD	__BIT(21) /* start TX with when a
    118  						    full frame is available */
    119 #define	GMAC_DMA_OP_FLUSHTX		__BIT(20) /* flush TX fifo */
    120 #define	GMAC_DMA_OP_TXSTART		__BIT(13) /* start TX DMA engine */
    121 #define	GMAC_DMA_OP_RXSTART		__BIT(1)  /* start RX DMA engine */
    122 
    123 #define	GMAC_DMA_INT_NIE		__BIT(16) /* Normal/Summary */
    124 #define	GMAC_DMA_INT_AIE		__BIT(15) /* Abnormal/Summary */
    125 #define	GMAC_DMA_INT_ERE		__BIT(14) /* Early receive */
    126 #define	GMAC_DMA_INT_FBE		__BIT(13) /* Fatal bus error */
    127 #define	GMAC_DMA_INT_ETE		__BIT(10) /* Early transmit */
    128 #define	GMAC_DMA_INT_RWE		__BIT(9)  /* Receive watchdog */
    129 #define	GMAC_DMA_INT_RSE		__BIT(8)  /* Receive stopped */
    130 #define	GMAC_DMA_INT_RUE		__BIT(7)  /* Receive buffer unavail. */
    131 #define	GMAC_DMA_INT_RIE		__BIT(6)  /* Receive interrupt */
    132 #define	GMAC_DMA_INT_UNE		__BIT(5)  /* Tx underflow */
    133 #define	GMAC_DMA_INT_OVE		__BIT(4)  /* Receive overflow */
    134 #define	GMAC_DMA_INT_TJE		__BIT(3)  /* Transmit jabber */
    135 #define	GMAC_DMA_INT_TUE		__BIT(2)  /* Transmit buffer unavail. */
    136 #define	GMAC_DMA_INT_TSE		__BIT(1)  /* Transmit stopped */
    137 #define	GMAC_DMA_INT_TIE		__BIT(0)  /* Transmit interrupt */
    138 
    139 #define	GMAC_DMA_INT_MASK	__BITS(0,16)	  /* all possible intr bits */
    140 
    141 struct dwc_gmac_dev_dmadesc {
    142 	uint32_t ddesc_status;
    143 /* both: */
    144 #define	DDESC_STATUS_OWNEDBYDEV		__BIT(31)
    145 
    146 /* for RX descriptors */
    147 #define	DDESC_STATUS_DAFILTERFAIL	__BIT(30)
    148 #define	DDESC_STATUS_FRMLENMSK		__BITS(29,16)
    149 #define	DDESC_STATUS_FRMLENSHIFT	16
    150 #define	DDESC_STATUS_RXERROR		__BIT(15)
    151 #define	DDESC_STATUS_RXTRUNCATED	__BIT(14)
    152 #define	DDESC_STATUS_SAFILTERFAIL	__BIT(13)
    153 #define	DDESC_STATUS_RXIPC_GIANTFRAME	__BIT(12)
    154 #define	DDESC_STATUS_RXDAMAGED		__BIT(11)
    155 #define	DDESC_STATUS_RXVLANTAG		__BIT(10)
    156 #define	DDESC_STATUS_RXFIRST		__BIT(9)
    157 #define	DDESC_STATUS_RXLAST		__BIT(8)
    158 #define	DDESC_STATUS_RXIPC_GIANT	__BIT(7)
    159 #define	DDESC_STATUS_RXCOLLISION	__BIT(6)
    160 #define	DDESC_STATUS_RXFRAMEETHER	__BIT(5)
    161 #define	DDESC_STATUS_RXWATCHDOG		__BIT(4)
    162 #define	DDESC_STATUS_RXMIIERROR		__BIT(3)
    163 #define	DDESC_STATUS_RXDRIBBLING	__BIT(2)
    164 #define	DDESC_STATUS_RXCRC		__BIT(1)
    165 
    166 	uint32_t ddesc_cntl;
    167 
    168 /* for TX descriptors */
    169 #define	DDESC_CNTL_TXINT		__BIT(31)
    170 #define	DDESC_CNTL_TXLAST		__BIT(30)
    171 #define	DDESC_CNTL_TXFIRST		__BIT(29)
    172 #define	DDESC_CNTL_TXCHECKINSCTRL	__BIT(27)
    173 #define	DDESC_CNTL_TXCRCDIS		__BIT(26)
    174 #define	DDESC_CNTL_TXRINGEND		__BIT(25)
    175 #define	DDESC_CNTL_TXCHAIN		__BIT(24)
    176 
    177 /* for RX descriptors */
    178 #define	DDESC_CNTL_RXINT		__BIT(31)
    179 #define	DDESC_CNTL_RXRINGEND		__BIT(25)
    180 #define	DDESC_CNTL_RXCHAIN		__BIT(24)
    181 
    182 /* both */
    183 #define	DDESC_CNTL_SIZE1MASK		__BITS(10,0)
    184 #define	DDESC_CNTL_SIZE1SHIFT		0
    185 #define	DDESC_CNTL_SIZE2MASK		__BITS(21,11)
    186 #define	DDESC_CNTL_SIZE2SHIFT		11
    187 
    188 	uint32_t ddesc_data;	/* pointer to buffer data */
    189 	uint32_t ddesc_next;	/* link to next descriptor */
    190 };
    191