xref: /linux/drivers/net/ethernet/hisilicon/hibmcge/hbg_reg.h (revision a239b2b1dee2dce9c48939b122b3ad3ed7b99cbd)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2024 Hisilicon Limited. */
3 
4 #ifndef __HBG_REG_H
5 #define __HBG_REG_H
6 
7 /* DEV SPEC */
8 #define HBG_REG_SPEC_VALID_ADDR			0x0000
9 #define HBG_REG_EVENT_REQ_ADDR			0x0004
10 #define HBG_REG_MAC_ID_ADDR			0x0008
11 #define HBG_REG_PHY_ID_ADDR			0x000C
12 #define HBG_REG_MAC_ADDR_ADDR			0x0010
13 #define HBG_REG_MDIO_FREQ_ADDR			0x0024
14 #define HBG_REG_MAX_MTU_ADDR			0x0028
15 #define HBG_REG_MIN_MTU_ADDR			0x002C
16 #define HBG_REG_TX_FIFO_NUM_ADDR		0x0030
17 #define HBG_REG_RX_FIFO_NUM_ADDR		0x0034
18 #define HBG_REG_VLAN_LAYERS_ADDR		0x0038
19 
20 /* MDIO */
21 #define HBG_REG_MDIO_BASE			0x8000
22 #define HBG_REG_MDIO_COMMAND_ADDR		(HBG_REG_MDIO_BASE + 0x0000)
23 #define HBG_REG_MDIO_COMMAND_CLK_SEL_EXP_B	BIT(17)
24 #define HBG_REG_MDIO_COMMAND_AUTO_SCAN_B	BIT(16)
25 #define HBG_REG_MDIO_COMMAND_CLK_SEL_B		BIT(15)
26 #define HBG_REG_MDIO_COMMAND_START_B		BIT(14)
27 #define HBG_REG_MDIO_COMMAND_ST_M		GENMASK(13, 12)
28 #define HBG_REG_MDIO_COMMAND_OP_M		GENMASK(11, 10)
29 #define HBG_REG_MDIO_COMMAND_PRTAD_M		GENMASK(9, 5)
30 #define HBG_REG_MDIO_COMMAND_DEVAD_M		GENMASK(4, 0)
31 #define HBG_REG_MDIO_WDATA_ADDR			(HBG_REG_MDIO_BASE + 0x0008)
32 #define HBG_REG_MDIO_WDATA_M			GENMASK(15, 0)
33 #define HBG_REG_MDIO_RDATA_ADDR			(HBG_REG_MDIO_BASE + 0x000C)
34 #define HBG_REG_MDIO_STA_ADDR			(HBG_REG_MDIO_BASE + 0x0010)
35 
36 /* GMAC */
37 #define HBG_REG_SGMII_BASE			0x10000
38 #define HBG_REG_DUPLEX_TYPE_ADDR		(HBG_REG_SGMII_BASE + 0x0008)
39 #define HBG_REG_DUPLEX_B			BIT(0)
40 #define HBG_REG_PORT_MODE_ADDR			(HBG_REG_SGMII_BASE + 0x0040)
41 #define HBG_REG_PORT_MODE_M			GENMASK(3, 0)
42 #define HBG_REG_TRANSMIT_CTRL_ADDR		(HBG_REG_SGMII_BASE + 0x0060)
43 #define HBG_REG_TRANSMIT_CTRL_PAD_EN_B		BIT(7)
44 #define HBG_REG_TRANSMIT_CTRL_CRC_ADD_B		BIT(6)
45 #define HBG_REG_TRANSMIT_CTRL_AN_EN_B		BIT(5)
46 #define HBG_REG_CF_CRC_STRIP_ADDR		(HBG_REG_SGMII_BASE + 0x01B0)
47 #define HBG_REG_CF_CRC_STRIP_B			BIT(0)
48 #define HBG_REG_MODE_CHANGE_EN_ADDR		(HBG_REG_SGMII_BASE + 0x01B4)
49 #define HBG_REG_MODE_CHANGE_EN_B		BIT(0)
50 #define HBG_REG_RECV_CTRL_ADDR			(HBG_REG_SGMII_BASE + 0x01E0)
51 #define HBG_REG_RECV_CTRL_STRIP_PAD_EN_B	BIT(3)
52 
53 /* PCU */
54 #define HBG_REG_RX_BUF_SIZE_ADDR		(HBG_REG_SGMII_BASE + 0x04E4)
55 #define HBG_REG_RX_BUF_SIZE_M			GENMASK(15, 0)
56 #define HBG_REG_BUS_CTRL_ADDR			(HBG_REG_SGMII_BASE + 0x04E8)
57 #define HBG_REG_BUS_CTRL_ENDIAN_M		GENMASK(2, 1)
58 #define HBG_REG_RX_CTRL_ADDR			(HBG_REG_SGMII_BASE + 0x04F0)
59 #define HBG_REG_RX_CTRL_RXBUF_1ST_SKIP_SIZE_M	GENMASK(31, 28)
60 #define HBG_REG_RX_CTRL_TIME_INF_EN_B		BIT(23)
61 #define HBG_REG_RX_CTRL_RX_ALIGN_NUM_M		GENMASK(18, 17)
62 #define HBG_REG_RX_CTRL_PORT_NUM		GENMASK(16, 13)
63 #define HBG_REG_RX_CTRL_RX_GET_ADDR_MODE_B	BIT(12)
64 #define HBG_REG_RX_CTRL_RXBUF_1ST_SKIP_SIZE2_M	GENMASK(3, 0)
65 #define HBG_REG_RX_PKT_MODE_ADDR		(HBG_REG_SGMII_BASE + 0x04F4)
66 #define HBG_REG_RX_PKT_MODE_PARSE_MODE_M	GENMASK(22, 21)
67 
68 enum hbg_port_mode {
69 	/* 0x0 ~ 0x5 are reserved */
70 	HBG_PORT_MODE_SGMII_10M = 0x6,
71 	HBG_PORT_MODE_SGMII_100M = 0x7,
72 	HBG_PORT_MODE_SGMII_1000M = 0x8,
73 };
74 
75 #endif
76