xref: /linux/drivers/net/phy/bcm-phy-lib.h (revision f878fe5685580a795793c2fcf880824e1c4b0911)
1a2443fd1SAndrew Lunn // SPDX-License-Identifier: GPL-2.0
2a1cba561SArun Parameswaran /*
3a1cba561SArun Parameswaran  * Copyright (C) 2015 Broadcom Corporation
4a1cba561SArun Parameswaran  */
5a1cba561SArun Parameswaran 
6a1cba561SArun Parameswaran #ifndef _LINUX_BCM_PHY_LIB_H
7a1cba561SArun Parameswaran #define _LINUX_BCM_PHY_LIB_H
8a1cba561SArun Parameswaran 
979fb218dSFlorian Fainelli #include <linux/brcmphy.h>
10a1cba561SArun Parameswaran #include <linux/phy.h>
11a1cba561SArun Parameswaran 
12*f878fe56SFlorian Fainelli /* 28nm only register definitions */
13*f878fe56SFlorian Fainelli #define MISC_ADDR(base, channel)	base, channel
14*f878fe56SFlorian Fainelli 
15*f878fe56SFlorian Fainelli #define DSP_TAP10			MISC_ADDR(0x0a, 0)
16*f878fe56SFlorian Fainelli #define PLL_PLLCTRL_1			MISC_ADDR(0x32, 1)
17*f878fe56SFlorian Fainelli #define PLL_PLLCTRL_2			MISC_ADDR(0x32, 2)
18*f878fe56SFlorian Fainelli #define PLL_PLLCTRL_4			MISC_ADDR(0x33, 0)
19*f878fe56SFlorian Fainelli 
20*f878fe56SFlorian Fainelli #define AFE_RXCONFIG_0			MISC_ADDR(0x38, 0)
21*f878fe56SFlorian Fainelli #define AFE_RXCONFIG_1			MISC_ADDR(0x38, 1)
22*f878fe56SFlorian Fainelli #define AFE_RXCONFIG_2			MISC_ADDR(0x38, 2)
23*f878fe56SFlorian Fainelli #define AFE_RX_LP_COUNTER		MISC_ADDR(0x38, 3)
24*f878fe56SFlorian Fainelli #define AFE_TX_CONFIG			MISC_ADDR(0x39, 0)
25*f878fe56SFlorian Fainelli #define AFE_VDCA_ICTRL_0		MISC_ADDR(0x39, 1)
26*f878fe56SFlorian Fainelli #define AFE_VDAC_OTHERS_0		MISC_ADDR(0x39, 3)
27*f878fe56SFlorian Fainelli #define AFE_HPF_TRIM_OTHERS		MISC_ADDR(0x3a, 0)
28*f878fe56SFlorian Fainelli 
29*f878fe56SFlorian Fainelli 
30a1cba561SArun Parameswaran int bcm_phy_write_exp(struct phy_device *phydev, u16 reg, u16 val);
31a1cba561SArun Parameswaran int bcm_phy_read_exp(struct phy_device *phydev, u16 reg);
32a1cba561SArun Parameswaran 
3379fb218dSFlorian Fainelli static inline int bcm_phy_write_exp_sel(struct phy_device *phydev,
3479fb218dSFlorian Fainelli 					u16 reg, u16 val)
3579fb218dSFlorian Fainelli {
3679fb218dSFlorian Fainelli 	return bcm_phy_write_exp(phydev, reg | MII_BCM54XX_EXP_SEL_ER, val);
3779fb218dSFlorian Fainelli }
3879fb218dSFlorian Fainelli 
395519da87SFlorian Fainelli int bcm54xx_auxctl_write(struct phy_device *phydev, u16 regnum, u16 val);
405519da87SFlorian Fainelli int bcm54xx_auxctl_read(struct phy_device *phydev, u16 regnum);
415519da87SFlorian Fainelli 
42a1cba561SArun Parameswaran int bcm_phy_write_misc(struct phy_device *phydev,
43a1cba561SArun Parameswaran 		       u16 reg, u16 chl, u16 value);
44a1cba561SArun Parameswaran int bcm_phy_read_misc(struct phy_device *phydev,
45a1cba561SArun Parameswaran 		      u16 reg, u16 chl);
46a1cba561SArun Parameswaran 
47a1cba561SArun Parameswaran int bcm_phy_write_shadow(struct phy_device *phydev, u16 shadow,
48a1cba561SArun Parameswaran 			 u16 val);
49a1cba561SArun Parameswaran int bcm_phy_read_shadow(struct phy_device *phydev, u16 shadow);
50a1cba561SArun Parameswaran 
51a1cba561SArun Parameswaran int bcm_phy_ack_intr(struct phy_device *phydev);
52a1cba561SArun Parameswaran int bcm_phy_config_intr(struct phy_device *phydev);
53a1cba561SArun Parameswaran 
54a1cba561SArun Parameswaran int bcm_phy_enable_apd(struct phy_device *phydev, bool dll_pwr_down);
55a1cba561SArun Parameswaran 
5699cec8a4SFlorian Fainelli int bcm_phy_set_eee(struct phy_device *phydev, bool enable);
57d06f78c4SFlorian Fainelli 
58d06f78c4SFlorian Fainelli int bcm_phy_downshift_get(struct phy_device *phydev, u8 *count);
59d06f78c4SFlorian Fainelli 
60d06f78c4SFlorian Fainelli int bcm_phy_downshift_set(struct phy_device *phydev, u8 count);
61d06f78c4SFlorian Fainelli 
62820ee17bSFlorian Fainelli int bcm_phy_get_sset_count(struct phy_device *phydev);
63820ee17bSFlorian Fainelli void bcm_phy_get_strings(struct phy_device *phydev, u8 *data);
64820ee17bSFlorian Fainelli void bcm_phy_get_stats(struct phy_device *phydev, u64 *shadow,
65820ee17bSFlorian Fainelli 		       struct ethtool_stats *stats, u64 *data);
66*f878fe56SFlorian Fainelli void bcm_phy_r_rc_cal_reset(struct phy_device *phydev);
67*f878fe56SFlorian Fainelli int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev);
68820ee17bSFlorian Fainelli 
69a1cba561SArun Parameswaran #endif /* _LINUX_BCM_PHY_LIB_H */
70