xref: /dpdk/drivers/net/ngbe/base/ngbe_phy_mvl.h (revision 6dcfb19f60e151d4659d1759fecb0d01bc5d1fc7)
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 #include "ngbe_hw.h"
7 
8 #ifndef _NGBE_PHY_MVL_H_
9 #define _NGBE_PHY_MVL_H_
10 
11 #define NGBE_PHYID_MVL			0x01410DD0U
12 
13 /* Page 0 for Copper, Page 1 for Fiber */
14 #define MVL_CTRL			0x0
15 #define   MVL_CTRL_RESET		MS16(15, 0x1)
16 #define	  MVL_CTRL_SPEED_SELECT0	MS16(13, 0x1)
17 #define   MVL_CTRL_ANE			MS16(12, 0x1)
18 #define   MVL_CTRL_PWDN			MS16(11, 0x1)
19 #define   MVL_CTRL_RESTART_AN		MS16(9, 0x1)
20 #define   MVL_CTRL_DUPLEX		MS16(8, 0x1)
21 #define	  MVL_CTRL_SPEED_SELECT1	MS16(6, 0x1)
22 #define MVL_ANA				0x4
23 /* copper */
24 #define   MVL_CANA_ASM_PAUSE		MS16(11, 0x1)
25 #define   MVL_CANA_PAUSE		MS16(10, 0x1)
26 #define   MVL_PHY_100BASET_FULL		MS16(8, 0x1)
27 #define   MVL_PHY_100BASET_HALF		MS16(7, 0x1)
28 #define   MVL_PHY_10BASET_FULL		MS16(6, 0x1)
29 #define   MVL_PHY_10BASET_HALF		MS16(5, 0x1)
30 /* fiber */
31 #define   MVL_FANA_PAUSE_MASK		MS16(7, 0x3)
32 #define     MVL_FANA_SYM_PAUSE		LS16(1, 7, 0x3)
33 #define     MVL_FANA_ASM_PAUSE		LS16(2, 7, 0x3)
34 #define   MVL_PHY_1000BASEX_HALF	MS16(6, 0x1)
35 #define   MVL_PHY_1000BASEX_FULL	MS16(5, 0x1)
36 #define MVL_LPAR			0x5
37 #define   MVL_CLPAR_ASM_PAUSE		MS(11, 0x1)
38 #define   MVL_CLPAR_PAUSE		MS(10, 0x1)
39 #define   MVL_FLPAR_PAUSE_MASK		MS(7, 0x3)
40 #define MVL_PHY_1000BASET		0x9
41 #define   MVL_PHY_1000BASET_FULL	MS16(9, 0x1)
42 #define   MVL_PHY_1000BASET_HALF	MS16(8, 0x1)
43 #define MVL_CTRL1			0x10
44 #define   MVL_CTRL1_INTR_POL		MS16(2, 0x1)
45 #define MVL_PHYSR			0x11
46 #define   MVL_PHYSR_SPEED_MASK		MS16(14, 0x3)
47 #define     MVL_PHYSR_SPEED_1000M	LS16(2, 14, 0x3)
48 #define     MVL_PHYSR_SPEED_100M	LS16(1, 14, 0x3)
49 #define     MVL_PHYSR_SPEED_10M		LS16(0, 14, 0x3)
50 #define   MVL_PHYSR_LINK		MS16(10, 0x1)
51 #define MVL_INTR_EN			0x12
52 #define   MVL_INTR_EN_ANC		MS16(11, 0x1)
53 #define   MVL_INTR_EN_LSC		MS16(10, 0x1)
54 #define MVL_INTR			0x13
55 #define   MVL_INTR_ANC			MS16(11, 0x1)
56 #define   MVL_INTR_LSC			MS16(10, 0x1)
57 
58 /* Page 2 */
59 #define MVL_RGM_CTL2			0x15
60 #define   MVL_RGM_CTL2_TTC		MS16(4, 0x1)
61 #define   MVL_RGM_CTL2_RTC		MS16(5, 0x1)
62 /* Page 3 */
63 #define MVL_LEDFCR			0x10
64 #define   MVL_LEDFCR_CTL1		MS16(4, 0xF)
65 #define     MVL_LEDFCR_CTL1_CONF	LS16(6, 4, 0xF)
66 #define   MVL_LEDFCR_CTL0		MS16(0, 0xF)
67 #define     MVL_LEDFCR_CTL0_CONF	LS16(1, 0, 0xF)
68 #define MVL_LEDPCR			0x11
69 #define   MVL_LEDPCR_CTL1		MS16(2, 0x3)
70 #define     MVL_LEDPCR_CTL1_CONF	LS16(1, 2, 0x3)
71 #define   MVL_LEDPCR_CTL0		MS16(0, 0x3)
72 #define     MVL_LEDPCR_CTL0_CONF	LS16(1, 0, 0x3)
73 #define MVL_LEDTCR			0x12
74 #define   MVL_LEDTCR_INTR_POL		MS16(11, 0x1)
75 #define   MVL_LEDTCR_INTR_EN		MS16(7, 0x1)
76 /* Page 18 */
77 #define MVL_GEN_CTL			0x14
78 #define   MVL_GEN_CTL_RESET		MS16(15, 0x1)
79 #define   MVL_GEN_CTL_MODE(v)		LS16(v, 0, 0x7)
80 #define     MVL_GEN_CTL_MODE_COPPER	LS16(0, 0, 0x7)
81 #define     MVL_GEN_CTL_MODE_FIBER	LS16(2, 0, 0x7)
82 
83 /* reg 22 */
84 #define MVL_PAGE_SEL			22
85 
86 /* reg 19_0 INT status*/
87 #define MVL_PHY_ANC                      0x0800
88 #define MVL_PHY_LSC                      0x0400
89 
90 s32 ngbe_read_phy_reg_mvl(struct ngbe_hw *hw, u32 reg_addr, u32 device_type,
91 			u16 *phy_data);
92 s32 ngbe_write_phy_reg_mvl(struct ngbe_hw *hw, u32 reg_addr, u32 device_type,
93 			u16 phy_data);
94 s32 ngbe_check_phy_mode_mvl(struct ngbe_hw *hw);
95 s32 ngbe_init_phy_mvl(struct ngbe_hw *hw);
96 
97 s32 ngbe_reset_phy_mvl(struct ngbe_hw *hw);
98 
99 s32 ngbe_check_phy_link_mvl(struct ngbe_hw *hw,
100 		u32 *speed, bool *link_up);
101 s32 ngbe_set_phy_power_mvl(struct ngbe_hw *hw, bool on);
102 s32 ngbe_setup_phy_link_mvl(struct ngbe_hw *hw,
103 			u32 speed, bool autoneg_wait_to_complete);
104 s32 ngbe_get_phy_advertised_pause_mvl(struct ngbe_hw *hw, u8 *pause_bit);
105 s32 ngbe_get_phy_lp_advertised_pause_mvl(struct ngbe_hw *hw, u8 *pause_bit);
106 s32 ngbe_set_phy_pause_adv_mvl(struct ngbe_hw *hw, u16 pause_bit);
107 
108 #endif /* _NGBE_PHY_MVL_H_ */
109