linux/drivers/ptp/ptp_dfl_tod.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * DFL device driver for Time-of-Day (ToD) private feature
 *
 * Copyright (C) 2023 Intel Corporation
 */

#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/dfl.h>
#include <linux/gcd.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/ptp_clock_kernel.h>
#include <linux/spinlock.h>
#include <linux/units.h>

#define FME_FEATURE_ID_TOD

/* ToD clock register space. */
#define TOD_CLK_FREQ

/*
 * The read sequence of ToD timestamp registers: TOD_NANOSEC, TOD_SECONDSL and
 * TOD_SECONDSH, because there is a hardware snapshot whenever the TOD_NANOSEC
 * register is read.
 *
 * The ToD IP requires writing registers in the reverse order to the read sequence.
 * The timestamp is corrected when the TOD_NANOSEC register is written, so the
 * sequence of write TOD registers: TOD_SECONDSH, TOD_SECONDSL and TOD_NANOSEC.
 */
#define TOD_SECONDSH
#define TOD_SECONDSL
#define TOD_NANOSEC
#define TOD_PERIOD
#define TOD_ADJUST_PERIOD
#define TOD_ADJUST_COUNT
#define TOD_DRIFT_ADJUST
#define TOD_DRIFT_ADJUST_RATE
#define PERIOD_FRAC_OFFSET
#define SECONDS_MSB
#define SECONDS_LSB
#define TOD_SECONDSH_SEC_MSB

#define CAL_SECONDS(m, l)

#define TOD_PERIOD_MASK
#define TOD_PERIOD_MAX
#define TOD_PERIOD_MIN
#define TOD_DRIFT_ADJUST_MASK
#define TOD_DRIFT_ADJUST_FNS_MAX
#define TOD_DRIFT_ADJUST_RATE_MAX
#define TOD_ADJUST_COUNT_MASK
#define TOD_ADJUST_COUNT_MAX
#define TOD_ADJUST_INTERVAL_US
#define TOD_ADJUST_MS
#define TOD_ADJUST_MS_MAX
#define TOD_ADJUST_MAX_US
#define TOD_MAX_ADJ

struct dfl_tod {};

/*
 * A fine ToD HW clock offset adjustment. To perform the fine offset adjustment, the
 * adjust_period and adjust_count argument are used to update the TOD_ADJUST_PERIOD
 * and TOD_ADJUST_COUNT register for in hardware. The dt->tod_lock spinlock must be
 * held when calling this function.
 */
static int fine_adjust_tod_clock(struct dfl_tod *dt, u32 adjust_period,
				 u32 adjust_count)
{}

/*
 * A coarse ToD HW clock offset adjustment. The coarse time adjustment performs by
 * adding or subtracting the delta value from the current ToD HW clock time.
 */
static int coarse_adjust_tod_clock(struct dfl_tod *dt, s64 delta)
{}

static int dfl_tod_adjust_fine(struct ptp_clock_info *ptp, long scaled_ppm)
{}

static int dfl_tod_adjust_time(struct ptp_clock_info *ptp, s64 delta)
{}

static int dfl_tod_get_timex(struct ptp_clock_info *ptp, struct timespec64 *ts,
			     struct ptp_system_timestamp *sts)
{}

static int dfl_tod_set_time(struct ptp_clock_info *ptp,
			    const struct timespec64 *ts)
{}

static struct ptp_clock_info dfl_tod_clock_ops =;

static int dfl_tod_probe(struct dfl_device *ddev)
{}

static void dfl_tod_remove(struct dfl_device *ddev)
{}

static const struct dfl_device_id dfl_tod_ids[] =;
MODULE_DEVICE_TABLE(dfl, dfl_tod_ids);

static struct dfl_driver dfl_tod_driver =;
module_dfl_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();