1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) 2015 Broadcom Corporation 4 */ 5 6 #ifndef _LINUX_BCM_PHY_LIB_H 7 #define _LINUX_BCM_PHY_LIB_H 8 9 #include <linux/brcmphy.h> 10 #include <linux/phy.h> 11 #include <linux/interrupt.h> 12 13 struct ethtool_wolinfo; 14 15 /* 28nm only register definitions */ 16 #define MISC_ADDR(base, channel) base, channel 17 18 #define DSP_TAP10 MISC_ADDR(0x0a, 0) 19 #define PLL_PLLCTRL_1 MISC_ADDR(0x32, 1) 20 #define PLL_PLLCTRL_2 MISC_ADDR(0x32, 2) 21 #define PLL_PLLCTRL_4 MISC_ADDR(0x33, 0) 22 23 #define AFE_RXCONFIG_0 MISC_ADDR(0x38, 0) 24 #define AFE_RXCONFIG_1 MISC_ADDR(0x38, 1) 25 #define AFE_RXCONFIG_2 MISC_ADDR(0x38, 2) 26 #define AFE_RX_LP_COUNTER MISC_ADDR(0x38, 3) 27 #define AFE_TX_CONFIG MISC_ADDR(0x39, 0) 28 #define AFE_VDCA_ICTRL_0 MISC_ADDR(0x39, 1) 29 #define AFE_VDAC_OTHERS_0 MISC_ADDR(0x39, 3) 30 #define AFE_HPF_TRIM_OTHERS MISC_ADDR(0x3a, 0) 31 32 33 int __bcm_phy_write_exp(struct phy_device *phydev, u16 reg, u16 val); 34 int __bcm_phy_read_exp(struct phy_device *phydev, u16 reg); 35 int __bcm_phy_modify_exp(struct phy_device *phydev, u16 reg, u16 mask, u16 set); 36 int bcm_phy_write_exp(struct phy_device *phydev, u16 reg, u16 val); 37 int bcm_phy_read_exp(struct phy_device *phydev, u16 reg); 38 int bcm_phy_modify_exp(struct phy_device *phydev, u16 reg, u16 mask, u16 set); 39 40 static inline int bcm_phy_write_exp_sel(struct phy_device *phydev, 41 u16 reg, u16 val) 42 { 43 return bcm_phy_write_exp(phydev, reg | MII_BCM54XX_EXP_SEL_ER, val); 44 } 45 46 static inline int bcm_phy_read_exp_sel(struct phy_device *phydev, u16 reg) 47 { 48 return bcm_phy_read_exp(phydev, reg | MII_BCM54XX_EXP_SEL_ER); 49 } 50 51 int bcm54xx_auxctl_write(struct phy_device *phydev, u16 regnum, u16 val); 52 int bcm54xx_auxctl_read(struct phy_device *phydev, u16 regnum); 53 54 int bcm_phy_write_misc(struct phy_device *phydev, 55 u16 reg, u16 chl, u16 value); 56 int bcm_phy_read_misc(struct phy_device *phydev, 57 u16 reg, u16 chl); 58 59 int bcm_phy_write_shadow(struct phy_device *phydev, u16 shadow, 60 u16 val); 61 int bcm_phy_read_shadow(struct phy_device *phydev, u16 shadow); 62 63 int __bcm_phy_write_rdb(struct phy_device *phydev, u16 rdb, u16 val); 64 int bcm_phy_write_rdb(struct phy_device *phydev, u16 rdb, u16 val); 65 int __bcm_phy_read_rdb(struct phy_device *phydev, u16 rdb); 66 int bcm_phy_read_rdb(struct phy_device *phydev, u16 rdb); 67 int __bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask, 68 u16 set); 69 int bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask, 70 u16 set); 71 72 int bcm_phy_ack_intr(struct phy_device *phydev); 73 int bcm_phy_config_intr(struct phy_device *phydev); 74 irqreturn_t bcm_phy_handle_interrupt(struct phy_device *phydev); 75 76 int bcm_phy_enable_apd(struct phy_device *phydev, bool dll_pwr_down); 77 78 int bcm_phy_set_eee(struct phy_device *phydev, bool enable); 79 80 int bcm_phy_downshift_get(struct phy_device *phydev, u8 *count); 81 82 int bcm_phy_downshift_set(struct phy_device *phydev, u8 count); 83 84 int bcm_phy_get_sset_count(struct phy_device *phydev); 85 void bcm_phy_get_strings(struct phy_device *phydev, u8 *data); 86 void bcm_phy_get_stats(struct phy_device *phydev, u64 *shadow, 87 struct ethtool_stats *stats, u64 *data); 88 void bcm_phy_r_rc_cal_reset(struct phy_device *phydev); 89 int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev); 90 int bcm_phy_enable_jumbo(struct phy_device *phydev); 91 92 int bcm_phy_cable_test_get_status_rdb(struct phy_device *phydev, 93 bool *finished); 94 int bcm_phy_cable_test_start_rdb(struct phy_device *phydev); 95 int bcm_phy_cable_test_start(struct phy_device *phydev); 96 int bcm_phy_cable_test_get_status(struct phy_device *phydev, bool *finished); 97 98 #if IS_ENABLED(CONFIG_BCM_NET_PHYPTP) 99 struct bcm_ptp_private *bcm_ptp_probe(struct phy_device *phydev); 100 void bcm_ptp_config_init(struct phy_device *phydev); 101 void bcm_ptp_stop(struct bcm_ptp_private *priv); 102 #else 103 static inline struct bcm_ptp_private *bcm_ptp_probe(struct phy_device *phydev) 104 { 105 return NULL; 106 } 107 108 static inline void bcm_ptp_config_init(struct phy_device *phydev) 109 { 110 } 111 112 static inline void bcm_ptp_stop(struct bcm_ptp_private *priv) 113 { 114 } 115 #endif 116 117 int bcm_phy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol); 118 void bcm_phy_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol); 119 irqreturn_t bcm_phy_wol_isr(int irq, void *dev_id); 120 121 int bcm_phy_led_brightness_set(struct phy_device *phydev, 122 u8 index, enum led_brightness value); 123 124 #endif /* _LINUX_BCM_PHY_LIB_H */ 125