18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright(c) 2007 Atheros Corporation. All rights reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Derived from Intel e1000 driver
68c2ecf20Sopenharmony_ci * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _ATHL1E_HW_H_
108c2ecf20Sopenharmony_ci#define _ATHL1E_HW_H_
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/types.h>
138c2ecf20Sopenharmony_ci#include <linux/mii.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct atl1e_adapter;
168c2ecf20Sopenharmony_cistruct atl1e_hw;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* function prototype */
198c2ecf20Sopenharmony_cis32 atl1e_reset_hw(struct atl1e_hw *hw);
208c2ecf20Sopenharmony_cis32 atl1e_read_mac_addr(struct atl1e_hw *hw);
218c2ecf20Sopenharmony_cis32 atl1e_init_hw(struct atl1e_hw *hw);
228c2ecf20Sopenharmony_cis32 atl1e_phy_commit(struct atl1e_hw *hw);
238c2ecf20Sopenharmony_cis32 atl1e_get_speed_and_duplex(struct atl1e_hw *hw, u16 *speed, u16 *duplex);
248c2ecf20Sopenharmony_ciu32 atl1e_auto_get_fc(struct atl1e_adapter *adapter, u16 duplex);
258c2ecf20Sopenharmony_ciu32 atl1e_hash_mc_addr(struct atl1e_hw *hw, u8 *mc_addr);
268c2ecf20Sopenharmony_civoid atl1e_hash_set(struct atl1e_hw *hw, u32 hash_value);
278c2ecf20Sopenharmony_cis32 atl1e_read_phy_reg(struct atl1e_hw *hw, u16 reg_addr, u16 *phy_data);
288c2ecf20Sopenharmony_cis32 atl1e_write_phy_reg(struct atl1e_hw *hw, u32 reg_addr, u16 phy_data);
298c2ecf20Sopenharmony_cis32 atl1e_validate_mdi_setting(struct atl1e_hw *hw);
308c2ecf20Sopenharmony_civoid atl1e_hw_set_mac_addr(struct atl1e_hw *hw);
318c2ecf20Sopenharmony_cibool atl1e_read_eeprom(struct atl1e_hw *hw, u32 offset, u32 *p_value);
328c2ecf20Sopenharmony_cibool atl1e_write_eeprom(struct atl1e_hw *hw, u32 offset, u32 value);
338c2ecf20Sopenharmony_cis32 atl1e_phy_enter_power_saving(struct atl1e_hw *hw);
348c2ecf20Sopenharmony_cis32 atl1e_phy_leave_power_saving(struct atl1e_hw *hw);
358c2ecf20Sopenharmony_cis32 atl1e_phy_init(struct atl1e_hw *hw);
368c2ecf20Sopenharmony_ciint atl1e_check_eeprom_exist(struct atl1e_hw *hw);
378c2ecf20Sopenharmony_civoid atl1e_force_ps(struct atl1e_hw *hw);
388c2ecf20Sopenharmony_cis32 atl1e_restart_autoneg(struct atl1e_hw *hw);
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* register definition */
418c2ecf20Sopenharmony_ci#define REG_PM_CTRLSTAT             0x44
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define REG_PCIE_CAP_LIST           0x58
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define REG_DEVICE_CAP              0x5C
468c2ecf20Sopenharmony_ci#define     DEVICE_CAP_MAX_PAYLOAD_MASK     0x7
478c2ecf20Sopenharmony_ci#define     DEVICE_CAP_MAX_PAYLOAD_SHIFT    0
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#define REG_DEVICE_CTRL             0x60
508c2ecf20Sopenharmony_ci#define     DEVICE_CTRL_MAX_PAYLOAD_MASK    0x7
518c2ecf20Sopenharmony_ci#define     DEVICE_CTRL_MAX_PAYLOAD_SHIFT   5
528c2ecf20Sopenharmony_ci#define     DEVICE_CTRL_MAX_RREQ_SZ_MASK    0x7
538c2ecf20Sopenharmony_ci#define     DEVICE_CTRL_MAX_RREQ_SZ_SHIFT   12
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci#define REG_VPD_CAP                 0x6C
568c2ecf20Sopenharmony_ci#define     VPD_CAP_ID_MASK                 0xff
578c2ecf20Sopenharmony_ci#define     VPD_CAP_ID_SHIFT                0
588c2ecf20Sopenharmony_ci#define     VPD_CAP_NEXT_PTR_MASK           0xFF
598c2ecf20Sopenharmony_ci#define     VPD_CAP_NEXT_PTR_SHIFT          8
608c2ecf20Sopenharmony_ci#define     VPD_CAP_VPD_ADDR_MASK           0x7FFF
618c2ecf20Sopenharmony_ci#define     VPD_CAP_VPD_ADDR_SHIFT          16
628c2ecf20Sopenharmony_ci#define     VPD_CAP_VPD_FLAG                0x80000000
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci#define REG_VPD_DATA                0x70
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_CTRL          0x200
678c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_STS_NON_RDY      0x1
688c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_STS_WEN          0x2
698c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_STS_WPEN         0x80
708c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_DEV_STS_MASK     0xFF
718c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_DEV_STS_SHIFT    0
728c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_INS_MASK         0x7
738c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_INS_SHIFT        8
748c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_START            0x800
758c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_EN_VPD           0x2000
768c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_LDSTART          0x8000
778c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CS_HI_MASK       0x3
788c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CS_HI_SHIFT      16
798c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CS_HOLD_MASK     0x3
808c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CS_HOLD_SHIFT    18
818c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CLK_LO_MASK      0x3
828c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CLK_LO_SHIFT     20
838c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CLK_HI_MASK      0x3
848c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CLK_HI_SHIFT     22
858c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CS_SETUP_MASK    0x3
868c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_CS_SETUP_SHIFT   24
878c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_EROM_PGSZ_MASK   0x3
888c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_EROM_PGSZ_SHIFT  26
898c2ecf20Sopenharmony_ci#define     SPI_FLASH_CTRL_WAIT_READY       0x10000000
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define REG_SPI_ADDR                0x204
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define REG_SPI_DATA                0x208
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_CONFIG        0x20C
968c2ecf20Sopenharmony_ci#define     SPI_FLASH_CONFIG_LD_ADDR_MASK   0xFFFFFF
978c2ecf20Sopenharmony_ci#define     SPI_FLASH_CONFIG_LD_ADDR_SHIFT  0
988c2ecf20Sopenharmony_ci#define     SPI_FLASH_CONFIG_VPD_ADDR_MASK  0x3
998c2ecf20Sopenharmony_ci#define     SPI_FLASH_CONFIG_VPD_ADDR_SHIFT 24
1008c2ecf20Sopenharmony_ci#define     SPI_FLASH_CONFIG_LD_EXIST       0x4000000
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_OP_PROGRAM    0x210
1048c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_OP_SC_ERASE   0x211
1058c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_OP_CHIP_ERASE 0x212
1068c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_OP_RDID       0x213
1078c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_OP_WREN       0x214
1088c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_OP_RDSR       0x215
1098c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_OP_WRSR       0x216
1108c2ecf20Sopenharmony_ci#define REG_SPI_FLASH_OP_READ       0x217
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#define REG_TWSI_CTRL               0x218
1138c2ecf20Sopenharmony_ci#define     TWSI_CTRL_LD_OFFSET_MASK        0xFF
1148c2ecf20Sopenharmony_ci#define     TWSI_CTRL_LD_OFFSET_SHIFT       0
1158c2ecf20Sopenharmony_ci#define     TWSI_CTRL_LD_SLV_ADDR_MASK      0x7
1168c2ecf20Sopenharmony_ci#define     TWSI_CTRL_LD_SLV_ADDR_SHIFT     8
1178c2ecf20Sopenharmony_ci#define     TWSI_CTRL_SW_LDSTART            0x800
1188c2ecf20Sopenharmony_ci#define     TWSI_CTRL_HW_LDSTART            0x1000
1198c2ecf20Sopenharmony_ci#define     TWSI_CTRL_SMB_SLV_ADDR_MASK     0x7F
1208c2ecf20Sopenharmony_ci#define     TWSI_CTRL_SMB_SLV_ADDR_SHIFT    15
1218c2ecf20Sopenharmony_ci#define     TWSI_CTRL_LD_EXIST              0x400000
1228c2ecf20Sopenharmony_ci#define     TWSI_CTRL_READ_FREQ_SEL_MASK    0x3
1238c2ecf20Sopenharmony_ci#define     TWSI_CTRL_READ_FREQ_SEL_SHIFT   23
1248c2ecf20Sopenharmony_ci#define     TWSI_CTRL_FREQ_SEL_100K         0
1258c2ecf20Sopenharmony_ci#define     TWSI_CTRL_FREQ_SEL_200K         1
1268c2ecf20Sopenharmony_ci#define     TWSI_CTRL_FREQ_SEL_300K         2
1278c2ecf20Sopenharmony_ci#define     TWSI_CTRL_FREQ_SEL_400K         3
1288c2ecf20Sopenharmony_ci#define     TWSI_CTRL_SMB_SLV_ADDR
1298c2ecf20Sopenharmony_ci#define     TWSI_CTRL_WRITE_FREQ_SEL_MASK   0x3
1308c2ecf20Sopenharmony_ci#define     TWSI_CTRL_WRITE_FREQ_SEL_SHIFT  24
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define REG_PCIE_DEV_MISC_CTRL      0x21C
1348c2ecf20Sopenharmony_ci#define     PCIE_DEV_MISC_CTRL_EXT_PIPE     0x2
1358c2ecf20Sopenharmony_ci#define     PCIE_DEV_MISC_CTRL_RETRY_BUFDIS 0x1
1368c2ecf20Sopenharmony_ci#define     PCIE_DEV_MISC_CTRL_SPIROM_EXIST 0x4
1378c2ecf20Sopenharmony_ci#define     PCIE_DEV_MISC_CTRL_SERDES_ENDIAN    0x8
1388c2ecf20Sopenharmony_ci#define     PCIE_DEV_MISC_CTRL_SERDES_SEL_DIN   0x10
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci#define REG_PCIE_PHYMISC	    0x1000
1418c2ecf20Sopenharmony_ci#define PCIE_PHYMISC_FORCE_RCV_DET	0x4
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci#define REG_LTSSM_TEST_MODE         0x12FC
1448c2ecf20Sopenharmony_ci#define         LTSSM_TEST_MODE_DEF     0xE000
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci/* Selene Master Control Register */
1478c2ecf20Sopenharmony_ci#define REG_MASTER_CTRL             0x1400
1488c2ecf20Sopenharmony_ci#define     MASTER_CTRL_SOFT_RST            0x1
1498c2ecf20Sopenharmony_ci#define     MASTER_CTRL_MTIMER_EN           0x2
1508c2ecf20Sopenharmony_ci#define     MASTER_CTRL_ITIMER_EN           0x4
1518c2ecf20Sopenharmony_ci#define     MASTER_CTRL_MANUAL_INT          0x8
1528c2ecf20Sopenharmony_ci#define     MASTER_CTRL_ITIMER2_EN          0x20
1538c2ecf20Sopenharmony_ci#define     MASTER_CTRL_INT_RDCLR           0x40
1548c2ecf20Sopenharmony_ci#define     MASTER_CTRL_LED_MODE	    0x200
1558c2ecf20Sopenharmony_ci#define     MASTER_CTRL_REV_NUM_SHIFT       16
1568c2ecf20Sopenharmony_ci#define     MASTER_CTRL_REV_NUM_MASK        0xff
1578c2ecf20Sopenharmony_ci#define     MASTER_CTRL_DEV_ID_SHIFT        24
1588c2ecf20Sopenharmony_ci#define     MASTER_CTRL_DEV_ID_MASK         0xff
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci/* Timer Initial Value Register */
1618c2ecf20Sopenharmony_ci#define REG_MANUAL_TIMER_INIT       0x1404
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci/* IRQ ModeratorTimer Initial Value Register */
1658c2ecf20Sopenharmony_ci#define REG_IRQ_MODU_TIMER_INIT     0x1408   /* w */
1668c2ecf20Sopenharmony_ci#define REG_IRQ_MODU_TIMER2_INIT    0x140A   /* w */
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci#define REG_GPHY_CTRL               0x140C
1708c2ecf20Sopenharmony_ci#define     GPHY_CTRL_EXT_RESET         1
1718c2ecf20Sopenharmony_ci#define     GPHY_CTRL_PIPE_MOD          2
1728c2ecf20Sopenharmony_ci#define     GPHY_CTRL_TEST_MODE_MASK    3
1738c2ecf20Sopenharmony_ci#define     GPHY_CTRL_TEST_MODE_SHIFT   2
1748c2ecf20Sopenharmony_ci#define     GPHY_CTRL_BERT_START        0x10
1758c2ecf20Sopenharmony_ci#define     GPHY_CTRL_GATE_25M_EN       0x20
1768c2ecf20Sopenharmony_ci#define     GPHY_CTRL_LPW_EXIT          0x40
1778c2ecf20Sopenharmony_ci#define     GPHY_CTRL_PHY_IDDQ          0x80
1788c2ecf20Sopenharmony_ci#define     GPHY_CTRL_PHY_IDDQ_DIS      0x100
1798c2ecf20Sopenharmony_ci#define     GPHY_CTRL_PCLK_SEL_DIS      0x200
1808c2ecf20Sopenharmony_ci#define     GPHY_CTRL_HIB_EN            0x400
1818c2ecf20Sopenharmony_ci#define     GPHY_CTRL_HIB_PULSE         0x800
1828c2ecf20Sopenharmony_ci#define     GPHY_CTRL_SEL_ANA_RST       0x1000
1838c2ecf20Sopenharmony_ci#define     GPHY_CTRL_PHY_PLL_ON        0x2000
1848c2ecf20Sopenharmony_ci#define     GPHY_CTRL_PWDOWN_HW		0x4000
1858c2ecf20Sopenharmony_ci#define     GPHY_CTRL_DEFAULT (\
1868c2ecf20Sopenharmony_ci		GPHY_CTRL_PHY_PLL_ON	|\
1878c2ecf20Sopenharmony_ci		GPHY_CTRL_SEL_ANA_RST	|\
1888c2ecf20Sopenharmony_ci		GPHY_CTRL_HIB_PULSE	|\
1898c2ecf20Sopenharmony_ci		GPHY_CTRL_HIB_EN)
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci#define     GPHY_CTRL_PW_WOL_DIS (\
1928c2ecf20Sopenharmony_ci		GPHY_CTRL_PHY_PLL_ON	|\
1938c2ecf20Sopenharmony_ci		GPHY_CTRL_SEL_ANA_RST	|\
1948c2ecf20Sopenharmony_ci		GPHY_CTRL_HIB_PULSE	|\
1958c2ecf20Sopenharmony_ci		GPHY_CTRL_HIB_EN	|\
1968c2ecf20Sopenharmony_ci		GPHY_CTRL_PWDOWN_HW	|\
1978c2ecf20Sopenharmony_ci		GPHY_CTRL_PCLK_SEL_DIS	|\
1988c2ecf20Sopenharmony_ci		GPHY_CTRL_PHY_IDDQ)
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/* IRQ Anti-Lost Timer Initial Value Register */
2018c2ecf20Sopenharmony_ci#define REG_CMBDISDMA_TIMER         0x140E
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci/* Block IDLE Status Register */
2058c2ecf20Sopenharmony_ci#define REG_IDLE_STATUS  	0x1410
2068c2ecf20Sopenharmony_ci#define     IDLE_STATUS_RXMAC       1    /* 1: RXMAC state machine is in non-IDLE state. 0: RXMAC is idling */
2078c2ecf20Sopenharmony_ci#define     IDLE_STATUS_TXMAC       2    /* 1: TXMAC state machine is in non-IDLE state. 0: TXMAC is idling */
2088c2ecf20Sopenharmony_ci#define     IDLE_STATUS_RXQ         4    /* 1: RXQ state machine is in non-IDLE state.   0: RXQ is idling   */
2098c2ecf20Sopenharmony_ci#define     IDLE_STATUS_TXQ         8    /* 1: TXQ state machine is in non-IDLE state.   0: TXQ is idling   */
2108c2ecf20Sopenharmony_ci#define     IDLE_STATUS_DMAR        0x10 /* 1: DMAR state machine is in non-IDLE state.  0: DMAR is idling  */
2118c2ecf20Sopenharmony_ci#define     IDLE_STATUS_DMAW        0x20 /* 1: DMAW state machine is in non-IDLE state.  0: DMAW is idling  */
2128c2ecf20Sopenharmony_ci#define     IDLE_STATUS_SMB         0x40 /* 1: SMB state machine is in non-IDLE state.   0: SMB is idling   */
2138c2ecf20Sopenharmony_ci#define     IDLE_STATUS_CMB         0x80 /* 1: CMB state machine is in non-IDLE state.   0: CMB is idling   */
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci/* MDIO Control Register */
2168c2ecf20Sopenharmony_ci#define REG_MDIO_CTRL           0x1414
2178c2ecf20Sopenharmony_ci#define     MDIO_DATA_MASK          0xffff  /* On MDIO write, the 16-bit control data to write to PHY MII management register */
2188c2ecf20Sopenharmony_ci#define     MDIO_DATA_SHIFT         0       /* On MDIO read, the 16-bit status data that was read from the PHY MII management register*/
2198c2ecf20Sopenharmony_ci#define     MDIO_REG_ADDR_MASK      0x1f    /* MDIO register address */
2208c2ecf20Sopenharmony_ci#define     MDIO_REG_ADDR_SHIFT     16
2218c2ecf20Sopenharmony_ci#define     MDIO_RW                 0x200000      /* 1: read, 0: write */
2228c2ecf20Sopenharmony_ci#define     MDIO_SUP_PREAMBLE       0x400000      /* Suppress preamble */
2238c2ecf20Sopenharmony_ci#define     MDIO_START              0x800000      /* Write 1 to initiate the MDIO master. And this bit is self cleared after one cycle*/
2248c2ecf20Sopenharmony_ci#define     MDIO_CLK_SEL_SHIFT      24
2258c2ecf20Sopenharmony_ci#define     MDIO_CLK_25_4           0
2268c2ecf20Sopenharmony_ci#define     MDIO_CLK_25_6           2
2278c2ecf20Sopenharmony_ci#define     MDIO_CLK_25_8           3
2288c2ecf20Sopenharmony_ci#define     MDIO_CLK_25_10          4
2298c2ecf20Sopenharmony_ci#define     MDIO_CLK_25_14          5
2308c2ecf20Sopenharmony_ci#define     MDIO_CLK_25_20          6
2318c2ecf20Sopenharmony_ci#define     MDIO_CLK_25_28          7
2328c2ecf20Sopenharmony_ci#define     MDIO_BUSY               0x8000000
2338c2ecf20Sopenharmony_ci#define     MDIO_AP_EN              0x10000000
2348c2ecf20Sopenharmony_ci#define MDIO_WAIT_TIMES         10
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci/* MII PHY Status Register */
2378c2ecf20Sopenharmony_ci#define REG_PHY_STATUS           0x1418
2388c2ecf20Sopenharmony_ci#define     PHY_STATUS_100M	      0x20000
2398c2ecf20Sopenharmony_ci#define     PHY_STATUS_EMI_CA	      0x40000
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci/* BIST Control and Status Register0 (for the Packet Memory) */
2428c2ecf20Sopenharmony_ci#define REG_BIST0_CTRL              0x141c
2438c2ecf20Sopenharmony_ci#define     BIST0_NOW                   0x1 /* 1: To trigger BIST0 logic. This bit stays high during the */
2448c2ecf20Sopenharmony_ci/* BIST process and reset to zero when BIST is done */
2458c2ecf20Sopenharmony_ci#define     BIST0_SRAM_FAIL             0x2 /* 1: The SRAM failure is un-repairable because it has address */
2468c2ecf20Sopenharmony_ci/* decoder failure or more than 1 cell stuck-to-x failure */
2478c2ecf20Sopenharmony_ci#define     BIST0_FUSE_FLAG             0x4 /* 1: Indicating one cell has been fixed */
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci/* BIST Control and Status Register1(for the retry buffer of PCI Express) */
2508c2ecf20Sopenharmony_ci#define REG_BIST1_CTRL              0x1420
2518c2ecf20Sopenharmony_ci#define     BIST1_NOW                   0x1 /* 1: To trigger BIST0 logic. This bit stays high during the */
2528c2ecf20Sopenharmony_ci/* BIST process and reset to zero when BIST is done */
2538c2ecf20Sopenharmony_ci#define     BIST1_SRAM_FAIL             0x2 /* 1: The SRAM failure is un-repairable because it has address */
2548c2ecf20Sopenharmony_ci/* decoder failure or more than 1 cell stuck-to-x failure.*/
2558c2ecf20Sopenharmony_ci#define     BIST1_FUSE_FLAG             0x4
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci/* SerDes Lock Detect Control and Status Register */
2588c2ecf20Sopenharmony_ci#define REG_SERDES_LOCK             0x1424
2598c2ecf20Sopenharmony_ci#define     SERDES_LOCK_DETECT          1  /* 1: SerDes lock detected . This signal comes from Analog SerDes */
2608c2ecf20Sopenharmony_ci#define     SERDES_LOCK_DETECT_EN       2  /* 1: Enable SerDes Lock detect function */
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci/* MAC Control Register  */
2638c2ecf20Sopenharmony_ci#define REG_MAC_CTRL                0x1480
2648c2ecf20Sopenharmony_ci#define     MAC_CTRL_TX_EN              1  /* 1: Transmit Enable */
2658c2ecf20Sopenharmony_ci#define     MAC_CTRL_RX_EN              2  /* 1: Receive Enable */
2668c2ecf20Sopenharmony_ci#define     MAC_CTRL_TX_FLOW            4  /* 1: Transmit Flow Control Enable */
2678c2ecf20Sopenharmony_ci#define     MAC_CTRL_RX_FLOW            8  /* 1: Receive Flow Control Enable */
2688c2ecf20Sopenharmony_ci#define     MAC_CTRL_LOOPBACK           0x10      /* 1: Loop back at G/MII Interface */
2698c2ecf20Sopenharmony_ci#define     MAC_CTRL_DUPLX              0x20      /* 1: Full-duplex mode  0: Half-duplex mode */
2708c2ecf20Sopenharmony_ci#define     MAC_CTRL_ADD_CRC            0x40      /* 1: Instruct MAC to attach CRC on all egress Ethernet frames */
2718c2ecf20Sopenharmony_ci#define     MAC_CTRL_PAD                0x80      /* 1: Instruct MAC to pad short frames to 60-bytes, and then attach CRC. This bit has higher priority over CRC_EN */
2728c2ecf20Sopenharmony_ci#define     MAC_CTRL_LENCHK             0x100     /* 1: Instruct MAC to check if length field matches the real packet length */
2738c2ecf20Sopenharmony_ci#define     MAC_CTRL_HUGE_EN            0x200     /* 1: receive Jumbo frame enable */
2748c2ecf20Sopenharmony_ci#define     MAC_CTRL_PRMLEN_SHIFT       10        /* Preamble length */
2758c2ecf20Sopenharmony_ci#define     MAC_CTRL_PRMLEN_MASK        0xf
2768c2ecf20Sopenharmony_ci#define     MAC_CTRL_RMV_VLAN           0x4000    /* 1: to remove VLAN Tag automatically from all receive packets */
2778c2ecf20Sopenharmony_ci#define     MAC_CTRL_PROMIS_EN          0x8000    /* 1: Promiscuous Mode Enable */
2788c2ecf20Sopenharmony_ci#define     MAC_CTRL_TX_PAUSE           0x10000   /* 1: transmit test pause */
2798c2ecf20Sopenharmony_ci#define     MAC_CTRL_SCNT               0x20000   /* 1: shortcut slot time counter */
2808c2ecf20Sopenharmony_ci#define     MAC_CTRL_SRST_TX            0x40000   /* 1: synchronized reset Transmit MAC module */
2818c2ecf20Sopenharmony_ci#define     MAC_CTRL_TX_SIMURST         0x80000   /* 1: transmit simulation reset */
2828c2ecf20Sopenharmony_ci#define     MAC_CTRL_SPEED_SHIFT        20        /* 10: gigabit 01:10M/100M */
2838c2ecf20Sopenharmony_ci#define     MAC_CTRL_SPEED_MASK         0x300000
2848c2ecf20Sopenharmony_ci#define     MAC_CTRL_SPEED_1000         2
2858c2ecf20Sopenharmony_ci#define     MAC_CTRL_SPEED_10_100       1
2868c2ecf20Sopenharmony_ci#define     MAC_CTRL_DBG_TX_BKPRESURE   0x400000  /* 1: transmit maximum backoff (half-duplex test bit) */
2878c2ecf20Sopenharmony_ci#define     MAC_CTRL_TX_HUGE            0x800000  /* 1: transmit huge enable */
2888c2ecf20Sopenharmony_ci#define     MAC_CTRL_RX_CHKSUM_EN       0x1000000 /* 1: RX checksum enable */
2898c2ecf20Sopenharmony_ci#define     MAC_CTRL_MC_ALL_EN          0x2000000 /* 1: upload all multicast frame without error to system */
2908c2ecf20Sopenharmony_ci#define     MAC_CTRL_BC_EN              0x4000000 /* 1: upload all broadcast frame without error to system */
2918c2ecf20Sopenharmony_ci#define     MAC_CTRL_DBG                0x8000000 /* 1: upload all received frame to system (Debug Mode) */
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci/* MAC IPG/IFG Control Register  */
2948c2ecf20Sopenharmony_ci#define REG_MAC_IPG_IFG             0x1484
2958c2ecf20Sopenharmony_ci#define     MAC_IPG_IFG_IPGT_SHIFT      0     /* Desired back to back inter-packet gap. The default is 96-bit time */
2968c2ecf20Sopenharmony_ci#define     MAC_IPG_IFG_IPGT_MASK       0x7f
2978c2ecf20Sopenharmony_ci#define     MAC_IPG_IFG_MIFG_SHIFT      8     /* Minimum number of IFG to enforce in between RX frames */
2988c2ecf20Sopenharmony_ci#define     MAC_IPG_IFG_MIFG_MASK       0xff  /* Frame gap below such IFP is dropped */
2998c2ecf20Sopenharmony_ci#define     MAC_IPG_IFG_IPGR1_SHIFT     16    /* 64bit Carrier-Sense window */
3008c2ecf20Sopenharmony_ci#define     MAC_IPG_IFG_IPGR1_MASK      0x7f
3018c2ecf20Sopenharmony_ci#define     MAC_IPG_IFG_IPGR2_SHIFT     24    /* 96-bit IPG window */
3028c2ecf20Sopenharmony_ci#define     MAC_IPG_IFG_IPGR2_MASK      0x7f
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci/* MAC STATION ADDRESS  */
3058c2ecf20Sopenharmony_ci#define REG_MAC_STA_ADDR            0x1488
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci/* Hash table for multicast address */
3088c2ecf20Sopenharmony_ci#define REG_RX_HASH_TABLE           0x1490
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci/* MAC Half-Duplex Control Register */
3128c2ecf20Sopenharmony_ci#define REG_MAC_HALF_DUPLX_CTRL     0x1498
3138c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_LCOL_SHIFT   0      /* Collision Window */
3148c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_LCOL_MASK    0x3ff
3158c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_RETRY_SHIFT  12     /* Retransmission maximum, afterwards the packet will be discarded */
3168c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_RETRY_MASK   0xf
3178c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_EXC_DEF_EN   0x10000 /* 1: Allow the transmission of a packet which has been excessively deferred */
3188c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_NO_BACK_C    0x20000 /* 1: No back-off on collision, immediately start the retransmission */
3198c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_NO_BACK_P    0x40000 /* 1: No back-off on backpressure, immediately start the transmission after back pressure */
3208c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_ABEBE        0x80000 /* 1: Alternative Binary Exponential Back-off Enabled */
3218c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_ABEBT_SHIFT  20      /* Maximum binary exponential number */
3228c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_ABEBT_MASK   0xf
3238c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_JAMIPG_SHIFT 24      /* IPG to start JAM for collision based flow control in half-duplex */
3248c2ecf20Sopenharmony_ci#define     MAC_HALF_DUPLX_CTRL_JAMIPG_MASK  0xf     /* mode. In unit of 8-bit time */
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci/* Maximum Frame Length Control Register   */
3278c2ecf20Sopenharmony_ci#define REG_MTU                     0x149c
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_ci/* Wake-On-Lan control register */
3308c2ecf20Sopenharmony_ci#define REG_WOL_CTRL                0x14a0
3318c2ecf20Sopenharmony_ci#define     WOL_PATTERN_EN                  0x00000001
3328c2ecf20Sopenharmony_ci#define     WOL_PATTERN_PME_EN              0x00000002
3338c2ecf20Sopenharmony_ci#define     WOL_MAGIC_EN                    0x00000004
3348c2ecf20Sopenharmony_ci#define     WOL_MAGIC_PME_EN                0x00000008
3358c2ecf20Sopenharmony_ci#define     WOL_LINK_CHG_EN                 0x00000010
3368c2ecf20Sopenharmony_ci#define     WOL_LINK_CHG_PME_EN             0x00000020
3378c2ecf20Sopenharmony_ci#define     WOL_PATTERN_ST                  0x00000100
3388c2ecf20Sopenharmony_ci#define     WOL_MAGIC_ST                    0x00000200
3398c2ecf20Sopenharmony_ci#define     WOL_LINKCHG_ST                  0x00000400
3408c2ecf20Sopenharmony_ci#define     WOL_CLK_SWITCH_EN               0x00008000
3418c2ecf20Sopenharmony_ci#define     WOL_PT0_EN                      0x00010000
3428c2ecf20Sopenharmony_ci#define     WOL_PT1_EN                      0x00020000
3438c2ecf20Sopenharmony_ci#define     WOL_PT2_EN                      0x00040000
3448c2ecf20Sopenharmony_ci#define     WOL_PT3_EN                      0x00080000
3458c2ecf20Sopenharmony_ci#define     WOL_PT4_EN                      0x00100000
3468c2ecf20Sopenharmony_ci#define     WOL_PT5_EN                      0x00200000
3478c2ecf20Sopenharmony_ci#define     WOL_PT6_EN                      0x00400000
3488c2ecf20Sopenharmony_ci/* WOL Length ( 2 DWORD ) */
3498c2ecf20Sopenharmony_ci#define REG_WOL_PATTERN_LEN         0x14a4
3508c2ecf20Sopenharmony_ci#define     WOL_PT_LEN_MASK                 0x7f
3518c2ecf20Sopenharmony_ci#define     WOL_PT0_LEN_SHIFT               0
3528c2ecf20Sopenharmony_ci#define     WOL_PT1_LEN_SHIFT               8
3538c2ecf20Sopenharmony_ci#define     WOL_PT2_LEN_SHIFT               16
3548c2ecf20Sopenharmony_ci#define     WOL_PT3_LEN_SHIFT               24
3558c2ecf20Sopenharmony_ci#define     WOL_PT4_LEN_SHIFT               0
3568c2ecf20Sopenharmony_ci#define     WOL_PT5_LEN_SHIFT               8
3578c2ecf20Sopenharmony_ci#define     WOL_PT6_LEN_SHIFT               16
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ci/* Internal SRAM Partition Register */
3608c2ecf20Sopenharmony_ci#define REG_SRAM_TRD_ADDR           0x1518
3618c2ecf20Sopenharmony_ci#define REG_SRAM_TRD_LEN            0x151C
3628c2ecf20Sopenharmony_ci#define REG_SRAM_RXF_ADDR           0x1520
3638c2ecf20Sopenharmony_ci#define REG_SRAM_RXF_LEN            0x1524
3648c2ecf20Sopenharmony_ci#define REG_SRAM_TXF_ADDR           0x1528
3658c2ecf20Sopenharmony_ci#define REG_SRAM_TXF_LEN            0x152C
3668c2ecf20Sopenharmony_ci#define REG_SRAM_TCPH_ADDR          0x1530
3678c2ecf20Sopenharmony_ci#define REG_SRAM_PKTH_ADDR          0x1532
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci/* Load Ptr Register */
3708c2ecf20Sopenharmony_ci#define REG_LOAD_PTR                0x1534  /* Software sets this bit after the initialization of the head and tail */
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci/*
3738c2ecf20Sopenharmony_ci * addresses of all descriptors, as well as the following descriptor
3748c2ecf20Sopenharmony_ci * control register, which triggers each function block to load the head
3758c2ecf20Sopenharmony_ci * pointer to prepare for the operation. This bit is then self-cleared
3768c2ecf20Sopenharmony_ci * after one cycle.
3778c2ecf20Sopenharmony_ci */
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci/* Descriptor Control register  */
3808c2ecf20Sopenharmony_ci#define REG_RXF3_BASE_ADDR_HI           0x153C
3818c2ecf20Sopenharmony_ci#define REG_DESC_BASE_ADDR_HI           0x1540
3828c2ecf20Sopenharmony_ci#define REG_RXF0_BASE_ADDR_HI           0x1540 /* share with DESC BASE ADDR HI */
3838c2ecf20Sopenharmony_ci#define REG_HOST_RXF0_PAGE0_LO          0x1544
3848c2ecf20Sopenharmony_ci#define REG_HOST_RXF0_PAGE1_LO          0x1548
3858c2ecf20Sopenharmony_ci#define REG_TPD_BASE_ADDR_LO            0x154C
3868c2ecf20Sopenharmony_ci#define REG_RXF1_BASE_ADDR_HI           0x1550
3878c2ecf20Sopenharmony_ci#define REG_RXF2_BASE_ADDR_HI           0x1554
3888c2ecf20Sopenharmony_ci#define REG_HOST_RXFPAGE_SIZE           0x1558
3898c2ecf20Sopenharmony_ci#define REG_TPD_RING_SIZE               0x155C
3908c2ecf20Sopenharmony_ci/* RSS about */
3918c2ecf20Sopenharmony_ci#define REG_RSS_KEY0                    0x14B0
3928c2ecf20Sopenharmony_ci#define REG_RSS_KEY1                    0x14B4
3938c2ecf20Sopenharmony_ci#define REG_RSS_KEY2                    0x14B8
3948c2ecf20Sopenharmony_ci#define REG_RSS_KEY3                    0x14BC
3958c2ecf20Sopenharmony_ci#define REG_RSS_KEY4                    0x14C0
3968c2ecf20Sopenharmony_ci#define REG_RSS_KEY5                    0x14C4
3978c2ecf20Sopenharmony_ci#define REG_RSS_KEY6                    0x14C8
3988c2ecf20Sopenharmony_ci#define REG_RSS_KEY7                    0x14CC
3998c2ecf20Sopenharmony_ci#define REG_RSS_KEY8                    0x14D0
4008c2ecf20Sopenharmony_ci#define REG_RSS_KEY9                    0x14D4
4018c2ecf20Sopenharmony_ci#define REG_IDT_TABLE4                  0x14E0
4028c2ecf20Sopenharmony_ci#define REG_IDT_TABLE5                  0x14E4
4038c2ecf20Sopenharmony_ci#define REG_IDT_TABLE6                  0x14E8
4048c2ecf20Sopenharmony_ci#define REG_IDT_TABLE7                  0x14EC
4058c2ecf20Sopenharmony_ci#define REG_IDT_TABLE0                  0x1560
4068c2ecf20Sopenharmony_ci#define REG_IDT_TABLE1                  0x1564
4078c2ecf20Sopenharmony_ci#define REG_IDT_TABLE2                  0x1568
4088c2ecf20Sopenharmony_ci#define REG_IDT_TABLE3                  0x156C
4098c2ecf20Sopenharmony_ci#define REG_IDT_TABLE                   REG_IDT_TABLE0
4108c2ecf20Sopenharmony_ci#define REG_RSS_HASH_VALUE              0x1570
4118c2ecf20Sopenharmony_ci#define REG_RSS_HASH_FLAG               0x1574
4128c2ecf20Sopenharmony_ci#define REG_BASE_CPU_NUMBER             0x157C
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci/* TXQ Control Register */
4168c2ecf20Sopenharmony_ci#define REG_TXQ_CTRL                0x1580
4178c2ecf20Sopenharmony_ci#define     TXQ_CTRL_NUM_TPD_BURST_MASK     0xF
4188c2ecf20Sopenharmony_ci#define     TXQ_CTRL_NUM_TPD_BURST_SHIFT    0
4198c2ecf20Sopenharmony_ci#define     TXQ_CTRL_EN                     0x20  /* 1: Enable TXQ */
4208c2ecf20Sopenharmony_ci#define     TXQ_CTRL_ENH_MODE               0x40  /* Performance enhancement mode, in which up to two back-to-back DMA read commands might be dispatched. */
4218c2ecf20Sopenharmony_ci#define     TXQ_CTRL_TXF_BURST_NUM_SHIFT    16    /* Number of data byte to read in a cache-aligned burst. Each SRAM entry is 8-byte in length. */
4228c2ecf20Sopenharmony_ci#define     TXQ_CTRL_TXF_BURST_NUM_MASK     0xffff
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci/* Jumbo packet Threshold for task offload */
4258c2ecf20Sopenharmony_ci#define REG_TX_EARLY_TH                     0x1584 /* Jumbo frame threshold in QWORD unit. Packet greater than */
4268c2ecf20Sopenharmony_ci/* JUMBO_TASK_OFFLOAD_THRESHOLD will not be task offloaded. */
4278c2ecf20Sopenharmony_ci#define     TX_TX_EARLY_TH_MASK             0x7ff
4288c2ecf20Sopenharmony_ci#define     TX_TX_EARLY_TH_SHIFT            0
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci/* RXQ Control Register */
4328c2ecf20Sopenharmony_ci#define REG_RXQ_CTRL                0x15A0
4338c2ecf20Sopenharmony_ci#define         RXQ_CTRL_PBA_ALIGN_32                   0   /* rx-packet alignment */
4348c2ecf20Sopenharmony_ci#define         RXQ_CTRL_PBA_ALIGN_64                   1
4358c2ecf20Sopenharmony_ci#define         RXQ_CTRL_PBA_ALIGN_128                  2
4368c2ecf20Sopenharmony_ci#define         RXQ_CTRL_PBA_ALIGN_256                  3
4378c2ecf20Sopenharmony_ci#define         RXQ_CTRL_Q1_EN				0x10
4388c2ecf20Sopenharmony_ci#define         RXQ_CTRL_Q2_EN				0x20
4398c2ecf20Sopenharmony_ci#define         RXQ_CTRL_Q3_EN				0x40
4408c2ecf20Sopenharmony_ci#define         RXQ_CTRL_IPV6_XSUM_VERIFY_EN		0x80
4418c2ecf20Sopenharmony_ci#define         RXQ_CTRL_HASH_TLEN_SHIFT                8
4428c2ecf20Sopenharmony_ci#define         RXQ_CTRL_HASH_TLEN_MASK                 0xFF
4438c2ecf20Sopenharmony_ci#define         RXQ_CTRL_HASH_TYPE_IPV4                 0x10000
4448c2ecf20Sopenharmony_ci#define         RXQ_CTRL_HASH_TYPE_IPV4_TCP             0x20000
4458c2ecf20Sopenharmony_ci#define         RXQ_CTRL_HASH_TYPE_IPV6                 0x40000
4468c2ecf20Sopenharmony_ci#define         RXQ_CTRL_HASH_TYPE_IPV6_TCP             0x80000
4478c2ecf20Sopenharmony_ci#define         RXQ_CTRL_RSS_MODE_DISABLE               0
4488c2ecf20Sopenharmony_ci#define         RXQ_CTRL_RSS_MODE_SQSINT                0x4000000
4498c2ecf20Sopenharmony_ci#define         RXQ_CTRL_RSS_MODE_MQUESINT              0x8000000
4508c2ecf20Sopenharmony_ci#define         RXQ_CTRL_RSS_MODE_MQUEMINT              0xC000000
4518c2ecf20Sopenharmony_ci#define         RXQ_CTRL_NIP_QUEUE_SEL_TBL              0x10000000
4528c2ecf20Sopenharmony_ci#define         RXQ_CTRL_HASH_ENABLE                    0x20000000
4538c2ecf20Sopenharmony_ci#define         RXQ_CTRL_CUT_THRU_EN                    0x40000000
4548c2ecf20Sopenharmony_ci#define         RXQ_CTRL_EN                             0x80000000
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ci/* Rx jumbo packet threshold and rrd  retirement timer  */
4578c2ecf20Sopenharmony_ci#define REG_RXQ_JMBOSZ_RRDTIM       0x15A4
4588c2ecf20Sopenharmony_ci/*
4598c2ecf20Sopenharmony_ci * Jumbo packet threshold for non-VLAN packet, in QWORD (64-bit) unit.
4608c2ecf20Sopenharmony_ci * When the packet length greater than or equal to this value, RXQ
4618c2ecf20Sopenharmony_ci * shall start cut-through forwarding of the received packet.
4628c2ecf20Sopenharmony_ci */
4638c2ecf20Sopenharmony_ci#define         RXQ_JMBOSZ_TH_MASK      0x7ff
4648c2ecf20Sopenharmony_ci#define         RXQ_JMBOSZ_TH_SHIFT         0  /* RRD retirement timer. Decrement by 1 after every 512ns passes*/
4658c2ecf20Sopenharmony_ci#define         RXQ_JMBO_LKAH_MASK          0xf
4668c2ecf20Sopenharmony_ci#define         RXQ_JMBO_LKAH_SHIFT         11
4678c2ecf20Sopenharmony_ci
4688c2ecf20Sopenharmony_ci/* RXF flow control register */
4698c2ecf20Sopenharmony_ci#define REG_RXQ_RXF_PAUSE_THRESH    0x15A8
4708c2ecf20Sopenharmony_ci#define     RXQ_RXF_PAUSE_TH_HI_SHIFT       0
4718c2ecf20Sopenharmony_ci#define     RXQ_RXF_PAUSE_TH_HI_MASK        0xfff
4728c2ecf20Sopenharmony_ci#define     RXQ_RXF_PAUSE_TH_LO_SHIFT       16
4738c2ecf20Sopenharmony_ci#define     RXQ_RXF_PAUSE_TH_LO_MASK        0xfff
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci/* DMA Engine Control Register */
4778c2ecf20Sopenharmony_ci#define REG_DMA_CTRL                0x15C0
4788c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAR_IN_ORDER          0x1
4798c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAR_ENH_ORDER         0x2
4808c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAR_OUT_ORDER         0x4
4818c2ecf20Sopenharmony_ci#define     DMA_CTRL_RCB_VALUE              0x8
4828c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAR_BURST_LEN_SHIFT   4
4838c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAR_BURST_LEN_MASK    7
4848c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAW_BURST_LEN_SHIFT   7
4858c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAW_BURST_LEN_MASK    7
4868c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAR_REQ_PRI           0x400
4878c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAR_DLY_CNT_MASK      0x1F
4888c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAR_DLY_CNT_SHIFT     11
4898c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAW_DLY_CNT_MASK      0xF
4908c2ecf20Sopenharmony_ci#define     DMA_CTRL_DMAW_DLY_CNT_SHIFT     16
4918c2ecf20Sopenharmony_ci#define     DMA_CTRL_TXCMB_EN               0x100000
4928c2ecf20Sopenharmony_ci#define     DMA_CTRL_RXCMB_EN				0x200000
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_ci/* CMB/SMB Control Register */
4968c2ecf20Sopenharmony_ci#define REG_SMB_STAT_TIMER                      0x15C4
4978c2ecf20Sopenharmony_ci#define REG_TRIG_RRD_THRESH                     0x15CA
4988c2ecf20Sopenharmony_ci#define REG_TRIG_TPD_THRESH                     0x15C8
4998c2ecf20Sopenharmony_ci#define REG_TRIG_TXTIMER                        0x15CC
5008c2ecf20Sopenharmony_ci#define REG_TRIG_RXTIMER                        0x15CE
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_ci/* HOST RXF Page 1,2,3 address */
5038c2ecf20Sopenharmony_ci#define REG_HOST_RXF1_PAGE0_LO                  0x15D0
5048c2ecf20Sopenharmony_ci#define REG_HOST_RXF1_PAGE1_LO                  0x15D4
5058c2ecf20Sopenharmony_ci#define REG_HOST_RXF2_PAGE0_LO                  0x15D8
5068c2ecf20Sopenharmony_ci#define REG_HOST_RXF2_PAGE1_LO                  0x15DC
5078c2ecf20Sopenharmony_ci#define REG_HOST_RXF3_PAGE0_LO                  0x15E0
5088c2ecf20Sopenharmony_ci#define REG_HOST_RXF3_PAGE1_LO                  0x15E4
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci/* Mail box */
5118c2ecf20Sopenharmony_ci#define REG_MB_RXF1_RADDR                       0x15B4
5128c2ecf20Sopenharmony_ci#define REG_MB_RXF2_RADDR                       0x15B8
5138c2ecf20Sopenharmony_ci#define REG_MB_RXF3_RADDR                       0x15BC
5148c2ecf20Sopenharmony_ci#define REG_MB_TPD_PROD_IDX                     0x15F0
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ci/* RXF-Page 0-3  PageNo & Valid bit */
5178c2ecf20Sopenharmony_ci#define REG_HOST_RXF0_PAGE0_VLD     0x15F4
5188c2ecf20Sopenharmony_ci#define     HOST_RXF_VALID              1
5198c2ecf20Sopenharmony_ci#define     HOST_RXF_PAGENO_SHIFT       1
5208c2ecf20Sopenharmony_ci#define     HOST_RXF_PAGENO_MASK        0x7F
5218c2ecf20Sopenharmony_ci#define REG_HOST_RXF0_PAGE1_VLD     0x15F5
5228c2ecf20Sopenharmony_ci#define REG_HOST_RXF1_PAGE0_VLD     0x15F6
5238c2ecf20Sopenharmony_ci#define REG_HOST_RXF1_PAGE1_VLD     0x15F7
5248c2ecf20Sopenharmony_ci#define REG_HOST_RXF2_PAGE0_VLD     0x15F8
5258c2ecf20Sopenharmony_ci#define REG_HOST_RXF2_PAGE1_VLD     0x15F9
5268c2ecf20Sopenharmony_ci#define REG_HOST_RXF3_PAGE0_VLD     0x15FA
5278c2ecf20Sopenharmony_ci#define REG_HOST_RXF3_PAGE1_VLD     0x15FB
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_ci/* Interrupt Status Register */
5308c2ecf20Sopenharmony_ci#define REG_ISR    0x1600
5318c2ecf20Sopenharmony_ci#define  ISR_SMB   		1
5328c2ecf20Sopenharmony_ci#define  ISR_TIMER		2       /* Interrupt when Timer is counted down to zero */
5338c2ecf20Sopenharmony_ci/*
5348c2ecf20Sopenharmony_ci * Software manual interrupt, for debug. Set when SW_MAN_INT_EN is set
5358c2ecf20Sopenharmony_ci * in Table 51 Selene Master Control Register (Offset 0x1400).
5368c2ecf20Sopenharmony_ci */
5378c2ecf20Sopenharmony_ci#define  ISR_MANUAL         	4
5388c2ecf20Sopenharmony_ci#define  ISR_HW_RXF_OV          8        /* RXF overflow interrupt */
5398c2ecf20Sopenharmony_ci#define  ISR_HOST_RXF0_OV       0x10
5408c2ecf20Sopenharmony_ci#define  ISR_HOST_RXF1_OV       0x20
5418c2ecf20Sopenharmony_ci#define  ISR_HOST_RXF2_OV       0x40
5428c2ecf20Sopenharmony_ci#define  ISR_HOST_RXF3_OV       0x80
5438c2ecf20Sopenharmony_ci#define  ISR_TXF_UN             0x100
5448c2ecf20Sopenharmony_ci#define  ISR_RX0_PAGE_FULL      0x200
5458c2ecf20Sopenharmony_ci#define  ISR_DMAR_TO_RST        0x400
5468c2ecf20Sopenharmony_ci#define  ISR_DMAW_TO_RST        0x800
5478c2ecf20Sopenharmony_ci#define  ISR_GPHY               0x1000
5488c2ecf20Sopenharmony_ci#define  ISR_TX_CREDIT          0x2000
5498c2ecf20Sopenharmony_ci#define  ISR_GPHY_LPW           0x4000    /* GPHY low power state interrupt */
5508c2ecf20Sopenharmony_ci#define  ISR_RX_PKT             0x10000   /* One packet received, triggered by RFD */
5518c2ecf20Sopenharmony_ci#define  ISR_TX_PKT             0x20000   /* One packet transmitted, triggered by TPD */
5528c2ecf20Sopenharmony_ci#define  ISR_TX_DMA             0x40000
5538c2ecf20Sopenharmony_ci#define  ISR_RX_PKT_1           0x80000
5548c2ecf20Sopenharmony_ci#define  ISR_RX_PKT_2           0x100000
5558c2ecf20Sopenharmony_ci#define  ISR_RX_PKT_3           0x200000
5568c2ecf20Sopenharmony_ci#define  ISR_MAC_RX             0x400000
5578c2ecf20Sopenharmony_ci#define  ISR_MAC_TX             0x800000
5588c2ecf20Sopenharmony_ci#define  ISR_UR_DETECTED        0x1000000
5598c2ecf20Sopenharmony_ci#define  ISR_FERR_DETECTED      0x2000000
5608c2ecf20Sopenharmony_ci#define  ISR_NFERR_DETECTED     0x4000000
5618c2ecf20Sopenharmony_ci#define  ISR_CERR_DETECTED      0x8000000
5628c2ecf20Sopenharmony_ci#define  ISR_PHY_LINKDOWN       0x10000000
5638c2ecf20Sopenharmony_ci#define  ISR_DIS_INT            0x80000000
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_ci
5668c2ecf20Sopenharmony_ci/* Interrupt Mask Register */
5678c2ecf20Sopenharmony_ci#define REG_IMR 0x1604
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci
5708c2ecf20Sopenharmony_ci#define IMR_NORMAL_MASK (\
5718c2ecf20Sopenharmony_ci		ISR_SMB	        |\
5728c2ecf20Sopenharmony_ci		ISR_TXF_UN      |\
5738c2ecf20Sopenharmony_ci		ISR_HW_RXF_OV   |\
5748c2ecf20Sopenharmony_ci		ISR_HOST_RXF0_OV|\
5758c2ecf20Sopenharmony_ci		ISR_MANUAL      |\
5768c2ecf20Sopenharmony_ci		ISR_GPHY        |\
5778c2ecf20Sopenharmony_ci		ISR_GPHY_LPW    |\
5788c2ecf20Sopenharmony_ci		ISR_DMAR_TO_RST |\
5798c2ecf20Sopenharmony_ci		ISR_DMAW_TO_RST |\
5808c2ecf20Sopenharmony_ci		ISR_PHY_LINKDOWN|\
5818c2ecf20Sopenharmony_ci		ISR_RX_PKT      |\
5828c2ecf20Sopenharmony_ci		ISR_TX_PKT)
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_ci#define ISR_TX_EVENT (ISR_TXF_UN | ISR_TX_PKT)
5858c2ecf20Sopenharmony_ci#define ISR_RX_EVENT (ISR_HOST_RXF0_OV | ISR_HW_RXF_OV | ISR_RX_PKT)
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci#define REG_MAC_RX_STATUS_BIN 0x1700
5888c2ecf20Sopenharmony_ci#define REG_MAC_RX_STATUS_END 0x175c
5898c2ecf20Sopenharmony_ci#define REG_MAC_TX_STATUS_BIN 0x1760
5908c2ecf20Sopenharmony_ci#define REG_MAC_TX_STATUS_END 0x17c0
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_ci/* Hardware Offset Register */
5938c2ecf20Sopenharmony_ci#define REG_HOST_RXF0_PAGEOFF 0x1800
5948c2ecf20Sopenharmony_ci#define REG_TPD_CONS_IDX      0x1804
5958c2ecf20Sopenharmony_ci#define REG_HOST_RXF1_PAGEOFF 0x1808
5968c2ecf20Sopenharmony_ci#define REG_HOST_RXF2_PAGEOFF 0x180C
5978c2ecf20Sopenharmony_ci#define REG_HOST_RXF3_PAGEOFF 0x1810
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ci/* RXF-Page 0-3 Offset DMA Address */
6008c2ecf20Sopenharmony_ci#define REG_HOST_RXF0_MB0_LO  0x1820
6018c2ecf20Sopenharmony_ci#define REG_HOST_RXF0_MB1_LO  0x1824
6028c2ecf20Sopenharmony_ci#define REG_HOST_RXF1_MB0_LO  0x1828
6038c2ecf20Sopenharmony_ci#define REG_HOST_RXF1_MB1_LO  0x182C
6048c2ecf20Sopenharmony_ci#define REG_HOST_RXF2_MB0_LO  0x1830
6058c2ecf20Sopenharmony_ci#define REG_HOST_RXF2_MB1_LO  0x1834
6068c2ecf20Sopenharmony_ci#define REG_HOST_RXF3_MB0_LO  0x1838
6078c2ecf20Sopenharmony_ci#define REG_HOST_RXF3_MB1_LO  0x183C
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ci/* Tpd CMB DMA Address */
6108c2ecf20Sopenharmony_ci#define REG_HOST_TX_CMB_LO    0x1840
6118c2ecf20Sopenharmony_ci#define REG_HOST_SMB_ADDR_LO  0x1844
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ci/* DEBUG ADDR */
6148c2ecf20Sopenharmony_ci#define REG_DEBUG_DATA0 0x1900
6158c2ecf20Sopenharmony_ci#define REG_DEBUG_DATA1 0x1904
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_ci/***************************** MII definition ***************************************/
6188c2ecf20Sopenharmony_ci/* PHY Common Register */
6198c2ecf20Sopenharmony_ci#define MII_AT001_PSCR                  0x10
6208c2ecf20Sopenharmony_ci#define MII_AT001_PSSR                  0x11
6218c2ecf20Sopenharmony_ci#define MII_INT_CTRL                    0x12
6228c2ecf20Sopenharmony_ci#define MII_INT_STATUS                  0x13
6238c2ecf20Sopenharmony_ci#define MII_SMARTSPEED                  0x14
6248c2ecf20Sopenharmony_ci#define MII_LBRERROR                    0x18
6258c2ecf20Sopenharmony_ci#define MII_RESV2                       0x1a
6268c2ecf20Sopenharmony_ci
6278c2ecf20Sopenharmony_ci#define MII_DBG_ADDR			0x1D
6288c2ecf20Sopenharmony_ci#define MII_DBG_DATA			0x1E
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci/* Autoneg Advertisement Register */
6318c2ecf20Sopenharmony_ci#define MII_AR_DEFAULT_CAP_MASK                 0
6328c2ecf20Sopenharmony_ci
6338c2ecf20Sopenharmony_ci/* 1000BASE-T Control Register */
6348c2ecf20Sopenharmony_ci#define MII_AT001_CR_1000T_SPEED_MASK \
6358c2ecf20Sopenharmony_ci	(ADVERTISE_1000FULL | ADVERTISE_1000HALF)
6368c2ecf20Sopenharmony_ci#define MII_AT001_CR_1000T_DEFAULT_CAP_MASK	MII_AT001_CR_1000T_SPEED_MASK
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_ci/* AT001 PHY Specific Control Register */
6398c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_JABBER_DISABLE           0x0001  /* 1=Jabber Function disabled */
6408c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_POLARITY_REVERSAL        0x0002  /* 1=Polarity Reversal enabled */
6418c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_SQE_TEST                 0x0004  /* 1=SQE Test enabled */
6428c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_MAC_POWERDOWN            0x0008
6438c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_CLK125_DISABLE           0x0010  /* 1=CLK125 low,
6448c2ecf20Sopenharmony_ci							 * 0=CLK125 toggling
6458c2ecf20Sopenharmony_ci							 */
6468c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_MDI_MANUAL_MODE          0x0000  /* MDI Crossover Mode bits 6:5 */
6478c2ecf20Sopenharmony_ci/* Manual MDI configuration */
6488c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_MDIX_MANUAL_MODE         0x0020  /* Manual MDIX configuration */
6498c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_AUTO_X_1000T             0x0040  /* 1000BASE-T: Auto crossover,
6508c2ecf20Sopenharmony_ci							 *  100BASE-TX/10BASE-T:
6518c2ecf20Sopenharmony_ci							 *  MDI Mode
6528c2ecf20Sopenharmony_ci							 */
6538c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_AUTO_X_MODE              0x0060  /* Auto crossover enabled
6548c2ecf20Sopenharmony_ci							 * all speeds.
6558c2ecf20Sopenharmony_ci							 */
6568c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_10BT_EXT_DIST_ENABLE     0x0080
6578c2ecf20Sopenharmony_ci/* 1=Enable Extended 10BASE-T distance
6588c2ecf20Sopenharmony_ci * (Lower 10BASE-T RX Threshold)
6598c2ecf20Sopenharmony_ci * 0=Normal 10BASE-T RX Threshold */
6608c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_MII_5BIT_ENABLE          0x0100
6618c2ecf20Sopenharmony_ci/* 1=5-Bit interface in 100BASE-TX
6628c2ecf20Sopenharmony_ci * 0=MII interface in 100BASE-TX */
6638c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_SCRAMBLER_DISABLE        0x0200  /* 1=Scrambler disable */
6648c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_FORCE_LINK_GOOD          0x0400  /* 1=Force link good */
6658c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_ASSERT_CRS_ON_TX         0x0800  /* 1=Assert CRS on Transmit */
6668c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_POLARITY_REVERSAL_SHIFT    1
6678c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_AUTO_X_MODE_SHIFT          5
6688c2ecf20Sopenharmony_ci#define MII_AT001_PSCR_10BT_EXT_DIST_ENABLE_SHIFT 7
6698c2ecf20Sopenharmony_ci/* AT001 PHY Specific Status Register */
6708c2ecf20Sopenharmony_ci#define MII_AT001_PSSR_SPD_DPLX_RESOLVED        0x0800  /* 1=Speed & Duplex resolved */
6718c2ecf20Sopenharmony_ci#define MII_AT001_PSSR_DPLX                     0x2000  /* 1=Duplex 0=Half Duplex */
6728c2ecf20Sopenharmony_ci#define MII_AT001_PSSR_SPEED                    0xC000  /* Speed, bits 14:15 */
6738c2ecf20Sopenharmony_ci#define MII_AT001_PSSR_10MBS                    0x0000  /* 00=10Mbs */
6748c2ecf20Sopenharmony_ci#define MII_AT001_PSSR_100MBS                   0x4000  /* 01=100Mbs */
6758c2ecf20Sopenharmony_ci#define MII_AT001_PSSR_1000MBS                  0x8000  /* 10=1000Mbs */
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci#endif /*_ATHL1E_HW_H_*/
678