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_RTL_H_ 8 #define _NGBE_PHY_RTL_H_ 9 10 #define NGBE_PHYID_RTL 0x001CC800U 11 12 /* Page 0 */ 13 #define RTL_DEV_ZERO 0 14 #define RTL_BMCR 0x0 15 #define RTL_BMCR_RESET MS16(15, 0x1) 16 #define RTL_BMCR_SPEED_SELECT0 MS16(13, 0x1) 17 #define RTL_BMCR_ANE MS16(12, 0x1) 18 #define RTL_BMCR_PWDN MS16(11, 0x1) 19 #define RTL_BMCR_RESTART_AN MS16(9, 0x1) 20 #define RTL_BMCR_DUPLEX MS16(8, 0x1) 21 #define RTL_BMCR_SPEED_SELECT1 MS16(6, 0x1) 22 #define RTL_BMSR 0x1 23 #define RTL_BMSR_ANC MS16(5, 0x1) 24 #define RTL_ID1_OFFSET 0x2 25 #define RTL_ID2_OFFSET 0x3 26 #define RTL_ID_MASK 0xFFFFFC00U 27 #define RTL_ANAR 0x4 28 #define RTL_ANAR_APAUSE MS16(11, 0x1) 29 #define RTL_ANAR_PAUSE MS16(10, 0x1) 30 #define RTL_ANAR_100F MS16(8, 0x1) 31 #define RTL_ANAR_100H MS16(7, 0x1) 32 #define RTL_ANAR_10F MS16(6, 0x1) 33 #define RTL_ANAR_10H MS16(5, 0x1) 34 #define RTL_ANLPAR 0x5 35 #define RTL_ANLPAR_LP MS16(10, 0x3) 36 #define RTL_GBCR 0x9 37 #define RTL_GBCR_1000F MS16(9, 0x1) 38 #define RTL_GBSR 0xA 39 #define RTL_GBSR_LRS MS16(13, 0x1) 40 /* Page 0xa42*/ 41 #define RTL_GSR 0x10 42 #define RTL_GSR_ST MS16(0, 0x7) 43 #define RTL_GSR_ST_LANON MS16(0, 0x3) 44 #define RTL_INER 0x12 45 #define RTL_INER_LSC MS16(4, 0x1) 46 #define RTL_INER_ANC MS16(3, 0x1) 47 /* Page 0xa43*/ 48 #define RTL_PHYSR 0x1A 49 #define RTL_PHYSR_SPEED_MASK MS16(4, 0x3) 50 #define RTL_PHYSR_SPEED_RES LS16(3, 4, 0x3) 51 #define RTL_PHYSR_SPEED_1000M LS16(2, 4, 0x3) 52 #define RTL_PHYSR_SPEED_100M LS16(1, 4, 0x3) 53 #define RTL_PHYSR_SPEED_10M LS16(0, 4, 0x3) 54 #define RTL_PHYSR_DP MS16(3, 0x1) 55 #define RTL_PHYSR_RTLS MS16(2, 0x1) 56 #define RTL_INSR 0x1D 57 #define RTL_INSR_ACCESS MS16(5, 0x1) 58 #define RTL_INSR_LSC MS16(4, 0x1) 59 #define RTL_INSR_ANC MS16(3, 0x1) 60 /* Page 0xa46*/ 61 #define RTL_SCR 0x14 62 #define RTL_SCR_EXTINI MS16(1, 0x1) 63 #define RTL_SCR_EFUSE MS16(0, 0x1) 64 /* Page 0xa47*/ 65 /* Page 0xd04*/ 66 #define RTL_LCR 0x10 67 #define RTL_EEELCR 0x11 68 #define RTL_LPCR 0x12 69 70 /* INTERNAL PHY CONTROL */ 71 #define RTL_PAGE_SELECT 31 72 #define NGBE_INTERNAL_PHY_OFFSET_MAX 32 73 #define NGBE_INTERNAL_PHY_ID 0x000732 74 75 #define NGBE_INTPHY_LED0 0x0010 76 #define NGBE_INTPHY_LED1 0x0040 77 #define NGBE_INTPHY_LED2 0x2000 78 79 s32 ngbe_read_phy_reg_rtl(struct ngbe_hw *hw, u32 reg_addr, u32 device_type, 80 u16 *phy_data); 81 s32 ngbe_write_phy_reg_rtl(struct ngbe_hw *hw, u32 reg_addr, u32 device_type, 82 u16 phy_data); 83 84 s32 ngbe_setup_phy_link_rtl(struct ngbe_hw *hw, 85 u32 speed, bool autoneg_wait_to_complete); 86 87 s32 ngbe_init_phy_rtl(struct ngbe_hw *hw); 88 s32 ngbe_reset_phy_rtl(struct ngbe_hw *hw); 89 s32 ngbe_get_phy_advertised_pause_rtl(struct ngbe_hw *hw, u8 *pause_bit); 90 s32 ngbe_get_phy_lp_advertised_pause_rtl(struct ngbe_hw *hw, u8 *pause_bit); 91 s32 ngbe_set_phy_pause_adv_rtl(struct ngbe_hw *hw, u16 pause_bit); 92 s32 ngbe_check_phy_link_rtl(struct ngbe_hw *hw, 93 u32 *speed, bool *link_up); 94 s32 ngbe_set_phy_power_rtl(struct ngbe_hw *hw, bool on); 95 96 #endif /* _NGBE_PHY_RTL_H_ */ 97