1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* cavium_ptp.h - PTP 1588 clock on Cavium hardware
3 * Copyright (c) 2003-2015, 2017 Cavium, Inc.
9 #include <linux/ptp_clock_kernel.h>
10 #include <linux/timecounter.h>
15 /* Serialize access to cycle_counter, time_counter and hw_registers */
17 struct cyclecounter cycle_counter;
18 struct timecounter time_counter;
19 void __iomem *reg_base;
23 struct ptp_clock_info ptp_info;
24 struct ptp_clock *ptp_clock;
27 #if IS_REACHABLE(CONFIG_CAVIUM_PTP)
29 struct cavium_ptp *cavium_ptp_get(void);
30 void cavium_ptp_put(struct cavium_ptp *ptp);
32 static inline u64 cavium_ptp_tstamp2time(struct cavium_ptp *ptp, u64 tstamp)
37 spin_lock_irqsave(&ptp->spin_lock, flags);
38 ret = timecounter_cyc2time(&ptp->time_counter, tstamp);
39 spin_unlock_irqrestore(&ptp->spin_lock, flags);
44 static inline int cavium_ptp_clock_index(struct cavium_ptp *clock)
46 return ptp_clock_index(clock->ptp_clock);
51 static inline struct cavium_ptp *cavium_ptp_get(void)
53 return ERR_PTR(-ENODEV);
56 static inline void cavium_ptp_put(struct cavium_ptp *ptp) {}
58 static inline u64 cavium_ptp_tstamp2time(struct cavium_ptp *ptp, u64 tstamp)
63 static inline int cavium_ptp_clock_index(struct cavium_ptp *clock)