pcs-xpcs.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2020 Synopsys, Inc. and/or its affiliates.
  4. * Synopsys DesignWare XPCS helpers
  5. *
  6. * Author: Jose Abreu <[email protected]>
  7. */
  8. #define SYNOPSYS_XPCS_ID 0x7996ced0
  9. #define SYNOPSYS_XPCS_MASK 0xffffffff
  10. /* Vendor regs access */
  11. #define DW_VENDOR BIT(15)
  12. /* VR_XS_PCS */
  13. #define DW_USXGMII_RST BIT(10)
  14. #define DW_USXGMII_EN BIT(9)
  15. #define DW_VR_XS_PCS_DIG_STS 0x0010
  16. #define DW_RXFIFO_ERR GENMASK(6, 5)
  17. /* SR_MII */
  18. #define DW_USXGMII_FULL BIT(8)
  19. #define DW_USXGMII_SS_MASK (BIT(13) | BIT(6) | BIT(5))
  20. #define DW_USXGMII_10000 (BIT(13) | BIT(6))
  21. #define DW_USXGMII_5000 (BIT(13) | BIT(5))
  22. #define DW_USXGMII_2500 (BIT(5))
  23. #define DW_USXGMII_1000 (BIT(6))
  24. #define DW_USXGMII_100 (BIT(13))
  25. #define DW_USXGMII_10 (0)
  26. /* SR_AN */
  27. #define DW_SR_AN_ADV1 0x10
  28. #define DW_SR_AN_ADV2 0x11
  29. #define DW_SR_AN_ADV3 0x12
  30. #define DW_SR_AN_LP_ABL1 0x13
  31. #define DW_SR_AN_LP_ABL2 0x14
  32. #define DW_SR_AN_LP_ABL3 0x15
  33. /* Clause 73 Defines */
  34. /* AN_LP_ABL1 */
  35. #define DW_C73_PAUSE BIT(10)
  36. #define DW_C73_ASYM_PAUSE BIT(11)
  37. #define DW_C73_AN_ADV_SF 0x1
  38. /* AN_LP_ABL2 */
  39. #define DW_C73_1000KX BIT(5)
  40. #define DW_C73_10000KX4 BIT(6)
  41. #define DW_C73_10000KR BIT(7)
  42. /* AN_LP_ABL3 */
  43. #define DW_C73_2500KX BIT(0)
  44. #define DW_C73_5000KR BIT(1)
  45. /* Clause 37 Defines */
  46. /* VR MII MMD registers offsets */
  47. #define DW_VR_MII_MMD_CTRL 0x0000
  48. #define DW_VR_MII_DIG_CTRL1 0x8000
  49. #define DW_VR_MII_AN_CTRL 0x8001
  50. #define DW_VR_MII_AN_INTR_STS 0x8002
  51. /* Enable 2.5G Mode */
  52. #define DW_VR_MII_DIG_CTRL1_2G5_EN BIT(2)
  53. /* EEE Mode Control Register */
  54. #define DW_VR_MII_EEE_MCTRL0 0x8006
  55. #define DW_VR_MII_EEE_MCTRL1 0x800b
  56. #define DW_VR_MII_DIG_CTRL2 0x80e1
  57. /* VR_MII_DIG_CTRL1 */
  58. #define DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW BIT(9)
  59. /* VR_MII_DIG_CTRL2 */
  60. #define DW_VR_MII_DIG_CTRL2_TX_POL_INV BIT(4)
  61. #define DW_VR_MII_DIG_CTRL2_RX_POL_INV BIT(0)
  62. /* VR_MII_AN_CTRL */
  63. #define DW_VR_MII_AN_CTRL_TX_CONFIG_SHIFT 3
  64. #define DW_VR_MII_TX_CONFIG_MASK BIT(3)
  65. #define DW_VR_MII_TX_CONFIG_PHY_SIDE_SGMII 0x1
  66. #define DW_VR_MII_TX_CONFIG_MAC_SIDE_SGMII 0x0
  67. #define DW_VR_MII_AN_CTRL_PCS_MODE_SHIFT 1
  68. #define DW_VR_MII_PCS_MODE_MASK GENMASK(2, 1)
  69. #define DW_VR_MII_PCS_MODE_C37_1000BASEX 0x0
  70. #define DW_VR_MII_PCS_MODE_C37_SGMII 0x2
  71. /* VR_MII_AN_INTR_STS */
  72. #define DW_VR_MII_AN_STS_C37_ANSGM_FD BIT(1)
  73. #define DW_VR_MII_AN_STS_C37_ANSGM_SP_SHIFT 2
  74. #define DW_VR_MII_AN_STS_C37_ANSGM_SP GENMASK(3, 2)
  75. #define DW_VR_MII_C37_ANSGM_SP_10 0x0
  76. #define DW_VR_MII_C37_ANSGM_SP_100 0x1
  77. #define DW_VR_MII_C37_ANSGM_SP_1000 0x2
  78. #define DW_VR_MII_C37_ANSGM_SP_LNKSTS BIT(4)
  79. /* SR MII MMD Control defines */
  80. #define AN_CL37_EN BIT(12) /* Enable Clause 37 auto-nego */
  81. #define SGMII_SPEED_SS13 BIT(13) /* SGMII speed along with SS6 */
  82. #define SGMII_SPEED_SS6 BIT(6) /* SGMII speed along with SS13 */
  83. /* VR MII EEE Control 0 defines */
  84. #define DW_VR_MII_EEE_LTX_EN BIT(0) /* LPI Tx Enable */
  85. #define DW_VR_MII_EEE_LRX_EN BIT(1) /* LPI Rx Enable */
  86. #define DW_VR_MII_EEE_TX_QUIET_EN BIT(2) /* Tx Quiet Enable */
  87. #define DW_VR_MII_EEE_RX_QUIET_EN BIT(3) /* Rx Quiet Enable */
  88. #define DW_VR_MII_EEE_TX_EN_CTRL BIT(4) /* Tx Control Enable */
  89. #define DW_VR_MII_EEE_RX_EN_CTRL BIT(7) /* Rx Control Enable */
  90. #define DW_VR_MII_EEE_MULT_FACT_100NS_SHIFT 8
  91. #define DW_VR_MII_EEE_MULT_FACT_100NS GENMASK(11, 8)
  92. /* VR MII EEE Control 1 defines */
  93. #define DW_VR_MII_EEE_TRN_LPI BIT(0) /* Transparent Mode Enable */
  94. int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg);
  95. int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val);
  96. int nxp_sja1105_sgmii_pma_config(struct dw_xpcs *xpcs);
  97. int nxp_sja1110_sgmii_pma_config(struct dw_xpcs *xpcs);
  98. int nxp_sja1110_2500basex_pma_config(struct dw_xpcs *xpcs);