bcm-phy-lib.h 4.5 KB

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