1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Microchip KSZ PTP Implementation 3 * 4 * Copyright (C) 2020 ARRI Lighting 5 * Copyright (C) 2022 Microchip Technology Inc. 6 */ 7 8 #ifndef _NET_DSA_DRIVERS_KSZ_PTP_H 9 #define _NET_DSA_DRIVERS_KSZ_PTP_H 10 11 #if IS_ENABLED(CONFIG_NET_DSA_MICROCHIP_KSZ_PTP) 12 13 #include <linux/ptp_clock_kernel.h> 14 15 struct ksz_ptp_data { 16 struct ptp_clock_info caps; 17 struct ptp_clock *clock; 18 /* Serializes all operations on the PTP hardware clock */ 19 struct mutex lock; 20 /* lock for accessing the clock_time */ 21 spinlock_t clock_lock; 22 struct timespec64 clock_time; 23 }; 24 25 int ksz_ptp_clock_register(struct dsa_switch *ds); 26 27 void ksz_ptp_clock_unregister(struct dsa_switch *ds); 28 29 int ksz_get_ts_info(struct dsa_switch *ds, int port, 30 struct ethtool_ts_info *ts); 31 int ksz_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *ifr); 32 int ksz_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr); 33 void ksz_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb); 34 void ksz_port_deferred_xmit(struct kthread_work *work); 35 bool ksz_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb, 36 unsigned int type); 37 int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p); 38 void ksz_ptp_irq_free(struct dsa_switch *ds, u8 p); 39 40 #else 41 42 struct ksz_ptp_data { 43 /* Serializes all operations on the PTP hardware clock */ 44 struct mutex lock; 45 }; 46 47 static inline int ksz_ptp_clock_register(struct dsa_switch *ds) 48 { 49 return 0; 50 } 51 52 static inline void ksz_ptp_clock_unregister(struct dsa_switch *ds) { } 53 54 static inline int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p) 55 { 56 return 0; 57 } 58 59 static inline void ksz_ptp_irq_free(struct dsa_switch *ds, u8 p) {} 60 61 #define ksz_get_ts_info NULL 62 63 #define ksz_hwtstamp_get NULL 64 65 #define ksz_hwtstamp_set NULL 66 67 #define ksz_port_rxtstamp NULL 68 69 #define ksz_port_txtstamp NULL 70 71 #define ksz_port_deferred_xmit NULL 72 73 #endif /* End of CONFIG_NET_DSA_MICROCHIP_KSZ_PTP */ 74 75 #endif 76