18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */
28c2ecf20Sopenharmony_ci/* Copyright (C) 2018 Microchip Technology Inc. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _LAN743X_H
58c2ecf20Sopenharmony_ci#define _LAN743X_H
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/phy.h>
88c2ecf20Sopenharmony_ci#include "lan743x_ptp.h"
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define DRIVER_AUTHOR   "Bryan Whitehead <Bryan.Whitehead@microchip.com>"
118c2ecf20Sopenharmony_ci#define DRIVER_DESC "LAN743x PCIe Gigabit Ethernet Driver"
128c2ecf20Sopenharmony_ci#define DRIVER_NAME "lan743x"
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/* Register Definitions */
158c2ecf20Sopenharmony_ci#define ID_REV				(0x00)
168c2ecf20Sopenharmony_ci#define ID_REV_ID_MASK_			(0xFFFF0000)
178c2ecf20Sopenharmony_ci#define ID_REV_ID_LAN7430_		(0x74300000)
188c2ecf20Sopenharmony_ci#define ID_REV_ID_LAN7431_		(0x74310000)
198c2ecf20Sopenharmony_ci#define ID_REV_IS_VALID_CHIP_ID_(id_rev)	\
208c2ecf20Sopenharmony_ci	(((id_rev) & 0xFFF00000) == 0x74300000)
218c2ecf20Sopenharmony_ci#define ID_REV_CHIP_REV_MASK_		(0x0000FFFF)
228c2ecf20Sopenharmony_ci#define ID_REV_CHIP_REV_A0_		(0x00000000)
238c2ecf20Sopenharmony_ci#define ID_REV_CHIP_REV_B0_		(0x00000010)
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define FPGA_REV			(0x04)
268c2ecf20Sopenharmony_ci#define FPGA_REV_GET_MINOR_(fpga_rev)	(((fpga_rev) >> 8) & 0x000000FF)
278c2ecf20Sopenharmony_ci#define FPGA_REV_GET_MAJOR_(fpga_rev)	((fpga_rev) & 0x000000FF)
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#define HW_CFG					(0x010)
308c2ecf20Sopenharmony_ci#define HW_CFG_RELOAD_TYPE_ALL_			(0x00000FC0)
318c2ecf20Sopenharmony_ci#define HW_CFG_EE_OTP_RELOAD_			BIT(4)
328c2ecf20Sopenharmony_ci#define HW_CFG_LRST_				BIT(1)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci#define PMT_CTL					(0x014)
358c2ecf20Sopenharmony_ci#define PMT_CTL_ETH_PHY_D3_COLD_OVR_		BIT(27)
368c2ecf20Sopenharmony_ci#define PMT_CTL_MAC_D3_RX_CLK_OVR_		BIT(25)
378c2ecf20Sopenharmony_ci#define PMT_CTL_ETH_PHY_EDPD_PLL_CTL_		BIT(24)
388c2ecf20Sopenharmony_ci#define PMT_CTL_ETH_PHY_D3_OVR_			BIT(23)
398c2ecf20Sopenharmony_ci#define PMT_CTL_RX_FCT_RFE_D3_CLK_OVR_		BIT(18)
408c2ecf20Sopenharmony_ci#define PMT_CTL_GPIO_WAKEUP_EN_			BIT(15)
418c2ecf20Sopenharmony_ci#define PMT_CTL_EEE_WAKEUP_EN_			BIT(13)
428c2ecf20Sopenharmony_ci#define PMT_CTL_READY_				BIT(7)
438c2ecf20Sopenharmony_ci#define PMT_CTL_ETH_PHY_RST_			BIT(4)
448c2ecf20Sopenharmony_ci#define PMT_CTL_WOL_EN_				BIT(3)
458c2ecf20Sopenharmony_ci#define PMT_CTL_ETH_PHY_WAKE_EN_		BIT(2)
468c2ecf20Sopenharmony_ci#define PMT_CTL_WUPS_MASK_			(0x00000003)
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define DP_SEL				(0x024)
498c2ecf20Sopenharmony_ci#define DP_SEL_DPRDY_			BIT(31)
508c2ecf20Sopenharmony_ci#define DP_SEL_MASK_			(0x0000001F)
518c2ecf20Sopenharmony_ci#define DP_SEL_RFE_RAM			(0x00000001)
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define DP_SEL_VHF_HASH_LEN		(16)
548c2ecf20Sopenharmony_ci#define DP_SEL_VHF_VLAN_LEN		(128)
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define DP_CMD				(0x028)
578c2ecf20Sopenharmony_ci#define DP_CMD_WRITE_			(0x00000001)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define DP_ADDR				(0x02C)
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define DP_DATA_0			(0x030)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define E2P_CMD				(0x040)
648c2ecf20Sopenharmony_ci#define E2P_CMD_EPC_BUSY_		BIT(31)
658c2ecf20Sopenharmony_ci#define E2P_CMD_EPC_CMD_WRITE_		(0x30000000)
668c2ecf20Sopenharmony_ci#define E2P_CMD_EPC_CMD_EWEN_		(0x20000000)
678c2ecf20Sopenharmony_ci#define E2P_CMD_EPC_CMD_READ_		(0x00000000)
688c2ecf20Sopenharmony_ci#define E2P_CMD_EPC_TIMEOUT_		BIT(10)
698c2ecf20Sopenharmony_ci#define E2P_CMD_EPC_ADDR_MASK_		(0x000001FF)
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define E2P_DATA			(0x044)
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define GPIO_CFG0			(0x050)
748c2ecf20Sopenharmony_ci#define GPIO_CFG0_GPIO_DIR_BIT_(bit)	BIT(16 + (bit))
758c2ecf20Sopenharmony_ci#define GPIO_CFG0_GPIO_DATA_BIT_(bit)	BIT(0 + (bit))
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#define GPIO_CFG1			(0x054)
788c2ecf20Sopenharmony_ci#define GPIO_CFG1_GPIOEN_BIT_(bit)	BIT(16 + (bit))
798c2ecf20Sopenharmony_ci#define GPIO_CFG1_GPIOBUF_BIT_(bit)	BIT(0 + (bit))
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define GPIO_CFG2			(0x058)
828c2ecf20Sopenharmony_ci#define GPIO_CFG2_1588_POL_BIT_(bit)	BIT(0 + (bit))
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define GPIO_CFG3			(0x05C)
858c2ecf20Sopenharmony_ci#define GPIO_CFG3_1588_CH_SEL_BIT_(bit)	BIT(16 + (bit))
868c2ecf20Sopenharmony_ci#define GPIO_CFG3_1588_OE_BIT_(bit)	BIT(0 + (bit))
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define FCT_RX_CTL			(0xAC)
898c2ecf20Sopenharmony_ci#define FCT_RX_CTL_EN_(channel)		BIT(28 + (channel))
908c2ecf20Sopenharmony_ci#define FCT_RX_CTL_DIS_(channel)	BIT(24 + (channel))
918c2ecf20Sopenharmony_ci#define FCT_RX_CTL_RESET_(channel)	BIT(20 + (channel))
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define FCT_TX_CTL			(0xC4)
948c2ecf20Sopenharmony_ci#define FCT_TX_CTL_EN_(channel)		BIT(28 + (channel))
958c2ecf20Sopenharmony_ci#define FCT_TX_CTL_DIS_(channel)	BIT(24 + (channel))
968c2ecf20Sopenharmony_ci#define FCT_TX_CTL_RESET_(channel)	BIT(20 + (channel))
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define FCT_FLOW(rx_channel)			(0xE0 + ((rx_channel) << 2))
998c2ecf20Sopenharmony_ci#define FCT_FLOW_CTL_OFF_THRESHOLD_		(0x00007F00)
1008c2ecf20Sopenharmony_ci#define FCT_FLOW_CTL_OFF_THRESHOLD_SET_(value)	\
1018c2ecf20Sopenharmony_ci	((value << 8) & FCT_FLOW_CTL_OFF_THRESHOLD_)
1028c2ecf20Sopenharmony_ci#define FCT_FLOW_CTL_REQ_EN_			BIT(7)
1038c2ecf20Sopenharmony_ci#define FCT_FLOW_CTL_ON_THRESHOLD_		(0x0000007F)
1048c2ecf20Sopenharmony_ci#define FCT_FLOW_CTL_ON_THRESHOLD_SET_(value)	\
1058c2ecf20Sopenharmony_ci	((value << 0) & FCT_FLOW_CTL_ON_THRESHOLD_)
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#define MAC_CR				(0x100)
1088c2ecf20Sopenharmony_ci#define MAC_CR_MII_EN_			BIT(19)
1098c2ecf20Sopenharmony_ci#define MAC_CR_EEE_EN_			BIT(17)
1108c2ecf20Sopenharmony_ci#define MAC_CR_ADD_			BIT(12)
1118c2ecf20Sopenharmony_ci#define MAC_CR_ASD_			BIT(11)
1128c2ecf20Sopenharmony_ci#define MAC_CR_CNTR_RST_		BIT(5)
1138c2ecf20Sopenharmony_ci#define MAC_CR_DPX_			BIT(3)
1148c2ecf20Sopenharmony_ci#define MAC_CR_CFG_H_			BIT(2)
1158c2ecf20Sopenharmony_ci#define MAC_CR_CFG_L_			BIT(1)
1168c2ecf20Sopenharmony_ci#define MAC_CR_RST_			BIT(0)
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci#define MAC_RX				(0x104)
1198c2ecf20Sopenharmony_ci#define MAC_RX_MAX_SIZE_SHIFT_		(16)
1208c2ecf20Sopenharmony_ci#define MAC_RX_MAX_SIZE_MASK_		(0x3FFF0000)
1218c2ecf20Sopenharmony_ci#define MAC_RX_RXD_			BIT(1)
1228c2ecf20Sopenharmony_ci#define MAC_RX_RXEN_			BIT(0)
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define MAC_TX				(0x108)
1258c2ecf20Sopenharmony_ci#define MAC_TX_TXD_			BIT(1)
1268c2ecf20Sopenharmony_ci#define MAC_TX_TXEN_			BIT(0)
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#define MAC_FLOW			(0x10C)
1298c2ecf20Sopenharmony_ci#define MAC_FLOW_CR_TX_FCEN_		BIT(30)
1308c2ecf20Sopenharmony_ci#define MAC_FLOW_CR_RX_FCEN_		BIT(29)
1318c2ecf20Sopenharmony_ci#define MAC_FLOW_CR_FCPT_MASK_		(0x0000FFFF)
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define MAC_RX_ADDRH			(0x118)
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define MAC_RX_ADDRL			(0x11C)
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci#define MAC_MII_ACC			(0x120)
1388c2ecf20Sopenharmony_ci#define MAC_MII_ACC_PHY_ADDR_SHIFT_	(11)
1398c2ecf20Sopenharmony_ci#define MAC_MII_ACC_PHY_ADDR_MASK_	(0x0000F800)
1408c2ecf20Sopenharmony_ci#define MAC_MII_ACC_MIIRINDA_SHIFT_	(6)
1418c2ecf20Sopenharmony_ci#define MAC_MII_ACC_MIIRINDA_MASK_	(0x000007C0)
1428c2ecf20Sopenharmony_ci#define MAC_MII_ACC_MII_READ_		(0x00000000)
1438c2ecf20Sopenharmony_ci#define MAC_MII_ACC_MII_WRITE_		(0x00000002)
1448c2ecf20Sopenharmony_ci#define MAC_MII_ACC_MII_BUSY_		BIT(0)
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci#define MAC_MII_DATA			(0x124)
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci#define MAC_EEE_TX_LPI_REQ_DLY_CNT		(0x130)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci#define MAC_WUCSR				(0x140)
1518c2ecf20Sopenharmony_ci#define MAC_WUCSR_RFE_WAKE_EN_			BIT(14)
1528c2ecf20Sopenharmony_ci#define MAC_WUCSR_PFDA_EN_			BIT(3)
1538c2ecf20Sopenharmony_ci#define MAC_WUCSR_WAKE_EN_			BIT(2)
1548c2ecf20Sopenharmony_ci#define MAC_WUCSR_MPEN_				BIT(1)
1558c2ecf20Sopenharmony_ci#define MAC_WUCSR_BCST_EN_			BIT(0)
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci#define MAC_WK_SRC				(0x144)
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define MAC_WUF_CFG0			(0x150)
1608c2ecf20Sopenharmony_ci#define MAC_NUM_OF_WUF_CFG		(32)
1618c2ecf20Sopenharmony_ci#define MAC_WUF_CFG_BEGIN		(MAC_WUF_CFG0)
1628c2ecf20Sopenharmony_ci#define MAC_WUF_CFG(index)		(MAC_WUF_CFG_BEGIN + (4 * (index)))
1638c2ecf20Sopenharmony_ci#define MAC_WUF_CFG_EN_			BIT(31)
1648c2ecf20Sopenharmony_ci#define MAC_WUF_CFG_TYPE_MCAST_		(0x02000000)
1658c2ecf20Sopenharmony_ci#define MAC_WUF_CFG_TYPE_ALL_		(0x01000000)
1668c2ecf20Sopenharmony_ci#define MAC_WUF_CFG_OFFSET_SHIFT_	(16)
1678c2ecf20Sopenharmony_ci#define MAC_WUF_CFG_CRC16_MASK_		(0x0000FFFF)
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci#define MAC_WUF_MASK0_0			(0x200)
1708c2ecf20Sopenharmony_ci#define MAC_WUF_MASK0_1			(0x204)
1718c2ecf20Sopenharmony_ci#define MAC_WUF_MASK0_2			(0x208)
1728c2ecf20Sopenharmony_ci#define MAC_WUF_MASK0_3			(0x20C)
1738c2ecf20Sopenharmony_ci#define MAC_WUF_MASK0_BEGIN		(MAC_WUF_MASK0_0)
1748c2ecf20Sopenharmony_ci#define MAC_WUF_MASK1_BEGIN		(MAC_WUF_MASK0_1)
1758c2ecf20Sopenharmony_ci#define MAC_WUF_MASK2_BEGIN		(MAC_WUF_MASK0_2)
1768c2ecf20Sopenharmony_ci#define MAC_WUF_MASK3_BEGIN		(MAC_WUF_MASK0_3)
1778c2ecf20Sopenharmony_ci#define MAC_WUF_MASK0(index)		(MAC_WUF_MASK0_BEGIN + (0x10 * (index)))
1788c2ecf20Sopenharmony_ci#define MAC_WUF_MASK1(index)		(MAC_WUF_MASK1_BEGIN + (0x10 * (index)))
1798c2ecf20Sopenharmony_ci#define MAC_WUF_MASK2(index)		(MAC_WUF_MASK2_BEGIN + (0x10 * (index)))
1808c2ecf20Sopenharmony_ci#define MAC_WUF_MASK3(index)		(MAC_WUF_MASK3_BEGIN + (0x10 * (index)))
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/* offset 0x400 - 0x500, x may range from 0 to 32, for a total of 33 entries */
1838c2ecf20Sopenharmony_ci#define RFE_ADDR_FILT_HI(x)		(0x400 + (8 * (x)))
1848c2ecf20Sopenharmony_ci#define RFE_ADDR_FILT_HI_VALID_		BIT(31)
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci/* offset 0x404 - 0x504, x may range from 0 to 32, for a total of 33 entries */
1878c2ecf20Sopenharmony_ci#define RFE_ADDR_FILT_LO(x)		(0x404 + (8 * (x)))
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci#define RFE_CTL				(0x508)
1908c2ecf20Sopenharmony_ci#define RFE_CTL_AB_			BIT(10)
1918c2ecf20Sopenharmony_ci#define RFE_CTL_AM_			BIT(9)
1928c2ecf20Sopenharmony_ci#define RFE_CTL_AU_			BIT(8)
1938c2ecf20Sopenharmony_ci#define RFE_CTL_MCAST_HASH_		BIT(3)
1948c2ecf20Sopenharmony_ci#define RFE_CTL_DA_PERFECT_		BIT(1)
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci#define RFE_RSS_CFG			(0x554)
1978c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_UDP_IPV6_EX_	BIT(16)
1988c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_TCP_IPV6_EX_	BIT(15)
1998c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_IPV6_EX_		BIT(14)
2008c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_UDP_IPV6_		BIT(13)
2018c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_TCP_IPV6_		BIT(12)
2028c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_IPV6_		BIT(11)
2038c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_UDP_IPV4_		BIT(10)
2048c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_TCP_IPV4_		BIT(9)
2058c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_IPV4_		BIT(8)
2068c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_VALID_HASH_BITS_	(0x000000E0)
2078c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_RSS_QUEUE_ENABLE_	BIT(2)
2088c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_RSS_HASH_STORE_	BIT(1)
2098c2ecf20Sopenharmony_ci#define RFE_RSS_CFG_RSS_ENABLE_		BIT(0)
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci#define RFE_HASH_KEY(index)		(0x558 + (index << 2))
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci#define RFE_INDX(index)			(0x580 + (index << 2))
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci#define MAC_WUCSR2			(0x600)
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci#define INT_STS				(0x780)
2188c2ecf20Sopenharmony_ci#define INT_BIT_DMA_RX_(channel)	BIT(24 + (channel))
2198c2ecf20Sopenharmony_ci#define INT_BIT_ALL_RX_			(0x0F000000)
2208c2ecf20Sopenharmony_ci#define INT_BIT_DMA_TX_(channel)	BIT(16 + (channel))
2218c2ecf20Sopenharmony_ci#define INT_BIT_ALL_TX_			(0x000F0000)
2228c2ecf20Sopenharmony_ci#define INT_BIT_SW_GP_			BIT(9)
2238c2ecf20Sopenharmony_ci#define INT_BIT_1588_			BIT(7)
2248c2ecf20Sopenharmony_ci#define INT_BIT_ALL_OTHER_		(INT_BIT_SW_GP_ | INT_BIT_1588_)
2258c2ecf20Sopenharmony_ci#define INT_BIT_MAS_			BIT(0)
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci#define INT_SET				(0x784)
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci#define INT_EN_SET			(0x788)
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci#define INT_EN_CLR			(0x78C)
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#define INT_STS_R2C			(0x790)
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci#define INT_VEC_EN_SET			(0x794)
2368c2ecf20Sopenharmony_ci#define INT_VEC_EN_CLR			(0x798)
2378c2ecf20Sopenharmony_ci#define INT_VEC_EN_AUTO_CLR		(0x79C)
2388c2ecf20Sopenharmony_ci#define INT_VEC_EN_(vector_index)	BIT(0 + vector_index)
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci#define INT_VEC_MAP0			(0x7A0)
2418c2ecf20Sopenharmony_ci#define INT_VEC_MAP0_RX_VEC_(channel, vector)	\
2428c2ecf20Sopenharmony_ci	(((u32)(vector)) << ((channel) << 2))
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci#define INT_VEC_MAP1			(0x7A4)
2458c2ecf20Sopenharmony_ci#define INT_VEC_MAP1_TX_VEC_(channel, vector)	\
2468c2ecf20Sopenharmony_ci	(((u32)(vector)) << ((channel) << 2))
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci#define INT_VEC_MAP2			(0x7A8)
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci#define INT_MOD_MAP0			(0x7B0)
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci#define INT_MOD_MAP1			(0x7B4)
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci#define INT_MOD_MAP2			(0x7B8)
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci#define INT_MOD_CFG0			(0x7C0)
2578c2ecf20Sopenharmony_ci#define INT_MOD_CFG1			(0x7C4)
2588c2ecf20Sopenharmony_ci#define INT_MOD_CFG2			(0x7C8)
2598c2ecf20Sopenharmony_ci#define INT_MOD_CFG3			(0x7CC)
2608c2ecf20Sopenharmony_ci#define INT_MOD_CFG4			(0x7D0)
2618c2ecf20Sopenharmony_ci#define INT_MOD_CFG5			(0x7D4)
2628c2ecf20Sopenharmony_ci#define INT_MOD_CFG6			(0x7D8)
2638c2ecf20Sopenharmony_ci#define INT_MOD_CFG7			(0x7DC)
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci#define PTP_CMD_CTL					(0x0A00)
2668c2ecf20Sopenharmony_ci#define PTP_CMD_CTL_PTP_CLK_STP_NSEC_			BIT(6)
2678c2ecf20Sopenharmony_ci#define PTP_CMD_CTL_PTP_CLOCK_STEP_SEC_			BIT(5)
2688c2ecf20Sopenharmony_ci#define PTP_CMD_CTL_PTP_CLOCK_LOAD_			BIT(4)
2698c2ecf20Sopenharmony_ci#define PTP_CMD_CTL_PTP_CLOCK_READ_			BIT(3)
2708c2ecf20Sopenharmony_ci#define PTP_CMD_CTL_PTP_ENABLE_				BIT(2)
2718c2ecf20Sopenharmony_ci#define PTP_CMD_CTL_PTP_DISABLE_			BIT(1)
2728c2ecf20Sopenharmony_ci#define PTP_CMD_CTL_PTP_RESET_				BIT(0)
2738c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG				(0x0A04)
2748c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_X_MASK_(channel) \
2758c2ecf20Sopenharmony_ci	(0x7 << (1 + ((channel) << 2)))
2768c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_100NS_	(0)
2778c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_10US_	(1)
2788c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_100US_	(2)
2798c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_1MS_	(3)
2808c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_10MS_	(4)
2818c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_200MS_	(5)
2828c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_X_SET_(channel, value) \
2838c2ecf20Sopenharmony_ci	(((value) & 0x7) << (1 + ((channel) << 2)))
2848c2ecf20Sopenharmony_ci#define PTP_GENERAL_CONFIG_RELOAD_ADD_X_(channel)	(BIT((channel) << 2))
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci#define PTP_INT_STS				(0x0A08)
2878c2ecf20Sopenharmony_ci#define PTP_INT_EN_SET				(0x0A0C)
2888c2ecf20Sopenharmony_ci#define PTP_INT_EN_CLR				(0x0A10)
2898c2ecf20Sopenharmony_ci#define PTP_INT_BIT_TX_SWTS_ERR_		BIT(13)
2908c2ecf20Sopenharmony_ci#define PTP_INT_BIT_TX_TS_			BIT(12)
2918c2ecf20Sopenharmony_ci#define PTP_INT_BIT_TIMER_B_			BIT(1)
2928c2ecf20Sopenharmony_ci#define PTP_INT_BIT_TIMER_A_			BIT(0)
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci#define PTP_CLOCK_SEC				(0x0A14)
2958c2ecf20Sopenharmony_ci#define PTP_CLOCK_NS				(0x0A18)
2968c2ecf20Sopenharmony_ci#define PTP_CLOCK_SUBNS				(0x0A1C)
2978c2ecf20Sopenharmony_ci#define PTP_CLOCK_RATE_ADJ			(0x0A20)
2988c2ecf20Sopenharmony_ci#define PTP_CLOCK_RATE_ADJ_DIR_			BIT(31)
2998c2ecf20Sopenharmony_ci#define PTP_CLOCK_STEP_ADJ			(0x0A2C)
3008c2ecf20Sopenharmony_ci#define PTP_CLOCK_STEP_ADJ_DIR_			BIT(31)
3018c2ecf20Sopenharmony_ci#define PTP_CLOCK_STEP_ADJ_VALUE_MASK_		(0x3FFFFFFF)
3028c2ecf20Sopenharmony_ci#define PTP_CLOCK_TARGET_SEC_X(channel)		(0x0A30 + ((channel) << 4))
3038c2ecf20Sopenharmony_ci#define PTP_CLOCK_TARGET_NS_X(channel)		(0x0A34 + ((channel) << 4))
3048c2ecf20Sopenharmony_ci#define PTP_CLOCK_TARGET_RELOAD_SEC_X(channel)	(0x0A38 + ((channel) << 4))
3058c2ecf20Sopenharmony_ci#define PTP_CLOCK_TARGET_RELOAD_NS_X(channel)	(0x0A3C + ((channel) << 4))
3068c2ecf20Sopenharmony_ci#define PTP_LATENCY				(0x0A5C)
3078c2ecf20Sopenharmony_ci#define PTP_LATENCY_TX_SET_(tx_latency)		(((u32)(tx_latency)) << 16)
3088c2ecf20Sopenharmony_ci#define PTP_LATENCY_RX_SET_(rx_latency)		\
3098c2ecf20Sopenharmony_ci	(((u32)(rx_latency)) & 0x0000FFFF)
3108c2ecf20Sopenharmony_ci#define PTP_CAP_INFO				(0x0A60)
3118c2ecf20Sopenharmony_ci#define PTP_CAP_INFO_TX_TS_CNT_GET_(reg_val)	(((reg_val) & 0x00000070) >> 4)
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci#define PTP_TX_MOD				(0x0AA4)
3148c2ecf20Sopenharmony_ci#define PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_	(0x10000000)
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci#define PTP_TX_MOD2				(0x0AA8)
3178c2ecf20Sopenharmony_ci#define PTP_TX_MOD2_TX_PTP_CLR_UDPV4_CHKSUM_	(0x00000001)
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci#define PTP_TX_EGRESS_SEC			(0x0AAC)
3208c2ecf20Sopenharmony_ci#define PTP_TX_EGRESS_NS			(0x0AB0)
3218c2ecf20Sopenharmony_ci#define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_MASK_	(0xC0000000)
3228c2ecf20Sopenharmony_ci#define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_AUTO_	(0x00000000)
3238c2ecf20Sopenharmony_ci#define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_SW_	(0x40000000)
3248c2ecf20Sopenharmony_ci#define PTP_TX_EGRESS_NS_TS_NS_MASK_		(0x3FFFFFFF)
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci#define PTP_TX_MSG_HEADER			(0x0AB4)
3278c2ecf20Sopenharmony_ci#define PTP_TX_MSG_HEADER_MSG_TYPE_		(0x000F0000)
3288c2ecf20Sopenharmony_ci#define PTP_TX_MSG_HEADER_MSG_TYPE_SYNC_	(0x00000000)
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci#define DMAC_CFG				(0xC00)
3318c2ecf20Sopenharmony_ci#define DMAC_CFG_COAL_EN_			BIT(16)
3328c2ecf20Sopenharmony_ci#define DMAC_CFG_CH_ARB_SEL_RX_HIGH_		(0x00000000)
3338c2ecf20Sopenharmony_ci#define DMAC_CFG_MAX_READ_REQ_MASK_		(0x00000070)
3348c2ecf20Sopenharmony_ci#define DMAC_CFG_MAX_READ_REQ_SET_(val)	\
3358c2ecf20Sopenharmony_ci	((((u32)(val)) << 4) & DMAC_CFG_MAX_READ_REQ_MASK_)
3368c2ecf20Sopenharmony_ci#define DMAC_CFG_MAX_DSPACE_16_			(0x00000000)
3378c2ecf20Sopenharmony_ci#define DMAC_CFG_MAX_DSPACE_32_			(0x00000001)
3388c2ecf20Sopenharmony_ci#define DMAC_CFG_MAX_DSPACE_64_			BIT(1)
3398c2ecf20Sopenharmony_ci#define DMAC_CFG_MAX_DSPACE_128_		(0x00000003)
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG				(0xC04)
3428c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_TIMER_LIMIT_MASK_		(0xFFF00000)
3438c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_TIMER_LIMIT_SET_(val)	\
3448c2ecf20Sopenharmony_ci	((((u32)(val)) << 20) & DMAC_COAL_CFG_TIMER_LIMIT_MASK_)
3458c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_TIMER_TX_START_		BIT(19)
3468c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_FLUSH_INTS_		BIT(18)
3478c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_INT_EXIT_COAL_		BIT(17)
3488c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_CSR_EXIT_COAL_		BIT(16)
3498c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_TX_THRES_MASK_		(0x0000FF00)
3508c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_TX_THRES_SET_(val)	\
3518c2ecf20Sopenharmony_ci	((((u32)(val)) << 8) & DMAC_COAL_CFG_TX_THRES_MASK_)
3528c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_RX_THRES_MASK_		(0x000000FF)
3538c2ecf20Sopenharmony_ci#define DMAC_COAL_CFG_RX_THRES_SET_(val)	\
3548c2ecf20Sopenharmony_ci	(((u32)(val)) & DMAC_COAL_CFG_RX_THRES_MASK_)
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ci#define DMAC_OBFF_CFG				(0xC08)
3578c2ecf20Sopenharmony_ci#define DMAC_OBFF_TX_THRES_MASK_		(0x0000FF00)
3588c2ecf20Sopenharmony_ci#define DMAC_OBFF_TX_THRES_SET_(val)	\
3598c2ecf20Sopenharmony_ci	((((u32)(val)) << 8) & DMAC_OBFF_TX_THRES_MASK_)
3608c2ecf20Sopenharmony_ci#define DMAC_OBFF_RX_THRES_MASK_		(0x000000FF)
3618c2ecf20Sopenharmony_ci#define DMAC_OBFF_RX_THRES_SET_(val)	\
3628c2ecf20Sopenharmony_ci	(((u32)(val)) & DMAC_OBFF_RX_THRES_MASK_)
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci#define DMAC_CMD				(0xC0C)
3658c2ecf20Sopenharmony_ci#define DMAC_CMD_SWR_				BIT(31)
3668c2ecf20Sopenharmony_ci#define DMAC_CMD_TX_SWR_(channel)		BIT(24 + (channel))
3678c2ecf20Sopenharmony_ci#define DMAC_CMD_START_T_(channel)		BIT(20 + (channel))
3688c2ecf20Sopenharmony_ci#define DMAC_CMD_STOP_T_(channel)		BIT(16 + (channel))
3698c2ecf20Sopenharmony_ci#define DMAC_CMD_RX_SWR_(channel)		BIT(8 + (channel))
3708c2ecf20Sopenharmony_ci#define DMAC_CMD_START_R_(channel)		BIT(4 + (channel))
3718c2ecf20Sopenharmony_ci#define DMAC_CMD_STOP_R_(channel)		BIT(0 + (channel))
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ci#define DMAC_INT_STS				(0xC10)
3748c2ecf20Sopenharmony_ci#define DMAC_INT_EN_SET				(0xC14)
3758c2ecf20Sopenharmony_ci#define DMAC_INT_EN_CLR				(0xC18)
3768c2ecf20Sopenharmony_ci#define DMAC_INT_BIT_RXFRM_(channel)		BIT(16 + (channel))
3778c2ecf20Sopenharmony_ci#define DMAC_INT_BIT_TX_IOC_(channel)		BIT(0 + (channel))
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci#define RX_CFG_A(channel)			(0xC40 + ((channel) << 6))
3808c2ecf20Sopenharmony_ci#define RX_CFG_A_RX_WB_ON_INT_TMR_		BIT(30)
3818c2ecf20Sopenharmony_ci#define RX_CFG_A_RX_WB_THRES_MASK_		(0x1F000000)
3828c2ecf20Sopenharmony_ci#define RX_CFG_A_RX_WB_THRES_SET_(val)	\
3838c2ecf20Sopenharmony_ci	((((u32)(val)) << 24) & RX_CFG_A_RX_WB_THRES_MASK_)
3848c2ecf20Sopenharmony_ci#define RX_CFG_A_RX_PF_THRES_MASK_		(0x001F0000)
3858c2ecf20Sopenharmony_ci#define RX_CFG_A_RX_PF_THRES_SET_(val)	\
3868c2ecf20Sopenharmony_ci	((((u32)(val)) << 16) & RX_CFG_A_RX_PF_THRES_MASK_)
3878c2ecf20Sopenharmony_ci#define RX_CFG_A_RX_PF_PRI_THRES_MASK_		(0x00001F00)
3888c2ecf20Sopenharmony_ci#define RX_CFG_A_RX_PF_PRI_THRES_SET_(val)	\
3898c2ecf20Sopenharmony_ci	((((u32)(val)) << 8) & RX_CFG_A_RX_PF_PRI_THRES_MASK_)
3908c2ecf20Sopenharmony_ci#define RX_CFG_A_RX_HP_WB_EN_			BIT(5)
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci#define RX_CFG_B(channel)			(0xC44 + ((channel) << 6))
3938c2ecf20Sopenharmony_ci#define RX_CFG_B_TS_ALL_RX_			BIT(29)
3948c2ecf20Sopenharmony_ci#define RX_CFG_B_RX_PAD_MASK_			(0x03000000)
3958c2ecf20Sopenharmony_ci#define RX_CFG_B_RX_PAD_0_			(0x00000000)
3968c2ecf20Sopenharmony_ci#define RX_CFG_B_RX_PAD_2_			(0x02000000)
3978c2ecf20Sopenharmony_ci#define RX_CFG_B_RDMABL_512_			(0x00040000)
3988c2ecf20Sopenharmony_ci#define RX_CFG_B_RX_RING_LEN_MASK_		(0x0000FFFF)
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci#define RX_BASE_ADDRH(channel)			(0xC48 + ((channel) << 6))
4018c2ecf20Sopenharmony_ci
4028c2ecf20Sopenharmony_ci#define RX_BASE_ADDRL(channel)			(0xC4C + ((channel) << 6))
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci#define RX_HEAD_WRITEBACK_ADDRH(channel)	(0xC50 + ((channel) << 6))
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci#define RX_HEAD_WRITEBACK_ADDRL(channel)	(0xC54 + ((channel) << 6))
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_ci#define RX_HEAD(channel)			(0xC58 + ((channel) << 6))
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci#define RX_TAIL(channel)			(0xC5C + ((channel) << 6))
4118c2ecf20Sopenharmony_ci#define RX_TAIL_SET_TOP_INT_EN_			BIT(30)
4128c2ecf20Sopenharmony_ci#define RX_TAIL_SET_TOP_INT_VEC_EN_		BIT(29)
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci#define RX_CFG_C(channel)			(0xC64 + ((channel) << 6))
4158c2ecf20Sopenharmony_ci#define RX_CFG_C_RX_TOP_INT_EN_AUTO_CLR_	BIT(6)
4168c2ecf20Sopenharmony_ci#define RX_CFG_C_RX_INT_EN_R2C_			BIT(4)
4178c2ecf20Sopenharmony_ci#define RX_CFG_C_RX_DMA_INT_STS_AUTO_CLR_	BIT(3)
4188c2ecf20Sopenharmony_ci#define RX_CFG_C_RX_INT_STS_R2C_MODE_MASK_	(0x00000007)
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci#define TX_CFG_A(channel)			(0xD40 + ((channel) << 6))
4218c2ecf20Sopenharmony_ci#define TX_CFG_A_TX_HP_WB_ON_INT_TMR_		BIT(30)
4228c2ecf20Sopenharmony_ci#define TX_CFG_A_TX_TMR_HPWB_SEL_IOC_		(0x10000000)
4238c2ecf20Sopenharmony_ci#define TX_CFG_A_TX_PF_THRES_MASK_		(0x001F0000)
4248c2ecf20Sopenharmony_ci#define TX_CFG_A_TX_PF_THRES_SET_(value)	\
4258c2ecf20Sopenharmony_ci	((((u32)(value)) << 16) & TX_CFG_A_TX_PF_THRES_MASK_)
4268c2ecf20Sopenharmony_ci#define TX_CFG_A_TX_PF_PRI_THRES_MASK_		(0x00001F00)
4278c2ecf20Sopenharmony_ci#define TX_CFG_A_TX_PF_PRI_THRES_SET_(value)	\
4288c2ecf20Sopenharmony_ci	((((u32)(value)) << 8) & TX_CFG_A_TX_PF_PRI_THRES_MASK_)
4298c2ecf20Sopenharmony_ci#define TX_CFG_A_TX_HP_WB_EN_			BIT(5)
4308c2ecf20Sopenharmony_ci#define TX_CFG_A_TX_HP_WB_THRES_MASK_		(0x0000000F)
4318c2ecf20Sopenharmony_ci#define TX_CFG_A_TX_HP_WB_THRES_SET_(value)	\
4328c2ecf20Sopenharmony_ci	(((u32)(value)) & TX_CFG_A_TX_HP_WB_THRES_MASK_)
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci#define TX_CFG_B(channel)			(0xD44 + ((channel) << 6))
4358c2ecf20Sopenharmony_ci#define TX_CFG_B_TDMABL_512_			(0x00040000)
4368c2ecf20Sopenharmony_ci#define TX_CFG_B_TX_RING_LEN_MASK_		(0x0000FFFF)
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci#define TX_BASE_ADDRH(channel)			(0xD48 + ((channel) << 6))
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci#define TX_BASE_ADDRL(channel)			(0xD4C + ((channel) << 6))
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci#define TX_HEAD_WRITEBACK_ADDRH(channel)	(0xD50 + ((channel) << 6))
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci#define TX_HEAD_WRITEBACK_ADDRL(channel)	(0xD54 + ((channel) << 6))
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci#define TX_HEAD(channel)			(0xD58 + ((channel) << 6))
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci#define TX_TAIL(channel)			(0xD5C + ((channel) << 6))
4498c2ecf20Sopenharmony_ci#define TX_TAIL_SET_DMAC_INT_EN_		BIT(31)
4508c2ecf20Sopenharmony_ci#define TX_TAIL_SET_TOP_INT_EN_			BIT(30)
4518c2ecf20Sopenharmony_ci#define TX_TAIL_SET_TOP_INT_VEC_EN_		BIT(29)
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci#define TX_CFG_C(channel)			(0xD64 + ((channel) << 6))
4548c2ecf20Sopenharmony_ci#define TX_CFG_C_TX_TOP_INT_EN_AUTO_CLR_	BIT(6)
4558c2ecf20Sopenharmony_ci#define TX_CFG_C_TX_DMA_INT_EN_AUTO_CLR_	BIT(5)
4568c2ecf20Sopenharmony_ci#define TX_CFG_C_TX_INT_EN_R2C_			BIT(4)
4578c2ecf20Sopenharmony_ci#define TX_CFG_C_TX_DMA_INT_STS_AUTO_CLR_	BIT(3)
4588c2ecf20Sopenharmony_ci#define TX_CFG_C_TX_INT_STS_R2C_MODE_MASK_	(0x00000007)
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci#define OTP_PWR_DN				(0x1000)
4618c2ecf20Sopenharmony_ci#define OTP_PWR_DN_PWRDN_N_			BIT(0)
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ci#define OTP_ADDR_HIGH				(0x1004)
4648c2ecf20Sopenharmony_ci#define OTP_ADDR_LOW				(0x1008)
4658c2ecf20Sopenharmony_ci
4668c2ecf20Sopenharmony_ci#define OTP_PRGM_DATA				(0x1010)
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ci#define OTP_PRGM_MODE				(0x1014)
4698c2ecf20Sopenharmony_ci#define OTP_PRGM_MODE_BYTE_			BIT(0)
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_ci#define OTP_READ_DATA				(0x1018)
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci#define OTP_FUNC_CMD				(0x1020)
4748c2ecf20Sopenharmony_ci#define OTP_FUNC_CMD_READ_			BIT(0)
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci#define OTP_TST_CMD				(0x1024)
4778c2ecf20Sopenharmony_ci#define OTP_TST_CMD_PRGVRFY_			BIT(3)
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci#define OTP_CMD_GO				(0x1028)
4808c2ecf20Sopenharmony_ci#define OTP_CMD_GO_GO_				BIT(0)
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_ci#define OTP_STATUS				(0x1030)
4838c2ecf20Sopenharmony_ci#define OTP_STATUS_BUSY_			BIT(0)
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_ci/* MAC statistics registers */
4868c2ecf20Sopenharmony_ci#define STAT_RX_FCS_ERRORS			(0x1200)
4878c2ecf20Sopenharmony_ci#define STAT_RX_ALIGNMENT_ERRORS		(0x1204)
4888c2ecf20Sopenharmony_ci#define STAT_RX_FRAGMENT_ERRORS			(0x1208)
4898c2ecf20Sopenharmony_ci#define STAT_RX_JABBER_ERRORS			(0x120C)
4908c2ecf20Sopenharmony_ci#define STAT_RX_UNDERSIZE_FRAME_ERRORS		(0x1210)
4918c2ecf20Sopenharmony_ci#define STAT_RX_OVERSIZE_FRAME_ERRORS		(0x1214)
4928c2ecf20Sopenharmony_ci#define STAT_RX_DROPPED_FRAMES			(0x1218)
4938c2ecf20Sopenharmony_ci#define STAT_RX_UNICAST_BYTE_COUNT		(0x121C)
4948c2ecf20Sopenharmony_ci#define STAT_RX_BROADCAST_BYTE_COUNT		(0x1220)
4958c2ecf20Sopenharmony_ci#define STAT_RX_MULTICAST_BYTE_COUNT		(0x1224)
4968c2ecf20Sopenharmony_ci#define STAT_RX_UNICAST_FRAMES			(0x1228)
4978c2ecf20Sopenharmony_ci#define STAT_RX_BROADCAST_FRAMES		(0x122C)
4988c2ecf20Sopenharmony_ci#define STAT_RX_MULTICAST_FRAMES		(0x1230)
4998c2ecf20Sopenharmony_ci#define STAT_RX_PAUSE_FRAMES			(0x1234)
5008c2ecf20Sopenharmony_ci#define STAT_RX_64_BYTE_FRAMES			(0x1238)
5018c2ecf20Sopenharmony_ci#define STAT_RX_65_127_BYTE_FRAMES		(0x123C)
5028c2ecf20Sopenharmony_ci#define STAT_RX_128_255_BYTE_FRAMES		(0x1240)
5038c2ecf20Sopenharmony_ci#define STAT_RX_256_511_BYTES_FRAMES		(0x1244)
5048c2ecf20Sopenharmony_ci#define STAT_RX_512_1023_BYTE_FRAMES		(0x1248)
5058c2ecf20Sopenharmony_ci#define STAT_RX_1024_1518_BYTE_FRAMES		(0x124C)
5068c2ecf20Sopenharmony_ci#define STAT_RX_GREATER_1518_BYTE_FRAMES	(0x1250)
5078c2ecf20Sopenharmony_ci#define STAT_RX_TOTAL_FRAMES			(0x1254)
5088c2ecf20Sopenharmony_ci#define STAT_EEE_RX_LPI_TRANSITIONS		(0x1258)
5098c2ecf20Sopenharmony_ci#define STAT_EEE_RX_LPI_TIME			(0x125C)
5108c2ecf20Sopenharmony_ci#define STAT_RX_COUNTER_ROLLOVER_STATUS		(0x127C)
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci#define STAT_TX_FCS_ERRORS			(0x1280)
5138c2ecf20Sopenharmony_ci#define STAT_TX_EXCESS_DEFERRAL_ERRORS		(0x1284)
5148c2ecf20Sopenharmony_ci#define STAT_TX_CARRIER_ERRORS			(0x1288)
5158c2ecf20Sopenharmony_ci#define STAT_TX_BAD_BYTE_COUNT			(0x128C)
5168c2ecf20Sopenharmony_ci#define STAT_TX_SINGLE_COLLISIONS		(0x1290)
5178c2ecf20Sopenharmony_ci#define STAT_TX_MULTIPLE_COLLISIONS		(0x1294)
5188c2ecf20Sopenharmony_ci#define STAT_TX_EXCESSIVE_COLLISION		(0x1298)
5198c2ecf20Sopenharmony_ci#define STAT_TX_LATE_COLLISIONS			(0x129C)
5208c2ecf20Sopenharmony_ci#define STAT_TX_UNICAST_BYTE_COUNT		(0x12A0)
5218c2ecf20Sopenharmony_ci#define STAT_TX_BROADCAST_BYTE_COUNT		(0x12A4)
5228c2ecf20Sopenharmony_ci#define STAT_TX_MULTICAST_BYTE_COUNT		(0x12A8)
5238c2ecf20Sopenharmony_ci#define STAT_TX_UNICAST_FRAMES			(0x12AC)
5248c2ecf20Sopenharmony_ci#define STAT_TX_BROADCAST_FRAMES		(0x12B0)
5258c2ecf20Sopenharmony_ci#define STAT_TX_MULTICAST_FRAMES		(0x12B4)
5268c2ecf20Sopenharmony_ci#define STAT_TX_PAUSE_FRAMES			(0x12B8)
5278c2ecf20Sopenharmony_ci#define STAT_TX_64_BYTE_FRAMES			(0x12BC)
5288c2ecf20Sopenharmony_ci#define STAT_TX_65_127_BYTE_FRAMES		(0x12C0)
5298c2ecf20Sopenharmony_ci#define STAT_TX_128_255_BYTE_FRAMES		(0x12C4)
5308c2ecf20Sopenharmony_ci#define STAT_TX_256_511_BYTES_FRAMES		(0x12C8)
5318c2ecf20Sopenharmony_ci#define STAT_TX_512_1023_BYTE_FRAMES		(0x12CC)
5328c2ecf20Sopenharmony_ci#define STAT_TX_1024_1518_BYTE_FRAMES		(0x12D0)
5338c2ecf20Sopenharmony_ci#define STAT_TX_GREATER_1518_BYTE_FRAMES	(0x12D4)
5348c2ecf20Sopenharmony_ci#define STAT_TX_TOTAL_FRAMES			(0x12D8)
5358c2ecf20Sopenharmony_ci#define STAT_EEE_TX_LPI_TRANSITIONS		(0x12DC)
5368c2ecf20Sopenharmony_ci#define STAT_EEE_TX_LPI_TIME			(0x12E0)
5378c2ecf20Sopenharmony_ci#define STAT_TX_COUNTER_ROLLOVER_STATUS		(0x12FC)
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci/* End of Register definitions */
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci#define LAN743X_MAX_RX_CHANNELS		(4)
5428c2ecf20Sopenharmony_ci#define LAN743X_MAX_TX_CHANNELS		(1)
5438c2ecf20Sopenharmony_cistruct lan743x_adapter;
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci#define LAN743X_USED_RX_CHANNELS	(4)
5468c2ecf20Sopenharmony_ci#define LAN743X_USED_TX_CHANNELS	(1)
5478c2ecf20Sopenharmony_ci#define LAN743X_INT_MOD	(400)
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_ci#if (LAN743X_USED_RX_CHANNELS > LAN743X_MAX_RX_CHANNELS)
5508c2ecf20Sopenharmony_ci#error Invalid LAN743X_USED_RX_CHANNELS
5518c2ecf20Sopenharmony_ci#endif
5528c2ecf20Sopenharmony_ci#if (LAN743X_USED_TX_CHANNELS > LAN743X_MAX_TX_CHANNELS)
5538c2ecf20Sopenharmony_ci#error Invalid LAN743X_USED_TX_CHANNELS
5548c2ecf20Sopenharmony_ci#endif
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_ci/* PCI */
5578c2ecf20Sopenharmony_ci/* SMSC acquired EFAR late 1990's, MCHP acquired SMSC 2012 */
5588c2ecf20Sopenharmony_ci#define PCI_VENDOR_ID_SMSC		PCI_VENDOR_ID_EFAR
5598c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_SMSC_LAN7430	(0x7430)
5608c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_SMSC_LAN7431	(0x7431)
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci#define PCI_CONFIG_LENGTH		(0x1000)
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_ci/* CSR */
5658c2ecf20Sopenharmony_ci#define CSR_LENGTH					(0x2000)
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_ci#define LAN743X_CSR_FLAG_IS_A0				BIT(0)
5688c2ecf20Sopenharmony_ci#define LAN743X_CSR_FLAG_IS_B0				BIT(1)
5698c2ecf20Sopenharmony_ci#define LAN743X_CSR_FLAG_SUPPORTS_INTR_AUTO_SET_CLR	BIT(8)
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_cistruct lan743x_csr {
5728c2ecf20Sopenharmony_ci	u32 flags;
5738c2ecf20Sopenharmony_ci	u8 __iomem *csr_address;
5748c2ecf20Sopenharmony_ci	u32 id_rev;
5758c2ecf20Sopenharmony_ci	u32 fpga_rev;
5768c2ecf20Sopenharmony_ci};
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_ci/* INTERRUPTS */
5798c2ecf20Sopenharmony_citypedef void(*lan743x_vector_handler)(void *context, u32 int_sts, u32 flags);
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_IRQ_SHARED			BIT(0)
5828c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_STATUS_READ		BIT(1)
5838c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_STATUS_R2C		BIT(2)
5848c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C		BIT(3)
5858c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CHECK		BIT(4)
5868c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CLEAR		BIT(5)
5878c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_R2C		BIT(6)
5888c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_MASTER_ENABLE_CLEAR		BIT(7)
5898c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_MASTER_ENABLE_SET		BIT(8)
5908c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_ISR_CLEAR	BIT(9)
5918c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_ISR_SET	BIT(10)
5928c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_CLEAR	BIT(11)
5938c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET	BIT(12)
5948c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_CLEAR	BIT(13)
5958c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET	BIT(14)
5968c2ecf20Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR	BIT(15)
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_cistruct lan743x_vector {
5998c2ecf20Sopenharmony_ci	int			irq;
6008c2ecf20Sopenharmony_ci	u32			flags;
6018c2ecf20Sopenharmony_ci	struct lan743x_adapter	*adapter;
6028c2ecf20Sopenharmony_ci	int			vector_index;
6038c2ecf20Sopenharmony_ci	u32			int_mask;
6048c2ecf20Sopenharmony_ci	lan743x_vector_handler	handler;
6058c2ecf20Sopenharmony_ci	void			*context;
6068c2ecf20Sopenharmony_ci};
6078c2ecf20Sopenharmony_ci
6088c2ecf20Sopenharmony_ci#define LAN743X_MAX_VECTOR_COUNT	(8)
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_cistruct lan743x_intr {
6118c2ecf20Sopenharmony_ci	int			flags;
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci	unsigned int		irq;
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci	struct lan743x_vector	vector_list[LAN743X_MAX_VECTOR_COUNT];
6168c2ecf20Sopenharmony_ci	int			number_of_vectors;
6178c2ecf20Sopenharmony_ci	bool			using_vectors;
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_ci	int			software_isr_flag;
6208c2ecf20Sopenharmony_ci};
6218c2ecf20Sopenharmony_ci
6228c2ecf20Sopenharmony_ci#define LAN743X_MAX_FRAME_SIZE			(9 * 1024)
6238c2ecf20Sopenharmony_ci
6248c2ecf20Sopenharmony_ci/* PHY */
6258c2ecf20Sopenharmony_cistruct lan743x_phy {
6268c2ecf20Sopenharmony_ci	bool	fc_autoneg;
6278c2ecf20Sopenharmony_ci	u8	fc_request_control;
6288c2ecf20Sopenharmony_ci};
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci/* TX */
6318c2ecf20Sopenharmony_cistruct lan743x_tx_descriptor;
6328c2ecf20Sopenharmony_cistruct lan743x_tx_buffer_info;
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_ci#define GPIO_QUEUE_STARTED		(0)
6358c2ecf20Sopenharmony_ci#define GPIO_TX_FUNCTION		(1)
6368c2ecf20Sopenharmony_ci#define GPIO_TX_COMPLETION		(2)
6378c2ecf20Sopenharmony_ci#define GPIO_TX_FRAGMENT		(3)
6388c2ecf20Sopenharmony_ci
6398c2ecf20Sopenharmony_ci#define TX_FRAME_FLAG_IN_PROGRESS	BIT(0)
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci#define TX_TS_FLAG_TIMESTAMPING_ENABLED	BIT(0)
6428c2ecf20Sopenharmony_ci#define TX_TS_FLAG_ONE_STEP_SYNC	BIT(1)
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_cistruct lan743x_tx {
6458c2ecf20Sopenharmony_ci	struct lan743x_adapter *adapter;
6468c2ecf20Sopenharmony_ci	u32	ts_flags;
6478c2ecf20Sopenharmony_ci	u32	vector_flags;
6488c2ecf20Sopenharmony_ci	int	channel_number;
6498c2ecf20Sopenharmony_ci
6508c2ecf20Sopenharmony_ci	int	ring_size;
6518c2ecf20Sopenharmony_ci	size_t	ring_allocation_size;
6528c2ecf20Sopenharmony_ci	struct lan743x_tx_descriptor *ring_cpu_ptr;
6538c2ecf20Sopenharmony_ci	dma_addr_t ring_dma_ptr;
6548c2ecf20Sopenharmony_ci	/* ring_lock: used to prevent concurrent access to tx ring */
6558c2ecf20Sopenharmony_ci	spinlock_t ring_lock;
6568c2ecf20Sopenharmony_ci	u32		frame_flags;
6578c2ecf20Sopenharmony_ci	u32		frame_first;
6588c2ecf20Sopenharmony_ci	u32		frame_data0;
6598c2ecf20Sopenharmony_ci	u32		frame_tail;
6608c2ecf20Sopenharmony_ci
6618c2ecf20Sopenharmony_ci	struct lan743x_tx_buffer_info *buffer_info;
6628c2ecf20Sopenharmony_ci
6638c2ecf20Sopenharmony_ci	__le32		*head_cpu_ptr;
6648c2ecf20Sopenharmony_ci	dma_addr_t	head_dma_ptr;
6658c2ecf20Sopenharmony_ci	int		last_head;
6668c2ecf20Sopenharmony_ci	int		last_tail;
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_ci	struct napi_struct napi;
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ci	struct sk_buff *overflow_skb;
6718c2ecf20Sopenharmony_ci};
6728c2ecf20Sopenharmony_ci
6738c2ecf20Sopenharmony_civoid lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx,
6748c2ecf20Sopenharmony_ci				      bool enable_timestamping,
6758c2ecf20Sopenharmony_ci				      bool enable_onestep_sync);
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci/* RX */
6788c2ecf20Sopenharmony_cistruct lan743x_rx_descriptor;
6798c2ecf20Sopenharmony_cistruct lan743x_rx_buffer_info;
6808c2ecf20Sopenharmony_ci
6818c2ecf20Sopenharmony_cistruct lan743x_rx {
6828c2ecf20Sopenharmony_ci	struct lan743x_adapter *adapter;
6838c2ecf20Sopenharmony_ci	u32	vector_flags;
6848c2ecf20Sopenharmony_ci	int	channel_number;
6858c2ecf20Sopenharmony_ci
6868c2ecf20Sopenharmony_ci	int	ring_size;
6878c2ecf20Sopenharmony_ci	size_t	ring_allocation_size;
6888c2ecf20Sopenharmony_ci	struct lan743x_rx_descriptor *ring_cpu_ptr;
6898c2ecf20Sopenharmony_ci	dma_addr_t ring_dma_ptr;
6908c2ecf20Sopenharmony_ci
6918c2ecf20Sopenharmony_ci	struct lan743x_rx_buffer_info *buffer_info;
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_ci	__le32		*head_cpu_ptr;
6948c2ecf20Sopenharmony_ci	dma_addr_t	head_dma_ptr;
6958c2ecf20Sopenharmony_ci	u32		last_head;
6968c2ecf20Sopenharmony_ci	u32		last_tail;
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci	struct napi_struct napi;
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_ci	u32		frame_count;
7018c2ecf20Sopenharmony_ci};
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_cistruct lan743x_adapter {
7048c2ecf20Sopenharmony_ci	struct net_device       *netdev;
7058c2ecf20Sopenharmony_ci	struct mii_bus		*mdiobus;
7068c2ecf20Sopenharmony_ci	phy_interface_t		phy_mode;
7078c2ecf20Sopenharmony_ci	int                     msg_enable;
7088c2ecf20Sopenharmony_ci#ifdef CONFIG_PM
7098c2ecf20Sopenharmony_ci	u32			wolopts;
7108c2ecf20Sopenharmony_ci#endif
7118c2ecf20Sopenharmony_ci	struct pci_dev		*pdev;
7128c2ecf20Sopenharmony_ci	struct lan743x_csr      csr;
7138c2ecf20Sopenharmony_ci	struct lan743x_intr     intr;
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_ci	struct lan743x_gpio	gpio;
7168c2ecf20Sopenharmony_ci	struct lan743x_ptp	ptp;
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_ci	u8			mac_address[ETH_ALEN];
7198c2ecf20Sopenharmony_ci
7208c2ecf20Sopenharmony_ci	struct lan743x_phy      phy;
7218c2ecf20Sopenharmony_ci	struct lan743x_tx       tx[LAN743X_MAX_TX_CHANNELS];
7228c2ecf20Sopenharmony_ci	struct lan743x_rx       rx[LAN743X_MAX_RX_CHANNELS];
7238c2ecf20Sopenharmony_ci
7248c2ecf20Sopenharmony_ci#define LAN743X_ADAPTER_FLAG_OTP		BIT(0)
7258c2ecf20Sopenharmony_ci	u32			flags;
7268c2ecf20Sopenharmony_ci};
7278c2ecf20Sopenharmony_ci
7288c2ecf20Sopenharmony_ci#define LAN743X_COMPONENT_FLAG_RX(channel)  BIT(20 + (channel))
7298c2ecf20Sopenharmony_ci
7308c2ecf20Sopenharmony_ci#define INTR_FLAG_IRQ_REQUESTED(vector_index)	BIT(0 + vector_index)
7318c2ecf20Sopenharmony_ci#define INTR_FLAG_MSI_ENABLED			BIT(8)
7328c2ecf20Sopenharmony_ci#define INTR_FLAG_MSIX_ENABLED			BIT(9)
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_ci#define MAC_MII_READ            1
7358c2ecf20Sopenharmony_ci#define MAC_MII_WRITE           0
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_ci#define PHY_FLAG_OPENED     BIT(0)
7388c2ecf20Sopenharmony_ci#define PHY_FLAG_ATTACHED   BIT(1)
7398c2ecf20Sopenharmony_ci
7408c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
7418c2ecf20Sopenharmony_ci#define DMA_ADDR_HIGH32(dma_addr)   ((u32)(((dma_addr) >> 32) & 0xFFFFFFFF))
7428c2ecf20Sopenharmony_ci#else
7438c2ecf20Sopenharmony_ci#define DMA_ADDR_HIGH32(dma_addr)   ((u32)(0))
7448c2ecf20Sopenharmony_ci#endif
7458c2ecf20Sopenharmony_ci#define DMA_ADDR_LOW32(dma_addr) ((u32)((dma_addr) & 0xFFFFFFFF))
7468c2ecf20Sopenharmony_ci#define DMA_DESCRIPTOR_SPACING_16       (16)
7478c2ecf20Sopenharmony_ci#define DMA_DESCRIPTOR_SPACING_32       (32)
7488c2ecf20Sopenharmony_ci#define DMA_DESCRIPTOR_SPACING_64       (64)
7498c2ecf20Sopenharmony_ci#define DMA_DESCRIPTOR_SPACING_128      (128)
7508c2ecf20Sopenharmony_ci#define DEFAULT_DMA_DESCRIPTOR_SPACING  (L1_CACHE_BYTES)
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_ci#define DMAC_CHANNEL_STATE_SET(start_bit, stop_bit) \
7538c2ecf20Sopenharmony_ci	(((start_bit) ? 2 : 0) | ((stop_bit) ? 1 : 0))
7548c2ecf20Sopenharmony_ci#define DMAC_CHANNEL_STATE_INITIAL      DMAC_CHANNEL_STATE_SET(0, 0)
7558c2ecf20Sopenharmony_ci#define DMAC_CHANNEL_STATE_STARTED      DMAC_CHANNEL_STATE_SET(1, 0)
7568c2ecf20Sopenharmony_ci#define DMAC_CHANNEL_STATE_STOP_PENDING DMAC_CHANNEL_STATE_SET(1, 1)
7578c2ecf20Sopenharmony_ci#define DMAC_CHANNEL_STATE_STOPPED      DMAC_CHANNEL_STATE_SET(0, 1)
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci/* TX Descriptor bits */
7608c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_DTYPE_MASK_		(0xC0000000)
7618c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_DTYPE_DATA_		(0x00000000)
7628c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_DTYPE_EXT_		(0x40000000)
7638c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_FS_			(0x20000000)
7648c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_LS_			(0x10000000)
7658c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_EXT_			(0x08000000)
7668c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_IOC_			(0x04000000)
7678c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_ICE_			(0x00400000)
7688c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_IPE_			(0x00200000)
7698c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_TPE_			(0x00100000)
7708c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_FCS_			(0x00020000)
7718c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_TSE_			(0x00010000)
7728c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_BUF_LENGTH_MASK_		(0x0000FFFF)
7738c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_EXT_LSO_			(0x00200000)
7748c2ecf20Sopenharmony_ci#define TX_DESC_DATA0_EXT_PAY_LENGTH_MASK_	(0x000FFFFF)
7758c2ecf20Sopenharmony_ci#define TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_	(0x3FFF0000)
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_cistruct lan743x_tx_descriptor {
7788c2ecf20Sopenharmony_ci	__le32     data0;
7798c2ecf20Sopenharmony_ci	__le32     data1;
7808c2ecf20Sopenharmony_ci	__le32     data2;
7818c2ecf20Sopenharmony_ci	__le32     data3;
7828c2ecf20Sopenharmony_ci} __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING);
7838c2ecf20Sopenharmony_ci
7848c2ecf20Sopenharmony_ci#define TX_BUFFER_INFO_FLAG_ACTIVE		BIT(0)
7858c2ecf20Sopenharmony_ci#define TX_BUFFER_INFO_FLAG_TIMESTAMP_REQUESTED	BIT(1)
7868c2ecf20Sopenharmony_ci#define TX_BUFFER_INFO_FLAG_IGNORE_SYNC		BIT(2)
7878c2ecf20Sopenharmony_ci#define TX_BUFFER_INFO_FLAG_SKB_FRAGMENT	BIT(3)
7888c2ecf20Sopenharmony_cistruct lan743x_tx_buffer_info {
7898c2ecf20Sopenharmony_ci	int flags;
7908c2ecf20Sopenharmony_ci	struct sk_buff *skb;
7918c2ecf20Sopenharmony_ci	dma_addr_t      dma_ptr;
7928c2ecf20Sopenharmony_ci	unsigned int    buffer_length;
7938c2ecf20Sopenharmony_ci};
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ci#define LAN743X_TX_RING_SIZE    (50)
7968c2ecf20Sopenharmony_ci
7978c2ecf20Sopenharmony_ci/* OWN bit is set. ie, Descs are owned by RX DMAC */
7988c2ecf20Sopenharmony_ci#define RX_DESC_DATA0_OWN_                (0x00008000)
7998c2ecf20Sopenharmony_ci/* OWN bit is clear. ie, Descs are owned by host */
8008c2ecf20Sopenharmony_ci#define RX_DESC_DATA0_FS_                 (0x80000000)
8018c2ecf20Sopenharmony_ci#define RX_DESC_DATA0_LS_                 (0x40000000)
8028c2ecf20Sopenharmony_ci#define RX_DESC_DATA0_FRAME_LENGTH_MASK_  (0x3FFF0000)
8038c2ecf20Sopenharmony_ci#define RX_DESC_DATA0_FRAME_LENGTH_GET_(data0)	\
8048c2ecf20Sopenharmony_ci	(((data0) & RX_DESC_DATA0_FRAME_LENGTH_MASK_) >> 16)
8058c2ecf20Sopenharmony_ci#define RX_DESC_DATA0_EXT_                (0x00004000)
8068c2ecf20Sopenharmony_ci#define RX_DESC_DATA0_BUF_LENGTH_MASK_    (0x00003FFF)
8078c2ecf20Sopenharmony_ci#define RX_DESC_DATA2_TS_NS_MASK_         (0x3FFFFFFF)
8088c2ecf20Sopenharmony_ci
8098c2ecf20Sopenharmony_ci#if ((NET_IP_ALIGN != 0) && (NET_IP_ALIGN != 2))
8108c2ecf20Sopenharmony_ci#error NET_IP_ALIGN must be 0 or 2
8118c2ecf20Sopenharmony_ci#endif
8128c2ecf20Sopenharmony_ci
8138c2ecf20Sopenharmony_ci#define RX_HEAD_PADDING		NET_IP_ALIGN
8148c2ecf20Sopenharmony_ci
8158c2ecf20Sopenharmony_cistruct lan743x_rx_descriptor {
8168c2ecf20Sopenharmony_ci	__le32     data0;
8178c2ecf20Sopenharmony_ci	__le32     data1;
8188c2ecf20Sopenharmony_ci	__le32     data2;
8198c2ecf20Sopenharmony_ci	__le32     data3;
8208c2ecf20Sopenharmony_ci} __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING);
8218c2ecf20Sopenharmony_ci
8228c2ecf20Sopenharmony_ci#define RX_BUFFER_INFO_FLAG_ACTIVE      BIT(0)
8238c2ecf20Sopenharmony_cistruct lan743x_rx_buffer_info {
8248c2ecf20Sopenharmony_ci	int flags;
8258c2ecf20Sopenharmony_ci	struct sk_buff *skb;
8268c2ecf20Sopenharmony_ci
8278c2ecf20Sopenharmony_ci	dma_addr_t      dma_ptr;
8288c2ecf20Sopenharmony_ci	unsigned int    buffer_length;
8298c2ecf20Sopenharmony_ci};
8308c2ecf20Sopenharmony_ci
8318c2ecf20Sopenharmony_ci#define LAN743X_RX_RING_SIZE        (65)
8328c2ecf20Sopenharmony_ci
8338c2ecf20Sopenharmony_ci#define RX_PROCESS_RESULT_NOTHING_TO_DO     (0)
8348c2ecf20Sopenharmony_ci#define RX_PROCESS_RESULT_PACKET_RECEIVED   (1)
8358c2ecf20Sopenharmony_ci#define RX_PROCESS_RESULT_PACKET_DROPPED    (2)
8368c2ecf20Sopenharmony_ci
8378c2ecf20Sopenharmony_ciu32 lan743x_csr_read(struct lan743x_adapter *adapter, int offset);
8388c2ecf20Sopenharmony_civoid lan743x_csr_write(struct lan743x_adapter *adapter, int offset, u32 data);
8398c2ecf20Sopenharmony_ci
8408c2ecf20Sopenharmony_ci#endif /* _LAN743X_H */
841