linux/drivers/net/phy/bcm-phy-ptp.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2022 Meta Platforms Inc.
 * Copyright (C) 2022 Jonathan Lemon <[email protected]>
 */

#include <asm/unaligned.h>
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/ptp_classify.h>
#include <linux/ptp_clock_kernel.h>
#include <linux/net_tstamp.h>
#include <linux/netdevice.h>
#include <linux/workqueue.h>

#include "bcm-phy-lib.h"

/* IEEE 1588 Expansion registers */
#define SLICE_CTRL
#define SLICE_TX_EN
#define SLICE_RX_EN
#define TX_EVENT_MODE
#define MODE_TX_UPDATE_CF
#define MODE_TX_REPLACE_TS_CF
#define MODE_TX_REPLACE_TS
#define RX_EVENT_MODE
#define MODE_RX_UPDATE_CF
#define MODE_RX_INSERT_TS_48
#define MODE_RX_INSERT_TS_64

#define MODE_EVT_SHIFT_SYNC
#define MODE_EVT_SHIFT_DELAY_REQ
#define MODE_EVT_SHIFT_PDELAY_REQ
#define MODE_EVT_SHIFT_PDELAY_RESP

#define MODE_SEL_SHIFT_PORT
#define MODE_SEL_SHIFT_CPU

#define RX_MODE_SEL(sel, evt, act)

#define TX_MODE_SEL(sel, evt, act)

/* needs global TS capture first */
#define TX_TS_CAPTURE
#define TX_TS_CAP_EN
#define RX_TS_CAPTURE
#define RX_TS_CAP_EN

#define TIME_CODE_0
#define TIME_CODE_1
#define TIME_CODE_2
#define TIME_CODE_3
#define TIME_CODE_4

#define DPLL_SELECT
#define DPLL_HB_MODE2

#define SHADOW_CTRL
#define SHADOW_LOAD
#define TIME_CODE_LOAD
#define SYNC_OUT_LOAD
#define NCO_TIME_LOAD
#define FREQ_LOAD
#define INTR_MASK
#define INTR_STATUS
#define INTC_FSYNC
#define INTC_SOP

#define NCO_FREQ_LSB
#define NCO_FREQ_MSB

#define NCO_TIME_0
#define NCO_TIME_1
#define NCO_TIME_2_CTRL
#define FREQ_MDIO_SEL

#define SYNC_OUT_0
#define SYNC_OUT_1
#define SYNC_OUT_2

#define SYNC_IN_DIVIDER

#define SYNOUT_TS_0
#define SYNOUT_TS_1
#define SYNOUT_TS_2

#define NSE_CTRL
#define NSE_GMODE_EN
#define NSE_CAPTURE_EN
#define NSE_INIT
#define NSE_CPU_FRAMESYNC
#define NSE_SYNC1_FRAMESYNC
#define NSE_FRAMESYNC_MASK
#define NSE_PEROUT_EN
#define NSE_ONESHOT_EN
#define NSE_SYNC_OUT_MASK

#define TS_READ_CTRL
#define TS_READ_START
#define TS_READ_END

#define HB_REG_0
#define HB_REG_1
#define HB_REG_2
#define HB_REG_3
#define HB_REG_4
#define HB_STAT_CTRL
#define HB_READ_START
#define HB_READ_END
#define HB_READ_MASK

#define TS_REG_0
#define TS_REG_1
#define TS_REG_2
#define TS_REG_3

#define TS_INFO_0
#define TS_INFO_1

#define TIMECODE_CTRL
#define TX_TIMECODE_SEL
#define RX_TIMECODE_SEL

#define TIME_SYNC
#define TIME_SYNC_EN

struct bcm_ptp_private {};

struct bcm_ptp_skb_cb {};

struct bcm_ptp_capture {};

#define BCM_SKB_CB(skb)
#define SKB_TS_TIMEOUT

#define BCM_MAX_PULSE_8NS
#define BCM_MAX_PERIOD_8NS

#define BRCM_PHY_MODEL(phydev)

static struct bcm_ptp_private *mii2priv(struct mii_timestamper *mii_ts)
{}

