Antoine Tenart | 45bce17 | 2019-08-12 16:45:34 +0200 | [diff] [blame] | 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 |
Yangbo Lu | 2b49d12 | 2020-04-20 10:46:45 +0800 | [diff] [blame] | 7 | * Copyright 2020 NXP |
Antoine Tenart | 45bce17 | 2019-08-12 16:45:34 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef _MSCC_OCELOT_PTP_H_ |
| 11 | #define _MSCC_OCELOT_PTP_H_ |
| 12 | |
Yangbo Lu | 2b49d12 | 2020-04-20 10:46:45 +0800 | [diff] [blame] | 13 | #include <linux/ptp_clock_kernel.h> |
| 14 | #include <soc/mscc/ocelot.h> |
| 15 | |
Antoine Tenart | 45bce17 | 2019-08-12 16:45:34 +0200 | [diff] [blame] | 16 | #define PTP_PIN_CFG_RSZ 0x20 |
| 17 | #define PTP_PIN_TOD_SEC_MSB_RSZ PTP_PIN_CFG_RSZ |
| 18 | #define PTP_PIN_TOD_SEC_LSB_RSZ PTP_PIN_CFG_RSZ |
| 19 | #define PTP_PIN_TOD_NSEC_RSZ PTP_PIN_CFG_RSZ |
Yangbo Lu | 94aca08 | 2020-04-20 10:46:48 +0800 | [diff] [blame] | 20 | #define PTP_PIN_WF_HIGH_PERIOD_RSZ PTP_PIN_CFG_RSZ |
| 21 | #define PTP_PIN_WF_LOW_PERIOD_RSZ PTP_PIN_CFG_RSZ |
Antoine Tenart | 45bce17 | 2019-08-12 16:45:34 +0200 | [diff] [blame] | 22 | |
| 23 | #define PTP_PIN_CFG_DOM BIT(0) |
| 24 | #define PTP_PIN_CFG_SYNC BIT(2) |
| 25 | #define PTP_PIN_CFG_ACTION(x) ((x) << 3) |
| 26 | #define PTP_PIN_CFG_ACTION_MASK PTP_PIN_CFG_ACTION(0x7) |
| 27 | |
| 28 | enum { |
| 29 | PTP_PIN_ACTION_IDLE = 0, |
| 30 | PTP_PIN_ACTION_LOAD, |
| 31 | PTP_PIN_ACTION_SAVE, |
| 32 | PTP_PIN_ACTION_CLOCK, |
| 33 | PTP_PIN_ACTION_DELTA, |
| 34 | PTP_PIN_ACTION_NOSYNC, |
| 35 | PTP_PIN_ACTION_SYNC, |
| 36 | }; |
| 37 | |
| 38 | #define PTP_CFG_MISC_PTP_EN BIT(2) |
| 39 | |
| 40 | #define PSEC_PER_SEC 1000000000000LL |
| 41 | |
| 42 | #define PTP_CFG_CLK_ADJ_CFG_ENA BIT(0) |
| 43 | #define PTP_CFG_CLK_ADJ_CFG_DIR BIT(1) |
| 44 | |
| 45 | #define PTP_CFG_CLK_ADJ_FREQ_NS BIT(30) |
| 46 | |
Yangbo Lu | 2b49d12 | 2020-04-20 10:46:45 +0800 | [diff] [blame] | 47 | int ocelot_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts); |
| 48 | int ocelot_ptp_settime64(struct ptp_clock_info *ptp, |
| 49 | const struct timespec64 *ts); |
| 50 | int ocelot_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta); |
| 51 | int ocelot_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm); |
Yangbo Lu | cc2d87b | 2020-04-20 10:46:49 +0800 | [diff] [blame] | 52 | int ocelot_ptp_verify(struct ptp_clock_info *ptp, unsigned int pin, |
| 53 | enum ptp_pin_function func, unsigned int chan); |
| 54 | int ocelot_ptp_enable(struct ptp_clock_info *ptp, |
| 55 | struct ptp_clock_request *rq, int on); |
Vladimir Oltean | 881321b | 2020-09-18 13:57:51 +0300 | [diff] [blame] | 56 | int ocelot_init_timestamp(struct ocelot *ocelot, |
| 57 | const struct ptp_clock_info *info); |
Yangbo Lu | 2b49d12 | 2020-04-20 10:46:45 +0800 | [diff] [blame] | 58 | int ocelot_deinit_timestamp(struct ocelot *ocelot); |
Antoine Tenart | 45bce17 | 2019-08-12 16:45:34 +0200 | [diff] [blame] | 59 | #endif |