hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
....@@ -1,25 +1,16 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*******************************************************************************
23 Copyright (C) 2013 Vayavya Labs Pvt Ltd
34
45 This implements all the API for managing HW timestamp & PTP.
56
6
- This program is free software; you can redistribute it and/or modify it
7
- under the terms and conditions of the GNU General Public License,
8
- version 2, as published by the Free Software Foundation.
9
-
10
- This program is distributed in the hope it will be useful, but WITHOUT
11
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- more details.
14
-
15
- The full GNU General Public License is included in this distribution in
16
- the file called "COPYING".
177
188 Author: Rayagond Kokatanur <rayagond@vayavyalabs.com>
199 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
2010 *******************************************************************************/
2111
2212 #include <linux/io.h>
13
+#include <linux/iopoll.h>
2314 #include <linux/delay.h>
2415 #include "common.h"
2516 #include "stmmac_ptp.h"
....@@ -67,7 +58,6 @@
6758
6859 static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
6960 {
70
- int limit;
7161 u32 value;
7262
7363 writel(sec, ioaddr + PTP_STSUR);
....@@ -78,16 +68,9 @@
7868 writel(value, ioaddr + PTP_TCR);
7969
8070 /* wait for present system time initialize to complete */
81
- limit = 10;
82
- while (limit--) {
83
- if (!(readl(ioaddr + PTP_TCR) & PTP_TCR_TSINIT))
84
- break;
85
- mdelay(10);
86
- }
87
- if (limit < 0)
88
- return -EBUSY;
89
-
90
- return 0;
71
+ return readl_poll_timeout_atomic(ioaddr + PTP_TCR, value,
72
+ !(value & PTP_TCR_TSINIT),
73
+ 10, 100000);
9174 }
9275
9376 static int config_addend(void __iomem *ioaddr, u32 addend)