162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 262306a36Sopenharmony_ci/* Copyright (C) 2018 Microchip Technology Inc. */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef _LAN743X_H 562306a36Sopenharmony_ci#define _LAN743X_H 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/phy.h> 862306a36Sopenharmony_ci#include "lan743x_ptp.h" 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#define DRIVER_AUTHOR "Bryan Whitehead <Bryan.Whitehead@microchip.com>" 1162306a36Sopenharmony_ci#define DRIVER_DESC "LAN743x PCIe Gigabit Ethernet Driver" 1262306a36Sopenharmony_ci#define DRIVER_NAME "lan743x" 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* Register Definitions */ 1562306a36Sopenharmony_ci#define ID_REV (0x00) 1662306a36Sopenharmony_ci#define ID_REV_ID_MASK_ (0xFFFF0000) 1762306a36Sopenharmony_ci#define ID_REV_ID_LAN7430_ (0x74300000) 1862306a36Sopenharmony_ci#define ID_REV_ID_LAN7431_ (0x74310000) 1962306a36Sopenharmony_ci#define ID_REV_ID_LAN743X_ (0x74300000) 2062306a36Sopenharmony_ci#define ID_REV_ID_A011_ (0xA0110000) // PCI11010 2162306a36Sopenharmony_ci#define ID_REV_ID_A041_ (0xA0410000) // PCI11414 2262306a36Sopenharmony_ci#define ID_REV_ID_A0X1_ (0xA0010000) 2362306a36Sopenharmony_ci#define ID_REV_IS_VALID_CHIP_ID_(id_rev) \ 2462306a36Sopenharmony_ci ((((id_rev) & 0xFFF00000) == ID_REV_ID_LAN743X_) || \ 2562306a36Sopenharmony_ci (((id_rev) & 0xFF0F0000) == ID_REV_ID_A0X1_)) 2662306a36Sopenharmony_ci#define ID_REV_CHIP_REV_MASK_ (0x0000FFFF) 2762306a36Sopenharmony_ci#define ID_REV_CHIP_REV_A0_ (0x00000000) 2862306a36Sopenharmony_ci#define ID_REV_CHIP_REV_B0_ (0x00000010) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define FPGA_REV (0x04) 3162306a36Sopenharmony_ci#define FPGA_REV_GET_MINOR_(fpga_rev) (((fpga_rev) >> 8) & 0x000000FF) 3262306a36Sopenharmony_ci#define FPGA_REV_GET_MAJOR_(fpga_rev) ((fpga_rev) & 0x000000FF) 3362306a36Sopenharmony_ci#define FPGA_SGMII_OP BIT(24) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define STRAP_READ (0x0C) 3662306a36Sopenharmony_ci#define STRAP_READ_USE_SGMII_EN_ BIT(22) 3762306a36Sopenharmony_ci#define STRAP_READ_SGMII_EN_ BIT(6) 3862306a36Sopenharmony_ci#define STRAP_READ_SGMII_REFCLK_ BIT(5) 3962306a36Sopenharmony_ci#define STRAP_READ_SGMII_2_5G_ BIT(4) 4062306a36Sopenharmony_ci#define STRAP_READ_BASE_X_ BIT(3) 4162306a36Sopenharmony_ci#define STRAP_READ_RGMII_TXC_DELAY_EN_ BIT(2) 4262306a36Sopenharmony_ci#define STRAP_READ_RGMII_RXC_DELAY_EN_ BIT(1) 4362306a36Sopenharmony_ci#define STRAP_READ_ADV_PM_DISABLE_ BIT(0) 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#define HW_CFG (0x010) 4662306a36Sopenharmony_ci#define HW_CFG_RST_PROTECT_PCIE_ BIT(19) 4762306a36Sopenharmony_ci#define HW_CFG_HOT_RESET_DIS_ BIT(15) 4862306a36Sopenharmony_ci#define HW_CFG_D3_VAUX_OVR_ BIT(14) 4962306a36Sopenharmony_ci#define HW_CFG_D3_RESET_DIS_ BIT(13) 5062306a36Sopenharmony_ci#define HW_CFG_RST_PROTECT_ BIT(12) 5162306a36Sopenharmony_ci#define HW_CFG_RELOAD_TYPE_ALL_ (0x00000FC0) 5262306a36Sopenharmony_ci#define HW_CFG_EE_OTP_RELOAD_ BIT(4) 5362306a36Sopenharmony_ci#define HW_CFG_LRST_ BIT(1) 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci#define PMT_CTL (0x014) 5662306a36Sopenharmony_ci#define PMT_CTL_ETH_PHY_D3_COLD_OVR_ BIT(27) 5762306a36Sopenharmony_ci#define PMT_CTL_MAC_D3_RX_CLK_OVR_ BIT(25) 5862306a36Sopenharmony_ci#define PMT_CTL_ETH_PHY_EDPD_PLL_CTL_ BIT(24) 5962306a36Sopenharmony_ci#define PMT_CTL_ETH_PHY_D3_OVR_ BIT(23) 6062306a36Sopenharmony_ci#define PMT_CTL_RX_FCT_RFE_D3_CLK_OVR_ BIT(18) 6162306a36Sopenharmony_ci#define PMT_CTL_GPIO_WAKEUP_EN_ BIT(15) 6262306a36Sopenharmony_ci#define PMT_CTL_EEE_WAKEUP_EN_ BIT(13) 6362306a36Sopenharmony_ci#define PMT_CTL_READY_ BIT(7) 6462306a36Sopenharmony_ci#define PMT_CTL_ETH_PHY_RST_ BIT(4) 6562306a36Sopenharmony_ci#define PMT_CTL_WOL_EN_ BIT(3) 6662306a36Sopenharmony_ci#define PMT_CTL_ETH_PHY_WAKE_EN_ BIT(2) 6762306a36Sopenharmony_ci#define PMT_CTL_WUPS_MASK_ (0x00000003) 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define DP_SEL (0x024) 7062306a36Sopenharmony_ci#define DP_SEL_DPRDY_ BIT(31) 7162306a36Sopenharmony_ci#define DP_SEL_MASK_ (0x0000001F) 7262306a36Sopenharmony_ci#define DP_SEL_RFE_RAM (0x00000001) 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci#define DP_SEL_VHF_HASH_LEN (16) 7562306a36Sopenharmony_ci#define DP_SEL_VHF_VLAN_LEN (128) 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci#define DP_CMD (0x028) 7862306a36Sopenharmony_ci#define DP_CMD_WRITE_ (0x00000001) 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci#define DP_ADDR (0x02C) 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci#define DP_DATA_0 (0x030) 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define E2P_CMD (0x040) 8562306a36Sopenharmony_ci#define E2P_CMD_EPC_BUSY_ BIT(31) 8662306a36Sopenharmony_ci#define E2P_CMD_EPC_CMD_WRITE_ (0x30000000) 8762306a36Sopenharmony_ci#define E2P_CMD_EPC_CMD_EWEN_ (0x20000000) 8862306a36Sopenharmony_ci#define E2P_CMD_EPC_CMD_READ_ (0x00000000) 8962306a36Sopenharmony_ci#define E2P_CMD_EPC_TIMEOUT_ BIT(10) 9062306a36Sopenharmony_ci#define E2P_CMD_EPC_ADDR_MASK_ (0x000001FF) 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci#define E2P_DATA (0x044) 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci/* Hearthstone top level & System Reg Addresses */ 9562306a36Sopenharmony_ci#define ETH_CTRL_REG_ADDR_BASE (0x0000) 9662306a36Sopenharmony_ci#define ETH_SYS_REG_ADDR_BASE (0x4000) 9762306a36Sopenharmony_ci#define CONFIG_REG_ADDR_BASE (0x0000) 9862306a36Sopenharmony_ci#define ETH_EEPROM_REG_ADDR_BASE (0x0E00) 9962306a36Sopenharmony_ci#define ETH_OTP_REG_ADDR_BASE (0x1000) 10062306a36Sopenharmony_ci#define GEN_SYS_CONFIG_LOAD_STARTED_REG (0x0078) 10162306a36Sopenharmony_ci#define ETH_SYS_CONFIG_LOAD_STARTED_REG (ETH_SYS_REG_ADDR_BASE + \ 10262306a36Sopenharmony_ci CONFIG_REG_ADDR_BASE + \ 10362306a36Sopenharmony_ci GEN_SYS_CONFIG_LOAD_STARTED_REG) 10462306a36Sopenharmony_ci#define GEN_SYS_LOAD_STARTED_REG_ETH_ BIT(4) 10562306a36Sopenharmony_ci#define SYS_LOCK_REG (0x00A0) 10662306a36Sopenharmony_ci#define SYS_LOCK_REG_MAIN_LOCK_ BIT(7) 10762306a36Sopenharmony_ci#define SYS_LOCK_REG_GEN_PERI_LOCK_ BIT(5) 10862306a36Sopenharmony_ci#define SYS_LOCK_REG_SPI_PERI_LOCK_ BIT(4) 10962306a36Sopenharmony_ci#define SYS_LOCK_REG_SMBUS_PERI_LOCK_ BIT(3) 11062306a36Sopenharmony_ci#define SYS_LOCK_REG_UART_SS_LOCK_ BIT(2) 11162306a36Sopenharmony_ci#define SYS_LOCK_REG_ENET_SS_LOCK_ BIT(1) 11262306a36Sopenharmony_ci#define SYS_LOCK_REG_USB_SS_LOCK_ BIT(0) 11362306a36Sopenharmony_ci#define ETH_SYSTEM_SYS_LOCK_REG (ETH_SYS_REG_ADDR_BASE + \ 11462306a36Sopenharmony_ci CONFIG_REG_ADDR_BASE + \ 11562306a36Sopenharmony_ci SYS_LOCK_REG) 11662306a36Sopenharmony_ci#define HS_EEPROM_REG_ADDR_BASE (ETH_SYS_REG_ADDR_BASE + \ 11762306a36Sopenharmony_ci ETH_EEPROM_REG_ADDR_BASE) 11862306a36Sopenharmony_ci#define HS_E2P_CMD (HS_EEPROM_REG_ADDR_BASE + 0x0000) 11962306a36Sopenharmony_ci#define HS_E2P_CMD_EPC_BUSY_ BIT(31) 12062306a36Sopenharmony_ci#define HS_E2P_CMD_EPC_CMD_WRITE_ GENMASK(29, 28) 12162306a36Sopenharmony_ci#define HS_E2P_CMD_EPC_CMD_READ_ (0x0) 12262306a36Sopenharmony_ci#define HS_E2P_CMD_EPC_TIMEOUT_ BIT(17) 12362306a36Sopenharmony_ci#define HS_E2P_CMD_EPC_ADDR_MASK_ GENMASK(15, 0) 12462306a36Sopenharmony_ci#define HS_E2P_DATA (HS_EEPROM_REG_ADDR_BASE + 0x0004) 12562306a36Sopenharmony_ci#define HS_E2P_DATA_MASK_ GENMASK(7, 0) 12662306a36Sopenharmony_ci#define HS_E2P_CFG (HS_EEPROM_REG_ADDR_BASE + 0x0008) 12762306a36Sopenharmony_ci#define HS_E2P_CFG_I2C_PULSE_MASK_ GENMASK(19, 16) 12862306a36Sopenharmony_ci#define HS_E2P_CFG_EEPROM_SIZE_SEL_ BIT(12) 12962306a36Sopenharmony_ci#define HS_E2P_CFG_I2C_BAUD_RATE_MASK_ GENMASK(9, 8) 13062306a36Sopenharmony_ci#define HS_E2P_CFG_TEST_EEPR_TO_BYP_ BIT(0) 13162306a36Sopenharmony_ci#define HS_E2P_PAD_CTL (HS_EEPROM_REG_ADDR_BASE + 0x000C) 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci#define GPIO_CFG0 (0x050) 13462306a36Sopenharmony_ci#define GPIO_CFG0_GPIO_DIR_BIT_(bit) BIT(16 + (bit)) 13562306a36Sopenharmony_ci#define GPIO_CFG0_GPIO_DATA_BIT_(bit) BIT(0 + (bit)) 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci#define GPIO_CFG1 (0x054) 13862306a36Sopenharmony_ci#define GPIO_CFG1_GPIOEN_BIT_(bit) BIT(16 + (bit)) 13962306a36Sopenharmony_ci#define GPIO_CFG1_GPIOBUF_BIT_(bit) BIT(0 + (bit)) 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci#define GPIO_CFG2 (0x058) 14262306a36Sopenharmony_ci#define GPIO_CFG2_1588_POL_BIT_(bit) BIT(0 + (bit)) 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci#define GPIO_CFG3 (0x05C) 14562306a36Sopenharmony_ci#define GPIO_CFG3_1588_CH_SEL_BIT_(bit) BIT(16 + (bit)) 14662306a36Sopenharmony_ci#define GPIO_CFG3_1588_OE_BIT_(bit) BIT(0 + (bit)) 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci#define FCT_RX_CTL (0xAC) 14962306a36Sopenharmony_ci#define FCT_RX_CTL_EN_(channel) BIT(28 + (channel)) 15062306a36Sopenharmony_ci#define FCT_RX_CTL_DIS_(channel) BIT(24 + (channel)) 15162306a36Sopenharmony_ci#define FCT_RX_CTL_RESET_(channel) BIT(20 + (channel)) 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci#define FCT_TX_CTL (0xC4) 15462306a36Sopenharmony_ci#define FCT_TX_CTL_EN_(channel) BIT(28 + (channel)) 15562306a36Sopenharmony_ci#define FCT_TX_CTL_DIS_(channel) BIT(24 + (channel)) 15662306a36Sopenharmony_ci#define FCT_TX_CTL_RESET_(channel) BIT(20 + (channel)) 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci#define FCT_FLOW(rx_channel) (0xE0 + ((rx_channel) << 2)) 15962306a36Sopenharmony_ci#define FCT_FLOW_CTL_OFF_THRESHOLD_ (0x00007F00) 16062306a36Sopenharmony_ci#define FCT_FLOW_CTL_OFF_THRESHOLD_SET_(value) \ 16162306a36Sopenharmony_ci ((value << 8) & FCT_FLOW_CTL_OFF_THRESHOLD_) 16262306a36Sopenharmony_ci#define FCT_FLOW_CTL_REQ_EN_ BIT(7) 16362306a36Sopenharmony_ci#define FCT_FLOW_CTL_ON_THRESHOLD_ (0x0000007F) 16462306a36Sopenharmony_ci#define FCT_FLOW_CTL_ON_THRESHOLD_SET_(value) \ 16562306a36Sopenharmony_ci ((value << 0) & FCT_FLOW_CTL_ON_THRESHOLD_) 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci#define MAC_CR (0x100) 16862306a36Sopenharmony_ci#define MAC_CR_MII_EN_ BIT(19) 16962306a36Sopenharmony_ci#define MAC_CR_EEE_EN_ BIT(17) 17062306a36Sopenharmony_ci#define MAC_CR_ADD_ BIT(12) 17162306a36Sopenharmony_ci#define MAC_CR_ASD_ BIT(11) 17262306a36Sopenharmony_ci#define MAC_CR_CNTR_RST_ BIT(5) 17362306a36Sopenharmony_ci#define MAC_CR_DPX_ BIT(3) 17462306a36Sopenharmony_ci#define MAC_CR_CFG_H_ BIT(2) 17562306a36Sopenharmony_ci#define MAC_CR_CFG_L_ BIT(1) 17662306a36Sopenharmony_ci#define MAC_CR_RST_ BIT(0) 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci#define MAC_RX (0x104) 17962306a36Sopenharmony_ci#define MAC_RX_MAX_SIZE_SHIFT_ (16) 18062306a36Sopenharmony_ci#define MAC_RX_MAX_SIZE_MASK_ (0x3FFF0000) 18162306a36Sopenharmony_ci#define MAC_RX_RXD_ BIT(1) 18262306a36Sopenharmony_ci#define MAC_RX_RXEN_ BIT(0) 18362306a36Sopenharmony_ci 18462306a36Sopenharmony_ci#define MAC_TX (0x108) 18562306a36Sopenharmony_ci#define MAC_TX_TXD_ BIT(1) 18662306a36Sopenharmony_ci#define MAC_TX_TXEN_ BIT(0) 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci#define MAC_FLOW (0x10C) 18962306a36Sopenharmony_ci#define MAC_FLOW_CR_TX_FCEN_ BIT(30) 19062306a36Sopenharmony_ci#define MAC_FLOW_CR_RX_FCEN_ BIT(29) 19162306a36Sopenharmony_ci#define MAC_FLOW_CR_FCPT_MASK_ (0x0000FFFF) 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci#define MAC_RX_ADDRH (0x118) 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci#define MAC_RX_ADDRL (0x11C) 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci#define MAC_MII_ACC (0x120) 19862306a36Sopenharmony_ci#define MAC_MII_ACC_MDC_CYCLE_SHIFT_ (16) 19962306a36Sopenharmony_ci#define MAC_MII_ACC_MDC_CYCLE_MASK_ (0x00070000) 20062306a36Sopenharmony_ci#define MAC_MII_ACC_MDC_CYCLE_2_5MHZ_ (0) 20162306a36Sopenharmony_ci#define MAC_MII_ACC_MDC_CYCLE_5MHZ_ (1) 20262306a36Sopenharmony_ci#define MAC_MII_ACC_MDC_CYCLE_12_5MHZ_ (2) 20362306a36Sopenharmony_ci#define MAC_MII_ACC_MDC_CYCLE_25MHZ_ (3) 20462306a36Sopenharmony_ci#define MAC_MII_ACC_MDC_CYCLE_1_25MHZ_ (4) 20562306a36Sopenharmony_ci#define MAC_MII_ACC_PHY_ADDR_SHIFT_ (11) 20662306a36Sopenharmony_ci#define MAC_MII_ACC_PHY_ADDR_MASK_ (0x0000F800) 20762306a36Sopenharmony_ci#define MAC_MII_ACC_MIIRINDA_SHIFT_ (6) 20862306a36Sopenharmony_ci#define MAC_MII_ACC_MIIRINDA_MASK_ (0x000007C0) 20962306a36Sopenharmony_ci#define MAC_MII_ACC_MII_READ_ (0x00000000) 21062306a36Sopenharmony_ci#define MAC_MII_ACC_MII_WRITE_ (0x00000002) 21162306a36Sopenharmony_ci#define MAC_MII_ACC_MII_BUSY_ BIT(0) 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci#define MAC_MII_ACC_MIIMMD_SHIFT_ (6) 21462306a36Sopenharmony_ci#define MAC_MII_ACC_MIIMMD_MASK_ (0x000007C0) 21562306a36Sopenharmony_ci#define MAC_MII_ACC_MIICL45_ BIT(3) 21662306a36Sopenharmony_ci#define MAC_MII_ACC_MIICMD_MASK_ (0x00000006) 21762306a36Sopenharmony_ci#define MAC_MII_ACC_MIICMD_ADDR_ (0x00000000) 21862306a36Sopenharmony_ci#define MAC_MII_ACC_MIICMD_WRITE_ (0x00000002) 21962306a36Sopenharmony_ci#define MAC_MII_ACC_MIICMD_READ_ (0x00000004) 22062306a36Sopenharmony_ci#define MAC_MII_ACC_MIICMD_READ_INC_ (0x00000006) 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci#define MAC_MII_DATA (0x124) 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci#define MAC_EEE_TX_LPI_REQ_DLY_CNT (0x130) 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci#define MAC_WUCSR (0x140) 22762306a36Sopenharmony_ci#define MAC_MP_SO_EN_ BIT(21) 22862306a36Sopenharmony_ci#define MAC_WUCSR_RFE_WAKE_EN_ BIT(14) 22962306a36Sopenharmony_ci#define MAC_WUCSR_PFDA_EN_ BIT(3) 23062306a36Sopenharmony_ci#define MAC_WUCSR_WAKE_EN_ BIT(2) 23162306a36Sopenharmony_ci#define MAC_WUCSR_MPEN_ BIT(1) 23262306a36Sopenharmony_ci#define MAC_WUCSR_BCST_EN_ BIT(0) 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci#define MAC_WK_SRC (0x144) 23562306a36Sopenharmony_ci#define MAC_MP_SO_HI (0x148) 23662306a36Sopenharmony_ci#define MAC_MP_SO_LO (0x14C) 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_ci#define MAC_WUF_CFG0 (0x150) 23962306a36Sopenharmony_ci#define MAC_NUM_OF_WUF_CFG (32) 24062306a36Sopenharmony_ci#define MAC_WUF_CFG_BEGIN (MAC_WUF_CFG0) 24162306a36Sopenharmony_ci#define MAC_WUF_CFG(index) (MAC_WUF_CFG_BEGIN + (4 * (index))) 24262306a36Sopenharmony_ci#define MAC_WUF_CFG_EN_ BIT(31) 24362306a36Sopenharmony_ci#define MAC_WUF_CFG_TYPE_MCAST_ (0x02000000) 24462306a36Sopenharmony_ci#define MAC_WUF_CFG_TYPE_ALL_ (0x01000000) 24562306a36Sopenharmony_ci#define MAC_WUF_CFG_OFFSET_SHIFT_ (16) 24662306a36Sopenharmony_ci#define MAC_WUF_CFG_CRC16_MASK_ (0x0000FFFF) 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_ci#define MAC_WUF_MASK0_0 (0x200) 24962306a36Sopenharmony_ci#define MAC_WUF_MASK0_1 (0x204) 25062306a36Sopenharmony_ci#define MAC_WUF_MASK0_2 (0x208) 25162306a36Sopenharmony_ci#define MAC_WUF_MASK0_3 (0x20C) 25262306a36Sopenharmony_ci#define MAC_WUF_MASK0_BEGIN (MAC_WUF_MASK0_0) 25362306a36Sopenharmony_ci#define MAC_WUF_MASK1_BEGIN (MAC_WUF_MASK0_1) 25462306a36Sopenharmony_ci#define MAC_WUF_MASK2_BEGIN (MAC_WUF_MASK0_2) 25562306a36Sopenharmony_ci#define MAC_WUF_MASK3_BEGIN (MAC_WUF_MASK0_3) 25662306a36Sopenharmony_ci#define MAC_WUF_MASK0(index) (MAC_WUF_MASK0_BEGIN + (0x10 * (index))) 25762306a36Sopenharmony_ci#define MAC_WUF_MASK1(index) (MAC_WUF_MASK1_BEGIN + (0x10 * (index))) 25862306a36Sopenharmony_ci#define MAC_WUF_MASK2(index) (MAC_WUF_MASK2_BEGIN + (0x10 * (index))) 25962306a36Sopenharmony_ci#define MAC_WUF_MASK3(index) (MAC_WUF_MASK3_BEGIN + (0x10 * (index))) 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_ci/* offset 0x400 - 0x500, x may range from 0 to 32, for a total of 33 entries */ 26262306a36Sopenharmony_ci#define RFE_ADDR_FILT_HI(x) (0x400 + (8 * (x))) 26362306a36Sopenharmony_ci#define RFE_ADDR_FILT_HI_VALID_ BIT(31) 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci/* offset 0x404 - 0x504, x may range from 0 to 32, for a total of 33 entries */ 26662306a36Sopenharmony_ci#define RFE_ADDR_FILT_LO(x) (0x404 + (8 * (x))) 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_ci#define RFE_CTL (0x508) 26962306a36Sopenharmony_ci#define RFE_CTL_TCP_UDP_COE_ BIT(12) 27062306a36Sopenharmony_ci#define RFE_CTL_IP_COE_ BIT(11) 27162306a36Sopenharmony_ci#define RFE_CTL_AB_ BIT(10) 27262306a36Sopenharmony_ci#define RFE_CTL_AM_ BIT(9) 27362306a36Sopenharmony_ci#define RFE_CTL_AU_ BIT(8) 27462306a36Sopenharmony_ci#define RFE_CTL_MCAST_HASH_ BIT(3) 27562306a36Sopenharmony_ci#define RFE_CTL_DA_PERFECT_ BIT(1) 27662306a36Sopenharmony_ci 27762306a36Sopenharmony_ci#define RFE_RSS_CFG (0x554) 27862306a36Sopenharmony_ci#define RFE_RSS_CFG_UDP_IPV6_EX_ BIT(16) 27962306a36Sopenharmony_ci#define RFE_RSS_CFG_TCP_IPV6_EX_ BIT(15) 28062306a36Sopenharmony_ci#define RFE_RSS_CFG_IPV6_EX_ BIT(14) 28162306a36Sopenharmony_ci#define RFE_RSS_CFG_UDP_IPV6_ BIT(13) 28262306a36Sopenharmony_ci#define RFE_RSS_CFG_TCP_IPV6_ BIT(12) 28362306a36Sopenharmony_ci#define RFE_RSS_CFG_IPV6_ BIT(11) 28462306a36Sopenharmony_ci#define RFE_RSS_CFG_UDP_IPV4_ BIT(10) 28562306a36Sopenharmony_ci#define RFE_RSS_CFG_TCP_IPV4_ BIT(9) 28662306a36Sopenharmony_ci#define RFE_RSS_CFG_IPV4_ BIT(8) 28762306a36Sopenharmony_ci#define RFE_RSS_CFG_VALID_HASH_BITS_ (0x000000E0) 28862306a36Sopenharmony_ci#define RFE_RSS_CFG_RSS_QUEUE_ENABLE_ BIT(2) 28962306a36Sopenharmony_ci#define RFE_RSS_CFG_RSS_HASH_STORE_ BIT(1) 29062306a36Sopenharmony_ci#define RFE_RSS_CFG_RSS_ENABLE_ BIT(0) 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_ci#define RFE_HASH_KEY(index) (0x558 + (index << 2)) 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_ci#define RFE_INDX(index) (0x580 + (index << 2)) 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci#define MAC_WUCSR2 (0x600) 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci#define SGMII_ACC (0x720) 29962306a36Sopenharmony_ci#define SGMII_ACC_SGMII_BZY_ BIT(31) 30062306a36Sopenharmony_ci#define SGMII_ACC_SGMII_WR_ BIT(30) 30162306a36Sopenharmony_ci#define SGMII_ACC_SGMII_MMD_SHIFT_ (16) 30262306a36Sopenharmony_ci#define SGMII_ACC_SGMII_MMD_MASK_ GENMASK(20, 16) 30362306a36Sopenharmony_ci#define SGMII_ACC_SGMII_MMD_VSR_ BIT(15) 30462306a36Sopenharmony_ci#define SGMII_ACC_SGMII_ADDR_SHIFT_ (0) 30562306a36Sopenharmony_ci#define SGMII_ACC_SGMII_ADDR_MASK_ GENMASK(15, 0) 30662306a36Sopenharmony_ci#define SGMII_DATA (0x724) 30762306a36Sopenharmony_ci#define SGMII_DATA_SHIFT_ (0) 30862306a36Sopenharmony_ci#define SGMII_DATA_MASK_ GENMASK(15, 0) 30962306a36Sopenharmony_ci#define SGMII_CTL (0x728) 31062306a36Sopenharmony_ci#define SGMII_CTL_SGMII_ENABLE_ BIT(31) 31162306a36Sopenharmony_ci#define SGMII_CTL_LINK_STATUS_SOURCE_ BIT(8) 31262306a36Sopenharmony_ci#define SGMII_CTL_SGMII_POWER_DN_ BIT(1) 31362306a36Sopenharmony_ci 31462306a36Sopenharmony_ci/* Vendor Specific SGMII MMD details */ 31562306a36Sopenharmony_ci#define SR_VSMMD_PCS_ID1 0x0004 31662306a36Sopenharmony_ci#define SR_VSMMD_PCS_ID2 0x0005 31762306a36Sopenharmony_ci#define SR_VSMMD_STS 0x0008 31862306a36Sopenharmony_ci#define SR_VSMMD_CTRL 0x0009 31962306a36Sopenharmony_ci 32062306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1 0x8000 32162306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_VR_RST_ BIT(15) 32262306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_R2TLBE_ BIT(14) 32362306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_EN_VSMMD1_ BIT(13) 32462306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_CS_EN_ BIT(10) 32562306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_MAC_AUTO_SW_ BIT(9) 32662306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_INIT_ BIT(8) 32762306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_DTXLANED_0_ BIT(4) 32862306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_CL37_TMR_OVR_RIDE_ BIT(3) 32962306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_EN_2_5G_MODE_ BIT(2) 33062306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_BYP_PWRUP_ BIT(1) 33162306a36Sopenharmony_ci#define VR_MII_DIG_CTRL1_PHY_MODE_CTRL_ BIT(0) 33262306a36Sopenharmony_ci#define VR_MII_AN_CTRL 0x8001 33362306a36Sopenharmony_ci#define VR_MII_AN_CTRL_MII_CTRL_ BIT(8) 33462306a36Sopenharmony_ci#define VR_MII_AN_CTRL_SGMII_LINK_STS_ BIT(4) 33562306a36Sopenharmony_ci#define VR_MII_AN_CTRL_TX_CONFIG_ BIT(3) 33662306a36Sopenharmony_ci#define VR_MII_AN_CTRL_1000BASE_X_ (0) 33762306a36Sopenharmony_ci#define VR_MII_AN_CTRL_SGMII_MODE_ (2) 33862306a36Sopenharmony_ci#define VR_MII_AN_CTRL_QSGMII_MODE_ (3) 33962306a36Sopenharmony_ci#define VR_MII_AN_CTRL_PCS_MODE_SHIFT_ (1) 34062306a36Sopenharmony_ci#define VR_MII_AN_CTRL_PCS_MODE_MASK_ GENMASK(2, 1) 34162306a36Sopenharmony_ci#define VR_MII_AN_CTRL_MII_AN_INTR_EN_ BIT(0) 34262306a36Sopenharmony_ci#define VR_MII_AN_INTR_STS 0x8002 34362306a36Sopenharmony_ci#define VR_MII_AN_INTR_STS_LINK_UP_ BIT(4) 34462306a36Sopenharmony_ci#define VR_MII_AN_INTR_STS_SPEED_MASK_ GENMASK(3, 2) 34562306a36Sopenharmony_ci#define VR_MII_AN_INTR_STS_1000_MBPS_ BIT(3) 34662306a36Sopenharmony_ci#define VR_MII_AN_INTR_STS_100_MBPS_ BIT(2) 34762306a36Sopenharmony_ci#define VR_MII_AN_INTR_STS_10_MBPS_ (0) 34862306a36Sopenharmony_ci#define VR_MII_AN_INTR_STS_FDX_ BIT(1) 34962306a36Sopenharmony_ci#define VR_MII_AN_INTR_STS_CL37_ANCMPLT_INTR_ BIT(0) 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ci#define VR_MII_LINK_TIMER_CTRL 0x800A 35262306a36Sopenharmony_ci#define VR_MII_DIG_STS 0x8010 35362306a36Sopenharmony_ci#define VR_MII_DIG_STS_PSEQ_STATE_MASK_ GENMASK(4, 2) 35462306a36Sopenharmony_ci#define VR_MII_DIG_STS_PSEQ_STATE_POS_ (2) 35562306a36Sopenharmony_ci#define VR_MII_GEN2_4_MPLL_CTRL0 0x8078 35662306a36Sopenharmony_ci#define VR_MII_MPLL_CTRL0_REF_CLK_DIV2_ BIT(12) 35762306a36Sopenharmony_ci#define VR_MII_MPLL_CTRL0_USE_REFCLK_PAD_ BIT(4) 35862306a36Sopenharmony_ci#define VR_MII_GEN2_4_MPLL_CTRL1 0x8079 35962306a36Sopenharmony_ci#define VR_MII_MPLL_CTRL1_MPLL_MULTIPLIER_ GENMASK(6, 0) 36062306a36Sopenharmony_ci#define VR_MII_BAUD_RATE_3P125GBPS (3125) 36162306a36Sopenharmony_ci#define VR_MII_BAUD_RATE_1P25GBPS (1250) 36262306a36Sopenharmony_ci#define VR_MII_MPLL_MULTIPLIER_125 (125) 36362306a36Sopenharmony_ci#define VR_MII_MPLL_MULTIPLIER_100 (100) 36462306a36Sopenharmony_ci#define VR_MII_MPLL_MULTIPLIER_50 (50) 36562306a36Sopenharmony_ci#define VR_MII_MPLL_MULTIPLIER_40 (40) 36662306a36Sopenharmony_ci#define VR_MII_GEN2_4_MISC_CTRL1 0x809A 36762306a36Sopenharmony_ci#define VR_MII_CTRL1_RX_RATE_0_MASK_ GENMASK(3, 2) 36862306a36Sopenharmony_ci#define VR_MII_CTRL1_RX_RATE_0_SHIFT_ (2) 36962306a36Sopenharmony_ci#define VR_MII_CTRL1_TX_RATE_0_MASK_ GENMASK(1, 0) 37062306a36Sopenharmony_ci#define VR_MII_MPLL_BAUD_CLK (0) 37162306a36Sopenharmony_ci#define VR_MII_MPLL_BAUD_CLK_DIV_2 (1) 37262306a36Sopenharmony_ci#define VR_MII_MPLL_BAUD_CLK_DIV_4 (2) 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci#define INT_STS (0x780) 37562306a36Sopenharmony_ci#define INT_BIT_DMA_RX_(channel) BIT(24 + (channel)) 37662306a36Sopenharmony_ci#define INT_BIT_ALL_RX_ (0x0F000000) 37762306a36Sopenharmony_ci#define INT_BIT_DMA_TX_(channel) BIT(16 + (channel)) 37862306a36Sopenharmony_ci#define INT_BIT_ALL_TX_ (0x000F0000) 37962306a36Sopenharmony_ci#define INT_BIT_SW_GP_ BIT(9) 38062306a36Sopenharmony_ci#define INT_BIT_1588_ BIT(7) 38162306a36Sopenharmony_ci#define INT_BIT_ALL_OTHER_ (INT_BIT_SW_GP_ | INT_BIT_1588_) 38262306a36Sopenharmony_ci#define INT_BIT_MAS_ BIT(0) 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci#define INT_SET (0x784) 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ci#define INT_EN_SET (0x788) 38762306a36Sopenharmony_ci 38862306a36Sopenharmony_ci#define INT_EN_CLR (0x78C) 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci#define INT_STS_R2C (0x790) 39162306a36Sopenharmony_ci 39262306a36Sopenharmony_ci#define INT_VEC_EN_SET (0x794) 39362306a36Sopenharmony_ci#define INT_VEC_EN_CLR (0x798) 39462306a36Sopenharmony_ci#define INT_VEC_EN_AUTO_CLR (0x79C) 39562306a36Sopenharmony_ci#define INT_VEC_EN_(vector_index) BIT(0 + vector_index) 39662306a36Sopenharmony_ci 39762306a36Sopenharmony_ci#define INT_VEC_MAP0 (0x7A0) 39862306a36Sopenharmony_ci#define INT_VEC_MAP0_RX_VEC_(channel, vector) \ 39962306a36Sopenharmony_ci (((u32)(vector)) << ((channel) << 2)) 40062306a36Sopenharmony_ci 40162306a36Sopenharmony_ci#define INT_VEC_MAP1 (0x7A4) 40262306a36Sopenharmony_ci#define INT_VEC_MAP1_TX_VEC_(channel, vector) \ 40362306a36Sopenharmony_ci (((u32)(vector)) << ((channel) << 2)) 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci#define INT_VEC_MAP2 (0x7A8) 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci#define INT_MOD_MAP0 (0x7B0) 40862306a36Sopenharmony_ci 40962306a36Sopenharmony_ci#define INT_MOD_MAP1 (0x7B4) 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci#define INT_MOD_MAP2 (0x7B8) 41262306a36Sopenharmony_ci 41362306a36Sopenharmony_ci#define INT_MOD_CFG0 (0x7C0) 41462306a36Sopenharmony_ci#define INT_MOD_CFG1 (0x7C4) 41562306a36Sopenharmony_ci#define INT_MOD_CFG2 (0x7C8) 41662306a36Sopenharmony_ci#define INT_MOD_CFG3 (0x7CC) 41762306a36Sopenharmony_ci#define INT_MOD_CFG4 (0x7D0) 41862306a36Sopenharmony_ci#define INT_MOD_CFG5 (0x7D4) 41962306a36Sopenharmony_ci#define INT_MOD_CFG6 (0x7D8) 42062306a36Sopenharmony_ci#define INT_MOD_CFG7 (0x7DC) 42162306a36Sopenharmony_ci#define INT_MOD_CFG8 (0x7E0) 42262306a36Sopenharmony_ci#define INT_MOD_CFG9 (0x7E4) 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ci#define PTP_CMD_CTL (0x0A00) 42562306a36Sopenharmony_ci#define PTP_CMD_CTL_PTP_LTC_TARGET_READ_ BIT(13) 42662306a36Sopenharmony_ci#define PTP_CMD_CTL_PTP_CLK_STP_NSEC_ BIT(6) 42762306a36Sopenharmony_ci#define PTP_CMD_CTL_PTP_CLOCK_STEP_SEC_ BIT(5) 42862306a36Sopenharmony_ci#define PTP_CMD_CTL_PTP_CLOCK_LOAD_ BIT(4) 42962306a36Sopenharmony_ci#define PTP_CMD_CTL_PTP_CLOCK_READ_ BIT(3) 43062306a36Sopenharmony_ci#define PTP_CMD_CTL_PTP_ENABLE_ BIT(2) 43162306a36Sopenharmony_ci#define PTP_CMD_CTL_PTP_DISABLE_ BIT(1) 43262306a36Sopenharmony_ci#define PTP_CMD_CTL_PTP_RESET_ BIT(0) 43362306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG (0x0A04) 43462306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_X_MASK_(channel) \ 43562306a36Sopenharmony_ci (0x7 << (1 + ((channel) << 2))) 43662306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_100NS_ (0) 43762306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_10US_ (1) 43862306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_100US_ (2) 43962306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_1MS_ (3) 44062306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_10MS_ (4) 44162306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_200MS_ (5) 44262306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_TOGGLE_ (6) 44362306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_CLOCK_EVENT_X_SET_(channel, value) \ 44462306a36Sopenharmony_ci (((value) & 0x7) << (1 + ((channel) << 2))) 44562306a36Sopenharmony_ci#define PTP_GENERAL_CONFIG_RELOAD_ADD_X_(channel) (BIT((channel) << 2)) 44662306a36Sopenharmony_ci 44762306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG (0x0A04) 44862306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_X_MASK_(channel) \ 44962306a36Sopenharmony_ci (0xf << (4 + ((channel) << 2))) 45062306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_100NS_ (0) 45162306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_500NS_ (1) 45262306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_1US_ (2) 45362306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_5US_ (3) 45462306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_10US_ (4) 45562306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_50US_ (5) 45662306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_100US_ (6) 45762306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_500US_ (7) 45862306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_1MS_ (8) 45962306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_5MS_ (9) 46062306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_10MS_ (10) 46162306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_50MS_ (11) 46262306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_100MS_ (12) 46362306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_200MS_ (13) 46462306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_TOGG_ (14) 46562306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_INT_ (15) 46662306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_CLOCK_EVENT_X_SET_(channel, value) \ 46762306a36Sopenharmony_ci (((value) & 0xf) << (4 + ((channel) << 2))) 46862306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_EVENT_POL_X_(channel) (BIT(1 + ((channel) * 2))) 46962306a36Sopenharmony_ci#define HS_PTP_GENERAL_CONFIG_RELOAD_ADD_X_(channel) (BIT((channel) * 2)) 47062306a36Sopenharmony_ci 47162306a36Sopenharmony_ci#define PTP_INT_STS (0x0A08) 47262306a36Sopenharmony_ci#define PTP_INT_IO_FE_MASK_ GENMASK(31, 24) 47362306a36Sopenharmony_ci#define PTP_INT_IO_FE_SHIFT_ (24) 47462306a36Sopenharmony_ci#define PTP_INT_IO_FE_SET_(channel) BIT(24 + (channel)) 47562306a36Sopenharmony_ci#define PTP_INT_IO_RE_MASK_ GENMASK(23, 16) 47662306a36Sopenharmony_ci#define PTP_INT_IO_RE_SHIFT_ (16) 47762306a36Sopenharmony_ci#define PTP_INT_IO_RE_SET_(channel) BIT(16 + (channel)) 47862306a36Sopenharmony_ci#define PTP_INT_TX_TS_OVRFL_INT_ BIT(14) 47962306a36Sopenharmony_ci#define PTP_INT_TX_SWTS_ERR_INT_ BIT(13) 48062306a36Sopenharmony_ci#define PTP_INT_TX_TS_INT_ BIT(12) 48162306a36Sopenharmony_ci#define PTP_INT_RX_TS_OVRFL_INT_ BIT(9) 48262306a36Sopenharmony_ci#define PTP_INT_RX_TS_INT_ BIT(8) 48362306a36Sopenharmony_ci#define PTP_INT_TIMER_INT_B_ BIT(1) 48462306a36Sopenharmony_ci#define PTP_INT_TIMER_INT_A_ BIT(0) 48562306a36Sopenharmony_ci#define PTP_INT_EN_SET (0x0A0C) 48662306a36Sopenharmony_ci#define PTP_INT_EN_FE_EN_SET_(channel) BIT(24 + (channel)) 48762306a36Sopenharmony_ci#define PTP_INT_EN_RE_EN_SET_(channel) BIT(16 + (channel)) 48862306a36Sopenharmony_ci#define PTP_INT_EN_TIMER_SET_(channel) BIT(channel) 48962306a36Sopenharmony_ci#define PTP_INT_EN_CLR (0x0A10) 49062306a36Sopenharmony_ci#define PTP_INT_EN_FE_EN_CLR_(channel) BIT(24 + (channel)) 49162306a36Sopenharmony_ci#define PTP_INT_EN_RE_EN_CLR_(channel) BIT(16 + (channel)) 49262306a36Sopenharmony_ci#define PTP_INT_BIT_TX_SWTS_ERR_ BIT(13) 49362306a36Sopenharmony_ci#define PTP_INT_BIT_TX_TS_ BIT(12) 49462306a36Sopenharmony_ci#define PTP_INT_BIT_TIMER_B_ BIT(1) 49562306a36Sopenharmony_ci#define PTP_INT_BIT_TIMER_A_ BIT(0) 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci#define PTP_CLOCK_SEC (0x0A14) 49862306a36Sopenharmony_ci#define PTP_CLOCK_NS (0x0A18) 49962306a36Sopenharmony_ci#define PTP_CLOCK_SUBNS (0x0A1C) 50062306a36Sopenharmony_ci#define PTP_CLOCK_RATE_ADJ (0x0A20) 50162306a36Sopenharmony_ci#define PTP_CLOCK_RATE_ADJ_DIR_ BIT(31) 50262306a36Sopenharmony_ci#define PTP_CLOCK_STEP_ADJ (0x0A2C) 50362306a36Sopenharmony_ci#define PTP_CLOCK_STEP_ADJ_DIR_ BIT(31) 50462306a36Sopenharmony_ci#define PTP_CLOCK_STEP_ADJ_VALUE_MASK_ (0x3FFFFFFF) 50562306a36Sopenharmony_ci#define PTP_CLOCK_TARGET_SEC_X(channel) (0x0A30 + ((channel) << 4)) 50662306a36Sopenharmony_ci#define PTP_CLOCK_TARGET_NS_X(channel) (0x0A34 + ((channel) << 4)) 50762306a36Sopenharmony_ci#define PTP_CLOCK_TARGET_RELOAD_SEC_X(channel) (0x0A38 + ((channel) << 4)) 50862306a36Sopenharmony_ci#define PTP_CLOCK_TARGET_RELOAD_NS_X(channel) (0x0A3C + ((channel) << 4)) 50962306a36Sopenharmony_ci#define PTP_LTC_SET_SEC_HI (0x0A50) 51062306a36Sopenharmony_ci#define PTP_LTC_SET_SEC_HI_SEC_47_32_MASK_ GENMASK(15, 0) 51162306a36Sopenharmony_ci#define PTP_VERSION (0x0A54) 51262306a36Sopenharmony_ci#define PTP_VERSION_TX_UP_MASK_ GENMASK(31, 24) 51362306a36Sopenharmony_ci#define PTP_VERSION_TX_LO_MASK_ GENMASK(23, 16) 51462306a36Sopenharmony_ci#define PTP_VERSION_RX_UP_MASK_ GENMASK(15, 8) 51562306a36Sopenharmony_ci#define PTP_VERSION_RX_LO_MASK_ GENMASK(7, 0) 51662306a36Sopenharmony_ci#define PTP_IO_SEL (0x0A58) 51762306a36Sopenharmony_ci#define PTP_IO_SEL_MASK_ GENMASK(10, 8) 51862306a36Sopenharmony_ci#define PTP_IO_SEL_SHIFT_ (8) 51962306a36Sopenharmony_ci#define PTP_LATENCY (0x0A5C) 52062306a36Sopenharmony_ci#define PTP_LATENCY_TX_SET_(tx_latency) (((u32)(tx_latency)) << 16) 52162306a36Sopenharmony_ci#define PTP_LATENCY_RX_SET_(rx_latency) \ 52262306a36Sopenharmony_ci (((u32)(rx_latency)) & 0x0000FFFF) 52362306a36Sopenharmony_ci#define PTP_CAP_INFO (0x0A60) 52462306a36Sopenharmony_ci#define PTP_CAP_INFO_TX_TS_CNT_GET_(reg_val) (((reg_val) & 0x00000070) >> 4) 52562306a36Sopenharmony_ci 52662306a36Sopenharmony_ci#define PTP_TX_MOD (0x0AA4) 52762306a36Sopenharmony_ci#define PTP_TX_MOD_TX_PTP_SYNC_TS_INSERT_ (0x10000000) 52862306a36Sopenharmony_ci 52962306a36Sopenharmony_ci#define PTP_TX_MOD2 (0x0AA8) 53062306a36Sopenharmony_ci#define PTP_TX_MOD2_TX_PTP_CLR_UDPV4_CHKSUM_ (0x00000001) 53162306a36Sopenharmony_ci 53262306a36Sopenharmony_ci#define PTP_TX_EGRESS_SEC (0x0AAC) 53362306a36Sopenharmony_ci#define PTP_TX_EGRESS_NS (0x0AB0) 53462306a36Sopenharmony_ci#define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_MASK_ (0xC0000000) 53562306a36Sopenharmony_ci#define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_AUTO_ (0x00000000) 53662306a36Sopenharmony_ci#define PTP_TX_EGRESS_NS_CAPTURE_CAUSE_SW_ (0x40000000) 53762306a36Sopenharmony_ci#define PTP_TX_EGRESS_NS_TS_NS_MASK_ (0x3FFFFFFF) 53862306a36Sopenharmony_ci 53962306a36Sopenharmony_ci#define PTP_TX_MSG_HEADER (0x0AB4) 54062306a36Sopenharmony_ci#define PTP_TX_MSG_HEADER_MSG_TYPE_ (0x000F0000) 54162306a36Sopenharmony_ci#define PTP_TX_MSG_HEADER_MSG_TYPE_SYNC_ (0x00000000) 54262306a36Sopenharmony_ci 54362306a36Sopenharmony_ci#define PTP_TX_CAP_INFO (0x0AB8) 54462306a36Sopenharmony_ci#define PTP_TX_CAP_INFO_TX_CH_MASK_ GENMASK(1, 0) 54562306a36Sopenharmony_ci#define PTP_TX_DOMAIN (0x0ABC) 54662306a36Sopenharmony_ci#define PTP_TX_DOMAIN_MASK_ GENMASK(23, 16) 54762306a36Sopenharmony_ci#define PTP_TX_DOMAIN_RANGE_EN_ BIT(15) 54862306a36Sopenharmony_ci#define PTP_TX_DOMAIN_RANGE_MASK_ GENMASK(7, 0) 54962306a36Sopenharmony_ci#define PTP_TX_SDOID (0x0AC0) 55062306a36Sopenharmony_ci#define PTP_TX_SDOID_MASK_ GENMASK(23, 16) 55162306a36Sopenharmony_ci#define PTP_TX_SDOID_RANGE_EN_ BIT(15) 55262306a36Sopenharmony_ci#define PTP_TX_SDOID_11_0_MASK_ GENMASK(7, 0) 55362306a36Sopenharmony_ci#define PTP_IO_CAP_CONFIG (0x0AC4) 55462306a36Sopenharmony_ci#define PTP_IO_CAP_CONFIG_LOCK_FE_(channel) BIT(24 + (channel)) 55562306a36Sopenharmony_ci#define PTP_IO_CAP_CONFIG_LOCK_RE_(channel) BIT(16 + (channel)) 55662306a36Sopenharmony_ci#define PTP_IO_CAP_CONFIG_FE_CAP_EN_(channel) BIT(8 + (channel)) 55762306a36Sopenharmony_ci#define PTP_IO_CAP_CONFIG_RE_CAP_EN_(channel) BIT(0 + (channel)) 55862306a36Sopenharmony_ci#define PTP_IO_RE_LTC_SEC_CAP_X (0x0AC8) 55962306a36Sopenharmony_ci#define PTP_IO_RE_LTC_NS_CAP_X (0x0ACC) 56062306a36Sopenharmony_ci#define PTP_IO_FE_LTC_SEC_CAP_X (0x0AD0) 56162306a36Sopenharmony_ci#define PTP_IO_FE_LTC_NS_CAP_X (0x0AD4) 56262306a36Sopenharmony_ci#define PTP_IO_EVENT_OUTPUT_CFG (0x0AD8) 56362306a36Sopenharmony_ci#define PTP_IO_EVENT_OUTPUT_CFG_SEL_(channel) BIT(16 + (channel)) 56462306a36Sopenharmony_ci#define PTP_IO_EVENT_OUTPUT_CFG_EN_(channel) BIT(0 + (channel)) 56562306a36Sopenharmony_ci#define PTP_IO_PIN_CFG (0x0ADC) 56662306a36Sopenharmony_ci#define PTP_IO_PIN_CFG_OBUF_TYPE_(channel) BIT(0 + (channel)) 56762306a36Sopenharmony_ci#define PTP_LTC_RD_SEC_HI (0x0AF0) 56862306a36Sopenharmony_ci#define PTP_LTC_RD_SEC_HI_SEC_47_32_MASK_ GENMASK(15, 0) 56962306a36Sopenharmony_ci#define PTP_LTC_RD_SEC_LO (0x0AF4) 57062306a36Sopenharmony_ci#define PTP_LTC_RD_NS (0x0AF8) 57162306a36Sopenharmony_ci#define PTP_LTC_RD_NS_29_0_MASK_ GENMASK(29, 0) 57262306a36Sopenharmony_ci#define PTP_LTC_RD_SUBNS (0x0AFC) 57362306a36Sopenharmony_ci#define PTP_RX_USER_MAC_HI (0x0B00) 57462306a36Sopenharmony_ci#define PTP_RX_USER_MAC_HI_47_32_MASK_ GENMASK(15, 0) 57562306a36Sopenharmony_ci#define PTP_RX_USER_MAC_LO (0x0B04) 57662306a36Sopenharmony_ci#define PTP_RX_USER_IP_ADDR_0 (0x0B20) 57762306a36Sopenharmony_ci#define PTP_RX_USER_IP_ADDR_1 (0x0B24) 57862306a36Sopenharmony_ci#define PTP_RX_USER_IP_ADDR_2 (0x0B28) 57962306a36Sopenharmony_ci#define PTP_RX_USER_IP_ADDR_3 (0x0B2C) 58062306a36Sopenharmony_ci#define PTP_RX_USER_IP_MASK_0 (0x0B30) 58162306a36Sopenharmony_ci#define PTP_RX_USER_IP_MASK_1 (0x0B34) 58262306a36Sopenharmony_ci#define PTP_RX_USER_IP_MASK_2 (0x0B38) 58362306a36Sopenharmony_ci#define PTP_RX_USER_IP_MASK_3 (0x0B3C) 58462306a36Sopenharmony_ci#define PTP_TX_USER_MAC_HI (0x0B40) 58562306a36Sopenharmony_ci#define PTP_TX_USER_MAC_HI_47_32_MASK_ GENMASK(15, 0) 58662306a36Sopenharmony_ci#define PTP_TX_USER_MAC_LO (0x0B44) 58762306a36Sopenharmony_ci#define PTP_TX_USER_IP_ADDR_0 (0x0B60) 58862306a36Sopenharmony_ci#define PTP_TX_USER_IP_ADDR_1 (0x0B64) 58962306a36Sopenharmony_ci#define PTP_TX_USER_IP_ADDR_2 (0x0B68) 59062306a36Sopenharmony_ci#define PTP_TX_USER_IP_ADDR_3 (0x0B6C) 59162306a36Sopenharmony_ci#define PTP_TX_USER_IP_MASK_0 (0x0B70) 59262306a36Sopenharmony_ci#define PTP_TX_USER_IP_MASK_1 (0x0B74) 59362306a36Sopenharmony_ci#define PTP_TX_USER_IP_MASK_2 (0x0B78) 59462306a36Sopenharmony_ci#define PTP_TX_USER_IP_MASK_3 (0x0B7C) 59562306a36Sopenharmony_ci 59662306a36Sopenharmony_ci#define DMAC_CFG (0xC00) 59762306a36Sopenharmony_ci#define DMAC_CFG_COAL_EN_ BIT(16) 59862306a36Sopenharmony_ci#define DMAC_CFG_CH_ARB_SEL_RX_HIGH_ (0x00000000) 59962306a36Sopenharmony_ci#define DMAC_CFG_MAX_READ_REQ_MASK_ (0x00000070) 60062306a36Sopenharmony_ci#define DMAC_CFG_MAX_READ_REQ_SET_(val) \ 60162306a36Sopenharmony_ci ((((u32)(val)) << 4) & DMAC_CFG_MAX_READ_REQ_MASK_) 60262306a36Sopenharmony_ci#define DMAC_CFG_MAX_DSPACE_16_ (0x00000000) 60362306a36Sopenharmony_ci#define DMAC_CFG_MAX_DSPACE_32_ (0x00000001) 60462306a36Sopenharmony_ci#define DMAC_CFG_MAX_DSPACE_64_ BIT(1) 60562306a36Sopenharmony_ci#define DMAC_CFG_MAX_DSPACE_128_ (0x00000003) 60662306a36Sopenharmony_ci 60762306a36Sopenharmony_ci#define DMAC_COAL_CFG (0xC04) 60862306a36Sopenharmony_ci#define DMAC_COAL_CFG_TIMER_LIMIT_MASK_ (0xFFF00000) 60962306a36Sopenharmony_ci#define DMAC_COAL_CFG_TIMER_LIMIT_SET_(val) \ 61062306a36Sopenharmony_ci ((((u32)(val)) << 20) & DMAC_COAL_CFG_TIMER_LIMIT_MASK_) 61162306a36Sopenharmony_ci#define DMAC_COAL_CFG_TIMER_TX_START_ BIT(19) 61262306a36Sopenharmony_ci#define DMAC_COAL_CFG_FLUSH_INTS_ BIT(18) 61362306a36Sopenharmony_ci#define DMAC_COAL_CFG_INT_EXIT_COAL_ BIT(17) 61462306a36Sopenharmony_ci#define DMAC_COAL_CFG_CSR_EXIT_COAL_ BIT(16) 61562306a36Sopenharmony_ci#define DMAC_COAL_CFG_TX_THRES_MASK_ (0x0000FF00) 61662306a36Sopenharmony_ci#define DMAC_COAL_CFG_TX_THRES_SET_(val) \ 61762306a36Sopenharmony_ci ((((u32)(val)) << 8) & DMAC_COAL_CFG_TX_THRES_MASK_) 61862306a36Sopenharmony_ci#define DMAC_COAL_CFG_RX_THRES_MASK_ (0x000000FF) 61962306a36Sopenharmony_ci#define DMAC_COAL_CFG_RX_THRES_SET_(val) \ 62062306a36Sopenharmony_ci (((u32)(val)) & DMAC_COAL_CFG_RX_THRES_MASK_) 62162306a36Sopenharmony_ci 62262306a36Sopenharmony_ci#define DMAC_OBFF_CFG (0xC08) 62362306a36Sopenharmony_ci#define DMAC_OBFF_TX_THRES_MASK_ (0x0000FF00) 62462306a36Sopenharmony_ci#define DMAC_OBFF_TX_THRES_SET_(val) \ 62562306a36Sopenharmony_ci ((((u32)(val)) << 8) & DMAC_OBFF_TX_THRES_MASK_) 62662306a36Sopenharmony_ci#define DMAC_OBFF_RX_THRES_MASK_ (0x000000FF) 62762306a36Sopenharmony_ci#define DMAC_OBFF_RX_THRES_SET_(val) \ 62862306a36Sopenharmony_ci (((u32)(val)) & DMAC_OBFF_RX_THRES_MASK_) 62962306a36Sopenharmony_ci 63062306a36Sopenharmony_ci#define DMAC_CMD (0xC0C) 63162306a36Sopenharmony_ci#define DMAC_CMD_SWR_ BIT(31) 63262306a36Sopenharmony_ci#define DMAC_CMD_TX_SWR_(channel) BIT(24 + (channel)) 63362306a36Sopenharmony_ci#define DMAC_CMD_START_T_(channel) BIT(20 + (channel)) 63462306a36Sopenharmony_ci#define DMAC_CMD_STOP_T_(channel) BIT(16 + (channel)) 63562306a36Sopenharmony_ci#define DMAC_CMD_RX_SWR_(channel) BIT(8 + (channel)) 63662306a36Sopenharmony_ci#define DMAC_CMD_START_R_(channel) BIT(4 + (channel)) 63762306a36Sopenharmony_ci#define DMAC_CMD_STOP_R_(channel) BIT(0 + (channel)) 63862306a36Sopenharmony_ci 63962306a36Sopenharmony_ci#define DMAC_INT_STS (0xC10) 64062306a36Sopenharmony_ci#define DMAC_INT_EN_SET (0xC14) 64162306a36Sopenharmony_ci#define DMAC_INT_EN_CLR (0xC18) 64262306a36Sopenharmony_ci#define DMAC_INT_BIT_RXFRM_(channel) BIT(16 + (channel)) 64362306a36Sopenharmony_ci#define DMAC_INT_BIT_TX_IOC_(channel) BIT(0 + (channel)) 64462306a36Sopenharmony_ci 64562306a36Sopenharmony_ci#define RX_CFG_A(channel) (0xC40 + ((channel) << 6)) 64662306a36Sopenharmony_ci#define RX_CFG_A_RX_WB_ON_INT_TMR_ BIT(30) 64762306a36Sopenharmony_ci#define RX_CFG_A_RX_WB_THRES_MASK_ (0x1F000000) 64862306a36Sopenharmony_ci#define RX_CFG_A_RX_WB_THRES_SET_(val) \ 64962306a36Sopenharmony_ci ((((u32)(val)) << 24) & RX_CFG_A_RX_WB_THRES_MASK_) 65062306a36Sopenharmony_ci#define RX_CFG_A_RX_PF_THRES_MASK_ (0x001F0000) 65162306a36Sopenharmony_ci#define RX_CFG_A_RX_PF_THRES_SET_(val) \ 65262306a36Sopenharmony_ci ((((u32)(val)) << 16) & RX_CFG_A_RX_PF_THRES_MASK_) 65362306a36Sopenharmony_ci#define RX_CFG_A_RX_PF_PRI_THRES_MASK_ (0x00001F00) 65462306a36Sopenharmony_ci#define RX_CFG_A_RX_PF_PRI_THRES_SET_(val) \ 65562306a36Sopenharmony_ci ((((u32)(val)) << 8) & RX_CFG_A_RX_PF_PRI_THRES_MASK_) 65662306a36Sopenharmony_ci#define RX_CFG_A_RX_HP_WB_EN_ BIT(5) 65762306a36Sopenharmony_ci 65862306a36Sopenharmony_ci#define RX_CFG_B(channel) (0xC44 + ((channel) << 6)) 65962306a36Sopenharmony_ci#define RX_CFG_B_TS_ALL_RX_ BIT(29) 66062306a36Sopenharmony_ci#define RX_CFG_B_RX_PAD_MASK_ (0x03000000) 66162306a36Sopenharmony_ci#define RX_CFG_B_RX_PAD_0_ (0x00000000) 66262306a36Sopenharmony_ci#define RX_CFG_B_RX_PAD_2_ (0x02000000) 66362306a36Sopenharmony_ci#define RX_CFG_B_RDMABL_512_ (0x00040000) 66462306a36Sopenharmony_ci#define RX_CFG_B_RX_RING_LEN_MASK_ (0x0000FFFF) 66562306a36Sopenharmony_ci 66662306a36Sopenharmony_ci#define RX_BASE_ADDRH(channel) (0xC48 + ((channel) << 6)) 66762306a36Sopenharmony_ci 66862306a36Sopenharmony_ci#define RX_BASE_ADDRL(channel) (0xC4C + ((channel) << 6)) 66962306a36Sopenharmony_ci 67062306a36Sopenharmony_ci#define RX_HEAD_WRITEBACK_ADDRH(channel) (0xC50 + ((channel) << 6)) 67162306a36Sopenharmony_ci 67262306a36Sopenharmony_ci#define RX_HEAD_WRITEBACK_ADDRL(channel) (0xC54 + ((channel) << 6)) 67362306a36Sopenharmony_ci 67462306a36Sopenharmony_ci#define RX_HEAD(channel) (0xC58 + ((channel) << 6)) 67562306a36Sopenharmony_ci 67662306a36Sopenharmony_ci#define RX_TAIL(channel) (0xC5C + ((channel) << 6)) 67762306a36Sopenharmony_ci#define RX_TAIL_SET_TOP_INT_EN_ BIT(30) 67862306a36Sopenharmony_ci#define RX_TAIL_SET_TOP_INT_VEC_EN_ BIT(29) 67962306a36Sopenharmony_ci 68062306a36Sopenharmony_ci#define RX_CFG_C(channel) (0xC64 + ((channel) << 6)) 68162306a36Sopenharmony_ci#define RX_CFG_C_RX_TOP_INT_EN_AUTO_CLR_ BIT(6) 68262306a36Sopenharmony_ci#define RX_CFG_C_RX_INT_EN_R2C_ BIT(4) 68362306a36Sopenharmony_ci#define RX_CFG_C_RX_DMA_INT_STS_AUTO_CLR_ BIT(3) 68462306a36Sopenharmony_ci#define RX_CFG_C_RX_INT_STS_R2C_MODE_MASK_ (0x00000007) 68562306a36Sopenharmony_ci 68662306a36Sopenharmony_ci#define TX_CFG_A(channel) (0xD40 + ((channel) << 6)) 68762306a36Sopenharmony_ci#define TX_CFG_A_TX_HP_WB_ON_INT_TMR_ BIT(30) 68862306a36Sopenharmony_ci#define TX_CFG_A_TX_TMR_HPWB_SEL_IOC_ (0x10000000) 68962306a36Sopenharmony_ci#define TX_CFG_A_TX_PF_THRES_MASK_ (0x001F0000) 69062306a36Sopenharmony_ci#define TX_CFG_A_TX_PF_THRES_SET_(value) \ 69162306a36Sopenharmony_ci ((((u32)(value)) << 16) & TX_CFG_A_TX_PF_THRES_MASK_) 69262306a36Sopenharmony_ci#define TX_CFG_A_TX_PF_PRI_THRES_MASK_ (0x00001F00) 69362306a36Sopenharmony_ci#define TX_CFG_A_TX_PF_PRI_THRES_SET_(value) \ 69462306a36Sopenharmony_ci ((((u32)(value)) << 8) & TX_CFG_A_TX_PF_PRI_THRES_MASK_) 69562306a36Sopenharmony_ci#define TX_CFG_A_TX_HP_WB_EN_ BIT(5) 69662306a36Sopenharmony_ci#define TX_CFG_A_TX_HP_WB_THRES_MASK_ (0x0000000F) 69762306a36Sopenharmony_ci#define TX_CFG_A_TX_HP_WB_THRES_SET_(value) \ 69862306a36Sopenharmony_ci (((u32)(value)) & TX_CFG_A_TX_HP_WB_THRES_MASK_) 69962306a36Sopenharmony_ci 70062306a36Sopenharmony_ci#define TX_CFG_B(channel) (0xD44 + ((channel) << 6)) 70162306a36Sopenharmony_ci#define TX_CFG_B_TDMABL_512_ (0x00040000) 70262306a36Sopenharmony_ci#define TX_CFG_B_TX_RING_LEN_MASK_ (0x0000FFFF) 70362306a36Sopenharmony_ci 70462306a36Sopenharmony_ci#define TX_BASE_ADDRH(channel) (0xD48 + ((channel) << 6)) 70562306a36Sopenharmony_ci 70662306a36Sopenharmony_ci#define TX_BASE_ADDRL(channel) (0xD4C + ((channel) << 6)) 70762306a36Sopenharmony_ci 70862306a36Sopenharmony_ci#define TX_HEAD_WRITEBACK_ADDRH(channel) (0xD50 + ((channel) << 6)) 70962306a36Sopenharmony_ci 71062306a36Sopenharmony_ci#define TX_HEAD_WRITEBACK_ADDRL(channel) (0xD54 + ((channel) << 6)) 71162306a36Sopenharmony_ci 71262306a36Sopenharmony_ci#define TX_HEAD(channel) (0xD58 + ((channel) << 6)) 71362306a36Sopenharmony_ci 71462306a36Sopenharmony_ci#define TX_TAIL(channel) (0xD5C + ((channel) << 6)) 71562306a36Sopenharmony_ci#define TX_TAIL_SET_DMAC_INT_EN_ BIT(31) 71662306a36Sopenharmony_ci#define TX_TAIL_SET_TOP_INT_EN_ BIT(30) 71762306a36Sopenharmony_ci#define TX_TAIL_SET_TOP_INT_VEC_EN_ BIT(29) 71862306a36Sopenharmony_ci 71962306a36Sopenharmony_ci#define TX_CFG_C(channel) (0xD64 + ((channel) << 6)) 72062306a36Sopenharmony_ci#define TX_CFG_C_TX_TOP_INT_EN_AUTO_CLR_ BIT(6) 72162306a36Sopenharmony_ci#define TX_CFG_C_TX_DMA_INT_EN_AUTO_CLR_ BIT(5) 72262306a36Sopenharmony_ci#define TX_CFG_C_TX_INT_EN_R2C_ BIT(4) 72362306a36Sopenharmony_ci#define TX_CFG_C_TX_DMA_INT_STS_AUTO_CLR_ BIT(3) 72462306a36Sopenharmony_ci#define TX_CFG_C_TX_INT_STS_R2C_MODE_MASK_ (0x00000007) 72562306a36Sopenharmony_ci 72662306a36Sopenharmony_ci#define OTP_PWR_DN (0x1000) 72762306a36Sopenharmony_ci#define OTP_PWR_DN_PWRDN_N_ BIT(0) 72862306a36Sopenharmony_ci 72962306a36Sopenharmony_ci#define OTP_ADDR_HIGH (0x1004) 73062306a36Sopenharmony_ci#define OTP_ADDR_LOW (0x1008) 73162306a36Sopenharmony_ci 73262306a36Sopenharmony_ci#define OTP_PRGM_DATA (0x1010) 73362306a36Sopenharmony_ci 73462306a36Sopenharmony_ci#define OTP_PRGM_MODE (0x1014) 73562306a36Sopenharmony_ci#define OTP_PRGM_MODE_BYTE_ BIT(0) 73662306a36Sopenharmony_ci 73762306a36Sopenharmony_ci#define OTP_READ_DATA (0x1018) 73862306a36Sopenharmony_ci 73962306a36Sopenharmony_ci#define OTP_FUNC_CMD (0x1020) 74062306a36Sopenharmony_ci#define OTP_FUNC_CMD_READ_ BIT(0) 74162306a36Sopenharmony_ci 74262306a36Sopenharmony_ci#define OTP_TST_CMD (0x1024) 74362306a36Sopenharmony_ci#define OTP_TST_CMD_PRGVRFY_ BIT(3) 74462306a36Sopenharmony_ci 74562306a36Sopenharmony_ci#define OTP_CMD_GO (0x1028) 74662306a36Sopenharmony_ci#define OTP_CMD_GO_GO_ BIT(0) 74762306a36Sopenharmony_ci 74862306a36Sopenharmony_ci#define OTP_STATUS (0x1030) 74962306a36Sopenharmony_ci#define OTP_STATUS_BUSY_ BIT(0) 75062306a36Sopenharmony_ci 75162306a36Sopenharmony_ci/* Hearthstone OTP block registers */ 75262306a36Sopenharmony_ci#define HS_OTP_BLOCK_BASE (ETH_SYS_REG_ADDR_BASE + \ 75362306a36Sopenharmony_ci ETH_OTP_REG_ADDR_BASE) 75462306a36Sopenharmony_ci#define HS_OTP_PWR_DN (HS_OTP_BLOCK_BASE + 0x0) 75562306a36Sopenharmony_ci#define HS_OTP_ADDR_HIGH (HS_OTP_BLOCK_BASE + 0x4) 75662306a36Sopenharmony_ci#define HS_OTP_ADDR_LOW (HS_OTP_BLOCK_BASE + 0x8) 75762306a36Sopenharmony_ci#define HS_OTP_PRGM_DATA (HS_OTP_BLOCK_BASE + 0x10) 75862306a36Sopenharmony_ci#define HS_OTP_PRGM_MODE (HS_OTP_BLOCK_BASE + 0x14) 75962306a36Sopenharmony_ci#define HS_OTP_READ_DATA (HS_OTP_BLOCK_BASE + 0x18) 76062306a36Sopenharmony_ci#define HS_OTP_FUNC_CMD (HS_OTP_BLOCK_BASE + 0x20) 76162306a36Sopenharmony_ci#define HS_OTP_TST_CMD (HS_OTP_BLOCK_BASE + 0x24) 76262306a36Sopenharmony_ci#define HS_OTP_CMD_GO (HS_OTP_BLOCK_BASE + 0x28) 76362306a36Sopenharmony_ci#define HS_OTP_STATUS (HS_OTP_BLOCK_BASE + 0x30) 76462306a36Sopenharmony_ci 76562306a36Sopenharmony_ci/* MAC statistics registers */ 76662306a36Sopenharmony_ci#define STAT_RX_FCS_ERRORS (0x1200) 76762306a36Sopenharmony_ci#define STAT_RX_ALIGNMENT_ERRORS (0x1204) 76862306a36Sopenharmony_ci#define STAT_RX_FRAGMENT_ERRORS (0x1208) 76962306a36Sopenharmony_ci#define STAT_RX_JABBER_ERRORS (0x120C) 77062306a36Sopenharmony_ci#define STAT_RX_UNDERSIZE_FRAME_ERRORS (0x1210) 77162306a36Sopenharmony_ci#define STAT_RX_OVERSIZE_FRAME_ERRORS (0x1214) 77262306a36Sopenharmony_ci#define STAT_RX_DROPPED_FRAMES (0x1218) 77362306a36Sopenharmony_ci#define STAT_RX_UNICAST_BYTE_COUNT (0x121C) 77462306a36Sopenharmony_ci#define STAT_RX_BROADCAST_BYTE_COUNT (0x1220) 77562306a36Sopenharmony_ci#define STAT_RX_MULTICAST_BYTE_COUNT (0x1224) 77662306a36Sopenharmony_ci#define STAT_RX_UNICAST_FRAMES (0x1228) 77762306a36Sopenharmony_ci#define STAT_RX_BROADCAST_FRAMES (0x122C) 77862306a36Sopenharmony_ci#define STAT_RX_MULTICAST_FRAMES (0x1230) 77962306a36Sopenharmony_ci#define STAT_RX_PAUSE_FRAMES (0x1234) 78062306a36Sopenharmony_ci#define STAT_RX_64_BYTE_FRAMES (0x1238) 78162306a36Sopenharmony_ci#define STAT_RX_65_127_BYTE_FRAMES (0x123C) 78262306a36Sopenharmony_ci#define STAT_RX_128_255_BYTE_FRAMES (0x1240) 78362306a36Sopenharmony_ci#define STAT_RX_256_511_BYTES_FRAMES (0x1244) 78462306a36Sopenharmony_ci#define STAT_RX_512_1023_BYTE_FRAMES (0x1248) 78562306a36Sopenharmony_ci#define STAT_RX_1024_1518_BYTE_FRAMES (0x124C) 78662306a36Sopenharmony_ci#define STAT_RX_GREATER_1518_BYTE_FRAMES (0x1250) 78762306a36Sopenharmony_ci#define STAT_RX_TOTAL_FRAMES (0x1254) 78862306a36Sopenharmony_ci#define STAT_EEE_RX_LPI_TRANSITIONS (0x1258) 78962306a36Sopenharmony_ci#define STAT_EEE_RX_LPI_TIME (0x125C) 79062306a36Sopenharmony_ci#define STAT_RX_COUNTER_ROLLOVER_STATUS (0x127C) 79162306a36Sopenharmony_ci 79262306a36Sopenharmony_ci#define STAT_TX_FCS_ERRORS (0x1280) 79362306a36Sopenharmony_ci#define STAT_TX_EXCESS_DEFERRAL_ERRORS (0x1284) 79462306a36Sopenharmony_ci#define STAT_TX_CARRIER_ERRORS (0x1288) 79562306a36Sopenharmony_ci#define STAT_TX_BAD_BYTE_COUNT (0x128C) 79662306a36Sopenharmony_ci#define STAT_TX_SINGLE_COLLISIONS (0x1290) 79762306a36Sopenharmony_ci#define STAT_TX_MULTIPLE_COLLISIONS (0x1294) 79862306a36Sopenharmony_ci#define STAT_TX_EXCESSIVE_COLLISION (0x1298) 79962306a36Sopenharmony_ci#define STAT_TX_LATE_COLLISIONS (0x129C) 80062306a36Sopenharmony_ci#define STAT_TX_UNICAST_BYTE_COUNT (0x12A0) 80162306a36Sopenharmony_ci#define STAT_TX_BROADCAST_BYTE_COUNT (0x12A4) 80262306a36Sopenharmony_ci#define STAT_TX_MULTICAST_BYTE_COUNT (0x12A8) 80362306a36Sopenharmony_ci#define STAT_TX_UNICAST_FRAMES (0x12AC) 80462306a36Sopenharmony_ci#define STAT_TX_BROADCAST_FRAMES (0x12B0) 80562306a36Sopenharmony_ci#define STAT_TX_MULTICAST_FRAMES (0x12B4) 80662306a36Sopenharmony_ci#define STAT_TX_PAUSE_FRAMES (0x12B8) 80762306a36Sopenharmony_ci#define STAT_TX_64_BYTE_FRAMES (0x12BC) 80862306a36Sopenharmony_ci#define STAT_TX_65_127_BYTE_FRAMES (0x12C0) 80962306a36Sopenharmony_ci#define STAT_TX_128_255_BYTE_FRAMES (0x12C4) 81062306a36Sopenharmony_ci#define STAT_TX_256_511_BYTES_FRAMES (0x12C8) 81162306a36Sopenharmony_ci#define STAT_TX_512_1023_BYTE_FRAMES (0x12CC) 81262306a36Sopenharmony_ci#define STAT_TX_1024_1518_BYTE_FRAMES (0x12D0) 81362306a36Sopenharmony_ci#define STAT_TX_GREATER_1518_BYTE_FRAMES (0x12D4) 81462306a36Sopenharmony_ci#define STAT_TX_TOTAL_FRAMES (0x12D8) 81562306a36Sopenharmony_ci#define STAT_EEE_TX_LPI_TRANSITIONS (0x12DC) 81662306a36Sopenharmony_ci#define STAT_EEE_TX_LPI_TIME (0x12E0) 81762306a36Sopenharmony_ci#define STAT_TX_COUNTER_ROLLOVER_STATUS (0x12FC) 81862306a36Sopenharmony_ci 81962306a36Sopenharmony_ci/* End of Register definitions */ 82062306a36Sopenharmony_ci 82162306a36Sopenharmony_ci#define LAN743X_MAX_RX_CHANNELS (4) 82262306a36Sopenharmony_ci#define LAN743X_MAX_TX_CHANNELS (1) 82362306a36Sopenharmony_ci#define PCI11X1X_MAX_TX_CHANNELS (4) 82462306a36Sopenharmony_cistruct lan743x_adapter; 82562306a36Sopenharmony_ci 82662306a36Sopenharmony_ci#define LAN743X_USED_RX_CHANNELS (4) 82762306a36Sopenharmony_ci#define LAN743X_USED_TX_CHANNELS (1) 82862306a36Sopenharmony_ci#define PCI11X1X_USED_TX_CHANNELS (4) 82962306a36Sopenharmony_ci#define LAN743X_INT_MOD (400) 83062306a36Sopenharmony_ci 83162306a36Sopenharmony_ci#if (LAN743X_USED_RX_CHANNELS > LAN743X_MAX_RX_CHANNELS) 83262306a36Sopenharmony_ci#error Invalid LAN743X_USED_RX_CHANNELS 83362306a36Sopenharmony_ci#endif 83462306a36Sopenharmony_ci#if (LAN743X_USED_TX_CHANNELS > LAN743X_MAX_TX_CHANNELS) 83562306a36Sopenharmony_ci#error Invalid LAN743X_USED_TX_CHANNELS 83662306a36Sopenharmony_ci#endif 83762306a36Sopenharmony_ci#if (PCI11X1X_USED_TX_CHANNELS > PCI11X1X_MAX_TX_CHANNELS) 83862306a36Sopenharmony_ci#error Invalid PCI11X1X_USED_TX_CHANNELS 83962306a36Sopenharmony_ci#endif 84062306a36Sopenharmony_ci 84162306a36Sopenharmony_ci/* PCI */ 84262306a36Sopenharmony_ci/* SMSC acquired EFAR late 1990's, MCHP acquired SMSC 2012 */ 84362306a36Sopenharmony_ci#define PCI_VENDOR_ID_SMSC PCI_VENDOR_ID_EFAR 84462306a36Sopenharmony_ci#define PCI_DEVICE_ID_SMSC_LAN7430 (0x7430) 84562306a36Sopenharmony_ci#define PCI_DEVICE_ID_SMSC_LAN7431 (0x7431) 84662306a36Sopenharmony_ci#define PCI_DEVICE_ID_SMSC_A011 (0xA011) 84762306a36Sopenharmony_ci#define PCI_DEVICE_ID_SMSC_A041 (0xA041) 84862306a36Sopenharmony_ci 84962306a36Sopenharmony_ci#define PCI_CONFIG_LENGTH (0x1000) 85062306a36Sopenharmony_ci 85162306a36Sopenharmony_ci/* CSR */ 85262306a36Sopenharmony_ci#define CSR_LENGTH (0x2000) 85362306a36Sopenharmony_ci 85462306a36Sopenharmony_ci#define LAN743X_CSR_FLAG_IS_A0 BIT(0) 85562306a36Sopenharmony_ci#define LAN743X_CSR_FLAG_IS_B0 BIT(1) 85662306a36Sopenharmony_ci#define LAN743X_CSR_FLAG_SUPPORTS_INTR_AUTO_SET_CLR BIT(8) 85762306a36Sopenharmony_ci 85862306a36Sopenharmony_cistruct lan743x_csr { 85962306a36Sopenharmony_ci u32 flags; 86062306a36Sopenharmony_ci u8 __iomem *csr_address; 86162306a36Sopenharmony_ci u32 id_rev; 86262306a36Sopenharmony_ci u32 fpga_rev; 86362306a36Sopenharmony_ci}; 86462306a36Sopenharmony_ci 86562306a36Sopenharmony_ci/* INTERRUPTS */ 86662306a36Sopenharmony_citypedef void(*lan743x_vector_handler)(void *context, u32 int_sts, u32 flags); 86762306a36Sopenharmony_ci 86862306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_IRQ_SHARED BIT(0) 86962306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_STATUS_READ BIT(1) 87062306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_STATUS_R2C BIT(2) 87162306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C BIT(3) 87262306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CHECK BIT(4) 87362306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CLEAR BIT(5) 87462306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_R2C BIT(6) 87562306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_MASTER_ENABLE_CLEAR BIT(7) 87662306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_MASTER_ENABLE_SET BIT(8) 87762306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_ISR_CLEAR BIT(9) 87862306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_ISR_SET BIT(10) 87962306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_CLEAR BIT(11) 88062306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_VECTOR_ENABLE_AUTO_SET BIT(12) 88162306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_CLEAR BIT(13) 88262306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_ENABLE_AUTO_SET BIT(14) 88362306a36Sopenharmony_ci#define LAN743X_VECTOR_FLAG_SOURCE_STATUS_AUTO_CLEAR BIT(15) 88462306a36Sopenharmony_ci 88562306a36Sopenharmony_cistruct lan743x_vector { 88662306a36Sopenharmony_ci int irq; 88762306a36Sopenharmony_ci u32 flags; 88862306a36Sopenharmony_ci struct lan743x_adapter *adapter; 88962306a36Sopenharmony_ci int vector_index; 89062306a36Sopenharmony_ci u32 int_mask; 89162306a36Sopenharmony_ci lan743x_vector_handler handler; 89262306a36Sopenharmony_ci void *context; 89362306a36Sopenharmony_ci}; 89462306a36Sopenharmony_ci 89562306a36Sopenharmony_ci#define LAN743X_MAX_VECTOR_COUNT (8) 89662306a36Sopenharmony_ci#define PCI11X1X_MAX_VECTOR_COUNT (16) 89762306a36Sopenharmony_ci 89862306a36Sopenharmony_cistruct lan743x_intr { 89962306a36Sopenharmony_ci int flags; 90062306a36Sopenharmony_ci 90162306a36Sopenharmony_ci unsigned int irq; 90262306a36Sopenharmony_ci 90362306a36Sopenharmony_ci struct lan743x_vector vector_list[PCI11X1X_MAX_VECTOR_COUNT]; 90462306a36Sopenharmony_ci int number_of_vectors; 90562306a36Sopenharmony_ci bool using_vectors; 90662306a36Sopenharmony_ci 90762306a36Sopenharmony_ci bool software_isr_flag; 90862306a36Sopenharmony_ci wait_queue_head_t software_isr_wq; 90962306a36Sopenharmony_ci}; 91062306a36Sopenharmony_ci 91162306a36Sopenharmony_ci#define LAN743X_MAX_FRAME_SIZE (9 * 1024) 91262306a36Sopenharmony_ci 91362306a36Sopenharmony_ci/* PHY */ 91462306a36Sopenharmony_cistruct lan743x_phy { 91562306a36Sopenharmony_ci bool fc_autoneg; 91662306a36Sopenharmony_ci u8 fc_request_control; 91762306a36Sopenharmony_ci}; 91862306a36Sopenharmony_ci 91962306a36Sopenharmony_ci/* TX */ 92062306a36Sopenharmony_cistruct lan743x_tx_descriptor; 92162306a36Sopenharmony_cistruct lan743x_tx_buffer_info; 92262306a36Sopenharmony_ci 92362306a36Sopenharmony_ci#define GPIO_QUEUE_STARTED (0) 92462306a36Sopenharmony_ci#define GPIO_TX_FUNCTION (1) 92562306a36Sopenharmony_ci#define GPIO_TX_COMPLETION (2) 92662306a36Sopenharmony_ci#define GPIO_TX_FRAGMENT (3) 92762306a36Sopenharmony_ci 92862306a36Sopenharmony_ci#define TX_FRAME_FLAG_IN_PROGRESS BIT(0) 92962306a36Sopenharmony_ci 93062306a36Sopenharmony_ci#define TX_TS_FLAG_TIMESTAMPING_ENABLED BIT(0) 93162306a36Sopenharmony_ci#define TX_TS_FLAG_ONE_STEP_SYNC BIT(1) 93262306a36Sopenharmony_ci 93362306a36Sopenharmony_cistruct lan743x_tx { 93462306a36Sopenharmony_ci struct lan743x_adapter *adapter; 93562306a36Sopenharmony_ci u32 ts_flags; 93662306a36Sopenharmony_ci u32 vector_flags; 93762306a36Sopenharmony_ci int channel_number; 93862306a36Sopenharmony_ci 93962306a36Sopenharmony_ci int ring_size; 94062306a36Sopenharmony_ci size_t ring_allocation_size; 94162306a36Sopenharmony_ci struct lan743x_tx_descriptor *ring_cpu_ptr; 94262306a36Sopenharmony_ci dma_addr_t ring_dma_ptr; 94362306a36Sopenharmony_ci /* ring_lock: used to prevent concurrent access to tx ring */ 94462306a36Sopenharmony_ci spinlock_t ring_lock; 94562306a36Sopenharmony_ci u32 frame_flags; 94662306a36Sopenharmony_ci u32 frame_first; 94762306a36Sopenharmony_ci u32 frame_data0; 94862306a36Sopenharmony_ci u32 frame_tail; 94962306a36Sopenharmony_ci 95062306a36Sopenharmony_ci struct lan743x_tx_buffer_info *buffer_info; 95162306a36Sopenharmony_ci 95262306a36Sopenharmony_ci __le32 *head_cpu_ptr; 95362306a36Sopenharmony_ci dma_addr_t head_dma_ptr; 95462306a36Sopenharmony_ci int last_head; 95562306a36Sopenharmony_ci int last_tail; 95662306a36Sopenharmony_ci 95762306a36Sopenharmony_ci struct napi_struct napi; 95862306a36Sopenharmony_ci u32 frame_count; 95962306a36Sopenharmony_ci u32 rqd_descriptors; 96062306a36Sopenharmony_ci}; 96162306a36Sopenharmony_ci 96262306a36Sopenharmony_civoid lan743x_tx_set_timestamping_mode(struct lan743x_tx *tx, 96362306a36Sopenharmony_ci bool enable_timestamping, 96462306a36Sopenharmony_ci bool enable_onestep_sync); 96562306a36Sopenharmony_ci 96662306a36Sopenharmony_ci/* RX */ 96762306a36Sopenharmony_cistruct lan743x_rx_descriptor; 96862306a36Sopenharmony_cistruct lan743x_rx_buffer_info; 96962306a36Sopenharmony_ci 97062306a36Sopenharmony_cistruct lan743x_rx { 97162306a36Sopenharmony_ci struct lan743x_adapter *adapter; 97262306a36Sopenharmony_ci u32 vector_flags; 97362306a36Sopenharmony_ci int channel_number; 97462306a36Sopenharmony_ci 97562306a36Sopenharmony_ci int ring_size; 97662306a36Sopenharmony_ci size_t ring_allocation_size; 97762306a36Sopenharmony_ci struct lan743x_rx_descriptor *ring_cpu_ptr; 97862306a36Sopenharmony_ci dma_addr_t ring_dma_ptr; 97962306a36Sopenharmony_ci 98062306a36Sopenharmony_ci struct lan743x_rx_buffer_info *buffer_info; 98162306a36Sopenharmony_ci 98262306a36Sopenharmony_ci __le32 *head_cpu_ptr; 98362306a36Sopenharmony_ci dma_addr_t head_dma_ptr; 98462306a36Sopenharmony_ci u32 last_head; 98562306a36Sopenharmony_ci u32 last_tail; 98662306a36Sopenharmony_ci 98762306a36Sopenharmony_ci struct napi_struct napi; 98862306a36Sopenharmony_ci 98962306a36Sopenharmony_ci u32 frame_count; 99062306a36Sopenharmony_ci 99162306a36Sopenharmony_ci struct sk_buff *skb_head, *skb_tail; 99262306a36Sopenharmony_ci}; 99362306a36Sopenharmony_ci 99462306a36Sopenharmony_ci/* SGMII Link Speed Duplex status */ 99562306a36Sopenharmony_cienum lan743x_sgmii_lsd { 99662306a36Sopenharmony_ci POWER_DOWN = 0, 99762306a36Sopenharmony_ci LINK_DOWN, 99862306a36Sopenharmony_ci ANEG_BUSY, 99962306a36Sopenharmony_ci LINK_10HD, 100062306a36Sopenharmony_ci LINK_10FD, 100162306a36Sopenharmony_ci LINK_100HD, 100262306a36Sopenharmony_ci LINK_100FD, 100362306a36Sopenharmony_ci LINK_1000_MASTER, 100462306a36Sopenharmony_ci LINK_1000_SLAVE, 100562306a36Sopenharmony_ci LINK_2500_MASTER, 100662306a36Sopenharmony_ci LINK_2500_SLAVE 100762306a36Sopenharmony_ci}; 100862306a36Sopenharmony_ci 100962306a36Sopenharmony_cistruct lan743x_adapter { 101062306a36Sopenharmony_ci struct net_device *netdev; 101162306a36Sopenharmony_ci struct mii_bus *mdiobus; 101262306a36Sopenharmony_ci int msg_enable; 101362306a36Sopenharmony_ci#ifdef CONFIG_PM 101462306a36Sopenharmony_ci u32 wolopts; 101562306a36Sopenharmony_ci u8 sopass[SOPASS_MAX]; 101662306a36Sopenharmony_ci#endif 101762306a36Sopenharmony_ci struct pci_dev *pdev; 101862306a36Sopenharmony_ci struct lan743x_csr csr; 101962306a36Sopenharmony_ci struct lan743x_intr intr; 102062306a36Sopenharmony_ci 102162306a36Sopenharmony_ci struct lan743x_gpio gpio; 102262306a36Sopenharmony_ci struct lan743x_ptp ptp; 102362306a36Sopenharmony_ci 102462306a36Sopenharmony_ci u8 mac_address[ETH_ALEN]; 102562306a36Sopenharmony_ci 102662306a36Sopenharmony_ci struct lan743x_phy phy; 102762306a36Sopenharmony_ci struct lan743x_tx tx[PCI11X1X_USED_TX_CHANNELS]; 102862306a36Sopenharmony_ci struct lan743x_rx rx[LAN743X_USED_RX_CHANNELS]; 102962306a36Sopenharmony_ci bool is_pci11x1x; 103062306a36Sopenharmony_ci bool is_sgmii_en; 103162306a36Sopenharmony_ci /* protect ethernet syslock */ 103262306a36Sopenharmony_ci spinlock_t eth_syslock_spinlock; 103362306a36Sopenharmony_ci bool eth_syslock_en; 103462306a36Sopenharmony_ci u32 eth_syslock_acquire_cnt; 103562306a36Sopenharmony_ci struct mutex sgmii_rw_lock; 103662306a36Sopenharmony_ci /* SGMII Link Speed & Duplex status */ 103762306a36Sopenharmony_ci enum lan743x_sgmii_lsd sgmii_lsd; 103862306a36Sopenharmony_ci u8 max_tx_channels; 103962306a36Sopenharmony_ci u8 used_tx_channels; 104062306a36Sopenharmony_ci u8 max_vector_count; 104162306a36Sopenharmony_ci 104262306a36Sopenharmony_ci#define LAN743X_ADAPTER_FLAG_OTP BIT(0) 104362306a36Sopenharmony_ci u32 flags; 104462306a36Sopenharmony_ci u32 hw_cfg; 104562306a36Sopenharmony_ci phy_interface_t phy_interface; 104662306a36Sopenharmony_ci}; 104762306a36Sopenharmony_ci 104862306a36Sopenharmony_ci#define LAN743X_COMPONENT_FLAG_RX(channel) BIT(20 + (channel)) 104962306a36Sopenharmony_ci 105062306a36Sopenharmony_ci#define INTR_FLAG_IRQ_REQUESTED(vector_index) BIT(0 + vector_index) 105162306a36Sopenharmony_ci#define INTR_FLAG_MSI_ENABLED BIT(8) 105262306a36Sopenharmony_ci#define INTR_FLAG_MSIX_ENABLED BIT(9) 105362306a36Sopenharmony_ci 105462306a36Sopenharmony_ci#define MAC_MII_READ 1 105562306a36Sopenharmony_ci#define MAC_MII_WRITE 0 105662306a36Sopenharmony_ci 105762306a36Sopenharmony_ci#define PHY_FLAG_OPENED BIT(0) 105862306a36Sopenharmony_ci#define PHY_FLAG_ATTACHED BIT(1) 105962306a36Sopenharmony_ci 106062306a36Sopenharmony_ci#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT 106162306a36Sopenharmony_ci#define DMA_ADDR_HIGH32(dma_addr) ((u32)(((dma_addr) >> 32) & 0xFFFFFFFF)) 106262306a36Sopenharmony_ci#else 106362306a36Sopenharmony_ci#define DMA_ADDR_HIGH32(dma_addr) ((u32)(0)) 106462306a36Sopenharmony_ci#endif 106562306a36Sopenharmony_ci#define DMA_ADDR_LOW32(dma_addr) ((u32)((dma_addr) & 0xFFFFFFFF)) 106662306a36Sopenharmony_ci#define DMA_DESCRIPTOR_SPACING_16 (16) 106762306a36Sopenharmony_ci#define DMA_DESCRIPTOR_SPACING_32 (32) 106862306a36Sopenharmony_ci#define DMA_DESCRIPTOR_SPACING_64 (64) 106962306a36Sopenharmony_ci#define DMA_DESCRIPTOR_SPACING_128 (128) 107062306a36Sopenharmony_ci#define DEFAULT_DMA_DESCRIPTOR_SPACING (L1_CACHE_BYTES) 107162306a36Sopenharmony_ci 107262306a36Sopenharmony_ci#define DMAC_CHANNEL_STATE_SET(start_bit, stop_bit) \ 107362306a36Sopenharmony_ci (((start_bit) ? 2 : 0) | ((stop_bit) ? 1 : 0)) 107462306a36Sopenharmony_ci#define DMAC_CHANNEL_STATE_INITIAL DMAC_CHANNEL_STATE_SET(0, 0) 107562306a36Sopenharmony_ci#define DMAC_CHANNEL_STATE_STARTED DMAC_CHANNEL_STATE_SET(1, 0) 107662306a36Sopenharmony_ci#define DMAC_CHANNEL_STATE_STOP_PENDING DMAC_CHANNEL_STATE_SET(1, 1) 107762306a36Sopenharmony_ci#define DMAC_CHANNEL_STATE_STOPPED DMAC_CHANNEL_STATE_SET(0, 1) 107862306a36Sopenharmony_ci 107962306a36Sopenharmony_ci/* TX Descriptor bits */ 108062306a36Sopenharmony_ci#define TX_DESC_DATA0_DTYPE_MASK_ (0xC0000000) 108162306a36Sopenharmony_ci#define TX_DESC_DATA0_DTYPE_DATA_ (0x00000000) 108262306a36Sopenharmony_ci#define TX_DESC_DATA0_DTYPE_EXT_ (0x40000000) 108362306a36Sopenharmony_ci#define TX_DESC_DATA0_FS_ (0x20000000) 108462306a36Sopenharmony_ci#define TX_DESC_DATA0_LS_ (0x10000000) 108562306a36Sopenharmony_ci#define TX_DESC_DATA0_EXT_ (0x08000000) 108662306a36Sopenharmony_ci#define TX_DESC_DATA0_IOC_ (0x04000000) 108762306a36Sopenharmony_ci#define TX_DESC_DATA0_ICE_ (0x00400000) 108862306a36Sopenharmony_ci#define TX_DESC_DATA0_IPE_ (0x00200000) 108962306a36Sopenharmony_ci#define TX_DESC_DATA0_TPE_ (0x00100000) 109062306a36Sopenharmony_ci#define TX_DESC_DATA0_FCS_ (0x00020000) 109162306a36Sopenharmony_ci#define TX_DESC_DATA0_TSE_ (0x00010000) 109262306a36Sopenharmony_ci#define TX_DESC_DATA0_BUF_LENGTH_MASK_ (0x0000FFFF) 109362306a36Sopenharmony_ci#define TX_DESC_DATA0_EXT_LSO_ (0x00200000) 109462306a36Sopenharmony_ci#define TX_DESC_DATA0_EXT_PAY_LENGTH_MASK_ (0x000FFFFF) 109562306a36Sopenharmony_ci#define TX_DESC_DATA3_FRAME_LENGTH_MSS_MASK_ (0x3FFF0000) 109662306a36Sopenharmony_ci 109762306a36Sopenharmony_cistruct lan743x_tx_descriptor { 109862306a36Sopenharmony_ci __le32 data0; 109962306a36Sopenharmony_ci __le32 data1; 110062306a36Sopenharmony_ci __le32 data2; 110162306a36Sopenharmony_ci __le32 data3; 110262306a36Sopenharmony_ci} __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING); 110362306a36Sopenharmony_ci 110462306a36Sopenharmony_ci#define TX_BUFFER_INFO_FLAG_ACTIVE BIT(0) 110562306a36Sopenharmony_ci#define TX_BUFFER_INFO_FLAG_TIMESTAMP_REQUESTED BIT(1) 110662306a36Sopenharmony_ci#define TX_BUFFER_INFO_FLAG_IGNORE_SYNC BIT(2) 110762306a36Sopenharmony_ci#define TX_BUFFER_INFO_FLAG_SKB_FRAGMENT BIT(3) 110862306a36Sopenharmony_cistruct lan743x_tx_buffer_info { 110962306a36Sopenharmony_ci int flags; 111062306a36Sopenharmony_ci struct sk_buff *skb; 111162306a36Sopenharmony_ci dma_addr_t dma_ptr; 111262306a36Sopenharmony_ci unsigned int buffer_length; 111362306a36Sopenharmony_ci}; 111462306a36Sopenharmony_ci 111562306a36Sopenharmony_ci#define LAN743X_TX_RING_SIZE (128) 111662306a36Sopenharmony_ci 111762306a36Sopenharmony_ci/* OWN bit is set. ie, Descs are owned by RX DMAC */ 111862306a36Sopenharmony_ci#define RX_DESC_DATA0_OWN_ (0x00008000) 111962306a36Sopenharmony_ci/* OWN bit is clear. ie, Descs are owned by host */ 112062306a36Sopenharmony_ci#define RX_DESC_DATA0_FS_ (0x80000000) 112162306a36Sopenharmony_ci#define RX_DESC_DATA0_LS_ (0x40000000) 112262306a36Sopenharmony_ci#define RX_DESC_DATA0_FRAME_LENGTH_MASK_ (0x3FFF0000) 112362306a36Sopenharmony_ci#define RX_DESC_DATA0_FRAME_LENGTH_GET_(data0) \ 112462306a36Sopenharmony_ci (((data0) & RX_DESC_DATA0_FRAME_LENGTH_MASK_) >> 16) 112562306a36Sopenharmony_ci#define RX_DESC_DATA0_EXT_ (0x00004000) 112662306a36Sopenharmony_ci#define RX_DESC_DATA0_BUF_LENGTH_MASK_ (0x00003FFF) 112762306a36Sopenharmony_ci#define RX_DESC_DATA1_STATUS_ICE_ (0x00020000) 112862306a36Sopenharmony_ci#define RX_DESC_DATA1_STATUS_TCE_ (0x00010000) 112962306a36Sopenharmony_ci#define RX_DESC_DATA1_STATUS_ICSM_ (0x00000001) 113062306a36Sopenharmony_ci#define RX_DESC_DATA2_TS_NS_MASK_ (0x3FFFFFFF) 113162306a36Sopenharmony_ci 113262306a36Sopenharmony_ci#if ((NET_IP_ALIGN != 0) && (NET_IP_ALIGN != 2)) 113362306a36Sopenharmony_ci#error NET_IP_ALIGN must be 0 or 2 113462306a36Sopenharmony_ci#endif 113562306a36Sopenharmony_ci 113662306a36Sopenharmony_ci#define RX_HEAD_PADDING NET_IP_ALIGN 113762306a36Sopenharmony_ci 113862306a36Sopenharmony_cistruct lan743x_rx_descriptor { 113962306a36Sopenharmony_ci __le32 data0; 114062306a36Sopenharmony_ci __le32 data1; 114162306a36Sopenharmony_ci __le32 data2; 114262306a36Sopenharmony_ci __le32 data3; 114362306a36Sopenharmony_ci} __aligned(DEFAULT_DMA_DESCRIPTOR_SPACING); 114462306a36Sopenharmony_ci 114562306a36Sopenharmony_ci#define RX_BUFFER_INFO_FLAG_ACTIVE BIT(0) 114662306a36Sopenharmony_cistruct lan743x_rx_buffer_info { 114762306a36Sopenharmony_ci int flags; 114862306a36Sopenharmony_ci struct sk_buff *skb; 114962306a36Sopenharmony_ci 115062306a36Sopenharmony_ci dma_addr_t dma_ptr; 115162306a36Sopenharmony_ci unsigned int buffer_length; 115262306a36Sopenharmony_ci}; 115362306a36Sopenharmony_ci 115462306a36Sopenharmony_ci#define LAN743X_RX_RING_SIZE (128) 115562306a36Sopenharmony_ci 115662306a36Sopenharmony_ci#define RX_PROCESS_RESULT_NOTHING_TO_DO (0) 115762306a36Sopenharmony_ci#define RX_PROCESS_RESULT_BUFFER_RECEIVED (1) 115862306a36Sopenharmony_ci 115962306a36Sopenharmony_ciu32 lan743x_csr_read(struct lan743x_adapter *adapter, int offset); 116062306a36Sopenharmony_civoid lan743x_csr_write(struct lan743x_adapter *adapter, int offset, u32 data); 116162306a36Sopenharmony_ciint lan743x_hs_syslock_acquire(struct lan743x_adapter *adapter, u16 timeout); 116262306a36Sopenharmony_civoid lan743x_hs_syslock_release(struct lan743x_adapter *adapter); 116362306a36Sopenharmony_civoid lan743x_mac_flow_ctrl_set_enables(struct lan743x_adapter *adapter, 116462306a36Sopenharmony_ci bool tx_enable, bool rx_enable); 116562306a36Sopenharmony_ciint lan743x_sgmii_read(struct lan743x_adapter *adapter, u8 mmd, u16 addr); 116662306a36Sopenharmony_ci 116762306a36Sopenharmony_ci#endif /* _LAN743X_H */ 1168