12b49d128SYangbo Lu /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ 22b49d128SYangbo Lu /* 32b49d128SYangbo Lu * Microsemi Ocelot Switch driver 42b49d128SYangbo Lu * 52b49d128SYangbo Lu * License: Dual MIT/GPL 62b49d128SYangbo Lu * Copyright (c) 2017 Microsemi Corporation 72b49d128SYangbo Lu * Copyright 2020 NXP 82b49d128SYangbo Lu */ 92b49d128SYangbo Lu 102b49d128SYangbo Lu #ifndef _MSCC_OCELOT_PTP_H_ 112b49d128SYangbo Lu #define _MSCC_OCELOT_PTP_H_ 122b49d128SYangbo Lu 132b49d128SYangbo Lu #include <linux/ptp_clock_kernel.h> 142b49d128SYangbo Lu #include <soc/mscc/ocelot.h> 152b49d128SYangbo Lu 16c57fe003SVladimir Oltean #define OCELOT_MAX_PTP_ID 63 17*52849bcfSVladimir Oltean #define OCELOT_PTP_FIFO_SIZE 128 18c57fe003SVladimir Oltean 192b49d128SYangbo Lu #define PTP_PIN_CFG_RSZ 0x20 202b49d128SYangbo Lu #define PTP_PIN_TOD_SEC_MSB_RSZ PTP_PIN_CFG_RSZ 212b49d128SYangbo Lu #define PTP_PIN_TOD_SEC_LSB_RSZ PTP_PIN_CFG_RSZ 222b49d128SYangbo Lu #define PTP_PIN_TOD_NSEC_RSZ PTP_PIN_CFG_RSZ 2394aca082SYangbo Lu #define PTP_PIN_WF_HIGH_PERIOD_RSZ PTP_PIN_CFG_RSZ 2494aca082SYangbo Lu #define PTP_PIN_WF_LOW_PERIOD_RSZ PTP_PIN_CFG_RSZ 252b49d128SYangbo Lu 262b49d128SYangbo Lu #define PTP_PIN_CFG_DOM BIT(0) 272b49d128SYangbo Lu #define PTP_PIN_CFG_SYNC BIT(2) 282b49d128SYangbo Lu #define PTP_PIN_CFG_ACTION(x) ((x) << 3) 292b49d128SYangbo Lu #define PTP_PIN_CFG_ACTION_MASK PTP_PIN_CFG_ACTION(0x7) 302b49d128SYangbo Lu 312b49d128SYangbo Lu enum { 322b49d128SYangbo Lu PTP_PIN_ACTION_IDLE = 0, 332b49d128SYangbo Lu PTP_PIN_ACTION_LOAD, 342b49d128SYangbo Lu PTP_PIN_ACTION_SAVE, 352b49d128SYangbo Lu PTP_PIN_ACTION_CLOCK, 362b49d128SYangbo Lu PTP_PIN_ACTION_DELTA, 372b49d128SYangbo Lu PTP_PIN_ACTION_NOSYNC, 382b49d128SYangbo Lu PTP_PIN_ACTION_SYNC, 392b49d128SYangbo Lu }; 402b49d128SYangbo Lu 412b49d128SYangbo Lu #define PTP_CFG_MISC_PTP_EN BIT(2) 422b49d128SYangbo Lu 432b49d128SYangbo Lu #define PTP_CFG_CLK_ADJ_CFG_ENA BIT(0) 442b49d128SYangbo Lu #define PTP_CFG_CLK_ADJ_CFG_DIR BIT(1) 452b49d128SYangbo Lu 462b49d128SYangbo Lu #define PTP_CFG_CLK_ADJ_FREQ_NS BIT(30) 472b49d128SYangbo Lu 482b49d128SYangbo Lu int ocelot_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts); 492b49d128SYangbo Lu int ocelot_ptp_settime64(struct ptp_clock_info *ptp, 502b49d128SYangbo Lu const struct timespec64 *ts); 512b49d128SYangbo Lu int ocelot_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta); 522b49d128SYangbo Lu int ocelot_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm); 53cc2d87bbSYangbo Lu int ocelot_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin, 54cc2d87bbSYangbo Lu enum ptp_pin_function func, unsigned int chan); 55cc2d87bbSYangbo Lu int ocelot_ptp_enable(struct ptp_clock_info *ptp, 56cc2d87bbSYangbo Lu struct ptp_clock_request *rq, int on); 57881321b6SVladimir Oltean int ocelot_init_timestamp(struct ocelot *ocelot, 58881321b6SVladimir Oltean const struct ptp_clock_info *info); 592b49d128SYangbo Lu int ocelot_deinit_timestamp(struct ocelot *ocelot); 602b49d128SYangbo Lu #endif 61