|
90 | 90 | #define FEC_PTP_MAX_NSEC_PERIOD 4000000000ULL
|
91 | 91 | #define FEC_PTP_MAX_NSEC_COUNTER 0x80000000ULL
|
92 | 92 |
|
| 93 | +/** |
| 94 | + * fec_ptp_read - read raw cycle counter (to be used by time counter) |
| 95 | + * @cc: the cyclecounter structure |
| 96 | + * |
| 97 | + * this function reads the cyclecounter registers and is called by the |
| 98 | + * cyclecounter structure used to construct a ns counter from the |
| 99 | + * arbitrary fixed point registers |
| 100 | + */ |
| 101 | +static u64 fec_ptp_read(const struct cyclecounter *cc) |
| 102 | +{ |
| 103 | + struct fec_enet_private *fep = |
| 104 | + container_of(cc, struct fec_enet_private, cc); |
| 105 | + u32 tempval; |
| 106 | + |
| 107 | + tempval = readl(fep->hwp + FEC_ATIME_CTRL); |
| 108 | + tempval |= FEC_T_CTRL_CAPTURE; |
| 109 | + writel(tempval, fep->hwp + FEC_ATIME_CTRL); |
| 110 | + |
| 111 | + if (fep->quirks & FEC_QUIRK_BUG_CAPTURE) |
| 112 | + udelay(1); |
| 113 | + |
| 114 | + return readl(fep->hwp + FEC_ATIME); |
| 115 | +} |
| 116 | + |
93 | 117 | /**
|
94 | 118 | * fec_ptp_enable_pps
|
95 | 119 | * @fep: the fec_enet_private structure handle
|
@@ -136,7 +160,7 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable)
|
136 | 160 | * NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds
|
137 | 161 | * to current timer would be next second.
|
138 | 162 | */
|
139 |
| - tempval = fep->cc.read(&fep->cc); |
| 163 | + tempval = fec_ptp_read(&fep->cc); |
140 | 164 | /* Convert the ptp local counter to 1588 timestamp */
|
141 | 165 | ns = timecounter_cyc2time(&fep->tc, tempval);
|
142 | 166 | ts = ns_to_timespec64(ns);
|
@@ -271,30 +295,6 @@ static enum hrtimer_restart fec_ptp_pps_perout_handler(struct hrtimer *timer)
|
271 | 295 | return HRTIMER_NORESTART;
|
272 | 296 | }
|
273 | 297 |
|
274 |
| -/** |
275 |
| - * fec_ptp_read - read raw cycle counter (to be used by time counter) |
276 |
| - * @cc: the cyclecounter structure |
277 |
| - * |
278 |
| - * this function reads the cyclecounter registers and is called by the |
279 |
| - * cyclecounter structure used to construct a ns counter from the |
280 |
| - * arbitrary fixed point registers |
281 |
| - */ |
282 |
| -static u64 fec_ptp_read(const struct cyclecounter *cc) |
283 |
| -{ |
284 |
| - struct fec_enet_private *fep = |
285 |
| - container_of(cc, struct fec_enet_private, cc); |
286 |
| - u32 tempval; |
287 |
| - |
288 |
| - tempval = readl(fep->hwp + FEC_ATIME_CTRL); |
289 |
| - tempval |= FEC_T_CTRL_CAPTURE; |
290 |
| - writel(tempval, fep->hwp + FEC_ATIME_CTRL); |
291 |
| - |
292 |
| - if (fep->quirks & FEC_QUIRK_BUG_CAPTURE) |
293 |
| - udelay(1); |
294 |
| - |
295 |
| - return readl(fep->hwp + FEC_ATIME); |
296 |
| -} |
297 |
| - |
298 | 298 | /**
|
299 | 299 | * fec_ptp_start_cyclecounter - create the cycle counter from hw
|
300 | 300 | * @ndev: network device
|
|
0 commit comments