ptp.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Marvell 88E6xxx Switch PTP support
  4. *
  5. * Copyright (c) 2008 Marvell Semiconductor
  6. *
  7. * Copyright (c) 2017 National Instruments
  8. * Erik Hons <[email protected]>
  9. * Brandon Streiff <[email protected]>
  10. * Dane Wagner <[email protected]>
  11. */
  12. #ifndef _MV88E6XXX_PTP_H
  13. #define _MV88E6XXX_PTP_H
  14. #include "chip.h"
  15. /* Offset 0x00: TAI Global Config */
  16. #define MV88E6XXX_TAI_CFG 0x00
  17. #define MV88E6XXX_TAI_CFG_CAP_OVERWRITE 0x8000
  18. #define MV88E6XXX_TAI_CFG_CAP_CTR_START 0x4000
  19. #define MV88E6XXX_TAI_CFG_EVREQ_FALLING 0x2000
  20. #define MV88E6XXX_TAI_CFG_TRIG_ACTIVE_LO 0x1000
  21. #define MV88E6XXX_TAI_CFG_IRL_ENABLE 0x0400
  22. #define MV88E6XXX_TAI_CFG_TRIG_IRQ_EN 0x0200
  23. #define MV88E6XXX_TAI_CFG_EVREQ_IRQ_EN 0x0100
  24. #define MV88E6XXX_TAI_CFG_TRIG_LOCK 0x0080
  25. #define MV88E6XXX_TAI_CFG_BLOCK_UPDATE 0x0008
  26. #define MV88E6XXX_TAI_CFG_MULTI_PTP 0x0004
  27. #define MV88E6XXX_TAI_CFG_TRIG_MODE_ONESHOT 0x0002
  28. #define MV88E6XXX_TAI_CFG_TRIG_ENABLE 0x0001
  29. /* Offset 0x01: Timestamp Clock Period (ps) */
  30. #define MV88E6XXX_TAI_CLOCK_PERIOD 0x01
  31. /* Offset 0x02/0x03: Trigger Generation Amount */
  32. #define MV88E6XXX_TAI_TRIG_GEN_AMOUNT_LO 0x02
  33. #define MV88E6XXX_TAI_TRIG_GEN_AMOUNT_HI 0x03
  34. /* Offset 0x04: Clock Compensation */
  35. #define MV88E6XXX_TAI_TRIG_CLOCK_COMP 0x04
  36. /* Offset 0x05: Trigger Configuration */
  37. #define MV88E6XXX_TAI_TRIG_CFG 0x05
  38. /* Offset 0x06: Ingress Rate Limiter Clock Generation Amount */
  39. #define MV88E6XXX_TAI_IRL_AMOUNT 0x06
  40. /* Offset 0x07: Ingress Rate Limiter Compensation */
  41. #define MV88E6XXX_TAI_IRL_COMP 0x07
  42. /* Offset 0x08: Ingress Rate Limiter Compensation */
  43. #define MV88E6XXX_TAI_IRL_COMP_PS 0x08
  44. /* Offset 0x09: Event Status */
  45. #define MV88E6XXX_TAI_EVENT_STATUS 0x09
  46. #define MV88E6XXX_TAI_EVENT_STATUS_CAP_TRIG 0x4000
  47. #define MV88E6XXX_TAI_EVENT_STATUS_ERROR 0x0200
  48. #define MV88E6XXX_TAI_EVENT_STATUS_VALID 0x0100
  49. #define MV88E6XXX_TAI_EVENT_STATUS_CTR_MASK 0x00ff
  50. /* Offset 0x0A/0x0B: Event Time */
  51. #define MV88E6XXX_TAI_EVENT_TIME_LO 0x0a
  52. #define MV88E6XXX_TAI_EVENT_TYPE_HI 0x0b
  53. /* Offset 0x0E/0x0F: PTP Global Time */
  54. #define MV88E6XXX_TAI_TIME_LO 0x0e
  55. #define MV88E6XXX_TAI_TIME_HI 0x0f
  56. /* Offset 0x10/0x11: Trig Generation Time */
  57. #define MV88E6XXX_TAI_TRIG_TIME_LO 0x10
  58. #define MV88E6XXX_TAI_TRIG_TIME_HI 0x11
  59. /* Offset 0x12: Lock Status */
  60. #define MV88E6XXX_TAI_LOCK_STATUS 0x12
  61. /* Offset 0x00: Ether Type */
  62. #define MV88E6XXX_PTP_GC_ETYPE 0x00
  63. /* 6165 Global Control Registers */
  64. /* Offset 0x00: Ether Type */
  65. #define MV88E6XXX_PTP_GC_ETYPE 0x00
  66. /* Offset 0x01: Message ID */
  67. #define MV88E6XXX_PTP_GC_MESSAGE_ID 0x01
  68. /* Offset 0x02: Time Stamp Arrive Time */
  69. #define MV88E6XXX_PTP_GC_TS_ARR_PTR 0x02
  70. /* Offset 0x03: Port Arrival Interrupt Enable */
  71. #define MV88E6XXX_PTP_GC_PORT_ARR_INT_EN 0x03
  72. /* Offset 0x04: Port Departure Interrupt Enable */
  73. #define MV88E6XXX_PTP_GC_PORT_DEP_INT_EN 0x04
  74. /* Offset 0x05: Configuration */
  75. #define MV88E6XXX_PTP_GC_CONFIG 0x05
  76. #define MV88E6XXX_PTP_GC_CONFIG_DIS_OVERWRITE BIT(1)
  77. #define MV88E6XXX_PTP_GC_CONFIG_DIS_TS BIT(0)
  78. /* Offset 0x8: Interrupt Status */
  79. #define MV88E6XXX_PTP_GC_INT_STATUS 0x08
  80. /* Offset 0x9/0xa: Global Time */
  81. #define MV88E6XXX_PTP_GC_TIME_LO 0x09
  82. #define MV88E6XXX_PTP_GC_TIME_HI 0x0A
  83. /* 6165 Per Port Registers */
  84. /* Offset 0: Arrival Time 0 Status */
  85. #define MV88E6165_PORT_PTP_ARR0_STS 0x00
  86. /* Offset 0x01/0x02: PTP Arrival 0 Time */
  87. #define MV88E6165_PORT_PTP_ARR0_TIME_LO 0x01
  88. #define MV88E6165_PORT_PTP_ARR0_TIME_HI 0x02
  89. /* Offset 0x03: PTP Arrival 0 Sequence ID */
  90. #define MV88E6165_PORT_PTP_ARR0_SEQID 0x03
  91. /* Offset 0x04: PTP Arrival 1 Status */
  92. #define MV88E6165_PORT_PTP_ARR1_STS 0x04
  93. /* Offset 0x05/0x6E: PTP Arrival 1 Time */
  94. #define MV88E6165_PORT_PTP_ARR1_TIME_LO 0x05
  95. #define MV88E6165_PORT_PTP_ARR1_TIME_HI 0x06
  96. /* Offset 0x07: PTP Arrival 1 Sequence ID */
  97. #define MV88E6165_PORT_PTP_ARR1_SEQID 0x07
  98. /* Offset 0x08: PTP Departure Status */
  99. #define MV88E6165_PORT_PTP_DEP_STS 0x08
  100. /* Offset 0x09/0x0a: PTP Deperture Time */
  101. #define MV88E6165_PORT_PTP_DEP_TIME_LO 0x09
  102. #define MV88E6165_PORT_PTP_DEP_TIME_HI 0x0a
  103. /* Offset 0x0b: PTP Departure Sequence ID */
  104. #define MV88E6165_PORT_PTP_DEP_SEQID 0x0b
  105. /* Offset 0x0d: Port Status */
  106. #define MV88E6164_PORT_STATUS 0x0d
  107. #ifdef CONFIG_NET_DSA_MV88E6XXX_PTP
  108. long mv88e6xxx_hwtstamp_work(struct ptp_clock_info *ptp);
  109. int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip);
  110. void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip);
  111. #define ptp_to_chip(ptp) container_of(ptp, struct mv88e6xxx_chip, \
  112. ptp_clock_info)
  113. extern const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops;
  114. extern const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops;
  115. extern const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops;
  116. #else /* !CONFIG_NET_DSA_MV88E6XXX_PTP */
  117. static inline long mv88e6xxx_hwtstamp_work(struct ptp_clock_info *ptp)
  118. {
  119. return -1;
  120. }
  121. static inline int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip)
  122. {
  123. return 0;
  124. }
  125. static inline void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip)
  126. {
  127. }
  128. static const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops = {};
  129. static const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops = {};
  130. static const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {};
  131. #endif /* CONFIG_NET_DSA_MV88E6XXX_PTP */
  132. #endif /* _MV88E6XXX_PTP_H */