162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Microchip LAN937X switch register definitions 362306a36Sopenharmony_ci * Copyright (C) 2019-2021 Microchip Technology Inc. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci#ifndef __LAN937X_REG_H 662306a36Sopenharmony_ci#define __LAN937X_REG_H 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#define PORT_CTRL_ADDR(port, addr) ((addr) | (((port) + 1) << 12)) 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci/* 0 - Operation */ 1162306a36Sopenharmony_ci#define REG_GLOBAL_CTRL_0 0x0007 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#define SW_PHY_REG_BLOCK BIT(7) 1462306a36Sopenharmony_ci#define SW_FAST_MODE BIT(3) 1562306a36Sopenharmony_ci#define SW_FAST_MODE_OVERRIDE BIT(2) 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#define REG_SW_INT_STATUS__4 0x0010 1862306a36Sopenharmony_ci#define REG_SW_INT_MASK__4 0x0014 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define LUE_INT BIT(31) 2162306a36Sopenharmony_ci#define TRIG_TS_INT BIT(30) 2262306a36Sopenharmony_ci#define APB_TIMEOUT_INT BIT(29) 2362306a36Sopenharmony_ci#define OVER_TEMP_INT BIT(28) 2462306a36Sopenharmony_ci#define HSR_INT BIT(27) 2562306a36Sopenharmony_ci#define PIO_INT BIT(26) 2662306a36Sopenharmony_ci#define POR_READY_INT BIT(25) 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define SWITCH_INT_MASK \ 2962306a36Sopenharmony_ci (LUE_INT | TRIG_TS_INT | APB_TIMEOUT_INT | OVER_TEMP_INT | HSR_INT | \ 3062306a36Sopenharmony_ci PIO_INT | POR_READY_INT) 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define REG_SW_PORT_INT_STATUS__4 0x0018 3362306a36Sopenharmony_ci#define REG_SW_PORT_INT_MASK__4 0x001C 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* 1 - Global */ 3662306a36Sopenharmony_ci#define REG_SW_GLOBAL_OUTPUT_CTRL__1 0x0103 3762306a36Sopenharmony_ci#define SW_CLK125_ENB BIT(1) 3862306a36Sopenharmony_ci#define SW_CLK25_ENB BIT(0) 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci/* 3 - Operation Control */ 4162306a36Sopenharmony_ci#define REG_SW_OPERATION 0x0300 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define SW_DOUBLE_TAG BIT(7) 4462306a36Sopenharmony_ci#define SW_OVER_TEMP_ENABLE BIT(2) 4562306a36Sopenharmony_ci#define SW_RESET BIT(1) 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#define REG_SW_LUE_CTRL_0 0x0310 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#define SW_VLAN_ENABLE BIT(7) 5062306a36Sopenharmony_ci#define SW_DROP_INVALID_VID BIT(6) 5162306a36Sopenharmony_ci#define SW_AGE_CNT_M 0x7 5262306a36Sopenharmony_ci#define SW_AGE_CNT_S 3 5362306a36Sopenharmony_ci#define SW_RESV_MCAST_ENABLE BIT(2) 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci#define REG_SW_LUE_CTRL_1 0x0311 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci#define UNICAST_LEARN_DISABLE BIT(7) 5862306a36Sopenharmony_ci#define SW_FLUSH_STP_TABLE BIT(5) 5962306a36Sopenharmony_ci#define SW_FLUSH_MSTP_TABLE BIT(4) 6062306a36Sopenharmony_ci#define SW_SRC_ADDR_FILTER BIT(3) 6162306a36Sopenharmony_ci#define SW_AGING_ENABLE BIT(2) 6262306a36Sopenharmony_ci#define SW_FAST_AGING BIT(1) 6362306a36Sopenharmony_ci#define SW_LINK_AUTO_AGING BIT(0) 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci#define REG_SW_AGE_PERIOD__1 0x0313 6662306a36Sopenharmony_ci#define SW_AGE_PERIOD_7_0_M GENMASK(7, 0) 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci#define REG_SW_AGE_PERIOD__2 0x0320 6962306a36Sopenharmony_ci#define SW_AGE_PERIOD_19_8_M GENMASK(19, 8) 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci#define REG_SW_MAC_CTRL_0 0x0330 7262306a36Sopenharmony_ci#define SW_NEW_BACKOFF BIT(7) 7362306a36Sopenharmony_ci#define SW_PAUSE_UNH_MODE BIT(1) 7462306a36Sopenharmony_ci#define SW_AGGR_BACKOFF BIT(0) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define REG_SW_MAC_CTRL_1 0x0331 7762306a36Sopenharmony_ci#define SW_SHORT_IFG BIT(7) 7862306a36Sopenharmony_ci#define MULTICAST_STORM_DISABLE BIT(6) 7962306a36Sopenharmony_ci#define SW_BACK_PRESSURE BIT(5) 8062306a36Sopenharmony_ci#define FAIR_FLOW_CTRL BIT(4) 8162306a36Sopenharmony_ci#define NO_EXC_COLLISION_DROP BIT(3) 8262306a36Sopenharmony_ci#define SW_LEGAL_PACKET_DISABLE BIT(1) 8362306a36Sopenharmony_ci#define SW_PASS_SHORT_FRAME BIT(0) 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci#define REG_SW_MAC_CTRL_6 0x0336 8662306a36Sopenharmony_ci#define SW_MIB_COUNTER_FLUSH BIT(7) 8762306a36Sopenharmony_ci#define SW_MIB_COUNTER_FREEZE BIT(6) 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci/* 4 - LUE */ 9062306a36Sopenharmony_ci#define REG_SW_ALU_STAT_CTRL__4 0x041C 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci#define REG_SW_ALU_VAL_B 0x0424 9362306a36Sopenharmony_ci#define ALU_V_OVERRIDE BIT(31) 9462306a36Sopenharmony_ci#define ALU_V_USE_FID BIT(30) 9562306a36Sopenharmony_ci#define ALU_V_PORT_MAP 0xFF 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci/* 7 - VPhy */ 9862306a36Sopenharmony_ci#define REG_VPHY_IND_ADDR__2 0x075C 9962306a36Sopenharmony_ci#define REG_VPHY_IND_DATA__2 0x0760 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci#define REG_VPHY_IND_CTRL__2 0x0768 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#define VPHY_IND_WRITE BIT(1) 10462306a36Sopenharmony_ci#define VPHY_IND_BUSY BIT(0) 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci#define REG_VPHY_SPECIAL_CTRL__2 0x077C 10762306a36Sopenharmony_ci#define VPHY_SMI_INDIRECT_ENABLE BIT(15) 10862306a36Sopenharmony_ci#define VPHY_SW_LOOPBACK BIT(14) 10962306a36Sopenharmony_ci#define VPHY_MDIO_INTERNAL_ENABLE BIT(13) 11062306a36Sopenharmony_ci#define VPHY_SPI_INDIRECT_ENABLE BIT(12) 11162306a36Sopenharmony_ci#define VPHY_PORT_MODE_M 0x3 11262306a36Sopenharmony_ci#define VPHY_PORT_MODE_S 8 11362306a36Sopenharmony_ci#define VPHY_MODE_RGMII 0 11462306a36Sopenharmony_ci#define VPHY_MODE_MII_PHY 1 11562306a36Sopenharmony_ci#define VPHY_MODE_SGMII 2 11662306a36Sopenharmony_ci#define VPHY_MODE_RMII_PHY 3 11762306a36Sopenharmony_ci#define VPHY_SW_COLLISION_TEST BIT(7) 11862306a36Sopenharmony_ci#define VPHY_SPEED_DUPLEX_STAT_M 0x7 11962306a36Sopenharmony_ci#define VPHY_SPEED_DUPLEX_STAT_S 2 12062306a36Sopenharmony_ci#define VPHY_SPEED_1000 BIT(4) 12162306a36Sopenharmony_ci#define VPHY_SPEED_100 BIT(3) 12262306a36Sopenharmony_ci#define VPHY_FULL_DUPLEX BIT(2) 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci/* Port Registers */ 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci/* 0 - Operation */ 12762306a36Sopenharmony_ci#define REG_PORT_INT_STATUS 0x001B 12862306a36Sopenharmony_ci#define REG_PORT_INT_MASK 0x001F 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci#define PORT_TAS_INT BIT(5) 13162306a36Sopenharmony_ci#define PORT_QCI_INT BIT(4) 13262306a36Sopenharmony_ci#define PORT_SGMII_INT BIT(3) 13362306a36Sopenharmony_ci#define PORT_PTP_INT BIT(2) 13462306a36Sopenharmony_ci#define PORT_PHY_INT BIT(1) 13562306a36Sopenharmony_ci#define PORT_ACL_INT BIT(0) 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci#define PORT_SRC_PHY_INT 1 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci#define REG_PORT_CTRL_0 0x0020 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci#define PORT_MAC_LOOPBACK BIT(7) 14262306a36Sopenharmony_ci#define PORT_MAC_REMOTE_LOOPBACK BIT(6) 14362306a36Sopenharmony_ci#define PORT_K2L_INSERT_ENABLE BIT(5) 14462306a36Sopenharmony_ci#define PORT_K2L_DEBUG_ENABLE BIT(4) 14562306a36Sopenharmony_ci#define PORT_TAIL_TAG_ENABLE BIT(2) 14662306a36Sopenharmony_ci#define PORT_QUEUE_SPLIT_ENABLE 0x3 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci/* 1 - Phy */ 14962306a36Sopenharmony_ci#define REG_PORT_T1_PHY_CTRL_BASE 0x0100 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ci/* 3 - xMII */ 15262306a36Sopenharmony_ci#define PORT_SGMII_SEL BIT(7) 15362306a36Sopenharmony_ci#define PORT_GRXC_ENABLE BIT(0) 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci#define PORT_MII_SEL_EDGE BIT(5) 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci#define REG_PORT_XMII_CTRL_4 0x0304 15862306a36Sopenharmony_ci#define REG_PORT_XMII_CTRL_5 0x0306 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci#define PORT_DLL_RESET BIT(15) 16162306a36Sopenharmony_ci#define PORT_TUNE_ADJ GENMASK(13, 7) 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci/* 4 - MAC */ 16462306a36Sopenharmony_ci#define REG_PORT_MAC_CTRL_0 0x0400 16562306a36Sopenharmony_ci#define PORT_CHECK_LENGTH BIT(2) 16662306a36Sopenharmony_ci#define PORT_BROADCAST_STORM BIT(1) 16762306a36Sopenharmony_ci#define PORT_JUMBO_PACKET BIT(0) 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci#define REG_PORT_MAC_CTRL_1 0x0401 17062306a36Sopenharmony_ci#define PORT_BACK_PRESSURE BIT(3) 17162306a36Sopenharmony_ci#define PORT_PASS_ALL BIT(0) 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci#define PORT_MAX_FR_SIZE 0x404 17462306a36Sopenharmony_ci#define FR_MIN_SIZE 1522 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci/* 8 - Classification and Policing */ 17762306a36Sopenharmony_ci#define REG_PORT_MRI_PRIO_CTRL 0x0801 17862306a36Sopenharmony_ci#define PORT_HIGHEST_PRIO BIT(7) 17962306a36Sopenharmony_ci#define PORT_OR_PRIO BIT(6) 18062306a36Sopenharmony_ci#define PORT_MAC_PRIO_ENABLE BIT(4) 18162306a36Sopenharmony_ci#define PORT_VLAN_PRIO_ENABLE BIT(3) 18262306a36Sopenharmony_ci#define PORT_802_1P_PRIO_ENABLE BIT(2) 18362306a36Sopenharmony_ci#define PORT_DIFFSERV_PRIO_ENABLE BIT(1) 18462306a36Sopenharmony_ci#define PORT_ACL_PRIO_ENABLE BIT(0) 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci#define P_PRIO_CTRL REG_PORT_MRI_PRIO_CTRL 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci/* 9 - Shaping */ 18962306a36Sopenharmony_ci#define REG_PORT_MTI_CREDIT_INCREMENT 0x091C 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci/* The port number as per the datasheet */ 19262306a36Sopenharmony_ci#define RGMII_2_PORT_NUM 5 19362306a36Sopenharmony_ci#define RGMII_1_PORT_NUM 6 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci#define LAN937X_RGMII_2_PORT (RGMII_2_PORT_NUM - 1) 19662306a36Sopenharmony_ci#define LAN937X_RGMII_1_PORT (RGMII_1_PORT_NUM - 1) 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ci#define RGMII_1_TX_DELAY_2NS 2 19962306a36Sopenharmony_ci#define RGMII_2_TX_DELAY_2NS 0 20062306a36Sopenharmony_ci#define RGMII_1_RX_DELAY_2NS 0x1B 20162306a36Sopenharmony_ci#define RGMII_2_RX_DELAY_2NS 0x14 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci#define LAN937X_TAG_LEN 2 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ci#endif 206