dwc_gmac_reg.h revision 1.2 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
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_DMA_BUSMODE 0x1000
46 #define AWIN_GMAC_DMA_TXPOLL 0x1004
47 #define AWIN_GMAC_DMA_RXPOLL 0x1008
48 #define AWIN_GMAC_DMA_RX_ADDR 0x100c
49 #define AWIN_GMAC_DMA_TX_ADDR 0x1010
50 #define AWIN_GMAC_DMA_STATUS 0x1014
51 #define AWIN_GMAC_DMA_OPMODE 0x1018
52 #define AWIN_GMAC_DMA_INTENABLE 0x101c
53 #define AWIN_GMAC_DMA_CUR_TX_DESC 0x1048
54 #define AWIN_GMAC_DMA_CUR_RX_DESC 0x104c
55 #define AWIN_GMAC_DMA_CUR_TX_BUFADDR 0x1050
56 #define AWIN_GMAC_DMA_CUR_RX_BUFADDR 0x1054
57
58 #define GMAC_MII_PHY_SHIFT 11
59 #define GMAC_MII_PHY_MASK (0x1F << GMAC_MII_PHY_SHIFT)
60 #define GMAC_MII_REG_SHIFT 6
61 #define GMAC_MII_REG_MASK (0x1F << GMAC_MII_REG_SHIFT)
62
63 #define GMAC_MII_BUSY 1
64 #define GMAC_MII_WRITE 2
65
66 #define GMAC_BUSMODE_RESET 1
67
68 #define AWIN_GMAC_MII_IRQ 1
69
70 #define GMAC_DMA_INT_NIE 0x10000 /* Normal/Summary */
71 #define GMAC_DMA_INT_AIE 0x08000 /* Abnormal/Summary */
72 #define GMAC_DMA_INT_ERE 0x04000 /* Early receive */
73 #define GMAC_DMA_INT_FBE 0x02000 /* Fatal bus error */
74 #define GMAC_DMA_INT_ETE 0x00400 /* Early transmit */
75 #define GMAC_DMA_INT_RWE 0x00200 /* Receive watchdog */
76 #define GMAC_DMA_INT_RSE 0x00100 /* Receive stopped */
77 #define GMAC_DMA_INT_RUE 0x00080 /* Receive buffer unavailable */
78 #define GMAC_DMA_INT_RIE 0x00040 /* Receive interrupt */
79 #define GMAC_DMA_INT_UNE 0x00020 /* Tx underflow */
80 #define GMAC_DMA_INT_OVE 0x00010 /* Receive overflow */
81 #define GMAC_DMA_INT_TJE 0x00008 /* Transmit jabber */
82 #define GMAC_DMA_INT_TUE 0x00004 /* Transmit buffer unavailable */
83 #define GMAC_DMA_INT_TSE 0x00002 /* Transmit stopped */
84 #define GMAC_DMA_INT_TIE 0x00001 /* Transmit interrupt */
85
86 #define GMAC_DEF_DMA_INT_MASK (GMAC_DMA_INT_TIE|GMAC_DMA_INT_RIE| \
87 GMAC_DMA_INT_NIE|GMAC_DMA_INT_AIE| \
88 GMAC_DMA_INT_FBE|GMAC_DMA_INT_UNE)
89
90 #define AWIN_DEF_MAC_INTRMASK 0x207 /* XXX ??? */
91
92 struct dwc_gmac_dev_dmadesc {
93 uint32_t ddesc_status;
94 /* both: */
95 #define DDESC_STATUS_OWNEDBYDEV (1<<31)
96 /* for TX descriptors */
97 #define DDESC_STATUS_TXINT (1<<30)
98 #define DDESC_STATUS_TXLAST (1<<29)
99 #define DDESC_STATUS_TXFIRST (1<<28)
100 #define DDESC_STATUS_TXCRCDIS (1<<27)
101 #define DDESC_STATUS_TXPADDIS (1<<26)
102 #define DDESC_STATUS_TXCHECKINSCTRL (1<<22)
103 #define DDESC_STATUS_TXRINGEND (1<<21)
104 #define DDESC_STATUS_TXCHAIN (1<<20)
105 #define DDESC_STATUS_MASK 0x1ffff
106 /* for RX descriptors */
107 #define DDESC_STATUS_DAFILTERFAIL (1<<30)
108 #define DDESC_STATUS_FRMLENMSK (0x3fff << 16)
109 #define DDESC_STATUS_FRMLENSHIFT 16
110 #define DDESC_STATUS_RXERROR (1<<15)
111 #define DDESC_STATUS_RXTRUNCATED (1<<14)
112 #define DDESC_STATUS_SAFILTERFAIL (1<<13)
113 #define DDESC_STATUS_RXIPC_GIANTFRAME (1<<12)
114 #define DDESC_STATUS_RXDAMAGED (1<<11)
115 #define DDESC_STATUS_RXVLANTAG (1<<10)
116 #define DDESC_STATUS_RXFIRST (1<<9)
117 #define DDESC_STATUS_RXLAST (1<<8)
118 #define DDESC_STATUS_RXIPC_GIANT (1<<7)
119 #define DDESC_STATUS_RXCOLLISION (1<<6)
120 #define DDESC_STATUS_RXFRAMEETHER (1<<5)
121 #define DDESC_STATUS_RXWATCHDOG (1<<4)
122 #define DDESC_STATUS_RXMIIERROR (1<<3)
123 #define DDESC_STATUS_RXDRIBBLING (1<<2)
124 #define DDESC_STATUS_RXCRC 1
125
126 uint32_t ddesc_cntl;
127 #define DDESC_CNTL_SIZE1MASK 0x1fff
128 #define DDESC_CNTL_SIZE1SHIFT 0
129 #define DDESC_CNTL_SIZE2MASK (0x1fff<<16)
130 #define DDESC_CNTL_SIZE2SHIFT 16
131
132 uint32_t ddesc_data; /* pointer to buffer data */
133 uint32_t ddesc_next; /* link to next descriptor */
134 };
135
136