xref: /openbmc/u-boot/include/fsl_tgec.h (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
28225b2fdSShaohui Xie /*
38225b2fdSShaohui Xie  * Copyright 2009-2011 Freescale Semiconductor, Inc.
48225b2fdSShaohui Xie  *	Dave Liu <daveliu@freescale.com>
58225b2fdSShaohui Xie  */
68225b2fdSShaohui Xie 
78225b2fdSShaohui Xie #ifndef __TGEC_H__
88225b2fdSShaohui Xie #define __TGEC_H__
98225b2fdSShaohui Xie 
108225b2fdSShaohui Xie #include <phy.h>
118225b2fdSShaohui Xie 
128225b2fdSShaohui Xie struct tgec {
138225b2fdSShaohui Xie 	/* 10GEC general control and status registers */
148225b2fdSShaohui Xie 	u32	tgec_id;	/* Controller ID register */
158225b2fdSShaohui Xie 	u32	res0;
168225b2fdSShaohui Xie 	u32	command_config;	/* Control and configuration register */
178225b2fdSShaohui Xie 	u32	mac_addr_0;	/* Lower 32 bits of 48-bit MAC address */
188225b2fdSShaohui Xie 	u32	mac_addr_1;	/* Upper 16 bits of 48-bit MAC address */
198225b2fdSShaohui Xie 	u32	maxfrm;		/* Maximum frame length register */
208225b2fdSShaohui Xie 	u32	pause_quant;	/* Pause quanta register */
218225b2fdSShaohui Xie 	u32	res1[4];
228225b2fdSShaohui Xie 	u32	hashtable_ctrl;	/* Hash table control register */
238225b2fdSShaohui Xie 	u32	res2[4];
248225b2fdSShaohui Xie 	u32	status;		/* MAC status register */
258225b2fdSShaohui Xie 	u32	tx_ipg_length;	/* Transmitter inter-packet-gap register */
268225b2fdSShaohui Xie 	u32	mac_addr_2;	/* Lower 32 bits of the 2nd 48-bit MAC addr */
278225b2fdSShaohui Xie 	u32	mac_addr_3;	/* Upper 16 bits of the 2nd 48-bit MAC addr */
288225b2fdSShaohui Xie 	u32	res3[4];
298225b2fdSShaohui Xie 	u32	imask;		/* Interrupt mask register */
308225b2fdSShaohui Xie 	u32	ievent;		/* Interrupt event register */
318225b2fdSShaohui Xie 	u32	res4[6];
328225b2fdSShaohui Xie 	/* 10GEC statistics counter registers */
338225b2fdSShaohui Xie 	u32	tx_frame_u;	/* Tx frame counter upper */
348225b2fdSShaohui Xie 	u32	tx_frame_l;	/* Tx frame counter lower */
358225b2fdSShaohui Xie 	u32	rx_frame_u;	/* Rx frame counter upper */
368225b2fdSShaohui Xie 	u32	rx_frame_l;	/* Rx frame counter lower */
378225b2fdSShaohui Xie 	u32	rx_frame_crc_err_u; /* Rx frame check sequence error upper */
388225b2fdSShaohui Xie 	u32	rx_frame_crc_err_l; /* Rx frame check sequence error lower */
398225b2fdSShaohui Xie 	u32	rx_align_err_u;	/* Rx alignment error upper */
408225b2fdSShaohui Xie 	u32	rx_align_err_l;	/* Rx alignment error lower */
418225b2fdSShaohui Xie 	u32	tx_pause_frame_u; /* Tx valid pause frame upper */
428225b2fdSShaohui Xie 	u32	tx_pause_frame_l; /* Tx valid pause frame lower */
438225b2fdSShaohui Xie 	u32	rx_pause_frame_u; /* Rx valid pause frame upper */
448225b2fdSShaohui Xie 	u32	rx_pause_frame_l; /* Rx valid pause frame upper */
458225b2fdSShaohui Xie 	u32	rx_long_err_u;	/* Rx too long frame error upper */
468225b2fdSShaohui Xie 	u32	rx_long_err_l;	/* Rx too long frame error lower */
478225b2fdSShaohui Xie 	u32	rx_frame_err_u;	/* Rx frame length error upper */
488225b2fdSShaohui Xie 	u32	rx_frame_err_l;	/* Rx frame length error lower */
498225b2fdSShaohui Xie 	u32	tx_vlan_u;	/* Tx VLAN frame upper */
508225b2fdSShaohui Xie 	u32	tx_vlan_l;	/* Tx VLAN frame lower */
518225b2fdSShaohui Xie 	u32	rx_vlan_u;	/* Rx VLAN frame upper */
528225b2fdSShaohui Xie 	u32	rx_vlan_l;	/* Rx VLAN frame lower */
538225b2fdSShaohui Xie 	u32	tx_oct_u;	/* Tx octets upper */
548225b2fdSShaohui Xie 	u32	tx_oct_l;	/* Tx octets lower */
558225b2fdSShaohui Xie 	u32	rx_oct_u;	/* Rx octets upper */
568225b2fdSShaohui Xie 	u32	rx_oct_l;	/* Rx octets lower */
578225b2fdSShaohui Xie 	u32	rx_uni_u;	/* Rx unicast frame upper */
588225b2fdSShaohui Xie 	u32	rx_uni_l;	/* Rx unicast frame lower */
598225b2fdSShaohui Xie 	u32	rx_multi_u;	/* Rx multicast frame upper */
608225b2fdSShaohui Xie 	u32	rx_multi_l;	/* Rx multicast frame lower */
618225b2fdSShaohui Xie 	u32	rx_brd_u;	/* Rx broadcast frame upper */
628225b2fdSShaohui Xie 	u32	rx_brd_l;	/* Rx broadcast frame lower */
638225b2fdSShaohui Xie 	u32	tx_frame_err_u;	/* Tx frame error upper */
648225b2fdSShaohui Xie 	u32	tx_frame_err_l;	/* Tx frame error lower */
658225b2fdSShaohui Xie 	u32	tx_uni_u;	/* Tx unicast frame upper */
668225b2fdSShaohui Xie 	u32	tx_uni_l;	/* Tx unicast frame lower */
678225b2fdSShaohui Xie 	u32	tx_multi_u;	/* Tx multicast frame upper */
688225b2fdSShaohui Xie 	u32	tx_multi_l;	/* Tx multicast frame lower */
698225b2fdSShaohui Xie 	u32	tx_brd_u;	/* Tx broadcast frame upper */
708225b2fdSShaohui Xie 	u32	tx_brd_l;	/* Tx broadcast frame lower */
718225b2fdSShaohui Xie 	u32	rx_drop_u;	/* Rx dropped packets upper */
728225b2fdSShaohui Xie 	u32	rx_drop_l;	/* Rx dropped packets lower */
738225b2fdSShaohui Xie 	u32	rx_eoct_u;	/* Rx ethernet octets upper */
748225b2fdSShaohui Xie 	u32	rx_eoct_l;	/* Rx ethernet octets lower */
758225b2fdSShaohui Xie 	u32	rx_pkt_u;	/* Rx packets upper */
768225b2fdSShaohui Xie 	u32	rx_pkt_l;	/* Rx packets lower */
778225b2fdSShaohui Xie 	u32	tx_undsz_u;	/* Undersized packet upper */
788225b2fdSShaohui Xie 	u32	tx_undsz_l;	/* Undersized packet lower */
798225b2fdSShaohui Xie 	u32	rx_64_u;	/* Rx 64 oct packet upper */
808225b2fdSShaohui Xie 	u32	rx_64_l;	/* Rx 64 oct packet lower */
818225b2fdSShaohui Xie 	u32	rx_127_u;	/* Rx 65 to 127 oct packet upper */
828225b2fdSShaohui Xie 	u32	rx_127_l;	/* Rx 65 to 127 oct packet lower */
838225b2fdSShaohui Xie 	u32	rx_255_u;	/* Rx 128 to 255 oct packet upper */
848225b2fdSShaohui Xie 	u32	rx_255_l;	/* Rx 128 to 255 oct packet lower */
858225b2fdSShaohui Xie 	u32	rx_511_u;	/* Rx 256 to 511 oct packet upper */
868225b2fdSShaohui Xie 	u32	rx_511_l;	/* Rx 256 to 511 oct packet lower */
878225b2fdSShaohui Xie 	u32	rx_1023_u;	/* Rx 512 to 1023 oct packet upper */
888225b2fdSShaohui Xie 	u32	rx_1023_l;	/* Rx 512 to 1023 oct packet lower */
898225b2fdSShaohui Xie 	u32	rx_1518_u;	/* Rx 1024 to 1518 oct packet upper */
908225b2fdSShaohui Xie 	u32	rx_1518_l;	/* Rx 1024 to 1518 oct packet lower */
918225b2fdSShaohui Xie 	u32	rx_1519_u;	/* Rx 1519 to max oct packet upper */
928225b2fdSShaohui Xie 	u32	rx_1519_l;	/* Rx 1519 to max oct packet lower */
938225b2fdSShaohui Xie 	u32	tx_oversz_u;	/* oversized packet upper */
948225b2fdSShaohui Xie 	u32	tx_oversz_l;	/* oversized packet lower */
958225b2fdSShaohui Xie 	u32	tx_jabber_u;	/* Jabber packet upper */
968225b2fdSShaohui Xie 	u32	tx_jabber_l;	/* Jabber packet lower */
978225b2fdSShaohui Xie 	u32	tx_frag_u;	/* Fragment packet upper */
988225b2fdSShaohui Xie 	u32	tx_frag_l;	/* Fragment packet lower */
998225b2fdSShaohui Xie 	u32	rx_err_u;	/* Rx frame error upper */
1008225b2fdSShaohui Xie 	u32	rx_err_l;	/* Rx frame error lower */
1018225b2fdSShaohui Xie 	u32	res5[0x39a];
1028225b2fdSShaohui Xie };
1038225b2fdSShaohui Xie 
1048225b2fdSShaohui Xie /* EC10G_ID - 10-gigabit ethernet MAC controller ID */
1058225b2fdSShaohui Xie #define EC10G_ID_VER_MASK	0x0000ff00
1068225b2fdSShaohui Xie #define EC10G_ID_VER_SHIFT	8
1078225b2fdSShaohui Xie #define EC10G_ID_REV_MASK	0x000000ff
1088225b2fdSShaohui Xie 
1098225b2fdSShaohui Xie /* COMMAND_CONFIG - command and configuration register */
1108225b2fdSShaohui Xie #define TGEC_CMD_CFG_EN_TIMESTAMP	0x00100000 /* enable IEEE1588 */
1118225b2fdSShaohui Xie #define TGEC_CMD_CFG_TX_ADDR_INS_SEL	0x00080000 /* Tx mac addr w/ second */
1128225b2fdSShaohui Xie #define TGEC_CMD_CFG_NO_LEN_CHK		0x00020000 /* payload len chk disable */
1138225b2fdSShaohui Xie #define TGEC_CMD_CFG_SEND_IDLE		0x00010000 /* send XGMII idle seqs */
1148225b2fdSShaohui Xie #define TGEC_CMD_CFG_RX_ER_DISC		0x00004000 /* Rx err frm discard enb */
1158225b2fdSShaohui Xie #define TGEC_CMD_CFG_CMD_FRM_EN		0x00002000 /* CMD frame RX enable */
1168225b2fdSShaohui Xie #define TGEC_CMD_CFG_STAT_CLR		0x00001000 /* clear stats */
1178225b2fdSShaohui Xie #define TGEC_CMD_CFG_TX_ADDR_INS	0x00000200 /* overwrite src MAC addr */
1188225b2fdSShaohui Xie #define TGEC_CMD_CFG_PAUSE_IGNORE	0x00000100 /* ignore pause frames */
1198225b2fdSShaohui Xie #define TGEC_CMD_CFG_PAUSE_FWD		0x00000080 /* fwd pause frames */
1208225b2fdSShaohui Xie #define TGEC_CMD_CFG_CRC_FWD		0x00000040 /* fwd Rx CRC frames */
1218225b2fdSShaohui Xie #define TGEC_CMD_CFG_PAD_EN		0x00000020 /* MAC remove Rx padding */
1228225b2fdSShaohui Xie #define TGEC_CMD_CFG_PROM_EN		0x00000010 /* promiscuous mode enable */
1238225b2fdSShaohui Xie #define TGEC_CMD_CFG_WAN_MODE		0x00000008 /* WAN mode enable */
1248225b2fdSShaohui Xie #define TGEC_CMD_CFG_RX_EN		0x00000002 /* MAC Rx path enable */
1258225b2fdSShaohui Xie #define TGEC_CMD_CFG_TX_EN		0x00000001 /* MAC Tx path enable */
1268225b2fdSShaohui Xie #define TGEC_CMD_CFG_RXTX_EN	(TGEC_CMD_CFG_RX_EN | TGEC_CMD_CFG_TX_EN)
1278225b2fdSShaohui Xie 
1288225b2fdSShaohui Xie /* HASHTABLE_CTRL - Hashtable control register */
1298225b2fdSShaohui Xie #define HASHTABLE_CTRL_MCAST_EN	0x00000200 /* enable mulitcast Rx hash */
1308225b2fdSShaohui Xie #define HASHTABLE_CTRL_ADDR_MASK	0x000001ff
1318225b2fdSShaohui Xie 
1328225b2fdSShaohui Xie /* TX_IPG_LENGTH - Transmit inter-packet gap length register */
1338225b2fdSShaohui Xie #define TX_IPG_LENGTH_IPG_LEN_MASK	0x000003ff
1348225b2fdSShaohui Xie 
1358225b2fdSShaohui Xie /* IMASK - interrupt mask register */
1368225b2fdSShaohui Xie #define IMASK_MDIO_SCAN_EVENT	0x00010000 /* MDIO scan event mask */
1378225b2fdSShaohui Xie #define IMASK_MDIO_CMD_CMPL	0x00008000 /* MDIO cmd completion mask */
1388225b2fdSShaohui Xie #define IMASK_REM_FAULT		0x00004000 /* remote fault mask */
1398225b2fdSShaohui Xie #define IMASK_LOC_FAULT		0x00002000 /* local fault mask */
1408225b2fdSShaohui Xie #define IMASK_TX_ECC_ER		0x00001000 /* Tx frame ECC error mask */
1418225b2fdSShaohui Xie #define IMASK_TX_FIFO_UNFL	0x00000800 /* Tx FIFO underflow mask */
1428225b2fdSShaohui Xie #define IMASK_TX_ER		0x00000200 /* Tx frame error mask */
1438225b2fdSShaohui Xie #define IMASK_RX_FIFO_OVFL	0x00000100 /* Rx FIFO overflow mask */
1448225b2fdSShaohui Xie #define IMASK_RX_ECC_ER		0x00000080 /* Rx frame ECC error mask */
1458225b2fdSShaohui Xie #define IMASK_RX_JAB_FRM	0x00000040 /* Rx jabber frame mask */
1468225b2fdSShaohui Xie #define IMASK_RX_OVRSZ_FRM	0x00000020 /* Rx oversized frame mask */
1478225b2fdSShaohui Xie #define IMASK_RX_RUNT_FRM	0x00000010 /* Rx runt frame mask */
1488225b2fdSShaohui Xie #define IMASK_RX_FRAG_FRM	0x00000008 /* Rx fragment frame mask */
1498225b2fdSShaohui Xie #define IMASK_RX_LEN_ER		0x00000004 /* Rx payload length error mask */
1508225b2fdSShaohui Xie #define IMASK_RX_CRC_ER		0x00000002 /* Rx CRC error mask */
1518225b2fdSShaohui Xie #define IMASK_RX_ALIGN_ER	0x00000001 /* Rx alignment error mask */
1528225b2fdSShaohui Xie 
1538225b2fdSShaohui Xie #define IMASK_MASK_ALL		0x00000000
1548225b2fdSShaohui Xie 
1558225b2fdSShaohui Xie /* IEVENT - interrupt event register */
1568225b2fdSShaohui Xie #define IEVENT_MDIO_SCAN_EVENT	0x00010000 /* MDIO scan event */
1578225b2fdSShaohui Xie #define IEVENT_MDIO_CMD_CMPL	0x00008000 /* MDIO cmd completion */
1588225b2fdSShaohui Xie #define IEVENT_REM_FAULT	0x00004000 /* remote fault */
1598225b2fdSShaohui Xie #define IEVENT_LOC_FAULT	0x00002000 /* local fault */
1608225b2fdSShaohui Xie #define IEVENT_TX_ECC_ER	0x00001000 /* Tx frame ECC error */
1618225b2fdSShaohui Xie #define IEVENT_TX_FIFO_UNFL	0x00000800 /* Tx FIFO underflow */
1628225b2fdSShaohui Xie #define IEVENT_TX_ER		0x00000200 /* Tx frame error */
1638225b2fdSShaohui Xie #define IEVENT_RX_FIFO_OVFL	0x00000100 /* Rx FIFO overflow */
1648225b2fdSShaohui Xie #define IEVENT_RX_ECC_ER	0x00000080 /* Rx frame ECC error */
1658225b2fdSShaohui Xie #define IEVENT_RX_JAB_FRM	0x00000040 /* Rx jabber frame */
1668225b2fdSShaohui Xie #define IEVENT_RX_OVRSZ_FRM	0x00000020 /* Rx oversized frame */
1678225b2fdSShaohui Xie #define IEVENT_RX_RUNT_FRM	0x00000010 /* Rx runt frame */
1688225b2fdSShaohui Xie #define IEVENT_RX_FRAG_FRM	0x00000008 /* Rx fragment frame */
1698225b2fdSShaohui Xie #define IEVENT_RX_LEN_ER	0x00000004 /* Rx payload length error */
1708225b2fdSShaohui Xie #define IEVENT_RX_CRC_ER	0x00000002 /* Rx CRC error */
1718225b2fdSShaohui Xie #define IEVENT_RX_ALIGN_ER	0x00000001 /* Rx alignment error */
1728225b2fdSShaohui Xie 
1738225b2fdSShaohui Xie #define IEVENT_CLEAR_ALL	0xffffffff
1748225b2fdSShaohui Xie 
1758225b2fdSShaohui Xie struct tgec_mdio_controller {
1768225b2fdSShaohui Xie 	u32	res0[0xc];
1778225b2fdSShaohui Xie 	u32	mdio_stat;	/* MDIO configuration and status */
1788225b2fdSShaohui Xie 	u32	mdio_ctl;	/* MDIO control */
1798225b2fdSShaohui Xie 	u32	mdio_data;	/* MDIO data */
1808225b2fdSShaohui Xie 	u32	mdio_addr;	/* MDIO address */
1818225b2fdSShaohui Xie };
1828225b2fdSShaohui Xie 
1838225b2fdSShaohui Xie #define MDIO_STAT_CLKDIV(x)	(((x>>1) & 0xff) << 8)
1848225b2fdSShaohui Xie #define MDIO_STAT_BSY		(1 << 0)
1858225b2fdSShaohui Xie #define MDIO_STAT_RD_ER		(1 << 1)
1868225b2fdSShaohui Xie #define MDIO_CTL_DEV_ADDR(x)	(x & 0x1f)
1878225b2fdSShaohui Xie #define MDIO_CTL_PORT_ADDR(x)	((x & 0x1f) << 5)
1888225b2fdSShaohui Xie #define MDIO_CTL_PRE_DIS	(1 << 10)
1898225b2fdSShaohui Xie #define MDIO_CTL_SCAN_EN	(1 << 11)
1908225b2fdSShaohui Xie #define MDIO_CTL_POST_INC	(1 << 14)
1918225b2fdSShaohui Xie #define MDIO_CTL_READ		(1 << 15)
1928225b2fdSShaohui Xie 
1938225b2fdSShaohui Xie #define MDIO_DATA(x)		(x & 0xffff)
1948225b2fdSShaohui Xie #define MDIO_DATA_BSY		(1 << 31)
1958225b2fdSShaohui Xie 
1968225b2fdSShaohui Xie struct fsl_enet_mac;
1978225b2fdSShaohui Xie 
1988225b2fdSShaohui Xie void init_tgec(struct fsl_enet_mac *mac, void *base, void *phyregs,
1998225b2fdSShaohui Xie 		int max_rx_len);
2008225b2fdSShaohui Xie 
2018225b2fdSShaohui Xie #endif
202