net/ngbe: support SR-IOV
[dpdk.git] / drivers / net / ngbe / base / ngbe_phy.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3  * Copyright(c) 2010-2017 Intel Corporation
4  */
5
6 #ifndef _NGBE_PHY_H_
7 #define _NGBE_PHY_H_
8
9 #include "ngbe_type.h"
10 #include "ngbe_phy_rtl.h"
11 #include "ngbe_phy_mvl.h"
12 #include "ngbe_phy_yt.h"
13
14 /******************************************************************************
15  * PHY MDIO Registers:
16  ******************************************************************************/
17 #define NGBE_MAX_PHY_ADDR               32
18
19 /* (dev_type = 1) */
20 #define NGBE_MD_DEV_PMA_PMD             0x1
21 #define NGBE_MD_PHY_ID_HIGH             0x2 /* PHY ID High Reg*/
22 #define NGBE_MD_PHY_ID_LOW              0x3 /* PHY ID Low Reg*/
23 #define   NGBE_PHY_REVISION_MASK        0xFFFFFFF0
24
25 #define NGBE_MII_AUTONEG_REG                    0x0
26
27 /* IEEE 802.3 Clause 22 */
28 struct mdi_reg_22 {
29         u16 page;
30         u16 addr;
31         u16 device_type;
32 };
33 typedef struct mdi_reg_22 mdi_reg_22_t;
34
35 /* IEEE 802.3ae Clause 45 */
36 struct mdi_reg {
37         u16 device_type;
38         u16 addr;
39 };
40 typedef struct mdi_reg mdi_reg_t;
41
42 #define NGBE_MD22_PHY_ID_HIGH           0x2 /* PHY ID High Reg*/
43 #define NGBE_MD22_PHY_ID_LOW            0x3 /* PHY ID Low Reg*/
44
45 s32 ngbe_mdi_map_register(mdi_reg_t *reg, mdi_reg_22_t *reg22);
46
47 bool ngbe_validate_phy_addr(struct ngbe_hw *hw, u32 phy_addr);
48 enum ngbe_phy_type ngbe_get_phy_type_from_id(struct ngbe_hw *hw);
49 s32 ngbe_get_phy_id(struct ngbe_hw *hw);
50 s32 ngbe_identify_phy(struct ngbe_hw *hw);
51 s32 ngbe_reset_phy(struct ngbe_hw *hw);
52 s32 ngbe_read_phy_reg_mdi(struct ngbe_hw *hw, u32 reg_addr, u32 device_type,
53                            u16 *phy_data);
54 s32 ngbe_write_phy_reg_mdi(struct ngbe_hw *hw, u32 reg_addr, u32 device_type,
55                             u16 phy_data);
56 s32 ngbe_read_phy_reg(struct ngbe_hw *hw, u32 reg_addr,
57                                u32 device_type, u16 *phy_data);
58 s32 ngbe_write_phy_reg(struct ngbe_hw *hw, u32 reg_addr,
59                                 u32 device_type, u16 phy_data);
60 s32 ngbe_check_reset_blocked(struct ngbe_hw *hw);
61
62 #endif /* _NGBE_PHY_H_ */