author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Mon, 08 Oct 2018 23:16:34 +0200 | |
branch | stable-1.5 |
changeset 2726 | ca80d6dac4c8 |
parent 2588 | 792892ab4806 |
permissions | -rw-r--r-- |
2588
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/* Intel PRO/1000 Linux driver |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* Copyright(c) 1999 - 2014 Intel Corporation. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* This program is free software; you can redistribute it and/or modify it |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* under the terms and conditions of the GNU General Public License, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* version 2, as published by the Free Software Foundation. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* This program is distributed in the hope it will be useful, but WITHOUT |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* more details. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* The full GNU General Public License is included in this distribution in |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* the file called "COPYING". |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* Contact Information: |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* Linux NICS <linux.nics@intel.com> |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
*/ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
/* PTP 1588 Hardware Clock (PHC) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* Derived from PTP Hardware Clock driver for Intel 82576 and 82580 (igb) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com> |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
*/ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
#include "e1000-3.16-ethercat.h" |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
/** |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* e1000e_phc_adjfreq - adjust the frequency of the hardware clock |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* @ptp: ptp clock structure |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
* @delta: Desired frequency change in parts per billion |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
* Adjust the frequency of the PHC cycle counter by the indicated delta from |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
* the base frequency. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
**/ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
static int e1000e_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
{ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
ptp_clock_info); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
struct e1000_hw *hw = &adapter->hw; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
bool neg_adj = false; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
unsigned long flags; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
u64 adjustment; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
u32 timinca, incvalue; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
s32 ret_val; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
if ((delta > ptp->max_adj) || (delta <= -1000000000)) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
return -EINVAL; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
if (delta < 0) { |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
neg_adj = true; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
delta = -delta; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
55 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
/* Get the System Time Register SYSTIM base frequency */ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
ret_val = e1000e_get_base_timinca(adapter, &timinca); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
if (ret_val) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
return ret_val; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
spin_lock_irqsave(&adapter->systim_lock, flags); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
incvalue = timinca & E1000_TIMINCA_INCVALUE_MASK; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
adjustment = incvalue; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
adjustment *= delta; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
67 |
adjustment = div_u64(adjustment, 1000000000); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
incvalue = neg_adj ? (incvalue - adjustment) : (incvalue + adjustment); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
timinca &= ~E1000_TIMINCA_INCVALUE_MASK; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
timinca |= incvalue; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
ew32(TIMINCA, timinca); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
spin_unlock_irqrestore(&adapter->systim_lock, flags); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
return 0; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
/** |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
* e1000e_phc_adjtime - Shift the time of the hardware clock |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
* @ptp: ptp clock structure |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
* @delta: Desired change in nanoseconds |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
* Adjust the timer by resetting the timecounter structure. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
**/ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
static int e1000e_phc_adjtime(struct ptp_clock_info *ptp, s64 delta) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
{ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
ptp_clock_info); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
unsigned long flags; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
s64 now; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
spin_lock_irqsave(&adapter->systim_lock, flags); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
now = timecounter_read(&adapter->tc); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
now += delta; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
timecounter_init(&adapter->tc, &adapter->cc, now); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
spin_unlock_irqrestore(&adapter->systim_lock, flags); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
return 0; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
/** |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
* e1000e_phc_gettime - Reads the current time from the hardware clock |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
* @ptp: ptp clock structure |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
* @ts: timespec structure to hold the current time value |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
* Read the timecounter and return the correct value in ns after converting |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
* it into a struct timespec. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
**/ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
static int e1000e_phc_gettime(struct ptp_clock_info *ptp, struct timespec *ts) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
{ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
ptp_clock_info); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
unsigned long flags; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
u32 remainder; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
u64 ns; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
spin_lock_irqsave(&adapter->systim_lock, flags); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
ns = timecounter_read(&adapter->tc); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
spin_unlock_irqrestore(&adapter->systim_lock, flags); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
ts->tv_sec = div_u64_rem(ns, NSEC_PER_SEC, &remainder); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
ts->tv_nsec = remainder; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
return 0; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
/** |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
* e1000e_phc_settime - Set the current time on the hardware clock |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
* @ptp: ptp clock structure |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
* @ts: timespec containing the new time for the cycle counter |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
* Reset the timecounter to use a new base value instead of the kernel |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
* wall timer value. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
**/ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
static int e1000e_phc_settime(struct ptp_clock_info *ptp, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
const struct timespec *ts) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
{ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
ptp_clock_info); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
unsigned long flags; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
u64 ns; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
ns = timespec_to_ns(ts); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
/* reset the timecounter */ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
spin_lock_irqsave(&adapter->systim_lock, flags); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
timecounter_init(&adapter->tc, &adapter->cc, ns); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
spin_unlock_irqrestore(&adapter->systim_lock, flags); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
return 0; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
/** |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
* e1000e_phc_enable - enable or disable an ancillary feature |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
* @ptp: ptp clock structure |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
* @request: Desired resource to enable or disable |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
* @on: Caller passes one to enable or zero to disable |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
* Enable (or disable) ancillary features of the PHC subsystem. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
* Currently, no ancillary features are supported. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
**/ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
static int e1000e_phc_enable(struct ptp_clock_info __always_unused *ptp, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
struct ptp_clock_request __always_unused *request, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
int __always_unused on) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
{ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
return -EOPNOTSUPP; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
static void e1000e_systim_overflow_work(struct work_struct *work) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
{ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
systim_overflow_work.work); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
struct e1000_hw *hw = &adapter->hw; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
struct timespec ts; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
adapter->ptp_clock_info.gettime(&adapter->ptp_clock_info, &ts); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
e_dbg("SYSTIM overflow check at %ld.%09lu\n", ts.tv_sec, ts.tv_nsec); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
schedule_delayed_work(&adapter->systim_overflow_work, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
E1000_SYSTIM_OVERFLOW_PERIOD); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
static const struct ptp_clock_info e1000e_ptp_clock_info = { |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
.owner = THIS_MODULE, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
.n_alarm = 0, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
.n_ext_ts = 0, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
.n_per_out = 0, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
.n_pins = 0, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
.pps = 0, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
.adjfreq = e1000e_phc_adjfreq, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
.adjtime = e1000e_phc_adjtime, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
.gettime = e1000e_phc_gettime, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
.settime = e1000e_phc_settime, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
.enable = e1000e_phc_enable, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
}; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
/** |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
* e1000e_ptp_init - initialize PTP for devices which support it |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
* @adapter: board private structure |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
* This function performs the required steps for enabling PTP support. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
* If PTP support has already been loaded it simply calls the cyclecounter |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
* init routine and exits. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
**/ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
void e1000e_ptp_init(struct e1000_adapter *adapter) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
{ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
struct e1000_hw *hw = &adapter->hw; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
adapter->ptp_clock = NULL; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP)) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
return; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
adapter->ptp_clock_info = e1000e_ptp_clock_info; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
snprintf(adapter->ptp_clock_info.name, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
sizeof(adapter->ptp_clock_info.name), "%pm", |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
adapter->netdev->perm_addr); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
switch (hw->mac.type) { |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
case e1000_pch2lan: |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
case e1000_pch_lpt: |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
if ((hw->mac.type != e1000_pch_lpt) || |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
(er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_SYSCFI)) { |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
adapter->ptp_clock_info.max_adj = 24000000 - 1; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
break; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
/* fall-through */ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
case e1000_82574: |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
case e1000_82583: |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
adapter->ptp_clock_info.max_adj = 600000000 - 1; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
break; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
default: |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
break; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
INIT_DELAYED_WORK(&adapter->systim_overflow_work, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
e1000e_systim_overflow_work); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
schedule_delayed_work(&adapter->systim_overflow_work, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
E1000_SYSTIM_OVERFLOW_PERIOD); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
adapter->ptp_clock = ptp_clock_register(&adapter->ptp_clock_info, |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
&adapter->pdev->dev); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
if (IS_ERR(adapter->ptp_clock)) { |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
adapter->ptp_clock = NULL; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
e_err("ptp_clock_register failed\n"); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
} else { |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
e_info("registered PHC clock\n"); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
/** |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
* e1000e_ptp_remove - disable PTP device and stop the overflow check |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
* @adapter: board private structure |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
* |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
* Stop the PTP support, and cancel the delayed work. |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
**/ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
void e1000e_ptp_remove(struct e1000_adapter *adapter) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
{ |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP)) |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
return; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
cancel_delayed_work_sync(&adapter->systim_overflow_work); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
|
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
if (adapter->ptp_clock) { |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
ptp_clock_unregister(adapter->ptp_clock); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
adapter->ptp_clock = NULL; |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
e_info("removed PHC\n"); |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
} |
792892ab4806
Added all drivers for kernel 3.16.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
} |