net/ngbe: identify and reset PHY
[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 /* IEEE 802.3 Clause 22 */
26 struct mdi_reg_22 {
27         u16 page;
28         u16 addr;
29         u16 device_type;
30 };
31 typedef struct mdi_reg_22 mdi_reg_22_t;
32
33 /* IEEE 802.3ae Clause 45 */
34 struct mdi_reg {
35         u16 device_type;
36         u16 addr;
37 };
38 typedef struct mdi_reg mdi_reg_t;
39
40 #define NGBE_MD22_PHY_ID_HIGH           0x2 /* PHY ID High Reg*/
41 #define NGBE_MD22_PHY_ID_LOW            0x3 /* PHY ID Low Reg*/
42
43 s32 ngbe_mdi_map_register(mdi_reg_t *reg, mdi_reg_22_t *reg22);
44
45 bool ngbe_validate_phy_addr(struct ngbe_hw *hw, u32 phy_addr);
46 enum ngbe_phy_type ngbe_get_phy_type_from_id(struct ngbe_hw *hw);
47 s32 ngbe_get_phy_id(struct ngbe_hw *hw);
48 s32 ngbe_identify_phy(struct ngbe_hw *hw);
49 s32 ngbe_reset_phy(struct ngbe_hw *hw);
50 s32 ngbe_read_phy_reg_mdi(struct ngbe_hw *hw, u32 reg_addr, u32 device_type,
51                            u16 *phy_data);
52 s32 ngbe_write_phy_reg_mdi(struct ngbe_hw *hw, u32 reg_addr, u32 device_type,
53                             u16 phy_data);
54 s32 ngbe_read_phy_reg(struct ngbe_hw *hw, u32 reg_addr,
55                                u32 device_type, u16 *phy_data);
56 s32 ngbe_write_phy_reg(struct ngbe_hw *hw, u32 reg_addr,
57                                 u32 device_type, u16 phy_data);
58 s32 ngbe_check_reset_blocked(struct ngbe_hw *hw);
59
60 #endif /* _NGBE_PHY_H_ */