ocelot_ptp.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
  2. /*
  3. * Microsemi Ocelot Switch driver
  4. *
  5. * License: Dual MIT/GPL
  6. * Copyright (c) 2017 Microsemi Corporation
  7. * Copyright 2020 NXP
  8. */
  9. #ifndef _MSCC_OCELOT_PTP_H_
  10. #define _MSCC_OCELOT_PTP_H_
  11. #include <linux/ptp_clock_kernel.h>
  12. #include <soc/mscc/ocelot.h>
  13. #define OCELOT_MAX_PTP_ID 63
  14. #define OCELOT_PTP_FIFO_SIZE 128
  15. #define PTP_PIN_CFG_RSZ 0x20
  16. #define PTP_PIN_TOD_SEC_MSB_RSZ PTP_PIN_CFG_RSZ
  17. #define PTP_PIN_TOD_SEC_LSB_RSZ PTP_PIN_CFG_RSZ
  18. #define PTP_PIN_TOD_NSEC_RSZ PTP_PIN_CFG_RSZ
  19. #define PTP_PIN_WF_HIGH_PERIOD_RSZ PTP_PIN_CFG_RSZ
  20. #define PTP_PIN_WF_LOW_PERIOD_RSZ PTP_PIN_CFG_RSZ
  21. #define PTP_PIN_CFG_DOM BIT(0)
  22. #define PTP_PIN_CFG_SYNC BIT(2)
  23. #define PTP_PIN_CFG_ACTION(x) ((x) << 3)
  24. #define PTP_PIN_CFG_ACTION_MASK PTP_PIN_CFG_ACTION(0x7)
  25. enum {
  26. PTP_PIN_ACTION_IDLE = 0,
  27. PTP_PIN_ACTION_LOAD,
  28. PTP_PIN_ACTION_SAVE,
  29. PTP_PIN_ACTION_CLOCK,
  30. PTP_PIN_ACTION_DELTA,
  31. PTP_PIN_ACTION_NOSYNC,
  32. PTP_PIN_ACTION_SYNC,
  33. };
  34. #define PTP_CFG_MISC_PTP_EN BIT(2)
  35. #define PTP_CFG_CLK_ADJ_CFG_ENA BIT(0)
  36. #define PTP_CFG_CLK_ADJ_CFG_DIR BIT(1)
  37. #define PTP_CFG_CLK_ADJ_FREQ_NS BIT(30)
  38. int ocelot_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts);
  39. int ocelot_ptp_settime64(struct ptp_clock_info *ptp,
  40. const struct timespec64 *ts);
  41. int ocelot_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta);
  42. int ocelot_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm);
  43. int ocelot_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin,
  44. enum ptp_pin_function func, unsigned int chan);
  45. int ocelot_ptp_enable(struct ptp_clock_info *ptp,
  46. struct ptp_clock_request *rq, int on);
  47. int ocelot_init_timestamp(struct ocelot *ocelot,
  48. const struct ptp_clock_info *info);
  49. int ocelot_deinit_timestamp(struct ocelot *ocelot);
  50. #endif