1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*  Marvell OcteonTx2 RPM driver
3  *
4  * Copyright (C) 2020 Marvell.
5  *
6  */
7 
8 #ifndef RPM_H
9 #define RPM_H
10 
11 #include <linux/bits.h>
12 
13 /* PCI device IDs */
14 #define PCI_DEVID_CN10K_RPM		0xA060
15 
16 /* Registers */
17 #define RPMX_CMRX_SW_INT                0x180
18 #define RPMX_CMRX_SW_INT_W1S            0x188
19 #define RPMX_CMRX_SW_INT_ENA_W1S        0x198
20 #define RPMX_CMRX_LINK_CFG		0x1070
21 #define RPMX_MTI_PCS100X_CONTROL1       0x20000
22 #define RPMX_MTI_LPCSX_CONTROL1         0x30000
23 #define RPMX_MTI_PCS_LBK                BIT_ULL(14)
24 #define RPMX_MTI_LPCSX_CONTROL(id)     (0x30000 | ((id) * 0x100))
25 
26 #define RPMX_CMRX_LINK_RANGE_MASK	GENMASK_ULL(19, 16)
27 #define RPMX_CMRX_LINK_BASE_MASK	GENMASK_ULL(11, 0)
28 #define RPMX_MTI_MAC100X_COMMAND_CONFIG	0x8010
29 #define RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE	BIT_ULL(29)
30 #define RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_P_DISABLE	BIT_ULL(28)
31 #define RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE	BIT_ULL(8)
32 #define RPMX_MTI_MAC100X_COMMAND_CONFIG_PFC_MODE	BIT_ULL(19)
33 #define RPMX_MTI_MAC100X_CL01_PAUSE_QUANTA		0x80A8
34 #define RPMX_MTI_MAC100X_CL01_QUANTA_THRESH		0x80C8
35 #define RPM_DEFAULT_PAUSE_TIME			0xFFFF
36 #define RPMX_CMR_RX_OVR_BP		0x4120
37 #define RPMX_CMR_RX_OVR_BP_EN(x)	BIT_ULL((x) + 8)
38 #define RPMX_CMR_RX_OVR_BP_BP(x)	BIT_ULL((x) + 4)
39 #define RPMX_MTI_STAT_RX_STAT_PAGES_COUNTERX 0x12000
40 #define RPMX_MTI_STAT_TX_STAT_PAGES_COUNTERX 0x13000
41 #define RPMX_MTI_STAT_DATA_HI_CDC            0x10038
42 
43 #define RPM_LMAC_FWI			0xa
44 
45 /* Function Declarations */
46 int rpm_get_nr_lmacs(void *rpmd);
47 u8 rpm_get_lmac_type(void *rpmd, int lmac_id);
48 int rpm_lmac_internal_loopback(void *rpmd, int lmac_id, bool enable);
49 void rpm_lmac_enadis_rx_pause_fwding(void *rpmd, int lmac_id, bool enable);
50 int rpm_lmac_get_pause_frm_status(void *cgxd, int lmac_id, u8 *tx_pause,
51 				  u8 *rx_pause);
52 void rpm_lmac_pause_frm_config(void *rpmd, int lmac_id, bool enable);
53 int rpm_lmac_enadis_pause_frm(void *rpmd, int lmac_id, u8 tx_pause,
54 			      u8 rx_pause);
55 int rpm_get_tx_stats(void *rpmd, int lmac_id, int idx, u64 *tx_stat);
56 int rpm_get_rx_stats(void *rpmd, int lmac_id, int idx, u64 *rx_stat);
57 #endif /* RPM_H */
58