// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 1999 - 2018 Intel Corporation. */ /* PTP 1588 Hardware Clock (PHC) * Derived from PTP Hardware Clock driver for Intel 82576 and 82580 (igb) * Copyright (C) 2011 Richard Cochran <[email protected]> */ #include "e1000.h" #ifdef CONFIG_E1000E_HWTS #include <linux/clocksource.h> #include <linux/ktime.h> #include <asm/tsc.h> #endif /** * e1000e_phc_adjfine - adjust the frequency of the hardware clock * @ptp: ptp clock structure * @delta: Desired frequency chance in scaled parts per million * * Adjust the frequency of the PHC cycle counter by the indicated delta from * the base frequency. * * Scaled parts per million is ppm but with a 16 bit binary fractional field. **/ static int e1000e_phc_adjfine(struct ptp_clock_info *ptp, long delta) { … } /** * e1000e_phc_adjtime - Shift the time of the hardware clock * @ptp: ptp clock structure * @delta: Desired change in nanoseconds * * Adjust the timer by resetting the timecounter structure. **/ static int e1000e_phc_adjtime(struct ptp_clock_info *ptp, s64 delta) { … } #ifdef CONFIG_E1000E_HWTS #define MAX_HW_WAIT_COUNT … /** * e1000e_phc_get_syncdevicetime - Callback given to timekeeping code reads system/device registers * @device: current device time * @system: system counter value read synchronously with device time * @ctx: context provided by timekeeping code * * Read device and system (ART) clock simultaneously and return the corrected * clock values in ns. **/ static int e1000e_phc_get_syncdevicetime(ktime_t *device, struct system_counterval_t *system, void *ctx) { … } /** * e1000e_phc_getcrosststamp - Reads the current system/device cross timestamp * @ptp: ptp clock structure * @xtstamp: structure containing timestamp * * Read device and system (ART) clock simultaneously and return the scaled * clock values in ns. **/ static int e1000e_phc_getcrosststamp(struct ptp_clock_info *ptp, struct system_device_crosststamp *xtstamp) { … } #endif/*CONFIG_E1000E_HWTS*/ /** * e1000e_phc_gettimex - Reads the current time from the hardware clock and * system clock * @ptp: ptp clock structure * @ts: timespec structure to hold the current PHC time * @sts: structure to hold the current system time * * Read the timecounter and return the correct value in ns after converting * it into a struct timespec. **/ static int e1000e_phc_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts, struct ptp_system_timestamp *sts) { … } /** * e1000e_phc_settime - Set the current time on the hardware clock * @ptp: ptp clock structure * @ts: timespec containing the new time for the cycle counter * * Reset the timecounter to use a new base value instead of the kernel * wall timer value. **/ static int e1000e_phc_settime(struct ptp_clock_info *ptp, const struct timespec64 *ts) { … } /** * e1000e_phc_enable - enable or disable an ancillary feature * @ptp: ptp clock structure * @request: Desired resource to enable or disable * @on: Caller passes one to enable or zero to disable * * Enable (or disable) ancillary features of the PHC subsystem. * Currently, no ancillary features are supported. **/ static int e1000e_phc_enable(struct ptp_clock_info __always_unused *ptp, struct ptp_clock_request __always_unused *request, int __always_unused on) { … } static void e1000e_systim_overflow_work(struct work_struct *work) { … } static const struct ptp_clock_info e1000e_ptp_clock_info = …; /** * e1000e_ptp_init - initialize PTP for devices which support it * @adapter: board private structure * * This function performs the required steps for enabling PTP support. * If PTP support has already been loaded it simply calls the cyclecounter * init routine and exits. **/ void e1000e_ptp_init(struct e1000_adapter *adapter) { … } /** * e1000e_ptp_remove - disable PTP device and stop the overflow check * @adapter: board private structure * * Stop the PTP support, and cancel the delayed work. **/ void e1000e_ptp_remove(struct e1000_adapter *adapter) { … }