1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Microchip KSZ PTP Implementation
4 * Copyright (C) 2020 ARRI Lighting
5 * Copyright (C) 2022 Microchip Technology Inc.
8 #ifndef _NET_DSA_DRIVERS_KSZ_PTP_H
9 #define _NET_DSA_DRIVERS_KSZ_PTP_H
11 #if IS_ENABLED(CONFIG_NET_DSA_MICROCHIP_KSZ_PTP)
13 #include <linux/ptp_clock_kernel.h>
15 #define KSZ_PTP_N_GPIO 2
17 enum ksz_ptp_tou_mode {
23 struct ptp_clock_info caps;
24 struct ptp_clock *clock;
25 struct ptp_pin_desc pin_config[KSZ_PTP_N_GPIO];
26 /* Serializes all operations on the PTP hardware clock */
28 /* lock for accessing the clock_time */
29 spinlock_t clock_lock;
30 struct timespec64 clock_time;
31 enum ksz_ptp_tou_mode tou_mode;
32 struct timespec64 perout_target_time_first; /* start of first pulse */
33 struct timespec64 perout_period;
36 int ksz_ptp_clock_register(struct dsa_switch *ds);
38 void ksz_ptp_clock_unregister(struct dsa_switch *ds);
40 int ksz_get_ts_info(struct dsa_switch *ds, int port,
41 struct kernel_ethtool_ts_info *ts);
42 int ksz_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *ifr);
43 int ksz_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr);
44 void ksz_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb);
45 void ksz_port_deferred_xmit(struct kthread_work *work);
46 bool ksz_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb,
48 int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p);
49 void ksz_ptp_irq_free(struct dsa_switch *ds, u8 p);
54 /* Serializes all operations on the PTP hardware clock */
58 static inline int ksz_ptp_clock_register(struct dsa_switch *ds)
63 static inline void ksz_ptp_clock_unregister(struct dsa_switch *ds) { }
65 static inline int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p)
70 static inline void ksz_ptp_irq_free(struct dsa_switch *ds, u8 p) {}
72 #define ksz_get_ts_info NULL
74 #define ksz_hwtstamp_get NULL
76 #define ksz_hwtstamp_set NULL
78 #define ksz_port_rxtstamp NULL
80 #define ksz_port_txtstamp NULL
82 #define ksz_port_deferred_xmit NULL
84 #endif /* End of CONFIG_NET_DSA_MICROCHIP_KSZ_PTP */