Skip to content

Commit 13e9088

Browse files
minimaxwellkuba-moo
authored andcommitted
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: Daniel Machon <[email protected]> Signed-off-by: Maxime Chevallier <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 80dc1ff commit 13e9088

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

drivers/net/ethernet/stmicro/stmmac/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ struct mac_device_info;
551551
extern const struct stmmac_hwtimestamp stmmac_ptp;
552552
extern const struct stmmac_mode_ops dwmac4_ring_mode_ops;
553553

554+
extern const struct ptp_clock_info stmmac_ptp_clock_ops;
555+
554556
struct mac_link {
555557
u32 caps;
556558
u32 speed_mask;

drivers/net/ethernet/stmicro/stmmac/hwif.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static const struct stmmac_hwif_entry {
113113
const void *dma;
114114
const void *mac;
115115
const void *hwtimestamp;
116+
const void *ptp;
116117
const void *mode;
117118
const void *tc;
118119
const void *mmc;
@@ -134,6 +135,7 @@ static const struct stmmac_hwif_entry {
134135
.dma = &dwmac100_dma_ops,
135136
.mac = &dwmac100_ops,
136137
.hwtimestamp = &stmmac_ptp,
138+
.ptp = &stmmac_ptp_clock_ops,
137139
.mode = NULL,
138140
.tc = NULL,
139141
.mmc = &dwmac_mmc_ops,
@@ -152,6 +154,7 @@ static const struct stmmac_hwif_entry {
152154
.dma = &dwmac1000_dma_ops,
153155
.mac = &dwmac1000_ops,
154156
.hwtimestamp = &stmmac_ptp,
157+
.ptp = &stmmac_ptp_clock_ops,
155158
.mode = NULL,
156159
.tc = NULL,
157160
.mmc = &dwmac_mmc_ops,
@@ -171,6 +174,7 @@ static const struct stmmac_hwif_entry {
171174
.dma = &dwmac4_dma_ops,
172175
.mac = &dwmac4_ops,
173176
.hwtimestamp = &stmmac_ptp,
177+
.ptp = &stmmac_ptp_clock_ops,
174178
.mode = NULL,
175179
.tc = &dwmac4_tc_ops,
176180
.mmc = &dwmac_mmc_ops,
@@ -192,6 +196,7 @@ static const struct stmmac_hwif_entry {
192196
.dma = &dwmac4_dma_ops,
193197
.mac = &dwmac410_ops,
194198
.hwtimestamp = &stmmac_ptp,
199+
.ptp = &stmmac_ptp_clock_ops,
195200
.mode = &dwmac4_ring_mode_ops,
196201
.tc = &dwmac510_tc_ops,
197202
.mmc = &dwmac_mmc_ops,
@@ -213,6 +218,7 @@ static const struct stmmac_hwif_entry {
213218
.dma = &dwmac410_dma_ops,
214219
.mac = &dwmac410_ops,
215220
.hwtimestamp = &stmmac_ptp,
221+
.ptp = &stmmac_ptp_clock_ops,
216222
.mode = &dwmac4_ring_mode_ops,
217223
.tc = &dwmac510_tc_ops,
218224
.mmc = &dwmac_mmc_ops,
@@ -234,6 +240,7 @@ static const struct stmmac_hwif_entry {
234240
.dma = &dwmac410_dma_ops,
235241
.mac = &dwmac510_ops,
236242
.hwtimestamp = &stmmac_ptp,
243+
.ptp = &stmmac_ptp_clock_ops,
237244
.mode = &dwmac4_ring_mode_ops,
238245
.tc = &dwmac510_tc_ops,
239246
.mmc = &dwmac_mmc_ops,
@@ -256,6 +263,7 @@ static const struct stmmac_hwif_entry {
256263
.dma = &dwxgmac210_dma_ops,
257264
.mac = &dwxgmac210_ops,
258265
.hwtimestamp = &stmmac_ptp,
266+
.ptp = &stmmac_ptp_clock_ops,
259267
.mode = NULL,
260268
.tc = &dwxgmac_tc_ops,
261269
.mmc = &dwxgmac_mmc_ops,
@@ -278,6 +286,7 @@ static const struct stmmac_hwif_entry {
278286
.dma = &dwxgmac210_dma_ops,
279287
.mac = &dwxlgmac2_ops,
280288
.hwtimestamp = &stmmac_ptp,
289+
.ptp = &stmmac_ptp_clock_ops,
281290
.mode = NULL,
282291
.tc = &dwxgmac_tc_ops,
283292
.mmc = &dwxgmac_mmc_ops,
@@ -362,6 +371,8 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
362371
priv->fpe_cfg.reg = entry->regs.fpe_reg;
363372
priv->ptpaddr = priv->ioaddr + entry->regs.ptp_off;
364373
priv->mmcaddr = priv->ioaddr + entry->regs.mmc_off;
374+
memcpy(&priv->ptp_clock_ops, entry->ptp,
375+
sizeof(struct ptp_clock_info));
365376
if (entry->est)
366377
priv->estaddr = priv->ioaddr + entry->regs.est_off;
367378

drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ static int stmmac_getcrosststamp(struct ptp_clock_info *ptp,
265265
}
266266

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

306-
priv->ptp_clock_ops = stmmac_ptp_clock_ops;
307-
308306
priv->ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num;
309307
priv->ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n;
310308

0 commit comments

Comments
 (0)