xref: /freebsd/sys/contrib/ncsw/inc/flib/fsl_fman_memac.h (revision c2c014f24c10f90d85126ac5fbd4d8524de32b1c)
1*852ba100SJustin Hibbits /*
2*852ba100SJustin Hibbits  * Copyright 2008-2012 Freescale Semiconductor Inc.
3*852ba100SJustin Hibbits  *
4*852ba100SJustin Hibbits  * Redistribution and use in source and binary forms, with or without
5*852ba100SJustin Hibbits  * modification, are permitted provided that the following conditions are met:
6*852ba100SJustin Hibbits  *     * Redistributions of source code must retain the above copyright
7*852ba100SJustin Hibbits  *       notice, this list of conditions and the following disclaimer.
8*852ba100SJustin Hibbits  *     * Redistributions in binary form must reproduce the above copyright
9*852ba100SJustin Hibbits  *       notice, this list of conditions and the following disclaimer in the
10*852ba100SJustin Hibbits  *       documentation and/or other materials provided with the distribution.
11*852ba100SJustin Hibbits  *     * Neither the name of Freescale Semiconductor nor the
12*852ba100SJustin Hibbits  *       names of its contributors may be used to endorse or promote products
13*852ba100SJustin Hibbits  *       derived from this software without specific prior written permission.
14*852ba100SJustin Hibbits  *
15*852ba100SJustin Hibbits  *
16*852ba100SJustin Hibbits  * ALTERNATIVELY, this software may be distributed under the terms of the
17*852ba100SJustin Hibbits  * GNU General Public License ("GPL") as published by the Free Software
18*852ba100SJustin Hibbits  * Foundation, either version 2 of that License or (at your option) any
19*852ba100SJustin Hibbits  * later version.
20*852ba100SJustin Hibbits  *
21*852ba100SJustin Hibbits  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22*852ba100SJustin Hibbits  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23*852ba100SJustin Hibbits  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24*852ba100SJustin Hibbits  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25*852ba100SJustin Hibbits  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26*852ba100SJustin Hibbits  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27*852ba100SJustin Hibbits  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28*852ba100SJustin Hibbits  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29*852ba100SJustin Hibbits  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30*852ba100SJustin Hibbits  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*852ba100SJustin Hibbits  */
32*852ba100SJustin Hibbits 
33*852ba100SJustin Hibbits 
34*852ba100SJustin Hibbits #ifndef __FSL_FMAN_MEMAC_H
35*852ba100SJustin Hibbits #define __FSL_FMAN_MEMAC_H
36*852ba100SJustin Hibbits 
37*852ba100SJustin Hibbits #include "common/general.h"
38*852ba100SJustin Hibbits #include "fsl_enet.h"
39*852ba100SJustin Hibbits 
40*852ba100SJustin Hibbits 
41*852ba100SJustin Hibbits #define MEMAC_NUM_OF_PADDRS 7 /* Num of additional exact match MAC adr regs */
42*852ba100SJustin Hibbits 
43*852ba100SJustin Hibbits /* Control and Configuration Register (COMMAND_CONFIG) */
44*852ba100SJustin Hibbits #define CMD_CFG_MG		0x80000000 /* 00 Magic Packet detection */
45*852ba100SJustin Hibbits #define CMD_CFG_REG_LOWP_RXETY	0x01000000 /* 07 Rx low power indication */
46*852ba100SJustin Hibbits #define CMD_CFG_TX_LOWP_ENA	0x00800000 /* 08 Tx Low Power Idle Enable */
47*852ba100SJustin Hibbits #define CMD_CFG_SFD_ANY		0x00200000 /* 10 Disable SFD check */
48*852ba100SJustin Hibbits #define CMD_CFG_PFC_MODE	0x00080000 /* 12 Enable PFC */
49*852ba100SJustin Hibbits #define CMD_CFG_NO_LEN_CHK	0x00020000 /* 14 Payload length check disable */
50*852ba100SJustin Hibbits #define CMD_CFG_SEND_IDLE	0x00010000 /* 15 Force idle generation */
51*852ba100SJustin Hibbits #define CMD_CFG_CNT_FRM_EN	0x00002000 /* 18 Control frame rx enable */
52*852ba100SJustin Hibbits #define CMD_CFG_SW_RESET	0x00001000 /* 19 S/W Reset, self clearing bit */
53*852ba100SJustin Hibbits #define CMD_CFG_TX_PAD_EN	0x00000800 /* 20 Enable Tx padding of frames */
54*852ba100SJustin Hibbits #define CMD_CFG_LOOPBACK_EN	0x00000400 /* 21 XGMII/GMII loopback enable */
55*852ba100SJustin Hibbits #define CMD_CFG_TX_ADDR_INS	0x00000200 /* 22 Tx source MAC addr insertion */
56*852ba100SJustin Hibbits #define CMD_CFG_PAUSE_IGNORE	0x00000100 /* 23 Ignore Pause frame quanta */
57*852ba100SJustin Hibbits #define CMD_CFG_PAUSE_FWD	0x00000080 /* 24 Terminate/frwd Pause frames */
58*852ba100SJustin Hibbits #define CMD_CFG_CRC_FWD		0x00000040 /* 25 Terminate/frwd CRC of frames */
59*852ba100SJustin Hibbits #define CMD_CFG_PAD_EN		0x00000020 /* 26 Frame padding removal */
60*852ba100SJustin Hibbits #define CMD_CFG_PROMIS_EN	0x00000010 /* 27 Promiscuous operation enable */
61*852ba100SJustin Hibbits #define CMD_CFG_WAN_MODE	0x00000008 /* 28 WAN mode enable */
62*852ba100SJustin Hibbits #define CMD_CFG_RX_EN		0x00000002 /* 30 MAC receive path enable */
63*852ba100SJustin Hibbits #define CMD_CFG_TX_EN		0x00000001 /* 31 MAC transmit path enable */
64*852ba100SJustin Hibbits 
65*852ba100SJustin Hibbits /* Transmit FIFO Sections Register (TX_FIFO_SECTIONS) */
66*852ba100SJustin Hibbits #define TX_FIFO_SECTIONS_TX_EMPTY_MASK			0xFFFF0000
67*852ba100SJustin Hibbits #define TX_FIFO_SECTIONS_TX_AVAIL_MASK			0x0000FFFF
68*852ba100SJustin Hibbits #define TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G	0x00400000
69*852ba100SJustin Hibbits #define TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_1G	0x00100000
70*852ba100SJustin Hibbits #define TX_FIFO_SECTIONS_TX_EMPTY_PFC_10G		0x00360000
71*852ba100SJustin Hibbits #define TX_FIFO_SECTIONS_TX_EMPTY_PFC_1G		0x00040000
72*852ba100SJustin Hibbits #define TX_FIFO_SECTIONS_TX_AVAIL_10G			0x00000019
73*852ba100SJustin Hibbits #define TX_FIFO_SECTIONS_TX_AVAIL_1G			0x00000020
74*852ba100SJustin Hibbits #define TX_FIFO_SECTIONS_TX_AVAIL_SLOW_10G		0x00000060
75*852ba100SJustin Hibbits 
76*852ba100SJustin Hibbits #define GET_TX_EMPTY_DEFAULT_VALUE(_val)					\
77*852ba100SJustin Hibbits _val &= ~TX_FIFO_SECTIONS_TX_EMPTY_MASK;					\
78*852ba100SJustin Hibbits ((_val == TX_FIFO_SECTIONS_TX_AVAIL_10G) ?					\
79*852ba100SJustin Hibbits 		(_val |= TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_10G) :	\
80*852ba100SJustin Hibbits 		(_val |= TX_FIFO_SECTIONS_TX_EMPTY_DEFAULT_1G));
81*852ba100SJustin Hibbits 
82*852ba100SJustin Hibbits #define GET_TX_EMPTY_PFC_VALUE(_val)						\
83*852ba100SJustin Hibbits _val &= ~TX_FIFO_SECTIONS_TX_EMPTY_MASK;					\
84*852ba100SJustin Hibbits ((_val == TX_FIFO_SECTIONS_TX_AVAIL_10G) ?					\
85*852ba100SJustin Hibbits 		(_val |= TX_FIFO_SECTIONS_TX_EMPTY_PFC_10G) :		\
86*852ba100SJustin Hibbits 		(_val |= TX_FIFO_SECTIONS_TX_EMPTY_PFC_1G));
87*852ba100SJustin Hibbits 
88*852ba100SJustin Hibbits /* Interface Mode Register (IF_MODE) */
89*852ba100SJustin Hibbits #define IF_MODE_MASK		0x00000003 /* 30-31 Mask on i/f mode bits */
90*852ba100SJustin Hibbits #define IF_MODE_XGMII		0x00000000 /* 30-31 XGMII (10G) interface */
91*852ba100SJustin Hibbits #define IF_MODE_GMII		0x00000002 /* 30-31 GMII (1G) interface */
92*852ba100SJustin Hibbits #define IF_MODE_RGMII		0x00000004
93*852ba100SJustin Hibbits #define IF_MODE_RGMII_AUTO	0x00008000
94*852ba100SJustin Hibbits #define IF_MODE_RGMII_1000  0x00004000 /* 10 - 1000Mbps RGMII */
95*852ba100SJustin Hibbits #define IF_MODE_RGMII_100   0x00000000 /* 00 - 100Mbps RGMII */
96*852ba100SJustin Hibbits #define IF_MODE_RGMII_10    0x00002000 /* 01 - 10Mbps RGMII */
97*852ba100SJustin Hibbits #define IF_MODE_RGMII_SP_MASK 0x00006000 /* Setsp mask bits */
98*852ba100SJustin Hibbits #define IF_MODE_RGMII_FD    0x00001000 /* Full duplex RGMII */
99*852ba100SJustin Hibbits #define IF_MODE_HD          0x00000040 /* Half duplex operation */
100*852ba100SJustin Hibbits 
101*852ba100SJustin Hibbits /* Hash table Control Register (HASHTABLE_CTRL) */
102*852ba100SJustin Hibbits #define HASH_CTRL_MCAST_SHIFT	26
103*852ba100SJustin Hibbits #define HASH_CTRL_MCAST_EN	0x00000100 /* 23 Mcast frame rx for hash */
104*852ba100SJustin Hibbits #define HASH_CTRL_ADDR_MASK	0x0000003F /* 26-31 Hash table address code */
105*852ba100SJustin Hibbits 
106*852ba100SJustin Hibbits #define GROUP_ADDRESS		0x0000010000000000LL /* MAC mcast indication */
107*852ba100SJustin Hibbits #define HASH_TABLE_SIZE		64 /* Hash tbl size */
108*852ba100SJustin Hibbits 
109*852ba100SJustin Hibbits /* Transmit Inter-Packet Gap Length Register (TX_IPG_LENGTH) */
110*852ba100SJustin Hibbits #define MEMAC_TX_IPG_LENGTH_MASK	0x0000003F
111*852ba100SJustin Hibbits 
112*852ba100SJustin Hibbits /* Statistics Configuration Register (STATN_CONFIG) */
113*852ba100SJustin Hibbits #define STATS_CFG_CLR		0x00000004 /* 29 Reset all counters */
114*852ba100SJustin Hibbits #define STATS_CFG_CLR_ON_RD	0x00000002 /* 30 Clear on read */
115*852ba100SJustin Hibbits #define STATS_CFG_SATURATE	0x00000001 /* 31 Saturate at the maximum val */
116*852ba100SJustin Hibbits 
117*852ba100SJustin Hibbits /* Interrupt Mask Register (IMASK) */
118*852ba100SJustin Hibbits #define MEMAC_IMASK_MGI		0x40000000 /* 1 Magic pkt detect indication */
119*852ba100SJustin Hibbits #define MEMAC_IMASK_TSECC_ER 0x20000000 /* 2 Timestamp FIFO ECC error evnt */
120*852ba100SJustin Hibbits #define MEMAC_IMASK_TECC_ER	0x02000000 /* 6 Transmit frame ECC error evnt */
121*852ba100SJustin Hibbits #define MEMAC_IMASK_RECC_ER	0x01000000 /* 7 Receive frame ECC error evnt */
122*852ba100SJustin Hibbits 
123*852ba100SJustin Hibbits #define MEMAC_ALL_ERRS_IMASK			\
124*852ba100SJustin Hibbits 		((uint32_t)(MEMAC_IMASK_TSECC_ER	| \
125*852ba100SJustin Hibbits 			MEMAC_IMASK_TECC_ER	| \
126*852ba100SJustin Hibbits 			MEMAC_IMASK_RECC_ER	| \
127*852ba100SJustin Hibbits 			MEMAC_IMASK_MGI))
128*852ba100SJustin Hibbits 
129*852ba100SJustin Hibbits #define MEMAC_IEVNT_PCS			0x80000000 /* PCS (XG). Link sync (G) */
130*852ba100SJustin Hibbits #define MEMAC_IEVNT_AN			0x40000000 /* Auto-negotiation */
131*852ba100SJustin Hibbits #define MEMAC_IEVNT_LT			0x20000000 /* Link Training/New page */
132*852ba100SJustin Hibbits #define MEMAC_IEVNT_MGI			0x00004000 /* Magic pkt detection */
133*852ba100SJustin Hibbits #define MEMAC_IEVNT_TS_ECC_ER   0x00002000 /* Timestamp FIFO ECC error */
134*852ba100SJustin Hibbits #define MEMAC_IEVNT_RX_FIFO_OVFL	0x00001000 /* Rx FIFO overflow */
135*852ba100SJustin Hibbits #define MEMAC_IEVNT_TX_FIFO_UNFL	0x00000800 /* Tx FIFO underflow */
136*852ba100SJustin Hibbits #define MEMAC_IEVNT_TX_FIFO_OVFL	0x00000400 /* Tx FIFO overflow */
137*852ba100SJustin Hibbits #define MEMAC_IEVNT_TX_ECC_ER		0x00000200 /* Tx frame ECC error */
138*852ba100SJustin Hibbits #define MEMAC_IEVNT_RX_ECC_ER		0x00000100 /* Rx frame ECC error */
139*852ba100SJustin Hibbits #define MEMAC_IEVNT_LI_FAULT		0x00000080 /* Link Interruption flt */
140*852ba100SJustin Hibbits #define MEMAC_IEVNT_RX_EMPTY		0x00000040 /* Rx FIFO empty */
141*852ba100SJustin Hibbits #define MEMAC_IEVNT_TX_EMPTY		0x00000020 /* Tx FIFO empty */
142*852ba100SJustin Hibbits #define MEMAC_IEVNT_RX_LOWP		0x00000010 /* Low Power Idle */
143*852ba100SJustin Hibbits #define MEMAC_IEVNT_PHY_LOS		0x00000004 /* Phy loss of signal */
144*852ba100SJustin Hibbits #define MEMAC_IEVNT_REM_FAULT		0x00000002 /* Remote fault (XGMII) */
145*852ba100SJustin Hibbits #define MEMAC_IEVNT_LOC_FAULT		0x00000001 /* Local fault (XGMII) */
146*852ba100SJustin Hibbits 
147*852ba100SJustin Hibbits enum memac_counters {
148*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_R64,
149*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_R127,
150*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_R255,
151*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_R511,
152*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_R1023,
153*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_R1518,
154*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_R1519X,
155*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RFRG,
156*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RJBR,
157*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RDRP,
158*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RALN,
159*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_TUND,
160*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_ROVR,
161*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RXPF,
162*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_TXPF,
163*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_ROCT,
164*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RMCA,
165*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RBCA,
166*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RPKT,
167*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RUCA,
168*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_RERR,
169*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_TOCT,
170*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_TMCA,
171*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_TBCA,
172*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_TUCA,
173*852ba100SJustin Hibbits 	E_MEMAC_COUNTER_TERR
174*852ba100SJustin Hibbits };
175*852ba100SJustin Hibbits 
176*852ba100SJustin Hibbits #define DEFAULT_PAUSE_QUANTA	0xf000
177*852ba100SJustin Hibbits #define DEFAULT_FRAME_LENGTH	0x600
178*852ba100SJustin Hibbits #define DEFAULT_TX_IPG_LENGTH	12
179*852ba100SJustin Hibbits 
180*852ba100SJustin Hibbits /*
181*852ba100SJustin Hibbits  * memory map
182*852ba100SJustin Hibbits  */
183*852ba100SJustin Hibbits 
184*852ba100SJustin Hibbits struct mac_addr {
185*852ba100SJustin Hibbits 	uint32_t   mac_addr_l;	/* Lower 32 bits of 48-bit MAC address */
186*852ba100SJustin Hibbits 	uint32_t   mac_addr_u;	/* Upper 16 bits of 48-bit MAC address */
187*852ba100SJustin Hibbits };
188*852ba100SJustin Hibbits 
189*852ba100SJustin Hibbits struct memac_regs {
190*852ba100SJustin Hibbits 	/* General Control and Status */
191*852ba100SJustin Hibbits 	uint32_t res0000[2];
192*852ba100SJustin Hibbits 	uint32_t command_config;	/* 0x008 Ctrl and cfg */
193*852ba100SJustin Hibbits 	struct mac_addr mac_addr0;	/* 0x00C-0x010 MAC_ADDR_0...1 */
194*852ba100SJustin Hibbits 	uint32_t maxfrm;		/* 0x014 Max frame length */
195*852ba100SJustin Hibbits 	uint32_t res0018[1];
196*852ba100SJustin Hibbits 	uint32_t rx_fifo_sections;	/* Receive FIFO configuration reg */
197*852ba100SJustin Hibbits 	uint32_t tx_fifo_sections;	/* Transmit FIFO configuration reg */
198*852ba100SJustin Hibbits 	uint32_t res0024[2];
199*852ba100SJustin Hibbits 	uint32_t hashtable_ctrl;	/* 0x02C Hash table control */
200*852ba100SJustin Hibbits 	uint32_t res0030[4];
201*852ba100SJustin Hibbits 	uint32_t ievent;		/* 0x040 Interrupt event */
202*852ba100SJustin Hibbits 	uint32_t tx_ipg_length;		/* 0x044 Transmitter inter-packet-gap */
203*852ba100SJustin Hibbits 	uint32_t res0048;
204*852ba100SJustin Hibbits 	uint32_t imask;			/* 0x04C Interrupt mask */
205*852ba100SJustin Hibbits 	uint32_t res0050;
206*852ba100SJustin Hibbits 	uint32_t pause_quanta[4];	/* 0x054 Pause quanta */
207*852ba100SJustin Hibbits 	uint32_t pause_thresh[4];	/* 0x064 Pause quanta threshold */
208*852ba100SJustin Hibbits 	uint32_t rx_pause_status;	/* 0x074 Receive pause status */
209*852ba100SJustin Hibbits 	uint32_t res0078[2];
210*852ba100SJustin Hibbits 	struct mac_addr mac_addr[MEMAC_NUM_OF_PADDRS]; /* 0x80-0x0B4 mac padr */
211*852ba100SJustin Hibbits 	uint32_t lpwake_timer;		/* 0x0B8 Low Power Wakeup Timer */
212*852ba100SJustin Hibbits 	uint32_t sleep_timer;		/* 0x0BC Transmit EEE Low Power Timer */
213*852ba100SJustin Hibbits 	uint32_t res00c0[8];
214*852ba100SJustin Hibbits 	uint32_t statn_config;		/* 0x0E0 Statistics configuration */
215*852ba100SJustin Hibbits 	uint32_t res00e4[7];
216*852ba100SJustin Hibbits 	/* Rx Statistics Counter */
217*852ba100SJustin Hibbits 	uint32_t reoct_l;
218*852ba100SJustin Hibbits 	uint32_t reoct_u;
219*852ba100SJustin Hibbits 	uint32_t roct_l;
220*852ba100SJustin Hibbits 	uint32_t roct_u;
221*852ba100SJustin Hibbits 	uint32_t raln_l;
222*852ba100SJustin Hibbits 	uint32_t raln_u;
223*852ba100SJustin Hibbits 	uint32_t rxpf_l;
224*852ba100SJustin Hibbits 	uint32_t rxpf_u;
225*852ba100SJustin Hibbits 	uint32_t rfrm_l;
226*852ba100SJustin Hibbits 	uint32_t rfrm_u;
227*852ba100SJustin Hibbits 	uint32_t rfcs_l;
228*852ba100SJustin Hibbits 	uint32_t rfcs_u;
229*852ba100SJustin Hibbits 	uint32_t rvlan_l;
230*852ba100SJustin Hibbits 	uint32_t rvlan_u;
231*852ba100SJustin Hibbits 	uint32_t rerr_l;
232*852ba100SJustin Hibbits 	uint32_t rerr_u;
233*852ba100SJustin Hibbits 	uint32_t ruca_l;
234*852ba100SJustin Hibbits 	uint32_t ruca_u;
235*852ba100SJustin Hibbits 	uint32_t rmca_l;
236*852ba100SJustin Hibbits 	uint32_t rmca_u;
237*852ba100SJustin Hibbits 	uint32_t rbca_l;
238*852ba100SJustin Hibbits 	uint32_t rbca_u;
239*852ba100SJustin Hibbits 	uint32_t rdrp_l;
240*852ba100SJustin Hibbits 	uint32_t rdrp_u;
241*852ba100SJustin Hibbits 	uint32_t rpkt_l;
242*852ba100SJustin Hibbits 	uint32_t rpkt_u;
243*852ba100SJustin Hibbits 	uint32_t rund_l;
244*852ba100SJustin Hibbits 	uint32_t rund_u;
245*852ba100SJustin Hibbits 	uint32_t r64_l;
246*852ba100SJustin Hibbits 	uint32_t r64_u;
247*852ba100SJustin Hibbits 	uint32_t r127_l;
248*852ba100SJustin Hibbits 	uint32_t r127_u;
249*852ba100SJustin Hibbits 	uint32_t r255_l;
250*852ba100SJustin Hibbits 	uint32_t r255_u;
251*852ba100SJustin Hibbits 	uint32_t r511_l;
252*852ba100SJustin Hibbits 	uint32_t r511_u;
253*852ba100SJustin Hibbits 	uint32_t r1023_l;
254*852ba100SJustin Hibbits 	uint32_t r1023_u;
255*852ba100SJustin Hibbits 	uint32_t r1518_l;
256*852ba100SJustin Hibbits 	uint32_t r1518_u;
257*852ba100SJustin Hibbits 	uint32_t r1519x_l;
258*852ba100SJustin Hibbits 	uint32_t r1519x_u;
259*852ba100SJustin Hibbits 	uint32_t rovr_l;
260*852ba100SJustin Hibbits 	uint32_t rovr_u;
261*852ba100SJustin Hibbits 	uint32_t rjbr_l;
262*852ba100SJustin Hibbits 	uint32_t rjbr_u;
263*852ba100SJustin Hibbits 	uint32_t rfrg_l;
264*852ba100SJustin Hibbits 	uint32_t rfrg_u;
265*852ba100SJustin Hibbits 	uint32_t rcnp_l;
266*852ba100SJustin Hibbits 	uint32_t rcnp_u;
267*852ba100SJustin Hibbits 	uint32_t rdrntp_l;
268*852ba100SJustin Hibbits 	uint32_t rdrntp_u;
269*852ba100SJustin Hibbits 	uint32_t res01d0[12];
270*852ba100SJustin Hibbits 	/* Tx Statistics Counter */
271*852ba100SJustin Hibbits 	uint32_t teoct_l;
272*852ba100SJustin Hibbits 	uint32_t teoct_u;
273*852ba100SJustin Hibbits 	uint32_t toct_l;
274*852ba100SJustin Hibbits 	uint32_t toct_u;
275*852ba100SJustin Hibbits 	uint32_t res0210[2];
276*852ba100SJustin Hibbits 	uint32_t txpf_l;
277*852ba100SJustin Hibbits 	uint32_t txpf_u;
278*852ba100SJustin Hibbits 	uint32_t tfrm_l;
279*852ba100SJustin Hibbits 	uint32_t tfrm_u;
280*852ba100SJustin Hibbits 	uint32_t tfcs_l;
281*852ba100SJustin Hibbits 	uint32_t tfcs_u;
282*852ba100SJustin Hibbits 	uint32_t tvlan_l;
283*852ba100SJustin Hibbits 	uint32_t tvlan_u;
284*852ba100SJustin Hibbits 	uint32_t terr_l;
285*852ba100SJustin Hibbits 	uint32_t terr_u;
286*852ba100SJustin Hibbits 	uint32_t tuca_l;
287*852ba100SJustin Hibbits 	uint32_t tuca_u;
288*852ba100SJustin Hibbits 	uint32_t tmca_l;
289*852ba100SJustin Hibbits 	uint32_t tmca_u;
290*852ba100SJustin Hibbits 	uint32_t tbca_l;
291*852ba100SJustin Hibbits 	uint32_t tbca_u;
292*852ba100SJustin Hibbits 	uint32_t res0258[2];
293*852ba100SJustin Hibbits 	uint32_t tpkt_l;
294*852ba100SJustin Hibbits 	uint32_t tpkt_u;
295*852ba100SJustin Hibbits 	uint32_t tund_l;
296*852ba100SJustin Hibbits 	uint32_t tund_u;
297*852ba100SJustin Hibbits 	uint32_t t64_l;
298*852ba100SJustin Hibbits 	uint32_t t64_u;
299*852ba100SJustin Hibbits 	uint32_t t127_l;
300*852ba100SJustin Hibbits 	uint32_t t127_u;
301*852ba100SJustin Hibbits 	uint32_t t255_l;
302*852ba100SJustin Hibbits 	uint32_t t255_u;
303*852ba100SJustin Hibbits 	uint32_t t511_l;
304*852ba100SJustin Hibbits 	uint32_t t511_u;
305*852ba100SJustin Hibbits 	uint32_t t1023_l;
306*852ba100SJustin Hibbits 	uint32_t t1023_u;
307*852ba100SJustin Hibbits 	uint32_t t1518_l;
308*852ba100SJustin Hibbits 	uint32_t t1518_u;
309*852ba100SJustin Hibbits 	uint32_t t1519x_l;
310*852ba100SJustin Hibbits 	uint32_t t1519x_u;
311*852ba100SJustin Hibbits 	uint32_t res02a8[6];
312*852ba100SJustin Hibbits 	uint32_t tcnp_l;
313*852ba100SJustin Hibbits 	uint32_t tcnp_u;
314*852ba100SJustin Hibbits 	uint32_t res02c8[14];
315*852ba100SJustin Hibbits 	/* Line Interface Control */
316*852ba100SJustin Hibbits 	uint32_t if_mode;		/* 0x300 Interface Mode Control */
317*852ba100SJustin Hibbits 	uint32_t if_status;		/* 0x304 Interface Status */
318*852ba100SJustin Hibbits 	uint32_t res0308[14];
319*852ba100SJustin Hibbits 	/* HiGig/2 */
320*852ba100SJustin Hibbits 	uint32_t hg_config;		/* 0x340 Control and cfg */
321*852ba100SJustin Hibbits 	uint32_t res0344[3];
322*852ba100SJustin Hibbits 	uint32_t hg_pause_quanta;	/* 0x350 Pause quanta */
323*852ba100SJustin Hibbits 	uint32_t res0354[3];
324*852ba100SJustin Hibbits 	uint32_t hg_pause_thresh;	/* 0x360 Pause quanta threshold */
325*852ba100SJustin Hibbits 	uint32_t res0364[3];
326*852ba100SJustin Hibbits 	uint32_t hgrx_pause_status;	/* 0x370 Receive pause status */
327*852ba100SJustin Hibbits 	uint32_t hg_fifos_status;	/* 0x374 fifos status */
328*852ba100SJustin Hibbits 	uint32_t rhm;			/* 0x378 rx messages counter */
329*852ba100SJustin Hibbits 	uint32_t thm;			/* 0x37C tx messages counter */
330*852ba100SJustin Hibbits };
331*852ba100SJustin Hibbits 
332*852ba100SJustin Hibbits struct memac_cfg {
333*852ba100SJustin Hibbits 	bool		reset_on_init;
334*852ba100SJustin Hibbits 	bool		rx_error_discard;
335*852ba100SJustin Hibbits 	bool		pause_ignore;
336*852ba100SJustin Hibbits 	bool		pause_forward_enable;
337*852ba100SJustin Hibbits 	bool		no_length_check_enable;
338*852ba100SJustin Hibbits 	bool		cmd_frame_enable;
339*852ba100SJustin Hibbits 	bool		send_idle_enable;
340*852ba100SJustin Hibbits 	bool		wan_mode_enable;
341*852ba100SJustin Hibbits 	bool		promiscuous_mode_enable;
342*852ba100SJustin Hibbits 	bool		tx_addr_ins_enable;
343*852ba100SJustin Hibbits 	bool		loopback_enable;
344*852ba100SJustin Hibbits 	bool		lgth_check_nostdr;
345*852ba100SJustin Hibbits 	bool		time_stamp_enable;
346*852ba100SJustin Hibbits 	bool		pad_enable;
347*852ba100SJustin Hibbits 	bool		phy_tx_ena_on;
348*852ba100SJustin Hibbits 	bool		rx_sfd_any;
349*852ba100SJustin Hibbits 	bool		rx_pbl_fwd;
350*852ba100SJustin Hibbits 	bool		tx_pbl_fwd;
351*852ba100SJustin Hibbits 	bool		debug_mode;
352*852ba100SJustin Hibbits 	bool		wake_on_lan;
353*852ba100SJustin Hibbits 	uint16_t	max_frame_length;
354*852ba100SJustin Hibbits 	uint16_t	pause_quanta;
355*852ba100SJustin Hibbits 	uint32_t	tx_ipg_length;
356*852ba100SJustin Hibbits };
357*852ba100SJustin Hibbits 
358*852ba100SJustin Hibbits 
359*852ba100SJustin Hibbits /**
360*852ba100SJustin Hibbits  * fman_memac_defconfig() - Get default MEMAC configuration
361*852ba100SJustin Hibbits  * @cfg:    pointer to configuration structure.
362*852ba100SJustin Hibbits  *
363*852ba100SJustin Hibbits  * Call this function to obtain a default set of configuration values for
364*852ba100SJustin Hibbits  * initializing MEMAC. The user can overwrite any of the values before calling
365*852ba100SJustin Hibbits  * fman_memac_init(), if specific configuration needs to be applied.
366*852ba100SJustin Hibbits  */
367*852ba100SJustin Hibbits void fman_memac_defconfig(struct memac_cfg *cfg);
368*852ba100SJustin Hibbits 
369*852ba100SJustin Hibbits int fman_memac_init(struct memac_regs *regs,
370*852ba100SJustin Hibbits 	struct memac_cfg *cfg,
371*852ba100SJustin Hibbits 	enum enet_interface enet_interface,
372*852ba100SJustin Hibbits 	enum enet_speed enet_speed,
373*852ba100SJustin Hibbits 	bool slow_10g_if,
374*852ba100SJustin Hibbits 	uint32_t exceptions);
375*852ba100SJustin Hibbits 
376*852ba100SJustin Hibbits void fman_memac_enable(struct memac_regs *regs, bool apply_rx, bool apply_tx);
377*852ba100SJustin Hibbits 
378*852ba100SJustin Hibbits void fman_memac_disable(struct memac_regs *regs, bool apply_rx, bool apply_tx);
379*852ba100SJustin Hibbits 
380*852ba100SJustin Hibbits void fman_memac_set_promiscuous(struct memac_regs *regs, bool val);
381*852ba100SJustin Hibbits 
382*852ba100SJustin Hibbits void fman_memac_add_addr_in_paddr(struct memac_regs *regs,
383*852ba100SJustin Hibbits 	uint8_t *adr,
384*852ba100SJustin Hibbits 	uint8_t paddr_num);
385*852ba100SJustin Hibbits 
386*852ba100SJustin Hibbits void fman_memac_clear_addr_in_paddr(struct memac_regs *regs,
387*852ba100SJustin Hibbits 	uint8_t paddr_num);
388*852ba100SJustin Hibbits 
389*852ba100SJustin Hibbits uint64_t fman_memac_get_counter(struct memac_regs *regs,
390*852ba100SJustin Hibbits 	enum memac_counters reg_name);
391*852ba100SJustin Hibbits 
392*852ba100SJustin Hibbits void fman_memac_set_tx_pause_frames(struct memac_regs *regs,
393*852ba100SJustin Hibbits 	uint8_t priority, uint16_t pauseTime, uint16_t threshTime);
394*852ba100SJustin Hibbits 
395*852ba100SJustin Hibbits uint16_t fman_memac_get_max_frame_len(struct memac_regs *regs);
396*852ba100SJustin Hibbits 
397*852ba100SJustin Hibbits void fman_memac_set_exception(struct memac_regs *regs, uint32_t val,
398*852ba100SJustin Hibbits 	bool enable);
399*852ba100SJustin Hibbits 
400*852ba100SJustin Hibbits void fman_memac_reset_stat(struct memac_regs *regs);
401*852ba100SJustin Hibbits 
402*852ba100SJustin Hibbits void fman_memac_reset(struct memac_regs *regs);
403*852ba100SJustin Hibbits 
404*852ba100SJustin Hibbits void fman_memac_reset_filter_table(struct memac_regs *regs);
405*852ba100SJustin Hibbits 
406*852ba100SJustin Hibbits void fman_memac_set_hash_table_entry(struct memac_regs *regs, uint32_t crc);
407*852ba100SJustin Hibbits 
408*852ba100SJustin Hibbits void fman_memac_set_hash_table(struct memac_regs *regs, uint32_t val);
409*852ba100SJustin Hibbits 
410*852ba100SJustin Hibbits void fman_memac_set_rx_ignore_pause_frames(struct memac_regs *regs,
411*852ba100SJustin Hibbits 	bool enable);
412*852ba100SJustin Hibbits 
413*852ba100SJustin Hibbits void fman_memac_set_wol(struct memac_regs *regs, bool enable);
414*852ba100SJustin Hibbits 
415*852ba100SJustin Hibbits uint32_t fman_memac_get_event(struct memac_regs *regs, uint32_t ev_mask);
416*852ba100SJustin Hibbits 
417*852ba100SJustin Hibbits void fman_memac_ack_event(struct memac_regs *regs, uint32_t ev_mask);
418*852ba100SJustin Hibbits 
419*852ba100SJustin Hibbits uint32_t fman_memac_get_interrupt_mask(struct memac_regs *regs);
420*852ba100SJustin Hibbits 
421*852ba100SJustin Hibbits void fman_memac_adjust_link(struct memac_regs *regs,
422*852ba100SJustin Hibbits 	enum enet_interface iface_mode,
423*852ba100SJustin Hibbits 	enum enet_speed speed, bool full_dx);
424*852ba100SJustin Hibbits 
425*852ba100SJustin Hibbits 
426*852ba100SJustin Hibbits 
427*852ba100SJustin Hibbits #endif /*__FSL_FMAN_MEMAC_H*/
428