forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/net/ethernet/ti/cpts.h
....@@ -1,21 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0+ */
12 /*
23 * TI Common Platform Time Sync
34 *
45 * Copyright (C) 2012 Richard Cochran <richardcochran@gmail.com>
56 *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
197 */
208 #ifndef _TI_CPTS_H_
219 #define _TI_CPTS_H_
....@@ -36,7 +24,7 @@
3624 struct cpsw_cpts {
3725 u32 idver; /* Identification and version */
3826 u32 control; /* Time sync control */
39
- u32 res1;
27
+ u32 rftclk_sel; /* Reference Clock Select Register */
4028 u32 ts_push; /* Time stamp event push */
4129 u32 ts_load_val; /* Time stamp load value */
4230 u32 ts_load_en; /* Time stamp load enable */
....@@ -106,6 +94,7 @@
10694 unsigned long tmo;
10795 u32 high;
10896 u32 low;
97
+ u64 timestamp;
10998 };
11099
111100 struct cpts {
....@@ -115,7 +104,7 @@
115104 int rx_enable;
116105 struct ptp_clock_info info;
117106 struct ptp_clock *clock;
118
- spinlock_t lock; /* protects time registers */
107
+ spinlock_t lock; /* protects fifo/events */
119108 u32 cc_mult; /* for the nominal frequency */
120109 struct cyclecounter cc;
121110 struct timecounter tc;
....@@ -126,6 +115,12 @@
126115 struct cpts_event pool_data[CPTS_MAX_EVENTS];
127116 unsigned long ov_check_period;
128117 struct sk_buff_head txq;
118
+ u64 cur_timestamp;
119
+ u32 mult_new;
120
+ struct mutex ptp_clk_mutex; /* sync PTP interface and worker */
121
+ bool irq_poll;
122
+ struct completion ts_push_complete;
123
+ u32 hw_ts_enable;
129124 };
130125
131126 void cpts_rx_timestamp(struct cpts *cpts, struct sk_buff *skb);
....@@ -133,28 +128,9 @@
133128 int cpts_register(struct cpts *cpts);
134129 void cpts_unregister(struct cpts *cpts);
135130 struct cpts *cpts_create(struct device *dev, void __iomem *regs,
136
- struct device_node *node);
131
+ struct device_node *node, u32 n_ext_ts);
137132 void cpts_release(struct cpts *cpts);
138
-
139
-static inline void cpts_rx_enable(struct cpts *cpts, int enable)
140
-{
141
- cpts->rx_enable = enable;
142
-}
143
-
144
-static inline bool cpts_is_rx_enabled(struct cpts *cpts)
145
-{
146
- return !!cpts->rx_enable;
147
-}
148
-
149
-static inline void cpts_tx_enable(struct cpts *cpts, int enable)
150
-{
151
- cpts->tx_enable = enable;
152
-}
153
-
154
-static inline bool cpts_is_tx_enabled(struct cpts *cpts)
155
-{
156
- return !!cpts->tx_enable;
157
-}
133
+void cpts_misc_interrupt(struct cpts *cpts);
158134
159135 static inline bool cpts_can_timestamp(struct cpts *cpts, struct sk_buff *skb)
160136 {
....@@ -164,6 +140,11 @@
164140 return false;
165141
166142 return true;
143
+}
144
+
145
+static inline void cpts_set_irqpoll(struct cpts *cpts, bool en)
146
+{
147
+ cpts->irq_poll = en;
167148 }
168149
169150 #else
....@@ -178,7 +159,7 @@
178159
179160 static inline
180161 struct cpts *cpts_create(struct device *dev, void __iomem *regs,
181
- struct device_node *node)
162
+ struct device_node *node, u32 n_ext_ts)
182163 {
183164 return NULL;
184165 }
....@@ -197,28 +178,18 @@
197178 {
198179 }
199180
200
-static inline void cpts_rx_enable(struct cpts *cpts, int enable)
201
-{
202
-}
203
-
204
-static inline bool cpts_is_rx_enabled(struct cpts *cpts)
205
-{
206
- return false;
207
-}
208
-
209
-static inline void cpts_tx_enable(struct cpts *cpts, int enable)
210
-{
211
-}
212
-
213
-static inline bool cpts_is_tx_enabled(struct cpts *cpts)
214
-{
215
- return false;
216
-}
217
-
218181 static inline bool cpts_can_timestamp(struct cpts *cpts, struct sk_buff *skb)
219182 {
220183 return false;
221184 }
185
+
186
+static inline void cpts_misc_interrupt(struct cpts *cpts)
187
+{
188
+}
189
+
190
+static inline void cpts_set_irqpoll(struct cpts *cpts, bool en)
191
+{
192
+}
222193 #endif
223194
224195