// SPDX-License-Identifier: GPL-2.0-only /******************************************************************************* PTP 1588 clock using the STMMAC. Copyright (C) 2013 Vayavya Labs Pvt Ltd Author: Rayagond Kokatanur <[email protected]> *******************************************************************************/ #include "stmmac.h" #include "stmmac_ptp.h" #include "dwmac4.h" /** * stmmac_adjust_freq * * @ptp: pointer to ptp_clock_info structure * @scaled_ppm: desired period change in scaled parts per million * * Description: this function will adjust the frequency of hardware clock. * * Scaled parts per million is ppm with a 16-bit binary fractional field. */ static int stmmac_adjust_freq(struct ptp_clock_info *ptp, long scaled_ppm) { … } /** * stmmac_adjust_time * * @ptp: pointer to ptp_clock_info structure * @delta: desired change in nanoseconds * * Description: this function will shift/adjust the hardware clock time. */ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta) { … } /** * stmmac_get_time * * @ptp: pointer to ptp_clock_info structure * @ts: pointer to hold time/result * * Description: this function will read the current time from the * hardware clock and store it in @ts. */ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts) { … } /** * stmmac_set_time * * @ptp: pointer to ptp_clock_info structure * @ts: time value to set * * Description: this function will set the current time on the * hardware clock. */ static int stmmac_set_time(struct ptp_clock_info *ptp, const struct timespec64 *ts) { … } static int stmmac_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *rq, int on) { … } /** * stmmac_get_syncdevicetime * @device: current device time * @system: system counter value read synchronously with device time * @ctx: context provided by timekeeping code * Description: Read device and system clock simultaneously and return the * corrected clock values in ns. **/ static int stmmac_get_syncdevicetime(ktime_t *device, struct system_counterval_t *system, void *ctx) { … } static int stmmac_getcrosststamp(struct ptp_clock_info *ptp, struct system_device_crosststamp *xtstamp) { … } /* structure describing a PTP hardware clock */ static struct ptp_clock_info stmmac_ptp_clock_ops = …; /** * stmmac_ptp_register * @priv: driver private structure * Description: this function will register the ptp clock driver * to kernel. It also does some house keeping work. */ void stmmac_ptp_register(struct stmmac_priv *priv) { … } /** * stmmac_ptp_unregister * @priv: driver private structure * Description: this function will remove/unregister the ptp clock driver * from the kernel. */ void stmmac_ptp_unregister(struct stmmac_priv *priv) { … }