18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Microsemi Ocelot Switch driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * License: Dual MIT/GPL 68c2ecf20Sopenharmony_ci * Copyright (c) 2017 Microsemi Corporation 78c2ecf20Sopenharmony_ci * Copyright 2020 NXP 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef _MSCC_OCELOT_PTP_H_ 118c2ecf20Sopenharmony_ci#define _MSCC_OCELOT_PTP_H_ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/ptp_clock_kernel.h> 148c2ecf20Sopenharmony_ci#include <soc/mscc/ocelot.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define PTP_PIN_CFG_RSZ 0x20 178c2ecf20Sopenharmony_ci#define PTP_PIN_TOD_SEC_MSB_RSZ PTP_PIN_CFG_RSZ 188c2ecf20Sopenharmony_ci#define PTP_PIN_TOD_SEC_LSB_RSZ PTP_PIN_CFG_RSZ 198c2ecf20Sopenharmony_ci#define PTP_PIN_TOD_NSEC_RSZ PTP_PIN_CFG_RSZ 208c2ecf20Sopenharmony_ci#define PTP_PIN_WF_HIGH_PERIOD_RSZ PTP_PIN_CFG_RSZ 218c2ecf20Sopenharmony_ci#define PTP_PIN_WF_LOW_PERIOD_RSZ PTP_PIN_CFG_RSZ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define PTP_PIN_CFG_DOM BIT(0) 248c2ecf20Sopenharmony_ci#define PTP_PIN_CFG_SYNC BIT(2) 258c2ecf20Sopenharmony_ci#define PTP_PIN_CFG_ACTION(x) ((x) << 3) 268c2ecf20Sopenharmony_ci#define PTP_PIN_CFG_ACTION_MASK PTP_PIN_CFG_ACTION(0x7) 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cienum { 298c2ecf20Sopenharmony_ci PTP_PIN_ACTION_IDLE = 0, 308c2ecf20Sopenharmony_ci PTP_PIN_ACTION_LOAD, 318c2ecf20Sopenharmony_ci PTP_PIN_ACTION_SAVE, 328c2ecf20Sopenharmony_ci PTP_PIN_ACTION_CLOCK, 338c2ecf20Sopenharmony_ci PTP_PIN_ACTION_DELTA, 348c2ecf20Sopenharmony_ci PTP_PIN_ACTION_NOSYNC, 358c2ecf20Sopenharmony_ci PTP_PIN_ACTION_SYNC, 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define PTP_CFG_MISC_PTP_EN BIT(2) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define PSEC_PER_SEC 1000000000000LL 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define PTP_CFG_CLK_ADJ_CFG_ENA BIT(0) 438c2ecf20Sopenharmony_ci#define PTP_CFG_CLK_ADJ_CFG_DIR BIT(1) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define PTP_CFG_CLK_ADJ_FREQ_NS BIT(30) 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciint ocelot_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts); 488c2ecf20Sopenharmony_ciint ocelot_ptp_settime64(struct ptp_clock_info *ptp, 498c2ecf20Sopenharmony_ci const struct timespec64 *ts); 508c2ecf20Sopenharmony_ciint ocelot_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta); 518c2ecf20Sopenharmony_ciint ocelot_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm); 528c2ecf20Sopenharmony_ciint ocelot_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin, 538c2ecf20Sopenharmony_ci enum ptp_pin_function func, unsigned int chan); 548c2ecf20Sopenharmony_ciint ocelot_ptp_enable(struct ptp_clock_info *ptp, 558c2ecf20Sopenharmony_ci struct ptp_clock_request *rq, int on); 568c2ecf20Sopenharmony_ciint ocelot_init_timestamp(struct ocelot *ocelot, 578c2ecf20Sopenharmony_ci const struct ptp_clock_info *info); 588c2ecf20Sopenharmony_ciint ocelot_deinit_timestamp(struct ocelot *ocelot); 598c2ecf20Sopenharmony_ci#endif 60