static struct bcm_ptp_private *ptp2priv(struct ptp_clock_info *info)
{}

static void bcm_ptp_get_framesync_ts(struct phy_device *phydev,
				     struct timespec64 *ts)
{}

static u16 bcm_ptp_framesync_disable(struct phy_device *phydev, u16 orig_ctrl)
{}

static void bcm_ptp_framesync_restore(struct phy_device *phydev, u16 orig_ctrl)
{}

static void bcm_ptp_framesync(struct phy_device *phydev, u16 ctrl)
{}

static int bcm_ptp_framesync_ts(struct phy_device *phydev,
				struct ptp_system_timestamp *sts,
				struct timespec64 *ts,
				u16 orig_ctrl)
{}

static int bcm_ptp_gettimex(struct ptp_clock_info *info,
			    struct timespec64 *ts,
			    struct ptp_system_timestamp *sts)
{}

static int bcm_ptp_settime_locked(struct bcm_ptp_private *priv,
				  const struct timespec64 *ts)
{}

static int bcm_ptp_settime(struct ptp_clock_info *info,
			   const struct timespec64 *ts)
{}

static int bcm_ptp_adjtime_locked(struct bcm_ptp_private *priv,
				  s64 delta_ns)
{}

static int bcm_ptp_adjtime(struct ptp_clock_info *info, s64 delta_ns)
{}

/* A 125Mhz clock should adjust 8ns per pulse.
 * The frequency adjustment base is 0x8000 0000, or 8*2^28.
 *
 * Frequency adjustment is
 * adj = scaled_ppm * 8*2^28 / (10^6 * 2^16)
 *   which simplifies to:
 * adj = scaled_ppm * 2^9 / 5^6
 */
static int bcm_ptp_adjfine(struct ptp_clock_info *info, long scaled_ppm)
{}

static bool bcm_ptp_rxtstamp(struct mii_timestamper *mii_ts,
			     struct sk_buff *skb, int type)
{}

static bool bcm_ptp_get_tstamp(struct bcm_ptp_private *priv,
			       struct bcm_ptp_capture *capts)
{}

static void bcm_ptp_match_tstamp(struct bcm_ptp_private *priv,
				 struct bcm_ptp_capture *capts)
{}

static long bcm_ptp_do_aux_work(struct ptp_clock_info *info)
{}

static int bcm_ptp_cancel_func(struct bcm_ptp_private *priv)
{}

static void bcm_ptp_perout_work(struct work_struct *pin_work)
{}

static int bcm_ptp_perout_locked(struct bcm_ptp_private *priv,
				 struct ptp_perout_request *req, int on)
{}

static void bcm_ptp_extts_work(struct work_struct *pin_work)
{}

static int bcm_ptp_extts_locked(struct bcm_ptp_private *priv, int on)
{}

static int bcm_ptp_enable(struct ptp_clock_info *info,
			  struct ptp_clock_request *rq, int on)
{}

static int bcm_ptp_verify(struct ptp_clock_info *info, unsigned int pin,
			  enum ptp_pin_function func, unsigned int chan)
{}

static const struct ptp_clock_info bcm_ptp_clock_info =;

static void bcm_ptp_txtstamp(struct mii_timestamper *mii_ts,
			     struct sk_buff *skb, int type)
{}

static int bcm_ptp_hwtstamp(struct mii_timestamper *mii_ts,
			    struct kernel_hwtstamp_config *cfg,
			    struct netlink_ext_ack *extack)
{}

static int bcm_ptp_ts_info(struct mii_timestamper *mii_ts,
			   struct kernel_ethtool_ts_info *ts_info)
{}

void bcm_ptp_stop(struct bcm_ptp_private *priv)
{}
EXPORT_SYMBOL_GPL();

void bcm_ptp_config_init(struct phy_device *phydev)
{}
EXPORT_SYMBOL_GPL();

static void bcm_ptp_init(struct bcm_ptp_private *priv)
{}

struct bcm_ptp_private *bcm_ptp_probe(struct phy_device *phydev)
{}
EXPORT_SYMBOL_GPL();

MODULE_LICENSE();
MODULE_DESCRIPTION();