xref: /linux/drivers/net/phy/bcm-phy-lib.h (revision e184a9072f8995e78ad6cef48bfeab2b987945ec)
19aab906aSNishad Kamdar /* 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 
12f878fe56SFlorian Fainelli /* 28nm only register definitions */
13f878fe56SFlorian Fainelli #define MISC_ADDR(base, channel)	base, channel
14f878fe56SFlorian Fainelli 
15f878fe56SFlorian Fainelli #define DSP_TAP10			MISC_ADDR(0x0a, 0)
16f878fe56SFlorian Fainelli #define PLL_PLLCTRL_1			MISC_ADDR(0x32, 1)
17f878fe56SFlorian Fainelli #define PLL_PLLCTRL_2			MISC_ADDR(0x32, 2)
18f878fe56SFlorian Fainelli #define PLL_PLLCTRL_4			MISC_ADDR(0x33, 0)
19f878fe56SFlorian Fainelli 
20f878fe56SFlorian Fainelli #define AFE_RXCONFIG_0			MISC_ADDR(0x38, 0)
21f878fe56SFlorian Fainelli #define AFE_RXCONFIG_1			MISC_ADDR(0x38, 1)
22f878fe56SFlorian Fainelli #define AFE_RXCONFIG_2			MISC_ADDR(0x38, 2)
23f878fe56SFlorian Fainelli #define AFE_RX_LP_COUNTER		MISC_ADDR(0x38, 3)
24f878fe56SFlorian Fainelli #define AFE_TX_CONFIG			MISC_ADDR(0x39, 0)
25f878fe56SFlorian Fainelli #define AFE_VDCA_ICTRL_0		MISC_ADDR(0x39, 1)
26f878fe56SFlorian Fainelli #define AFE_VDAC_OTHERS_0		MISC_ADDR(0x39, 3)
27f878fe56SFlorian Fainelli #define AFE_HPF_TRIM_OTHERS		MISC_ADDR(0x3a, 0)
28f878fe56SFlorian Fainelli 
29f878fe56SFlorian Fainelli 
307d7e7bceSMichael Walle int __bcm_phy_write_exp(struct phy_device *phydev, u16 reg, u16 val);
317d7e7bceSMichael Walle int __bcm_phy_read_exp(struct phy_device *phydev, u16 reg);
32*e184a907SMichael Walle int __bcm_phy_modify_exp(struct phy_device *phydev, u16 reg, u16 mask, u16 set);
33a1cba561SArun Parameswaran int bcm_phy_write_exp(struct phy_device *phydev, u16 reg, u16 val);
34a1cba561SArun Parameswaran int bcm_phy_read_exp(struct phy_device *phydev, u16 reg);
35*e184a907SMichael Walle int bcm_phy_modify_exp(struct phy_device *phydev, u16 reg, u16 mask, u16 set);
36a1cba561SArun Parameswaran 
3779fb218dSFlorian Fainelli static inline int bcm_phy_write_exp_sel(struct phy_device *phydev,
3879fb218dSFlorian Fainelli 					u16 reg, u16 val)
3979fb218dSFlorian Fainelli {
4079fb218dSFlorian Fainelli 	return bcm_phy_write_exp(phydev, reg | MII_BCM54XX_EXP_SEL_ER, val);
4179fb218dSFlorian Fainelli }
4279fb218dSFlorian Fainelli 
435519da87SFlorian Fainelli int bcm54xx_auxctl_write(struct phy_device *phydev, u16 regnum, u16 val);
445519da87SFlorian Fainelli int bcm54xx_auxctl_read(struct phy_device *phydev, u16 regnum);
455519da87SFlorian Fainelli 
46a1cba561SArun Parameswaran int bcm_phy_write_misc(struct phy_device *phydev,
47a1cba561SArun Parameswaran 		       u16 reg, u16 chl, u16 value);
48a1cba561SArun Parameswaran int bcm_phy_read_misc(struct phy_device *phydev,
49a1cba561SArun Parameswaran 		      u16 reg, u16 chl);
50a1cba561SArun Parameswaran 
51a1cba561SArun Parameswaran int bcm_phy_write_shadow(struct phy_device *phydev, u16 shadow,
52a1cba561SArun Parameswaran 			 u16 val);
53a1cba561SArun Parameswaran int bcm_phy_read_shadow(struct phy_device *phydev, u16 shadow);
54a1cba561SArun Parameswaran 
550a32f1ffSMichael Walle int __bcm_phy_write_rdb(struct phy_device *phydev, u16 rdb, u16 val);
560a32f1ffSMichael Walle int bcm_phy_write_rdb(struct phy_device *phydev, u16 rdb, u16 val);
570a32f1ffSMichael Walle int __bcm_phy_read_rdb(struct phy_device *phydev, u16 rdb);
580a32f1ffSMichael Walle int bcm_phy_read_rdb(struct phy_device *phydev, u16 rdb);
590a32f1ffSMichael Walle int __bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask,
600a32f1ffSMichael Walle 			 u16 set);
610a32f1ffSMichael Walle int bcm_phy_modify_rdb(struct phy_device *phydev, u16 rdb, u16 mask,
620a32f1ffSMichael Walle 		       u16 set);
630a32f1ffSMichael Walle 
64a1cba561SArun Parameswaran int bcm_phy_ack_intr(struct phy_device *phydev);
65a1cba561SArun Parameswaran int bcm_phy_config_intr(struct phy_device *phydev);
66a1cba561SArun Parameswaran 
67a1cba561SArun Parameswaran int bcm_phy_enable_apd(struct phy_device *phydev, bool dll_pwr_down);
68a1cba561SArun Parameswaran 
6999cec8a4SFlorian Fainelli int bcm_phy_set_eee(struct phy_device *phydev, bool enable);
70d06f78c4SFlorian Fainelli 
71d06f78c4SFlorian Fainelli int bcm_phy_downshift_get(struct phy_device *phydev, u8 *count);
72d06f78c4SFlorian Fainelli 
73d06f78c4SFlorian Fainelli int bcm_phy_downshift_set(struct phy_device *phydev, u8 count);
74d06f78c4SFlorian Fainelli 
75820ee17bSFlorian Fainelli int bcm_phy_get_sset_count(struct phy_device *phydev);
76820ee17bSFlorian Fainelli void bcm_phy_get_strings(struct phy_device *phydev, u8 *data);
77820ee17bSFlorian Fainelli void bcm_phy_get_stats(struct phy_device *phydev, u64 *shadow,
78820ee17bSFlorian Fainelli 		       struct ethtool_stats *stats, u64 *data);
79f878fe56SFlorian Fainelli void bcm_phy_r_rc_cal_reset(struct phy_device *phydev);
80f878fe56SFlorian Fainelli int bcm_phy_28nm_a0b0_afe_config_init(struct phy_device *phydev);
81ab41ca34SMurali Krishna Policharla int bcm_phy_enable_jumbo(struct phy_device *phydev);
82820ee17bSFlorian Fainelli 
83a1cba561SArun Parameswaran #endif /* _LINUX_BCM_PHY_LIB_H */
84