Commit 13e90880 authored by Maxime Chevallier's avatar Maxime Chevallier Committed by Jakub Kicinski
Browse files

net: stmmac: Use per-hw ptp clock ops



The auxiliary snapshot configuration was found to differ depending on
the dwmac version. To prepare supporting this, allow specifying the
ptp_clock_info ops in the hwif array

Reviewed-by: default avatarDaniel Machon <daniel.machon@microchip.com>
Signed-off-by: default avatarMaxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20241112170658.2388529-3-maxime.chevallier@bootlin.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 80dc1ff7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -551,6 +551,8 @@ struct mac_device_info;
extern const struct stmmac_hwtimestamp stmmac_ptp;
extern const struct stmmac_mode_ops dwmac4_ring_mode_ops;

extern const struct ptp_clock_info stmmac_ptp_clock_ops;

struct mac_link {
	u32 caps;
	u32 speed_mask;
+11 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ static const struct stmmac_hwif_entry {
	const void *dma;
	const void *mac;
	const void *hwtimestamp;
	const void *ptp;
	const void *mode;
	const void *tc;
	const void *mmc;
@@ -134,6 +135,7 @@ static const struct stmmac_hwif_entry {
		.dma = &dwmac100_dma_ops,
		.mac = &dwmac100_ops,
		.hwtimestamp = &stmmac_ptp,
		.ptp = &stmmac_ptp_clock_ops,
		.mode = NULL,
		.tc = NULL,
		.mmc = &dwmac_mmc_ops,
@@ -152,6 +154,7 @@ static const struct stmmac_hwif_entry {
		.dma = &dwmac1000_dma_ops,
		.mac = &dwmac1000_ops,
		.hwtimestamp = &stmmac_ptp,
		.ptp = &stmmac_ptp_clock_ops,
		.mode = NULL,
		.tc = NULL,
		.mmc = &dwmac_mmc_ops,
@@ -171,6 +174,7 @@ static const struct stmmac_hwif_entry {
		.dma = &dwmac4_dma_ops,
		.mac = &dwmac4_ops,
		.hwtimestamp = &stmmac_ptp,
		.ptp = &stmmac_ptp_clock_ops,
		.mode = NULL,
		.tc = &dwmac4_tc_ops,
		.mmc = &dwmac_mmc_ops,
@@ -192,6 +196,7 @@ static const struct stmmac_hwif_entry {
		.dma = &dwmac4_dma_ops,
		.mac = &dwmac410_ops,
		.hwtimestamp = &stmmac_ptp,
		.ptp = &stmmac_ptp_clock_ops,
		.mode = &dwmac4_ring_mode_ops,
		.tc = &dwmac510_tc_ops,
		.mmc = &dwmac_mmc_ops,
@@ -213,6 +218,7 @@ static const struct stmmac_hwif_entry {
		.dma = &dwmac410_dma_ops,
		.mac = &dwmac410_ops,
		.hwtimestamp = &stmmac_ptp,
		.ptp = &stmmac_ptp_clock_ops,
		.mode = &dwmac4_ring_mode_ops,
		.tc = &dwmac510_tc_ops,
		.mmc = &dwmac_mmc_ops,
@@ -234,6 +240,7 @@ static const struct stmmac_hwif_entry {
		.dma = &dwmac410_dma_ops,
		.mac = &dwmac510_ops,
		.hwtimestamp = &stmmac_ptp,
		.ptp = &stmmac_ptp_clock_ops,
		.mode = &dwmac4_ring_mode_ops,
		.tc = &dwmac510_tc_ops,
		.mmc = &dwmac_mmc_ops,
@@ -256,6 +263,7 @@ static const struct stmmac_hwif_entry {
		.dma = &dwxgmac210_dma_ops,
		.mac = &dwxgmac210_ops,
		.hwtimestamp = &stmmac_ptp,
		.ptp = &stmmac_ptp_clock_ops,
		.mode = NULL,
		.tc = &dwxgmac_tc_ops,
		.mmc = &dwxgmac_mmc_ops,
@@ -278,6 +286,7 @@ static const struct stmmac_hwif_entry {
		.dma = &dwxgmac210_dma_ops,
		.mac = &dwxlgmac2_ops,
		.hwtimestamp = &stmmac_ptp,
		.ptp = &stmmac_ptp_clock_ops,
		.mode = NULL,
		.tc = &dwxgmac_tc_ops,
		.mmc = &dwxgmac_mmc_ops,
@@ -362,6 +371,8 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
		priv->fpe_cfg.reg = entry->regs.fpe_reg;
		priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off;
		priv->mmcaddr = priv->ioaddr + entry->regs.mmc_off;
		memcpy(&priv->ptp_clock_ops, entry->ptp,
		       sizeof(struct ptp_clock_info));
		if (entry->est)
			priv->estaddr = priv->ioaddr + entry->regs.est_off;

+1 −3
Original line number Diff line number Diff line
@@ -265,7 +265,7 @@ static int stmmac_getcrosststamp(struct ptp_clock_info *ptp,
}

/* structure describing a PTP hardware clock */
static struct ptp_clock_info stmmac_ptp_clock_ops = {
const struct ptp_clock_info stmmac_ptp_clock_ops = {
	.owner = THIS_MODULE,
	.name = "stmmac ptp",
	.max_adj = 62500000,
@@ -303,8 +303,6 @@ void stmmac_ptp_register(struct stmmac_priv *priv)
	if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate)
		priv->plat->cdc_error_adj = (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_rate;

	priv->ptp_clock_ops = stmmac_ptp_clock_ops;

	priv->ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num;
	priv->ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n;