net/ngbe: identify and reset PHY
[dpdk.git] / drivers / net / ngbe / base / ngbe_phy_mvl.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3  */
4
5 #include "ngbe_phy.h"
6
7 #ifndef _NGBE_PHY_MVL_H_
8 #define _NGBE_PHY_MVL_H_
9
10 #define NGBE_PHYID_MVL                  0x01410DD0U
11
12 /* Page 0 for Copper, Page 1 for Fiber */
13 #define MVL_CTRL                        0x0
14 #define   MVL_CTRL_RESET                MS16(15, 0x1)
15 #define   MVL_CTRL_ANE                  MS16(12, 0x1)
16 #define   MVL_CTRL_RESTART_AN           MS16(9, 0x1)
17 #define MVL_ANA                         0x4
18 /* copper */
19 #define   MVL_CANA_ASM_PAUSE            MS16(11, 0x1)
20 #define   MVL_CANA_PAUSE                MS16(10, 0x1)
21 #define   MVL_PHY_100BASET_FULL         MS16(8, 0x1)
22 #define   MVL_PHY_100BASET_HALF         MS16(7, 0x1)
23 #define   MVL_PHY_10BASET_FULL          MS16(6, 0x1)
24 #define   MVL_PHY_10BASET_HALF          MS16(5, 0x1)
25 /* fiber */
26 #define   MVL_FANA_PAUSE_MASK           MS16(7, 0x3)
27 #define     MVL_FANA_SYM_PAUSE          LS16(1, 7, 0x3)
28 #define     MVL_FANA_ASM_PAUSE          LS16(2, 7, 0x3)
29 #define   MVL_PHY_1000BASEX_HALF        MS16(6, 0x1)
30 #define   MVL_PHY_1000BASEX_FULL        MS16(5, 0x1)
31 #define MVL_LPAR                        0x5
32 #define   MVL_CLPAR_ASM_PAUSE           MS(11, 0x1)
33 #define   MVL_CLPAR_PAUSE               MS(10, 0x1)
34 #define   MVL_FLPAR_PAUSE_MASK          MS(7, 0x3)
35 #define MVL_PHY_1000BASET               0x9
36 #define   MVL_PHY_1000BASET_FULL        MS16(9, 0x1)
37 #define   MVL_PHY_1000BASET_HALF        MS16(8, 0x1)
38 #define MVL_CTRL1                       0x10
39 #define   MVL_CTRL1_INTR_POL            MS16(2, 0x1)
40 #define MVL_PHYSR                       0x11
41 #define   MVL_PHYSR_SPEED_MASK          MS16(14, 0x3)
42 #define     MVL_PHYSR_SPEED_1000M       LS16(2, 14, 0x3)
43 #define     MVL_PHYSR_SPEED_100M        LS16(1, 14, 0x3)
44 #define     MVL_PHYSR_SPEED_10M         LS16(0, 14, 0x3)
45 #define   MVL_PHYSR_LINK                MS16(10, 0x1)
46 #define MVL_INTR_EN                     0x12
47 #define   MVL_INTR_EN_ANC               MS16(11, 0x1)
48 #define   MVL_INTR_EN_LSC               MS16(10, 0x1)
49 #define MVL_INTR                        0x13
50 #define   MVL_INTR_ANC                  MS16(11, 0x1)
51 #define   MVL_INTR_LSC                  MS16(10, 0x1)
52
53 /* Page 2 */
54 #define MVL_RGM_CTL2                    0x15
55 #define   MVL_RGM_CTL2_TTC              MS16(4, 0x1)
56 #define   MVL_RGM_CTL2_RTC              MS16(5, 0x1)
57 /* Page 3 */
58 #define MVL_LEDFCR                      0x10
59 #define   MVL_LEDFCR_CTL1               MS16(4, 0xF)
60 #define     MVL_LEDFCR_CTL1_CONF        LS16(6, 4, 0xF)
61 #define   MVL_LEDFCR_CTL0               MS16(0, 0xF)
62 #define     MVL_LEDFCR_CTL0_CONF        LS16(1, 0, 0xF)
63 #define MVL_LEDPCR                      0x11
64 #define   MVL_LEDPCR_CTL1               MS16(2, 0x3)
65 #define     MVL_LEDPCR_CTL1_CONF        LS16(1, 2, 0x3)
66 #define   MVL_LEDPCR_CTL0               MS16(0, 0x3)
67 #define     MVL_LEDPCR_CTL0_CONF        LS16(1, 0, 0x3)
68 #define MVL_LEDTCR                      0x12
69 #define   MVL_LEDTCR_INTR_POL           MS16(11, 0x1)
70 #define   MVL_LEDTCR_INTR_EN            MS16(7, 0x1)
71 /* Page 18 */
72 #define MVL_GEN_CTL                     0x14
73 #define   MVL_GEN_CTL_RESET             MS16(15, 0x1)
74 #define   MVL_GEN_CTL_MODE(v)           LS16(v, 0, 0x7)
75 #define     MVL_GEN_CTL_MODE_COPPER     LS16(0, 0, 0x7)
76 #define     MVL_GEN_CTL_MODE_FIBER      LS16(2, 0, 0x7)
77
78 /* reg 22 */
79 #define MVL_PAGE_SEL                    22
80
81 /* reg 19_0 INT status*/
82 #define MVL_PHY_ANC                      0x0800
83 #define MVL_PHY_LSC                      0x0400
84
85 s32 ngbe_read_phy_reg_mvl(struct ngbe_hw *hw, u32 reg_addr, u32 device_type,
86                         u16 *phy_data);
87 s32 ngbe_write_phy_reg_mvl(struct ngbe_hw *hw, u32 reg_addr, u32 device_type,
88                         u16 phy_data);
89
90 s32 ngbe_reset_phy_mvl(struct ngbe_hw *hw);
91
92 #endif /* _NGBE_PHY_MVL_H_ */