162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Allwinner EMAC Fast Ethernet driver for Linux.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Copyright 2012 Stefan Roese <sr@denx.de>
562306a36Sopenharmony_ci * Copyright 2013 Maxime Ripard <maxime.ripard@free-electrons.com>
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Based on the Linux driver provided by Allwinner:
862306a36Sopenharmony_ci * Copyright (C) 1997  Sten Wang
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * This file is licensed under the terms of the GNU General Public
1162306a36Sopenharmony_ci * License version 2. This program is licensed "as is" without any
1262306a36Sopenharmony_ci * warranty of any kind, whether express or implied.
1362306a36Sopenharmony_ci */
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#ifndef _SUN4I_EMAC_H_
1662306a36Sopenharmony_ci#define _SUN4I_EMAC_H_
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define EMAC_CTL_REG		(0x00)
1962306a36Sopenharmony_ci#define EMAC_CTL_RESET			(1 << 0)
2062306a36Sopenharmony_ci#define EMAC_CTL_TX_EN			(1 << 1)
2162306a36Sopenharmony_ci#define EMAC_CTL_RX_EN			(1 << 2)
2262306a36Sopenharmony_ci#define EMAC_TX_MODE_REG	(0x04)
2362306a36Sopenharmony_ci#define EMAC_TX_MODE_ABORTED_FRAME_EN	(1 << 0)
2462306a36Sopenharmony_ci#define EMAC_TX_MODE_DMA_EN		(1 << 1)
2562306a36Sopenharmony_ci#define EMAC_TX_FLOW_REG	(0x08)
2662306a36Sopenharmony_ci#define EMAC_TX_CTL0_REG	(0x0c)
2762306a36Sopenharmony_ci#define EMAC_TX_CTL1_REG	(0x10)
2862306a36Sopenharmony_ci#define EMAC_TX_INS_REG		(0x14)
2962306a36Sopenharmony_ci#define EMAC_TX_PL0_REG		(0x18)
3062306a36Sopenharmony_ci#define EMAC_TX_PL1_REG		(0x1c)
3162306a36Sopenharmony_ci#define EMAC_TX_STA_REG		(0x20)
3262306a36Sopenharmony_ci#define EMAC_TX_IO_DATA_REG	(0x24)
3362306a36Sopenharmony_ci#define EMAC_TX_IO_DATA1_REG	(0x28)
3462306a36Sopenharmony_ci#define EMAC_TX_TSVL0_REG	(0x2c)
3562306a36Sopenharmony_ci#define EMAC_TX_TSVH0_REG	(0x30)
3662306a36Sopenharmony_ci#define EMAC_TX_TSVL1_REG	(0x34)
3762306a36Sopenharmony_ci#define EMAC_TX_TSVH1_REG	(0x38)
3862306a36Sopenharmony_ci#define EMAC_RX_CTL_REG		(0x3c)
3962306a36Sopenharmony_ci#define EMAC_RX_CTL_AUTO_DRQ_EN		(1 << 1)
4062306a36Sopenharmony_ci#define EMAC_RX_CTL_DMA_EN		(1 << 2)
4162306a36Sopenharmony_ci#define EMAC_RX_CTL_FLUSH_FIFO		(1 << 3)
4262306a36Sopenharmony_ci#define EMAC_RX_CTL_PASS_ALL_EN		(1 << 4)
4362306a36Sopenharmony_ci#define EMAC_RX_CTL_PASS_CTL_EN		(1 << 5)
4462306a36Sopenharmony_ci#define EMAC_RX_CTL_PASS_CRC_ERR_EN	(1 << 6)
4562306a36Sopenharmony_ci#define EMAC_RX_CTL_PASS_LEN_ERR_EN	(1 << 7)
4662306a36Sopenharmony_ci#define EMAC_RX_CTL_PASS_LEN_OOR_EN	(1 << 8)
4762306a36Sopenharmony_ci#define EMAC_RX_CTL_ACCEPT_UNICAST_EN	(1 << 16)
4862306a36Sopenharmony_ci#define EMAC_RX_CTL_DA_FILTER_EN	(1 << 17)
4962306a36Sopenharmony_ci#define EMAC_RX_CTL_ACCEPT_MULTICAST_EN	(1 << 20)
5062306a36Sopenharmony_ci#define EMAC_RX_CTL_HASH_FILTER_EN	(1 << 21)
5162306a36Sopenharmony_ci#define EMAC_RX_CTL_ACCEPT_BROADCAST_EN	(1 << 22)
5262306a36Sopenharmony_ci#define EMAC_RX_CTL_SA_FILTER_EN	(1 << 24)
5362306a36Sopenharmony_ci#define EMAC_RX_CTL_SA_FILTER_INVERT_EN	(1 << 25)
5462306a36Sopenharmony_ci#define EMAC_RX_HASH0_REG	(0x40)
5562306a36Sopenharmony_ci#define EMAC_RX_HASH1_REG	(0x44)
5662306a36Sopenharmony_ci#define EMAC_RX_STA_REG		(0x48)
5762306a36Sopenharmony_ci#define EMAC_RX_IO_DATA_REG	(0x4c)
5862306a36Sopenharmony_ci#define EMAC_RX_IO_DATA_LEN(x)		(x & 0xffff)
5962306a36Sopenharmony_ci#define EMAC_RX_IO_DATA_STATUS(x)	((x >> 16) & 0xffff)
6062306a36Sopenharmony_ci#define EMAC_RX_IO_DATA_STATUS_CRC_ERR	(1 << 4)
6162306a36Sopenharmony_ci#define EMAC_RX_IO_DATA_STATUS_LEN_ERR	(3 << 5)
6262306a36Sopenharmony_ci#define EMAC_RX_IO_DATA_STATUS_OK	(1 << 7)
6362306a36Sopenharmony_ci#define EMAC_RX_FBC_REG		(0x50)
6462306a36Sopenharmony_ci#define EMAC_INT_CTL_REG	(0x54)
6562306a36Sopenharmony_ci#define EMAC_INT_CTL_RX_EN	(1 << 8)
6662306a36Sopenharmony_ci#define EMAC_INT_CTL_TX0_EN	(1)
6762306a36Sopenharmony_ci#define EMAC_INT_CTL_TX1_EN	(1 << 1)
6862306a36Sopenharmony_ci#define EMAC_INT_CTL_TX_EN	(EMAC_INT_CTL_TX0_EN | EMAC_INT_CTL_TX1_EN)
6962306a36Sopenharmony_ci#define EMAC_INT_CTL_TX0_ABRT_EN	(0x1 << 2)
7062306a36Sopenharmony_ci#define EMAC_INT_CTL_TX1_ABRT_EN	(0x1 << 3)
7162306a36Sopenharmony_ci#define EMAC_INT_CTL_TX_ABRT_EN	(EMAC_INT_CTL_TX0_ABRT_EN | EMAC_INT_CTL_TX1_ABRT_EN)
7262306a36Sopenharmony_ci#define EMAC_INT_STA_REG	(0x58)
7362306a36Sopenharmony_ci#define EMAC_INT_STA_TX0_COMPLETE	(0x1)
7462306a36Sopenharmony_ci#define EMAC_INT_STA_TX1_COMPLETE	(0x1 << 1)
7562306a36Sopenharmony_ci#define EMAC_INT_STA_TX_COMPLETE	(EMAC_INT_STA_TX0_COMPLETE | EMAC_INT_STA_TX1_COMPLETE)
7662306a36Sopenharmony_ci#define EMAC_INT_STA_TX0_ABRT	(0x1 << 2)
7762306a36Sopenharmony_ci#define EMAC_INT_STA_TX1_ABRT	(0x1 << 3)
7862306a36Sopenharmony_ci#define EMAC_INT_STA_TX_ABRT	(EMAC_INT_STA_TX0_ABRT | EMAC_INT_STA_TX1_ABRT)
7962306a36Sopenharmony_ci#define EMAC_INT_STA_RX_COMPLETE	(0x1 << 8)
8062306a36Sopenharmony_ci#define EMAC_MAC_CTL0_REG	(0x5c)
8162306a36Sopenharmony_ci#define EMAC_MAC_CTL0_RX_FLOW_CTL_EN	(1 << 2)
8262306a36Sopenharmony_ci#define EMAC_MAC_CTL0_TX_FLOW_CTL_EN	(1 << 3)
8362306a36Sopenharmony_ci#define EMAC_MAC_CTL0_SOFT_RESET	(1 << 15)
8462306a36Sopenharmony_ci#define EMAC_MAC_CTL1_REG	(0x60)
8562306a36Sopenharmony_ci#define EMAC_MAC_CTL1_DUPLEX_EN		(1 << 0)
8662306a36Sopenharmony_ci#define EMAC_MAC_CTL1_LEN_CHECK_EN	(1 << 1)
8762306a36Sopenharmony_ci#define EMAC_MAC_CTL1_HUGE_FRAME_EN	(1 << 2)
8862306a36Sopenharmony_ci#define EMAC_MAC_CTL1_DELAYED_CRC_EN	(1 << 3)
8962306a36Sopenharmony_ci#define EMAC_MAC_CTL1_CRC_EN		(1 << 4)
9062306a36Sopenharmony_ci#define EMAC_MAC_CTL1_PAD_EN		(1 << 5)
9162306a36Sopenharmony_ci#define EMAC_MAC_CTL1_PAD_CRC_EN	(1 << 6)
9262306a36Sopenharmony_ci#define EMAC_MAC_CTL1_AD_SHORT_FRAME_EN	(1 << 7)
9362306a36Sopenharmony_ci#define EMAC_MAC_CTL1_BACKOFF_DIS	(1 << 12)
9462306a36Sopenharmony_ci#define EMAC_MAC_IPGT_REG	(0x64)
9562306a36Sopenharmony_ci#define EMAC_MAC_IPGT_HALF_DUPLEX	(0x12)
9662306a36Sopenharmony_ci#define EMAC_MAC_IPGT_FULL_DUPLEX	(0x15)
9762306a36Sopenharmony_ci#define EMAC_MAC_IPGR_REG	(0x68)
9862306a36Sopenharmony_ci#define EMAC_MAC_IPGR_IPG1		(0x0c)
9962306a36Sopenharmony_ci#define EMAC_MAC_IPGR_IPG2		(0x12)
10062306a36Sopenharmony_ci#define EMAC_MAC_CLRT_REG	(0x6c)
10162306a36Sopenharmony_ci#define EMAC_MAC_CLRT_COLLISION_WINDOW	(0x37)
10262306a36Sopenharmony_ci#define EMAC_MAC_CLRT_RM		(0x0f)
10362306a36Sopenharmony_ci#define EMAC_MAC_MAXF_REG	(0x70)
10462306a36Sopenharmony_ci#define EMAC_MAC_SUPP_REG	(0x74)
10562306a36Sopenharmony_ci#define EMAC_MAC_SUPP_100M	(0x1 << 8)
10662306a36Sopenharmony_ci#define EMAC_MAC_TEST_REG	(0x78)
10762306a36Sopenharmony_ci#define EMAC_MAC_MCFG_REG	(0x7c)
10862306a36Sopenharmony_ci#define EMAC_MAC_MCFG_MII_CLKD_MASK	(0xff << 2)
10962306a36Sopenharmony_ci#define EMAC_MAC_MCFG_MII_CLKD_72	(0x0d << 2)
11062306a36Sopenharmony_ci#define EMAC_MAC_A0_REG		(0x98)
11162306a36Sopenharmony_ci#define EMAC_MAC_A1_REG		(0x9c)
11262306a36Sopenharmony_ci#define EMAC_MAC_A2_REG		(0xa0)
11362306a36Sopenharmony_ci#define EMAC_SAFX_L_REG0	(0xa4)
11462306a36Sopenharmony_ci#define EMAC_SAFX_H_REG0	(0xa8)
11562306a36Sopenharmony_ci#define EMAC_SAFX_L_REG1	(0xac)
11662306a36Sopenharmony_ci#define EMAC_SAFX_H_REG1	(0xb0)
11762306a36Sopenharmony_ci#define EMAC_SAFX_L_REG2	(0xb4)
11862306a36Sopenharmony_ci#define EMAC_SAFX_H_REG2	(0xb8)
11962306a36Sopenharmony_ci#define EMAC_SAFX_L_REG3	(0xbc)
12062306a36Sopenharmony_ci#define EMAC_SAFX_H_REG3	(0xc0)
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci#define EMAC_PHY_DUPLEX		(1 << 8)
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci#define EMAC_EEPROM_MAGIC	(0x444d394b)
12562306a36Sopenharmony_ci#define EMAC_UNDOCUMENTED_MAGIC	(0x0143414d)
12662306a36Sopenharmony_ci#endif /* _SUN4I_EMAC_H_ */
127