hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
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"
....@@ -53,7 +44,8 @@
5344 if (!(value & PTP_TCR_TSCTRLSSR))
5445 data = (data * 1000) / 465;
5546
56
- data &= PTP_SSIR_SSINC_MASK;
47
+ if (data > PTP_SSIR_SSINC_MAX)
48
+ data = PTP_SSIR_SSINC_MAX;
5749
5850 reg_value = data;
5951 if (gmac4)
....@@ -67,7 +59,6 @@
6759
6860 static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
6961 {
70
- int limit;
7162 u32 value;
7263
7364 writel(sec, ioaddr + PTP_STSUR);
....@@ -78,16 +69,9 @@
7869 writel(value, ioaddr + PTP_TCR);
7970
8071 /* 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;
72
+ return readl_poll_timeout_atomic(ioaddr + PTP_TCR, value,
73
+ !(value & PTP_TCR_TSINIT),
74
+ 10, 100000);
9175 }
9276
9377 static int config_addend(void __iomem *ioaddr, u32 addend)