Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92ba6888 authored by Rayagond Kokatanur's avatar Rayagond Kokatanur Committed by David S. Miller
Browse files

stmmac: add the support for PTP hw clock driver



This patch implements PHC (ptp hardware clock) driver for stmmac
driver to support 1588 PTP.

V2: added support for FINE method, reduced loop delay and review spinlock.

Signed-off-by: default avatarRayagond Kokatanur <rayagond@vayavyalabs.com>
Hacked-by: default avatarGiuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 891434b1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ config STMMAC_ETH
	select MII
	select PHYLIB
	select CRC32
	select PTP_1588_CLOCK
	---help---
	  This is the driver for the Ethernet IPs are built around a
	  Synopsys IP Core and only tested on the STMicroelectronics
+1 −1
Original line number Diff line number Diff line
@@ -4,4 +4,4 @@ stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o
stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o	\
	      chain_mode.o dwmac_lib.o dwmac1000_core.o  dwmac1000_dma.o \
	      dwmac100_core.o dwmac100_dma.o enh_desc.o  norm_desc.o \
	      mmc_core.o stmmac_hwtstamp.o $(stmmac-y)
	      mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o $(stmmac-y)
+3 −0
Original line number Diff line number Diff line
@@ -411,6 +411,9 @@ struct stmmac_hwtimestamp {
	void (*config_sub_second_increment) (void __iomem *ioaddr);
	int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec);
	int (*config_addend)(void __iomem *ioaddr, u32 addend);
	int (*adjust_systime)(void __iomem *ioaddr, u32 sec, u32 nsec,
			      int add_sub);
	u64 (*get_systime)(void __iomem *ioaddr);
};

struct mac_link {
+6 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <linux/phy.h>
#include <linux/pci.h>
#include "common.h"
#include <linux/ptp_clock_kernel.h>

struct stmmac_priv {
	/* Frequently used values are kept adjacent for cache effect */
@@ -103,6 +104,9 @@ struct stmmac_priv {
	int hwts_rx_en;
	unsigned int default_addend;
	u32 adv_ts;
	struct ptp_clock *ptp_clock;
	struct ptp_clock_info ptp_clock_ops;
	spinlock_t ptp_lock;
};

extern int phyaddr;
@@ -113,6 +117,8 @@ extern void stmmac_set_ethtool_ops(struct net_device *netdev);
extern const struct stmmac_desc_ops enh_desc_ops;
extern const struct stmmac_desc_ops ndesc_ops;
extern const struct stmmac_hwtimestamp stmmac_ptp;
extern int stmmac_ptp_register(struct stmmac_priv *priv);
extern void stmmac_ptp_unregister(struct stmmac_priv *priv);
int stmmac_freeze(struct net_device *ndev);
int stmmac_restore(struct net_device *ndev);
int stmmac_resume(struct net_device *ndev);
+3 −0
Original line number Diff line number Diff line
@@ -737,6 +737,9 @@ static int stmmac_get_ts_info(struct net_device *dev,
					SOF_TIMESTAMPING_RX_HARDWARE |
					SOF_TIMESTAMPING_RAW_HARDWARE;

		if (priv->ptp_clock)
			info->phc_index = ptp_clock_index(priv->ptp_clock);

		info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);

		info->rx_filters = ((1 << HWTSTAMP_FILTER_NONE) |
Loading