linux-imx/drivers/net/dsa/microchip/ksz_ptp.h
Christian Eggers bb01ad3057 net: dsa: microchip: ptp: manipulating absolute time using ptp hw clock
This patch is used for reconstructing the absolute time from the 32bit
hardware time stamping value. The do_aux ioctl is used for reading the
ptp hardware clock and store it to global variable.
The timestamped value in tail tag during rx and register during tx are
32 bit value (2 bit seconds and 30 bit nanoseconds). The time taken to
read entire ptp clock will be time consuming. In order to speed up, the
software clock is maintained. This clock time will be added to 32 bit
timestamp to get the absolute time stamp.

Signed-off-by: Christian Eggers <ceggers@arri.de>
Co-developed-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-01-13 08:40:40 +00:00

57 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/* Microchip KSZ PTP Implementation
*
* Copyright (C) 2020 ARRI Lighting
* Copyright (C) 2022 Microchip Technology Inc.
*/
#ifndef _NET_DSA_DRIVERS_KSZ_PTP_H
#define _NET_DSA_DRIVERS_KSZ_PTP_H
#if IS_ENABLED(CONFIG_NET_DSA_MICROCHIP_KSZ_PTP)
#include <linux/ptp_clock_kernel.h>
struct ksz_ptp_data {
struct ptp_clock_info caps;
struct ptp_clock *clock;
/* Serializes all operations on the PTP hardware clock */
struct mutex lock;
/* lock for accessing the clock_time */
spinlock_t clock_lock;
struct timespec64 clock_time;
};
int ksz_ptp_clock_register(struct dsa_switch *ds);
void ksz_ptp_clock_unregister(struct dsa_switch *ds);
int ksz_get_ts_info(struct dsa_switch *ds, int port,
struct ethtool_ts_info *ts);
int ksz_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *ifr);
int ksz_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr);
#else
struct ksz_ptp_data {
/* Serializes all operations on the PTP hardware clock */
struct mutex lock;
};
static inline int ksz_ptp_clock_register(struct dsa_switch *ds)
{
return 0;
}
static inline void ksz_ptp_clock_unregister(struct dsa_switch *ds) { }
#define ksz_get_ts_info NULL
#define ksz_hwtstamp_get NULL
#define ksz_hwtstamp_set NULL
#endif /* End of CONFIG_NET_DSA_MICROCHIP_KSZ_PTP */
#endif