diff options
Diffstat (limited to 'meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-pch-ieee1588.patch')
-rw-r--r-- | meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-pch-ieee1588.patch | 7945 |
1 files changed, 7945 insertions, 0 deletions
diff --git a/meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-pch-ieee1588.patch b/meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-pch-ieee1588.patch new file mode 100644 index 0000000000..ac1bea9050 --- /dev/null +++ b/meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-pch-ieee1588.patch | |||
@@ -0,0 +1,7945 @@ | |||
1 | |||
2 | |||
3 | From: Masayuki Ohtake <masa-korg@dsn.okisemi.com> | ||
4 | Subject: OKI Semiconductor PCH IEEE1588 driver | ||
5 | |||
6 | This driver implements IEEE1588 controls for PCH. | ||
7 | |||
8 | Signed-off-by: Masayuki Ohtake <masa-korg@dsn.okisemi.com> | ||
9 | Acked-by: Wang Qi <qi.wang@intel.com> | ||
10 | |||
11 | --- | ||
12 | drivers/char/Kconfig | 7 ++ | ||
13 | drivers/char/Makefile | 2 | ||
14 | drivers/char/pch_ieee1588/Makefile | 10 | ||
15 | drivers/char/pch_ieee1588/pch_1588_hal.c | 4040 | ||
16 | drivers/char/pch_ieee1588/pch_1588_hal.h | 885 | ||
17 | drivers/char/pch_ieee1588/pch_1588_main.c | 1192 | ||
18 | drivers/char/pch_ieee1588/pch_1588_main.h | 702 | ||
19 | drivers/char/pch_ieee1588/pch_1588_pci.c | 700 | ||
20 | drivers/char/pch_ieee1588/pch_1588_pci.h | 122 | ||
21 | drivers/char/pch_ieee1588/pch_common.h | 146 | ||
22 | drivers/char/pch_ieee1588/pch_debug.h | 60 | ||
23 | +++++++++++++++++++++++++++++++ 11 files changed, zz insertions(+) | ||
24 | diff -urN linux-2.6.33-rc3/drivers/char/Kconfig topcliff-2.6.33-rc3/drivers/char/Kconfig | ||
25 | --- linux-2.6.33-rc3/drivers/char/Kconfig 2010-01-06 09:02:46.000000000 +0900 | ||
26 | +++ topcliff-2.6.33-rc3/drivers/char/Kconfig 2010-03-09 10:14:52.000000000 +0900 | ||
27 | @@ -4,6 +4,13 @@ | ||
28 | |||
29 | menu "Character devices" | ||
30 | |||
31 | +config PCH_IEEE1588 | ||
32 | + tristate "PCH IEEE1588" | ||
33 | + depends on PCI | ||
34 | + help | ||
35 | + If you say yes to this option, support will be included for the | ||
36 | + PCH IEEE1588 Host controller. | ||
37 | + | ||
38 | config VT | ||
39 | bool "Virtual terminal" if EMBEDDED | ||
40 | depends on !S390 | ||
41 | diff -urN linux-2.6.33-rc3/drivers/char/Makefile topcliff-2.6.33-rc3/drivers/char/Makefile | ||
42 | --- linux-2.6.33-rc3/drivers/char/Makefile 2010-01-06 09:02:46.000000000 +0900 | ||
43 | +++ topcliff-2.6.33-rc3/drivers/char/Makefile 2010-03-05 22:57:39.000000000 +0900 | ||
44 | @@ -111,6 +111,8 @@ | ||
45 | obj-$(CONFIG_JS_RTC) += js-rtc.o | ||
46 | js-rtc-y = rtc.o | ||
47 | |||
48 | +obj-$(CONFIG_PCH_IEEE1588) += pch_ieee1588/ | ||
49 | + | ||
50 | # Files generated that shall be removed upon make clean | ||
51 | clean-files := consolemap_deftbl.c defkeymap.c | ||
52 | |||
53 | diff -urN linux-2.6.33-rc3/drivers/char/pch_ieee1588/Makefile topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/Makefile | ||
54 | --- linux-2.6.33-rc3/drivers/char/pch_ieee1588/Makefile 1970-01-01 09:00:00.000000000 +0900 | ||
55 | +++ topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/Makefile 2010-03-10 04:52:54.000000000 +0900 | ||
56 | @@ -0,0 +1,10 @@ | ||
57 | +ifeq ($(CONFIG_IEEE1588_DEBUG_CORE),y) | ||
58 | +EXTRA_CFLAGS += -DDEBUG | ||
59 | +endif | ||
60 | + | ||
61 | +obj-$(CONFIG_PCH_IEEE1588) += pch_ieee1588.o | ||
62 | + | ||
63 | +#for A0_A1_SAMPLE LSI board | ||
64 | +EXTRA_CFLAGS+=-DIOH_IEEE1588_A0_A1_SAMPLE_BUG | ||
65 | + | ||
66 | +pch_ieee1588-objs := pch_1588_main.o pch_1588_pci.o pch_1588_hal.o | ||
67 | diff -urN linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_hal.c topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_hal.c | ||
68 | --- linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_hal.c 1970-01-01 09:00:00.000000000 +0900 | ||
69 | +++ topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_hal.c 2010-03-09 10:34:22.000000000 +0900 | ||
70 | @@ -0,0 +1,4040 @@ | ||
71 | + /*! | ||
72 | + * @file ioh_1588_hal.c | ||
73 | + * @brief | ||
74 | + * This file has the definitions for HALLAyer APIs. | ||
75 | + * @version 0.92 | ||
76 | + * @section | ||
77 | + * This program is free software; you can redistribute it and/or modify | ||
78 | + * it under the terms of the GNU General Public License as published by | ||
79 | + * the Free Software Foundation; version 2 of the License. | ||
80 | + * | ||
81 | + * This program is distributed in the hope that it will be useful, | ||
82 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
83 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
84 | + * GNU General Public License for more details. | ||
85 | + * | ||
86 | + * You should have received a copy of the GNU General Public License | ||
87 | + * along with this program; if not, write to the Free Software | ||
88 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
89 | + */ | ||
90 | + | ||
91 | +/* | ||
92 | + * History: | ||
93 | + * modified to support Intel IOH GE IEEE 1588 hardware | ||
94 | + * Copyright (C) 2008 OKI SEMICONDUCTOR Co., LTD. | ||
95 | + * All rights reserved. | ||
96 | + * derived from | ||
97 | + * IEEE 1588 Time Synchronization Driver for Intel EP80579 | ||
98 | + * Copyright(c) 2007,2008 Intel Corporation. All rights reserved. | ||
99 | + * All rights reserved. | ||
100 | + * | ||
101 | + */ | ||
102 | + | ||
103 | +#include <linux/io.h> | ||
104 | +#include "pch_common.h" | ||
105 | +#include "pch_debug.h" | ||
106 | +#include <linux/module.h> | ||
107 | +#include "pch_1588_hal.h" | ||
108 | + | ||
109 | +/* | ||
110 | + * HAL API definitions for the IEEE 1588 module | ||
111 | + */ | ||
112 | + | ||
113 | +/*! @ingroup IEEE1588 | ||
114 | + * @def INLINE | ||
115 | + * @brief The macro used instead of the keyword __inline. | ||
116 | +*/ | ||
117 | +#define INLINE inline | ||
118 | + | ||
119 | +/*Register read/write macros*/ | ||
120 | +#define IOH_REG_32_READ(regAddr, varRef) (*(varRef) = IOH_READ32(regAddr)) | ||
121 | +#define IOH_REG_32_WRITE(regAddr, varValue) IOH_WRITE32(varValue, regAddr) | ||
122 | +#define IOH_BIT_SET_CHECK(regAddr, bitMask) \ | ||
123 | + ((IOH_READ32(regAddr) & (bitMask)) == (bitMask)) | ||
124 | + | ||
125 | +#ifdef IOH_IEEE1588_A1_SAMPLE_BUG | ||
126 | +/*global variable to store tick rate*/ | ||
127 | +static unsigned long gTickRateApp; | ||
128 | +#endif | ||
129 | + | ||
130 | +/* function prototypes */ | ||
131 | +/* TS_Control register access routines */ | ||
132 | +static INLINE void ioh_1588_pps_imask_set(void); | ||
133 | +static INLINE void ioh_1588_amms_imask_set(void); | ||
134 | +static INLINE void ioh_1588_asms_imask_set(void); | ||
135 | +static INLINE void ioh_1588_ttm_imask_set(void); | ||
136 | +static INLINE void ioh_1588_pps_imask_clear(void); | ||
137 | +static INLINE void ioh_1588_amms_imask_clear(void); | ||
138 | +static INLINE void ioh_1588_asms_imask_clear(void); | ||
139 | +static INLINE void ioh_1588_ttm_imask_clear(void); | ||
140 | +static INLINE unsigned long ioh_1588_pps_imask_get(void); | ||
141 | +static INLINE unsigned long ioh_1588_amms_imask_get(void); | ||
142 | +static INLINE unsigned long ioh_1588_asms_imask_get(void); | ||
143 | +static INLINE unsigned long ioh_1588_ttm_imask_get(void); | ||
144 | +static INLINE void ioh_1588_block_reset(void); | ||
145 | + | ||
146 | +/* TS_Event register access routines */ | ||
147 | +static INLINE unsigned long ioh_1588_pps_evt_get(void); | ||
148 | +static INLINE unsigned long ioh_1588_amms_evt_get(void); | ||
149 | +static INLINE unsigned long ioh_1588_asms_evt_get(void); | ||
150 | +static INLINE unsigned long ioh_1588_ttm_evt_get(void); | ||
151 | +static INLINE void ioh_1588_pps_evt_clear(void); | ||
152 | +static INLINE void ioh_1588_amms_evt_clear(void); | ||
153 | +static INLINE void ioh_1588_asms_evt_clear(void); | ||
154 | +static INLINE void ioh_1588_ttm_evt_clear(void); | ||
155 | + | ||
156 | +/* TS_Addend register access routines - Frequency Scaling Value */ | ||
157 | +static INLINE void ioh_1588_addend_set(unsigned long fsv); | ||
158 | +static INLINE void ioh_1588_addend_get(unsigned long *fsv); | ||
159 | + | ||
160 | +/* TS_PPS_Compare register access routines */ | ||
161 | +static INLINE void ioh_1588_pps_set(unsigned long fsv); | ||
162 | +static INLINE void ioh_1588_pps_get(unsigned long *fsv); | ||
163 | +/* TS_SYSTimeLo, Hi registers access routines */ | ||
164 | +static INLINE void ioh_1588_sys_snap_set(unsigned long sys_time_low, | ||
165 | + unsigned long sys_time_high); | ||
166 | +static INLINE void ioh_1588_sys_snap_get(unsigned long *sys_time_low, | ||
167 | + unsigned long *sys_time_high); | ||
168 | +/* TS_TrgtTimeLo, Hi registers access routines */ | ||
169 | +static INLINE void ioh_1588_tgt_snap_set(unsigned long tgt_time_low, | ||
170 | + unsigned long tgt_time_high); | ||
171 | +static INLINE void ioh_1588_tgt_snap_get(unsigned long *tgt_time_low, | ||
172 | + unsigned long *tgt_time_high); | ||
173 | +/* TS_ASMSLo, Hi registers access routines */ | ||
174 | +static INLINE void ioh_1588_aux_slave_snap_get(unsigned long *asms_low, | ||
175 | + unsigned long *asms_high); | ||
176 | +/* TS_AMMSLo, Hi registers access routines */ | ||
177 | +static INLINE void ioh_1588_aux_master_snap_get(unsigned long *amms_low, | ||
178 | + unsigned long *amms_high); | ||
179 | + | ||
180 | +/* TS_Ch_Control register access routines */ | ||
181 | +static INLINE void ioh_1588_master_mode_set(unsigned long master_mode); | ||
182 | +static INLINE unsigned long ioh_1588_master_mode_get(void); | ||
183 | +static INLINE void ioh_1588_timestamp_all_set(unsigned long allMsg); | ||
184 | +static INLINE unsigned long ioh_1588_timestamp_all_get(void); | ||
185 | +static INLINE void ioh_1588_op_mode_set(unsigned long mode); | ||
186 | +static INLINE unsigned long ioh_1588_op_mode_get(void); | ||
187 | +static INLINE void ioh_1588_version_set(unsigned long versionVal); | ||
188 | +static INLINE unsigned long ioh_1588_version_get(void); | ||
189 | + | ||
190 | +/* TS_Ch_Event register access routines */ | ||
191 | +static INLINE unsigned long ioh_1588_rx_snap_evt(void); | ||
192 | +static INLINE unsigned long ioh_1588_tx_snap_evt(void); | ||
193 | +static INLINE void ioh_1588_rx_snap_evt_clear(void); | ||
194 | +static INLINE void ioh_1588_tx_snap_evt_clear(void); | ||
195 | +/* TS_TxSnapLo, Hi registers access routines */ | ||
196 | +static INLINE void ioh_1588_tx_snap_get(unsigned long *txs_low, | ||
197 | + unsigned long *txs_high); | ||
198 | +/* TS_RxSnapLo, Hi registers access routines */ | ||
199 | +static INLINE void ioh_1588_rx_snap_get(unsigned long *rxs_low, | ||
200 | + unsigned long *rxs_high); | ||
201 | +/* TS_srcUUIDLo, Hi registers access routines */ | ||
202 | +static INLINE void ioh_1588_uuid_seqid_get(unsigned long *uuid_low, | ||
203 | + unsigned long *uuid_high, | ||
204 | + unsigned int *seq_id); | ||
205 | + | ||
206 | +static INLINE unsigned long ioh_1588_can_snap_valid(void); | ||
207 | +static INLINE unsigned long ioh_1588_can_snap_ovr(void); | ||
208 | +static INLINE void ioh_1588_can_snap_valid_clear(void); | ||
209 | +static INLINE void ioh_1588_can_snap_ovr_clear(void); | ||
210 | +static INLINE void ioh_1588_can_snap_get(unsigned long *rxs_low, | ||
211 | + unsigned long *rxs_high); | ||
212 | + | ||
213 | +static INLINE void ioh_1588_eth_enable_set(void); | ||
214 | +static INLINE void ioh_1588_eth_enable_clear(void); | ||
215 | +static INLINE unsigned long ioh_1588_eth_enable_get(void); | ||
216 | +static INLINE void ioh_1588_can_enable_set(void); | ||
217 | +static INLINE void ioh_1588_can_enable_clear(void); | ||
218 | +static INLINE unsigned long ioh_1588_can_enable_get(void); | ||
219 | +static INLINE void ioh_1588_station_set(unsigned long station, | ||
220 | + unsigned long value); | ||
221 | +static INLINE void ioh_1588_station_get(unsigned long station, | ||
222 | + unsigned long *value); | ||
223 | + | ||
224 | +/* Masks to extract High and Low SHORTs from unsigned long values */ | ||
225 | +#define IOH_1588_MSB_SHORT_MASK (0xFFFF0000) | ||
226 | +#define IOH_1588_LSB_SHORT_MASK (0x0000FFFF) | ||
227 | + | ||
228 | +/* Location of SeqID in the register */ | ||
229 | +#define IOH_1588_SID_LOC (16) | ||
230 | + | ||
231 | +/* Variable declarations */ | ||
232 | + | ||
233 | +/** | ||
234 | + * Client registered callback routines for | ||
235 | + * a) the target time reached or exceeded interrupt notification | ||
236 | + * b) the auxiliary time stamps availability interrupt notification | ||
237 | + * c) the pulse per second match interrupt notification | ||
238 | + */ | ||
239 | +static ioh1588TargetTimeCallback ioh_tt_cbptr = | ||
240 | + (ioh1588TargetTimeCallback) NULL; | ||
241 | +static ioh1588AuxTimeCallback ioh_am_cbptr = (ioh1588AuxTimeCallback) NULL; | ||
242 | +static ioh1588AuxTimeCallback ioh_as_cbptr = (ioh1588AuxTimeCallback) NULL; | ||
243 | +static ioh1588PulsePerSecondCallback ioh_pps_cbptr = | ||
244 | + (ioh1588PulsePerSecondCallback) NULL; | ||
245 | + | ||
246 | +/* The transmit and receive timestamp statistics */ | ||
247 | +static struct ioh1588Stats ioh_1588_stats = { 0, 0 }; | ||
248 | + | ||
249 | +/* To save the state of all registers of the module */ | ||
250 | +static struct ioh_1588_regs_set ioh_1588_regs; | ||
251 | + | ||
252 | +/* IO mapped virtual address for the 1588 registers */ | ||
253 | +static unsigned long ioh_1588_base; | ||
254 | + | ||
255 | +/* local functions definitions. */ | ||
256 | + | ||
257 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
258 | + * @fn static INLINE void ioh_1588_pps_imask_set(void) | ||
259 | + * @brief Enable PPS Interrupt | ||
260 | + * @param None | ||
261 | + * @retval None | ||
262 | +*/ | ||
263 | + | ||
264 | +static INLINE void ioh_1588_pps_imask_set(void) | ||
265 | +{ | ||
266 | + /* SET the ppsm bit */ | ||
267 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
268 | + IOH_1588_TSC_PPSM_MASK); | ||
269 | +} | ||
270 | + | ||
271 | +/** @ingroup IEEE_1588_HALLayerAPI | ||
272 | + * @fn static INLINE void ioh_1588_amms_imask_set(void) | ||
273 | + * @brief Enable Auxiliary Master Mode Snapshot Interrupt | ||
274 | + * @param None | ||
275 | + * @retval None | ||
276 | +*/ | ||
277 | +static INLINE void ioh_1588_amms_imask_set(void) | ||
278 | +{ | ||
279 | + /* SET the amms bit */ | ||
280 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
281 | + IOH_1588_TSC_AMMS_MASK); | ||
282 | +} | ||
283 | + | ||
284 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
285 | + * @fn static INLINE void ioh_1588_asms_imask_set(void) | ||
286 | + * @brief Enable Auxiliary Slave Mode Snapshot Interrupt | ||
287 | + * @param None | ||
288 | + * @retval None | ||
289 | +*/ | ||
290 | +static INLINE void ioh_1588_asms_imask_set(void) | ||
291 | +{ | ||
292 | + /* SET the asms bit */ | ||
293 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
294 | + IOH_1588_TSC_ASMS_MASK); | ||
295 | +} | ||
296 | + | ||
297 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
298 | + * @fn static INLINE void ioh_1588_ttm_imask_set(void) | ||
299 | + * @brief Enable Target Time Interrupt | ||
300 | + * @param None | ||
301 | + * @retval None | ||
302 | +*/ | ||
303 | +static INLINE void ioh_1588_ttm_imask_set(void) | ||
304 | +{ | ||
305 | + /* SET the ttm bit */ | ||
306 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
307 | + IOH_1588_TSC_TTM_MASK); | ||
308 | +} | ||
309 | + | ||
310 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
311 | + * @fn static INLINE unsigned long ioh_1588_pps_imask_get(void) | ||
312 | + * @brief Get PPS Interrupt Mask value | ||
313 | + * @param None | ||
314 | + * @retval unsigned long | ||
315 | +*/ | ||
316 | +static INLINE unsigned long ioh_1588_pps_imask_get(void) | ||
317 | +{ | ||
318 | + /* Is the ppsm bit SET? */ | ||
319 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
320 | + IOH_1588_TSC_PPSM_MASK); | ||
321 | +} | ||
322 | + | ||
323 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
324 | + * @fn static INLINE unsigned long ioh_1588_amms_imask_get(void) | ||
325 | + * @brief Get Auxiliary Master Mode Snapshot Interrupt Mask value | ||
326 | + * @param None | ||
327 | + * @retval unsigned long | ||
328 | +*/ | ||
329 | +static INLINE unsigned long ioh_1588_amms_imask_get(void) | ||
330 | +{ | ||
331 | + /* Is the amms bit SET? */ | ||
332 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
333 | + IOH_1588_TSC_AMMS_MASK); | ||
334 | +} | ||
335 | + | ||
336 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
337 | + @fn static INLINE unsigned long ioh_1588_asms_imask_get(void) | ||
338 | + @brief Get Auxiliary Slave Mode Snapshot Interrupt Mask value | ||
339 | + @param None | ||
340 | + @retval unsigned long | ||
341 | +*/ | ||
342 | +static INLINE unsigned long ioh_1588_asms_imask_get(void) | ||
343 | +{ | ||
344 | + /* Is the asms bit SET? */ | ||
345 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
346 | + IOH_1588_TSC_ASMS_MASK); | ||
347 | +} | ||
348 | + | ||
349 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
350 | + * @fn static INLINE unsigned long ioh_1588_ttm_imask_get(void) | ||
351 | + * @brief Get Target Time Interrupt Mask value | ||
352 | + * @param None. | ||
353 | + * @retval unsigned long | ||
354 | +*/ | ||
355 | +static INLINE unsigned long ioh_1588_ttm_imask_get(void) | ||
356 | +{ | ||
357 | + /* Is the ttm bit SET? */ | ||
358 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
359 | + IOH_1588_TSC_TTM_MASK); | ||
360 | +} | ||
361 | + | ||
362 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
363 | + @fn static INLINE void ioh_1588_pps_imask_clear(void) | ||
364 | + @brief Disable PPS Interrupt | ||
365 | + @param None | ||
366 | + @retval None | ||
367 | +*/ | ||
368 | +static INLINE void ioh_1588_pps_imask_clear(void) | ||
369 | +{ | ||
370 | + /* CLEAR the ppsm bit */ | ||
371 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
372 | + IOH_1588_TSC_PPSM_MASK); | ||
373 | +} | ||
374 | + | ||
375 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
376 | + * @fn static INLINE void ioh_1588_amms_imask_clear(void) | ||
377 | + * @brief Disable Auxiliary Master Mode Snapshot Interrupt. | ||
378 | + * @param None. | ||
379 | + * @retval None | ||
380 | +*/ | ||
381 | +static INLINE void ioh_1588_amms_imask_clear(void) | ||
382 | +{ | ||
383 | + /* CLEAR the amms bit */ | ||
384 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
385 | + IOH_1588_TSC_AMMS_MASK); | ||
386 | +} | ||
387 | + | ||
388 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
389 | + * @fn static INLINE void ioh_1588_asms_imask_clear(void) | ||
390 | + * @brief Disable Auxiliary Slave Mode Snapshot Interrupt | ||
391 | + * @param None | ||
392 | + * @retval None | ||
393 | +*/ | ||
394 | +static INLINE void ioh_1588_asms_imask_clear(void) | ||
395 | +{ | ||
396 | + /* CLEAR the asms bit */ | ||
397 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
398 | + IOH_1588_TSC_ASMS_MASK); | ||
399 | +} | ||
400 | + | ||
401 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
402 | + * @fn static INLINE void ioh_1588_ttm_imask_clear(void) | ||
403 | + * @brief Disable Target Time Interrupt | ||
404 | + * @param None | ||
405 | + * @retval None | ||
406 | +*/ | ||
407 | +static INLINE void ioh_1588_ttm_imask_clear(void) | ||
408 | +{ | ||
409 | + /* CLEAR the ttm bit */ | ||
410 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
411 | + IOH_1588_TSC_TTM_MASK); | ||
412 | +} | ||
413 | + | ||
414 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
415 | + * @fn static INLINE void ioh_1588_block_reset(void) | ||
416 | + * @brief Reset Hardware Assist block | ||
417 | + * @param None | ||
418 | + * @retval None | ||
419 | +*/ | ||
420 | +static INLINE void ioh_1588_block_reset(void) | ||
421 | +{ | ||
422 | + /* SET the rst bit */ | ||
423 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
424 | + IOH_1588_TSC_RESET); | ||
425 | + /* CLEAR the rst bit */ | ||
426 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_TSC_OFFSET, | ||
427 | + IOH_1588_TSC_RESET); | ||
428 | +} | ||
429 | + | ||
430 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
431 | + * @fn static INLINE unsigned long ioh_1588_pps_evt_get(void) | ||
432 | + * @brief Poll for PPS event | ||
433 | + * @param None | ||
434 | + * @retval unsigned long | ||
435 | +*/ | ||
436 | +static INLINE unsigned long ioh_1588_pps_evt_get(void) | ||
437 | +{ | ||
438 | + /* Check for PPS event */ | ||
439 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_TSE_OFFSET, | ||
440 | + IOH_1588_TSE_PPS); | ||
441 | +} | ||
442 | + | ||
443 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
444 | + * @fn static INLINE unsigned long ioh_1588_amms_evt_get(void) | ||
445 | + * @brief Poll for Auxiliary Master Mode Snapshot Captured event | ||
446 | + * @param None | ||
447 | + * @retval unsigned long | ||
448 | +*/ | ||
449 | +static INLINE unsigned long ioh_1588_amms_evt_get(void) | ||
450 | +{ | ||
451 | + /* Check for AMMS event */ | ||
452 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_TSE_OFFSET, | ||
453 | + IOH_1588_TSE_SNM); | ||
454 | +} | ||
455 | + | ||
456 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
457 | + * @fn static INLINE unsigned long ioh_1588_asms_evt_get(void) | ||
458 | + * @brief Poll for Auxiliary Slave Mode Snapshot Captured event | ||
459 | + * @param None | ||
460 | + * @retval unsigned long | ||
461 | +*/ | ||
462 | +static INLINE unsigned long ioh_1588_asms_evt_get(void) | ||
463 | +{ | ||
464 | + /* Check ASMS event */ | ||
465 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_TSE_OFFSET, | ||
466 | + IOH_1588_TSE_SNS); | ||
467 | +} | ||
468 | + | ||
469 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
470 | + * @fn static INLINE unsigned long ioh_1588_ttm_evt_get(void) | ||
471 | + * @brief Poll for Target Time Reached event | ||
472 | + * @param None | ||
473 | + * @retval unsigned long | ||
474 | +*/ | ||
475 | +static INLINE unsigned long ioh_1588_ttm_evt_get(void) | ||
476 | +{ | ||
477 | + /* Check target time pending event */ | ||
478 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_TSE_OFFSET, | ||
479 | + IOH_1588_TSE_TTIPEND); | ||
480 | +} | ||
481 | + | ||
482 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
483 | + * @fn static INLINE void ioh_1588_pps_evt_clear(void) | ||
484 | + * @brief Clear PPS event | ||
485 | + * @param None | ||
486 | + * @retval None | ||
487 | +*/ | ||
488 | +static INLINE void ioh_1588_pps_evt_clear(void) | ||
489 | +{ | ||
490 | + /* clear the pps bit */ | ||
491 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_TSE_OFFSET, IOH_1588_TSE_PPS); | ||
492 | +} | ||
493 | + | ||
494 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
495 | + * @fn static INLINE void ioh_1588_amms_evt_clear(void) | ||
496 | + * @brief Clear Auxiliary Master Mode Snapshot Captured event | ||
497 | + * @param None. | ||
498 | + * @retval None. | ||
499 | +*/ | ||
500 | +static INLINE void ioh_1588_amms_evt_clear(void) | ||
501 | +{ | ||
502 | + /* clear the snm bit */ | ||
503 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_TSE_OFFSET, IOH_1588_TSE_SNM); | ||
504 | +} | ||
505 | + | ||
506 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
507 | + * @fn static INLINE void ioh_1588_asms_evt_clear(void) | ||
508 | + * @brief Clear Auxiliary Slave Mode Snapshot Captured event | ||
509 | + * @param None | ||
510 | + * @retval None | ||
511 | +*/ | ||
512 | +static INLINE void ioh_1588_asms_evt_clear(void) | ||
513 | +{ | ||
514 | + /* clear the sns bit */ | ||
515 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_TSE_OFFSET, IOH_1588_TSE_SNS); | ||
516 | +} | ||
517 | + | ||
518 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
519 | + * @fn static INLINE void ioh_1588_ttm_evt_clear(void) | ||
520 | + * @brief Clear Target Time Reached event | ||
521 | + * @param None | ||
522 | + * @retval None | ||
523 | +*/ | ||
524 | +static INLINE void ioh_1588_ttm_evt_clear(void) | ||
525 | +{ | ||
526 | + /* CLEAR the ttipend bit */ | ||
527 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_TSE_OFFSET, | ||
528 | + IOH_1588_TSE_TTIPEND); | ||
529 | +} | ||
530 | + | ||
531 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
532 | + * @fn static INLINE void ioh_1588_sys_snap_set( | ||
533 | + * unsigned long sys_time_low, unsigned long sys_time_high) | ||
534 | + * @brief Set System Time value | ||
535 | + * @param sys_time_low [IN] The system time low. | ||
536 | + * @param sys_time_high {In} The system time high. | ||
537 | + * @retval None | ||
538 | +*/ | ||
539 | +static INLINE void | ||
540 | +ioh_1588_sys_snap_set(unsigned long sys_time_low, unsigned long sys_time_high) | ||
541 | +{ | ||
542 | + /* Update the System Time Low Register contents */ | ||
543 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_STL_OFFSET, sys_time_low); | ||
544 | + | ||
545 | + /* Update the System Time High Register contents */ | ||
546 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_STH_OFFSET, sys_time_high); | ||
547 | +} | ||
548 | + | ||
549 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
550 | + * @fn static INLINE voidioh_1588_sys_snap_get( | ||
551 | + * unsigned long *sys_time_low, unsigned long *sys_time_high) | ||
552 | + * @brief Get System Time Low value | ||
553 | + * @param sys_time_low [OUT] The system time low. | ||
554 | + * @param sys_time_high [OUT] The system time high. | ||
555 | + * @retval None | ||
556 | +*/ | ||
557 | +static INLINE void | ||
558 | +ioh_1588_sys_snap_get(unsigned long *sys_time_low, unsigned long *sys_time_high) | ||
559 | +{ | ||
560 | + /* Get the System Time Low Register contents */ | ||
561 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_STL_OFFSET, sys_time_low); | ||
562 | + | ||
563 | + /* Get the System Time High Register contents */ | ||
564 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_STH_OFFSET, sys_time_high); | ||
565 | +} | ||
566 | + | ||
567 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
568 | + * @fn static INLINE void ioh_1588_tgt_snap_set ( | ||
569 | + * unsigned long tgt_time_low, unsigned long tgt_time_high) | ||
570 | + * @brief Set Target Time value | ||
571 | + * @param tgt_time_low [IN] The target time low. | ||
572 | + * @param tgt_time_high [IN] The target time high. | ||
573 | + * @retval None. | ||
574 | +*/ | ||
575 | +static INLINE void | ||
576 | +ioh_1588_tgt_snap_set(unsigned long tgt_time_low, unsigned long tgt_time_high) | ||
577 | +{ | ||
578 | + /* Update the Target Time Low Register contents */ | ||
579 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_TTL_OFFSET, tgt_time_low); | ||
580 | + | ||
581 | + /* Update the Target Time High Register contents */ | ||
582 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_TTH_OFFSET, tgt_time_high); | ||
583 | +} | ||
584 | + | ||
585 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
586 | + * @fn static INLINE void ioh_1588_tgt_snap_get( | ||
587 | + * unsigned long *tgt_time_low, unsigned long *tgt_time_high) | ||
588 | + * @brief Get Target Time value | ||
589 | + * @param tgt_time_low [OUT] The target time low. | ||
590 | + * @param tgt_time_high [IN] The target time high. | ||
591 | + * @retval None | ||
592 | +*/ | ||
593 | +static INLINE void | ||
594 | +ioh_1588_tgt_snap_get(unsigned long *tgt_time_low, unsigned long *tgt_time_high) | ||
595 | +{ | ||
596 | + /* Get the Target Time Low Register contents */ | ||
597 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_TTL_OFFSET, tgt_time_low); | ||
598 | + | ||
599 | + /* Get the Target Time High Register contents */ | ||
600 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_TTH_OFFSET, tgt_time_high); | ||
601 | +} | ||
602 | + | ||
603 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
604 | + * @fn static INLINE void ioh_1588_addend_set(unsigned long fsv) | ||
605 | + * @brief Set Frequency Scaling Value | ||
606 | + * @param fsv [IN] Frequency | ||
607 | + * @retval None | ||
608 | +*/ | ||
609 | +static INLINE void ioh_1588_addend_set(unsigned long fsv) | ||
610 | +{ | ||
611 | + /* Update the Addend Register contents */ | ||
612 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_ADD_OFFSET, fsv); | ||
613 | +} | ||
614 | + | ||
615 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
616 | + * @fn static INLINE void ioh_1588_addend_get(unsigned long *fsv) | ||
617 | + * @brief Get Frequency Scaling Value | ||
618 | + * @param fsv [OUT] The frequency. | ||
619 | + * @retval None | ||
620 | +*/ | ||
621 | +static INLINE void ioh_1588_addend_get(unsigned long *fsv) | ||
622 | +{ | ||
623 | + /* Get the Addend Register contents */ | ||
624 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_ADD_OFFSET, fsv); | ||
625 | +} | ||
626 | + | ||
627 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
628 | + * @fn static INLINE void ioh_1588_pps_set(unsigned long pps) | ||
629 | + * @brief Set Pulse Per Second Value | ||
630 | + * @param pps [IN] The pulse per second value. | ||
631 | + * @retval None. | ||
632 | +*/ | ||
633 | +static INLINE void ioh_1588_pps_set(unsigned long pps) | ||
634 | +{ | ||
635 | + /* Update the PPS Compare Register contents */ | ||
636 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_PPS_OFFSET, pps); | ||
637 | +} | ||
638 | + | ||
639 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
640 | + * @fn static INLINE void ioh_1588_pps_get(unsigned long *pps) | ||
641 | + * @brief Get Pulse Per Second Value | ||
642 | + * @param pps [OUT] The pulse per second value. | ||
643 | + * @retval None. | ||
644 | +*/ | ||
645 | +static INLINE void ioh_1588_pps_get(unsigned long *pps) | ||
646 | +{ | ||
647 | + /* Get the PPS Compare Register contents */ | ||
648 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_PPS_OFFSET, pps); | ||
649 | +} | ||
650 | + | ||
651 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
652 | + * @fn static INLINE void ioh_1588_aux_master_snap_get( | ||
653 | + * unsigned long *amms_low, unsigned long *amms_high) | ||
654 | + * @brief Get AMMS value | ||
655 | + * @param amms_low [OUT] AMMS low value. | ||
656 | + * @param amms_high [OUT] AMMS high value. | ||
657 | + * @retval None. | ||
658 | +*/ | ||
659 | +static INLINE void | ||
660 | +ioh_1588_aux_master_snap_get(unsigned long *amms_low, unsigned long *amms_high) | ||
661 | +{ | ||
662 | + /* Get the Auxiliary Master Mode Snapshot Low Register contents */ | ||
663 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_AMSL_OFFSET, amms_low); | ||
664 | + | ||
665 | + /* Get the Auxiliary Master Mode Snapshot High Register contents */ | ||
666 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_AMSH_OFFSET, amms_high); | ||
667 | +} | ||
668 | + | ||
669 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
670 | + * @fn static INLINE void ioh_1588_aux_slave_snap_get( | ||
671 | + * unsigned long *asms_low, unsigned long *asms_high) | ||
672 | + * @brief Get ASMS value | ||
673 | + * @param asms_low [OUT] The ASMS low value. | ||
674 | + * @param asms_high [OUT] The ASMS high value. | ||
675 | + * @retval None | ||
676 | +*/ | ||
677 | +static INLINE void | ||
678 | +ioh_1588_aux_slave_snap_get(unsigned long *asms_low, unsigned long *asms_high) | ||
679 | +{ | ||
680 | + /* Get the Auxiliary Slave Mode Snapshot Low Register contents */ | ||
681 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_ASSL_OFFSET, asms_low); | ||
682 | + | ||
683 | + /* Get the Auxiliary Slave Mode Snapshot High Register contents */ | ||
684 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_ASSH_OFFSET, asms_high); | ||
685 | +} | ||
686 | + | ||
687 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
688 | + * @fn static INLINE void ioh_1588_master_mode_set( | ||
689 | + * unsigned long master_mode) | ||
690 | + * @brief Set the channel mode to 1588 Master/Slave | ||
691 | + * @param master_mode [IN] The channel mode. | ||
692 | + * @retval None | ||
693 | +*/ | ||
694 | +static INLINE void ioh_1588_master_mode_set(unsigned long master_mode) | ||
695 | +{ | ||
696 | + /* SET or CLEAR the Master Mode */ | ||
697 | + if (TRUE == master_mode) { | ||
698 | + IOH_DEBUG("ioh_1588_master_mode_set: setting master mode\n"); | ||
699 | + /* SET the mm bit */ | ||
700 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_CC_OFFSET, | ||
701 | + IOH_1588_CC_MM); | ||
702 | + } else { | ||
703 | + IOH_DEBUG("ioh_1588_master_mode_set: clearing master mode\n"); | ||
704 | + /* CLEAR the mm bit */ | ||
705 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_CC_OFFSET, | ||
706 | + IOH_1588_CC_MM); | ||
707 | + } | ||
708 | +} | ||
709 | + | ||
710 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
711 | + * @fn static INLINE unsigned long ioh_1588_master_mode_get (void) | ||
712 | + * @brief Check for 1588 master mode of channel | ||
713 | + * @param None. | ||
714 | + * @retval unsigned long | ||
715 | +*/ | ||
716 | +static INLINE unsigned long ioh_1588_master_mode_get(void) | ||
717 | +{ | ||
718 | + /* Is the mm bit SET? */ | ||
719 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_CC_OFFSET, | ||
720 | + IOH_1588_CC_MM); | ||
721 | +} | ||
722 | + | ||
723 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
724 | + * @fn static INLINE void ioh_1588_timestamp_all_set( | ||
725 | + * unsigned long allMsg) | ||
726 | + * @brief Set Timestamp all or only PTP messages flag | ||
727 | + * @param allMsg [IN] All/PTP messages. | ||
728 | + * @retval None | ||
729 | +*/ | ||
730 | +static INLINE void ioh_1588_timestamp_all_set(unsigned long allMsg) | ||
731 | +{ | ||
732 | + /* SET or CLEAR the All Message Timestamping */ | ||
733 | + if (TRUE == allMsg) { | ||
734 | + IOH_DEBUG | ||
735 | + ("ioh_1588_timestamp_all_set: time stamp all messages\n"); | ||
736 | + /* SET the ta bit */ | ||
737 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_CC_OFFSET, | ||
738 | + IOH_1588_CC_TA); | ||
739 | + } else { /* else of if (TRUE == allMsg) */ | ||
740 | + | ||
741 | + IOH_DEBUG | ||
742 | + ("ioh_1588_timestamp_all_set: time stamp PTP messages \ | ||
743 | + only\n"); | ||
744 | + /* CLEAR the ta bit */ | ||
745 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_CC_OFFSET, | ||
746 | + IOH_1588_CC_TA); | ||
747 | + } | ||
748 | +} | ||
749 | + | ||
750 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
751 | + * @fn static INLINE unsigned long ioh_1588_timestamp_all_get(void) | ||
752 | + * @brief Check for Timestamp all OR only PTP messages flag | ||
753 | + * @param None. | ||
754 | + * @retval unsigned long | ||
755 | +*/ | ||
756 | +static INLINE unsigned long ioh_1588_timestamp_all_get(void) | ||
757 | +{ | ||
758 | + /* Is the ta bit SET? */ | ||
759 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_CC_OFFSET, | ||
760 | + IOH_1588_CC_TA); | ||
761 | +} | ||
762 | + | ||
763 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
764 | + * @fn static INLINE void ioh_1588_version_set( | ||
765 | + * unsigned long versionVal) | ||
766 | + * @brief Set the 1588 version number | ||
767 | + * @param versionVal [IN] The version value. | ||
768 | + * @retval None. | ||
769 | +*/ | ||
770 | +static INLINE void ioh_1588_version_set(unsigned long versionVal) | ||
771 | +{ | ||
772 | + if (TRUE == versionVal) { | ||
773 | + IOH_DEBUG | ||
774 | + ("ioh_1588_version_set supports IEEE1588 v1 and \ | ||
775 | + IEEE1588-2008\n"); | ||
776 | + /* SET the version bit */ | ||
777 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_CC_OFFSET, | ||
778 | + IOH_1588_CC_VERSION); | ||
779 | + } else { | ||
780 | + IOH_DEBUG("ioh_1588_version_set supports IEEE1588 v1 only\n"); | ||
781 | + /* CLEAR the version bit */ | ||
782 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_CC_OFFSET, | ||
783 | + IOH_1588_CC_VERSION); | ||
784 | + } | ||
785 | +} | ||
786 | + | ||
787 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
788 | + * @fn static INLINE unsigned long ioh_1588_version_get (void) | ||
789 | + * @brief Get the 1588 version number | ||
790 | + * @param None. | ||
791 | + * @retval unsigned long | ||
792 | +*/ | ||
793 | +static INLINE unsigned long ioh_1588_version_get(void) | ||
794 | +{ | ||
795 | + /* Is the version bit SET? */ | ||
796 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_CC_OFFSET, | ||
797 | + IOH_1588_CC_VERSION); | ||
798 | +} | ||
799 | + | ||
800 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
801 | + * @fn static INLINE unsigned long ioh_1588_can_snap_valid (void) | ||
802 | + * @brief CAN Timestamp available | ||
803 | + * @param None | ||
804 | + * @retval unsigned long | ||
805 | +*/ | ||
806 | +static INLINE unsigned long ioh_1588_can_snap_valid(void) | ||
807 | +{ | ||
808 | + /* Is the valid bit SET? */ | ||
809 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_CCE_OFFSET, | ||
810 | + IOH_1588_CE_VAL); | ||
811 | +} | ||
812 | + | ||
813 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
814 | + * @fn static INLINE unsigned long ioh_1588_can_snap_ovr(void) | ||
815 | + * @brief CAN Timestamp overrun | ||
816 | + * @param None | ||
817 | + * @retval unsigned long | ||
818 | +*/ | ||
819 | +static INLINE unsigned long ioh_1588_can_snap_ovr(void) | ||
820 | +{ | ||
821 | + /* Is the ovr bit SET? */ | ||
822 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_CCE_OFFSET, | ||
823 | + IOH_1588_CE_OVR); | ||
824 | +} | ||
825 | + | ||
826 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
827 | + * @fn static INLINE void ioh_1588_can_snap_valid_clear(void) | ||
828 | + * @brief Clear CAN Timestamp valid flag | ||
829 | + * @param None | ||
830 | + * @retval None | ||
831 | +*/ | ||
832 | +static INLINE void ioh_1588_can_snap_valid_clear(void) | ||
833 | +{ | ||
834 | + /* CLEAR the valid bit by writing '1' onto it */ | ||
835 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_CCE_OFFSET, IOH_1588_CE_VAL); | ||
836 | +} | ||
837 | + | ||
838 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
839 | + * @fn static INLINE void ioh_1588_can_snap_ovr_clear(void) | ||
840 | + * @brief Clear CAN Timestamp overrun flag | ||
841 | + * @param None | ||
842 | + * @retval None | ||
843 | +*/ | ||
844 | +static INLINE void ioh_1588_can_snap_ovr_clear(void) | ||
845 | +{ | ||
846 | + /* CLEAR the overrun bit */ | ||
847 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_CCE_OFFSET, IOH_1588_CE_OVR); | ||
848 | +} | ||
849 | + | ||
850 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
851 | + * @fn static INLINE unsigned long ioh_1588_rx_snap_evt(void) | ||
852 | + * @brief Receive Timestamp available | ||
853 | + * @param None | ||
854 | + * @retval unsigned long | ||
855 | +*/ | ||
856 | +static INLINE unsigned long ioh_1588_rx_snap_evt(void) | ||
857 | +{ | ||
858 | + /* Is the rxs bit SET? */ | ||
859 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_CE_OFFSET, | ||
860 | + IOH_1588_CE_RXS); | ||
861 | +} | ||
862 | + | ||
863 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
864 | + * @fn | ||
865 | + * @brief Transmit Timestamp available | ||
866 | + * @param None | ||
867 | + * @retval unsigned long | ||
868 | +*/ | ||
869 | +static INLINE unsigned long ioh_1588_tx_snap_evt(void) | ||
870 | +{ | ||
871 | + /* Is the txs bit SET? */ | ||
872 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_CE_OFFSET, | ||
873 | + IOH_1588_CE_TXS); | ||
874 | +} | ||
875 | + | ||
876 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
877 | + * @fn static INLINE void ioh_1588_rx_snap_evt_clear(void) | ||
878 | + * @brief Clear Receive Timestamp available event | ||
879 | + * @param None. | ||
880 | + * @retval None.*/ | ||
881 | +static INLINE void ioh_1588_rx_snap_evt_clear(void) | ||
882 | +{ | ||
883 | + /* CLEAR the rxs bit */ | ||
884 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_CE_OFFSET, IOH_1588_CE_RXS); | ||
885 | +} | ||
886 | + | ||
887 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
888 | + * @fn static INLINE void ioh_1588_tx_snap_evt_clear(void) | ||
889 | + * @brief Clear Transmit Timestamp available event | ||
890 | + * @param None | ||
891 | + * @retval None | ||
892 | +*/ | ||
893 | +static INLINE void ioh_1588_tx_snap_evt_clear(void) | ||
894 | +{ | ||
895 | + unsigned long ev_reg; | ||
896 | + | ||
897 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_CE_OFFSET, &ev_reg); | ||
898 | + IOH_DEBUG | ||
899 | + ("ioh_1588_tx_snap_evt_clear event reg content before clearing= %lx\n", | ||
900 | + ev_reg); | ||
901 | + | ||
902 | + /* CLEAR the txs bit */ | ||
903 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_CE_OFFSET, IOH_1588_CE_TXS); | ||
904 | + | ||
905 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_CE_OFFSET, &ev_reg); | ||
906 | + IOH_DEBUG | ||
907 | + ("ioh_1588_tx_snap_evt_clear event reg content after clearing= %lx\n", | ||
908 | + ev_reg); | ||
909 | +} | ||
910 | + | ||
911 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
912 | + * @fn static INLINE void ioh_1588_can_snap_get( | ||
913 | + * unsigned long *rxs_low,unsigned long *rxs_high) | ||
914 | + * @brief Get PTP CAN Port Timestamp value | ||
915 | + * @param rxs_low [OUT] The CAN Rx low value. | ||
916 | + * @param rxs_high [OUT] The CAN Rx high value. | ||
917 | + * @retval None. | ||
918 | +*/ | ||
919 | +static INLINE void | ||
920 | +ioh_1588_can_snap_get(unsigned long *rxs_low, unsigned long *rxs_high) | ||
921 | +{ | ||
922 | + /* Get the Receive Timestamp/Snapshot Low Register contents */ | ||
923 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_CXSL_OFFSET, rxs_low); | ||
924 | + | ||
925 | + /* Get the Receive Timestamp/Snapshot High Register contents */ | ||
926 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_CXSH_OFFSET, rxs_high); | ||
927 | +} | ||
928 | + | ||
929 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
930 | + * @fn static INLINE void ioh_1588_rx_snap_get( | ||
931 | + * unsigned long *rxs_low, unsigned long *rxs_high) | ||
932 | + * @brief Get PTP Port Rx Timestamp value | ||
933 | + * @param rxs_low [OUT] The Snap Rx value. | ||
934 | + * @param rxs_high [OUT] The Snap Rx Value. | ||
935 | + * @reatval None | ||
936 | +*/ | ||
937 | +static INLINE void | ||
938 | +ioh_1588_rx_snap_get(unsigned long *rxs_low, unsigned long *rxs_high) | ||
939 | +{ | ||
940 | + /* Get the Receive Timestamp/Snapshot Low Register contents */ | ||
941 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_RSL_OFFSET, rxs_low); | ||
942 | + | ||
943 | + /* Get the Receive Timestamp/Snapshot High Register contents */ | ||
944 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_RSH_OFFSET, rxs_high); | ||
945 | +} | ||
946 | + | ||
947 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
948 | + * @fn static INLINE void ioh_1588_tx_snap_get( | ||
949 | + * unsigned long *txs_low, unsigned long *txs_high) | ||
950 | + * @brief Get PTP Port Tx Timestamp value | ||
951 | + * @param txs_low [OUT] The Port Tx value low. | ||
952 | + * @param txs_high [OUT] The Port Tx value high. | ||
953 | + * @retval None | ||
954 | +*/ | ||
955 | +static INLINE void | ||
956 | +ioh_1588_tx_snap_get(unsigned long *txs_low, unsigned long *txs_high) | ||
957 | +{ | ||
958 | + /* Get the Transmit Timestamp/Snapshot Low Register contents */ | ||
959 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_XSL_OFFSET, txs_low); | ||
960 | + | ||
961 | + /* Get the Transmit Timestamp/Snapshot High Register contents */ | ||
962 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_XSH_OFFSET, txs_high); | ||
963 | + | ||
964 | +} | ||
965 | + | ||
966 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
967 | + * @fn static INLINE void ioh_1588_uuid_seqid_get( | ||
968 | + * unsigned long *uuid_low,unsigned long *uuid_high, unsigned int *seq_id) | ||
969 | + * @brief Get UUID High (16-bit value) & Sequence ID (16-bit value) of | ||
970 | + * PTP message | ||
971 | + * @param uuid_low [OUT] The UUID low value. | ||
972 | + * @param seq_id [OUT] The sequence ID. | ||
973 | + * @retval None. | ||
974 | +*/ | ||
975 | +static INLINE void | ||
976 | +ioh_1588_uuid_seqid_get(unsigned long *uuid_low, | ||
977 | + unsigned long *uuid_high, unsigned int *seq_id) | ||
978 | +{ | ||
979 | + unsigned long regval = 0; | ||
980 | + | ||
981 | + /* Get the UUID Low Register contents */ | ||
982 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_UID_OFFSET, uuid_low); | ||
983 | + | ||
984 | + /* Get the Sequence ID and Source UUID High Register contents */ | ||
985 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_SID_OFFSET, ®val); | ||
986 | + | ||
987 | + *seq_id = (regval >> IOH_1588_SID_LOC); | ||
988 | + *uuid_high = (regval & IOH_1588_LSB_SHORT_MASK); | ||
989 | +} | ||
990 | + | ||
991 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
992 | + * @fn static INLINE void ioh_1588_op_mode_set(unsigned long mode) | ||
993 | + * @brief Sets the operation mode. | ||
994 | + * @param mode [IN] The mode value. | ||
995 | + * @retval None. | ||
996 | +*/ | ||
997 | +static INLINE void ioh_1588_op_mode_set(unsigned long mode) | ||
998 | +{ | ||
999 | + unsigned long regval; | ||
1000 | + | ||
1001 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_CC_OFFSET, ®val); | ||
1002 | + regval = | ||
1003 | + (regval & ~IOH_1588_CC_MODE_MASK) | (mode << | ||
1004 | + IOH_1588_CC_MODE_SHIFT); | ||
1005 | + /* set the operaion mode bits */ | ||
1006 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_CC_OFFSET, regval); | ||
1007 | +} | ||
1008 | + | ||
1009 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1010 | + * @fn static INLINE unsigned long ioh_1588_op_mode_get(void) | ||
1011 | + * @brief Gets the operation mode. | ||
1012 | + * @param None. | ||
1013 | + * @retval unsigned long | ||
1014 | +*/ | ||
1015 | +static INLINE unsigned long ioh_1588_op_mode_get(void) | ||
1016 | +{ | ||
1017 | + unsigned long regval; | ||
1018 | + unsigned long mode; | ||
1019 | + | ||
1020 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_CC_OFFSET, ®val); | ||
1021 | + /* get the operaion mode bits */ | ||
1022 | + mode = (regval & IOH_1588_CC_MODE_MASK) >> IOH_1588_CC_MODE_SHIFT; | ||
1023 | + | ||
1024 | + return mode; | ||
1025 | +} | ||
1026 | + | ||
1027 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1028 | + * @fn static INLINE void ioh_1588_eth_enable_set(void) | ||
1029 | + * @brief Enbales the eth. | ||
1030 | + * @param None. | ||
1031 | + * @retval None. | ||
1032 | +*/ | ||
1033 | +static INLINE void ioh_1588_eth_enable_set(void) | ||
1034 | +{ | ||
1035 | + /* SET the eth_enable bit */ | ||
1036 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_ECS_OFFSET, IOH_1588_ECS_ETH); | ||
1037 | +} | ||
1038 | + | ||
1039 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1040 | + * @fn static INLINE void ioh_1588_eth_enable_clear(void) | ||
1041 | + * @brief Clears the eth enable. | ||
1042 | + * @param None. | ||
1043 | + * @retval None. | ||
1044 | +*/ | ||
1045 | +static INLINE void ioh_1588_eth_enable_clear(void) | ||
1046 | +{ | ||
1047 | + /* Clear the eth_enable bit */ | ||
1048 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_ECS_OFFSET, IOH_1588_ECS_ETH); | ||
1049 | +} | ||
1050 | + | ||
1051 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1052 | + * @fn static INLINE unsigned long ioh_1588_eth_enable_get(void) | ||
1053 | + * @brief Gets the eth enable. | ||
1054 | + * @param None. | ||
1055 | + * @retval unsigned long | ||
1056 | +*/ | ||
1057 | +static INLINE unsigned long ioh_1588_eth_enable_get(void) | ||
1058 | +{ | ||
1059 | + /* Is eth_enable bit set? */ | ||
1060 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_ECS_OFFSET, | ||
1061 | + IOH_1588_ECS_ETH); | ||
1062 | +} | ||
1063 | + | ||
1064 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1065 | + * @fn static INLINE void ioh_1588_can_enable_set(void) | ||
1066 | + * @brief Sets the CAN enable. | ||
1067 | + * @param None | ||
1068 | + * @retval None | ||
1069 | +*/ | ||
1070 | +static INLINE void ioh_1588_can_enable_set(void) | ||
1071 | +{ | ||
1072 | + /* SET the can_enable bit */ | ||
1073 | + IOH_SET_ADDR_BIT(ioh_1588_base + IOH_1588_ECS_OFFSET, IOH_1588_ECS_CAN); | ||
1074 | +} | ||
1075 | + | ||
1076 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1077 | + * @fn static INLINE void ioh_1588_can_enable_clear(void) | ||
1078 | + * @brief Sets the CAN enable clear | ||
1079 | + * @param None | ||
1080 | + * @retval None | ||
1081 | +*/ | ||
1082 | +static INLINE void ioh_1588_can_enable_clear(void) | ||
1083 | +{ | ||
1084 | + /* Clear the can_enable bit */ | ||
1085 | + IOH_CLR_ADDR_BIT(ioh_1588_base + IOH_1588_ECS_OFFSET, IOH_1588_ECS_CAN); | ||
1086 | +} | ||
1087 | + | ||
1088 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1089 | + * @fn static INLINE unsigned long ioh_1588_can_enable_get(void) | ||
1090 | + * @brief Gets the CAN enable status. | ||
1091 | + * @param None. | ||
1092 | + * @retval unsigned long | ||
1093 | +*/ | ||
1094 | +static INLINE unsigned long ioh_1588_can_enable_get(void) | ||
1095 | +{ | ||
1096 | + /* Is can_enable bit set? */ | ||
1097 | + return IOH_BIT_SET_CHECK(ioh_1588_base + IOH_1588_ECS_OFFSET, | ||
1098 | + IOH_1588_ECS_CAN); | ||
1099 | +} | ||
1100 | + | ||
1101 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1102 | + * @fn static INLINE void ioh_1588_station_set(unsigned long station, | ||
1103 | + * unsigned long value) | ||
1104 | + * @brief Set the station[1-6] address to be used in PTP message | ||
1105 | + * @param station [IN] The Station. | ||
1106 | + * @param value [IN] The Value. | ||
1107 | + * @retval None. | ||
1108 | +*/ | ||
1109 | +static INLINE void | ||
1110 | +ioh_1588_station_set(unsigned long station, unsigned long value) | ||
1111 | +{ | ||
1112 | + IOH_DEBUG("ioh_1588_station_set;setting station address=%lx\n", value); | ||
1113 | + /* Set the Station Address Register contents */ | ||
1114 | + IOH_REG_32_WRITE(ioh_1588_base + IOH_1588_STA_OFFSET + | ||
1115 | + station * sizeof(int), value); | ||
1116 | +} | ||
1117 | + | ||
1118 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1119 | + * @fn static INLINE void ioh_1588_station_get (unsigned long station, | ||
1120 | + * unsigned long *value) | ||
1121 | + * @brief Get the station[1-6] address used in PTP message | ||
1122 | + * @param station [IN] The station. | ||
1123 | + * @param value [OUT] The value. | ||
1124 | + * @retval None. | ||
1125 | +*/ | ||
1126 | +static INLINE void | ||
1127 | +ioh_1588_station_get(unsigned long station, unsigned long *value) | ||
1128 | +{ | ||
1129 | + /* Get the Station Address Register contents */ | ||
1130 | + IOH_REG_32_READ(ioh_1588_base + IOH_1588_STA_OFFSET + | ||
1131 | + station * sizeof(int), value); | ||
1132 | + *value &= 0xFF; /* only one byte */ | ||
1133 | +} | ||
1134 | + | ||
1135 | +/** | ||
1136 | + * Support functions definitions | ||
1137 | + */ | ||
1138 | + | ||
1139 | +/** | ||
1140 | + * @ingroup IEEE_1588_HALLayerAPI | ||
1141 | + * @fn enum ioh_status ioh_1588_disable_interrupts(void) | ||
1142 | + * @brief Disables all interrupts on the 1588 device. | ||
1143 | + * @param None | ||
1144 | + * @retval enum ioh_status | ||
1145 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1146 | + */ | ||
1147 | + | ||
1148 | +enum ioh_status ioh_1588_disable_interrupts(void) | ||
1149 | +{ | ||
1150 | + if (ioh_1588_base != 0) { | ||
1151 | + IOH_DEBUG | ||
1152 | + ("ioh_1588_disable_interrupts:invoking \ | ||
1153 | + ioh_1588_ttm_imask_clear\n"); | ||
1154 | + ioh_1588_ttm_imask_clear(); | ||
1155 | + IOH_DEBUG | ||
1156 | + ("ioh_1588_disable_interrupts:invoking \ | ||
1157 | + ioh_1588_asms_imask_clear\n"); | ||
1158 | + ioh_1588_asms_imask_clear(); | ||
1159 | + IOH_DEBUG | ||
1160 | + ("ioh_1588_disable_interrupts:invoking \ | ||
1161 | + ioh_1588_amms_imask_clear\n"); | ||
1162 | + ioh_1588_amms_imask_clear(); | ||
1163 | + IOH_DEBUG | ||
1164 | + ("ioh_1588_disable_interrupts:invoking \ | ||
1165 | + ioh_1588_pps_imask_clear\n"); | ||
1166 | + ioh_1588_pps_imask_clear(); | ||
1167 | + } | ||
1168 | + return IOH_1588_SUCCESS; | ||
1169 | +} | ||
1170 | + | ||
1171 | +/** | ||
1172 | + * @ingroup IEEE_1588_HALLayerAPI | ||
1173 | + * @fn enum ioh_status ioh_1588_interrupt_pending( | ||
1174 | + * unsigned long *pending) | ||
1175 | + * @brief Check whether there is any pending interrupts from the 1588 | ||
1176 | + * device. | ||
1177 | + * @param pending [IN] Pending flag which set to TRUE if there is any | ||
1178 | + * pending interrupt | ||
1179 | + * @retval enum ioh_status | ||
1180 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1181 | + */ | ||
1182 | +enum ioh_status ioh_1588_interrupt_pending(unsigned long *pending) | ||
1183 | +{ | ||
1184 | + *pending = FALSE; | ||
1185 | + if (ioh_1588_pps_evt_get() || ioh_1588_amms_evt_get() || | ||
1186 | + ioh_1588_asms_evt_get() || ioh_1588_ttm_evt_get()) { | ||
1187 | + IOH_DEBUG("ioh_1588_interrupt_pending:interrupt pending\n"); | ||
1188 | + *pending = TRUE; | ||
1189 | + } else { | ||
1190 | + IOH_DEBUG("ioh_1588_interrupt_pending:NO interrupt pending\n"); | ||
1191 | + } | ||
1192 | + | ||
1193 | + return IOH_1588_SUCCESS; | ||
1194 | +} | ||
1195 | + | ||
1196 | +/** | ||
1197 | + * @ingroup IEEE_1588_HALLayerAPI | ||
1198 | + * @fn enum ioh1588PTPPortMode ioh_1588_port_mode_get( | ||
1199 | + * enum ioh1588PTPPort ptpPort) | ||
1200 | + * @brief Function to determine the port mode | ||
1201 | + * @param ptpPort [IN] Interested port (GBE_0) | ||
1202 | + * @retval enum ioh1588PTPPortMode | ||
1203 | + * - IOH_1588PTP_PORT_MASTER | ||
1204 | + * - IOH_1588PTP_PORT_SLAVE | ||
1205 | + * - IOH_1588PTP_PORT_ANYMODE | ||
1206 | + */ | ||
1207 | +enum ioh1588PTPPortMode ioh_1588_port_mode_get(enum ioh1588PTPPort ptpPort) | ||
1208 | +{ | ||
1209 | + /* Local variables */ | ||
1210 | + unsigned long master_mode = FALSE; | ||
1211 | + unsigned long any_mode = FALSE; | ||
1212 | + enum ioh1588PTPPortMode port_mode = IOH_1588PTP_PORT_SLAVE; | ||
1213 | + | ||
1214 | + /* Get the Mode of the PTP Port */ | ||
1215 | + master_mode = ioh_1588_master_mode_get(); | ||
1216 | + any_mode = ioh_1588_timestamp_all_get(); | ||
1217 | + | ||
1218 | + /* Is ANY mode (all message timestamp mode) on? */ | ||
1219 | + if (TRUE == any_mode) { | ||
1220 | + IOH_DEBUG | ||
1221 | + ("ioh_1588_port_mode_get:all messages being timestamped\n"); | ||
1222 | + /* | ||
1223 | + * When Any mode is set, all messages are time stamped, | ||
1224 | + * irrespective of the Master/Slave mode bit | ||
1225 | + */ | ||
1226 | + port_mode = IOH_1588PTP_PORT_ANYMODE; | ||
1227 | + IOH_DEBUG | ||
1228 | + ("ioh_1588_port_mode_get:port_mode = \ | ||
1229 | + IOH_1588PTP_PORT_ANYMODE\n"); | ||
1230 | + } else { | ||
1231 | + /* Is Master mode on? */ | ||
1232 | + if (TRUE == master_mode) { | ||
1233 | + port_mode = IOH_1588PTP_PORT_MASTER; | ||
1234 | + IOH_DEBUG | ||
1235 | + ("ioh_1588_port_mode_get:port_mode = \ | ||
1236 | + IOH_1588PTP_PORT_MASTER\n"); | ||
1237 | + } else { | ||
1238 | + port_mode = IOH_1588PTP_PORT_SLAVE; | ||
1239 | + IOH_DEBUG | ||
1240 | + ("ioh_1588_port_mode_get:port_mode = \ | ||
1241 | + IOH_1588PTP_PORT_SLAVE\n"); | ||
1242 | + } | ||
1243 | + } | ||
1244 | + | ||
1245 | + return port_mode; | ||
1246 | +} | ||
1247 | + | ||
1248 | +/* | ||
1249 | + * Public API definitions | ||
1250 | + */ | ||
1251 | + | ||
1252 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1253 | + * @fn enum ioh_status ioh_1588_blpl_base_address_set(unsigned long base_addr) | ||
1254 | + * | ||
1255 | + * @brief Function sets the virtual address of registers | ||
1256 | + * @remarks This API will set the starting virtual addresses for the | ||
1257 | + * 1588 hardware registers. The main tasks performed by this | ||
1258 | + * function are: | ||
1259 | + * - If the aargument passed is NULL, return status | ||
1260 | + * IOH_1588_INVALIDPARAM | ||
1261 | + * - Set base address of IEEE 1588 registers to specified value | ||
1262 | + * | ||
1263 | + * | ||
1264 | + * @param base_addr [IN] - Virtual address of IEEE 1588 module registers | ||
1265 | + * | ||
1266 | + * @retval enum ioh_status | ||
1267 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1268 | + * @li IOH_1588_INVALIDPARAM - Invalid parameter passed | ||
1269 | + */ | ||
1270 | +enum ioh_status ioh_1588_blpl_base_address_set(unsigned long base_addr) | ||
1271 | +{ | ||
1272 | + if (!base_addr) { | ||
1273 | + IOH_LOG(KERN_ERR, | ||
1274 | + "ioh_1588_blpl_base_address_set:invalid base address\ | ||
1275 | + returning IOH_1588_INVALIDPARAM\n"); | ||
1276 | + return IOH_1588_INVALIDPARAM; | ||
1277 | + } | ||
1278 | + | ||
1279 | + ioh_1588_base = base_addr; | ||
1280 | + IOH_DEBUG("ioh_1588_blpl_base_address_set:base address=%lx\n", | ||
1281 | + ioh_1588_base); | ||
1282 | + | ||
1283 | + /* Initialize the callback pointers */ | ||
1284 | + ioh_tt_cbptr = (ioh1588TargetTimeCallback) NULL; | ||
1285 | + ioh_am_cbptr = (ioh1588AuxTimeCallback) NULL; | ||
1286 | + ioh_as_cbptr = (ioh1588AuxTimeCallback) NULL; | ||
1287 | + ioh_pps_cbptr = (ioh1588PulsePerSecondCallback) NULL; | ||
1288 | + IOH_DEBUG("ioh_1588_blpl_base_address_set:initialized callback ptrs\n"); | ||
1289 | + | ||
1290 | + /* Reset the statistics counters */ | ||
1291 | + ioh_1588_stats.rxMsgs = ioh_1588_stats.txMsgs = 0; | ||
1292 | + IOH_DEBUG("ioh_1588_blpl_base_address_set:reset statistics counters\n"); | ||
1293 | + | ||
1294 | + /* Clear availability of various events */ | ||
1295 | + IOH_DEBUG | ||
1296 | + ("ioh_1588_blpl_base_address_set:invoking \ | ||
1297 | + ioh_1588_pps_evt_clear\n"); | ||
1298 | + ioh_1588_pps_evt_clear(); | ||
1299 | + IOH_DEBUG | ||
1300 | + ("ioh_1588_blpl_base_address_set:invoking \ | ||
1301 | + ioh_1588_ttm_evt_clear\n"); | ||
1302 | + ioh_1588_ttm_evt_clear(); | ||
1303 | + IOH_DEBUG | ||
1304 | + ("ioh_1588_blpl_base_address_set:invoking \ | ||
1305 | + ioh_1588_amms_evt_clear\n"); | ||
1306 | + ioh_1588_amms_evt_clear(); | ||
1307 | + IOH_DEBUG | ||
1308 | + ("ioh_1588_blpl_base_address_set:invoking \ | ||
1309 | + ioh_1588_asms_evt_clear\n"); | ||
1310 | + ioh_1588_asms_evt_clear(); | ||
1311 | + | ||
1312 | + IOH_DEBUG("ioh_1588_blpl_base_address_set:returning success\n"); | ||
1313 | + return IOH_1588_SUCCESS; | ||
1314 | +} | ||
1315 | + | ||
1316 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1317 | + * @fn enum ioh_status ioh_1588_ptp_port_config_set( | ||
1318 | + * enum ioh1588PTPPort ptpPort, enum ioh1588PTPPortMode ptpPortMode) | ||
1319 | + * | ||
1320 | + * @brief Configure IEEE 1588 Hardware Assist message detection on a given PTP | ||
1321 | + * port | ||
1322 | + * | ||
1323 | + * @remarks This API enables the time stamping on a particular PTP port. | ||
1324 | + * The main tasks performed by this function are: | ||
1325 | + * - Validate the parameters and return | ||
1326 | + * IOH_1588_INVALIDPARAM, if found invalid | ||
1327 | + * - Modify the TS_Channel_Control register to set the | ||
1328 | + * requested mode | ||
1329 | + * | ||
1330 | + * | ||
1331 | + * @param ptpPort [IN] - port on which PTP message detection to be enabled | ||
1332 | + * @param ptpPortMode [IN]- Master/Slave/All messages | ||
1333 | + * | ||
1334 | + * @retval enum ioh_status | ||
1335 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1336 | + * @li IOH_1588_INVALIDPARAM - Invalid parameters passed | ||
1337 | + */ | ||
1338 | +enum ioh_status | ||
1339 | +ioh_1588_ptp_port_config_set(enum ioh1588PTPPort ptpPort, | ||
1340 | + enum ioh1588PTPPortMode ptpPortMode) | ||
1341 | +{ | ||
1342 | + /* Verify the parameters for proper values */ | ||
1343 | + if (ptpPort != IOH_1588_GBE_0_1588PTP_PORT) { | ||
1344 | + IOH_LOG(KERN_ERR, | ||
1345 | + "ioh_1588_ptp_port_config_set:invalid ptp port\ | ||
1346 | + returning IOH_1588_GBE_0_1588PTP_PORT\n"); | ||
1347 | + return IOH_1588_INVALIDPARAM; | ||
1348 | + } | ||
1349 | + | ||
1350 | + /* Set the Mode of the PTP Port */ | ||
1351 | + switch (ptpPortMode) { | ||
1352 | + case IOH_1588PTP_PORT_MASTER: | ||
1353 | + { | ||
1354 | + IOH_DEBUG | ||
1355 | + ("ioh_1588_ptp_port_config_set:port_mode=\ | ||
1356 | + IOH_1588PTP_PORT_MASTER\n"); | ||
1357 | + IOH_DEBUG | ||
1358 | + ("ioh_1588_ptp_port_config_set:invoking \ | ||
1359 | + ioh_1588_master_mode_set \ | ||
1360 | + with param TRUE\n"); | ||
1361 | + ioh_1588_master_mode_set(TRUE); | ||
1362 | + IOH_DEBUG | ||
1363 | + ("ioh_1588_ptp_port_config_set:invoking \ | ||
1364 | + ioh_1588_timestamp_all_set \ | ||
1365 | + with param FALSE\n"); | ||
1366 | + ioh_1588_timestamp_all_set(FALSE); | ||
1367 | + break; | ||
1368 | + } | ||
1369 | + case IOH_1588PTP_PORT_SLAVE: | ||
1370 | + { | ||
1371 | + IOH_DEBUG | ||
1372 | + ("ioh_1588_ptp_port_config_set:port_mode=\ | ||
1373 | + IOH_1588PTP_PORT_SLAVE\n"); | ||
1374 | + IOH_DEBUG | ||
1375 | + ("ioh_1588_ptp_port_config_set:invoking \ | ||
1376 | + ioh_1588_master_mode_set \ | ||
1377 | + with param FALSE\n"); | ||
1378 | + ioh_1588_master_mode_set(FALSE); | ||
1379 | + IOH_DEBUG | ||
1380 | + ("ioh_1588_ptp_port_config_set:invoking \ | ||
1381 | + ioh_1588_timestamp_all_set \ | ||
1382 | + with param FALSE\n"); | ||
1383 | + ioh_1588_timestamp_all_set(FALSE); | ||
1384 | + break; | ||
1385 | + } | ||
1386 | + case IOH_1588PTP_PORT_ANYMODE: | ||
1387 | + { | ||
1388 | + IOH_DEBUG | ||
1389 | + ("ioh_1588_ptp_port_config_set:port_mode=\ | ||
1390 | + IOH_1588PTP_PORT_ANYMODE\n"); | ||
1391 | + IOH_DEBUG | ||
1392 | + ("ioh_1588_ptp_port_config_set:invoking \ | ||
1393 | + ioh_1588_master_mode_set \ | ||
1394 | + with param FALSE\n"); | ||
1395 | + ioh_1588_master_mode_set(FALSE); | ||
1396 | + IOH_DEBUG | ||
1397 | + ("ioh_1588_ptp_port_config_set:invoking \ | ||
1398 | + ioh_1588_timestamp_all_set \ | ||
1399 | + with param TRUE\n"); | ||
1400 | + ioh_1588_timestamp_all_set(TRUE); | ||
1401 | + break; | ||
1402 | + } | ||
1403 | + default: | ||
1404 | + { | ||
1405 | + IOH_LOG(KERN_ERR, "ioh_1588_ptp_port_config_set: \ | ||
1406 | + Invalid Port Mode (%d) \ | ||
1407 | + returning IOH_1588_INVALIDPARAM\n", | ||
1408 | + ptpPortMode); | ||
1409 | + return IOH_1588_INVALIDPARAM; | ||
1410 | + } | ||
1411 | + } | ||
1412 | + | ||
1413 | + return IOH_1588_SUCCESS; | ||
1414 | +} | ||
1415 | + | ||
1416 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1417 | + * @fn enum ioh_status ioh_1588_ptp_port_config_get( | ||
1418 | + * enum ioh1588PTPPort ptpPort, | ||
1419 | + * enum ioh1588PTPPortMode *ptpPortMode) | ||
1420 | + * | ||
1421 | + * @brief Get the configuration of IEEE 1588 Hardware Assist message | ||
1422 | + * detection | ||
1423 | + * for given PTP port | ||
1424 | + * | ||
1425 | + * @remarks This API retrieves the time stamping configuration of the given | ||
1426 | + * PTP port. | ||
1427 | + * The main tasks performed by this function are: | ||
1428 | + * - Validate the parameters and return | ||
1429 | + * IOH_1588_INVALIDPARAM, if found invalid | ||
1430 | + * - Return the current master/slave mode from | ||
1431 | + * TS_Channel_Control register | ||
1432 | + * | ||
1433 | + * | ||
1434 | + * @param ptpPort [IN] port for which PTP message configuration | ||
1435 | + * to be obtained | ||
1436 | + * @param ptpPortMode [OUT] Master/Slave/All messages | ||
1437 | + * | ||
1438 | + * | ||
1439 | + * @retval enum ioh_status | ||
1440 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1441 | + * @li IOH_1588_INVALIDPARAM - Invalid parameters passed | ||
1442 | + */ | ||
1443 | +enum ioh_status | ||
1444 | +ioh_1588_ptp_port_config_get(enum ioh1588PTPPort ptpPort, | ||
1445 | + enum ioh1588PTPPortMode *ptpPortMode) | ||
1446 | +{ | ||
1447 | + /* Verify the parameters for proper values */ | ||
1448 | + if ((ptpPort != IOH_1588_GBE_0_1588PTP_PORT) || | ||
1449 | + ((enum ioh1588PTPPortMode *) NULL == ptpPortMode)) { | ||
1450 | + IOH_LOG(KERN_ERR, | ||
1451 | + "ioh_1588_ptp_port_config_get:\ | ||
1452 | + invalid port_mode or port \ | ||
1453 | + returning IOH_1588_INVALIDPARAM\n"); | ||
1454 | + return IOH_1588_INVALIDPARAM; | ||
1455 | + } | ||
1456 | + | ||
1457 | + /* Get the Mode of the PTP Port */ | ||
1458 | + IOH_DEBUG | ||
1459 | + ("ioh_1588_ptp_port_config_get:invoking ioh_1588_port_mode_get\n"); | ||
1460 | + *ptpPortMode = ioh_1588_port_mode_get(ptpPort); | ||
1461 | + | ||
1462 | + return IOH_1588_SUCCESS; | ||
1463 | +} | ||
1464 | + | ||
1465 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1466 | + * @fn enum ioh_status ioh_1588_ptp_rx_poll( | ||
1467 | + * enum ioh1588PTPPort ptpPort, | ||
1468 | + * struct ioh1588PtpMsgData *ptpMsgData) | ||
1469 | + * | ||
1470 | + * @brief Poll the IEEE 1588 Hardware Assist receive side message/time | ||
1471 | + * stamp | ||
1472 | + * detection status for given PTP Port | ||
1473 | + * | ||
1474 | + * @remarks This API will poll for the availability of a time stamp on the | ||
1475 | + * received Sync (in slave mode) or Delay_Req (in master mode) | ||
1476 | + * messages. | ||
1477 | + * The buffer is provided by the caller. | ||
1478 | + * The steps performed in this function are: | ||
1479 | + * - If ptpPort not valid or ptpMsgData is NULL return | ||
1480 | + * IOH_1588_INVALID_PARAM | ||
1481 | + * - Find out whether locked /unlocked mode. | ||
1482 | + * - If locked mode ,check the TS_Channel_Event register for Rx | ||
1483 | + * event | ||
1484 | + * - If locked mode, return NO TIMESTAMP if no Rx event flag is | ||
1485 | + * set. | ||
1486 | + * - Read the time stamp from RECV_Snapshot low, high and | ||
1487 | + * - SourceUUID0 low, high registers | ||
1488 | + * - Clear SourceUUId if the mode is not master/slave and PTP v1 | ||
1489 | + * only. | ||
1490 | + * - Increment RX messages captured statistics counter | ||
1491 | + * - If locked mode ,clear the RX event is TS_Channel_Event | ||
1492 | + * register | ||
1493 | + * | ||
1494 | + * | ||
1495 | + * @param ptpPort [IN] port on which time stamp availability | ||
1496 | + * to be checked | ||
1497 | + * @param ptpMsgData [out] Captured time stamp and other message | ||
1498 | + * information | ||
1499 | + * | ||
1500 | + * @retval enum ioh_status | ||
1501 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1502 | + * @li IOH_1588_INVALIDPARAM - Invalid parameters passed | ||
1503 | + * @li IOH_1588_NOTIMESTAMP - Time stamp not available | ||
1504 | + * @li IOH_1588_FAILED - Internal error occurred | ||
1505 | + */ | ||
1506 | +enum ioh_status | ||
1507 | +ioh_1588_ptp_rx_poll(enum ioh1588PTPPort ptpPort, \ | ||
1508 | + struct ioh1588PtpMsgData *ptpMsgData) | ||
1509 | +{ | ||
1510 | + unsigned long locked_mode = FALSE; | ||
1511 | + | ||
1512 | + enum ioh1588PTPPortMode port_mode = IOH_1588PTP_PORT_MODE_INVALID; | ||
1513 | + enum ioh1588PTPVersion ptpVersion = IOH_1588PTP_VERSION_INVALID; | ||
1514 | + enum ioh1588PTPOperationMode opMode = IOH_1588PTP_OP_MODE_INVALID; | ||
1515 | + | ||
1516 | + /* Verify the parameters for proper values */ | ||
1517 | + if ((ptpPort != IOH_1588_GBE_0_1588PTP_PORT) || | ||
1518 | + ((struct ioh1588PtpMsgData *) NULL == ptpMsgData)) { | ||
1519 | + IOH_LOG(KERN_ERR, | ||
1520 | + "ioh_1588_ptp_rx_poll:invalid port or ptp message \ | ||
1521 | + returning IOH_1588_INVALIDPARAM\n"); | ||
1522 | + return IOH_1588_INVALIDPARAM; | ||
1523 | + } | ||
1524 | + | ||
1525 | + /*Get the PTP version */ | ||
1526 | + ptpVersion = ioh_1588_version_get(); | ||
1527 | + | ||
1528 | + /*check if locked/unlocked mode */ | ||
1529 | + if (ptpVersion == IOH_1588PTP_VERSION_0) { /*PTP v1 only */ | ||
1530 | + /* Get the Mode of the PTP Port if only PTPv1 is supported */ | ||
1531 | + port_mode = ioh_1588_port_mode_get(ptpPort); | ||
1532 | + if (port_mode != IOH_1588PTP_PORT_ANYMODE) | ||
1533 | + locked_mode = TRUE; | ||
1534 | + } else { /*PTP v1 & v2 */ | ||
1535 | + | ||
1536 | + /*get operation mode */ | ||
1537 | + opMode = ioh_1588_op_mode_get(); | ||
1538 | + if ((opMode != IOH_1588PTP_OP_MODE_V1_ALL_MSGS) && | ||
1539 | + (opMode != IOH_1588PTP_OP_MODE_V1_V2_ALL_MSGS)) { | ||
1540 | + locked_mode = TRUE; | ||
1541 | + } | ||
1542 | + } | ||
1543 | + | ||
1544 | + /*if locked mode,check event flag */ | ||
1545 | + if ((TRUE == locked_mode) && (TRUE != ioh_1588_rx_snap_evt())) { | ||
1546 | + IOH_DEBUG | ||
1547 | + ("ioh_1588_ptp_rx_poll:locked mode-event flag not set\n"); | ||
1548 | + IOH_DEBUG("ioh_1588_ptp_rx_poll:NO TIMESTAMP \ | ||
1549 | + returning IOH_1588_NOTIMESTAMP\n"); | ||
1550 | + return IOH_1588_NOTIMESTAMP; | ||
1551 | + } | ||
1552 | + | ||
1553 | + /* Fetch the receive timestamp */ | ||
1554 | + IOH_DEBUG("ioh_1588_ptp_rx_poll:invoking ioh_1588_rx_snap_get\n"); | ||
1555 | + ioh_1588_rx_snap_get(&ptpMsgData->ptpTimeStamp.timeValueLowWord, | ||
1556 | + &ptpMsgData->ptpTimeStamp.timeValueHighWord); | ||
1557 | + | ||
1558 | + IOH_DEBUG | ||
1559 | + ("ioh_1588_ptp_rx_poll:ioh_1588_ptp_rx_poll Snapshot (Hi:Low): \ | ||
1560 | + %lx : %lx\n", | ||
1561 | + ptpMsgData->ptpTimeStamp.timeValueHighWord, | ||
1562 | + ptpMsgData->ptpTimeStamp.timeValueLowWord); | ||
1563 | + | ||
1564 | + /* Fetch the UUID & Seq# of PTP messages in 'Master/Slave Mode' only */ | ||
1565 | + if ((TRUE == locked_mode) && (IOH_1588PTP_VERSION_0 == ptpVersion)) { | ||
1566 | + IOH_DEBUG | ||
1567 | + ("ioh_1588_ptp_rx_poll:invoking ioh_1588_uuid_seqid_get\n"); | ||
1568 | + ioh_1588_uuid_seqid_get(&ptpMsgData->ptpUuid.uuidValueLowWord, | ||
1569 | + &ptpMsgData->ptpUuid. | ||
1570 | + uuidValueHighHalfword, | ||
1571 | + &ptpMsgData->ptpSequenceNumber); | ||
1572 | + } | ||
1573 | + /* Clear-off the UUID & Seq# of all the messages in 'Any Mode' */ | ||
1574 | + else { | ||
1575 | + IOH_DEBUG | ||
1576 | + ("ioh_1588_ptp_rx_poll:port mode is ANYMODE,clearing off \ | ||
1577 | + UUID & SeqNumber\n"); | ||
1578 | + ptpMsgData->ptpUuid.uuidValueLowWord = 0; | ||
1579 | + ptpMsgData->ptpUuid.uuidValueHighHalfword = 0; | ||
1580 | + ptpMsgData->ptpSequenceNumber = 0; | ||
1581 | + } | ||
1582 | + | ||
1583 | + /* Increment receive timestamp counter | ||
1584 | + * Note:In unlocked modes,this will get incremented | ||
1585 | + * for every rx time stamp poll. | ||
1586 | + */ | ||
1587 | + ioh_1588_stats.rxMsgs++; | ||
1588 | + IOH_DEBUG("ioh_1588_ptp_rx_poll:incremented rcv timestamp \ | ||
1589 | + counter=%ld\n", ioh_1588_stats.rxMsgs); | ||
1590 | + | ||
1591 | + /* | ||
1592 | + * Fill-in the PTP message type.This can be done | ||
1593 | + * only when PTP v1 alone is supported and mode | ||
1594 | + * is master/slave.Set the message type as unknown | ||
1595 | + * for all other cases. | ||
1596 | + */ | ||
1597 | + if (ptpVersion == IOH_1588PTP_VERSION_0) { /*PTP v1 only */ | ||
1598 | + switch (port_mode) { | ||
1599 | + case IOH_1588PTP_PORT_MASTER: | ||
1600 | + { | ||
1601 | + IOH_DEBUG | ||
1602 | + ("ioh_1588_ptp_rx_poll:PTP message type=\ | ||
1603 | + IOH_1588PTP_MSGTYPE_DELAYREQ\n"); | ||
1604 | + ptpMsgData->ptpMsgType = | ||
1605 | + IOH_1588PTP_MSGTYPE_DELAYREQ; | ||
1606 | + break; | ||
1607 | + } | ||
1608 | + case IOH_1588PTP_PORT_SLAVE: | ||
1609 | + { | ||
1610 | + IOH_DEBUG | ||
1611 | + ("ioh_1588_ptp_rx_poll:PTP message type=\ | ||
1612 | + IOH_1588PTP_MSGTYPE_SYNC\n"); | ||
1613 | + ptpMsgData->ptpMsgType = | ||
1614 | + IOH_1588PTP_MSGTYPE_SYNC; | ||
1615 | + break; | ||
1616 | + } | ||
1617 | + case IOH_1588PTP_PORT_ANYMODE: | ||
1618 | + { | ||
1619 | + IOH_DEBUG | ||
1620 | + ("ioh_1588_ptp_rx_poll:PTP message type=\ | ||
1621 | + IOH_1588PTP_MSGTYPE_UNKNOWN\n"); | ||
1622 | + ptpMsgData->ptpMsgType = | ||
1623 | + IOH_1588PTP_MSGTYPE_UNKNOWN; | ||
1624 | + break; | ||
1625 | + } | ||
1626 | + default: | ||
1627 | + { | ||
1628 | + IOH_LOG(KERN_ERR, | ||
1629 | + "ioh_1588_ptp_rx_poll(): Invalid Port \ | ||
1630 | + Mode \ | ||
1631 | + returning IOH_1588_FAILED\n"); | ||
1632 | + return IOH_1588_FAILED; | ||
1633 | + } | ||
1634 | + } | ||
1635 | + } else { /*PTP v1 & v2 */ | ||
1636 | + | ||
1637 | + IOH_DEBUG | ||
1638 | + ("ioh_1588_ptp_rx_poll:PTP message type=\ | ||
1639 | + IOH_1588PTP_MSGTYPE_UNKNOWN\n"); | ||
1640 | + ptpMsgData->ptpMsgType = IOH_1588PTP_MSGTYPE_UNKNOWN; | ||
1641 | + } | ||
1642 | + | ||
1643 | + /* If locked mode allow next timestamp to be captured */ | ||
1644 | + if (TRUE == locked_mode) { | ||
1645 | + IOH_DEBUG | ||
1646 | + ("ioh_1588_ptp_rx_poll:invoking \ | ||
1647 | + ioh_1588_rx_snap_evt_clear\n"); | ||
1648 | + ioh_1588_rx_snap_evt_clear(); | ||
1649 | + } | ||
1650 | + | ||
1651 | + return IOH_1588_SUCCESS; | ||
1652 | +} | ||
1653 | + | ||
1654 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1655 | + * @fn enum ioh_status ioh_1588_ptp_tx_poll( | ||
1656 | + * enum ioh1588PTPPort ptpPort, | ||
1657 | + * struct ioh1588PtpMsgData *ptpMsgData) | ||
1658 | + * | ||
1659 | + * @brief Poll the IEEE 1588 Hardware Assist transmit side message/time | ||
1660 | + * stamp | ||
1661 | + * detection status for given PTP Port | ||
1662 | + * | ||
1663 | + * @remarks This API will poll for the availability of a time stamp on the | ||
1664 | + * transmit side Sync (in master mode) or Delay_Req (in slave mode) | ||
1665 | + * messages. | ||
1666 | + * The buffer is provided by the caller. | ||
1667 | + * The main tasks performed by this function are: | ||
1668 | + * - If ptpPort not valid or ptpMsgData is NULL | ||
1669 | + * return IOH_1588_INVALID_PARAM | ||
1670 | + * - Find out whether locked /unlocked mode. | ||
1671 | + * - If locked mode ,check the TS_Channel_Event register for Tx | ||
1672 | + * event | ||
1673 | + * - If locked mode, return NO TIMESTAMP if no Tx event flag is | ||
1674 | + * set. | ||
1675 | + * - Read the time stamp from XMIT_Snapshot low, high registers | ||
1676 | + * - Increment TX messages captured statistics counter | ||
1677 | + * - If locked mode, clear the TX event is TS_Channel_Event | ||
1678 | + * register | ||
1679 | + * | ||
1680 | + * | ||
1681 | + * @param ptpPort [IN] port on which time stamp availability to be | ||
1682 | + * checked | ||
1683 | + * @param ptpMsgData [OUT] Captured time stamp and other message | ||
1684 | + * information | ||
1685 | + * | ||
1686 | + * @retval enum ioh_status | ||
1687 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1688 | + * @li IOH_1588_INVALIDPARAM - Invalid parameters passed | ||
1689 | + * @li IOH_1588_NOTIMESTAMP - Time stamp not available | ||
1690 | + * @li IOH_1588_FAILED - Internal error occurred | ||
1691 | + */ | ||
1692 | +enum ioh_status | ||
1693 | +ioh_1588_ptp_tx_poll(enum ioh1588PTPPort ptpPort, \ | ||
1694 | + struct ioh1588PtpMsgData *ptpMsgData) | ||
1695 | +{ | ||
1696 | + unsigned long locked_mode = FALSE; | ||
1697 | + | ||
1698 | + enum ioh1588PTPPortMode port_mode = IOH_1588PTP_PORT_MODE_INVALID; | ||
1699 | + enum ioh1588PTPVersion ptpVersion = IOH_1588PTP_VERSION_INVALID; | ||
1700 | + enum ioh1588PTPOperationMode opMode = IOH_1588PTP_OP_MODE_INVALID; | ||
1701 | + | ||
1702 | + /* Verify the parameters for proper values */ | ||
1703 | + if ((ptpPort != IOH_1588_GBE_0_1588PTP_PORT) || | ||
1704 | + ((struct ioh1588PtpMsgData *) NULL == ptpMsgData)) { | ||
1705 | + IOH_LOG(KERN_ERR, | ||
1706 | + "ioh_1588_ptp_tx_poll:invalid port or ptp message \ | ||
1707 | + returning IOH_1588_INVALIDPARAM\n"); | ||
1708 | + return IOH_1588_INVALIDPARAM; | ||
1709 | + } | ||
1710 | + | ||
1711 | + /*Get the PTP version */ | ||
1712 | + ptpVersion = ioh_1588_version_get(); | ||
1713 | + | ||
1714 | + /*check if locked/unlocked mode */ | ||
1715 | + if (ptpVersion == IOH_1588PTP_VERSION_0) { /*PTP v1 only */ | ||
1716 | + /* Get the Mode of the PTP Port if only PTPv1 is supported */ | ||
1717 | + port_mode = ioh_1588_port_mode_get(ptpPort); | ||
1718 | + if (port_mode != IOH_1588PTP_PORT_ANYMODE) | ||
1719 | + locked_mode = TRUE; | ||
1720 | + } else { /*PTP v1 & v2 */ | ||
1721 | + | ||
1722 | + /*get operation mode */ | ||
1723 | + opMode = ioh_1588_op_mode_get(); | ||
1724 | + if ((opMode != IOH_1588PTP_OP_MODE_V1_ALL_MSGS) && | ||
1725 | + (opMode != IOH_1588PTP_OP_MODE_V1_V2_ALL_MSGS)) { | ||
1726 | + locked_mode = TRUE; | ||
1727 | + } | ||
1728 | + } | ||
1729 | + | ||
1730 | + /*if locked mode,check event flag */ | ||
1731 | + if ((TRUE == locked_mode) && (TRUE != ioh_1588_tx_snap_evt())) { | ||
1732 | + IOH_DEBUG | ||
1733 | + ("ioh_1588_ptp_tx_poll:locked mode-event flag not set\n"); | ||
1734 | + IOH_DEBUG | ||
1735 | + ("ioh_1588_ptp_tx_poll:ioh_1588_ptp_tx_poll NO TIMESTAMP \ | ||
1736 | + returning IOH_1588_NOTIMESTAMP\n"); | ||
1737 | + return IOH_1588_NOTIMESTAMP; | ||
1738 | + } | ||
1739 | + | ||
1740 | + /* read time stamp registers */ | ||
1741 | + ioh_1588_tx_snap_get(&ptpMsgData->ptpTimeStamp.timeValueLowWord, | ||
1742 | + &ptpMsgData->ptpTimeStamp.timeValueHighWord); | ||
1743 | + | ||
1744 | + IOH_DEBUG | ||
1745 | + ("ioh_1588_ptp_tx_poll:ioh_1588_ptp_tx_poll Snapshot (Hi:Low): \ | ||
1746 | + %lx : %lx\n", | ||
1747 | + ptpMsgData->ptpTimeStamp.timeValueHighWord, | ||
1748 | + ptpMsgData->ptpTimeStamp.timeValueLowWord); | ||
1749 | + /* | ||
1750 | + * Fill the UUID and Seq# with invalid values (zeros) | ||
1751 | + * since they are not relevant for transmit timestamp | ||
1752 | + */ | ||
1753 | + ptpMsgData->ptpUuid.uuidValueLowWord = 0; | ||
1754 | + ptpMsgData->ptpUuid.uuidValueHighHalfword = 0; | ||
1755 | + ptpMsgData->ptpSequenceNumber = 0; | ||
1756 | + | ||
1757 | + /* | ||
1758 | + * Increment transmit timestamp counter | ||
1759 | + * Note:In unlocked modes,this will get incremented | ||
1760 | + * for every tx time stamp poll | ||
1761 | + */ | ||
1762 | + ioh_1588_stats.txMsgs++; | ||
1763 | + IOH_DEBUG("ioh_1588_ptp_tx_poll:incremented tx timestamp counter=%ld\n", | ||
1764 | + ioh_1588_stats.txMsgs); | ||
1765 | + | ||
1766 | + /* | ||
1767 | + * Fill-in the PTP message type.This can be done | ||
1768 | + * only when PTP v1 alone is supported and mode | ||
1769 | + * is master/slave.Set the message type as unknown | ||
1770 | + * for all other cases. | ||
1771 | + */ | ||
1772 | + if (ptpVersion == IOH_1588PTP_VERSION_0) { /*PTP v1 only */ | ||
1773 | + switch (port_mode) { | ||
1774 | + case IOH_1588PTP_PORT_MASTER: | ||
1775 | + { | ||
1776 | + IOH_DEBUG | ||
1777 | + ("ioh_1588_ptp_tx_poll:PTP message type=\ | ||
1778 | + IOH_1588PTP_MSGTYPE_SYNC\n"); | ||
1779 | + ptpMsgData->ptpMsgType = | ||
1780 | + IOH_1588PTP_MSGTYPE_SYNC; | ||
1781 | + break; | ||
1782 | + } | ||
1783 | + case IOH_1588PTP_PORT_SLAVE: | ||
1784 | + { | ||
1785 | + IOH_DEBUG | ||
1786 | + ("ioh_1588_ptp_tx_poll:PTP message type=\ | ||
1787 | + IOH_1588PTP_MSGTYPE_DELAYREQ\n"); | ||
1788 | + ptpMsgData->ptpMsgType = | ||
1789 | + IOH_1588PTP_MSGTYPE_DELAYREQ; | ||
1790 | + break; | ||
1791 | + } | ||
1792 | + case IOH_1588PTP_PORT_ANYMODE: | ||
1793 | + { | ||
1794 | + IOH_DEBUG | ||
1795 | + ("ioh_1588_ptp_tx_poll:PTP message type=\ | ||
1796 | + IOH_1588PTP_MSGTYPE_UNKNOWN\n"); | ||
1797 | + ptpMsgData->ptpMsgType = | ||
1798 | + IOH_1588PTP_MSGTYPE_UNKNOWN; | ||
1799 | + break; | ||
1800 | + } | ||
1801 | + default: | ||
1802 | + { | ||
1803 | + IOH_LOG(KERN_ERR, | ||
1804 | + "ioh_1588_ptp_tx_poll(): \ | ||
1805 | + Invalid Port Mode \ | ||
1806 | + returning IOH_1588_FAILED\n"); | ||
1807 | + return IOH_1588_FAILED; | ||
1808 | + } | ||
1809 | + } | ||
1810 | + } else { /*PTP v1 & v2 */ | ||
1811 | + | ||
1812 | + IOH_DEBUG | ||
1813 | + ("ioh_1588_ptp_tx_poll:PTP message type=\ | ||
1814 | + IOH_1588PTP_MSGTYPE_UNKNOWN\n"); | ||
1815 | + ptpMsgData->ptpMsgType = IOH_1588PTP_MSGTYPE_UNKNOWN; | ||
1816 | + } | ||
1817 | + | ||
1818 | + /* If locked mode allow next timestamp to be captured */ | ||
1819 | + if (locked_mode) { | ||
1820 | + IOH_DEBUG | ||
1821 | + ("ioh_1588_ptp_tx_poll:invoking ioh_1588_tx_snap_evt_clear\n"); | ||
1822 | + ioh_1588_tx_snap_evt_clear(); | ||
1823 | + } | ||
1824 | + | ||
1825 | + return IOH_1588_SUCCESS; | ||
1826 | +} | ||
1827 | + | ||
1828 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1829 | + * @fn enum ioh_status ioh_1588_system_time_set( | ||
1830 | + * struct ioh1588TimeValue systemTime) | ||
1831 | + * | ||
1832 | + * @brief This API sets the system time to given value | ||
1833 | + * @remarks Sets the System Time in the IEEE 1588 hardware assist block. | ||
1834 | + * | ||
1835 | + * @param systemTime [IN] value to set the system time to | ||
1836 | + * | ||
1837 | + * @retval enum ioh_status | ||
1838 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1839 | + */ | ||
1840 | +enum ioh_status ioh_1588_system_time_set(struct ioh1588TimeValue systemTime) | ||
1841 | +{ | ||
1842 | + unsigned long old_fsv = 0; | ||
1843 | + | ||
1844 | + /* Retrieve old Frequency Scaling Value */ | ||
1845 | + IOH_DEBUG("ioh_1588_system_time_set:invoking ioh_1588_addend_get\n"); | ||
1846 | + ioh_1588_addend_get(&old_fsv); | ||
1847 | + IOH_DEBUG("ioh_1588_system_time_set:existing freq scaling value=%lx\n", | ||
1848 | + old_fsv); | ||
1849 | + | ||
1850 | + /* | ||
1851 | + * Set the Frequency Scaling Value to zero (0) so that | ||
1852 | + * System Time doesn't get incremented while it is being written to | ||
1853 | + */ | ||
1854 | + IOH_DEBUG("ioh_1588_system_time_set:invoking ioh_1588_addend_set \ | ||
1855 | + to set frequncy scaling value to 0\n"); | ||
1856 | + ioh_1588_addend_set(0); | ||
1857 | + | ||
1858 | + /* Update System Time with user specified values */ | ||
1859 | + IOH_DEBUG("ioh_1588_system_time_set:invoking \ | ||
1860 | + ioh_1588_ioh_1588_sys_snap_set \ | ||
1861 | + with values low=%lx,high=%lx\n", | ||
1862 | + systemTime.timeValueLowWord, systemTime.timeValueHighWord); | ||
1863 | + ioh_1588_sys_snap_set(systemTime.timeValueLowWord, | ||
1864 | + systemTime.timeValueHighWord); | ||
1865 | + | ||
1866 | + /* | ||
1867 | + * Let the hardware assist re-evaluate the target time reached | ||
1868 | + * condition based on the new system time | ||
1869 | + */ | ||
1870 | + IOH_DEBUG("ioh_1588_system_time_set:invoking ioh_1588_ttm_evt_clear\n"); | ||
1871 | + ioh_1588_ttm_evt_clear(); | ||
1872 | + | ||
1873 | + /* | ||
1874 | + * Restore old Frequency Scaling Value so that System Time | ||
1875 | + * can be incremented | ||
1876 | + */ | ||
1877 | + IOH_DEBUG("ioh_1588_system_time_set:invoking ioh_1588_addend_set \ | ||
1878 | + to restore freq scaling value\n"); | ||
1879 | + ioh_1588_addend_set(old_fsv); | ||
1880 | + | ||
1881 | + IOH_DEBUG("ioh_1588_system_time_set:returning IOH_1588_SUCCESS\n"); | ||
1882 | + return IOH_1588_SUCCESS; | ||
1883 | +} | ||
1884 | + | ||
1885 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1886 | + * @fn enum ioh_status ioh_1588_system_time_get( | ||
1887 | + * struct ioh1588TimeValue *systemTime) | ||
1888 | + * | ||
1889 | + * @brief Gets the System Time from the IEEE 1588 hardware assist block | ||
1890 | + * @remarks This API gets the System time. | ||
1891 | + * The main steps followed in this function are: | ||
1892 | + * - Return IOH_1588_INVALIDPARAM if argument passed is NULL | ||
1893 | + * - Return the current system time by reading the SystemTime low, | ||
1894 | + * high registers | ||
1895 | + * | ||
1896 | + * | ||
1897 | + * @param systemTime [OUT] - Address to which system time is to be | ||
1898 | + * returned | ||
1899 | + * | ||
1900 | + * @return enum ioh_status | ||
1901 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1902 | + * @li IOH_1588_INVALIDPARAM - Invalid address passed | ||
1903 | + */ | ||
1904 | +enum ioh_status ioh_1588_system_time_get(struct ioh1588TimeValue *systemTime) | ||
1905 | +{ | ||
1906 | + /* Verify the parameter */ | ||
1907 | + if ((struct ioh1588TimeValue *) NULL == systemTime) { | ||
1908 | + IOH_LOG(KERN_ERR, "ioh_1588_system_time_get:invalid parameter \ | ||
1909 | + returning IOH_1588_INVALIDPARAM\n"); | ||
1910 | + return IOH_1588_INVALIDPARAM; | ||
1911 | + } | ||
1912 | + | ||
1913 | + /* Fetch System Time */ | ||
1914 | + ioh_1588_sys_snap_get(&systemTime->timeValueLowWord, | ||
1915 | + &systemTime->timeValueHighWord); | ||
1916 | + | ||
1917 | + IOH_DEBUG("ioh_1588_system_time_get:invoked \ | ||
1918 | + ioh_1588_ioh_1588_sys_snap_get \ | ||
1919 | + system time:low=%lx,high=%lx\n", | ||
1920 | + systemTime->timeValueLowWord, systemTime->timeValueHighWord); | ||
1921 | + IOH_DEBUG("ioh_1588_system_time_get returning IOH_1588_SUCCESS\n"); | ||
1922 | + return IOH_1588_SUCCESS; | ||
1923 | +} | ||
1924 | + | ||
1925 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1926 | + * @fn enum ioh_status ioh_1588_tick_rate_set(unsigned long tickRate) | ||
1927 | + * | ||
1928 | + * @brief Sets the Frequency Scaling Value in the IEEE 1588 hardware | ||
1929 | + * assist block | ||
1930 | + * | ||
1931 | + * @remarks This API sets the Tick Rate (Frequency Scaling Value) in the | ||
1932 | + * IEEE 1588 block. This value determines the progress at which | ||
1933 | + * the System time advances. | ||
1934 | + * Note: For the A1 hardware sample, the addend register value | ||
1935 | + * configured in the hardware | ||
1936 | + * is calculated as follows: | ||
1937 | + * Addend register value = Logical right shift tickRate by 1 and | ||
1938 | + * set MSB to 1 | ||
1939 | + * | ||
1940 | + * @param tickRate [IN] Frequency scaling value | ||
1941 | + * | ||
1942 | + * @retval enum ioh_status | ||
1943 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1944 | + */ | ||
1945 | +enum ioh_status ioh_1588_tick_rate_set(unsigned long tickRate) | ||
1946 | +{ | ||
1947 | + /* Update the Frequency Scaling Value */ | ||
1948 | +#ifdef IOH_IEEE1588_A1_SAMPLE_BUG | ||
1949 | + /*back up tick rate provided by app */ | ||
1950 | + gTickRateApp = tickRate; | ||
1951 | + /*calculate actual tick rate for device */ | ||
1952 | + IOH_DEBUG("ioh_1588_tick_rate_set:tick rate [app]=%lx\n", tickRate); | ||
1953 | + tickRate = ((tickRate >> 1) | 0x80000000); | ||
1954 | + IOH_DEBUG("ioh_1588_tick_rate_set:tick rate [dev]=%lx\n", tickRate); | ||
1955 | +#endif | ||
1956 | + IOH_DEBUG("ioh_1588_tick_rate_set:invoking ioh_1588_addend_set \ | ||
1957 | + with tick rate=%lx\n", tickRate); | ||
1958 | + ioh_1588_addend_set(tickRate); | ||
1959 | + | ||
1960 | + return IOH_1588_SUCCESS; | ||
1961 | +} | ||
1962 | + | ||
1963 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
1964 | + * @fn enum ioh_status ioh_1588_tick_rate_get(unsigned long *tickRate) | ||
1965 | + * | ||
1966 | + * @brief Gets the Frequency Scaling Value from the IEEE 1588 hardware | ||
1967 | + * assist block | ||
1968 | + * | ||
1969 | + * @remarks This API gets the Tick Rate (Frequency Scaling Value) used in | ||
1970 | + * the IEEE 1588 block. | ||
1971 | + * This value determines the progress at which the System time | ||
1972 | + * advances. | ||
1973 | + * The main steps followed in this function are: | ||
1974 | + * - Return IOH_1588_INVALIDPARAM if argument passed is NULL | ||
1975 | + * - Return the content of Addend register | ||
1976 | + * | ||
1977 | + * | ||
1978 | + * @param tickRate [IN] - Address where current Frequency scaling value is | ||
1979 | + * returned | ||
1980 | + * | ||
1981 | + * @return enum ioh_status | ||
1982 | + * @li IOH_1588_SUCCESS - Operation successful | ||
1983 | + * @li IOH_1588_INVALIDPARM - Invalid address passed | ||
1984 | + */ | ||
1985 | +enum ioh_status ioh_1588_tick_rate_get(unsigned long *tickRate) | ||
1986 | +{ | ||
1987 | + /* Verify the parameter */ | ||
1988 | + if ((unsigned long *)NULL == tickRate) { | ||
1989 | + IOH_LOG(KERN_ERR, "ioh_1588_tick_rate_get:invalid tick rate\ | ||
1990 | + returning IOH_1588_INVALIDPARAM\n"); | ||
1991 | + return IOH_1588_INVALIDPARAM; | ||
1992 | + } | ||
1993 | +#ifdef IOH_IEEE1588_A1_SAMPLE_BUG | ||
1994 | + /* Retrieve Frequency Scaling Value stored in software buffer */ | ||
1995 | + *tickRate = gTickRateApp; | ||
1996 | +#else | ||
1997 | + /* Retrieve Current Frequency Scaling Value */ | ||
1998 | + ioh_1588_addend_get(tickRate); | ||
1999 | +#endif | ||
2000 | + IOH_DEBUG("ioh_1588_tick_rate_get:invoked ioh_1588_addend_get\ | ||
2001 | + the tick rate=%lx\n", *tickRate); | ||
2002 | + | ||
2003 | + return IOH_1588_SUCCESS; | ||
2004 | +} | ||
2005 | + | ||
2006 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2007 | + * @fn enum ioh_status ioh_1588_target_time_interrupt_enable( | ||
2008 | + * ioh1588TargetTimeCallback callBack) | ||
2009 | + * | ||
2010 | + * @brief Enable the target time reached/exceeded system time interrupt | ||
2011 | + * | ||
2012 | + * @remarks This API enables the interrupt that occurs when the System time | ||
2013 | + * reaches the Target time set in the IEEE 1588 hardware assist | ||
2014 | + * block. | ||
2015 | + * The main steps followed in this function are: | ||
2016 | + * - Return IOH_1588_INVALIDPARAM if argument passed is NULL | ||
2017 | + * - Modify Time Sync Control Register to enable target time | ||
2018 | + * interrupt | ||
2019 | + * - Set the handler to callback function provided | ||
2020 | + * | ||
2021 | + * | ||
2022 | + * @param callBack [IN] - Routine to be invoked when target time reached | ||
2023 | + * interrupt occurs | ||
2024 | + * | ||
2025 | + * @retval enum ioh_status | ||
2026 | + * @li IOH_1588_SUCCESS - Operation successful | ||
2027 | + * @li IOH_1588_INVALIDPARAM - Null parameter passed for callback | ||
2028 | + */ | ||
2029 | +enum ioh_status | ||
2030 | +ioh_1588_target_time_interrupt_enable(ioh1588TargetTimeCallback callBack) | ||
2031 | +{ | ||
2032 | + /* Verify the parameter */ | ||
2033 | + if ((ioh1588TargetTimeCallback) NULL == callBack) { | ||
2034 | + IOH_LOG(KERN_ERR, "ioh_1588_target_time_interrupt_enable\ | ||
2035 | + invalid callback;returning IOH_1588_INVALIDPARAM\n"); | ||
2036 | + return IOH_1588_INVALIDPARAM; | ||
2037 | + } | ||
2038 | + | ||
2039 | + /* Register the Callback */ | ||
2040 | + ioh_tt_cbptr = callBack; | ||
2041 | + | ||
2042 | + /* Set target time interrupt mask */ | ||
2043 | + IOH_DEBUG("ioh_1588_target_time_interrupt_enable:invoking\ | ||
2044 | + ioh_1588_ttm_imask_set\n"); | ||
2045 | + ioh_1588_ttm_imask_set(); | ||
2046 | + | ||
2047 | + return IOH_1588_SUCCESS; | ||
2048 | +} | ||
2049 | + | ||
2050 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2051 | + * @fn enum ioh_status ioh_1588_target_time_interrupt_disable(void) | ||
2052 | + * | ||
2053 | + * @brief Disable the target time reached/exceeded system time interrupt | ||
2054 | + * | ||
2055 | + * @remarks This API disables the interrupt that occurs when the System time | ||
2056 | + * reaches the Target time set in the IEEE 1588 hardware assist | ||
2057 | + * block. | ||
2058 | + * The main steps followed in this function are: | ||
2059 | + * - Modify Time Sync Control Register to disable target time | ||
2060 | + * interrupt | ||
2061 | + * - Clear the callback handler | ||
2062 | + * | ||
2063 | + * @param None | ||
2064 | + * | ||
2065 | + * @retval enum ioh_status | ||
2066 | + * @li IOH_1588_SUCCESS - Operation successful | ||
2067 | + */ | ||
2068 | +enum ioh_status ioh_1588_target_time_interrupt_disable(void) | ||
2069 | +{ | ||
2070 | + /* Clear target time interrupt mask */ | ||
2071 | + IOH_DEBUG("ioh_1588_target_time_interrupt_disable:invoking \ | ||
2072 | + ioh_1588_ttm_imask_clear\n"); | ||
2073 | + ioh_1588_ttm_imask_clear(); | ||
2074 | + | ||
2075 | + /* Unregister the Callback */ | ||
2076 | + ioh_tt_cbptr = (ioh1588TargetTimeCallback) NULL; | ||
2077 | + | ||
2078 | + return IOH_1588_SUCCESS; | ||
2079 | +} | ||
2080 | + | ||
2081 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2082 | + * @fn enum ioh_status ioh_1588_target_time_poll( | ||
2083 | + * unsigned long *ttmPollFlag, struct ioh1588TimeValue *targetTime) | ||
2084 | + * | ||
2085 | + * @brief Poll to verify whether the System time is greater or equal | ||
2086 | + * to the Target time in the IEEE 1588 hardware assist block. | ||
2087 | + * | ||
2088 | + * @remarks The main steps followed in this function are: | ||
2089 | + * - Validate the parameters and return IOH_1588_INVALIDPARAM, if | ||
2090 | + * not valid | ||
2091 | + * - If callback function registered, return status | ||
2092 | + * IOH_1588_INTERRUPTMODEINUSE | ||
2093 | + * - Read the TS_Event register to check for the presence of valid | ||
2094 | + * snapshot | ||
2095 | + * - Read the TargetTimeSnap low, high registers | ||
2096 | + * - Clear the event from TS_Event register | ||
2097 | + * | ||
2098 | + * | ||
2099 | + * @param ttmPollFlag [OUT] TRUE if target time has reached system | ||
2100 | + * time | ||
2101 | + * FALSE if target time has not reached | ||
2102 | + * system time | ||
2103 | + * @param targetTime [OUT] Snap shot of target time captured | ||
2104 | + * | ||
2105 | + * @retval enum ioh_status | ||
2106 | + * @li IOH_1588_SUCCESS - Operation successful | ||
2107 | + * @li IOH_1588_INVALIDPARAM - Null parameter passed | ||
2108 | + * @li IOH_1588_INTERRUPTMODEINUSE - Interrupt mode is in use | ||
2109 | + */ | ||
2110 | +enum ioh_status | ||
2111 | +ioh_1588_target_time_poll(unsigned long *ttmPollFlag, | ||
2112 | + struct ioh1588TimeValue *targetTime) | ||
2113 | +{ | ||
2114 | + /* Verify the parameters */ | ||
2115 | + if (((unsigned long *)NULL == ttmPollFlag) || | ||
2116 | + ((struct ioh1588TimeValue *) NULL == targetTime)) { | ||
2117 | + IOH_LOG(KERN_ERR, "ioh_1588_target_time_poll: invalid param\ | ||
2118 | + returning IOH_1588_INVALIDPARAM\n"); | ||
2119 | + return IOH_1588_INVALIDPARAM; | ||
2120 | + } | ||
2121 | + | ||
2122 | + /* Is interrupt mode of processing is enabled? */ | ||
2123 | + if ((ioh1588TargetTimeCallback) NULL != ioh_tt_cbptr) { | ||
2124 | + IOH_LOG(KERN_ERR, | ||
2125 | + "ioh_1588_target_time_poll:returning \ | ||
2126 | + IOH_1588_INTERRUPTMODEINUSE\n"); | ||
2127 | + return IOH_1588_INTERRUPTMODEINUSE; | ||
2128 | + } | ||
2129 | + | ||
2130 | + /* Is the System Time reached or exceeded Target Time? */ | ||
2131 | + *ttmPollFlag = ioh_1588_ttm_evt_get(); | ||
2132 | + if (FALSE == *ttmPollFlag) { | ||
2133 | + IOH_DEBUG | ||
2134 | + ("ioh_1588_target_time_poll:target time not reached\n"); | ||
2135 | + /* Target Time not to be returned yet */ | ||
2136 | + targetTime->timeValueLowWord = 0; | ||
2137 | + targetTime->timeValueHighWord = 0; | ||
2138 | + | ||
2139 | + return IOH_1588_SUCCESS; | ||
2140 | + } | ||
2141 | + | ||
2142 | + IOH_DEBUG("ioh_1588_target_time_poll:target time reached\n"); | ||
2143 | + /* Get the Target Time */ | ||
2144 | + ioh_1588_tgt_snap_get(&targetTime->timeValueLowWord, | ||
2145 | + &targetTime->timeValueHighWord); | ||
2146 | + | ||
2147 | + IOH_DEBUG("ioh_1588_target_time_poll:target time:low=%lx high=%lx\n", | ||
2148 | + targetTime->timeValueLowWord, targetTime->timeValueHighWord); | ||
2149 | + | ||
2150 | + IOH_DEBUG | ||
2151 | + ("ioh_1588_target_time_poll:invoking ioh_1588_ttm_evt_clear\n"); | ||
2152 | + /* Clear the target time reached condition (ttipend bit) */ | ||
2153 | + ioh_1588_ttm_evt_clear(); | ||
2154 | + | ||
2155 | + return IOH_1588_SUCCESS; | ||
2156 | +} | ||
2157 | + | ||
2158 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2159 | + * @fn enum ioh_status ioh_1588_target_time_set( | ||
2160 | + * struct ioh1588TimeValue targetTime) | ||
2161 | + * | ||
2162 | + * @brief Sets the Target Time in the IEEE 1588 hardware assist block | ||
2163 | + * | ||
2164 | + * @remarks This API will set the Target Time to a given value. | ||
2165 | + * | ||
2166 | + * @param targetTime [IN] - Target time to set | ||
2167 | + * | ||
2168 | + * | ||
2169 | + * @retval enum ioh_status | ||
2170 | + * @li IOH_1588_SUCCESS - Operation successful | ||
2171 | + */ | ||
2172 | +enum ioh_status ioh_1588_target_time_set(struct ioh1588TimeValue targetTime) | ||
2173 | +{ | ||
2174 | + unsigned long old_mask = FALSE; | ||
2175 | + | ||
2176 | + /* Retrieve existing target time interrupt mask value */ | ||
2177 | + old_mask = ioh_1588_ttm_imask_get(); | ||
2178 | + IOH_DEBUG("ioh_1588_target_time_set:target time interrupt mask=%lx\n", | ||
2179 | + old_mask); | ||
2180 | + | ||
2181 | + /* | ||
2182 | + * Clear the target time interrupt mask so that the interrupt will not | ||
2183 | + * come | ||
2184 | + * during the time we manipulate the registers. | ||
2185 | + */ | ||
2186 | + IOH_DEBUG("ioh_1588_target_time_set:invoking ioh_1588_ttm_imask_clear\ | ||
2187 | + to clear the target time interrupt mask\n"); | ||
2188 | + ioh_1588_ttm_imask_clear(); | ||
2189 | + | ||
2190 | + IOH_DEBUG("ioh_1588_target_time_set:invoking ioh_1588_tgt_snap_set \ | ||
2191 | + with values:low=%lx,high=%lx\n", \ | ||
2192 | + targetTime.timeValueLowWord, targetTime.timeValueHighWord); | ||
2193 | + /* Update Target Time with user specified values */ | ||
2194 | + ioh_1588_tgt_snap_set(targetTime.timeValueLowWord, | ||
2195 | + targetTime.timeValueHighWord); | ||
2196 | + | ||
2197 | + /* | ||
2198 | + * Let the hardware assist re-evaluate the target time reached | ||
2199 | + * condition based on the new target time | ||
2200 | + */ | ||
2201 | + IOH_DEBUG("ioh_1588_target_time_set:invoking ioh_1588_ttm_evt_clear\n"); | ||
2202 | + ioh_1588_ttm_evt_clear(); | ||
2203 | + | ||
2204 | + /* Restore the preserved target time interrupt mask value */ | ||
2205 | + if (TRUE == old_mask) { | ||
2206 | + IOH_DEBUG | ||
2207 | + ("ioh_1588_target_time_set:invoking \ | ||
2208 | + ioh_1588_ttm_imask_set\n"); | ||
2209 | + ioh_1588_ttm_imask_set(); | ||
2210 | + } | ||
2211 | + | ||
2212 | + IOH_DEBUG("ioh_1588_target_time_set:returning IOH_1588_SUCCESS\n"); | ||
2213 | + return IOH_1588_SUCCESS; | ||
2214 | +} | ||
2215 | + | ||
2216 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2217 | + * @fn enum ioh_status ioh_1588_target_time_get( | ||
2218 | + * struct ioh1588TimeValue *targetTime) | ||
2219 | + * | ||
2220 | + * @brief Gets the Target Time in the IEEE 1588 hardware assist block | ||
2221 | + * | ||
2222 | + * @remarks This API will get the Target Time from IEEE 1588 block | ||
2223 | + * - Return IOH_1588_INVALIDPARAM if argument passed is NULL | ||
2224 | + * - Read and return the content of TargetTime low, high registers | ||
2225 | + * | ||
2226 | + * | ||
2227 | + * @param targetTime [IN] - Address to which target time is to be returned | ||
2228 | + * | ||
2229 | + * | ||
2230 | + * @retval enum ioh_status | ||
2231 | + * @li IOH_1588_SUCCESS - Operation successful | ||
2232 | + * @li IOH_1588_INVALIDPARAM - Null parameter passed | ||
2233 | + */ | ||
2234 | +enum ioh_status ioh_1588_target_time_get(struct ioh1588TimeValue *targetTime) | ||
2235 | +{ | ||
2236 | + /* Verify the parameter */ | ||
2237 | + if ((struct ioh1588TimeValue *) NULL == targetTime) { | ||
2238 | + IOH_DEBUG("ioh_1588_target_time_get:invalid param \ | ||
2239 | + returning IOH_1588_INVALIDPARAM\n"); | ||
2240 | + return IOH_1588_INVALIDPARAM; | ||
2241 | + } | ||
2242 | + | ||
2243 | + /* Get Target Time */ | ||
2244 | + ioh_1588_tgt_snap_get(&targetTime->timeValueLowWord, | ||
2245 | + &targetTime->timeValueHighWord); | ||
2246 | + IOH_DEBUG("ioh_1588_target_time_get:invoked ioh_1588_tgt_snap_get \ | ||
2247 | + target time:low=%lx,high:%lx\n", \ | ||
2248 | + targetTime->timeValueLowWord, targetTime->timeValueHighWord); | ||
2249 | + | ||
2250 | + return IOH_1588_SUCCESS; | ||
2251 | +} | ||
2252 | + | ||
2253 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2254 | + * @fn enum ioh_status ioh_1588_aux_time_interrupt_enable( | ||
2255 | + * enum ioh1588AuxMode auxMode,ioh1588AuxTimeCallback callBack) | ||
2256 | + * | ||
2257 | + * @brief Enables the interrupt for the Auxiliary Master/Slave mode for | ||
2258 | + * Time | ||
2259 | + * Stamp in the IEEE 1588 hardware assist block | ||
2260 | + * | ||
2261 | + * @remarks This API will enable the Auxiliary Master/Slave | ||
2262 | + * Time stamp Interrupt. The main steps followed in | ||
2263 | + * this function are: | ||
2264 | + * - Return IOH_1588_INVALIDPARAM if argument passed is NULL | ||
2265 | + * - Modify the Time Sync Controller register to enable the | ||
2266 | + * interrupt | ||
2267 | + * - Set the callback routine | ||
2268 | + * | ||
2269 | + * | ||
2270 | + * @param auxMode [IN] - Auxiliary slave or master mode | ||
2271 | + * @param callBack [IN] - Callback to be invoked when interrupt | ||
2272 | + * fires | ||
2273 | + * | ||
2274 | + * | ||
2275 | + * @retval enum ioh_status | ||
2276 | + * @li IOH_1588_SUCCESS - Operation successful | ||
2277 | + * @li IOH_1588_INVALIDPARAM - Null parameter passed | ||
2278 | + */ | ||
2279 | +enum ioh_status | ||
2280 | +ioh_1588_aux_time_interrupt_enable(enum ioh1588AuxMode auxMode, | ||
2281 | + ioh1588AuxTimeCallback callBack) | ||
2282 | +{ | ||
2283 | + /* Verify the parameters */ | ||
2284 | + if ((IOH_1588_AUXMODE_INVALID <= auxMode) || | ||
2285 | + ((ioh1588AuxTimeCallback) NULL == callBack)) { | ||
2286 | + IOH_DEBUG("ioh_1588_aux_time_interrupt_enable:invalid param \ | ||
2287 | + returning IOH_1588_INVALIDPARAM\n"); | ||
2288 | + return IOH_1588_INVALIDPARAM; | ||
2289 | + } | ||
2290 | + | ||
2291 | + /* Register the Callback and SET the amm/asm bits on */ | ||
2292 | + if (IOH_1588_AUXMODE_MASTER == auxMode) { | ||
2293 | + IOH_DEBUG | ||
2294 | + ("ioh_1588_aux_time_interrupt_enable:IOH_1588_AUXMODE_MASTER \ | ||
2295 | + invoking ioh_1588_amms_imask_set\n"); | ||
2296 | + ioh_am_cbptr = callBack; | ||
2297 | + ioh_1588_amms_imask_set(); | ||
2298 | + | ||
2299 | + } else { | ||
2300 | + IOH_DEBUG | ||
2301 | + ("ioh_1588_aux_time_interrupt_enable:IOH_1588_AUXMODE_SLAVE \ | ||
2302 | + invoking ioh_1588_asms_imask_set\n"); | ||
2303 | + ioh_as_cbptr = callBack; | ||
2304 | + ioh_1588_asms_imask_set(); | ||
2305 | + } | ||
2306 | + | ||
2307 | + return IOH_1588_SUCCESS; | ||
2308 | +} | ||
2309 | + | ||
2310 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2311 | + * @fn enum ioh_status ioh_1588_aux_time_interrupt_disable( | ||
2312 | + * enum ioh1588AuxMode auxMode) | ||
2313 | + * | ||
2314 | + * @brief Disables the interrupt for the Auxiliary Master/Slave mode for | ||
2315 | + * Time | ||
2316 | + * Stamp in the IEEE 1588 hardware assist block | ||
2317 | + * | ||
2318 | + * @remarks This API will disable the Auxiliary Master/Slave | ||
2319 | + * Time stamp Interrupt. The main steps followed in this | ||
2320 | + * function are: | ||
2321 | + * - Return IOH_1588_INVALIDPARAM if auxMode passed is not valid | ||
2322 | + * - Modify the Time Sync Controller register to disable the | ||
2323 | + * interrupt | ||
2324 | + * - Clear the callback handler | ||
2325 | + * | ||
2326 | + * | ||
2327 | + * @param auxMode [IN] - Auxiliary slave or master mode | ||
2328 | + * | ||
2329 | + * | ||
2330 | + * @retval enum ioh_status | ||
2331 | + * @li IOH_1588_SUCCESS - Operation successful | ||
2332 | + * @li IOH_1588_INVALIDPARAM - Invalid mode specified | ||
2333 | + */ | ||
2334 | +enum ioh_status ioh_1588_aux_time_interrupt_disable(enum ioh1588AuxMode auxMode) | ||
2335 | +{ | ||
2336 | + /* Verify the parameters */ | ||
2337 | + if (IOH_1588_AUXMODE_INVALID <= auxMode) { | ||
2338 | + IOH_DEBUG("ioh_1588_aux_time_interrupt_disable:invalid param \ | ||
2339 | + returning IOH_1588_INVALIDPARAM\n"); | ||
2340 | + return IOH_1588_INVALIDPARAM; | ||
2341 | + } | ||
2342 | + | ||
2343 | + if (IOH_1588_AUXMODE_MASTER == auxMode) { | ||
2344 | + IOH_DEBUG | ||
2345 | + ("ioh_1588_aux_time_interrupt_disable:\ | ||
2346 | + IOH_1588_AUXMODE_MASTER\ | ||
2347 | + invoking ioh_1588_amms_imask_clear\n"); | ||
2348 | + ioh_1588_amms_imask_clear(); | ||
2349 | + ioh_am_cbptr = (ioh1588AuxTimeCallback) NULL; | ||
2350 | + } else { | ||
2351 | + IOH_DEBUG | ||
2352 | + ("ioh_1588_aux_time_interrupt_disable:\ | ||
2353 | + IOH_1588_AUXMODE_SLAVE\ | ||
2354 | + invoking ioh_1588_asms_imask_clear\n"); | ||
2355 | + ioh_1588_asms_imask_clear(); | ||
2356 | + ioh_as_cbptr = (ioh1588AuxTimeCallback) NULL; | ||
2357 | + } | ||
2358 | + | ||
2359 | + return IOH_1588_SUCCESS; | ||
2360 | +} | ||
2361 | + | ||
2362 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2363 | + * @fn enum ioh_status ioh_1588_aux_time_poll( | ||
2364 | + * enum ioh1588AuxMode auxMode, unsigned long *pollFlag, | ||
2365 | + * struct ioh1588TimeValue*auxTime) | ||
2366 | + * | ||
2367 | + * @brief Poll for the Auxiliary Time Stamp captured event for the mode | ||
2368 | + * requested | ||
2369 | + * | ||
2370 | + * @remarks Polls for the Time stamp in the appropriate Auxiliary Snapshot | ||
2371 | + * Registers based on the mode specified. Return true and | ||
2372 | + * the contents of the Auxiliary snapshot if it is available | ||
2373 | + * otherwise return false. The main steps followed in this function | ||
2374 | + * are: | ||
2375 | + * - Validate the parameters and return IOH_1588_INVALIDPARAM if | ||
2376 | + * found invalid | ||
2377 | + * - If callbacks registered, return status | ||
2378 | + * IOH_1588_INTERRUPTMODEINUSE | ||
2379 | + * - Read the TS_Event register to check for the presence of valid | ||
2380 | + * snapshot | ||
2381 | + * - If the event is not set, return status IOH_1588_NOTIMESTAMP | ||
2382 | + * - Read the AuxSlaveModeSnap or AuxMasterModeSnap low, high | ||
2383 | + * registers depending on the auxMode | ||
2384 | + * - Clear the event from TS_Event register | ||
2385 | + * | ||
2386 | + * | ||
2387 | + * @param auxMode [IN] Auxiliary Snapshot Register | ||
2388 | + * (Master/Slave) to be checked | ||
2389 | + * @param pollFlag [OUT] TRUE if time stamp captured in aux | ||
2390 | + * snapshot register | ||
2391 | + * FALSE if the time stamp not captured | ||
2392 | + * @param auxTime [OUT] Buffer for returning captured Auxiliary | ||
2393 | + * Snapshot time | ||
2394 | + * | ||
2395 | + * | ||
2396 | + * @retval enum ioh_status | ||
2397 | + * @li IOH_1588_SUCCESS - Operation successful | ||
2398 | + * @li IOH_1588_INVALIDPARAM - Invalid parameter passed | ||
2399 | + * @li IOH_1588_INTERRUPTMODEINUSE - Interrupt mode is in use | ||
2400 | + */ | ||
2401 | +enum ioh_status | ||
2402 | +ioh_1588_aux_time_poll(enum ioh1588AuxMode auxMode, unsigned long *pollFlag, | ||
2403 | + struct ioh1588TimeValue *auxTime) | ||
2404 | +{ | ||
2405 | + unsigned long ammsFlag = FALSE; | ||
2406 | + unsigned long asmsFlag = FALSE; | ||
2407 | + | ||
2408 | + /* Verify the parameters */ | ||
2409 | + if (((unsigned long *)NULL == pollFlag) || | ||
2410 | + (IOH_1588_AUXMODE_INVALID <= auxMode) || | ||
2411 | + ((struct ioh1588TimeValue *) NULL == auxTime)) { | ||
2412 | + IOH_DEBUG("ioh_1588_aux_time_poll:invalid param \ | ||
2413 | + returning IOH_1588_INVALIDPARAM\n"); | ||
2414 | + return IOH_1588_INVALIDPARAM; | ||
2415 | + } | ||
2416 | + | ||
2417 | + /* Get Auxiliary Master/Slave Mode Snapshot */ | ||
2418 | + if (IOH_1588_AUXMODE_MASTER == auxMode) { | ||
2419 | + IOH_DEBUG("ioh_1588_aux_time_poll:IOH_1588_AUXMODE_MASTER\n"); | ||
2420 | + /* Is interrupt mode of processing is enabled? */ | ||
2421 | + if ((ioh1588AuxTimeCallback) NULL != ioh_am_cbptr) { | ||
2422 | + IOH_DEBUG | ||
2423 | + ("ioh_1588_aux_time_poll:interrupt mode in use\n"); | ||
2424 | + return IOH_1588_INTERRUPTMODEINUSE; | ||
2425 | + } | ||
2426 | + | ||
2427 | + /* Is the Auxiliary Master Mode Snapshot available? */ | ||
2428 | + ammsFlag = ioh_1588_amms_evt_get(); | ||
2429 | + if (FALSE == ammsFlag) { | ||
2430 | + IOH_DEBUG("ioh_1588_aux_time_poll:NO Auxiliary Master \ | ||
2431 | + Mode Snapshot available\n"); | ||
2432 | + *pollFlag = FALSE; | ||
2433 | + auxTime->timeValueLowWord = 0; | ||
2434 | + auxTime->timeValueHighWord = 0; | ||
2435 | + return IOH_1588_SUCCESS; | ||
2436 | + } | ||
2437 | + | ||
2438 | + /* Get Auxiliary Master Snapshot */ | ||
2439 | + ioh_1588_aux_master_snap_get(&auxTime->timeValueLowWord, | ||
2440 | + &auxTime->timeValueHighWord); | ||
2441 | + IOH_DEBUG("ioh_1588_aux_time_poll:Auxiliary Master Snapshot \ | ||
2442 | + low=%lx,high=%lx\n", auxTime->timeValueLowWord, \ | ||
2443 | + auxTime->timeValueHighWord); | ||
2444 | + | ||
2445 | + *pollFlag = TRUE; | ||
2446 | + | ||
2447 | + /* Clear the snapshot availability condition */ | ||
2448 | + IOH_DEBUG | ||
2449 | + ("ioh_1588_aux_time_poll:invoking ioh_1588_amms_evt_clear\n"); | ||
2450 | + ioh_1588_amms_evt_clear(); | ||
2451 | + } else { /* IOH_1588_AUXMODE_SLAVE == auxMode */ | ||
2452 | + | ||
2453 | + IOH_DEBUG("ioh_1588_aux_time_poll:IOH_1588_AUXMODE_SLAVE\n"); | ||
2454 | + /* Is interrupt mode of processing is enabled? */ | ||
2455 | + if ((ioh1588AuxTimeCallback) NULL != ioh_as_cbptr) { | ||
2456 | + IOH_DEBUG | ||
2457 | + ("ioh_1588_aux_time_poll:interrupt mode in use\n"); | ||
2458 | + return IOH_1588_INTERRUPTMODEINUSE; | ||
2459 | + } | ||
2460 | + | ||
2461 | + /* Is the Auxiliary Slave Mode Snapshot available? */ | ||
2462 | + asmsFlag = ioh_1588_asms_evt_get(); | ||
2463 | + if (FALSE == asmsFlag) { | ||
2464 | + IOH_DEBUG("ioh_1588_aux_time_poll:NO Auxiliary Slave \ | ||
2465 | + Mode Snapshot available\n"); | ||
2466 | + *pollFlag = FALSE; | ||
2467 | + auxTime->timeValueLowWord = 0; | ||
2468 | + auxTime->timeValueHighWord = 0; | ||
2469 | + return IOH_1588_SUCCESS; | ||
2470 | + } | ||
2471 | + | ||
2472 | + /* Get Auxiliary Slave Snapshot */ | ||
2473 | + ioh_1588_aux_slave_snap_get(&auxTime->timeValueLowWord, | ||
2474 | + &auxTime->timeValueHighWord); | ||
2475 | + IOH_DEBUG("ioh_1588_aux_time_poll:Auxiliary Slave Snapshot \ | ||
2476 | + low=%lx,high=%lx\n", auxTime->timeValueLowWord, \ | ||
2477 | + auxTime->timeValueHighWord); | ||
2478 | + | ||
2479 | + *pollFlag = TRUE; | ||
2480 | + | ||
2481 | + /* Clear the snapshot availability condition */ | ||
2482 | + IOH_DEBUG | ||
2483 | + ("ioh_1588_aux_time_poll:invoking ioh_1588_amms_evt_clear\n"); | ||
2484 | + ioh_1588_asms_evt_clear(); | ||
2485 | + } | ||
2486 | + | ||
2487 | + return IOH_1588_SUCCESS; | ||
2488 | +} | ||
2489 | + | ||
2490 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2491 | + * @fn enum ioh_status ioh_1588_reset(void) | ||
2492 | + * | ||
2493 | + * @brief Resets the IEEE 1588 hardware assist block | ||
2494 | + * | ||
2495 | + * @remarks Resets the IEEE 1588 hardware assist block. The | ||
2496 | + * main steps followed in this function are: | ||
2497 | + * - Set the reset bit of Time Sync Control register | ||
2498 | + * - Clear the reset bit of Time Sync Control register | ||
2499 | + * -Note: For A0/A1 sample, test mode setting is enabled for | ||
2500 | + * the 64 bit System Time Register. This is a work around for | ||
2501 | + * the non continuous value in the 64 bit System Time Register | ||
2502 | + * consisting of High(32bit) / Low(32bit) | ||
2503 | + * | ||
2504 | + * | ||
2505 | + * @param None | ||
2506 | + * | ||
2507 | + * @retval enum ioh_status | ||
2508 | + * @li IOH_1588_SUCCESS - Operation is successful | ||
2509 | + */ | ||
2510 | +enum ioh_status ioh_1588_reset(void) | ||
2511 | +{ | ||
2512 | + /* Reset Hardware Assist */ | ||
2513 | + IOH_DEBUG("ioh_1588_reset:invoking ioh_1588_block_reset\n"); | ||
2514 | + ioh_1588_block_reset(); | ||
2515 | + | ||
2516 | + /* Clear Stats */ | ||
2517 | + ioh_1588_stats.rxMsgs = ioh_1588_stats.txMsgs = 0; | ||
2518 | + | ||
2519 | + /* Unregister any Callback Routines */ | ||
2520 | + IOH_DEBUG("ioh_1588_reset:unregistering callbacks\n"); | ||
2521 | + ioh_pps_cbptr = (ioh1588PulsePerSecondCallback) NULL; | ||
2522 | + ioh_am_cbptr = (ioh1588AuxTimeCallback) NULL; | ||
2523 | + ioh_as_cbptr = (ioh1588AuxTimeCallback) NULL; | ||
2524 | + ioh_tt_cbptr = (ioh1588TargetTimeCallback) NULL; | ||
2525 | + | ||
2526 | +#ifdef IOH_IEEE1588_A0_A1_SAMPLE_BUG | ||
2527 | + /*enable all 32 bits in system time registers */ | ||
2528 | + ioh_1588_set_system_time_count(); | ||
2529 | +#endif | ||
2530 | + return IOH_1588_SUCCESS; | ||
2531 | +} | ||
2532 | + | ||
2533 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2534 | + * @fn enum ioh_status ioh_1588_chnl_reset(enum ioh1588PTPPort ptpPort) | ||
2535 | + * | ||
2536 | + * @brief Resets the IEEE 1588 channel by resetting the hardware block | ||
2537 | + * | ||
2538 | + * @remarks This API also sets the reset bit in the IEEE1588 to fully | ||
2539 | + * resets the block. The main steps followed in this function | ||
2540 | + * are: | ||
2541 | + * - Return IOH_1588_INVALIDPARAM if ptpPort passed is not valid | ||
2542 | + * - Perform a block level reset by invoking ioh_1588_reset | ||
2543 | + * | ||
2544 | + * | ||
2545 | + * @param ptpPort [IN] The PTP port that is to be reset | ||
2546 | + * | ||
2547 | + * | ||
2548 | + * @retval enum ioh_status | ||
2549 | + * @li IOH_1588_SUCCESS - Operation successful | ||
2550 | + */ | ||
2551 | +enum ioh_status ioh_1588_chnl_reset(enum ioh1588PTPPort ptpPort) | ||
2552 | +{ | ||
2553 | + IOH_DEBUG("ioh_1588_chnl_reset:invoking ioh_1588_reset\n"); | ||
2554 | + return ioh_1588_reset(); | ||
2555 | +} | ||
2556 | + | ||
2557 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2558 | + * @fn enum ioh_status ioh_1588_stats_get(struct ioh1588Stats *stats) | ||
2559 | + * | ||
2560 | + * @brief Returns the ioh1588 Statistics | ||
2561 | + * | ||
2562 | + * @remarks This API will return the statistics of the snapshots captured | ||
2563 | + * for | ||
2564 | + * receive and transmit of messages. The main steps followed in | ||
2565 | + * this | ||
2566 | + * function are: | ||
2567 | + * - Return IOH_1588_INVALIDPARAM if argument passed is NULL | ||
2568 | + * - Return the counter values stored for Rx and Tx messages | ||
2569 | + * | ||
2570 | + * | ||
2571 | + * @param stats [OUT] Buffer for returning the statistics | ||
2572 | + * counter values | ||
2573 | + * | ||
2574 | + * | ||
2575 | + * @note These counters are updated only when the client application | ||
2576 | + * polls for | ||
2577 | + * the time stamps or interrupt are enabled. | ||
2578 | + * | ||
2579 | + * @retval enum ioh_status | ||
2580 | + * @li IOH_1588_SUCCESS - Operation is successful | ||
2581 | + * @li IOH_1588_INVALIDPARAM - NULL parameter passed | ||
2582 | + */ | ||
2583 | + | ||
2584 | +enum ioh_status ioh_1588_stats_get(struct ioh1588Stats *stats) | ||
2585 | +{ | ||
2586 | + /* Verify the parameter */ | ||
2587 | + if ((struct ioh1588Stats *) NULL == stats) { | ||
2588 | + IOH_DEBUG("ioh_1588_stats_get:invalid param \ | ||
2589 | + returning IOH_1588_INVALIDPARAM\n"); | ||
2590 | + return IOH_1588_INVALIDPARAM; | ||
2591 | + } | ||
2592 | + | ||
2593 | + /* Return the statistics */ | ||
2594 | + stats->rxMsgs = ioh_1588_stats.rxMsgs; | ||
2595 | + stats->txMsgs = ioh_1588_stats.txMsgs; | ||
2596 | + IOH_DEBUG("ioh_1588_stats_get:stats-txMsg=%lx,rxMsg=%lx\n", | ||
2597 | + stats->txMsgs, stats->rxMsgs); | ||
2598 | + | ||
2599 | + return IOH_1588_SUCCESS; | ||
2600 | +} | ||
2601 | + | ||
2602 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2603 | + * @fn void ioh_1588_stats_reset(void) | ||
2604 | + * | ||
2605 | + * @brief Resets the statistics counters | ||
2606 | + * | ||
2607 | + * @remarks This API will reset the statistics counters maintained by the | ||
2608 | + * driver | ||
2609 | + * | ||
2610 | + * @param None | ||
2611 | + * @retval None | ||
2612 | + */ | ||
2613 | +void ioh_1588_stats_reset(void) | ||
2614 | +{ | ||
2615 | + /* Clear the statistics */ | ||
2616 | + IOH_DEBUG("ioh_1588_stats_reset:clearing stats\n"); | ||
2617 | + ioh_1588_stats.rxMsgs = ioh_1588_stats.txMsgs = 0; | ||
2618 | + | ||
2619 | + return; | ||
2620 | +} | ||
2621 | + | ||
2622 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2623 | + * @fn void ioh_1588_save_state(void) | ||
2624 | + * | ||
2625 | + * @brief Save the state of all registers | ||
2626 | + * | ||
2627 | + * @remarks Save the content of all registers of IEEE1588 module | ||
2628 | + * | ||
2629 | + * @param None. | ||
2630 | + * | ||
2631 | + * @retval None | ||
2632 | + */ | ||
2633 | +void ioh_1588_save_state(void) | ||
2634 | +{ | ||
2635 | + int i; | ||
2636 | + unsigned long val; | ||
2637 | + | ||
2638 | + /* Time stamp control register */ | ||
2639 | + ioh_1588_regs.ts_control = | ||
2640 | + (ioh_1588_ttm_imask_get() << IOH_1588_TSC_TTM_SHIFT) | | ||
2641 | + (ioh_1588_asms_imask_get() << IOH_1588_TSC_ASMS_SHIFT) | | ||
2642 | + (ioh_1588_amms_imask_get() << IOH_1588_TSC_AMMS_SHIFT) | | ||
2643 | + (ioh_1588_pps_imask_get() << IOH_1588_TSC_PPSM_SHIFT); | ||
2644 | + IOH_DEBUG("ioh_1588_save_state:TS_CONTROL reg=%lx\n", | ||
2645 | + ioh_1588_regs.ts_control); | ||
2646 | + | ||
2647 | + /* | ||
2648 | + * Time stamp event register; clear on write, | ||
2649 | + * so no point in reading and then saving; | ||
2650 | + * Will be cleared on restore to start in a clean slate | ||
2651 | + */ | ||
2652 | + ioh_1588_regs.ts_event = IOH_1588_TSE_TTIPEND | IOH_1588_TSE_SNS | | ||
2653 | + IOH_1588_TSE_SNM | IOH_1588_TSE_PPS; | ||
2654 | + IOH_DEBUG("ioh_1588_save_state:TS_EVENT reg=%lx\n", | ||
2655 | + ioh_1588_regs.ts_event); | ||
2656 | + | ||
2657 | + /* Addend register */ | ||
2658 | + ioh_1588_addend_get(&ioh_1588_regs.ts_addend); | ||
2659 | + IOH_DEBUG("ioh_1588_save_state:TS_ADDEND reg=%lx\n", | ||
2660 | + ioh_1588_regs.ts_addend); | ||
2661 | + | ||
2662 | + /* PPS comapre register */ | ||
2663 | + ioh_1588_pps_get(&ioh_1588_regs.ts_compare); | ||
2664 | + IOH_DEBUG("ioh_1588_save_state:TS_COMPARE reg=%lx\n", | ||
2665 | + ioh_1588_regs.ts_compare); | ||
2666 | + | ||
2667 | + /* System time Low and Hi registers */ | ||
2668 | + ioh_1588_sys_snap_get(&ioh_1588_regs.ts_syslo, &ioh_1588_regs.ts_syshi); | ||
2669 | + IOH_DEBUG("ioh_1588_save_state:sys time reg-low =%lx,high=%lx\n", | ||
2670 | + ioh_1588_regs.ts_syslo, ioh_1588_regs.ts_syshi); | ||
2671 | + | ||
2672 | + /* Target time Low and Hi registers */ | ||
2673 | + ioh_1588_tgt_snap_get(&ioh_1588_regs.ts_tgtlo, &ioh_1588_regs.ts_tgthi); | ||
2674 | + IOH_DEBUG("ioh_1588_save_state:target time reg-low =%lx,high=%lx\n", | ||
2675 | + ioh_1588_regs.ts_tgtlo, ioh_1588_regs.ts_tgthi); | ||
2676 | + | ||
2677 | +#if 0 | ||
2678 | + /* | ||
2679 | + * Below registers are read only, so no point in reading/storing, since | ||
2680 | + * we can't restore them | ||
2681 | + */ | ||
2682 | + /* Slave mode snapshot Low and Hi registers */ | ||
2683 | + ioh_1588_aux_slave_snap_get(&ioh_1588_regs.ts_asmslo, | ||
2684 | + &ioh_1588_regs.ts_asmshi); | ||
2685 | + | ||
2686 | + /* Master mode snapshot Low and Hi registers */ | ||
2687 | + ioh_1588_aux_master_snap_get(&ioh_1588_regs.ts_ammslo, | ||
2688 | + &ioh_1588_regs.ts_ammshi); | ||
2689 | +#endif | ||
2690 | + ioh_1588_regs.ts_cc = | ||
2691 | + (ioh_1588_master_mode_get() << IOH_1588_CC_MM_SHIFT) | | ||
2692 | + (ioh_1588_timestamp_all_get() << IOH_1588_CC_TA_SHIFT) | | ||
2693 | + (ioh_1588_op_mode_get() << IOH_1588_CC_MODE_SHIFT) | | ||
2694 | + (ioh_1588_version_get() << IOH_1588_CC_VERSION_SHIFT); | ||
2695 | + IOH_DEBUG("ioh_1588_save_state:TS_CC reg=%lx\n", ioh_1588_regs.ts_cc); | ||
2696 | + | ||
2697 | + /* Channel event register, not saved - will be cleared on restore */ | ||
2698 | + ioh_1588_regs.ts_ce = IOH_1588_CE_TXS | IOH_1588_CE_RXS; | ||
2699 | + | ||
2700 | +#if 0 | ||
2701 | + /* | ||
2702 | + * Below registers are read only, so no point in reading/storing, since | ||
2703 | + * we can't restore them | ||
2704 | + */ | ||
2705 | + ioh_1588_rx_snap_get(&ioh_1588_regs.ts_xslo, &ioh_1588_regs.ts_xshi); | ||
2706 | + ioh_1588_tx_snap_get(&ioh_1588_regs.ts_rslo, &ioh_1588_regs.ts_rshi); | ||
2707 | + ioh_1588_uuid_seqid_get(&ioh_1588_regs.ts_uuidlo, | ||
2708 | + &ioh_1588_regs.ts_uuidhi); | ||
2709 | + | ||
2710 | + /* CAN */ | ||
2711 | + ioh_1588_can_snap_get(&ioh_1588_regs.ts_cxslo, &ioh_1588_regs.ts_cxshi); | ||
2712 | +#endif | ||
2713 | + | ||
2714 | + /* CAN Channel event register, not saved - will be cleared on restore */ | ||
2715 | + ioh_1588_regs.ts_cce = IOH_1588_CE_OVR | IOH_1588_CE_VAL; | ||
2716 | + | ||
2717 | + /* Ethernet CAN selector register */ | ||
2718 | + ioh_1588_regs.ts_sel = | ||
2719 | + (ioh_1588_eth_enable_get() << IOH_1588_ECS_ETH_SHIFT) | | ||
2720 | + (ioh_1588_can_enable_get() << IOH_1588_ECS_CAN_SHIFT); | ||
2721 | + IOH_DEBUG("ioh_1588_save_state:TS_SEL reg=%lx\n", ioh_1588_regs.ts_sel); | ||
2722 | + | ||
2723 | + /* Station Address registers */ | ||
2724 | + for (i = 0; i < IOH_1588_STATION_BYTES; i++) { | ||
2725 | + ioh_1588_station_get(i, &val); | ||
2726 | + ioh_1588_regs.ts_sti[i] = val & 0xff; | ||
2727 | + IOH_DEBUG("ioh_1588_save_state:TS_ST[%d] reg=%d\n", i, | ||
2728 | + ioh_1588_regs.ts_sti[i]); | ||
2729 | + } | ||
2730 | +} | ||
2731 | + | ||
2732 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2733 | + * @fn void ioh_1588_restore_state(void) | ||
2734 | + * | ||
2735 | + * @brief Restore the state of all registers | ||
2736 | + * | ||
2737 | + * @remarks Restores the content of all registers of IEEE1588 module. | ||
2738 | + * Note: For A0/A1 sample, test mode setting is enabled for | ||
2739 | + * the 64 bit System Time Register. This is a work around for | ||
2740 | + * the non continuous value in the 64 bit System Time | ||
2741 | + * Register | ||
2742 | + * consisting of High(32bit) / Low(32bit) | ||
2743 | + * | ||
2744 | + * @param None | ||
2745 | + * @retval None | ||
2746 | + */ | ||
2747 | +void ioh_1588_restore_state(void) | ||
2748 | +{ | ||
2749 | + int i; | ||
2750 | + | ||
2751 | + /* Time stamp control register */ | ||
2752 | + if (ioh_1588_regs.ts_control & IOH_1588_TSC_TTM_MASK) { | ||
2753 | + IOH_DEBUG | ||
2754 | + ("ioh_1588_restore_state:invoking ioh_1588_ttm_imask_set\n"); | ||
2755 | + ioh_1588_ttm_imask_set(); | ||
2756 | + } | ||
2757 | + if (ioh_1588_regs.ts_control & IOH_1588_TSC_ASMS_MASK) { | ||
2758 | + IOH_DEBUG | ||
2759 | + ("ioh_1588_restore_state:invoking ioh_1588_asms_imask_set\n"); | ||
2760 | + ioh_1588_asms_imask_set(); | ||
2761 | + } | ||
2762 | + if (ioh_1588_regs.ts_control & IOH_1588_TSC_AMMS_MASK) { | ||
2763 | + IOH_DEBUG | ||
2764 | + ("ioh_1588_restore_state:invoking ioh_1588_amms_imask_set\n"); | ||
2765 | + ioh_1588_amms_imask_set(); | ||
2766 | + } | ||
2767 | + if (ioh_1588_regs.ts_control & IOH_1588_TSC_PPSM_MASK) { | ||
2768 | + IOH_DEBUG | ||
2769 | + ("ioh_1588_restore_state:invoking ioh_1588_pps_imask_set\n"); | ||
2770 | + ioh_1588_pps_imask_set(); | ||
2771 | + } | ||
2772 | + | ||
2773 | + /* Time stamp event register; clear all events */ | ||
2774 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_ttm_evt_clear\n"); | ||
2775 | + ioh_1588_ttm_evt_clear(); | ||
2776 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_asms_evt_clear\n"); | ||
2777 | + ioh_1588_asms_evt_clear(); | ||
2778 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_amms_evt_clear\n"); | ||
2779 | + ioh_1588_amms_evt_clear(); | ||
2780 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_pps_evt_clear\n"); | ||
2781 | + ioh_1588_pps_evt_clear(); | ||
2782 | + | ||
2783 | +#ifdef IOH_IEEE1588_A0_A1_SAMPLE_BUG | ||
2784 | + /*enable all 32 bits in system time registers */ | ||
2785 | + ioh_1588_set_system_time_count(); | ||
2786 | +#endif | ||
2787 | + | ||
2788 | + /* Addend register */ | ||
2789 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_addend_set\n"); | ||
2790 | + ioh_1588_addend_set(ioh_1588_regs.ts_addend); | ||
2791 | + | ||
2792 | + /* PPS comapre register */ | ||
2793 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_pps_set\n"); | ||
2794 | + ioh_1588_pps_set(ioh_1588_regs.ts_compare); | ||
2795 | + | ||
2796 | + /* System time Low and Hi registers */ | ||
2797 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_sys_snap_set\n"); | ||
2798 | + ioh_1588_sys_snap_set(ioh_1588_regs.ts_syslo, ioh_1588_regs.ts_syshi); | ||
2799 | + | ||
2800 | + /* Target time Low and Hi registers */ | ||
2801 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_tgt_snap_set\n"); | ||
2802 | + ioh_1588_tgt_snap_set(ioh_1588_regs.ts_tgtlo, ioh_1588_regs.ts_tgthi); | ||
2803 | + | ||
2804 | + /* Ethernet Channel Control register */ | ||
2805 | + if (ioh_1588_regs.ts_cc & IOH_1588_CC_MM) { | ||
2806 | + IOH_DEBUG | ||
2807 | + ("ioh_1588_restore_state:invoking ioh_1588_master_mode_set\ | ||
2808 | + with TRUE as parameter\n"); | ||
2809 | + ioh_1588_master_mode_set(TRUE); | ||
2810 | + } | ||
2811 | + if (ioh_1588_regs.ts_cc & IOH_1588_CC_TA) { | ||
2812 | + IOH_DEBUG | ||
2813 | + ("ioh_1588_restore_state:invoking ioh_1588_timestamp_all_set\ | ||
2814 | + with TRUE as parameter\n"); | ||
2815 | + ioh_1588_timestamp_all_set(TRUE); | ||
2816 | + } | ||
2817 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_op_mode_set\n"); | ||
2818 | + ioh_1588_op_mode_set((ioh_1588_regs.ts_cc & IOH_1588_CC_MODE_MASK) >> | ||
2819 | + IOH_1588_CC_MODE_SHIFT); | ||
2820 | + if (ioh_1588_regs.ts_cc & IOH_1588_CC_VERSION) { | ||
2821 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_version_set\ | ||
2822 | + with IOH_1588PTP_VERSION_1 as parameter\n"); | ||
2823 | + ioh_1588_version_set(IOH_1588PTP_VERSION_1); | ||
2824 | + } | ||
2825 | + | ||
2826 | + /* Channel event register, cleared on restore */ | ||
2827 | + IOH_DEBUG | ||
2828 | + ("ioh_1588_restore_state:invoking ioh_1588_rx_snap_evt_clear\n"); | ||
2829 | + ioh_1588_rx_snap_evt_clear(); | ||
2830 | + IOH_DEBUG | ||
2831 | + ("ioh_1588_restore_state:invoking ioh_1588_tx_snap_evt_clear\n"); | ||
2832 | + ioh_1588_tx_snap_evt_clear(); | ||
2833 | + | ||
2834 | + /* CAN Channel event register, cleared on restore */ | ||
2835 | + IOH_DEBUG | ||
2836 | + ("ioh_1588_restore_state:invoking ioh_1588_tx_snap_ovr_clear\n"); | ||
2837 | + ioh_1588_can_snap_ovr_clear(); | ||
2838 | + IOH_DEBUG | ||
2839 | + ("ioh_1588_restore_state:invoking ioh_1588_tx_snap_valid_clear\n"); | ||
2840 | + ioh_1588_can_snap_valid_clear(); | ||
2841 | + | ||
2842 | + /* Ethernet CAN selector register */ | ||
2843 | + if (ioh_1588_regs.ts_sel & IOH_1588_ECS_ETH) { | ||
2844 | + IOH_DEBUG | ||
2845 | + ("ioh_1588_restore_state:invoking ioh_1588_eth_enable_set\n"); | ||
2846 | + ioh_1588_eth_enable_set(); | ||
2847 | + } | ||
2848 | + if (ioh_1588_regs.ts_sel & IOH_1588_ECS_CAN) { | ||
2849 | + IOH_DEBUG | ||
2850 | + ("ioh_1588_restore_state:invoking ioh_1588_can_enable_set\n"); | ||
2851 | + ioh_1588_can_enable_set(); | ||
2852 | + } | ||
2853 | + | ||
2854 | + /* Station Address registers */ | ||
2855 | + for (i = 0; i < IOH_1588_STATION_BYTES; i++) { | ||
2856 | + IOH_DEBUG("ioh_1588_restore_state:invoking ioh_1588_station_set\ | ||
2857 | + for station=%d\n", i); | ||
2858 | + ioh_1588_station_set(i, ioh_1588_regs.ts_sti[i]); | ||
2859 | + } | ||
2860 | +} | ||
2861 | + | ||
2862 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
2863 | + * @fn void ioh_1588_show(void) | ||
2864 | + * | ||
2865 | + * @brief Display the dump of IEEE 1588 registers | ||
2866 | + * | ||
2867 | + * @remarks This API will dump the contents of configuration, event and | ||
2868 | + * snapshot | ||
2869 | + * registers of the IEEE1588 module | ||
2870 | + * | ||
2871 | + * @param None. | ||
2872 | + * | ||
2873 | + * @retval enum ioh_status | ||
2874 | + * @li IOH_1588_SUCCESS | ||
2875 | + */ | ||
2876 | +enum ioh_status ioh_1588_show(void) | ||
2877 | +{ | ||
2878 | + int i; | ||
2879 | + unsigned long flag = FALSE; | ||
2880 | + unsigned long reg_low = 0; | ||
2881 | + unsigned long reg_hi = 0; | ||
2882 | + unsigned int seq_id = 0; | ||
2883 | + unsigned long uuid_low = 0; | ||
2884 | + unsigned long uuid_hi = 0; | ||
2885 | + | ||
2886 | + /*dump all register as such */ | ||
2887 | + IOH_DEBUG("TS Control Register offset = %x,content = %x\n", | ||
2888 | + IOH_1588_TSC_OFFSET, | ||
2889 | + IOH_READ32(ioh_1588_base + IOH_1588_TSC_OFFSET)); | ||
2890 | + IOH_DEBUG("TS Event Register offset = %x,content = %x\n", | ||
2891 | + IOH_1588_TSE_OFFSET, | ||
2892 | + IOH_READ32(ioh_1588_base + IOH_1588_TSE_OFFSET)); | ||
2893 | + IOH_DEBUG("TS Addend Register offset = %x,content = %x\n", | ||
2894 | + IOH_1588_ADD_OFFSET, | ||
2895 | + IOH_READ32(ioh_1588_base + IOH_1588_ADD_OFFSET)); | ||
2896 | + IOH_DEBUG("TS Accumulator Register offset = %x,content = %x\n", | ||
2897 | + IOH_1588_ACC_OFFSET, | ||
2898 | + IOH_READ32(ioh_1588_base + IOH_1588_ACC_OFFSET)); | ||
2899 | + IOH_DEBUG("TS Test Register offset = %x,content = %x\n", | ||
2900 | + IOH_1588_TST_OFFSET, | ||
2901 | + IOH_READ32(ioh_1588_base + IOH_1588_TST_OFFSET)); | ||
2902 | + IOH_DEBUG("TS PPS Compare Register offset = %x,content = %x\n", | ||
2903 | + IOH_1588_PPS_OFFSET, | ||
2904 | + IOH_READ32(ioh_1588_base + IOH_1588_PPS_OFFSET)); | ||
2905 | + IOH_DEBUG("TS System Time Low Register offset = %x,content = %x\n", | ||
2906 | + IOH_1588_STL_OFFSET, | ||
2907 | + IOH_READ32(ioh_1588_base + IOH_1588_STL_OFFSET)); | ||
2908 | + IOH_DEBUG("TS System Time High Register offset = %x,content = %x\n", | ||
2909 | + IOH_1588_STH_OFFSET, | ||
2910 | + IOH_READ32(ioh_1588_base + IOH_1588_STH_OFFSET)); | ||
2911 | + IOH_DEBUG("TS Target Time Low Register offset = %x,content = %x\n", | ||
2912 | + IOH_1588_TTL_OFFSET, | ||
2913 | + IOH_READ32(ioh_1588_base + IOH_1588_TTL_OFFSET)); | ||
2914 | + IOH_DEBUG("TS Target Time High Register offset = %x,content = %x\n", | ||
2915 | + IOH_1588_TTH_OFFSET, | ||
2916 | + IOH_READ32(ioh_1588_base + IOH_1588_TTH_OFFSET)); | ||
2917 | + IOH_DEBUG | ||
2918 | + ("TS Aux Slave Mode Snapshot Low Register offset = %x,content = %x\n", | ||
2919 | + IOH_1588_ASSL_OFFSET, | ||
2920 | + IOH_READ32(ioh_1588_base + IOH_1588_ASSL_OFFSET)); | ||
2921 | + IOH_DEBUG | ||
2922 | + ("TS Aux Slave Mode Snapshot High Register offset = %x,content = %x\n", | ||
2923 | + IOH_1588_ASSH_OFFSET, | ||
2924 | + IOH_READ32(ioh_1588_base + IOH_1588_ASSH_OFFSET)); | ||
2925 | + IOH_DEBUG | ||
2926 | + ("TS Aux Master Mode Snapshot Low Register offset = %x,content = %x\n", | ||
2927 | + IOH_1588_AMSL_OFFSET, | ||
2928 | + IOH_READ32(ioh_1588_base + IOH_1588_AMSL_OFFSET)); | ||
2929 | + IOH_DEBUG | ||
2930 | + ("TS Aux Master Mode Snapshot High Register offset = %x,content = %x\n", | ||
2931 | + IOH_1588_AMSH_OFFSET, | ||
2932 | + IOH_READ32(ioh_1588_base + IOH_1588_AMSH_OFFSET)); | ||
2933 | + IOH_DEBUG("TS Channel Control Register offset = %x,content = %x\n", | ||
2934 | + IOH_1588_CC_OFFSET, | ||
2935 | + IOH_READ32(ioh_1588_base + IOH_1588_CC_OFFSET)); | ||
2936 | + IOH_DEBUG("TS Channel Event Register offset = %x,content = %x\n", | ||
2937 | + IOH_1588_CE_OFFSET, | ||
2938 | + IOH_READ32(ioh_1588_base + IOH_1588_CE_OFFSET)); | ||
2939 | + IOH_DEBUG("TS Tx Snapshot High Register offset = %x,content = %x\n", | ||
2940 | + IOH_1588_XSH_OFFSET, | ||
2941 | + IOH_READ32(ioh_1588_base + IOH_1588_XSH_OFFSET)); | ||
2942 | + IOH_DEBUG("TS Tx Snapshot Low Register offset = %x,content = %x\n", | ||
2943 | + IOH_1588_XSL_OFFSET, | ||
2944 | + IOH_READ32(ioh_1588_base + IOH_1588_XSL_OFFSET)); | ||
2945 | + IOH_DEBUG("TS Rx Snapshot Low Register offset = %x,content = %x\n", | ||
2946 | + IOH_1588_RSL_OFFSET, | ||
2947 | + IOH_READ32(ioh_1588_base + IOH_1588_RSL_OFFSET)); | ||
2948 | + IOH_DEBUG("TS Rx Snapshot High Register offset = %x,content = %x\n", | ||
2949 | + IOH_1588_RSH_OFFSET, | ||
2950 | + IOH_READ32(ioh_1588_base + IOH_1588_RSH_OFFSET)); | ||
2951 | + IOH_DEBUG("TS Source UUID Low Register offset = %x,content = %x\n", | ||
2952 | + IOH_1588_UID_OFFSET, | ||
2953 | + IOH_READ32(ioh_1588_base + IOH_1588_UID_OFFSET)); | ||
2954 | + IOH_DEBUG | ||
2955 | + ("TS Source UUID High/SequenceID Register offset = %x,content = %x\n", | ||
2956 | + IOH_1588_SID_OFFSET, | ||
2957 | + IOH_READ32(ioh_1588_base + IOH_1588_SID_OFFSET)); | ||
2958 | + IOH_DEBUG("TS CAN Channel Status Register offset = %x,content = %x\n", | ||
2959 | + IOH_1588_CCE_OFFSET, | ||
2960 | + IOH_READ32(ioh_1588_base + IOH_1588_CCE_OFFSET)); | ||
2961 | + IOH_DEBUG("TS CAN Snapshot Low Register offset = %x,content = %x\n", | ||
2962 | + IOH_1588_CXSL_OFFSET, | ||
2963 | + IOH_READ32(ioh_1588_base + IOH_1588_CXSL_OFFSET)); | ||
2964 | + IOH_DEBUG("TS CAN Snapshot High Register offset = %x,content = %x\n", | ||
2965 | + IOH_1588_CXSH_OFFSET, | ||
2966 | + IOH_READ32(ioh_1588_base + IOH_1588_CXSH_OFFSET)); | ||
2967 | + IOH_DEBUG("TS Ethernet/CAN Selecti Register offset = %x,content = %x\n", | ||
2968 | + IOH_1588_ECS_OFFSET, | ||
2969 | + IOH_READ32(ioh_1588_base + IOH_1588_ECS_OFFSET)); | ||
2970 | + /* Station Address registers */ | ||
2971 | + IOH_DEBUG("TS Station Address [1-6]"); | ||
2972 | + for (i = 0; i < IOH_1588_STATION_BYTES; i++) { | ||
2973 | + ioh_1588_station_get(i, ®_low); | ||
2974 | + IOH_DEBUG(":%02lx", reg_low); | ||
2975 | + } | ||
2976 | + IOH_DEBUG("\n"); | ||
2977 | + | ||
2978 | + /* Target time reached interrupt mask */ | ||
2979 | + flag = ioh_1588_ttm_imask_get(); | ||
2980 | + IOH_LOG(KERN_ERR, "Target Time Interrupt Mask: %s\n", | ||
2981 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
2982 | + | ||
2983 | + /* Auxiliary Slave Mode Snapshot interrupt mask */ | ||
2984 | + flag = ioh_1588_asms_imask_get(); | ||
2985 | + IOH_LOG(KERN_ERR, "ASMS Interrupt Mask: %s\n", | ||
2986 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
2987 | + | ||
2988 | + /* Auxiliary Master Mode Snapshot interrupt mask */ | ||
2989 | + flag = ioh_1588_amms_imask_get(); | ||
2990 | + IOH_LOG(KERN_ERR, "AMMS Interrupt Mask: %s\n", | ||
2991 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
2992 | + | ||
2993 | + /* Pulse per second interrupt mask */ | ||
2994 | + flag = ioh_1588_pps_imask_get(); | ||
2995 | + IOH_LOG(KERN_ERR, "PPS Interrupt Mask: %s\n", | ||
2996 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
2997 | + | ||
2998 | + /* TS_Event Register */ | ||
2999 | + /* Target time interrupt event */ | ||
3000 | + flag = ioh_1588_ttm_evt_get(); | ||
3001 | + IOH_LOG(KERN_ERR, "Target Time Interrupt Pending: %s\n", | ||
3002 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3003 | + | ||
3004 | + /* Auxiliary Slave Mode Snapshot event */ | ||
3005 | + flag = ioh_1588_asms_evt_get(); | ||
3006 | + IOH_LOG(KERN_ERR, "ASMS Snapshot Event: %s\n", | ||
3007 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3008 | + | ||
3009 | + /* Auxiliary Master Mode Snapshot event */ | ||
3010 | + flag = ioh_1588_amms_evt_get(); | ||
3011 | + IOH_LOG(KERN_ERR, "AMMS Snapshot Event: %s\n", | ||
3012 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3013 | + | ||
3014 | + /* PPS Match event */ | ||
3015 | + flag = ioh_1588_pps_evt_get(); | ||
3016 | + IOH_LOG(KERN_ERR, "PPS Match Event: %s\n", | ||
3017 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3018 | + | ||
3019 | + /* Addend Register */ | ||
3020 | + reg_low = 0; | ||
3021 | + ioh_1588_addend_get(®_low); | ||
3022 | + IOH_LOG(KERN_ERR, "Frequency Scaling Value: %lx\n", reg_low); | ||
3023 | + | ||
3024 | + /* PPS Comapre Register */ | ||
3025 | + reg_low = 0; | ||
3026 | + ioh_1588_pps_get(®_low); | ||
3027 | + IOH_LOG(KERN_ERR, "PPS Compare Register Value: %lx\n", reg_low); | ||
3028 | + | ||
3029 | + /* System Time registers */ | ||
3030 | + reg_low = reg_hi = 0; | ||
3031 | + ioh_1588_sys_snap_get(®_low, ®_hi); | ||
3032 | + IOH_LOG(KERN_ERR, "System Time (Hi:Low): %lx : %lx\n", reg_hi, reg_low); | ||
3033 | + | ||
3034 | + /* Target Time registers */ | ||
3035 | + reg_low = reg_hi = 0; | ||
3036 | + ioh_1588_tgt_snap_get(®_low, ®_hi); | ||
3037 | + IOH_LOG(KERN_ERR, "Target Time (Hi:Low): %lx : %lx\n", reg_hi, reg_low); | ||
3038 | + | ||
3039 | + /* Auxiliary Slave Mode Snapshot registers */ | ||
3040 | + reg_low = reg_hi = 0; | ||
3041 | + ioh_1588_aux_slave_snap_get(®_low, ®_hi); | ||
3042 | + IOH_LOG(KERN_ERR, | ||
3043 | + "Auxiliary Slave Mode Snapshot (Hi:Low) : %lx : %lx\n", reg_hi, | ||
3044 | + reg_low); | ||
3045 | + | ||
3046 | + /* Auxiliary Master Mode Snapshot registers */ | ||
3047 | + reg_low = reg_hi = 0; | ||
3048 | + ioh_1588_aux_master_snap_get(®_low, ®_hi); | ||
3049 | + IOH_LOG(KERN_ERR, | ||
3050 | + "Auxiliary Master Mode Snapshot (Hi:Low): %lx : %lx\n", reg_hi, | ||
3051 | + reg_low); | ||
3052 | + | ||
3053 | + /* Ethernet port */ | ||
3054 | + IOH_LOG(KERN_ERR, "\nPTP Eth Port\n"); | ||
3055 | + | ||
3056 | + /* Master Mode */ | ||
3057 | + flag = ioh_1588_master_mode_get(); | ||
3058 | + IOH_LOG(KERN_ERR, "Master Mode: %s\n", | ||
3059 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3060 | + | ||
3061 | + /* Timestamp All PTP messages */ | ||
3062 | + flag = ioh_1588_timestamp_all_get(); | ||
3063 | + IOH_LOG(KERN_ERR, "Timestamp All Messages: %s\n", | ||
3064 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3065 | + | ||
3066 | + /* Version */ | ||
3067 | + flag = ioh_1588_version_get(); | ||
3068 | + IOH_LOG(KERN_ERR, "Version support: %s\n", | ||
3069 | + ((TRUE == flag) ? "v1 and v2" : "v1 only")); | ||
3070 | + | ||
3071 | + /* Receive Snapshot Locked */ | ||
3072 | + flag = ioh_1588_rx_snap_evt(); | ||
3073 | + IOH_LOG(KERN_ERR, "Receive Snapshot Locked: %s\n", | ||
3074 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3075 | + | ||
3076 | + /* Transmit Snapshot Locked */ | ||
3077 | + flag = ioh_1588_tx_snap_evt(); | ||
3078 | + IOH_LOG(KERN_ERR, "Transmit Snapshot Locked: %s\n", | ||
3079 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3080 | + | ||
3081 | + /* Receive Snapshot registers */ | ||
3082 | + reg_low = reg_hi = 0; | ||
3083 | + ioh_1588_rx_snap_get(®_low, ®_hi); | ||
3084 | + IOH_LOG(KERN_ERR, "Receive Snapshot (Hi:Low): %lx : %lx\n", reg_hi, | ||
3085 | + reg_low); | ||
3086 | + | ||
3087 | + /* Transmit Snapshot registers */ | ||
3088 | + reg_low = reg_hi = 0; | ||
3089 | + ioh_1588_tx_snap_get(®_low, ®_hi); | ||
3090 | + IOH_LOG(KERN_ERR, "Transmit Snapshot (Hi:Low): %lx : %lx\n", reg_hi, | ||
3091 | + reg_low); | ||
3092 | + | ||
3093 | + /* UUID and Seqquence Id */ | ||
3094 | + ioh_1588_uuid_seqid_get(&uuid_low, &uuid_hi, &seq_id); | ||
3095 | + IOH_LOG(KERN_ERR, "UUID (Hi:Lo): %lx : %lx\n", uuid_hi, uuid_low); | ||
3096 | + IOH_LOG(KERN_ERR, "Sequence id: %x\n", seq_id); | ||
3097 | + | ||
3098 | + /* CAN port */ | ||
3099 | + IOH_LOG(KERN_ERR, "\nPTP CAN Port:\n"); | ||
3100 | + | ||
3101 | + /* Snapshot Valid */ | ||
3102 | + flag = ioh_1588_can_snap_valid(); | ||
3103 | + IOH_LOG(KERN_ERR, "Snapshot Valid : %s\n", | ||
3104 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3105 | + | ||
3106 | + /* Snapshot Overrun */ | ||
3107 | + flag = ioh_1588_can_snap_ovr(); | ||
3108 | + IOH_LOG(KERN_ERR, "Snapshot Overrun: %s\n", | ||
3109 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3110 | + | ||
3111 | + /* CAN Snapshot registers */ | ||
3112 | + reg_low = reg_hi = 0; | ||
3113 | + ioh_1588_can_snap_get(®_low, ®_hi); | ||
3114 | + IOH_LOG(KERN_ERR, "CAN Snapshot (Hi:Low): %lx : %lx\n", reg_hi, | ||
3115 | + reg_low); | ||
3116 | + | ||
3117 | + /* Ethernet Selector */ | ||
3118 | + flag = ioh_1588_eth_enable_get(); | ||
3119 | + IOH_LOG(KERN_ERR, "\nEthernet Enable: %s\n", | ||
3120 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3121 | + | ||
3122 | + /* CAN Selector */ | ||
3123 | + flag = ioh_1588_can_enable_get(); | ||
3124 | + IOH_LOG(KERN_ERR, "CAN Enable: %s\n", | ||
3125 | + ((TRUE == flag) ? "Set" : "Clear")); | ||
3126 | + | ||
3127 | + /* Station Address Registers */ | ||
3128 | + IOH_LOG(KERN_ERR, "Station Address [1-6]"); | ||
3129 | + for (i = 0; i < IOH_1588_STATION_BYTES; i++) { | ||
3130 | + ioh_1588_station_get(i, ®_low); | ||
3131 | + IOH_LOG(KERN_ERR, ":%02lx", reg_low); | ||
3132 | + } | ||
3133 | + IOH_LOG(KERN_ERR, "\n"); | ||
3134 | + | ||
3135 | + /* Statistics */ | ||
3136 | + IOH_LOG(KERN_ERR, | ||
3137 | + "Receive Snapshot Count: %lu\nTransmit Snapshot Count: %lu\n", | ||
3138 | + ioh_1588_stats.rxMsgs, ioh_1588_stats.txMsgs); | ||
3139 | + | ||
3140 | + return IOH_1588_SUCCESS; | ||
3141 | +} | ||
3142 | + | ||
3143 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3144 | + * @fn enum ioh_status ioh_1588_ptp_can_poll ( | ||
3145 | + * enum ioh1588PTPPort ptpPort, | ||
3146 | + * struct ioh1588TimeValue *ptpTimeStamp) | ||
3147 | + * | ||
3148 | + * @brief Polls the IEEE 1588 message time stamp detect status on a given | ||
3149 | + * CAN PTP Port. | ||
3150 | + * | ||
3151 | + * @remarks This API polls for the availability of a time stamp on a CAN | ||
3152 | + * port. | ||
3153 | + * | ||
3154 | + * @param ptpPort [IN] PTP port to poll | ||
3155 | + * @param ptpTimeStamp [OUT] Buffer to store the snapshot captured | ||
3156 | + * | ||
3157 | + * | ||
3158 | + * @retval enum ioh_status | ||
3159 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3160 | + * @li IOH_1588_INVALIDPARAM - Invalid parameters passed | ||
3161 | + * @li IOH_1588_NOTIMESTAMP - No time stamp available | ||
3162 | + */ | ||
3163 | +enum ioh_status | ||
3164 | +ioh_1588_ptp_can_poll(enum ioh1588PTPPort ptpPort, \ | ||
3165 | + struct ioh1588TimeValue *ptpTimeStamp) | ||
3166 | +{ | ||
3167 | + unsigned long valid = FALSE; | ||
3168 | + unsigned long overrun = FALSE; | ||
3169 | + | ||
3170 | + /* Verify the parameters for proper values */ | ||
3171 | + if ((ptpPort != IOH_1588_CAN_0_1588PTP_PORT) || | ||
3172 | + ((struct ioh1588TimeValue *) NULL == ptpTimeStamp)) { | ||
3173 | + IOH_DEBUG("ioh_1588_ptp_can_poll:invalid params\ | ||
3174 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3175 | + return IOH_1588_INVALIDPARAM; | ||
3176 | + } | ||
3177 | + | ||
3178 | + /* Check whether a new timestamp available? */ | ||
3179 | + IOH_DEBUG("ioh_1588_ptp_can_poll:invoking ioh_1588_can_snap_valid\n"); | ||
3180 | + valid = ioh_1588_can_snap_valid(); | ||
3181 | + | ||
3182 | + /* there is not a valid timestamp */ | ||
3183 | + if (TRUE != valid) { | ||
3184 | + IOH_DEBUG("ioh_1588_ptp_can_poll:no valid timestamp\ | ||
3185 | + returning IOH_1588_NOTIMESTAMP\n"); | ||
3186 | + return IOH_1588_NOTIMESTAMP; | ||
3187 | + } | ||
3188 | + | ||
3189 | + /* check overrun bit before retreiving timestamp */ | ||
3190 | + IOH_DEBUG("ioh_1588_ptp_can_poll:invoking ioh_1588_can_snap_ovr\n"); | ||
3191 | + overrun = ioh_1588_can_snap_ovr(); | ||
3192 | + | ||
3193 | + /* if the timestamp has been overwritten */ | ||
3194 | + if (TRUE == overrun) { | ||
3195 | + IOH_DEBUG("ioh_1588_ptp_can_poll:overrun occured\n"); | ||
3196 | + /* reset valid and overrun bits */ | ||
3197 | + IOH_DEBUG | ||
3198 | + ("ioh_1588_ptp_can_poll:invoking \ | ||
3199 | + ioh_1588_can_snap_valid_clear\n"); | ||
3200 | + ioh_1588_can_snap_valid_clear(); | ||
3201 | + IOH_DEBUG | ||
3202 | + ("ioh_1588_ptp_can_poll:invoking \ | ||
3203 | + ioh_1588_can_snap_ovr_clear\n"); | ||
3204 | + ioh_1588_can_snap_ovr_clear(); | ||
3205 | + | ||
3206 | + /* return no valid timestamp available */ | ||
3207 | + ptpTimeStamp->timeValueLowWord = 0; | ||
3208 | + ptpTimeStamp->timeValueHighWord = 0; | ||
3209 | + | ||
3210 | + IOH_DEBUG | ||
3211 | + ("ioh_1588_ptp_can_poll:returning IOH_1588_NOTIMESTAMP\n"); | ||
3212 | + return IOH_1588_NOTIMESTAMP; | ||
3213 | + } | ||
3214 | + | ||
3215 | + /* Fetch the receive timestamp */ | ||
3216 | + ioh_1588_can_snap_get(&ptpTimeStamp->timeValueLowWord, | ||
3217 | + &ptpTimeStamp->timeValueHighWord); | ||
3218 | + IOH_DEBUG("ioh_1588_ptp_can_poll:timestamp-low=%lx,high=%lx\n", | ||
3219 | + ptpTimeStamp->timeValueLowWord, | ||
3220 | + ptpTimeStamp->timeValueHighWord); | ||
3221 | + | ||
3222 | + /* check overrun bit again to ensure timestamp is valid */ | ||
3223 | + overrun = ioh_1588_can_snap_ovr(); | ||
3224 | + | ||
3225 | + /* if the timestamp has been overwritten */ | ||
3226 | + if (TRUE == overrun) { | ||
3227 | + IOH_DEBUG("ioh_1588_ptp_can_poll:overrun occured\n"); | ||
3228 | + /* reset valid and overrun bits */ | ||
3229 | + IOH_DEBUG | ||
3230 | + ("ioh_1588_ptp_can_poll:invoking \ | ||
3231 | + ioh_1588_can_snap_valid_clear\n"); | ||
3232 | + ioh_1588_can_snap_valid_clear(); | ||
3233 | + IOH_DEBUG | ||
3234 | + ("ioh_1588_ptp_can_poll:invoking \ | ||
3235 | + ioh_1588_can_snap_ovr_clear\n"); | ||
3236 | + ioh_1588_can_snap_ovr_clear(); | ||
3237 | + | ||
3238 | + /* return no valid timestamp available */ | ||
3239 | + ptpTimeStamp->timeValueLowWord = 0; | ||
3240 | + ptpTimeStamp->timeValueHighWord = 0; | ||
3241 | + | ||
3242 | + IOH_DEBUG | ||
3243 | + ("ioh_1588_ptp_can_poll:returning IOH_1588_NOTIMESTAMP\n"); | ||
3244 | + return IOH_1588_NOTIMESTAMP; | ||
3245 | + } | ||
3246 | + | ||
3247 | + /* reset valid bit */ | ||
3248 | + IOH_DEBUG | ||
3249 | + ("ioh_1588_ptp_can_poll:invoking ioh_1588_can_snap_valid_clear\n"); | ||
3250 | + ioh_1588_can_snap_valid_clear(); | ||
3251 | + | ||
3252 | + return IOH_1588_SUCCESS; | ||
3253 | +} | ||
3254 | + | ||
3255 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3256 | + * @fn enum ioh_status ioh_1588_handler(void) | ||
3257 | + * | ||
3258 | + * @brief Interrupt handler for the IEEE 1588 module | ||
3259 | + * | ||
3260 | + * @remarks Interrupt handler for the IEEE 1588 module | ||
3261 | + * The Interrupts are handled in the following order | ||
3262 | + * - 1 - Target Time Reached/Hit Condition | ||
3263 | + * - 2 - Auxiliary Master Timestamp | ||
3264 | + * - 3 - Auxiliary Slave Timestamp | ||
3265 | + * - 4 - pulse per second | ||
3266 | + * | ||
3267 | + * @retval enum ioh_status | ||
3268 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3269 | + */ | ||
3270 | +enum ioh_status ioh_1588_handler(void) | ||
3271 | +{ | ||
3272 | + struct ioh1588TimeValue tgt_time = { 0, 0 }; | ||
3273 | + struct ioh1588TimeValue aux_time = { 0, 0 }; | ||
3274 | + unsigned long pps; | ||
3275 | + | ||
3276 | + /* If valid callbacks are available process each interrupt */ | ||
3277 | + | ||
3278 | + /* Handle Target Time Reached or Exceeded Interrupt */ | ||
3279 | + if ((NULL != ioh_tt_cbptr) && (TRUE == ioh_1588_ttm_evt_get())) { | ||
3280 | + IOH_DEBUG | ||
3281 | + ("ioh_1588_handler:Target Time Reached or Exceeded \ | ||
3282 | + Interrupt\n"); | ||
3283 | + IOH_DEBUG("ioh_1588_handler:invoking ioh_1588_ttm_imask_clear\ | ||
3284 | + to disable interrupts\n"); | ||
3285 | + /* Disable interrupt */ | ||
3286 | + ioh_1588_ttm_imask_clear(); | ||
3287 | + | ||
3288 | + /* Target Time registers contents */ | ||
3289 | + ioh_1588_tgt_snap_get(&tgt_time.timeValueLowWord, | ||
3290 | + &tgt_time.timeValueHighWord); | ||
3291 | + IOH_DEBUG("ioh_1588_handler:target time-low=%lx,high=%lx\n", | ||
3292 | + tgt_time.timeValueLowWord, | ||
3293 | + tgt_time.timeValueHighWord); | ||
3294 | + | ||
3295 | + IOH_DEBUG("ioh_1588_handler:invoking callback\n"); | ||
3296 | + /* Invoke client callback */ | ||
3297 | + (*ioh_tt_cbptr) (tgt_time); | ||
3298 | + | ||
3299 | + /* Clear the target time reached condition (ttipend bit) */ | ||
3300 | + IOH_DEBUG("ioh_1588_handler:invoking ioh_1588_ttm_evt_clear\n"); | ||
3301 | + ioh_1588_ttm_evt_clear(); | ||
3302 | + } | ||
3303 | + | ||
3304 | + /* Handle Auxiliary Master Mode Snapshot Interrupt */ | ||
3305 | + if ((NULL != ioh_am_cbptr) && (TRUE == ioh_1588_amms_evt_get())) { | ||
3306 | + IOH_DEBUG | ||
3307 | + ("ioh_1588_handler:Auxiliary Master Mode Snapshot Interrupt\n"); | ||
3308 | + /* Disable interrupt */ | ||
3309 | + IOH_DEBUG("ioh_1588_handler:invoking ioh_1588_amms_imask_clear\ | ||
3310 | + to disable interrupts\n"); | ||
3311 | + ioh_1588_amms_imask_clear(); | ||
3312 | + | ||
3313 | + /* Fetch Auxiliary Master Mode Snapshot */ | ||
3314 | + ioh_1588_aux_master_snap_get(&aux_time.timeValueLowWord, | ||
3315 | + &aux_time.timeValueHighWord); | ||
3316 | + IOH_DEBUG | ||
3317 | + ("ioh_1588_handler:Auxiliary Master Mode Snapshot-low=%lx,\ | ||
3318 | + high=%lx\n", | ||
3319 | + aux_time.timeValueLowWord, aux_time.timeValueHighWord); | ||
3320 | + | ||
3321 | + IOH_DEBUG("ioh_1588_handler:invoking callback\n"); | ||
3322 | + /* Return Auxiliary Master Mode Snapshot */ | ||
3323 | + (*ioh_am_cbptr) (IOH_1588_AUXMODE_MASTER, aux_time); | ||
3324 | + | ||
3325 | + /* Clear the snapshot availability condition */ | ||
3326 | + IOH_DEBUG | ||
3327 | + ("ioh_1588_handler:invoking ioh_1588_amms_evt_clear\n"); | ||
3328 | + ioh_1588_amms_evt_clear(); | ||
3329 | + } | ||
3330 | + | ||
3331 | + /* Handle Auxiliary Slave Mode Snapshot Interrupt */ | ||
3332 | + if ((NULL != ioh_as_cbptr) && (TRUE == ioh_1588_asms_evt_get())) { | ||
3333 | + IOH_DEBUG | ||
3334 | + ("ioh_1588_handler:Auxiliary Slave Mode Snapshot Interrupt\n"); | ||
3335 | + /* Disable interrupt */ | ||
3336 | + IOH_DEBUG("ioh_1588_handler:invoking ioh_1588_asms_imask_clear\ | ||
3337 | + to disable interrupts\n"); | ||
3338 | + ioh_1588_asms_imask_clear(); | ||
3339 | + | ||
3340 | + /* Fetch Auxiliary Slave Mode Snapshot */ | ||
3341 | + ioh_1588_aux_slave_snap_get(&aux_time.timeValueLowWord, | ||
3342 | + &aux_time.timeValueHighWord); | ||
3343 | + IOH_DEBUG | ||
3344 | + ("ioh_1588_handler:Auxiliary Master Mode Snapshot-low=%lx,\ | ||
3345 | + high=%lx\n", | ||
3346 | + aux_time.timeValueLowWord, aux_time.timeValueHighWord); | ||
3347 | + | ||
3348 | + /* Return Auxiliary Slave Mode Snapshot */ | ||
3349 | + IOH_DEBUG("ioh_1588_handler:invoking callback\n"); | ||
3350 | + (*ioh_as_cbptr) (IOH_1588_AUXMODE_SLAVE, aux_time); | ||
3351 | + | ||
3352 | + /* Clear the snapshot availability condition */ | ||
3353 | + IOH_DEBUG | ||
3354 | + ("ioh_1588_handler:invoking ioh_1588_asms_evt_clear\n"); | ||
3355 | + ioh_1588_asms_evt_clear(); | ||
3356 | + } | ||
3357 | + | ||
3358 | + /* Handle Pulse Per Second Interrupt */ | ||
3359 | + if ((NULL != ioh_pps_cbptr) && (TRUE == ioh_1588_pps_evt_get())) { | ||
3360 | + IOH_DEBUG("ioh_1588_handler:Pulse Per Second Interrupt\n"); | ||
3361 | + /* Disable interrupt */ | ||
3362 | + IOH_DEBUG("ioh_1588_handler:invoking ioh_1588_pps_imask_clear\ | ||
3363 | + to disable interrupts\n"); | ||
3364 | + ioh_1588_pps_imask_clear(); | ||
3365 | + | ||
3366 | + /* Fetch PPS compare register */ | ||
3367 | + IOH_DEBUG("ioh_1588_handler:invoking ioh_1588_pps_get\n"); | ||
3368 | + ioh_1588_pps_get(&pps); | ||
3369 | + | ||
3370 | + /* Invoke the call back */ | ||
3371 | + IOH_DEBUG("ioh_1588_handler:invoking callback\n"); | ||
3372 | + (*ioh_pps_cbptr) (pps); | ||
3373 | + | ||
3374 | + /* Clear the snapshot availability condition */ | ||
3375 | + IOH_DEBUG("ioh_1588_handler:invoking ioh_1588_pps_evt_clear\n"); | ||
3376 | + ioh_1588_pps_evt_clear(); | ||
3377 | + | ||
3378 | + } | ||
3379 | + | ||
3380 | + return IOH_1588_SUCCESS; | ||
3381 | +} | ||
3382 | + | ||
3383 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3384 | + * @fn enum ioh_status ioh_1588_ptp_version_get( | ||
3385 | + * enum ioh1588PTPPort ptpPort, enum ioh1588PTPVersion *ptpVersion) | ||
3386 | + * | ||
3387 | + * @brief Retrieves IEEE 1588 PTP version supported on the given PTP port. | ||
3388 | + * | ||
3389 | + * @remarks This API retrieves IEEE 1588 PTP version supported on given PTP | ||
3390 | + * port. | ||
3391 | + * The main steps followed in this function are: | ||
3392 | + * - Return IOH_1588_INVALIDPARAM if ptpPort passed is not valid or | ||
3393 | + * ptpVersion passed is NULL | ||
3394 | + * - Ensure that the module is initialized and the port is valid | ||
3395 | + * - Return the PTP version that is supported from the | ||
3396 | + * TS_Channel_Control register, bit 31 | ||
3397 | + * | ||
3398 | + * | ||
3399 | + * @param ptpPort [IN] PTP port | ||
3400 | + * @param ptpVersion [OUT] Version supported on PTP port | ||
3401 | + * | ||
3402 | + * | ||
3403 | + * @retval enum ioh_status | ||
3404 | + * @li IOH_1588_SUCCESS - Operation is successful | ||
3405 | + * @li IOH_1588_INVALIDPARAM - Invalid parameters passed | ||
3406 | + */ | ||
3407 | +enum ioh_status | ||
3408 | +ioh_1588_ptp_version_get(enum ioh1588PTPPort ptpPort, \ | ||
3409 | + enum ioh1588PTPVersion *ptpVersion) | ||
3410 | +{ | ||
3411 | + /* Verify the parameters for proper values */ | ||
3412 | + if ((ptpPort != IOH_1588_GBE_0_1588PTP_PORT) || (ptpVersion == NULL)) { | ||
3413 | + IOH_DEBUG("ioh_1588_ptp_version_get:invalid params\ | ||
3414 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3415 | + return IOH_1588_INVALIDPARAM; | ||
3416 | + } | ||
3417 | + | ||
3418 | + IOH_DEBUG("ioh_1588_ptp_version_get:invoking ioh_1588_version_get\n"); | ||
3419 | + *ptpVersion = ioh_1588_version_get(); | ||
3420 | + | ||
3421 | + return IOH_1588_SUCCESS; | ||
3422 | +} | ||
3423 | + | ||
3424 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3425 | + * @fn enum ioh_status ioh_1588_ptp_version_set( | ||
3426 | + * enum ioh1588PTPPort ptpPort, | ||
3427 | + * enum ioh1588PTPVersion ptpVersion) | ||
3428 | + * | ||
3429 | + * @brief Configures IEEE 1588 PTP version to be used on given PTP port. | ||
3430 | + * | ||
3431 | + * @remarks This API set the IEEE 1588 PTP version to be used on given PTP | ||
3432 | + * port. | ||
3433 | + * The main steps followed in this function are: | ||
3434 | + * - Validate parameter | ||
3435 | + * - Ensure that the module is initialized and the version | ||
3436 | + * requested is valid | ||
3437 | + * - Set the version in TS_Channel_Control register, bit 31 | ||
3438 | + * | ||
3439 | + * | ||
3440 | + * @param ptpPort [IN] PTP port | ||
3441 | + * @param ptpVersion [IN] Version to be supported on PTP port | ||
3442 | + * | ||
3443 | + * | ||
3444 | + * @retval enum ioh_status | ||
3445 | + * @li IOH_1588_SUCCESS - Operation is successful | ||
3446 | + * @li IOH_1588_INVALIDPARAM - Invalid parameters passed | ||
3447 | + */ | ||
3448 | +enum ioh_status | ||
3449 | +ioh_1588_ptp_version_set(enum ioh1588PTPPort ptpPort, \ | ||
3450 | + enum ioh1588PTPVersion ptpVersion) | ||
3451 | +{ | ||
3452 | + /* Verify the parameters for proper values */ | ||
3453 | + if ((ptpPort != IOH_1588_GBE_0_1588PTP_PORT) || | ||
3454 | + ((ptpVersion != IOH_1588PTP_VERSION_0) && | ||
3455 | + (ptpVersion != IOH_1588PTP_VERSION_1))) { | ||
3456 | + IOH_DEBUG("ioh_1588_ptp_version_set:invalid params\ | ||
3457 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3458 | + return IOH_1588_INVALIDPARAM; | ||
3459 | + } | ||
3460 | + | ||
3461 | + IOH_DEBUG("ioh_1588_ptp_version_get:invoking ioh_1588_version_set\n"); | ||
3462 | + ioh_1588_version_set(ptpVersion); | ||
3463 | + | ||
3464 | + return IOH_1588_SUCCESS; | ||
3465 | +} | ||
3466 | + | ||
3467 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3468 | + * @fn enum ioh_status ioh_1588_ptp_operation_mode_set( | ||
3469 | + * enum ioh1588PTPPort ptpPort, | ||
3470 | + * enum ioh1588PTPOperationMode ptpMode) | ||
3471 | + * | ||
3472 | + * @brief Configure the IEEE 1588 PTP operation mode of given PTP port. | ||
3473 | + * | ||
3474 | + * @remarks This API will set the operation mode on given PTP port. | ||
3475 | + * The main steps followed in this function are: | ||
3476 | + * - Ensure that the module is initialized and the mode requested | ||
3477 | + * is valid | ||
3478 | + * - If not valid, return status IOH_1588_INVALIDPARAM | ||
3479 | + * - Set the requested operation mode in TS_Channel_Control | ||
3480 | + * register, bits 16-20 | ||
3481 | + * | ||
3482 | + * | ||
3483 | + * @param ptpPort [IN] PTP port to configure | ||
3484 | + * @param ptpMode [IN] Operation mode to be used | ||
3485 | + * | ||
3486 | + * | ||
3487 | + * @retval enum ioh_status | ||
3488 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3489 | + * @li IOH_1588_INVALIDPARAM - Invalid parameters passed | ||
3490 | + */ | ||
3491 | +enum ioh_status | ||
3492 | +ioh_1588_ptp_operation_mode_set(enum ioh1588PTPPort ptpPort, | ||
3493 | + enum ioh1588PTPOperationMode ptpMode) | ||
3494 | +{ | ||
3495 | + /* Verify the parameters for proper values */ | ||
3496 | + if ((ptpPort != IOH_1588_GBE_0_1588PTP_PORT) || | ||
3497 | + ((ptpMode != IOH_1588PTP_OP_MODE_SYNC_DELAYREQ_MSGS) && | ||
3498 | + (ptpMode != IOH_1588PTP_OP_MODE_V1_ALL_MSGS) && | ||
3499 | + (ptpMode != IOH_1588PTP_OP_MODE_V1_V2_EVENT_MSGS) && | ||
3500 | + (ptpMode != IOH_1588PTP_OP_MODE_V1_V2_ALL_MSGS))) { | ||
3501 | + IOH_DEBUG("ioh_1588_ptp_operation_mode_set:invalid params\ | ||
3502 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3503 | + return IOH_1588_INVALIDPARAM; | ||
3504 | + } | ||
3505 | + | ||
3506 | + IOH_DEBUG("ioh_1588_ptp_version_get:invoking ioh_1588_op_mode_set\n"); | ||
3507 | + ioh_1588_op_mode_set(ptpMode); | ||
3508 | + | ||
3509 | + return IOH_1588_SUCCESS; | ||
3510 | +} | ||
3511 | + | ||
3512 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3513 | + * @fn enum ioh_status ioh_1588_ptp_operation_mode_get( | ||
3514 | + * enum ioh1588PTPPort ptpPort, | ||
3515 | + * enum ioh1588PTPOperationMode *ptpMode) | ||
3516 | + * | ||
3517 | + * @brief Gets the current PTP operation mode of given PTP port. | ||
3518 | + * | ||
3519 | + * @remarks This API will get the operation mode of given PTP port. | ||
3520 | + * The main steps followed in this function are: | ||
3521 | + * - Ensure that the module is initialized and the port is valid | ||
3522 | + * - If not valid, return status IOH_1588_INVALIDPARAM | ||
3523 | + * - Return the PTP operation mode that is currently in use by | ||
3524 | + * reading the TS_Channel_Control register, bits 16-20 | ||
3525 | + * | ||
3526 | + * | ||
3527 | + * @param ptpPort [IN] PTP port to configure | ||
3528 | + * @param ptpMode [OUT] Address where PTP operation mode is | ||
3529 | + * returned | ||
3530 | + * | ||
3531 | + * | ||
3532 | + * @retval enum ioh_status | ||
3533 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3534 | + * @li IOH_1588_INVALIDPARAM - Null parameter passed | ||
3535 | + */ | ||
3536 | +enum ioh_status | ||
3537 | +ioh_1588_ptp_operation_mode_get(enum ioh1588PTPPort ptpPort, | ||
3538 | + enum ioh1588PTPOperationMode *ptpMode) | ||
3539 | +{ | ||
3540 | + /* Verify the parameters for proper values */ | ||
3541 | + if ((ptpPort != IOH_1588_GBE_0_1588PTP_PORT) || (ptpMode == NULL)) { | ||
3542 | + IOH_DEBUG("ioh_1588_ptp_operation_mode_get:invalid params\ | ||
3543 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3544 | + return IOH_1588_INVALIDPARAM; | ||
3545 | + } | ||
3546 | + | ||
3547 | + IOH_DEBUG | ||
3548 | + ("ioh_1588_ptp_operation_mode_get:invoking ioh_1588_op_mode_get\n"); | ||
3549 | + *ptpMode = ioh_1588_op_mode_get(); | ||
3550 | + | ||
3551 | + return IOH_1588_SUCCESS; | ||
3552 | +} | ||
3553 | + | ||
3554 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3555 | + * @fn enum ioh_status ioh_1588_pulse_per_sec_interrupt_enable( | ||
3556 | + * ioh1588PulsePerSecondCallback callBack) | ||
3557 | + * | ||
3558 | + * @brief Enable the Pulse Per Second match interrupt | ||
3559 | + * | ||
3560 | + * @remarks This API will enable the Pulse Per Second match interrupt. | ||
3561 | + * This interrupt is generated when the low word of System | ||
3562 | + * Time matches the value in the Pulse Per Second compare | ||
3563 | + * register in the IEEE hardware assist block. The main steps | ||
3564 | + * followed in this function are: | ||
3565 | + * - Return IOH_1588_INVALIDPARAM if argument passed is NULL | ||
3566 | + * - Modify the Time Sync Controller register to enable the | ||
3567 | + * interrupt | ||
3568 | + * - Set the callback routine | ||
3569 | + * | ||
3570 | + * @param callBack [IN] Routine to be invoked when interrupt | ||
3571 | + * fires | ||
3572 | + * | ||
3573 | + * @retval enum ioh_status | ||
3574 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3575 | + * @li IOH_1588_INVALIDPARAM - Null parameter passed | ||
3576 | + */ | ||
3577 | +enum ioh_status | ||
3578 | +ioh_1588_pulse_per_sec_interrupt_enable(ioh1588PulsePerSecondCallback callBack) | ||
3579 | +{ | ||
3580 | + /* Verify the parameter */ | ||
3581 | + if ((ioh1588PulsePerSecondCallback) NULL == callBack) { | ||
3582 | + IOH_DEBUG | ||
3583 | + ("ioh_1588_pulse_per_sec_interrupt_enable:invalid params\ | ||
3584 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3585 | + return IOH_1588_INVALIDPARAM; | ||
3586 | + } | ||
3587 | + | ||
3588 | + /* Register the Callback */ | ||
3589 | + ioh_pps_cbptr = callBack; | ||
3590 | + | ||
3591 | + /* Set target time interrupt mask */ | ||
3592 | + IOH_DEBUG("ioh_1588_pulse_per_sec_interrupt_enable:invoking \ | ||
3593 | + ioh_1588_pps_imask_set\n"); | ||
3594 | + ioh_1588_pps_imask_set(); | ||
3595 | + | ||
3596 | + return IOH_1588_SUCCESS; | ||
3597 | +} | ||
3598 | + | ||
3599 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3600 | + * @fn enum ioh_status ioh_1588_pulse_per_sec_interrupt_disable(void) | ||
3601 | + * | ||
3602 | + * @brief Disable the Pulse Per Second match interrupt | ||
3603 | + * | ||
3604 | + * @remarks This API will disable the Pulse Per Second match interrupt. | ||
3605 | + * This interrupt is generated when the low word of System | ||
3606 | + * Time matches the value in the Pulse Per Second compare | ||
3607 | + * register in the IEEE hardware assist block. The main | ||
3608 | + * steps followed in this function are: | ||
3609 | + * - Modify the Time Sync Controller register to disable the | ||
3610 | + * interrupt | ||
3611 | + * - Clear the callback routine | ||
3612 | + * | ||
3613 | + * @param None | ||
3614 | + * | ||
3615 | + * @retval enum ioh_status | ||
3616 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3617 | + */ | ||
3618 | +enum ioh_status ioh_1588_pulse_per_sec_interrupt_disable(void) | ||
3619 | +{ | ||
3620 | + /* Clear pulse per second interrupt mask */ | ||
3621 | + IOH_DEBUG("ioh_1588_pulse_per_sec_interrupt_disable:invoking \ | ||
3622 | + ioh_1588_pps_imask_clear\n"); | ||
3623 | + ioh_1588_pps_imask_clear(); | ||
3624 | + | ||
3625 | + /* Unregister the Callback */ | ||
3626 | + ioh_pps_cbptr = (ioh1588PulsePerSecondCallback) NULL; | ||
3627 | + | ||
3628 | + return IOH_1588_SUCCESS; | ||
3629 | +} | ||
3630 | + | ||
3631 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3632 | + * @fn enum ioh_status ioh_1588_pulse_per_sec_time_set(unsigned long | ||
3633 | + * ppsTime) | ||
3634 | + * | ||
3635 | + * @brief Sets the Pulse Per Second match time in the IEEE 1588 hardware | ||
3636 | + * assist block | ||
3637 | + * | ||
3638 | + * @remarks This API will set the PPS match register with the value supplied | ||
3639 | + * The main steps followed in this function are: | ||
3640 | + * - Return IOH_1588_INVALIDPARAM if argument passed is NULL | ||
3641 | + * - Set the time in PPS Compare Register | ||
3642 | + * | ||
3643 | + * | ||
3644 | + * @param ppsTime [IN] Value to be stored in pps match register | ||
3645 | + * | ||
3646 | + * | ||
3647 | + * @retval enum ioh_status | ||
3648 | + * @li IOH_1588_SUCCESS - Operation is successful | ||
3649 | + * @li IOH_1588_INVALIDPARAM - Null parameter passed | ||
3650 | + */ | ||
3651 | +enum ioh_status ioh_1588_pulse_per_sec_time_set(unsigned long ppsTime) | ||
3652 | +{ | ||
3653 | + unsigned long old_mask = FALSE; | ||
3654 | + | ||
3655 | + /* Retrieve existing pps mask value */ | ||
3656 | + old_mask = ioh_1588_pps_imask_get(); | ||
3657 | + IOH_DEBUG | ||
3658 | + ("ioh_1588_pulse_per_sec_time_set:target time interrupt mask=%lx\n", | ||
3659 | + old_mask); | ||
3660 | + | ||
3661 | + /* | ||
3662 | + * Clear the pps time interrupt mask so that the interrupt will not come | ||
3663 | + * during the time we manipulate the registers. | ||
3664 | + */ | ||
3665 | + IOH_DEBUG | ||
3666 | + ("ioh_1588_pulse_per_sec_time_set:invoking ioh_1588_pps_imask_clear\ | ||
3667 | + to clear the pps interrupt mask\n"); | ||
3668 | + ioh_1588_pps_imask_clear(); | ||
3669 | + | ||
3670 | + /* Update the PPS time */ | ||
3671 | + IOH_DEBUG | ||
3672 | + ("ioh_1588_pulse_per_sec_time_set:invoking ioh_1588_pps_set\n"); | ||
3673 | + | ||
3674 | + ioh_1588_pps_set(ppsTime); | ||
3675 | + | ||
3676 | + /* | ||
3677 | + * Let the hardware assist re-evaluate the pps reached | ||
3678 | + * condition based on the new pps value | ||
3679 | + */ | ||
3680 | + IOH_DEBUG | ||
3681 | + ("ioh_1588_pulse_per_sec_time_set:invoking ioh_1588_pps_evt_clear\n"); | ||
3682 | + ioh_1588_pps_evt_clear(); | ||
3683 | + | ||
3684 | + /* Restore the preserved pps interrupt mask value */ | ||
3685 | + if (TRUE == old_mask) { | ||
3686 | + IOH_DEBUG | ||
3687 | + ("ioh_1588_pulse_per_sec_time_set:invoking \ | ||
3688 | + ioh_1588_pps_imask_set\n"); | ||
3689 | + ioh_1588_pps_imask_set(); | ||
3690 | + } | ||
3691 | + | ||
3692 | + IOH_DEBUG | ||
3693 | + ("ioh_1588_pulse_per_sec_time_set:returning IOH_1588_SUCCESS\n"); | ||
3694 | + return IOH_1588_SUCCESS; | ||
3695 | +} | ||
3696 | + | ||
3697 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3698 | + * @fn enum ioh_status ioh_1588_pulse_per_sec_time_get( | ||
3699 | + * unsigned long *ppsTime) | ||
3700 | + * | ||
3701 | + * @brief Gets the Pulse Per Second match time from the IEEE 1588 hardware | ||
3702 | + * assist block | ||
3703 | + * | ||
3704 | + * @remarks This API will get the PPS match register content | ||
3705 | + * from IEEE 1588 block. The main steps followed in this | ||
3706 | + * function are: | ||
3707 | + * - Return IOH_1588_INVALIDPARAM if argument passed is NULL | ||
3708 | + * - Return the time from PPS compare register | ||
3709 | + * | ||
3710 | + * | ||
3711 | + * @param ppsTime [OUT] Buffer for returning the pps match value | ||
3712 | + * | ||
3713 | + * | ||
3714 | + * @retval enum ioh_status | ||
3715 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3716 | + * @li IOH_1588_INVALIDPARAM - Null parameter passed | ||
3717 | + */ | ||
3718 | +enum ioh_status ioh_1588_pulse_per_sec_time_get(unsigned long *ppsTime) | ||
3719 | +{ | ||
3720 | + /* Verify the parameter */ | ||
3721 | + if ((unsigned long *)NULL == ppsTime) { | ||
3722 | + IOH_DEBUG("ioh_1588_pulse_per_sec_time_get:invalid params\ | ||
3723 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3724 | + return IOH_1588_INVALIDPARAM; | ||
3725 | + } | ||
3726 | + | ||
3727 | + /* Retrieve PPS Value */ | ||
3728 | + IOH_DEBUG | ||
3729 | + ("ioh_1588_pulse_per_sec_time_get:invoking ioh_1588_pps_get\n"); | ||
3730 | + ioh_1588_pps_get(ppsTime); | ||
3731 | + | ||
3732 | + return IOH_1588_SUCCESS; | ||
3733 | +} | ||
3734 | + | ||
3735 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3736 | + * @fn enum ioh_status ioh_1588_eth_enable(void) | ||
3737 | + * | ||
3738 | + * @brief Sets the eth_enb bit (bit 0) of Ethernet-CAN Select Register | ||
3739 | + * @remarks This API enables the IEEE 1588 hardware time stamping of PTP | ||
3740 | + * traffic | ||
3741 | + * on the Ethernet interface | ||
3742 | + * | ||
3743 | + * @param None | ||
3744 | + * | ||
3745 | + * @retval enum ioh_status | ||
3746 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3747 | + */ | ||
3748 | +enum ioh_status ioh_1588_eth_enable(void) | ||
3749 | +{ | ||
3750 | + if (ioh_1588_base != 0) { | ||
3751 | + IOH_DEBUG | ||
3752 | + ("ioh_1588_eth_enable:invoking ioh_1588_eth_enable_set\n"); | ||
3753 | + ioh_1588_eth_enable_set(); | ||
3754 | + } | ||
3755 | + | ||
3756 | + return IOH_1588_SUCCESS; | ||
3757 | +} | ||
3758 | + | ||
3759 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3760 | + * @fn enum ioh_status ioh_1588_eth_disable(void) | ||
3761 | + * | ||
3762 | + * @brief Clears the eth_enb bit (bit 0) of Ethernet-CAN Select Register | ||
3763 | + * @remarks This API disables the IEEE 1588 hardware time stamping of PTP | ||
3764 | + * traffic | ||
3765 | + * on the Ethernet interface | ||
3766 | + * | ||
3767 | + * @param None | ||
3768 | + * | ||
3769 | + * @retval enum ioh_status | ||
3770 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3771 | + */ | ||
3772 | +enum ioh_status ioh_1588_eth_disable(void) | ||
3773 | +{ | ||
3774 | + if (ioh_1588_base != 0) { | ||
3775 | + IOH_DEBUG | ||
3776 | + ("ioh_1588_eth_disable:invoking ioh_1588_eth_enable_clear\n"); | ||
3777 | + ioh_1588_eth_enable_clear(); | ||
3778 | + } | ||
3779 | + | ||
3780 | + return IOH_1588_SUCCESS; | ||
3781 | +} | ||
3782 | + | ||
3783 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3784 | + * @fn enum ioh_status ioh_1588_can_enable(void) | ||
3785 | + * | ||
3786 | + * @brief Sets the can_enb bit (bit 1) of Ethernet-CAN Select Register | ||
3787 | + * @remraks This API enables the IEEE 1588 hardware time stamping of PTP | ||
3788 | + * traffic | ||
3789 | + * on the CAN interface | ||
3790 | + * | ||
3791 | + * @param None | ||
3792 | + * | ||
3793 | + * @retval enum ioh_status | ||
3794 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3795 | + */ | ||
3796 | +enum ioh_status ioh_1588_can_enable(void) | ||
3797 | +{ | ||
3798 | + if (ioh_1588_base != 0) { | ||
3799 | + IOH_DEBUG | ||
3800 | + ("ioh_1588_can_enable:invoking ioh_1588_can_enable_set\n"); | ||
3801 | + ioh_1588_can_enable_set(); | ||
3802 | + } | ||
3803 | + | ||
3804 | + return IOH_1588_SUCCESS; | ||
3805 | +} | ||
3806 | + | ||
3807 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3808 | + * @fn enum ioh_status ioh_1588_can_disable(void) | ||
3809 | + * | ||
3810 | + * @brief Clear the can_enb bit (bit 1) of Ethernet-CAN Select Register | ||
3811 | + * @remarks This API disables the IEEE 1588 hardware time stamping of PTP | ||
3812 | + * traffic | ||
3813 | + * on the CAN interface | ||
3814 | + * | ||
3815 | + * @param None | ||
3816 | + * | ||
3817 | + * @retval enum ioh_status | ||
3818 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3819 | + */ | ||
3820 | +enum ioh_status ioh_1588_can_disable(void) | ||
3821 | +{ | ||
3822 | + if (ioh_1588_base != 0) { | ||
3823 | + IOH_DEBUG | ||
3824 | + ("ioh_1588_can_disable:invoking ioh_1588_can_enable_clear\n"); | ||
3825 | + ioh_1588_can_enable_clear(); | ||
3826 | + } | ||
3827 | + | ||
3828 | + return IOH_1588_SUCCESS; | ||
3829 | +} | ||
3830 | + | ||
3831 | +/** | ||
3832 | + * @ingroup IEEE_1588_UtilitiesAPI | ||
3833 | + * @fn static int get_decimal(unsigned char ch) | ||
3834 | + * | ||
3835 | + * @brief Returns the decimal value of the passed | ||
3836 | + * hexadecimal value. | ||
3837 | + * | ||
3838 | + * @note Returns -1 if the passed arguement is invalid. | ||
3839 | + * | ||
3840 | + * @param ch [IN] The hexadecimal value that has to be converted. | ||
3841 | + * | ||
3842 | + * @retval int | ||
3843 | + * - On Success --> decimal Value | ||
3844 | + * - Invalid value --> -1 | ||
3845 | + */ | ||
3846 | +static int get_decimal(unsigned char ch) | ||
3847 | +{ | ||
3848 | + int ret; | ||
3849 | + | ||
3850 | + if ((ch >= '0') && (ch <= '9')) { | ||
3851 | + ret = ch - '0'; | ||
3852 | + return ret; | ||
3853 | + } else if ((ch >= 'A') && (ch <= 'F')) { | ||
3854 | + ret = 10 + ch - 'A'; | ||
3855 | + return ret; | ||
3856 | + } else if ((ch >= 'a') && (ch <= 'f')) { | ||
3857 | + ret = 10 + ch - 'a'; | ||
3858 | + return ret; | ||
3859 | + } | ||
3860 | + | ||
3861 | + return -1; | ||
3862 | +} | ||
3863 | + | ||
3864 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3865 | + * @fn enum ioh_status ioh_1588_set_station_address ( | ||
3866 | + * unsigned char *addr) | ||
3867 | + * | ||
3868 | + * @brief This API sets the station address used by IEEE 1588 hardware | ||
3869 | + * when looking | ||
3870 | + * at PTP traffic on the ethernet interface | ||
3871 | + * | ||
3872 | + * @param addr [IN] Address which contain the column separated | ||
3873 | + * address to be used | ||
3874 | + * @retval enum ioh_status | ||
3875 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3876 | + * @li IOH_1588_INVALIDPARAM - Invalid address string | ||
3877 | + */ | ||
3878 | +enum ioh_status ioh_1588_set_station_address(unsigned char *addr) | ||
3879 | +{ | ||
3880 | + int i; | ||
3881 | + | ||
3882 | + /* Verify the parameter */ | ||
3883 | + if ((ioh_1588_base == 0) || (unsigned char *)NULL == addr) { | ||
3884 | + IOH_DEBUG("ioh_1588_set_station_address :invalid params\ | ||
3885 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3886 | + return IOH_1588_INVALIDPARAM; | ||
3887 | + } | ||
3888 | + | ||
3889 | + for (i = 0; i < IOH_1588_STATION_BYTES; i++) { /* For all station | ||
3890 | + address bytes */ | ||
3891 | + unsigned long val = 0; | ||
3892 | + int tmp; | ||
3893 | + | ||
3894 | + tmp = get_decimal(addr[i * 3]); | ||
3895 | + if (tmp < 0) { | ||
3896 | + IOH_DEBUG("ioh_1588_set_station_address :invalid params\ | ||
3897 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3898 | + return IOH_1588_INVALIDPARAM; | ||
3899 | + } | ||
3900 | + val = tmp * 16; | ||
3901 | + tmp = get_decimal(addr[(i * 3) + 1]); | ||
3902 | + if (tmp < 0) { | ||
3903 | + IOH_DEBUG("ioh_1588_set_station_address :invalid params\ | ||
3904 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3905 | + return IOH_1588_INVALIDPARAM; | ||
3906 | + } | ||
3907 | + val += tmp; | ||
3908 | + if ((i < 5) && (addr[(i * 3) + 2] != ':')) { /* Expects ':' | ||
3909 | + separated addresses */ | ||
3910 | + IOH_DEBUG("ioh_1588_set_station_address :invalid params\ | ||
3911 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3912 | + return IOH_1588_INVALIDPARAM; | ||
3913 | + } | ||
3914 | + | ||
3915 | + /* Ideally we should set the address only after validating | ||
3916 | + entire string */ | ||
3917 | + IOH_DEBUG | ||
3918 | + ("ioh_1588_set_station_address \ | ||
3919 | + :invoking ioh_1588_station_set\n"); | ||
3920 | + ioh_1588_station_set(i, val); | ||
3921 | + } | ||
3922 | + return IOH_1588_SUCCESS; | ||
3923 | +} | ||
3924 | + | ||
3925 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3926 | + * @fn enum ioh_status ioh_1588_get_station_address(char *addr) | ||
3927 | + * @brief This API gets the station address currently used by IEEE 1588 | ||
3928 | + * hardware when looking at PTP traffic on the ethernet interface | ||
3929 | + * | ||
3930 | + * @param addr [OUT] Buffer to which column separated address is | ||
3931 | + * returned | ||
3932 | + * @retval enum ioh_status | ||
3933 | + * @li IOH_1588_SUCCESS - Operation successful | ||
3934 | + * @li IOH_1588_INVALIDPARAM - Null parameter passed | ||
3935 | + */ | ||
3936 | +enum ioh_status ioh_1588_get_station_address(char *addr) | ||
3937 | +{ | ||
3938 | + int i; | ||
3939 | + | ||
3940 | + /* Verify the parameter */ | ||
3941 | + if ((char *)NULL == addr) { | ||
3942 | + IOH_DEBUG("ioh_1588_get_station_address:invalid params\ | ||
3943 | + returning IOH_1588_INVALIDPARAM\n"); | ||
3944 | + return IOH_1588_INVALIDPARAM; | ||
3945 | + } | ||
3946 | + | ||
3947 | + for (i = 0; i < IOH_1588_STATION_BYTES; i++) { | ||
3948 | + unsigned long val = 0; | ||
3949 | + | ||
3950 | + ioh_1588_station_get(i, &val); | ||
3951 | + addr[i * 3] = val / 16; | ||
3952 | + if (addr[i * 3] > 9) | ||
3953 | + addr[i * 3] += 'a' - 10; | ||
3954 | + else | ||
3955 | + addr[i * 3] += '0'; | ||
3956 | + addr[i * 3 + 1] = val % 16; | ||
3957 | + if (addr[i * 3 + 1] > 9) | ||
3958 | + addr[i * 3 + 1] += 'a' - 10; | ||
3959 | + else | ||
3960 | + addr[i * 3 + 1] += '0'; | ||
3961 | + addr[i * 3 + 2] = ':'; | ||
3962 | + } | ||
3963 | + addr[17] = '\0'; | ||
3964 | + return IOH_1588_SUCCESS; | ||
3965 | +} | ||
3966 | + | ||
3967 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3968 | + * @fn enum ioh_status ioh_1588_aux_target_time_interrupt_enable( | ||
3969 | + * void *callBack) | ||
3970 | + * | ||
3971 | + * @brief This API just returns an error. | ||
3972 | + * | ||
3973 | + * @remarks This API is just for compatibility. It just returns an error. | ||
3974 | + * | ||
3975 | + * @param callBack [IN] Callback to be invoked when interrupt | ||
3976 | + * fires | ||
3977 | + * | ||
3978 | + * | ||
3979 | + * @retval enum ioh_status | ||
3980 | + * @li IOH_1588_UNSUPPORTED - Operation is not supported | ||
3981 | + */ | ||
3982 | +enum ioh_status ioh_1588_aux_target_time_interrupt_enable(void *callBack) | ||
3983 | +{ | ||
3984 | + IOH_DEBUG("ioh_1588_aux_target_time_interrupt_enable:unsupported\n"); | ||
3985 | + return IOH_1588_UNSUPPORTED; | ||
3986 | +} | ||
3987 | + | ||
3988 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
3989 | + * @fn enum ioh_status ioh_1588_aux_target_time_interrupt_disable(void) | ||
3990 | + * | ||
3991 | + * @brief This API just returns an error. | ||
3992 | + * | ||
3993 | + * @remarks This API is just for compatibility. It just returns an error. | ||
3994 | + * | ||
3995 | + * @param None | ||
3996 | + * | ||
3997 | + * @retval enum ioh_status | ||
3998 | + * @li IOH_1588_UNSUPPORTED - Operation is not supported | ||
3999 | + */ | ||
4000 | +enum ioh_status ioh_1588_aux_target_time_interrupt_disable(void) | ||
4001 | +{ | ||
4002 | + IOH_DEBUG("ioh_1588_aux_target_time_interrupt_disable:unsupported\n"); | ||
4003 | + return IOH_1588_UNSUPPORTED; | ||
4004 | +} | ||
4005 | + | ||
4006 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4007 | + * @fn enum ioh_status ioh_1588_aux_target_time_poll( | ||
4008 | + * unsigned long *attmPollFlag, | ||
4009 | + * struct ioh1588TimeValue *targetTime) | ||
4010 | + * | ||
4011 | + * @brief This API just returns an error. | ||
4012 | + * | ||
4013 | + * @remarks This API is just for compatibility. It just returns an error. | ||
4014 | + * | ||
4015 | + * @param attmPollFlag [OUT] Flag returning the availablity of a | ||
4016 | + * snapshot | ||
4017 | + * @param targetTime [OUT] Snapshot captured | ||
4018 | + * | ||
4019 | + * | ||
4020 | + * @retval enum ioh_status | ||
4021 | + * @li IOH_1588_UNSUPPORTED - Operation supported | ||
4022 | + */ | ||
4023 | +enum ioh_status | ||
4024 | +ioh_1588_aux_target_time_poll(unsigned long *attmPollFlag, | ||
4025 | + struct ioh1588TimeValue *targetTime) | ||
4026 | +{ | ||
4027 | + IOH_DEBUG("ioh_1588_aux_target_time_poll:unsupported\n"); | ||
4028 | + return IOH_1588_UNSUPPORTED; | ||
4029 | +} | ||
4030 | + | ||
4031 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4032 | + * @fn enum ioh_status ioh_1588_aux_target_time_set( | ||
4033 | + * struct ioh1588TimeValue targetTime) | ||
4034 | + * | ||
4035 | + * @brief This API just returns an error. | ||
4036 | + * | ||
4037 | + * @remarks This API is just for compatibility. It just returns an error. | ||
4038 | + * | ||
4039 | + * @param targetTime [IN] Time to set to | ||
4040 | + * | ||
4041 | + * | ||
4042 | + * @retval enum ioh_status | ||
4043 | + * @li IOH_1588_UNSUPPORTED - Operation supported | ||
4044 | + */ | ||
4045 | +enum ioh_status ioh_1588_aux_target_time_set(struct ioh1588TimeValue targetTime) | ||
4046 | +{ | ||
4047 | + IOH_DEBUG("ioh_1588_aux_target_time_set:unsupported\n"); | ||
4048 | + return IOH_1588_UNSUPPORTED; | ||
4049 | +} | ||
4050 | + | ||
4051 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4052 | + * @fn enum ioh_status ioh_1588_aux_target_time_get( | ||
4053 | + * struct ioh1588TimeValue *targetTime) | ||
4054 | + * | ||
4055 | + * @brief This API just returns an error. | ||
4056 | + * | ||
4057 | + * @remarks This API is just for compatibility. It just returns an error. | ||
4058 | + * | ||
4059 | + * @param targetTime [OUT] Buffer for returning time snapshot | ||
4060 | + * | ||
4061 | + * | ||
4062 | + * @retval enum ioh_status | ||
4063 | + * @li IOH_1588_UNSUPPORTED - Operation supported | ||
4064 | + */ | ||
4065 | +enum ioh_status ioh_1588_aux_target_time_get( | ||
4066 | + struct ioh1588TimeValue *targetTime) | ||
4067 | +{ | ||
4068 | + IOH_DEBUG("ioh_1588_aux_target_time_get:unsupported\n"); | ||
4069 | + return IOH_1588_UNSUPPORTED; | ||
4070 | +} | ||
4071 | + | ||
4072 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4073 | + * | ||
4074 | + * @fn int ioh_1588_eth_can_get(void) | ||
4075 | + * | ||
4076 | + * @brief This function returns the modes [ethernet/CAN] enabled | ||
4077 | + * | ||
4078 | + * @retval int | ||
4079 | + * - the modes enabled | ||
4080 | + */ | ||
4081 | +int ioh_1588_eth_can_get(void) | ||
4082 | +{ | ||
4083 | + int ieee_mode = 0; | ||
4084 | + | ||
4085 | + if (ioh_1588_eth_enable_get() == 1) | ||
4086 | + ieee_mode |= IOH_IEEE1588_ETH; | ||
4087 | + if (ioh_1588_can_enable_get() == 1) | ||
4088 | + ieee_mode |= IOH_IEEE1588_CAN; | ||
4089 | + | ||
4090 | + return ieee_mode; | ||
4091 | +} | ||
4092 | + | ||
4093 | +#ifdef IOH_IEEE1588_A0_A1_SAMPLE_BUG | ||
4094 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4095 | + * | ||
4096 | + * @fn void ioh_1588_set_system_time_count(void) | ||
4097 | + * | ||
4098 | + * @brief This function enables all 64 bits in system time registers | ||
4099 | + * [high & low]. This is a work-around for non continuous value | ||
4100 | + * in the SystemTime Register | ||
4101 | + * | ||
4102 | + * @retval none | ||
4103 | + */ | ||
4104 | +void ioh_1588_set_system_time_count(void) | ||
4105 | +{ | ||
4106 | + IOH_REG_32_WRITE((ioh_1588_base + 0xC0), 0x1); | ||
4107 | + IOH_REG_32_WRITE((ioh_1588_base + 0xC4), 0xFFFFFFFF); | ||
4108 | + IOH_REG_32_WRITE((ioh_1588_base + 0xC0), 0x0); | ||
4109 | +} | ||
4110 | +#endif | ||
4111 | diff -urN linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_hal.h topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_hal.h | ||
4112 | --- linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_hal.h 1970-01-01 09:00:00.000000000 +0900 | ||
4113 | +++ topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_hal.h 2010-03-09 07:40:00.000000000 +0900 | ||
4114 | @@ -0,0 +1,885 @@ | ||
4115 | + /*! | ||
4116 | + * @file ioh_1588_hal.h | ||
4117 | + * @brief | ||
4118 | + * This file lists the declarations of IEEE_1588_HALLayer APIs. | ||
4119 | + * @version 0.92 | ||
4120 | + * @section | ||
4121 | + * This program is free software; you can redistribute it and/or modify | ||
4122 | + * it under the terms of the GNU General Public License as published by | ||
4123 | + * the Free Software Foundation; version 2 of the License. | ||
4124 | + * | ||
4125 | + * This program is distributed in the hope that it will be useful, | ||
4126 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4127 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4128 | + * GNU General Public License for more details. | ||
4129 | + * | ||
4130 | + * You should have received a copy of the GNU General Public License | ||
4131 | + * along with this program; if not, write to the Free Software | ||
4132 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
4133 | + */ | ||
4134 | + | ||
4135 | +/* | ||
4136 | + * History: | ||
4137 | + * modified to support Intel IOH GE IEEE 1588 hardware | ||
4138 | + * Copyright (C) 2008 OKI SEMICONDUCTOR Co., LTD. | ||
4139 | + * All rights reserved. | ||
4140 | + * derived from | ||
4141 | + * IEEE 1588 Time Synchronization Driver for Intel EP80579 | ||
4142 | + * Copyright(c) 2007,2008 Intel Corporation. All rights reserved. | ||
4143 | + * All rights reserved. | ||
4144 | + * | ||
4145 | + */ | ||
4146 | + | ||
4147 | +#ifndef IOH_1588_HAL_H | ||
4148 | +#define IOH_1588_HAL_H | ||
4149 | + | ||
4150 | +#include "pch_1588_main.h" | ||
4151 | + | ||
4152 | +/* IOH 1588 Hardware Assist Module Register offsets */ | ||
4153 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4154 | +@def IOH_1588_TSC_OFFSET | ||
4155 | +@brief TS Control Register Offset | ||
4156 | +*/ | ||
4157 | +#define IOH_1588_TSC_OFFSET (0x00) /* TS_Control */ | ||
4158 | + | ||
4159 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4160 | +@def IOH_1588_TSE_OFFSET | ||
4161 | +@brief TS Event Register Offset | ||
4162 | +*/ | ||
4163 | +#define IOH_1588_TSE_OFFSET (0x04) /* TS_Event */ | ||
4164 | + | ||
4165 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4166 | +@def IOH_1588_ADD_OFFSET | ||
4167 | +@brief TS Addend Register Offset | ||
4168 | +*/ | ||
4169 | +#define IOH_1588_ADD_OFFSET (0x08) /* TS_Addend */ | ||
4170 | + | ||
4171 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4172 | +@def IOH_1588_ACC_OFFSET | ||
4173 | +@brief TS Accumulator Register Offset | ||
4174 | +*/ | ||
4175 | +#define IOH_1588_ACC_OFFSET (0x0C) /* TS_Accum */ | ||
4176 | + | ||
4177 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4178 | +@def IOH_1588_TST_OFFSET | ||
4179 | +@brief TS Test Register Offset | ||
4180 | +*/ | ||
4181 | +#define IOH_1588_TST_OFFSET (0x10) /* TS_Test */ | ||
4182 | + | ||
4183 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4184 | +@def IOH_1588_PPS_OFFSET | ||
4185 | +@brief TS PPS Compare Register Offset | ||
4186 | +*/ | ||
4187 | +#define IOH_1588_PPS_OFFSET (0x14) /* TS_PPS_Compare */ | ||
4188 | + | ||
4189 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4190 | +@def IOH_1588_STL_OFFSET | ||
4191 | +@brief TS System Time Low Register Offset | ||
4192 | +*/ | ||
4193 | +#define IOH_1588_STL_OFFSET (0x20) /* TS_SysTimeLo */ | ||
4194 | + | ||
4195 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4196 | +@def IOH_1588_STH_OFFSET | ||
4197 | +@brief TS System Time High Register Offset | ||
4198 | +*/ | ||
4199 | +#define IOH_1588_STH_OFFSET (0x24) /* TS_SysTimeHi */ | ||
4200 | + | ||
4201 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4202 | +@def IOH_1588_TTL_OFFSET | ||
4203 | +@brief TS Target Time Low Register Offset | ||
4204 | +*/ | ||
4205 | +#define IOH_1588_TTL_OFFSET (0x28) /* TS_TrgtLo */ | ||
4206 | + | ||
4207 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4208 | +@def IOH_1588_TTH_OFFSET | ||
4209 | +@brief TS Target Time High Register Offset | ||
4210 | +*/ | ||
4211 | +#define IOH_1588_TTH_OFFSET (0x2c) /* TS_TrgtHi */ | ||
4212 | + | ||
4213 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4214 | +@def IOH_1588_ASSL_OFFSET | ||
4215 | +@brief TS Aux Slave Mode Snapshot Low Register Offset | ||
4216 | +*/ | ||
4217 | +#define IOH_1588_ASSL_OFFSET (0x30) /* TS_ASMSLo */ | ||
4218 | + | ||
4219 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4220 | +@def IOH_1588_ASSH_OFFSET | ||
4221 | +@brief TS Aux Slave Mode Snapshot High Register Offset | ||
4222 | +*/ | ||
4223 | +#define IOH_1588_ASSH_OFFSET (0x34) /* TS_ASMSHi */ | ||
4224 | + | ||
4225 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4226 | +@def IOH_1588_ASSH_OFFSET | ||
4227 | +@brief TS Aux Master Mode Snapshot Low Register Offset | ||
4228 | +*/ | ||
4229 | +#define IOH_1588_AMSL_OFFSET (0x38) /* TS_AMMSLo */ | ||
4230 | + | ||
4231 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4232 | +@def IOH_1588_AMSH_OFFSET | ||
4233 | +@brief TS Aux Master Mode Snapshot High Register Offset | ||
4234 | +*/ | ||
4235 | +#define IOH_1588_AMSH_OFFSET (0x3C) /* TS_AMMSHi */ | ||
4236 | + | ||
4237 | +/* Ethernet */ | ||
4238 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4239 | +@def IOH_1588_CC_OFFSET | ||
4240 | +@brief TS Channel Control Register Offset | ||
4241 | +*/ | ||
4242 | +#define IOH_1588_CC_OFFSET (0x40) /* TS_Ch_Contr */ | ||
4243 | + | ||
4244 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4245 | +@def IOH_1588_CE_OFFSET | ||
4246 | +@brief TS Channel Event Register Offset | ||
4247 | +*/ | ||
4248 | +#define IOH_1588_CE_OFFSET (0x44) /* TS_Ch_Event */ | ||
4249 | + | ||
4250 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4251 | +@def IOH_1588_XSL_OFFSET | ||
4252 | +@brief TS Tx Snapshot Low Register Offset | ||
4253 | +*/ | ||
4254 | +#define IOH_1588_XSL_OFFSET (0x48) /* TS_TxSnapLo */ | ||
4255 | + | ||
4256 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4257 | +@def IOH_1588_XSH_OFFSET | ||
4258 | +@brief TS Tx Snapshot High Register Offset | ||
4259 | +*/ | ||
4260 | +#define IOH_1588_XSH_OFFSET (0x4C) /* TS_TxSnapHi */ | ||
4261 | + | ||
4262 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4263 | +@def IOH_1588_RSL_OFFSET | ||
4264 | +@brief TS Rx Snapshot Low Register Offset | ||
4265 | +*/ | ||
4266 | +#define IOH_1588_RSL_OFFSET (0x50) /* TS_RxSnapLo */ | ||
4267 | + | ||
4268 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4269 | +@def IOH_1588_RSH_OFFSET | ||
4270 | +@brief TS Rx Snapshot High Register Offset | ||
4271 | +*/ | ||
4272 | +#define IOH_1588_RSH_OFFSET (0x54) /* TS_RxSnapHi */ | ||
4273 | + | ||
4274 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4275 | +@def IOH_1588_UID_OFFSET | ||
4276 | +@brief TS Source UUID Low Register Offset | ||
4277 | +*/ | ||
4278 | +#define IOH_1588_UID_OFFSET (0x58) /* TS_SrcUUID */ | ||
4279 | + | ||
4280 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4281 | +@def IOH_1588_SID_OFFSET | ||
4282 | +@brief TS Source UUID High/SequenceID Register Offset | ||
4283 | +*/ | ||
4284 | +#define IOH_1588_SID_OFFSET (0x5C) /* TS_SrcUUID */ | ||
4285 | + | ||
4286 | +/* CAN */ | ||
4287 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4288 | +@def IOH_1588_CCE_OFFSET | ||
4289 | +@brief TS CAN Channel Status Register Offset | ||
4290 | +*/ | ||
4291 | +#define IOH_1588_CCE_OFFSET (0x60) /* TS_CAN_Stat */ | ||
4292 | + | ||
4293 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4294 | +@def IOH_1588_CXSL_OFFSET | ||
4295 | +@brief TS CAN Snapshot Low Register Offset | ||
4296 | +*/ | ||
4297 | +#define IOH_1588_CXSL_OFFSET (0x64) /* TS_CAN_Snap */ | ||
4298 | + | ||
4299 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4300 | +@def IOH_1588_CXSH_OFFSET | ||
4301 | +@brief TS CAN Snapshot High Register Offset | ||
4302 | +*/ | ||
4303 | +#define IOH_1588_CXSH_OFFSET (0x68) /* TS_CAN_Snap */ | ||
4304 | + | ||
4305 | +/* Selector */ | ||
4306 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4307 | +@def IOH_1588_ECS_OFFSET | ||
4308 | +@brief TS Ethernet/CAN Select Register Offset | ||
4309 | +*/ | ||
4310 | +#define IOH_1588_ECS_OFFSET (0x6c) /* TS_SEL */ | ||
4311 | + | ||
4312 | +/* Station Address 1-6 */ | ||
4313 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4314 | +@def IOH_1588_STA_OFFSET | ||
4315 | +@brief TS Station Address Register Offset | ||
4316 | +*/ | ||
4317 | +#define IOH_1588_STA_OFFSET (0x70) /* TS_ST1 */ | ||
4318 | + | ||
4319 | +/* Bit Masks of Control Register */ | ||
4320 | +/* Hardware Assist Reset */ | ||
4321 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4322 | +@def IOH_1588_TSC_RESET_SHIFT | ||
4323 | +@brief Reset Bit position in Control Register | ||
4324 | +*/ | ||
4325 | +#define IOH_1588_TSC_RESET_SHIFT 0 | ||
4326 | + | ||
4327 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4328 | +@def IOH_1588_TSC_RESET | ||
4329 | +@brief Bit Maks for Reset Bit in Control Register | ||
4330 | +*/ | ||
4331 | +#define IOH_1588_TSC_RESET (1 << IOH_1588_TSC_RESET_SHIFT) | ||
4332 | + | ||
4333 | +/* Target Time Interrupt Mask */ | ||
4334 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4335 | +@def IOH_1588_TSC_TIM_SHIFT | ||
4336 | +@brief Bit position of Target Time Interrupt Bit in Control | ||
4337 | + Register | ||
4338 | +*/ | ||
4339 | +#define IOH_1588_TSC_TTM_SHIFT 1 | ||
4340 | + | ||
4341 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4342 | +@def IOH_1588_TSC_TIM_MASK | ||
4343 | +@brief Bit Mask for Target Time Interrupt in Control Register | ||
4344 | +*/ | ||
4345 | +#define IOH_1588_TSC_TTM_MASK (1 << IOH_1588_TSC_TTM_SHIFT) | ||
4346 | + | ||
4347 | +/* Auxiliary Slave Mode snapshot Interrupt Mask */ | ||
4348 | + | ||
4349 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4350 | +@def IOH_1588_TSC_ASMS_SHIFT | ||
4351 | +@brief Bit position of Aux Slave Mode snapshot | ||
4352 | + Interrupt in Control Register | ||
4353 | +*/ | ||
4354 | +#define IOH_1588_TSC_ASMS_SHIFT 2 | ||
4355 | + | ||
4356 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4357 | +@def IOH_1588_TSC_ASMS_MASK | ||
4358 | +@brief Bit Mask for Aux Slave Mode snapshot | ||
4359 | + Interrupt in Control Register | ||
4360 | +*/ | ||
4361 | +#define IOH_1588_TSC_ASMS_MASK (1 << IOH_1588_TSC_ASMS_SHIFT) | ||
4362 | + | ||
4363 | +/* Auxiliary Master Mode snapshot Interrupt Mask */ | ||
4364 | + | ||
4365 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4366 | +@def IOH_1588_TSC_AMMS_SHIFT | ||
4367 | +@brief Bit position for for Aux Master Mode snapshot | ||
4368 | + Interrupt in Control Register | ||
4369 | +*/ | ||
4370 | +#define IOH_1588_TSC_AMMS_SHIFT 3 | ||
4371 | + | ||
4372 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4373 | +@def IOH_1588_TSC_AMMS_MASK | ||
4374 | +@brief Bit mask for for Aux Master Mode snapshot | ||
4375 | + Interrupt in Control Register | ||
4376 | +*/ | ||
4377 | +#define IOH_1588_TSC_AMMS_MASK (1 << IOH_1588_TSC_AMMS_SHIFT) | ||
4378 | + | ||
4379 | +/* Pulse Per Second Interrupt Mask */ | ||
4380 | + | ||
4381 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4382 | +@def IOH_1588_TSC_PPSM_SHIFT | ||
4383 | +@brief Bit position of Pulse Per Second | ||
4384 | + Interrupt in Control Register | ||
4385 | +*/ | ||
4386 | +#define IOH_1588_TSC_PPSM_SHIFT 4 | ||
4387 | + | ||
4388 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4389 | +@def IOH_1588_TSC_PPSM_MASK | ||
4390 | +@brief Bit mask of Pulse Per Second | ||
4391 | + Interrupt in Control Register | ||
4392 | +*/ | ||
4393 | +#define IOH_1588_TSC_PPSM_MASK (1 << IOH_1588_TSC_PPSM_SHIFT) | ||
4394 | + | ||
4395 | +/* Bit Masks of Event Register */ | ||
4396 | +/* Target Time Interrupt Pending Event */ | ||
4397 | + | ||
4398 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4399 | +@def IOH_1588_TSE_TTIPEND_SHIFT | ||
4400 | +@brief Bit position of Target Time Interrupt | ||
4401 | + Pending in Event Register | ||
4402 | +*/ | ||
4403 | +#define IOH_1588_TSE_TTIPEND_SHIFT 1 | ||
4404 | + | ||
4405 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4406 | +@def IOH_1588_TSE_TTIPEND | ||
4407 | +@brief Bit mask of Target Time Interrupt | ||
4408 | + Pending in Event Register | ||
4409 | +*/ | ||
4410 | +#define IOH_1588_TSE_TTIPEND (1 << IOH_1588_TSE_TTIPEND_SHIFT) | ||
4411 | + | ||
4412 | +/* Auxiliary Slave Mode snapshot Event */ | ||
4413 | + | ||
4414 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4415 | +@def IOH_1588_TSE_SNS_SHIFT | ||
4416 | +@brief Bit position of Aux Slave Mode snapshot | ||
4417 | + in Event Register | ||
4418 | +*/ | ||
4419 | +#define IOH_1588_TSE_SNS_SHIFT 2 | ||
4420 | + | ||
4421 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4422 | +@def IOH_1588_TSE_SNS | ||
4423 | +@brief Bit mask of Aux Slave Mode snapshot | ||
4424 | + in Event Register | ||
4425 | +*/ | ||
4426 | +#define IOH_1588_TSE_SNS (1 << IOH_1588_TSE_SNS_SHIFT) | ||
4427 | + | ||
4428 | +/* Auxiliary Master Mode snapshot Event */ | ||
4429 | + | ||
4430 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4431 | +@def IOH_1588_TSE_SNM_SHIFT | ||
4432 | +@brief Bit position of Aux Master Mode snapshot | ||
4433 | + in Event Register | ||
4434 | +*/ | ||
4435 | +#define IOH_1588_TSE_SNM_SHIFT 3 | ||
4436 | + | ||
4437 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4438 | +@def IOH_1588_TSE_SNM | ||
4439 | +@brief Bit mask of Aux Master Mode snapshot | ||
4440 | + in Event Register | ||
4441 | +*/ | ||
4442 | +#define IOH_1588_TSE_SNM (1 << IOH_1588_TSE_SNM_SHIFT) | ||
4443 | + | ||
4444 | +/* Pulse Per Second Match */ | ||
4445 | + | ||
4446 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4447 | +@def IOH_1588_TSE_PPS_SHIFT | ||
4448 | +@brief Bit position of Pusle Per Second Match | ||
4449 | + in Event Register | ||
4450 | +*/ | ||
4451 | +#define IOH_1588_TSE_PPS_SHIFT 4 | ||
4452 | + | ||
4453 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4454 | +@def IOH_1588_TSE_PPS | ||
4455 | +@brief Bit mask of Pusle Per Second Match | ||
4456 | + in Event Register | ||
4457 | +*/ | ||
4458 | +#define IOH_1588_TSE_PPS (1 << IOH_1588_TSE_PPS_SHIFT) | ||
4459 | + | ||
4460 | +/* Bit Masks of Channel Control Register */ | ||
4461 | +/* Timestamp Master or Slave Mode Control Flag */ | ||
4462 | + | ||
4463 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4464 | +@def IOH_1588_CC_MM_SHIFT | ||
4465 | +@brief Bit position of Timestamp Master/Slave Mode | ||
4466 | + in Channel Control Register | ||
4467 | +*/ | ||
4468 | +#define IOH_1588_CC_MM_SHIFT 0 | ||
4469 | + | ||
4470 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4471 | +@def IOH_1588_CC_MM | ||
4472 | +@brief Bit mask of Timestamp Master/Slave Mode | ||
4473 | + control flag in | ||
4474 | + in Channel Control Register | ||
4475 | +*/ | ||
4476 | +#define IOH_1588_CC_MM (1 << IOH_1588_CC_MM_SHIFT) | ||
4477 | + | ||
4478 | +/* Timestamp All Messages Control Flag */ | ||
4479 | + | ||
4480 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4481 | +@def IOH_1588_CC_TA_SHIFT | ||
4482 | +@brief Bit position of Timestamp all messages | ||
4483 | + Mode control flag | ||
4484 | + in Channel Control Register | ||
4485 | +*/ | ||
4486 | +#define IOH_1588_CC_TA_SHIFT 1 | ||
4487 | + | ||
4488 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4489 | +@def IOH_1588_CC_TA | ||
4490 | +@brief Bit mask of Timestamp all messages | ||
4491 | + Mode control flag | ||
4492 | + in Channel Control Register | ||
4493 | +*/ | ||
4494 | +#define IOH_1588_CC_TA (1 << IOH_1588_CC_TA_SHIFT) | ||
4495 | + | ||
4496 | +/* Mode bits */ | ||
4497 | + | ||
4498 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4499 | +@def IOH_1588_CC_MODE_SHIFT | ||
4500 | +@brief Bit position of mode bits | ||
4501 | + in Channel Control Register | ||
4502 | +*/ | ||
4503 | +#define IOH_1588_CC_MODE_SHIFT 16 | ||
4504 | + | ||
4505 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4506 | +@def IOH_1588_CC_MODE_MASK | ||
4507 | +@brief Bit mask for mode bits | ||
4508 | + in Channel Control Register | ||
4509 | +*/ | ||
4510 | +#define IOH_1588_CC_MODE_MASK (0x001F0000) | ||
4511 | + | ||
4512 | +/* Version bit */ | ||
4513 | + | ||
4514 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4515 | +@def IOH_1588_CC_VERSION_SHIFT | ||
4516 | +@brief Bit position for version bits | ||
4517 | + in Channel Control Register | ||
4518 | +*/ | ||
4519 | +#define IOH_1588_CC_VERSION_SHIFT 31 | ||
4520 | + | ||
4521 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4522 | +@def IOH_1588_CC_VERSION | ||
4523 | +@brief Bit mask for version bits | ||
4524 | + in Channel Control Register | ||
4525 | +*/ | ||
4526 | +#define IOH_1588_CC_VERSION (1 << IOH_1588_CC_VERSION_SHIFT) | ||
4527 | + | ||
4528 | +/* Bit Masks of Channel Event Register */ | ||
4529 | +/* Transmit Snapshot Locked Indicator Flag */ | ||
4530 | + | ||
4531 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4532 | +@def IOH_1588_CE_TXS | ||
4533 | +@brief Bit mask for Transmit Snapshot Locked bit | ||
4534 | + in Channel Event Register | ||
4535 | +*/ | ||
4536 | +#define IOH_1588_CE_TXS (1 << 0) | ||
4537 | + | ||
4538 | +/* Receive Snapshot Locked Indicator Flag */ | ||
4539 | + | ||
4540 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4541 | +@def IOH_1588_CE_TXS | ||
4542 | +@brief Bit mask for Receive Snapshot Locked bit | ||
4543 | + in Channel Event Register | ||
4544 | +*/ | ||
4545 | +#define IOH_1588_CE_RXS (1 << 1) | ||
4546 | + | ||
4547 | +/* Bit Masks of CAN Channel Event Register */ | ||
4548 | +/* Overrun Indicator Flag */ | ||
4549 | + | ||
4550 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4551 | +@def IOH_1588_CE_OVR | ||
4552 | +@brief Bit mask for Overrun Indicator bit | ||
4553 | + in Channel Event Register | ||
4554 | +*/ | ||
4555 | +#define IOH_1588_CE_OVR (1 << 0) | ||
4556 | + | ||
4557 | +/* Valid Indicator Flag */ | ||
4558 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4559 | +@def IOH_1588_CE_VAL | ||
4560 | +@brief Bit mask for Valid Indicator bit | ||
4561 | + in Channel Event Register | ||
4562 | +*/ | ||
4563 | +#define IOH_1588_CE_VAL (1 << 1) | ||
4564 | + | ||
4565 | +/* Ethernet Enable bit */ | ||
4566 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4567 | +@def IOH_1588_ECS_ETH_SHIFT | ||
4568 | +@brief Bit position for Ethernet Enable bit | ||
4569 | + in Ethernet/CAN select Register | ||
4570 | +*/ | ||
4571 | +#define IOH_1588_ECS_ETH_SHIFT 0 | ||
4572 | + | ||
4573 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4574 | +@def IOH_1588_ECS_ETH | ||
4575 | +@brief Bit mask for Ethernet Enable bit | ||
4576 | + in Ethernet/CAN select Register | ||
4577 | +*/ | ||
4578 | +#define IOH_1588_ECS_ETH (1 << IOH_1588_ECS_ETH_SHIFT) | ||
4579 | +/* Can Enable bit */ | ||
4580 | + | ||
4581 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4582 | +@def IOH_1588_ECS_CAN_SHIFT | ||
4583 | +@brief Bit position for CAN Enable bit | ||
4584 | + in Ethernet/CAN select Register | ||
4585 | +*/ | ||
4586 | +#define IOH_1588_ECS_CAN_SHIFT 1 | ||
4587 | + | ||
4588 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4589 | +@def IOH_1588_ECS_CAN | ||
4590 | +@brief Bit mask for CAN Enable bit | ||
4591 | + in Ethernet/CAN select Register | ||
4592 | +*/ | ||
4593 | +#define IOH_1588_ECS_CAN (1 << IOH_1588_ECS_CAN_SHIFT) | ||
4594 | + | ||
4595 | +/* Station Address bytes */ | ||
4596 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4597 | +@def IOH_1588_STATION_BYTES | ||
4598 | +@brief Bytes for Station Address | ||
4599 | +*/ | ||
4600 | +#define IOH_1588_STATION_BYTES 6 | ||
4601 | + | ||
4602 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4603 | +@def DRIVER_NAME | ||
4604 | +@brief The name of this driver | ||
4605 | +*/ | ||
4606 | +#define DRIVER_NAME "ioh_ieee1588" | ||
4607 | + | ||
4608 | +#define IOH_IEEE1588_ETH (1 << 0) | ||
4609 | +#define IOH_IEEE1588_CAN (1 << 1) | ||
4610 | + | ||
4611 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4612 | +@typedef typedef void (*ioh1588TargetTimeCallback) | ||
4613 | + (struct ioh1588TimeValue tgt_time) | ||
4614 | +@brief Pointer for Callback function for Target Time interrupt | ||
4615 | +@see | ||
4616 | + - ioh_1588_blpl_base_address_set | ||
4617 | + - ioh_1588_target_time_interrupt_enable | ||
4618 | + - ioh_1588_target_time_interrupt_disable | ||
4619 | + - ioh_1588_target_time_poll | ||
4620 | + - ioh_1588_reset | ||
4621 | +*/ | ||
4622 | +typedef void (*ioh1588TargetTimeCallback) (struct ioh1588TimeValue tgt_time); | ||
4623 | + | ||
4624 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4625 | +@typedef typedef void (*ioh1588AuxTimeCallback) | ||
4626 | + (enum ioh1588AuxMode aux_mode, | ||
4627 | + struct ioh1588TimeValue aux_time) | ||
4628 | +@brief Pointer for Callback function for Aux Time interrupt | ||
4629 | +@see | ||
4630 | + - ioh_1588_blpl_base_address_set | ||
4631 | + - ioh_1588_aux_time_interrupt_enable | ||
4632 | + - ioh_1588_aux_time_interrupt_disable | ||
4633 | + - ioh_1588_aux_time_poll | ||
4634 | + - ioh_1588_reset | ||
4635 | +*/ | ||
4636 | +typedef void (*ioh1588AuxTimeCallback) (enum ioh1588AuxMode aux_mode, | ||
4637 | + struct ioh1588TimeValue aux_time); | ||
4638 | + | ||
4639 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4640 | +@typedef typedef void (*ioh1588PulsePerSecondCallback)( | ||
4641 | + unsigned long pps) | ||
4642 | +@brief Pointer for Callback function for Pulse Per Second | ||
4643 | + interrupt | ||
4644 | +@see | ||
4645 | + - ioh_1588_blpl_base_address_set | ||
4646 | + - ioh_1588_pulse_per_sec_interrupt_enable | ||
4647 | + - ioh_1588_pulse_per_sec_interrupt_disable | ||
4648 | + - ioh_1588_reset | ||
4649 | +*/ | ||
4650 | +typedef void (*ioh1588PulsePerSecondCallback) (unsigned long pps); | ||
4651 | + | ||
4652 | +/** | ||
4653 | + * prototypes of HAL APIs | ||
4654 | + */ | ||
4655 | + | ||
4656 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4657 | + * @fn enum ioh_status ioh_1588_blpl_base_address_set(unsigned long base_addr) | ||
4658 | + */ | ||
4659 | +enum ioh_status ioh_1588_blpl_base_address_set(unsigned long base_addr); | ||
4660 | + | ||
4661 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4662 | + * @fn enum ioh_status ioh_1588_ptp_port_config_set( | ||
4663 | + * enum ioh1588PTPPort ptpPort, | ||
4664 | + * enum ioh1588PTPPortMode ptpPortMode) | ||
4665 | + */ | ||
4666 | +enum ioh_status | ||
4667 | +ioh_1588_ptp_port_config_set(enum ioh1588PTPPort ptpPort, | ||
4668 | + enum ioh1588PTPPortMode ptpPortMode); | ||
4669 | + | ||
4670 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4671 | + * @fn enum ioh_status ioh_1588_ptp_port_config_get( | ||
4672 | + * enum ioh1588PTPPort ptpPort, | ||
4673 | + * enum ioh1588PTPPortMode *ptpPortMode) | ||
4674 | + */ | ||
4675 | +enum ioh_status | ||
4676 | +ioh_1588_ptp_port_config_get(enum ioh1588PTPPort ptpPort, | ||
4677 | + enum ioh1588PTPPortMode *ptpPortMode); | ||
4678 | + | ||
4679 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4680 | + * @fn enum ioh_status ioh_1588_ptp_rx_poll( | ||
4681 | + * enum ioh1588PTPPort ptpPort, | ||
4682 | + * struct ioh1588PtpMsgData *ptpMsgData) | ||
4683 | + * | ||
4684 | + * | ||
4685 | + */ | ||
4686 | +enum ioh_status | ||
4687 | +ioh_1588_ptp_rx_poll( | ||
4688 | + enum ioh1588PTPPort ptpPort, \ | ||
4689 | + struct ioh1588PtpMsgData *ptpMsgData); | ||
4690 | + | ||
4691 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4692 | + * @fn enum ioh_status ioh_1588_ptp_tx_poll( | ||
4693 | + * enum ioh1588PTPPort ptpPort, | ||
4694 | + * struct ioh1588PtpMsgData *ptpMsgData) | ||
4695 | + * | ||
4696 | + */ | ||
4697 | +enum ioh_status | ||
4698 | +ioh_1588_ptp_tx_poll( | ||
4699 | + enum ioh1588PTPPort ptpPort, \ | ||
4700 | + struct ioh1588PtpMsgData *ptpMsgData); | ||
4701 | + | ||
4702 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4703 | + * @fn enum ioh_status ioh_1588_system_time_set( | ||
4704 | + * struct ioh1588TimeValue systemTime) | ||
4705 | + * | ||
4706 | + */ | ||
4707 | +enum ioh_status ioh_1588_system_time_set(struct ioh1588TimeValue systemTime); | ||
4708 | + | ||
4709 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4710 | + * @fn enum ioh_status ioh_1588_system_time_get( | ||
4711 | + * struct ioh1588TimeValue *systemTime) | ||
4712 | + * | ||
4713 | + */ | ||
4714 | +enum ioh_status ioh_1588_system_time_get(struct ioh1588TimeValue *systemTime); | ||
4715 | + | ||
4716 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4717 | + * @fn enum ioh_status ioh_1588_tick_rate_set(unsigned long tickRate) | ||
4718 | + * | ||
4719 | + */ | ||
4720 | +enum ioh_status ioh_1588_tick_rate_set(unsigned long tickRate); | ||
4721 | + | ||
4722 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4723 | + * @fn enum ioh_status ioh_1588_tick_rate_get(unsigned long *tickRate) | ||
4724 | + * | ||
4725 | + */ | ||
4726 | +enum ioh_status ioh_1588_tick_rate_get(unsigned long *tickRate); | ||
4727 | + | ||
4728 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4729 | + * @fn enum ioh_status ioh_1588_target_time_interrupt_enable( | ||
4730 | + * ioh1588TargetTimeCallback callBack) | ||
4731 | + * | ||
4732 | + */ | ||
4733 | +enum ioh_status | ||
4734 | +ioh_1588_target_time_interrupt_enable(ioh1588TargetTimeCallback callBack); | ||
4735 | + | ||
4736 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4737 | + * @fn enum ioh_status ioh_1588_target_time_interrupt_disable(void) | ||
4738 | + * | ||
4739 | + */ | ||
4740 | +enum ioh_status ioh_1588_target_time_interrupt_disable(void); | ||
4741 | + | ||
4742 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4743 | + * @fn enum ioh_status ioh_1588_target_time_poll( | ||
4744 | + * unsigned long *ttmPollFlag, | ||
4745 | + * struct ioh1588TimeValue *targetTime) | ||
4746 | + * | ||
4747 | + */ | ||
4748 | +enum ioh_status | ||
4749 | +ioh_1588_target_time_poll(unsigned long *ttmPollFlag, | ||
4750 | + struct ioh1588TimeValue *targetTime); | ||
4751 | + | ||
4752 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4753 | + * @fn enum ioh_status ioh_1588_target_time_set( | ||
4754 | + * struct ioh1588TimeValue targetTime) | ||
4755 | + * | ||
4756 | + */ | ||
4757 | +enum ioh_status ioh_1588_target_time_set(struct ioh1588TimeValue targetTime); | ||
4758 | + | ||
4759 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4760 | + * @fn enum ioh_status ioh_1588_target_time_get( | ||
4761 | + * struct ioh1588TimeValue *targetTime) | ||
4762 | + * | ||
4763 | + */ | ||
4764 | +enum ioh_status ioh_1588_target_time_get(struct ioh1588TimeValue *targetTime); | ||
4765 | + | ||
4766 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4767 | + * @fn enum ioh_status ioh_1588_aux_time_interrupt_enable( | ||
4768 | + enum ioh1588AuxMode auxMode, | ||
4769 | + * ioh1588AuxTimeCallback callBack) | ||
4770 | + * | ||
4771 | + */ | ||
4772 | +enum ioh_status | ||
4773 | +ioh_1588_aux_time_interrupt_enable(enum ioh1588AuxMode auxMode, | ||
4774 | + ioh1588AuxTimeCallback callBack); | ||
4775 | + | ||
4776 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4777 | + * @fn enum ioh_status ioh_1588_aux_time_interrupt_disable( | ||
4778 | + enum ioh1588AuxMode auxMode) | ||
4779 | + * | ||
4780 | + */ | ||
4781 | +enum ioh_status ioh_1588_aux_time_interrupt_disable( | ||
4782 | + enum ioh1588AuxMode auxMode); | ||
4783 | + | ||
4784 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4785 | + * @fn enum ioh_status ioh_1588_aux_time_poll( | ||
4786 | + * enum ioh1588AuxMode auxMode, | ||
4787 | + * unsigned long *pollFlag, | ||
4788 | + * struct ioh1588TimeValue *auxTime) | ||
4789 | + * | ||
4790 | + */ | ||
4791 | +enum ioh_status | ||
4792 | +ioh_1588_aux_time_poll(enum ioh1588AuxMode auxMode, | ||
4793 | + unsigned long *pollFlag, | ||
4794 | + struct ioh1588TimeValue *auxTime); | ||
4795 | + | ||
4796 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4797 | + * @fn enum ioh_status ioh_1588_reset(void) | ||
4798 | + * | ||
4799 | + */ | ||
4800 | +enum ioh_status ioh_1588_reset(void); | ||
4801 | + | ||
4802 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4803 | + * @fn enum ioh_status ioh_1588_chnl_reset(enum ioh1588PTPPort ptpPort) | ||
4804 | + * | ||
4805 | + */ | ||
4806 | +enum ioh_status ioh_1588_chnl_reset(enum ioh1588PTPPort ptpPort); | ||
4807 | + | ||
4808 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4809 | + * @fn enum ioh_status ioh_1588_stats_get(struct ioh1588Stats *stats) | ||
4810 | + * | ||
4811 | + */ | ||
4812 | +enum ioh_status ioh_1588_stats_get(struct ioh1588Stats *stats); | ||
4813 | + | ||
4814 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4815 | + * @fn void ioh_1588_stats_reset(void) | ||
4816 | + * | ||
4817 | + */ | ||
4818 | +void ioh_1588_stats_reset(void); | ||
4819 | + | ||
4820 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4821 | + * @fn void ioh_1588_show(void) | ||
4822 | + * | ||
4823 | + */ | ||
4824 | +enum ioh_status ioh_1588_show(void); | ||
4825 | + | ||
4826 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4827 | + * @fn enum ioh_status ioh_1588_pulse_per_sec_interrupt_enable( | ||
4828 | + * ioh1588PulsePerSecondCallback callBack) | ||
4829 | + * | ||
4830 | + */ | ||
4831 | +enum ioh_status | ||
4832 | +ioh_1588_pulse_per_sec_interrupt_enable(ioh1588PulsePerSecondCallback callBack); | ||
4833 | + | ||
4834 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4835 | + * @fn enum ioh_status ioh_1588_pulse_per_sec_interrupt_disable(void) | ||
4836 | + * | ||
4837 | + */ | ||
4838 | +enum ioh_status ioh_1588_pulse_per_sec_interrupt_disable(void); | ||
4839 | + | ||
4840 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4841 | + * @fn enum ioh_status ioh_1588_pulse_per_sec_time_get(unsigned long *ppsTime) | ||
4842 | + * | ||
4843 | + */ | ||
4844 | +enum ioh_status ioh_1588_pulse_per_sec_time_get(unsigned long *ppsTime); | ||
4845 | + | ||
4846 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4847 | + * @fn enum ioh_status ioh_1588_pulse_per_sec_time_set(unsigned long ppsTime) | ||
4848 | + * | ||
4849 | + */ | ||
4850 | +enum ioh_status ioh_1588_pulse_per_sec_time_set(unsigned long ppsTime); | ||
4851 | + | ||
4852 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4853 | + * @fn enum ioh_status ioh_1588_ptp_can_poll ( | ||
4854 | + * enum ioh1588PTPPort ptpPort, | ||
4855 | + * struct ioh1588TimeValue *ptpTimeStamp) | ||
4856 | + * | ||
4857 | + */ | ||
4858 | +enum ioh_status ioh_1588_ptp_can_poll(enum ioh1588PTPPort ptpPort, | ||
4859 | + struct ioh1588TimeValue *ptpTimeStamp); | ||
4860 | + | ||
4861 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4862 | + * @fn enum ioh_status ioh_1588_ptp_version_get(enum ioh1588PTPPort ptpPort, | ||
4863 | + * enum ioh1588PTPVersion *ptpVersion) | ||
4864 | + * | ||
4865 | + */ | ||
4866 | +enum ioh_status | ||
4867 | +ioh_1588_ptp_version_get(enum ioh1588PTPPort ptpPort, | ||
4868 | + enum ioh1588PTPVersion *ptpVersion); | ||
4869 | + | ||
4870 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4871 | + * @fn enum ioh_status ioh_1588_ptp_version_set(enum ioh1588PTPPort ptpPort, | ||
4872 | + * enum ioh1588PTPVersion ptpVersion) | ||
4873 | + * | ||
4874 | + */ | ||
4875 | +enum ioh_status | ||
4876 | +ioh_1588_ptp_version_set( | ||
4877 | + enum ioh1588PTPPort ptpPort, \ | ||
4878 | + enum ioh1588PTPVersion ptpVersion); | ||
4879 | + | ||
4880 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4881 | + * @fn enum ioh_status ioh_1588_ptp_operation_mode_set( | ||
4882 | + * enum ioh1588PTPPort ptpPort, | ||
4883 | + * enum ioh1588PTPOperationMode ptpMode) | ||
4884 | + * | ||
4885 | + */ | ||
4886 | +enum ioh_status | ||
4887 | +ioh_1588_ptp_operation_mode_set(enum ioh1588PTPPort ptpPort, | ||
4888 | + enum ioh1588PTPOperationMode ptpMode); | ||
4889 | + | ||
4890 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4891 | + * @fn enum ioh_status ioh_1588_ptp_operation_mode_get(enum ioh1588PTPPort ptpPort, | ||
4892 | + * enum ioh1588PTPOperationMode *ptpMode) | ||
4893 | + */ | ||
4894 | +enum ioh_status | ||
4895 | +ioh_1588_ptp_operation_mode_get(enum ioh1588PTPPort ptpPort, | ||
4896 | + enum ioh1588PTPOperationMode *ptpMode); | ||
4897 | + | ||
4898 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4899 | + * @fn enum ioh_status ioh_1588_handler(void) | ||
4900 | + * | ||
4901 | + */ | ||
4902 | +enum ioh_status ioh_1588_handler(void); | ||
4903 | + | ||
4904 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4905 | + * @fn enum ioh_status ioh_1588_aux_target_time_interrupt_enable(void *callBack) | ||
4906 | + * | ||
4907 | + */ | ||
4908 | +enum ioh_status ioh_1588_aux_target_time_interrupt_enable(void *callBack); | ||
4909 | + | ||
4910 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4911 | + * @fn enum ioh_status ioh_1588_aux_target_time_interrupt_disable(void) | ||
4912 | + * | ||
4913 | + */ | ||
4914 | +enum ioh_status ioh_1588_aux_target_time_interrupt_disable(void); | ||
4915 | + | ||
4916 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4917 | + * @fn enum ioh_status ioh_1588_aux_target_time_poll( | ||
4918 | + * unsigned long *attmPollFlag, struct ioh1588TimeValue *targetTime) | ||
4919 | + * | ||
4920 | + */ | ||
4921 | +enum ioh_status | ||
4922 | +ioh_1588_aux_target_time_poll(unsigned long *attmPollFlag, | ||
4923 | + struct ioh1588TimeValue *targetTime); | ||
4924 | + | ||
4925 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4926 | + * @fn enum ioh_status ioh_1588_aux_target_time_set( | ||
4927 | + * struct ioh1588TimeValue targetTime) | ||
4928 | + * | ||
4929 | + */ | ||
4930 | +enum ioh_status ioh_1588_aux_target_time_set( | ||
4931 | + struct ioh1588TimeValue targetTime); | ||
4932 | + | ||
4933 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4934 | + * @fn enum ioh_status ioh_1588_aux_target_time_get( | ||
4935 | + * struct ioh1588TimeValue *targetTime) | ||
4936 | + * | ||
4937 | + */ | ||
4938 | +enum ioh_status ioh_1588_aux_target_time_get( | ||
4939 | + struct ioh1588TimeValue *stargetTime); | ||
4940 | + | ||
4941 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4942 | + * @fn enum ioh_status ioh_1588_disable_interrupts(void) | ||
4943 | + * | ||
4944 | + */ | ||
4945 | +enum ioh_status ioh_1588_disable_interrupts(void); | ||
4946 | + | ||
4947 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4948 | + * @fn enum ioh_status ioh_1588_interrupt_pending(unsigned long *pending) | ||
4949 | + * | ||
4950 | + */ | ||
4951 | +enum ioh_status ioh_1588_interrupt_pending(unsigned long *pending); | ||
4952 | + | ||
4953 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4954 | + * @fn enum ioh_status ioh_1588_eth_enable(void) | ||
4955 | + * | ||
4956 | + */ | ||
4957 | +enum ioh_status ioh_1588_eth_enable(void); | ||
4958 | + | ||
4959 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4960 | + * @fn enum ioh_status ioh_1588_eth_disable(void) | ||
4961 | + * | ||
4962 | + */ | ||
4963 | +enum ioh_status ioh_1588_eth_disable(void); | ||
4964 | + | ||
4965 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4966 | + * @fn enum ioh_status ioh_1588_can_enable(void) | ||
4967 | + * | ||
4968 | + */ | ||
4969 | +enum ioh_status ioh_1588_can_enable(void); | ||
4970 | + | ||
4971 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4972 | + * @fn enum ioh_status ioh_1588_can_disable(void) | ||
4973 | + * | ||
4974 | + */ | ||
4975 | +enum ioh_status ioh_1588_can_disable(void); | ||
4976 | + | ||
4977 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4978 | + * @fn enum ioh_status ioh_1588_set_station_address (unsigned char *addr) | ||
4979 | + * | ||
4980 | + */ | ||
4981 | +enum ioh_status ioh_1588_set_station_address(unsigned char *addr); | ||
4982 | + | ||
4983 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4984 | + * @fn enum ioh_status ioh_1588_get_station_address(char *addr) | ||
4985 | + * | ||
4986 | + */ | ||
4987 | +enum ioh_status ioh_1588_get_station_address(char *addr); | ||
4988 | + | ||
4989 | +/*! @ingroup IEEE_1588_HALLayerAPI | ||
4990 | + * @fn int ioh_1588_eth_can_get(void) | ||
4991 | + * | ||
4992 | + */ | ||
4993 | +int ioh_1588_eth_can_get(void); | ||
4994 | + | ||
4995 | +#ifdef IOH_IEEE1588_A0_A1_SAMPLE_BUG | ||
4996 | +void ioh_1588_set_system_time_count(void); | ||
4997 | +#endif | ||
4998 | + | ||
4999 | +#endif /* IOH_1588_HAL_H */ | ||
5000 | diff -urN linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_main.c topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_main.c | ||
5001 | --- linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_main.c 1970-01-01 09:00:00.000000000 +0900 | ||
5002 | +++ topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_main.c 2010-03-09 10:33:42.000000000 +0900 | ||
5003 | @@ -0,0 +1,1192 @@ | ||
5004 | + /*! | ||
5005 | + * @file ioh_1588_main.c | ||
5006 | + * @brief | ||
5007 | + * This file contains the definitions of the IEEE_1588_InterfaceLayer APIs | ||
5008 | + * @version 0.92 | ||
5009 | + * @section | ||
5010 | + * This program is free software; you can redistribute it and/or modify | ||
5011 | + * it under the terms of the GNU General Public License as published by | ||
5012 | + * the Free Software Foundation; version 2 of the License. | ||
5013 | + * | ||
5014 | + * This program is distributed in the hope that it will be useful, | ||
5015 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
5016 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
5017 | + * GNU General Public License for more details. | ||
5018 | + * | ||
5019 | + * You should have received a copy of the GNU General Public License | ||
5020 | + * along with this program; if not, write to the Free Software | ||
5021 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
5022 | + */ | ||
5023 | + | ||
5024 | +/* | ||
5025 | + * History: | ||
5026 | + * modified to support Intel IOH GE IEEE 1588 hardware | ||
5027 | + * Copyright (C) 2008 OKI SEMICONDUCTOR Co., LTD. | ||
5028 | + * All rights reserved. | ||
5029 | + * derived from | ||
5030 | + * IEEE 1588 Time Synchronization Driver for Intel EP80579 | ||
5031 | + * Copyright(c) 2007,2008 Intel Corporation. All rights reserved. | ||
5032 | + * All rights reserved. | ||
5033 | + */ | ||
5034 | + | ||
5035 | +#include "pch_1588_pci.h" | ||
5036 | +#include "pch_1588_main.h" | ||
5037 | +#include "pch_1588_hal.h" | ||
5038 | +#include "pch_debug.h" | ||
5039 | +#include <linux/sched.h> | ||
5040 | + | ||
5041 | +/* Linux functions prototypes */ | ||
5042 | +static int ioh_1588_open(struct inode *inode, struct file *filep); | ||
5043 | +static int ioh_1588_release(struct inode *inode, struct file *filep); | ||
5044 | +static int ioh_1588_ioctl(struct inode *inode, struct file *filep, | ||
5045 | + unsigned int cmd, unsigned long arg); | ||
5046 | + | ||
5047 | +/* Linux file operations */ | ||
5048 | +/*! @ingroup IEEE_1588_Global | ||
5049 | + * @var ioh_1588_fops | ||
5050 | + * @brief The structure variable used to specify the | ||
5051 | + * driver specific functionalities to the kernel | ||
5052 | + * subsystem. | ||
5053 | +*/ | ||
5054 | +const struct file_operations ioh_1588_fops = { | ||
5055 | + .owner = THIS_MODULE, | ||
5056 | + .open = ioh_1588_open, | ||
5057 | + .release = ioh_1588_release, | ||
5058 | + .ioctl = ioh_1588_ioctl, | ||
5059 | +}; | ||
5060 | + | ||
5061 | +/* For notify ioctls - values are populated from isr callbacks */ | ||
5062 | +/*! @ingroup IEEE_1588_Global | ||
5063 | + * @var ioh_1588_target_time | ||
5064 | + * @brief This variable is updated from the target time reached callback | ||
5065 | + */ | ||
5066 | +struct ioh1588TimeValue ioh_1588_target_time; | ||
5067 | +/*! @ingroup IEEE_1588_Global | ||
5068 | + * @var ioh_1588_aux_time | ||
5069 | + * @brief This variable is updated from the Auxiliary master/slave time | ||
5070 | + * captured callback | ||
5071 | + */ | ||
5072 | +struct ioh1588AuxTimeIoctl ioh_1588_aux_time; | ||
5073 | +/*! @ingroup IEEE_1588_Global | ||
5074 | + * @var ioh_1588_pps_time | ||
5075 | + * @brief This variable is updated from the Pulse per second match | ||
5076 | + * callback | ||
5077 | + */ | ||
5078 | +unsigned long ioh_1588_pps_time; | ||
5079 | + | ||
5080 | +typedef int (*ioc_func_ptr) (unsigned long cmd, char *arg); | ||
5081 | +static int ioc_handle_notify(unsigned long cmd, char *buf); | ||
5082 | +static int ioc_handle_clr_notify(unsigned long cmd, char *buf); | ||
5083 | +static int ioc_handle_reset(unsigned long cmd, char *buf); | ||
5084 | +static int ioc_handle_show(unsigned long cmd, char *buf); | ||
5085 | +static int ioc_handle_stats(unsigned long cmd, char *buf); | ||
5086 | +static int ioc_handle_stats_reset(unsigned long cmd, char *buf); | ||
5087 | +static int ioc_handle_int_enable(unsigned long cmd, char *buf); | ||
5088 | +static int ioc_handle_int_disable(unsigned long cmd, char *buf); | ||
5089 | +static int ioc_handle_port_config(unsigned long cmd, char *buf); | ||
5090 | +static int ioc_handle_poll(unsigned long cmd, char *buf); | ||
5091 | +static int ioc_handle_time_set(unsigned long cmd, char *buf); | ||
5092 | +static int ioc_handle_time_get(unsigned long cmd, char *buf); | ||
5093 | +static int ioc_handle_tick_rate(unsigned long cmd, char *buf); | ||
5094 | +static int ioc_handle_pps_reqt(unsigned long cmd, char *buf); | ||
5095 | +static int ioc_handle_version_reqt(unsigned long cmd, char *buf); | ||
5096 | +static int ioc_handle_op_mode_reqt(unsigned long cmd, char *buf); | ||
5097 | + | ||
5098 | +/* IOCTL command and their associated functions */ | ||
5099 | + | ||
5100 | +/*! @ingroup IEEE_1588_Global | ||
5101 | + * @struct ioh_1588_ioc_tbl | ||
5102 | + * @brief Structure to map the ioctl command to the associated function | ||
5103 | + */ | ||
5104 | +static const struct ioh_1588_ioc_tbl { | ||
5105 | + unsigned long cmd; | ||
5106 | + ioc_func_ptr func; | ||
5107 | +} ioh_1588_ioc_tbl[] = { | ||
5108 | + { | ||
5109 | + IOCTL_1588_TARG_TIME_NOTIFY, ioc_handle_notify}, { | ||
5110 | + IOCTL_1588_AUX_TIME_NOTIFY, ioc_handle_notify}, { | ||
5111 | + IOCTL_1588_PULSE_PER_SEC_NOTIFY, ioc_handle_notify}, { | ||
5112 | + IOCTL_1588_AUX_TARG_TIME_NOTIFY, ioc_handle_notify}, { | ||
5113 | + IOCTL_1588_TARG_TIME_CLR_NOTIFY, ioc_handle_clr_notify}, { | ||
5114 | + IOCTL_1588_AUX_TIME_CLR_NOTIFY, ioc_handle_clr_notify}, { | ||
5115 | + IOCTL_1588_PULSE_PER_SEC_CLR_NOTIFY, ioc_handle_clr_notify}, { | ||
5116 | + IOCTL_1588_AUX_TARG_TIME_CLR_NOTIFY, ioc_handle_clr_notify}, { | ||
5117 | + IOCTL_1588_RESET, ioc_handle_reset}, { | ||
5118 | + IOCTL_1588_CHNL_RESET, ioc_handle_reset}, /* for this case too */ | ||
5119 | + { | ||
5120 | + IOCTL_1588_SHOW_ALL, ioc_handle_show}, { | ||
5121 | + IOCTL_1588_STATS_GET, ioc_handle_stats}, { | ||
5122 | + IOCTL_1588_STATS_RESET, ioc_handle_stats_reset}, { | ||
5123 | + IOCTL_1588_TARG_TIME_INTRPT_ENABLE, ioc_handle_int_enable}, { | ||
5124 | + IOCTL_1588_AUX_TIME_INTRPT_ENABLE, ioc_handle_int_enable}, { | ||
5125 | + IOCTL_1588_PULSE_PER_SEC_INTRPT_ENABLE, ioc_handle_int_enable}, { | ||
5126 | + IOCTL_1588_AUX_TARG_TIME_INTRPT_ENABLE, ioc_handle_int_enable}, { | ||
5127 | + IOCTL_1588_TARG_TIME_INTRPT_DISABLE, ioc_handle_int_disable}, { | ||
5128 | + IOCTL_1588_AUX_TIME_INTRPT_DISABLE, ioc_handle_int_disable}, { | ||
5129 | + IOCTL_1588_PULSE_PER_SEC_INTRPT_DISABLE, ioc_handle_int_disable}, { | ||
5130 | + IOCTL_1588_AUX_TARG_TIME_INTRPT_DISABLE, ioc_handle_int_disable}, { | ||
5131 | + IOCTL_1588_PORT_CONFIG_SET, ioc_handle_port_config}, { | ||
5132 | + IOCTL_1588_PORT_CONFIG_GET, ioc_handle_port_config}, { | ||
5133 | + IOCTL_1588_RX_POLL, ioc_handle_poll}, { | ||
5134 | + IOCTL_1588_TX_POLL, ioc_handle_poll}, { | ||
5135 | + IOCTL_1588_CAN_POLL, ioc_handle_poll}, { | ||
5136 | + IOCTL_1588_TARG_TIME_POLL, ioc_handle_poll}, { | ||
5137 | + IOCTL_1588_AUX_TIME_POLL, ioc_handle_poll}, { | ||
5138 | + IOCTL_1588_AUX_TARG_TIME_POLL, ioc_handle_poll}, { | ||
5139 | + IOCTL_1588_SYS_TIME_SET, ioc_handle_time_set}, { | ||
5140 | + IOCTL_1588_TARG_TIME_SET, ioc_handle_time_set}, { | ||
5141 | + IOCTL_1588_AUX_TARG_TIME_SET, ioc_handle_time_set}, { | ||
5142 | + IOCTL_1588_SYS_TIME_GET, ioc_handle_time_get}, { | ||
5143 | + IOCTL_1588_TARG_TIME_GET, ioc_handle_time_get}, { | ||
5144 | + IOCTL_1588_AUX_TARG_TIME_GET, ioc_handle_time_get}, { | ||
5145 | + IOCTL_1588_TICK_RATE_GET, ioc_handle_tick_rate}, { | ||
5146 | + IOCTL_1588_TICK_RATE_SET, ioc_handle_tick_rate}, { | ||
5147 | + IOCTL_1588_PULSE_PER_SEC_TIME_SET, ioc_handle_pps_reqt}, { | ||
5148 | + IOCTL_1588_PULSE_PER_SEC_TIME_GET, ioc_handle_pps_reqt}, { | ||
5149 | + IOCTL_1588_PORT_VERSION_SET, ioc_handle_version_reqt}, { | ||
5150 | + IOCTL_1588_PORT_VERSION_GET, ioc_handle_version_reqt}, { | ||
5151 | + IOCTL_1588_PORT_OPERATION_MODE_SET, ioc_handle_op_mode_reqt}, { | ||
5152 | +IOCTL_1588_PORT_OPERATION_MODE_GET, ioc_handle_op_mode_reqt},}; | ||
5153 | + | ||
5154 | +#define IOH_1588_IOC_TBL_ENTRIES \ | ||
5155 | + (sizeof ioh_1588_ioc_tbl / sizeof ioh_1588_ioc_tbl[0]) | ||
5156 | + | ||
5157 | +/*! @ingroup IEEE_1588_InterfaceLayerAPI | ||
5158 | + * @fn int ioh_1588_open(struct inode *inode, struct file *filep) | ||
5159 | + * @brief This function is called when the driver interface is opened | ||
5160 | + * @remarks This function is registered at the driver initialization | ||
5161 | + * point (module_init) and invoked when a process opens the | ||
5162 | + * IEEE 1588 device node. | ||
5163 | + * | ||
5164 | + * @param inode [IN] pointer to device inode structure | ||
5165 | + * @param filep [IN] pointer to open file structure | ||
5166 | + * | ||
5167 | + * @return int | ||
5168 | + * - Returns 0 on success and <0 on failure | ||
5169 | + */ | ||
5170 | +static int ioh_1588_open(struct inode *inode, struct file *filep) | ||
5171 | +{ | ||
5172 | + if (ioh_1588_devp->suspend) { | ||
5173 | + IOH_LOG(KERN_ERR, | ||
5174 | + "ioh_1588_open returning as device is suspended\n"); | ||
5175 | + return -EINTR; | ||
5176 | + } | ||
5177 | + IOH_DEBUG("ioh_1588_open\n"); | ||
5178 | + | ||
5179 | + return 0; | ||
5180 | +} | ||
5181 | + | ||
5182 | +/*! @ingroup IEEE_1588_InterfaceLayerAPI | ||
5183 | + * @fn int ioh_1588_release(struct inode *inode, struct file *filep) | ||
5184 | + * @brief This function is called when the driver interface is closed | ||
5185 | + * @remarks This function is registered at the driver initialization | ||
5186 | + * point (module_init) and invoked when the last process | ||
5187 | + * which has an open file table entry for the device | ||
5188 | + * exits or does a close of the device file. | ||
5189 | + * | ||
5190 | + * @param inode [IN] pointer to device inode structure | ||
5191 | + * @param filep [IN] pointer to open file structure | ||
5192 | + * | ||
5193 | + * @retval int | ||
5194 | + * - Returns 0 on success and <0 on failure | ||
5195 | + */ | ||
5196 | +static int ioh_1588_release(struct inode *inode, struct file *filep) | ||
5197 | +{ | ||
5198 | + IOH_DEBUG("ioh_1588_release\n"); | ||
5199 | + | ||
5200 | + return 0; | ||
5201 | +} | ||
5202 | + | ||
5203 | +/*! @ingroup IEEE_1588_InterfaceLayerAPI | ||
5204 | + * @fn int ioh_1588_ioctl(struct inode *inode, struct file *filep, | ||
5205 | + * unsigned int cmd, unsigned long arg) | ||
5206 | + * @brief This function implements the ioctl interface of the driver | ||
5207 | + * @remarks This function is registered at the driver initialization | ||
5208 | + * point (module_init) and invoked when a user process | ||
5209 | + * invokes the .ioctl. call on the device | ||
5210 | + * | ||
5211 | + * @param inode [IN] pointer to device inode structure | ||
5212 | + * @param filep [IN] pointer to open file structure | ||
5213 | + * @param cmd [IN] ioctl command | ||
5214 | + * @param arg [INOUT] argument passed to the command | ||
5215 | + * | ||
5216 | + * @retval int | ||
5217 | + * - Returns 0 on success and <0 on failure | ||
5218 | + */ | ||
5219 | +static int ioh_1588_ioctl(struct inode *inode, struct file *filep, | ||
5220 | + unsigned int cmd, unsigned long arg) | ||
5221 | +{ | ||
5222 | + char buffer[0x64]; | ||
5223 | + unsigned int argsz; | ||
5224 | + int i, ret = 0; | ||
5225 | + | ||
5226 | + if ((!ioh_1588_devp->initialized) || (ioh_1588_devp->suspend)) { | ||
5227 | + IOH_LOG(KERN_ERR, | ||
5228 | + "ioh_1588_ioctl:device is suspended OR \ | ||
5229 | + uninitialized\n"); | ||
5230 | + return -EINTR; | ||
5231 | + } | ||
5232 | + | ||
5233 | + argsz = _IOC_SIZE(cmd); | ||
5234 | + | ||
5235 | + if (argsz > sizeof buffer) { | ||
5236 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: buffer size too small.\n"); | ||
5237 | + return -EINVAL; | ||
5238 | + } | ||
5239 | + | ||
5240 | + /* if data is being written to the driver */ | ||
5241 | + if (_IOC_DIR(cmd) & _IOC_WRITE) { | ||
5242 | + /* get the data passed in by user */ | ||
5243 | + if (copy_from_user(&buffer, (void *)arg, argsz)) { | ||
5244 | + IOH_LOG(KERN_ERR, | ||
5245 | + "ioh_1588_ioctl: could not copy user space \ | ||
5246 | + data.\n"); | ||
5247 | + return -EFAULT; | ||
5248 | + } | ||
5249 | + } | ||
5250 | + | ||
5251 | + for (i = 0; i < IOH_1588_IOC_TBL_ENTRIES; i++) { | ||
5252 | + if (ioh_1588_ioc_tbl[i].cmd == cmd) { | ||
5253 | + ret = ioh_1588_ioc_tbl[i].func(cmd, buffer); | ||
5254 | + break; | ||
5255 | + } | ||
5256 | + } | ||
5257 | + if (i >= IOH_1588_IOC_TBL_ENTRIES) { /* did not find a match */ | ||
5258 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: unknown command (0x%x)\n", | ||
5259 | + cmd); | ||
5260 | + return -EINVAL; | ||
5261 | + } | ||
5262 | + | ||
5263 | + /* if data is being read from the driver */ | ||
5264 | + if ((ret == 0) && (_IOC_DIR(cmd) & _IOC_READ)) { | ||
5265 | + if (copy_to_user((void *)arg, buffer, argsz)) { | ||
5266 | + IOH_LOG(KERN_ERR, | ||
5267 | + "ioh_1588_ioctl: could not copy data to user \ | ||
5268 | + space.\n"); | ||
5269 | + return -EFAULT; | ||
5270 | + } | ||
5271 | + } | ||
5272 | + | ||
5273 | + return ret; | ||
5274 | +} | ||
5275 | + | ||
5276 | +/* Handles all NOTIFY IOCTLs */ | ||
5277 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5278 | + * @fn ioc_handle_notify (unsigned long cmd, char *buf) | ||
5279 | + * @brief Handles all NOTIFY IOCTLs | ||
5280 | + * @param cmd [IN] the IOCTL command | ||
5281 | + * @param buf [OUT] the reference to data to be returned | ||
5282 | + * @retval int | ||
5283 | + * - 0 | ||
5284 | + * <hr> | ||
5285 | + */ | ||
5286 | +static int ioc_handle_notify(unsigned long cmd, char *buf) | ||
5287 | +{ | ||
5288 | + unsigned int bytes_ret = 0; | ||
5289 | + void *param_addr = NULL; | ||
5290 | + wait_queue_head_t *event = NULL; | ||
5291 | + unsigned int eventnum = 0; | ||
5292 | + | ||
5293 | + if (IOCTL_1588_AUX_TARG_TIME_NOTIFY == cmd) { | ||
5294 | + IOH_LOG(KERN_ERR, "ioc_handle_notify \ | ||
5295 | + returning...[cmd = IOCTL_1588_AUX_TARG_TIME_NOTIFY]\n"); | ||
5296 | + return -EINVAL; | ||
5297 | + } | ||
5298 | + /* request to be notified of a 1588 interrupt event Target Time */ | ||
5299 | + else if (cmd == IOCTL_1588_TARG_TIME_NOTIFY) { | ||
5300 | + IOH_DEBUG | ||
5301 | + ("ioc_handle_notify cmd = IOCTL_1588_TARG_TIME_NOTIFY]\n"); | ||
5302 | + event = &ioh_1588_devp->notify_evt[TARG_TIME_EVENT_NUM]; | ||
5303 | + bytes_ret = sizeof(struct ioh1588TimeValue); | ||
5304 | + param_addr = &ioh_1588_target_time; | ||
5305 | + eventnum = TARG_TIME_EVENT_NUM; | ||
5306 | + } else if (cmd == IOCTL_1588_AUX_TIME_NOTIFY) { | ||
5307 | + IOH_DEBUG | ||
5308 | + ("ioc_handle_notify cmd = IOCTL_1588_AUX_TIME_NOTIFY]\n"); | ||
5309 | + event = &ioh_1588_devp->notify_evt[AUX_TIME_EVENT_NUM]; | ||
5310 | + bytes_ret = sizeof(struct ioh1588AuxTimeIoctl); | ||
5311 | + param_addr = &ioh_1588_aux_time; | ||
5312 | + eventnum = AUX_TIME_EVENT_NUM; | ||
5313 | + } else { | ||
5314 | + event = &ioh_1588_devp->notify_evt[PPS_EVENT_NUM]; | ||
5315 | + bytes_ret = sizeof(unsigned long); | ||
5316 | + param_addr = &ioh_1588_pps_time; | ||
5317 | + eventnum = PPS_EVENT_NUM; | ||
5318 | + } | ||
5319 | + | ||
5320 | + ioh_1588_devp->event_flags[eventnum] = 0; | ||
5321 | + | ||
5322 | + /* wait infinitely for a 1588 interrupt event to occur */ | ||
5323 | + IOH_DEBUG("ioc_handle_notify waiting for interrupt event...\n"); | ||
5324 | + wait_event_interruptible(*event, | ||
5325 | + ioh_1588_devp->event_flags[eventnum] == 1); | ||
5326 | + IOH_DEBUG("ioc_handle_notify got interrupt event...\n"); | ||
5327 | + | ||
5328 | + /* copy global data retreived from interrupt handler */ | ||
5329 | + (void)memcpy((void *)&buf, (const void *)param_addr, bytes_ret); | ||
5330 | + | ||
5331 | + /* reset global data to 0 */ | ||
5332 | + (void)memset((void *)param_addr, 0, bytes_ret); | ||
5333 | + | ||
5334 | + ioh_1588_devp->event_flags[eventnum] = 0; | ||
5335 | + | ||
5336 | + return 0; | ||
5337 | +} | ||
5338 | + | ||
5339 | +/* Handles all CLEAR NOTIFY IOCTLs */ | ||
5340 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5341 | + * @fn ioc_handle_clr_notify (unsigned long cmd, char *buf) | ||
5342 | + * @brief Handles all CLEAR NOTIFY IOCTLs | ||
5343 | + * @param cmd [IN] the IOCTL command | ||
5344 | + * @param buf unused | ||
5345 | + * @retval int | ||
5346 | + * - 0 on success | ||
5347 | + * - -EINVAL for unsupported IOCTL | ||
5348 | + * <hr> | ||
5349 | + */ | ||
5350 | +static int ioc_handle_clr_notify(unsigned long cmd, char *buf) | ||
5351 | +{ | ||
5352 | + unsigned int eventnum = 0; | ||
5353 | + | ||
5354 | + /* | ||
5355 | + * request to release a notify thread that is waiting | ||
5356 | + * on a 1588 interrupt event | ||
5357 | + */ | ||
5358 | + if (cmd == IOCTL_1588_TARG_TIME_CLR_NOTIFY) { | ||
5359 | + IOH_DEBUG | ||
5360 | + ("ioc_handle_clr_notify cmd=\ | ||
5361 | + IOCTL_1588_TARG_TIME_CLR_NOTIFY\n"); | ||
5362 | + eventnum = TARG_TIME_EVENT_NUM; | ||
5363 | + } else if (cmd == IOCTL_1588_AUX_TIME_CLR_NOTIFY) { | ||
5364 | + IOH_DEBUG | ||
5365 | + ("ioc_handle_clr_notify cmd=\ | ||
5366 | + IOCTL_1588_AUX_TIME_CLR_NOTIFY\n"); | ||
5367 | + eventnum = AUX_TIME_EVENT_NUM; | ||
5368 | + } else if (cmd == IOCTL_1588_PULSE_PER_SEC_CLR_NOTIFY) { | ||
5369 | + IOH_DEBUG | ||
5370 | + ("ioc_handle_clr_notify cmd=\ | ||
5371 | + IOCTL_1588_PULSE_PER_SEC_CLR_NOTIFY\n"); | ||
5372 | + eventnum = PPS_EVENT_NUM; | ||
5373 | + } else if (cmd == IOCTL_1588_AUX_TARG_TIME_CLR_NOTIFY) { | ||
5374 | + IOH_DEBUG | ||
5375 | + ("ioc_handle_clr_notify cmd=\ | ||
5376 | + IOCTL_1588_AUX_TARG_TIME_CLR_NOTIFY\n"); | ||
5377 | + IOH_LOG(KERN_ERR, "ioc_handle_clr_notify returning -EINVAL\n"); | ||
5378 | + return -EINVAL; | ||
5379 | + } | ||
5380 | + | ||
5381 | + ioh_1588_devp->event_flags[eventnum] = 1; | ||
5382 | + | ||
5383 | + IOH_DEBUG("ioc_handle_clr_notify waking up blocking notify call...\n"); | ||
5384 | + wake_up_interruptible(&ioh_1588_devp->notify_evt[eventnum]); | ||
5385 | + return 0; | ||
5386 | +} | ||
5387 | + | ||
5388 | +/* Handles reset and channel reset IOCTLs */ | ||
5389 | + | ||
5390 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5391 | + * @fn ioc_handle_reset (unsigned long cmd, char *buf) | ||
5392 | + * @brief Handles reset and channel reset IOCTLs | ||
5393 | + * @param cmd [IN] the IOCTL command | ||
5394 | + * @param buf unused | ||
5395 | + * @retval int | ||
5396 | + * - 0 on success | ||
5397 | + * - -EINVAL when hardware reset fails | ||
5398 | + * <hr> | ||
5399 | + */ | ||
5400 | +static int ioc_handle_reset(unsigned long cmd, char *buf) | ||
5401 | +{ | ||
5402 | + int i = 0; | ||
5403 | + int ieee_mode; | ||
5404 | + unsigned char station[STATION_ADDR_LEN] = "00:00:00:00:00:00"; | ||
5405 | + | ||
5406 | + IOH_DEBUG("ioc_handle_reset: invoking ioh_1588_reset\n"); | ||
5407 | + | ||
5408 | + /*retrieve eth/CAN mode */ | ||
5409 | + ieee_mode = ioh_1588_eth_can_get(); | ||
5410 | + | ||
5411 | + /*retrive station address */ | ||
5412 | + ioh_1588_get_station_address(station); | ||
5413 | + | ||
5414 | + /* reset the 1588 hardware */ | ||
5415 | + if (ioh_1588_reset() != IOH_1588_SUCCESS) { | ||
5416 | + IOH_LOG(KERN_ERR, "ioc_handle_reset: ioh_1588_reset failed\n"); | ||
5417 | + return -EINVAL; | ||
5418 | + } | ||
5419 | + /* Anyway, now clear all the events */ | ||
5420 | + for (i = 0; i < NUM_EVENTS; i++) | ||
5421 | + ioh_1588_devp->event_flags[i] = 0; | ||
5422 | + /*set ETH/CAN mode */ | ||
5423 | + if (ieee_mode & IOH_IEEE1588_ETH) | ||
5424 | + ioh_1588_eth_enable(); | ||
5425 | + if (ieee_mode & IOH_IEEE1588_CAN) | ||
5426 | + ioh_1588_can_enable(); | ||
5427 | + | ||
5428 | + /*set station address */ | ||
5429 | + if (strcmp(station, "00:00:00:00:00:00") != 0) { | ||
5430 | + if (ioh_1588_set_station_address(station) != IOH_1588_SUCCESS) { | ||
5431 | + IOH_LOG(KERN_ERR, | ||
5432 | + "ioh_1588_reset: could not set station \ | ||
5433 | + address\n"); | ||
5434 | + } | ||
5435 | + } | ||
5436 | + | ||
5437 | + IOH_DEBUG("ioc_handle_reset: returning 0\n"); | ||
5438 | + return 0; | ||
5439 | +} | ||
5440 | + | ||
5441 | +/* Handles reset statistics IOCTL */ | ||
5442 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5443 | + * @fn ioc_handle_stats_reset (unsigned long cmd, char *buf) | ||
5444 | + * @brief Handles reset statistics IOCTLs | ||
5445 | + * @param cmd unused | ||
5446 | + * @param buf unused | ||
5447 | + * @retval int | ||
5448 | + * - 0 on success | ||
5449 | + * <hr> | ||
5450 | + */ | ||
5451 | +static int ioc_handle_stats_reset(unsigned long cmd, char *buf) | ||
5452 | +{ | ||
5453 | + | ||
5454 | + IOH_DEBUG("ioc_handle_stats_reset: invoking ioh_1588_stats_reset\n"); | ||
5455 | + ioh_1588_stats_reset(); | ||
5456 | + IOH_DEBUG("ioc_handle_stats_reset: returning 0\n"); | ||
5457 | + return 0; | ||
5458 | +} | ||
5459 | + | ||
5460 | +/* Handles get statistics IOCTL */ | ||
5461 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5462 | + * @fn ioc_handle_stats (unsigned long cmd, char *buf) | ||
5463 | + * @brief Handles get statistics IOCTL | ||
5464 | + * @param cmd [IN] the IOCTL command | ||
5465 | + * @param buf [OUT] reference to statistics retrieved | ||
5466 | + * @retval int | ||
5467 | + * - 0 on success | ||
5468 | + * <hr> | ||
5469 | + */ | ||
5470 | +static int ioc_handle_stats(unsigned long cmd, char *buf) | ||
5471 | +{ | ||
5472 | + IOH_DEBUG("ioc_handle_stats: invoking ioh_ioh_1588_stats_get\n"); | ||
5473 | + if (ioh_1588_stats_get((struct ioh1588Stats *) buf) != \ | ||
5474 | + IOH_1588_SUCCESS) { | ||
5475 | + IOH_LOG(KERN_ERR, | ||
5476 | + "ioh_1588_ioctl: ioh_1588_stats_get failed\n"); | ||
5477 | + return -EINVAL; | ||
5478 | + } | ||
5479 | + IOH_DEBUG("ioc_handle_statst: returning 0\n"); | ||
5480 | + return 0; | ||
5481 | +} | ||
5482 | + | ||
5483 | +/* Handles show all IOCTL */ | ||
5484 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5485 | + * @fn ioc_handle_show (unsigned long cmd, char *buf) | ||
5486 | + * @brief Handles show all IOCTL | ||
5487 | + * @param cmd unused | ||
5488 | + * @param buf unused | ||
5489 | + * @retval int | ||
5490 | + * - 0 on success | ||
5491 | + * - -EINVAL when @ref ioh_1588_show fails | ||
5492 | + * <hr> | ||
5493 | + */ | ||
5494 | +static int ioc_handle_show(unsigned long cmd, char *buf) | ||
5495 | +{ | ||
5496 | + IOH_DEBUG("ioc_handle_show: invoking ioh_1588_show\n"); | ||
5497 | + if (ioh_1588_show() != IOH_1588_SUCCESS) { | ||
5498 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: ioh_1588_show failed\n"); | ||
5499 | + return -EINVAL; | ||
5500 | + } | ||
5501 | + IOH_DEBUG("ioc_handle_show: returning 0\n"); | ||
5502 | + return 0; | ||
5503 | +} | ||
5504 | + | ||
5505 | +/* Handles all interrupt enable IOCTLs */ | ||
5506 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5507 | + * @fn ioc_handle_int_enable (unsigned long cmd, char *buf) | ||
5508 | + * @brief Handles all interrupt enable IOCTLs | ||
5509 | + * @param cmd [IN] the IOCTL command | ||
5510 | + * @param buf [IN] the reference to auxiliary mode | ||
5511 | + * @retval int | ||
5512 | + * - 0 on success | ||
5513 | + * - -EINVAL failed to enable interrupt | ||
5514 | + * <hr> | ||
5515 | + */ | ||
5516 | +static int ioc_handle_int_enable(unsigned long cmd, char *buf) | ||
5517 | +{ | ||
5518 | + int ret = 0; | ||
5519 | + | ||
5520 | + if (IOCTL_1588_TARG_TIME_INTRPT_ENABLE == cmd) { | ||
5521 | + IOH_DEBUG | ||
5522 | + ("ioc_handle_int_enable cmd=\ | ||
5523 | + IOCTL_1588_TARG_TIME_INTRPT_ENABLE \ | ||
5524 | + invoking \ | ||
5525 | + ioh_1588_target_time_interrupt_enable\n"); | ||
5526 | + if (ioh_1588_target_time_interrupt_enable(target_time_callback) | ||
5527 | + != IOH_1588_SUCCESS) { | ||
5528 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5529 | + ioh_1588_target_time_interrupt_enable \ | ||
5530 | + failed\n"); | ||
5531 | + ret = -EINVAL; | ||
5532 | + } | ||
5533 | + } else if (IOCTL_1588_AUX_TIME_INTRPT_ENABLE == cmd) { | ||
5534 | + enum ioh1588AuxMode aux_mode; | ||
5535 | + IOH_DEBUG | ||
5536 | + ("ioc_handle_int_enable cmd=\ | ||
5537 | + IOCTL_1588_AUX_TIME_INTRPT_ENABLE \ | ||
5538 | + invoking ioh_1588_aux_time_interrupt_enable\n"); | ||
5539 | + | ||
5540 | + (void)memcpy((void *)&aux_mode, (const void *)buf, | ||
5541 | + sizeof(enum ioh1588AuxMode)); | ||
5542 | + | ||
5543 | + if (ioh_1588_aux_time_interrupt_enable | ||
5544 | + (aux_mode, auxiliary_time_callback) != IOH_1588_SUCCESS) { | ||
5545 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5546 | + ioh_1588_aux_time_interrupt_enable \ | ||
5547 | + failed\n"); | ||
5548 | + ret = -EINVAL; | ||
5549 | + } | ||
5550 | + } else if (IOCTL_1588_PULSE_PER_SEC_INTRPT_ENABLE == cmd) { | ||
5551 | + IOH_DEBUG | ||
5552 | + ("ioc_handle_int_enable cmd=\ | ||
5553 | + IOCTL_1588_PULSE_PER_SEC_INTRPT_ENABLE \ | ||
5554 | + invoking \ | ||
5555 | + ioh_1588_pulse_per_sec_interrupt_enable\n"); | ||
5556 | + if (ioh_1588_pulse_per_sec_interrupt_enable | ||
5557 | + (pulse_per_sec_callback) | ||
5558 | + != IOH_1588_SUCCESS) { | ||
5559 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5560 | + ioh_1588_pps_interrupt_enable \ | ||
5561 | + failed\n"); | ||
5562 | + ret = -EINVAL; | ||
5563 | + } | ||
5564 | + } else { /* IOCTL_1588_AUX_TARG_TIME_INTRPT_ENABLE */ | ||
5565 | + | ||
5566 | + IOH_DEBUG | ||
5567 | + ("ioc_handle_int_enable cmd=\ | ||
5568 | + OCTL_1588_AUX_TARG_TIME_INTRPT_ENABLE \ | ||
5569 | + invoking \ | ||
5570 | + ioh_1588_aux_target_time_interrupt_enable\n"); | ||
5571 | + if (ioh_1588_aux_target_time_interrupt_enable((void *)NULL) | ||
5572 | + != IOH_1588_SUCCESS) { | ||
5573 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5574 | + ioh_1588_aux_target_time_interrupt_enable \ | ||
5575 | + failed\n"); | ||
5576 | + ret = -EINVAL; | ||
5577 | + } | ||
5578 | + } | ||
5579 | + return ret; | ||
5580 | +} | ||
5581 | + | ||
5582 | +/* Handles all interrupt disable IOCTLs */ | ||
5583 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5584 | + * @fn ioc_handle_int_disable (unsigned long cmd, char *buf) | ||
5585 | + * @brief Handles all interrupt enable IOCTLs | ||
5586 | + * @param cmd [IN] the IOCTL command | ||
5587 | + * @param buf [IN] the reference to auxiliary mode | ||
5588 | + * @retval int | ||
5589 | + * - 0 on success | ||
5590 | + * - -EINVAL failed to disable interrupt | ||
5591 | + * <hr> | ||
5592 | + */ | ||
5593 | +static int ioc_handle_int_disable(unsigned long cmd, char *buf) | ||
5594 | +{ | ||
5595 | + int ret = 0; | ||
5596 | + | ||
5597 | + if (IOCTL_1588_TARG_TIME_INTRPT_DISABLE == cmd) { | ||
5598 | + IOH_DEBUG | ||
5599 | + ("ioc_handle_int_disable cmd=\ | ||
5600 | + IOCTL_1588_TARG_TIME_INTRPT_DISABLE \ | ||
5601 | + invoking \ | ||
5602 | + ioh_1588_target_time_interrupt_disable\n"); | ||
5603 | + if (ioh_1588_target_time_interrupt_disable() | ||
5604 | + != IOH_1588_SUCCESS) { | ||
5605 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5606 | + ioh_1588_target_time_interrupt_disable \ | ||
5607 | + failed\n"); | ||
5608 | + ret = -EINVAL; | ||
5609 | + } | ||
5610 | + } else if (IOCTL_1588_AUX_TIME_INTRPT_DISABLE == cmd) { | ||
5611 | + enum ioh1588AuxMode aux_mode; | ||
5612 | + IOH_DEBUG | ||
5613 | + ("ioc_handle_int_disable cmd=\ | ||
5614 | + IOCTL_1588_AUX_TIME_INTRPT_DISABLE \ | ||
5615 | + invoking \ | ||
5616 | + ioh_1588_aux_time_interrupt_disable\n"); | ||
5617 | + | ||
5618 | + (void)memcpy((void *)&aux_mode, (const void *)buf, | ||
5619 | + sizeof(enum ioh1588AuxMode)); | ||
5620 | + | ||
5621 | + if (ioh_1588_aux_time_interrupt_disable(aux_mode) | ||
5622 | + != IOH_1588_SUCCESS) { | ||
5623 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5624 | + ioh_1588_aux_time_interrupt_disable \ | ||
5625 | + failed\n"); | ||
5626 | + ret = -EINVAL; | ||
5627 | + } | ||
5628 | + } else if (IOCTL_1588_PULSE_PER_SEC_INTRPT_DISABLE == cmd) { | ||
5629 | + IOH_DEBUG | ||
5630 | + ("ioc_handle_int_disable cmd=\ | ||
5631 | + IOCTL_1588_PULSE_PER_SEC_INTRPT_DISABLE \ | ||
5632 | + invoking \ | ||
5633 | + ioh_1588_pulse_per_sec_interrupt_disable\n"); | ||
5634 | + if (ioh_1588_pulse_per_sec_interrupt_disable() != | ||
5635 | + IOH_1588_SUCCESS) { | ||
5636 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5637 | + ioh_1588_pulse_per_sec_interrupt_disable \ | ||
5638 | + failed\n"); | ||
5639 | + ret = -EINVAL; | ||
5640 | + } | ||
5641 | + } else { /* IOCTL_1588_AUX_TARG_TIME_INTRPT_DISABLE */ | ||
5642 | + | ||
5643 | + IOH_DEBUG | ||
5644 | + ("ioc_handle_int_disable cmd=\ | ||
5645 | + IOCTL_1588_AUX_TARG_TIME_INTRPT_DISABLE \ | ||
5646 | + invoking \ | ||
5647 | + ioh_1588_aux_target_time_interrupt_disable\n"); | ||
5648 | + if (ioh_1588_aux_target_time_interrupt_disable() != | ||
5649 | + IOH_1588_SUCCESS) { | ||
5650 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5651 | + ioh_1588_aux_target_time_interrupt_disable \ | ||
5652 | + failed\n"); | ||
5653 | + ret = -EINVAL; | ||
5654 | + } | ||
5655 | + } | ||
5656 | + return ret; | ||
5657 | +} | ||
5658 | + | ||
5659 | +/* Handles port config set/get IOCTLs */ | ||
5660 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5661 | + * @fn ioc_handle_port_config (unsigned long cmd, char *buf) | ||
5662 | + * @brief Handles port config set/get IOCTLs | ||
5663 | + * @param cmd [IN] the IOCTL command | ||
5664 | + * @param buf [IN] the port configuration | ||
5665 | + * @retval int | ||
5666 | + * - 0 on success | ||
5667 | + * - -EINVAL failed to set/get port configuration | ||
5668 | + * <hr> | ||
5669 | + */ | ||
5670 | +static int ioc_handle_port_config(unsigned long cmd, char *buf) | ||
5671 | +{ | ||
5672 | + struct ioh1588PortCfgIoctl *port_cfg_ioctl = \ | ||
5673 | + (struct ioh1588PortCfgIoctl *) buf; | ||
5674 | + | ||
5675 | + if (IOCTL_1588_PORT_CONFIG_SET == cmd) { | ||
5676 | + IOH_DEBUG | ||
5677 | + ("ioc_handle_port_config cmd = IOCTL_1588_PORT_CONFIG_SET \ | ||
5678 | + invoking ioh_1588_ptp_port_config_set\n"); | ||
5679 | + | ||
5680 | + if (ioh_1588_ptp_port_config_set(port_cfg_ioctl->ptpPort, | ||
5681 | + port_cfg_ioctl->ptpPortMode) != | ||
5682 | + IOH_1588_SUCCESS) { | ||
5683 | + IOH_LOG(KERN_ERR, | ||
5684 | + "ioh_1588_ioctl: ioh_1588_ptp_port_config_set \ | ||
5685 | + failed\n"); | ||
5686 | + return -EINVAL; | ||
5687 | + } | ||
5688 | + } else { /* IOCTL_1588_PORT_CONFIG_GET */ | ||
5689 | + | ||
5690 | + IOH_DEBUG | ||
5691 | + ("ioc_handle_port_config cmd = IOCTL_1588_PORT_CONFIG_GET \ | ||
5692 | + invoking ioh_1588_ptp_port_config_get\n"); | ||
5693 | + if (ioh_1588_ptp_port_config_get | ||
5694 | + (port_cfg_ioctl->ptpPort, | ||
5695 | + &port_cfg_ioctl->ptpPortMode) != IOH_1588_SUCCESS) { | ||
5696 | + IOH_LOG(KERN_ERR, | ||
5697 | + "ioh_1588_ioctl: ioh_1588_ptp_port_config_get \ | ||
5698 | + failed\n"); | ||
5699 | + return -EINVAL; | ||
5700 | + } | ||
5701 | + } | ||
5702 | + return 0; | ||
5703 | +} | ||
5704 | + | ||
5705 | +/* Handles all POLL IOCTLs */ | ||
5706 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5707 | + * @fn ioc_handle_poll (unsigned long cmd, char *buf) | ||
5708 | + * @brief Handles all poll IOCTLs | ||
5709 | + * @param cmd [IN] the IOCTL command | ||
5710 | + * @param buf [IN] the poll configuration | ||
5711 | + * @retval int | ||
5712 | + * - 0 on success | ||
5713 | + * - -EINVAL on failure | ||
5714 | + * <hr> | ||
5715 | + */ | ||
5716 | +static int ioc_handle_poll(unsigned long cmd, char *buf) | ||
5717 | +{ | ||
5718 | + int ret = 0; | ||
5719 | + struct ioh1588RxTxPollIoctl *poll_ioctl = \ | ||
5720 | + (struct ioh1588RxTxPollIoctl *) buf; | ||
5721 | + struct ioh1588CANPollIoctl *can_poll_ioctl = \ | ||
5722 | + (struct ioh1588CANPollIoctl *) buf; | ||
5723 | + struct ioh1588TimePollIoctl *time_poll_ioctl = \ | ||
5724 | + (struct ioh1588TimePollIoctl *) buf; | ||
5725 | + | ||
5726 | + if (IOCTL_1588_RX_POLL == cmd) { | ||
5727 | + IOH_DEBUG("ioc_handle_poll: cmd = IOCTL_1588_RX_POLL \ | ||
5728 | + invoking ioh_1588_ptp_rx_poll\n"); | ||
5729 | + ret = ioh_1588_ptp_rx_poll(poll_ioctl->ptpPort, | ||
5730 | + &poll_ioctl->ptpMsgData); | ||
5731 | + if ((ret != IOH_1588_SUCCESS) && \ | ||
5732 | + (ret != IOH_1588_NOTIMESTAMP)) { | ||
5733 | + IOH_LOG(KERN_ERR, | ||
5734 | + "ioh_1588_ioctl: ioh_1588_ptp_rx_poll \ | ||
5735 | + failed\n"); | ||
5736 | + ret = -EINVAL; | ||
5737 | + } | ||
5738 | + } else if (IOCTL_1588_TX_POLL == cmd) { | ||
5739 | + IOH_DEBUG("ioc_handle_poll: cmd = IOCTL_1588_TX_POLL \ | ||
5740 | + invoking ioh_1588_ptp_tx_poll\n"); | ||
5741 | + ret = ioh_1588_ptp_tx_poll(poll_ioctl->ptpPort, | ||
5742 | + &poll_ioctl->ptpMsgData); | ||
5743 | + if ((ret != IOH_1588_SUCCESS) && \ | ||
5744 | + (ret != IOH_1588_NOTIMESTAMP)) { | ||
5745 | + IOH_LOG(KERN_ERR, | ||
5746 | + "ioh_1588_ioctl: ioh_1588_ptp_tx_poll \ | ||
5747 | + failed\n"); | ||
5748 | + ret = -EINVAL; | ||
5749 | + } | ||
5750 | + } else if (IOCTL_1588_CAN_POLL == cmd) { | ||
5751 | + IOH_DEBUG("ioc_handle_poll: cmd = IOCTL_1588_CAN_POLL \ | ||
5752 | + invoking ioh_1588_ptp_can_poll\n"); | ||
5753 | + ret = ioh_1588_ptp_can_poll(can_poll_ioctl->ptpPort, | ||
5754 | + &can_poll_ioctl->ptpTimeStamp); | ||
5755 | + if ((ret != IOH_1588_SUCCESS) && \ | ||
5756 | + (ret != IOH_1588_NOTIMESTAMP)) { | ||
5757 | + IOH_LOG(KERN_ERR, | ||
5758 | + "ioh_1588_ioctl: ioh_1588_ptp_can_poll \ | ||
5759 | + failed\n"); | ||
5760 | + ret = -EINVAL; | ||
5761 | + } | ||
5762 | + } else if (IOCTL_1588_TARG_TIME_POLL == cmd) { | ||
5763 | + IOH_DEBUG("ioc_handle_poll: cmd = IOCTL_1588_TARG_TIME_POLL " | ||
5764 | + "invoking ioh_1588_target_time_poll\n"); | ||
5765 | + if (ioh_1588_target_time_poll(&time_poll_ioctl->pollFlag, | ||
5766 | + &time_poll_ioctl->timeVal) != | ||
5767 | + IOH_1588_SUCCESS) { | ||
5768 | + IOH_LOG(KERN_ERR, | ||
5769 | + "ioh_1588_ioctl: ioh_1588_target_time_poll \ | ||
5770 | + failed\n"); | ||
5771 | + ret = -EINVAL; | ||
5772 | + } | ||
5773 | + } else if (IOCTL_1588_AUX_TIME_POLL == cmd) { | ||
5774 | + IOH_DEBUG("ioc_handle_poll: cmd = IOCTL_1588_AUX_TIME_POLL " | ||
5775 | + "invoking ioh_1588_aux_time_poll\n"); | ||
5776 | + if (ioh_1588_aux_time_poll(time_poll_ioctl->auxMode, | ||
5777 | + &time_poll_ioctl->pollFlag, | ||
5778 | + &time_poll_ioctl->timeVal) | ||
5779 | + != IOH_1588_SUCCESS) { | ||
5780 | + IOH_LOG(KERN_ERR, | ||
5781 | + "ioh_1588_ioctl: ioh_1588_aux_time_poll \ | ||
5782 | + failed\n"); | ||
5783 | + ret = -EINVAL; | ||
5784 | + } | ||
5785 | + } else { /* IOCTL_1588_AUX_TARG_TIME_POLL */ | ||
5786 | + | ||
5787 | + IOH_DEBUG | ||
5788 | + ("ioc_handle_poll: cmd = IOCTL_1588_AUX_TARG_TIME_POLL " | ||
5789 | + "invoking ioh_1588_aux_target_time_poll\n"); | ||
5790 | + if (ioh_1588_aux_target_time_poll | ||
5791 | + (&time_poll_ioctl->pollFlag, | ||
5792 | + &time_poll_ioctl->timeVal) != IOH_1588_SUCCESS) { | ||
5793 | + IOH_LOG(KERN_ERR, | ||
5794 | + "ioh_1588_ioctl: ioh_1588_aux_target_time_poll \ | ||
5795 | + failed\n"); | ||
5796 | + ret = -EINVAL; | ||
5797 | + } | ||
5798 | + } | ||
5799 | + if ((unsigned long)ret == IOH_1588_NOTIMESTAMP) | ||
5800 | + ret = 0; | ||
5801 | + return ret; | ||
5802 | +} | ||
5803 | + | ||
5804 | +/* Handles all Time Set IOCTLs */ | ||
5805 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5806 | + * @fn ioc_handle_time_set (unsigned long cmd, char *buf) | ||
5807 | + * @brief Handles all Time Set IOCTLs | ||
5808 | + * @param cmd [IN] the IOCTL command | ||
5809 | + * @param buf [IN] the time value | ||
5810 | + * @retval int | ||
5811 | + * - 0 on success | ||
5812 | + * - -EINVAL on failure | ||
5813 | + * <hr> | ||
5814 | + */ | ||
5815 | +static int ioc_handle_time_set(unsigned long cmd, char *buf) | ||
5816 | +{ | ||
5817 | + struct ioh1588TimeValue time_value; | ||
5818 | + | ||
5819 | + (void)memcpy((void *)&time_value, (const void *)buf, | ||
5820 | + sizeof(struct ioh1588TimeValue)); | ||
5821 | + | ||
5822 | + if (IOCTL_1588_SYS_TIME_SET == cmd) { | ||
5823 | + IOH_DEBUG("ioc_handle_time_set cmd=IOCTL_1588_SYS_TIME_SET \ | ||
5824 | + invoking ioh_1588_system_time_set\n"); | ||
5825 | + if (ioh_1588_system_time_set(time_value) != IOH_1588_SUCCESS) { | ||
5826 | + IOH_LOG(KERN_ERR, | ||
5827 | + "ioh_1588_ioctl: ioh_1588_system_time_set \ | ||
5828 | + failed\n"); | ||
5829 | + return -EINVAL; | ||
5830 | + } | ||
5831 | + } else if (IOCTL_1588_TARG_TIME_SET == cmd) { | ||
5832 | + IOH_DEBUG("ioc_handle_time_set cmd=IOCTL_1588_TARG_TIME_SET \ | ||
5833 | + invoking ioh_1588_target_time_set\n"); | ||
5834 | + if (ioh_1588_target_time_set(time_value) != IOH_1588_SUCCESS) { | ||
5835 | + IOH_LOG(KERN_ERR, | ||
5836 | + "ioh_1588_ioctl: ioh_1588_target_time_set \ | ||
5837 | + failed\n"); | ||
5838 | + return -EINVAL; | ||
5839 | + } | ||
5840 | + } else { /* IOCTL_1588_AUX_TARG_TIME_SET */ | ||
5841 | + | ||
5842 | + IOH_DEBUG | ||
5843 | + ("ioc_handle_time_set cmd=IOCTL_1588_AUX_TARG_TIME_SET \ | ||
5844 | + invoking ioh_1588_aux_target_time_set\n"); | ||
5845 | + if (ioh_1588_aux_target_time_set(time_value) != | ||
5846 | + IOH_1588_SUCCESS) { | ||
5847 | + IOH_LOG(KERN_ERR, | ||
5848 | + "ioh_1588_ioctl: ioh_1588_aux_target_time_set \ | ||
5849 | + failed\n"); | ||
5850 | + return -EINVAL; | ||
5851 | + } | ||
5852 | + } | ||
5853 | + return 0; | ||
5854 | +} | ||
5855 | + | ||
5856 | +/* Handles all Time Get IOCTLs */ | ||
5857 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5858 | + * @fn ioc_handle_time_get (unsigned long cmd, char *buf) | ||
5859 | + * @brief Handles all Time Get IOCTLs | ||
5860 | + * @param cmd [IN] the IOCTL command | ||
5861 | + * @param buf [OUT] the time value | ||
5862 | + * @retval int | ||
5863 | + * - 0 on success | ||
5864 | + * - -EINVAL on failure | ||
5865 | + * <hr> | ||
5866 | + */ | ||
5867 | +static int ioc_handle_time_get(unsigned long cmd, char *buf) | ||
5868 | +{ | ||
5869 | + struct ioh1588TimeValue time_value; | ||
5870 | + | ||
5871 | + if (IOCTL_1588_SYS_TIME_GET == cmd) { | ||
5872 | + IOH_DEBUG("ioc_handle_time_get cmd=IOCTL_1588_SYS_TIME_GET \ | ||
5873 | + invoking ioh_1588_system_time_get\n"); | ||
5874 | + if (ioh_1588_system_time_get(&time_value) != IOH_1588_SUCCESS) { | ||
5875 | + IOH_LOG(KERN_ERR, | ||
5876 | + "ioh_1588_ioctl: ioh_1588_system_time_get \ | ||
5877 | + failed\n"); | ||
5878 | + return -EINVAL; | ||
5879 | + } | ||
5880 | + } else if (IOCTL_1588_TARG_TIME_GET == cmd) { | ||
5881 | + IOH_DEBUG("ioc_handle_time_get cmd=IOCTL_1588_TARG_TIME_GET \ | ||
5882 | + invoking ioh_1588_target_time_get\n"); | ||
5883 | + if (ioh_1588_target_time_get(&time_value) != IOH_1588_SUCCESS) { | ||
5884 | + IOH_LOG(KERN_ERR, | ||
5885 | + "ioh_1588_ioctl: ioh_1588_target_time_get \ | ||
5886 | + failed\n"); | ||
5887 | + return -EINVAL; | ||
5888 | + } | ||
5889 | + } else { /* IOCTL_1588_AUX_TARG_TIME_GET */ | ||
5890 | + | ||
5891 | + IOH_DEBUG | ||
5892 | + ("ioc_handle_time_get cmd=IOCTL_1588_AUX_TARG_TIME_GET \ | ||
5893 | + invoking ioh_1588_aux_target_time_get\n"); | ||
5894 | + if (ioh_1588_aux_target_time_get(&time_value)) { | ||
5895 | + IOH_LOG(KERN_ERR, | ||
5896 | + "ioh_1588_ioctl: ioh_1588_aux_target_time_set \ | ||
5897 | + failed\n"); | ||
5898 | + return -EINVAL; | ||
5899 | + } | ||
5900 | + } | ||
5901 | + | ||
5902 | + (void)memcpy((void *)buf, (const void *)&time_value, | ||
5903 | + sizeof(struct ioh1588TimeValue)); | ||
5904 | + return 0; | ||
5905 | +} | ||
5906 | + | ||
5907 | +/* Handles tick rate get/set IOCTLs */ | ||
5908 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5909 | + * @fn ioc_handle_tick_rate (unsigned long cmd, char *buf) | ||
5910 | + * @brief Handles tick rate get/set IOCTLs | ||
5911 | + * @param cmd [IN] the IOCTL command | ||
5912 | + * @param buf [OUT] the tick rate | ||
5913 | + * @retval int | ||
5914 | + * - 0 on success | ||
5915 | + * - -EINVAL on failure | ||
5916 | + * <hr> | ||
5917 | + */ | ||
5918 | +static int ioc_handle_tick_rate(unsigned long cmd, char *buf) | ||
5919 | +{ | ||
5920 | + unsigned long val; | ||
5921 | + | ||
5922 | + if (IOCTL_1588_TICK_RATE_GET == cmd) { | ||
5923 | + IOH_DEBUG("ioc_handle_tick_rate cmd =IOCTL_1588_TICK_RATE_GET \ | ||
5924 | + invoking ioh_1588_tick_rate_get\n"); | ||
5925 | + if (ioh_1588_tick_rate_get(&val) != IOH_1588_SUCCESS) { | ||
5926 | + IOH_LOG(KERN_ERR, | ||
5927 | + "ioh_1588_ioctl: ioh_1588_tick_rate_get \ | ||
5928 | + failed\n"); | ||
5929 | + return -EINVAL; | ||
5930 | + } | ||
5931 | + | ||
5932 | + (void)memcpy((void *)buf, (const void *)&val, sizeof val); | ||
5933 | + } else { /* (cmd == IOCTL_1588_TICK_RATE_SET) */ | ||
5934 | + | ||
5935 | + IOH_DEBUG("ioc_handle_tick_rate cmd =IOCTL_1588_TICK_RATE_SET \ | ||
5936 | + invoking ioh_1588_tick_rate_set\n"); | ||
5937 | + (void)memcpy((void *)&val, (const void *)buf, sizeof val); | ||
5938 | + | ||
5939 | + if (ioh_1588_tick_rate_set(val) != IOH_1588_SUCCESS) { | ||
5940 | + IOH_LOG(KERN_ERR, | ||
5941 | + "ioh_1588_ioctl: ioh_1588_tick_rate_set \ | ||
5942 | + failed\n"); | ||
5943 | + return -EINVAL; | ||
5944 | + } | ||
5945 | + } | ||
5946 | + return 0; | ||
5947 | +} | ||
5948 | + | ||
5949 | +/* Handles pps time get/set IOCTLs */ | ||
5950 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5951 | + * @fn ioc_handle_pps_reqt (unsigned long cmd, char *buf) | ||
5952 | + * @brief Handles pps time get/set IOCTLs | ||
5953 | + * @param cmd [IN] the IOCTL command | ||
5954 | + * @param buf [INOUT] the pulse per second value | ||
5955 | + * @retval int | ||
5956 | + * - 0 on success | ||
5957 | + * - -EINVAL on failure | ||
5958 | + * <hr> | ||
5959 | + */ | ||
5960 | +static int ioc_handle_pps_reqt(unsigned long cmd, char *buf) | ||
5961 | +{ | ||
5962 | + unsigned long val; | ||
5963 | + | ||
5964 | + if (IOCTL_1588_PULSE_PER_SEC_TIME_SET == cmd) { | ||
5965 | + IOH_DEBUG | ||
5966 | + ("ioc_handle_pps_reqt cmd=\ | ||
5967 | + IOCTL_1588_PULSE_PER_SEC_TIME_SET \ | ||
5968 | + invoking ioh_1588_pulse_per_sec_time_set\n"); | ||
5969 | + (void)memcpy((void *)&val, (const void *)buf, sizeof val); | ||
5970 | + if (ioh_1588_pulse_per_sec_time_set(val) != IOH_1588_SUCCESS) { | ||
5971 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5972 | + ioh_1588_pulse_per_sec_time_set \ | ||
5973 | + failed\n"); | ||
5974 | + return -EINVAL; | ||
5975 | + } | ||
5976 | + } else { /* IOCTL_1588_PULSE_PER_SEC_TIME_GET */ | ||
5977 | + | ||
5978 | + IOH_DEBUG | ||
5979 | + ("ioc_handle_pps_reqt cmd=\ | ||
5980 | + IOCTL_1588_PULSE_PER_SEC_TIME_GET \ | ||
5981 | + invoking ioh_1588_pulse_per_sec_time_get\n"); | ||
5982 | + if (ioh_1588_pulse_per_sec_time_get(&val) != IOH_1588_SUCCESS) { | ||
5983 | + IOH_LOG(KERN_ERR, "ioh_1588_ioctl: \ | ||
5984 | + ioh_1588_pulse_per_sec_time_get failed\n"); | ||
5985 | + return -EINVAL; | ||
5986 | + } | ||
5987 | + (void)memcpy((void *)buf, (const void *)&val, sizeof val); | ||
5988 | + } | ||
5989 | + return 0; | ||
5990 | +} | ||
5991 | + | ||
5992 | +/* Handles ptp version get/set IOCTLs */ | ||
5993 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
5994 | + * @fn ioc_handle_version_reqt (unsigned long cmd, char *buf) | ||
5995 | + * @brief Handles ptp version get/set IOCTLs | ||
5996 | + * @param cmd [IN] the IOCTL command | ||
5997 | + * @param buf [INOUT]the ptp version | ||
5998 | + * @retval int | ||
5999 | + * - 0 on success | ||
6000 | + * - -EINVAL on failure | ||
6001 | + * <hr> | ||
6002 | + */ | ||
6003 | +static int ioc_handle_version_reqt(unsigned long cmd, char *buf) | ||
6004 | +{ | ||
6005 | + struct ioh1588VersionIoctl *version_ioctl = \ | ||
6006 | + (struct ioh1588VersionIoctl *) buf; | ||
6007 | + | ||
6008 | + if (IOCTL_1588_PORT_VERSION_SET == cmd) { | ||
6009 | + IOH_DEBUG | ||
6010 | + ("ioc_handle_version_reqt cmd=IOCTL_1588_PORT_VERSION_SET \ | ||
6011 | + invoking ioh_1588_ptp_version_set\n"); | ||
6012 | + if (ioh_1588_ptp_version_set | ||
6013 | + (version_ioctl->ptpPort, | ||
6014 | + version_ioctl->ptpVersion) != IOH_1588_SUCCESS) { | ||
6015 | + IOH_LOG(KERN_ERR, | ||
6016 | + "ioh_1588_ioctl: ioh_1588_ptp_version_set \ | ||
6017 | + failed\n"); | ||
6018 | + return -EINVAL; | ||
6019 | + } | ||
6020 | + } else { /* IOCTL_1588_PORT_VERSION_GET */ | ||
6021 | + | ||
6022 | + IOH_DEBUG | ||
6023 | + ("ioc_handle_version_reqt cmd=IOCTL_1588_PORT_VERSION_GET \ | ||
6024 | + invoking ioh_1588_ptp_version_get\n"); | ||
6025 | + if (ioh_1588_ptp_version_get | ||
6026 | + (version_ioctl->ptpPort, | ||
6027 | + &version_ioctl->ptpVersion) != IOH_1588_SUCCESS) { | ||
6028 | + IOH_LOG(KERN_ERR, | ||
6029 | + "ioh_1588_ioctl: ioh_1588_ptp_version_get \ | ||
6030 | + failed\n"); | ||
6031 | + return -EINVAL; | ||
6032 | + } | ||
6033 | + } | ||
6034 | + return 0; | ||
6035 | +} | ||
6036 | + | ||
6037 | +/* Handles ptp operation mode get/set IOCTLs */ | ||
6038 | +/*! @ingroup IEEE_1588_UtilitiesAPI | ||
6039 | + * @fn ioc_handle_op_mode_reqt (unsigned long cmd, char *buf) | ||
6040 | + * @brief Handles ptp operation mode get/set IOCTLs | ||
6041 | + * @param cmd [IN] the IOCTL command | ||
6042 | + * @param buf [INOUT]the ptp operation mode | ||
6043 | + * @retval int | ||
6044 | + * - 0 on success | ||
6045 | + * - -EINVAL on failure | ||
6046 | + * <hr> | ||
6047 | + */ | ||
6048 | +static int ioc_handle_op_mode_reqt(unsigned long cmd, char *buf) | ||
6049 | +{ | ||
6050 | + struct ioh1588OperationModeIoctl *opmode_ioctl = | ||
6051 | + (struct ioh1588OperationModeIoctl *) buf; | ||
6052 | + | ||
6053 | + if (IOCTL_1588_PORT_OPERATION_MODE_SET == cmd) { | ||
6054 | + IOH_DEBUG | ||
6055 | + ("ioc_handle_op_mode_reqt cmd=\ | ||
6056 | + IOCTL_1588_PORT_OPERATION_MODE_SET \ | ||
6057 | + invoking ioh_1588_ptp_operation_mode_set\n"); | ||
6058 | + if (ioh_1588_ptp_operation_mode_set | ||
6059 | + (opmode_ioctl->ptpPort, | ||
6060 | + opmode_ioctl->ptpOpMode) != IOH_1588_SUCCESS) { | ||
6061 | + IOH_LOG(KERN_ERR, | ||
6062 | + "ioh_1588_ioctl: \ | ||
6063 | + ioh_1588_ptp_operation_mode_set failed\n"); | ||
6064 | + return -EINVAL; | ||
6065 | + } | ||
6066 | + } else { /* IOCTL_1588_PORT_OPERATION_MODE_GET */ | ||
6067 | + | ||
6068 | + IOH_DEBUG | ||
6069 | + ("ioc_handle_op_mode_reqt cmd=\ | ||
6070 | + IOCTL_1588_PORT_OPERATION_MODE_GET \ | ||
6071 | + invoking ioh_1588_ptp_operation_mode_get\n"); | ||
6072 | + if (ioh_1588_ptp_operation_mode_get | ||
6073 | + (opmode_ioctl->ptpPort, | ||
6074 | + &opmode_ioctl->ptpOpMode) != IOH_1588_SUCCESS) { | ||
6075 | + IOH_LOG(KERN_ERR, | ||
6076 | + "ioh_1588_ioctl: \ | ||
6077 | + ioh_1588_ptp_operation_mode_get failed\n"); | ||
6078 | + return -EINVAL; | ||
6079 | + } | ||
6080 | + } | ||
6081 | + return 0; | ||
6082 | +} | ||
6083 | + | ||
6084 | +/*! @ingroup InterfaceLayerNotifyRoutines | ||
6085 | + * @fn irqreturn_t ioh_1588_isr(int irq, void *p_data) | ||
6086 | + * @brief This function is the driver interrupt service routine. | ||
6087 | + * | ||
6088 | + * @param irq [IN] interrupt number | ||
6089 | + * @param p_data caller data | ||
6090 | + * | ||
6091 | + * @retval irqreturn_t | ||
6092 | + * - IRQ_HANDLED => interrupt handled, | ||
6093 | + * - IRQ_NONE => this device did not interrupt | ||
6094 | + */ | ||
6095 | +irqreturn_t ioh_1588_isr(int irq, void *p_data) | ||
6096 | +{ | ||
6097 | + unsigned long pending = 0; | ||
6098 | + | ||
6099 | + (void)ioh_1588_interrupt_pending(&pending); | ||
6100 | + if (!pending) { | ||
6101 | + IOH_DEBUG("ioh_1588_isr: no pending interrupt\n"); | ||
6102 | + return IRQ_NONE; | ||
6103 | + } | ||
6104 | + | ||
6105 | + if (ioh_1588_handler() != IOH_1588_SUCCESS) { | ||
6106 | + IOH_LOG(KERN_ERR, "ioh_1588_isr: ioh_1588_handler failed\n"); | ||
6107 | + return IRQ_NONE; | ||
6108 | + } | ||
6109 | + | ||
6110 | + return IRQ_HANDLED; | ||
6111 | +} | ||
6112 | + | ||
6113 | +/*! @ingroup InterfaceLayerNotifyRoutines | ||
6114 | + * @fn void target_time_callback(struct ioh1588TimeValue tgt_time) | ||
6115 | + * @brief The callback function that is called from the HAL | ||
6116 | + * when the target time expired interrupt occurs | ||
6117 | + * | ||
6118 | + * @param tgt_time target time register timestamp | ||
6119 | + * | ||
6120 | + * @retval None | ||
6121 | + */ | ||
6122 | +void target_time_callback(struct ioh1588TimeValue tgt_time) | ||
6123 | +{ | ||
6124 | + /* | ||
6125 | + * copy the target time value to the global value to be read by the | ||
6126 | + * notify ioctl | ||
6127 | + */ | ||
6128 | + (void)memcpy((void *)&ioh_1588_target_time, (const void *)&tgt_time, | ||
6129 | + sizeof(struct ioh1588TimeValue)); | ||
6130 | + | ||
6131 | + ioh_1588_devp->event_flags[TARG_TIME_EVENT_NUM] = 1; | ||
6132 | + | ||
6133 | + IOH_DEBUG("target_time_callback: signalling the notify ioctl \ | ||
6134 | + that the target time has expired\n"); | ||
6135 | + /* signal the notify ioctl that the target time has expired */ | ||
6136 | + wake_up_interruptible(&ioh_1588_devp->notify_evt[TARG_TIME_EVENT_NUM]); | ||
6137 | +} | ||
6138 | + | ||
6139 | +/*! @ingroup InterfaceLayerNotifyRoutines | ||
6140 | + * @fn void auxiliary_time_callback(enum ioh1588AuxMode aux_mode, | ||
6141 | + * struct ioh1588TimeValue aux_time) | ||
6142 | + * @brief The callback function that is called from the HAL | ||
6143 | + * when an aux time interrupt has occurred | ||
6144 | + * | ||
6145 | + * @param aux_mode master, slave, or any | ||
6146 | + * @param aux_time aux time register timestamp | ||
6147 | + * | ||
6148 | + * @return None | ||
6149 | + */ | ||
6150 | +void auxiliary_time_callback(enum ioh1588AuxMode aux_mode, \ | ||
6151 | + struct ioh1588TimeValue aux_time) | ||
6152 | +{ | ||
6153 | + /* | ||
6154 | + * copy the aux time value and aux mode to the global value | ||
6155 | + * to be read by the notify ioctl | ||
6156 | + */ | ||
6157 | + | ||
6158 | + ioh_1588_aux_time.auxMode = aux_mode; | ||
6159 | + (void)memcpy((void *)&ioh_1588_aux_time.auxTime, | ||
6160 | + (const void *)&aux_time, \ | ||
6161 | + sizeof(struct ioh1588AuxTimeIoctl)); | ||
6162 | + | ||
6163 | + ioh_1588_devp->event_flags[AUX_TIME_EVENT_NUM] = 1; | ||
6164 | + | ||
6165 | + IOH_DEBUG("auxiliary_time_callback: signalling the notify ioctl \ | ||
6166 | + that the auxiliary time stamp has been set\n"); | ||
6167 | + | ||
6168 | + /* | ||
6169 | + * signal the notify ioctl that the aux timestamp has been set | ||
6170 | + */ | ||
6171 | + wake_up_interruptible(&ioh_1588_devp->notify_evt[AUX_TIME_EVENT_NUM]); | ||
6172 | +} | ||
6173 | + | ||
6174 | +/*! @ingroup InterfaceLayerNotifyRoutines | ||
6175 | + * @fn void pulse_per_sec_callback(unsigned long pps) | ||
6176 | + * @brief This is a callback function that will be called from the HAL | ||
6177 | + * when the pulse per second time has expired which generates an | ||
6178 | + * interrupt | ||
6179 | + * | ||
6180 | + * @param pps pulse per second register timestamp | ||
6181 | + * | ||
6182 | + * @retval None | ||
6183 | + */ | ||
6184 | +void pulse_per_sec_callback(unsigned long pps) | ||
6185 | +{ | ||
6186 | + ioh_1588_pps_time = pps; | ||
6187 | + | ||
6188 | + ioh_1588_devp->event_flags[PPS_EVENT_NUM] = 1; | ||
6189 | + | ||
6190 | + IOH_DEBUG("pulse_per_sec_callback: signalling the notify ioctl \ | ||
6191 | + that the pulse per second time has expired\n"); | ||
6192 | + /* signal the notify ioctl that the pulse per second time has expired */ | ||
6193 | + | ||
6194 | + wake_up_interruptible(&ioh_1588_devp->notify_evt[PPS_EVENT_NUM]); | ||
6195 | +} | ||
6196 | diff -urN linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_main.h topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_main.h | ||
6197 | --- linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_main.h 1970-01-01 09:00:00.000000000 +0900 | ||
6198 | +++ topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_main.h 2010-03-09 10:22:48.000000000 +0900 | ||
6199 | @@ -0,0 +1,702 @@ | ||
6200 | + /*! | ||
6201 | + * @file ioh_1588_main.h | ||
6202 | + * @brief | ||
6203 | + * This file contains the declarations of IEEE_1588_InterfaceLayer APIs | ||
6204 | + * @version 0.92 | ||
6205 | + * @section | ||
6206 | + * This program is free software; you can redistribute it and/or modify | ||
6207 | + * it under the terms of the GNU General Public License as published by | ||
6208 | + * the Free Software Foundation; version 2 of the License. | ||
6209 | + * | ||
6210 | + * This program is distributed in the hope that it will be useful, | ||
6211 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
6212 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
6213 | + * GNU General Public License for more details. | ||
6214 | + * | ||
6215 | + * You should have received a copy of the GNU General Public License | ||
6216 | + * along with this program; if not, write to the Free Software | ||
6217 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
6218 | + */ | ||
6219 | + | ||
6220 | +/* | ||
6221 | + * History: | ||
6222 | + * modified to support Intel IOH GE IEEE 1588 hardware | ||
6223 | + * Copyright (C) 2008 OKI SEMICONDUCTOR Co., LTD. | ||
6224 | + * All rights reserved. | ||
6225 | + * derived from | ||
6226 | + * IEEE 1588 Time Synchronization Driver for Intel EP80579 | ||
6227 | + * Copyright(c) 2007,2008 Intel Corporation. All rights reserved. | ||
6228 | + * All rights reserved. | ||
6229 | + * | ||
6230 | + */ | ||
6231 | + | ||
6232 | +#ifndef IOH_1588_MAIN_H | ||
6233 | +#define IOH_1588_MAIN_H | ||
6234 | + | ||
6235 | +#ifdef __GNUC__ | ||
6236 | +#define UNUSED __attribute__ ((unused)) | ||
6237 | +#define UNUSED_ARG(x) | ||
6238 | +#else | ||
6239 | +#define UNUSED | ||
6240 | +#define UNUSED_ARG(x) (void) x | ||
6241 | +#endif | ||
6242 | + | ||
6243 | +#include <linux/ioctl.h> | ||
6244 | + | ||
6245 | +#define TRUE 1 | ||
6246 | +#define FALSE 0 | ||
6247 | + | ||
6248 | +/*! @defgroup IEEE1588*/ | ||
6249 | + | ||
6250 | +/*! @defgroup IEEE_1588_Global | ||
6251 | + * @ingroup IEEE1588 | ||
6252 | + * @brief This group describes the global entities within | ||
6253 | + * the module. | ||
6254 | + * @remarks This group includes all the global data structures | ||
6255 | + * used within the modules. These are mainly used to | ||
6256 | + * store the device related information, so that it can | ||
6257 | + * be used by other functions of the modules. | ||
6258 | + * <hr> | ||
6259 | + * */ | ||
6260 | + | ||
6261 | +/*! @defgroup IEEE_1588_PCILayer | ||
6262 | + * @ingroup IEEE1588 | ||
6263 | + * @brief This group describes the PCI layer interface | ||
6264 | + * functionalities. | ||
6265 | + * @remarks This group contains the functions and data structures | ||
6266 | + * that are used to interface the module with PCI Layer | ||
6267 | + * subsystem of the Kernel. | ||
6268 | + * <hr> | ||
6269 | + * */ | ||
6270 | + | ||
6271 | +/*! @defgroup IEEE_1588_InterfaceLayer | ||
6272 | + * @ingroup IEEE1588 | ||
6273 | + * @brief This group describes the Driver interface functionalities. | ||
6274 | + * @remarks This group contains the data structures and functions used | ||
6275 | + * to interface the module driver with the kernel subsystem. | ||
6276 | + * <hr> | ||
6277 | + * */ | ||
6278 | + | ||
6279 | +/*! @defgroup IEEE_1588_HALLayer | ||
6280 | + * @ingroup IEEE1588 | ||
6281 | + * @brief This group describes the hardware specific functionalities. | ||
6282 | + * @remarks This group contains the functions and data structures used | ||
6283 | + * by the module to communicate with the hardware. These | ||
6284 | + * functions are device specific and designed according to the | ||
6285 | + * device specifications. | ||
6286 | + * <hr> | ||
6287 | + * */ | ||
6288 | + | ||
6289 | +/*! @defgroup IEEE_1588_Utilities | ||
6290 | + * @ingroup IEEE1588 | ||
6291 | + * @brief This group describes the utility functionalities. | ||
6292 | + * @remarks This group contains the functions and data structures used | ||
6293 | + * to assist the other functionalities in their operations. | ||
6294 | + * <hr> | ||
6295 | + **/ | ||
6296 | + | ||
6297 | +/*! @defgroup IEEE_1588_PCILayerAPI | ||
6298 | + * @ingroup IEEE_1588_PCILayer | ||
6299 | + * @brief This group contains the API(functions) used as the PCI | ||
6300 | + * interface between the Kernel subsystem and the module. | ||
6301 | + *<hr> | ||
6302 | + **/ | ||
6303 | + | ||
6304 | +/*! @defgroup IEEE_1588_PCILayerFacilitators | ||
6305 | + * @ingroup IEEE_1588_PCILayer | ||
6306 | + * @brief This group contains the data structures used by the PCI | ||
6307 | + * Layer APIs for their functionalities. | ||
6308 | + * <hr> | ||
6309 | + **/ | ||
6310 | + | ||
6311 | +/*! @defgroup IEEE_1588_InterfaceLayerAPI | ||
6312 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6313 | + * @brief This group contains the API(functions) used as the Driver | ||
6314 | + * interface between the Kernel subsystem and the module. | ||
6315 | + * <hr> | ||
6316 | + **/ | ||
6317 | + | ||
6318 | +/*! @defgroup IEEE_1588_InterfaceLayerFacilitators | ||
6319 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6320 | + * @brief This group contains the data structures used by the Driver | ||
6321 | + * interface APIs for their functionalities. | ||
6322 | + * <hr> | ||
6323 | + **/ | ||
6324 | + | ||
6325 | +/*! @defgroup IEEE_1588_HALLayerAPI | ||
6326 | + * @ingroup IEEE_1588_HALLayer | ||
6327 | + * @brief This group contains the APIs(functions) used to interact with | ||
6328 | + * the hardware. These APIs act as an interface between the | ||
6329 | + * hardware and the other driver functions. | ||
6330 | + * <hr> | ||
6331 | + **/ | ||
6332 | + | ||
6333 | +/*! @defgroup IEEE_1588_UtilitiesAPI | ||
6334 | + * @ingroup IEEE_1588_Utilities | ||
6335 | + * @brief This group contains the APIs(functions) used by other | ||
6336 | + * functions | ||
6337 | + * in their operations. | ||
6338 | + * <hr> | ||
6339 | + **/ | ||
6340 | + | ||
6341 | +/* 1588 module ioctl command codes */ | ||
6342 | + | ||
6343 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6344 | + * @def IOC_1588_BASE | ||
6345 | + * @brief The unique one byte data used to define | ||
6346 | + * the IOCTL commands | ||
6347 | + */ | ||
6348 | +#define IOC_1588_BASE 0x88 | ||
6349 | + | ||
6350 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6351 | + * @def IOCTL_1588_PORT_CONFIG_SET | ||
6352 | + * @brief Set the IEEE 1588 Ethernet port to Mater/Slave/All mode | ||
6353 | + */ | ||
6354 | +#define IOCTL_1588_PORT_CONFIG_SET \ | ||
6355 | + _IOW(IOC_1588_BASE, 0, struct ioh1588PortCfgIoctl) | ||
6356 | + | ||
6357 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6358 | + * @def IOCTL_1588_PORT_CONFIG_GET | ||
6359 | + * @brief Get the IEEE 1588 Ethernet port Configuration mode | ||
6360 | + */ | ||
6361 | +#define IOCTL_1588_PORT_CONFIG_GET \ | ||
6362 | + _IOWR(IOC_1588_BASE, 1, struct ioh1588PortCfgIoctl) | ||
6363 | + | ||
6364 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6365 | + * @def IOCTL_1588_RX_POLL | ||
6366 | + * @brief Poll for receive timestamp captured on the IEEE 1588 ethernet | ||
6367 | + * channel | ||
6368 | + */ | ||
6369 | +#define IOCTL_1588_RX_POLL _IOWR(IOC_1588_BASE, 2, struct ioh1588RxTxPollIoctl) | ||
6370 | + | ||
6371 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6372 | + * @def IOCTL_1588_TX_POLL | ||
6373 | + * @brief Poll for transmit timestamp captured on the IEEE 1588 ethernet | ||
6374 | + * channel | ||
6375 | + */ | ||
6376 | +#define IOCTL_1588_TX_POLL _IOWR(IOC_1588_BASE, 3, struct ioh1588RxTxPollIoctl) | ||
6377 | + | ||
6378 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6379 | + * @def IOCTL_1588_CAN_POLL | ||
6380 | + * @brief Poll for timestamp captured on the IEEE 1588 CAN channel | ||
6381 | + */ | ||
6382 | +#define IOCTL_1588_CAN_POLL _IOWR(IOC_1588_BASE, 4, struct ioh1588CANPollIoctl) | ||
6383 | + | ||
6384 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6385 | + * @def IOCTL_1588_SYS_TIME_GET | ||
6386 | + * @brief Get the IEEE 1588 system time from the module | ||
6387 | + */ | ||
6388 | +#define IOCTL_1588_SYS_TIME_GET _IOR(IOC_1588_BASE, 5, struct ioh1588TimeValue) | ||
6389 | + | ||
6390 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6391 | + * @def IOCTL_1588_SYS_TIME_SET | ||
6392 | + * @brief Set the IEEE 1588 system time on the module | ||
6393 | + */ | ||
6394 | +#define IOCTL_1588_SYS_TIME_SET _IOW(IOC_1588_BASE, 6, struct ioh1588TimeValue) | ||
6395 | + | ||
6396 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6397 | + * @def IOCTL_1588_TICK_RATE_SET | ||
6398 | + * @brief Set the frequency scaling value used on IEEE 1588 module | ||
6399 | + */ | ||
6400 | +#define IOCTL_1588_TICK_RATE_SET _IOW(IOC_1588_BASE, 7, unsigned long) | ||
6401 | + | ||
6402 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6403 | + * @def IOCTL_1588_TICK_RATE_GET | ||
6404 | + * @brief Get the frequency scaling value used on IEEE 1588 module | ||
6405 | + */ | ||
6406 | +#define IOCTL_1588_TICK_RATE_GET _IOR(IOC_1588_BASE, 8, unsigned long) | ||
6407 | + | ||
6408 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6409 | + * @def IOCTL_1588_TARG_TIME_INTRPT_ENABLE | ||
6410 | + * @brief Enable the target time reached/exceeded interrupt on IEEE 1588 module | ||
6411 | + */ | ||
6412 | +#define IOCTL_1588_TARG_TIME_INTRPT_ENABLE _IO(IOC_1588_BASE, 9) | ||
6413 | + | ||
6414 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6415 | + * @def IOCTL_1588_TARG_TIME_INTRPT_DISABLE | ||
6416 | + * @brief Disable the target time reached/exceeded interrupt on IEEE 1588 module | ||
6417 | + */ | ||
6418 | +#define IOCTL_1588_TARG_TIME_INTRPT_DISABLE _IO(IOC_1588_BASE, 10) | ||
6419 | + | ||
6420 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6421 | + * @def IOCTL_1588_TARG_TIME_POLL | ||
6422 | + * @brief Poll for the target time reached/exceeded condition on IEEE 1588 | ||
6423 | + * module | ||
6424 | + */ | ||
6425 | +#define IOCTL_1588_TARG_TIME_POLL \ | ||
6426 | + _IOR(IOC_1588_BASE, 11, struct ioh1588TimePollIoctl) | ||
6427 | + | ||
6428 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6429 | + * @def IOCTL_1588_TARG_TIME_SET | ||
6430 | + * @brief Set the target time to match on IEEE 1588 module | ||
6431 | + */ | ||
6432 | +#define IOCTL_1588_TARG_TIME_SET \ | ||
6433 | + _IOW(IOC_1588_BASE, 12, struct ioh1588TimeValue) | ||
6434 | + | ||
6435 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6436 | + * @def IOCTL_1588_TARG_TIME_GET | ||
6437 | + * @brief Get the target time currently set on IEEE 1588 module | ||
6438 | + */ | ||
6439 | +#define IOCTL_1588_TARG_TIME_GET \ | ||
6440 | + _IOR(IOC_1588_BASE, 13, struct ioh1588TimeValue) | ||
6441 | + | ||
6442 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6443 | + * @def IOCTL_1588_AUX_TIME_INTRPT_ENABLE | ||
6444 | + * @brief Enable the auxiliary time captured interrupt on IEEE 1588 module | ||
6445 | + */ | ||
6446 | +#define IOCTL_1588_AUX_TIME_INTRPT_ENABLE \ | ||
6447 | + _IOW(IOC_1588_BASE, 14, enum ioh1588AuxMode) | ||
6448 | + | ||
6449 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6450 | + * @def IOCTL_1588_AUX_TIME_INTRPT_DISABLE | ||
6451 | + * @brief Disable the auxiliary time captured interrupt on IEEE 1588 module | ||
6452 | + */ | ||
6453 | +#define IOCTL_1588_AUX_TIME_INTRPT_DISABLE \ | ||
6454 | + _IOW(IOC_1588_BASE, 15, enum ioh1588AuxMode) | ||
6455 | + | ||
6456 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6457 | + * @def IOCTL_1588_AUX_TIME_POLL | ||
6458 | + * @brief Poll for the auxiliary time captured on IEEE 1588 module | ||
6459 | + */ | ||
6460 | +#define IOCTL_1588_AUX_TIME_POLL \ | ||
6461 | + _IOWR(IOC_1588_BASE, 16, struct ioh1588TimePollIoctl) | ||
6462 | + | ||
6463 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6464 | + * @def IOCTL_1588_RESET | ||
6465 | + * @brief Reset the IEEE 1588 module | ||
6466 | + */ | ||
6467 | +#define IOCTL_1588_RESET _IO(IOC_1588_BASE, 17) | ||
6468 | + | ||
6469 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6470 | + * @def IOCTL_1588_CHNL_RESET | ||
6471 | + * @brief Reset the IEEE 1588 channel | ||
6472 | + */ | ||
6473 | +#define IOCTL_1588_CHNL_RESET _IOW(IOC_1588_BASE, 18, enum ioh1588PTPPort) | ||
6474 | + | ||
6475 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6476 | + * @def IOCTL_1588_STATS_GET | ||
6477 | + * @brief Get the timestamp captured counters from the IEEE 1588 module | ||
6478 | + */ | ||
6479 | +#define IOCTL_1588_STATS_GET _IOR(IOC_1588_BASE, 19, struct ioh1588Stats) | ||
6480 | + | ||
6481 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6482 | + * @def IOCTL_1588_STATS_RESET | ||
6483 | + * @brief Reset the timestamp captured counters maintained for IEEE 1588 module | ||
6484 | + */ | ||
6485 | +#define IOCTL_1588_STATS_RESET _IO(IOC_1588_BASE, 20) | ||
6486 | + | ||
6487 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6488 | + * @def IOCTL_1588_SHOW_ALL | ||
6489 | + * @brief Display the register contents of IEEE 1588 module | ||
6490 | + */ | ||
6491 | +#define IOCTL_1588_SHOW_ALL _IO(IOC_1588_BASE, 21) | ||
6492 | + | ||
6493 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6494 | + * @def IOCTL_1588_AUX_TARG_TIME_INTRPT_ENABLE | ||
6495 | + * @brief Enable Auxiliary target time reached interrupt - not supported | ||
6496 | + */ | ||
6497 | +#define IOCTL_1588_AUX_TARG_TIME_INTRPT_ENABLE _IO(IOC_1588_BASE, 22) | ||
6498 | + | ||
6499 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6500 | + * @def IOCTL_1588_AUX_TARG_TIME_INTRPT_DISABLE | ||
6501 | + * @brief Disable Auxiliary target time reached interrupt - not supported | ||
6502 | + */ | ||
6503 | +#define IOCTL_1588_AUX_TARG_TIME_INTRPT_DISABLE _IO(IOC_1588_BASE, 23) | ||
6504 | + | ||
6505 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6506 | + * @def IOCTL_1588_AUX_TARG_TIME_POLL | ||
6507 | + * @brief Poll for Auxiliary target time captured - not supported | ||
6508 | + */ | ||
6509 | +#define IOCTL_1588_AUX_TARG_TIME_POLL \ | ||
6510 | + _IOR(IOC_1588_BASE, 24, struct ioh1588TimePollIoctl) | ||
6511 | + | ||
6512 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6513 | + * @def IOCTL_1588_AUX_TARG_TIME_SET | ||
6514 | + * @brief Set Auxiliary target time - not supported | ||
6515 | + */ | ||
6516 | +#define IOCTL_1588_AUX_TARG_TIME_SET \ | ||
6517 | + _IOW(IOC_1588_BASE, 25, struct ioh1588TimeValue) | ||
6518 | + | ||
6519 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6520 | + * @def IOCTL_1588_AUX_TARG_TIME_GET | ||
6521 | + * @brief Get Auxiliary target time currently set - not supported | ||
6522 | + */ | ||
6523 | +#define IOCTL_1588_AUX_TARG_TIME_GET \ | ||
6524 | + _IOR(IOC_1588_BASE, 26, struct ioh1588TimeValue) | ||
6525 | + | ||
6526 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6527 | + * @def IOCTL_1588_PULSE_PER_SEC_INTRPT_ENABLE | ||
6528 | + * @brief Enable Pulse per second match interrupt | ||
6529 | + */ | ||
6530 | +#define IOCTL_1588_PULSE_PER_SEC_INTRPT_ENABLE _IO(IOC_1588_BASE, 27) | ||
6531 | + | ||
6532 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6533 | + * @def IOCTL_1588_PULSE_PER_SEC_INTRPT_DISABLE | ||
6534 | + * @brief Disable Pulse per second match interrupt | ||
6535 | + */ | ||
6536 | +#define IOCTL_1588_PULSE_PER_SEC_INTRPT_DISABLE _IO(IOC_1588_BASE, 28) | ||
6537 | + | ||
6538 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6539 | + * @def IOCTL_1588_TARG_TIME_NOTIFY | ||
6540 | + * @brief Block till a target time reached interrupt occurs | ||
6541 | + */ | ||
6542 | +#define IOCTL_1588_TARG_TIME_NOTIFY \ | ||
6543 | + _IOR(IOC_1588_BASE, 29, struct ioh1588TimeValue) | ||
6544 | + | ||
6545 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6546 | + * @def IOCTL_1588_AUX_TIME_NOTIFY | ||
6547 | + * @brief Block till an auxiliary time captured interrupt occurs | ||
6548 | + */ | ||
6549 | +#define IOCTL_1588_AUX_TIME_NOTIFY \ | ||
6550 | + _IOR(IOC_1588_BASE, 30, struct ioh1588AuxTimeIoctl) | ||
6551 | + | ||
6552 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6553 | + * @def IOCTL_1588_AUX_TARG_TIME_NOTIFY | ||
6554 | + * @brief Block till an auxiliary target time reached interrupt occurs - not | ||
6555 | + * supported | ||
6556 | + */ | ||
6557 | +#define IOCTL_1588_AUX_TARG_TIME_NOTIFY \ | ||
6558 | + _IOR(IOC_1588_BASE, 31, struct ioh1588TimeValue) | ||
6559 | + | ||
6560 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6561 | + * @def IOCTL_1588_PULSE_PER_SEC_NOTIFY | ||
6562 | + * @brief Block till a pulse per second match interrupt occurs | ||
6563 | + */ | ||
6564 | +#define IOCTL_1588_PULSE_PER_SEC_NOTIFY _IOR(IOC_1588_BASE, 32, unsigned long) | ||
6565 | + | ||
6566 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6567 | + * @def IOCTL_1588_TARG_TIME_CLR_NOTIFY | ||
6568 | + * @brief Unblock a process waiting on target time reached interrupt | ||
6569 | + */ | ||
6570 | +#define IOCTL_1588_TARG_TIME_CLR_NOTIFY _IO(IOC_1588_BASE, 33) | ||
6571 | + | ||
6572 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6573 | + * @def IOCTL_1588_AUX_TIME_CLR_NOTIFY | ||
6574 | + * @brief Unblock a process waiting on auxiliary time captured interrupt | ||
6575 | + */ | ||
6576 | +#define IOCTL_1588_AUX_TIME_CLR_NOTIFY _IO(IOC_1588_BASE, 34) | ||
6577 | + | ||
6578 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6579 | + * @def IOCTL_1588_AUX_TARG_TIME_CLR_NOTIFY | ||
6580 | + * @brief Unblock a process waiting on an auxiliary target time reached | ||
6581 | + * interrupt - not supported | ||
6582 | + */ | ||
6583 | +#define IOCTL_1588_AUX_TARG_TIME_CLR_NOTIFY _IO(IOC_1588_BASE, 35) | ||
6584 | + | ||
6585 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6586 | + * @def IOCTL_1588_PULSE_PER_SEC_CLR_NOTIFY | ||
6587 | + * @brief Unblock a process waiting on a pulse per second match interrupt | ||
6588 | + */ | ||
6589 | +#define IOCTL_1588_PULSE_PER_SEC_CLR_NOTIFY _IO(IOC_1588_BASE, 36) | ||
6590 | + | ||
6591 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6592 | + * @def IOCTL_1588_PULSE_PER_SEC_TIME_GET | ||
6593 | + * @brief Get the currently specified pulse per second match time | ||
6594 | + */ | ||
6595 | +#define IOCTL_1588_PULSE_PER_SEC_TIME_GET _IOR(IOC_1588_BASE, 37, unsigned long) | ||
6596 | + | ||
6597 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6598 | + * @def IOCTL_1588_PULSE_PER_SEC_TIME_SET | ||
6599 | + * @brief Specify the pulse per second match time | ||
6600 | + */ | ||
6601 | +#define IOCTL_1588_PULSE_PER_SEC_TIME_SET _IOW(IOC_1588_BASE, 38, unsigned long) | ||
6602 | + | ||
6603 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6604 | + * @def IOCTL_1588_PORT_VERSION_SET | ||
6605 | + * @brief Set the PTP version to be used on the given PTP channel | ||
6606 | + */ | ||
6607 | +#define IOCTL_1588_PORT_VERSION_SET \ | ||
6608 | + _IOW(IOC_1588_BASE, 39, struct ioh1588VersionIoctl) | ||
6609 | + | ||
6610 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6611 | + * @def IOCTL_1588_PORT_VERSION_GET | ||
6612 | + * @brief Get the PTP version used on the given PTP channel | ||
6613 | + */ | ||
6614 | +#define IOCTL_1588_PORT_VERSION_GET \ | ||
6615 | + _IOWR(IOC_1588_BASE, 40, struct ioh1588VersionIoctl) | ||
6616 | + | ||
6617 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6618 | + * @def IOCTL_1588_PORT_OPERATION_MODE_SET | ||
6619 | + * @brief Set the PTP messages that are matched by the module on the given PTP | ||
6620 | + * channel | ||
6621 | + */ | ||
6622 | +#define IOCTL_1588_PORT_OPERATION_MODE_SET \ | ||
6623 | + _IOW(IOC_1588_BASE, 41, struct ioh1588OperationModeIoctl) | ||
6624 | + | ||
6625 | +/*! @ingroup IEEE_1588_InterfaceLayer | ||
6626 | + * @def IOCTL_1588_PORT_OPERATION_MODE_GET | ||
6627 | + * @brief Get the PTP messages that are currently matched by the module on given | ||
6628 | + * PTP channel | ||
6629 | + */ | ||
6630 | +#define IOCTL_1588_PORT_OPERATION_MODE_GET \ | ||
6631 | + _IOWR(IOC_1588_BASE, 42, struct ioh1588OperationModeIoctl) | ||
6632 | + | ||
6633 | +/** | ||
6634 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6635 | + * @enum ioh1588PTPPort | ||
6636 | + * @brief IEEE 1588 PTP Communication Port(Channel) | ||
6637 | + */ | ||
6638 | +enum ioh1588PTPPort { /* ioh1588PTPPort */ | ||
6639 | + IOH_1588_GBE_0_1588PTP_PORT, /**< PTP Communication Port on GBE-0 */ | ||
6640 | + IOH_1588_CAN_0_1588PTP_PORT, /**< PTP Communication Port on CAN-0 */ | ||
6641 | + IOH_1588_PORT_INVALID /**< Invalid PTP Communication Port */ | ||
6642 | +}; | ||
6643 | + | ||
6644 | +/** | ||
6645 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6646 | + * @enum ioh1588PTPPortMode | ||
6647 | + * @brief PTP Port mode - Master or Slave or any | ||
6648 | + */ | ||
6649 | +enum ioh1588PTPPortMode { /* ioh1588PTPPortMode */ | ||
6650 | + IOH_1588PTP_PORT_MASTER, /**< Master Mode */ | ||
6651 | + IOH_1588PTP_PORT_SLAVE, /**< Slave Mode */ | ||
6652 | + IOH_1588PTP_PORT_ANYMODE, /**< Timestamp all messages */ | ||
6653 | + IOH_1588PTP_PORT_MODE_INVALID /**< Invalid PTP Port Mode */ | ||
6654 | +}; | ||
6655 | + | ||
6656 | +/** | ||
6657 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6658 | + * @struct ioh1588PortCfgIoctl | ||
6659 | + * @brief Struct to pass port config data for ioctl call | ||
6660 | + */ | ||
6661 | +struct ioh1588PortCfgIoctl { /* ioh1588PortCfgIoctl */ | ||
6662 | + enum ioh1588PTPPort ptpPort; /**< IEEE 1588 PTP Communication Port */ | ||
6663 | + enum ioh1588PTPPortMode ptpPortMode; /**< Master, Slave, | ||
6664 | + or Any mode */ | ||
6665 | +}; | ||
6666 | + | ||
6667 | +/** | ||
6668 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6669 | + * @enum ioh1588PTPMsgType | ||
6670 | + * @brief PTP Messages types that can be detected on communication port | ||
6671 | + */ | ||
6672 | +enum ioh1588PTPMsgType { /* ioh1588PTPMsgType */ | ||
6673 | + IOH_1588PTP_MSGTYPE_SYNC, /**< PTP Sync message sent by Master or | ||
6674 | + received by Slave */ | ||
6675 | + IOH_1588PTP_MSGTYPE_DELAYREQ, /**< PTP Delay_Req message sent by Slave | ||
6676 | + or received by Master */ | ||
6677 | + IOH_1588PTP_MSGTYPE_UNKNOWN /**< Other PTP and non-PTP message sent | ||
6678 | + or received by both Master | ||
6679 | + and/or Slave */ | ||
6680 | +}; | ||
6681 | + | ||
6682 | +/** | ||
6683 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6684 | + * @struct ioh1588TimeValue | ||
6685 | + * @brief Struct to hold 64 bit SystemTime and TimeStamp values | ||
6686 | + */ | ||
6687 | +struct ioh1588TimeValue { /* ioh1588TimeValue */ | ||
6688 | + unsigned long timeValueLowWord; /**< Lower 32 bits of time value */ | ||
6689 | + unsigned long timeValueHighWord; /**< Upper 32 bits of time value */ | ||
6690 | +}; | ||
6691 | + | ||
6692 | +/** | ||
6693 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6694 | + * @struct ioh1588Uuid | ||
6695 | + * @brief Struct to hold 48 bit UUID values captured in Sync or Delay_Req | ||
6696 | + * messages | ||
6697 | + */ | ||
6698 | +struct ioh1588Uuid{ /* ioh1588Uuid */ | ||
6699 | + unsigned long uuidValueLowWord; /**< The lower 32 bits of UUID */ | ||
6700 | + unsigned long uuidValueHighHalfword; /**< The upper 16 bits of UUID */ | ||
6701 | +}; | ||
6702 | + | ||
6703 | +/** | ||
6704 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6705 | + * @struct ioh1588PtpMsgData | ||
6706 | + * @brief Struct for data from the PTP message returned when TimeStamp | ||
6707 | + * available | ||
6708 | + */ | ||
6709 | +struct ioh1588PtpMsgData{ /* ioh1588PtpMsgData */ | ||
6710 | + enum ioh1588PTPMsgType ptpMsgType; /**< PTP Messages type */ | ||
6711 | + struct ioh1588TimeValue ptpTimeStamp; /**< 64 bit TimeStamp value from | ||
6712 | + PTP Message */ | ||
6713 | + struct ioh1588Uuid ptpUuid; /**< 48 bit UUID value from the | ||
6714 | + PTP Message */ | ||
6715 | + unsigned int ptpSequenceNumber; /**< 16 bit Sequence Number from PTP | ||
6716 | + Message */ | ||
6717 | +}; | ||
6718 | + | ||
6719 | +/** | ||
6720 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6721 | + * @struct ioh1588RxTxPollIoctl | ||
6722 | + * @brief Struct to pass PTP message data for ioctl call | ||
6723 | + */ | ||
6724 | +struct ioh1588RxTxPollIoctl{ /* ioh1588RxTxPollIoctl */ | ||
6725 | + enum ioh1588PTPPort ptpPort; /**< IEEE 1588 PTP Communication Port */ | ||
6726 | + struct ioh1588PtpMsgData ptpMsgData; /**< PTP message data */ | ||
6727 | +}; | ||
6728 | + | ||
6729 | +/** | ||
6730 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6731 | + * @struct ioh1588CANPollIoctl | ||
6732 | + * @brief Struct to pass CAN timestamp data for ioctl call | ||
6733 | + */ | ||
6734 | +struct ioh1588CANPollIoctl{ /* ioh1588CANPollIoctl */ | ||
6735 | + enum ioh1588PTPPort ptpPort; /**< IEEE 1588 PTP Communication | ||
6736 | + Port */ | ||
6737 | + struct ioh1588TimeValue ptpTimeStamp; /**< CAN PTP timestamp */ | ||
6738 | +}; | ||
6739 | + | ||
6740 | +/** | ||
6741 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6742 | + * @enum ioh1588AuxMode | ||
6743 | + * @brief Master or Slave Auxiliary Time Stamp (Snap Shot) | ||
6744 | + */ | ||
6745 | +enum ioh1588AuxMode{ /* ioh1588AuxMode */ | ||
6746 | + IOH_1588_AUXMODE_MASTER, /**< Auxiliary Master Mode */ | ||
6747 | + IOH_1588_AUXMODE_SLAVE, /**< Auxiliary Slave Mode */ | ||
6748 | + IOH_1588_AUXMODE_INVALID /**< Invalid Auxiliary Mode */ | ||
6749 | +}; | ||
6750 | + | ||
6751 | +/** | ||
6752 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6753 | + * @struct ioh1588TimePollIoctl | ||
6754 | + * @brief Struct to pass timestamp data for ioctl call | ||
6755 | + */ | ||
6756 | +struct ioh1588TimePollIoctl { /* ioh1588TimePollIoctl */ | ||
6757 | + unsigned long pollFlag; /**< time event */ | ||
6758 | + struct ioh1588TimeValue timeVal; /**< timestamp value */ | ||
6759 | + enum ioh1588AuxMode auxMode; /**< Master or Slave mode */ | ||
6760 | +}; | ||
6761 | + | ||
6762 | +/** | ||
6763 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6764 | + * @struct ioh1588Stats | ||
6765 | + * @brief Provides the number of times timestamps are locked for rx and tx | ||
6766 | + * PTP | ||
6767 | + * messages. The counters are reinitialized when the module is | ||
6768 | + * reset. | ||
6769 | + */ | ||
6770 | +struct ioh1588Stats { /* ioh1588Stats */ | ||
6771 | + unsigned long rxMsgs; /**< Count of timestamps for received PTP Msgs */ | ||
6772 | + unsigned long txMsgs; /**< Count of timestamps for transmitted PTP | ||
6773 | + Msgs */ | ||
6774 | +}; | ||
6775 | + | ||
6776 | +/** | ||
6777 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6778 | + * @struct ioh1588AuxTimeIoctl | ||
6779 | + * @brief Struct to pass aux time data for ioctl call | ||
6780 | + */ | ||
6781 | +struct ioh1588AuxTimeIoctl { /* ioh1588AuxTimeIoctl */ | ||
6782 | + enum ioh1588AuxMode auxMode; /**< aux mode: master or slave */ | ||
6783 | + struct ioh1588TimeValue auxTime; /**< aux time snapshot */ | ||
6784 | +}; | ||
6785 | + | ||
6786 | +/** | ||
6787 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6788 | + * @enum ioh1588PTPVersion | ||
6789 | + * @brief 1588 PTP version value that can be detected on communication | ||
6790 | + * port | ||
6791 | + */ | ||
6792 | +enum ioh1588PTPVersion { /* ioh1588PTPVersion */ | ||
6793 | + IOH_1588PTP_VERSION_0, /**< support version 1 only */ | ||
6794 | + IOH_1588PTP_VERSION_1, /**< support both version 1 and version | ||
6795 | + 2 */ | ||
6796 | + IOH_1588PTP_VERSION_INVALID /**< Invalid version */ | ||
6797 | +}; | ||
6798 | + | ||
6799 | +/** | ||
6800 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6801 | + * @struct ioh1588VersionIoctl | ||
6802 | + * @brief Struct to pass timestamp data for ioctl call | ||
6803 | + */ | ||
6804 | +struct ioh1588VersionIoctl { /* ioh1588VersionIoctl */ | ||
6805 | + enum ioh1588PTPPort ptpPort; /**< IEEE 1588 PTP Communication Port */ | ||
6806 | + enum ioh1588PTPVersion ptpVersion; /**< version value */ | ||
6807 | +}; | ||
6808 | + | ||
6809 | +/** | ||
6810 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6811 | + * @enum ioh1588VersionIoctl | ||
6812 | + * @brief 1588 PTP operation mode value that can be detected on | ||
6813 | + * communication port | ||
6814 | + */ | ||
6815 | +enum ioh1588PTPOperationMode { /* ioh1588PTPOperationMode */ | ||
6816 | + IOH_1588PTP_OP_MODE_SYNC_DELAYREQ_MSGS, | ||
6817 | + /**< timestamp version 1 SYNC and DELAYED_REQ only */ | ||
6818 | + IOH_1588PTP_OP_MODE_V1_ALL_MSGS, | ||
6819 | + /**< timestamp version 1 all messages */ | ||
6820 | + IOH_1588PTP_OP_MODE_V1_V2_EVENT_MSGS, | ||
6821 | + /**< timestamp version 1 and 2 event messages only */ | ||
6822 | + IOH_1588PTP_OP_MODE_V1_V2_ALL_MSGS, | ||
6823 | + /**< timestamp version 1 and 2 all messages */ | ||
6824 | + IOH_1588PTP_OP_MODE_INVALID /**< Invalid mode */ | ||
6825 | +}; | ||
6826 | + | ||
6827 | +/** | ||
6828 | + * @ingroup IEEE_1588_InterfaceLayer | ||
6829 | + * @struct ioh1588OperationModeIoctl | ||
6830 | + * @brief Struct to pass timestamp data for ioctl call | ||
6831 | + */ | ||
6832 | +struct ioh1588OperationModeIoctl { /* ioh1588OperationModeIoctl */ | ||
6833 | + enum ioh1588PTPPort ptpPort; /**< IEEE 1588 PTP Communication | ||
6834 | + Port */ | ||
6835 | + enum ioh1588PTPOperationMode ptpOpMode; /**< IEEE 1588 operation mode */ | ||
6836 | +}; | ||
6837 | + | ||
6838 | +/** | ||
6839 | + * @ingroup IEEE_1588_Global | ||
6840 | + * @enum ioh_status | ||
6841 | + * @brief The status as returned from the HAL | ||
6842 | + */ | ||
6843 | +enum ioh_status { /* ioh_status */ | ||
6844 | + IOH_1588_SUCCESS, /**< operation successful */ | ||
6845 | + IOH_1588_INVALIDPARAM, /**< parameter passed is invalid */ | ||
6846 | + IOH_1588_NOTIMESTAMP, /**< no time stamp available when | ||
6847 | + polled */ | ||
6848 | + IOH_1588_INTERRUPTMODEINUSE, /**< while operating in interrupt mode, | ||
6849 | + polling not permitted */ | ||
6850 | + IOH_1588_FAILED, /**< Internal error in driver */ | ||
6851 | + IOH_1588_UNSUPPORTED, /**< Implementation does not support | ||
6852 | + this feature */ | ||
6853 | +}; | ||
6854 | + | ||
6855 | +/* IEEE 1588 registers to save and restore on suspend/resume */ | ||
6856 | + | ||
6857 | +/** @ingroup IEEE_1588_Global | ||
6858 | + * @struct ioh_1588_regs_set | ||
6859 | + * @brief IEEE 1588 registers to save and restore on suspend/resume | ||
6860 | + */ | ||
6861 | +struct ioh_1588_regs_set { | ||
6862 | + unsigned long ts_control; | ||
6863 | + unsigned long ts_event; /* not saved, cleared on restore */ | ||
6864 | + unsigned long ts_addend; | ||
6865 | + unsigned long ts_accum; /* not saved/restored */ | ||
6866 | + unsigned long ts_test; /* not saved/restored */ | ||
6867 | + unsigned long ts_compare; | ||
6868 | + unsigned long ts_syslo; | ||
6869 | + unsigned long ts_syshi; | ||
6870 | + unsigned long ts_tgtlo; | ||
6871 | + unsigned long ts_tgthi; | ||
6872 | + unsigned long ts_asmslo; /* not saved/restored */ | ||
6873 | + unsigned long ts_asmshi; /* not saved/restored */ | ||
6874 | + unsigned long ts_ammslo; /* not saved/restored */ | ||
6875 | + unsigned long ts_ammshi; /* not saved/restored */ | ||
6876 | + | ||
6877 | + /* Ethernet */ | ||
6878 | + unsigned long ts_cc; | ||
6879 | + unsigned long ts_ce; /* not saved, cleared on restore */ | ||
6880 | + unsigned long ts_xslo; /* not saved/restored */ | ||
6881 | + unsigned long ts_xshi; /* not saved/restored */ | ||
6882 | + unsigned long ts_rslo; /* not saved/restored */ | ||
6883 | + unsigned long ts_rshi; /* not saved/restored */ | ||
6884 | + unsigned long ts_uuidlo; /* not saved/restored */ | ||
6885 | + unsigned long ts_uuidhi; /* not saved/restored */ | ||
6886 | + | ||
6887 | + /* CAN */ | ||
6888 | + unsigned long ts_cce; /* not saved, cleared on restore */ | ||
6889 | + unsigned long ts_cxslo; /* not saved/restored */ | ||
6890 | + unsigned long ts_cxshi; /* not saved/restored */ | ||
6891 | + | ||
6892 | + unsigned long ts_sel; /* Selector */ | ||
6893 | + unsigned char ts_sti[6]; /* station addresses */ | ||
6894 | +}; | ||
6895 | + | ||
6896 | +/* callback function prototypes */ | ||
6897 | +extern void target_time_callback(struct ioh1588TimeValue targetTime); | ||
6898 | +extern void auxiliary_time_callback(enum ioh1588AuxMode aux_mode, \ | ||
6899 | + struct ioh1588TimeValue auxTime); | ||
6900 | +extern void pulse_per_sec_callback(unsigned long pps); | ||
6901 | +#endif /* IOH_1588_H */ | ||
6902 | diff -urN linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_pci.c topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_pci.c | ||
6903 | --- linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_pci.c 1970-01-01 09:00:00.000000000 +0900 | ||
6904 | +++ topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_pci.c 2010-03-09 10:32:42.000000000 +0900 | ||
6905 | @@ -0,0 +1,700 @@ | ||
6906 | + /*! | ||
6907 | + * @file ioh_1588_pci.c | ||
6908 | + * @brief | ||
6909 | + * This file contains the definitions of IEEE_1588_PCILayer APIs | ||
6910 | + * @version 0.92 | ||
6911 | + * @section | ||
6912 | + * This program is free software; you can redistribute it and/or modify | ||
6913 | + * it under the terms of the GNU General Public License as published by | ||
6914 | + * the Free Software Foundation; version 2 of the License. | ||
6915 | + * | ||
6916 | + * This program is distributed in the hope that it will be useful, | ||
6917 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
6918 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
6919 | + * GNU General Public License for more details. | ||
6920 | + * | ||
6921 | + * You should have received a copy of the GNU General Public License | ||
6922 | + * along with this program; if not, write to the Free Software | ||
6923 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
6924 | + */ | ||
6925 | + | ||
6926 | +/* | ||
6927 | + * History: | ||
6928 | + * modified to support Intel IOH GE IEEE 1588 hardware | ||
6929 | + * Copyright (C) 2008 OKI SEMICONDUCTOR Co., LTD. | ||
6930 | + * All rights reserved. | ||
6931 | + * derived from | ||
6932 | + * IEEE 1588 Time Synchronization Driver for Intels EP80579 | ||
6933 | + * Copyright(c) 2007,2008 Intel Corporation. All rights reserved. | ||
6934 | + * All rights reserved. | ||
6935 | + * | ||
6936 | + */ | ||
6937 | + | ||
6938 | +#include "pch_1588_pci.h" | ||
6939 | +#include "pch_1588_hal.h" | ||
6940 | +#include "pch_debug.h" | ||
6941 | + | ||
6942 | +#ifdef CONFIG_PM | ||
6943 | +static int ioh_1588_suspend(struct pci_dev *pdev, pm_message_t state); | ||
6944 | +static int ioh_1588_resume(struct pci_dev *pdev); | ||
6945 | +#endif | ||
6946 | +static int ioh_1588_probe(struct pci_dev *pdev, const struct pci_device_id *id); | ||
6947 | +static void ioh_1588_remove(struct pci_dev *pdev); | ||
6948 | + | ||
6949 | +/*! @ingroup IEEE_1588_PCILayerFacilitators | ||
6950 | + * @struct ioh_1588_pcidev_id | ||
6951 | + * @brief PCI device ids supported by this driver | ||
6952 | + * @remarks This structure is used to specify the Ids of the | ||
6953 | + * devices supported by the driver module during | ||
6954 | + * registering of the module as PCI driver.The values | ||
6955 | + * within the structure is maintained by the kernel | ||
6956 | + * subsystem to recognize the individual devices | ||
6957 | + * when they are attached to the system. Depending | ||
6958 | + * on this the corresponding device functionalities | ||
6959 | + * such as probe, remove, suspend,... are invoked. | ||
6960 | + * | ||
6961 | + * @note This structure contains the Vendor and device | ||
6962 | + * IDs of the device supported by the driver module. | ||
6963 | + * | ||
6964 | + * @see | ||
6965 | + * - ioh_1588_pcidev | ||
6966 | + * <hr> | ||
6967 | + */ | ||
6968 | +static const struct pci_device_id ioh_1588_pcidev_id[] = { | ||
6969 | + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_IOH_1588)}, | ||
6970 | + {0}, | ||
6971 | +}; | ||
6972 | + | ||
6973 | +/* Linux pci operations */ | ||
6974 | +/*! @ingroup IEEE_1588_PCILayerFacilitators | ||
6975 | +* @struct ioh_1588_pcidev | ||
6976 | +* @brief Store the references of PCI driver interfaces to kernel. | ||
6977 | +* @remarks This strutcure is used to specify the driver specific | ||
6978 | +* functionalities to the kernel subsystem. The kernel invokes | ||
6979 | +* these functionalities depending on the supported device and | ||
6980 | +* the events that occured. | ||
6981 | +* | ||
6982 | +* @note This structure is registered with the kernel via the call | ||
6983 | +* pci_register_driver from @ref ioh_1588_init | ||
6984 | +* @see | ||
6985 | +* - ioh_1588_init | ||
6986 | +* - ioh_1588_exit | ||
6987 | +*<hr> | ||
6988 | +*/ | ||
6989 | + | ||
6990 | +static struct pci_driver ioh_1588_pcidev = { | ||
6991 | + .name = DRIVER_NAME, | ||
6992 | + .id_table = ioh_1588_pcidev_id, | ||
6993 | + .probe = ioh_1588_probe, | ||
6994 | + .remove = ioh_1588_remove, | ||
6995 | +#ifdef CONFIG_PM | ||
6996 | + .suspend = ioh_1588_suspend, | ||
6997 | + .resume = ioh_1588_resume, | ||
6998 | +#endif | ||
6999 | +}; | ||
7000 | + | ||
7001 | +/* instance of driver data structure */ | ||
7002 | +/*! @ingroup IEEE_1588_PCILayerFacilitators | ||
7003 | + * @var ioh_1588_dev | ||
7004 | + * @brief instance of driver data structure | ||
7005 | + * @see | ||
7006 | + * - ioh_1588_probe | ||
7007 | + * - ioh_1588_init | ||
7008 | + * - ioh_1588_remove | ||
7009 | + * - ioh_1588_suspend | ||
7010 | + * - ioh_1588_resume | ||
7011 | + * <hr> | ||
7012 | + */ | ||
7013 | +static struct ioh_1588_dev ioh_1588_dev; | ||
7014 | + | ||
7015 | +/*! @ingroup IEEE_1588_Global | ||
7016 | + * @var ioh_1588_devp | ||
7017 | + * @brief Pointer to driver data structure | ||
7018 | + * @see | ||
7019 | + * - ioc_handle_notify | ||
7020 | + * - ioc_handle_clr_notify | ||
7021 | + * - ioc_handle_reset | ||
7022 | + * - target_time_callback | ||
7023 | + * - auxiliary_time_callback | ||
7024 | + * - pulse_per_sec_callback | ||
7025 | + * - ioh_1588_open | ||
7026 | + * <hr> | ||
7027 | + */ | ||
7028 | + | ||
7029 | +struct ioh_1588_dev *ioh_1588_devp = &ioh_1588_dev; | ||
7030 | + | ||
7031 | +/*! @ingroup IEEE_1588_PCILayerFacilitators | ||
7032 | + * @struct ioh_1588_params_ | ||
7033 | + * @brief structure to hold the module parameters | ||
7034 | + * @see | ||
7035 | + * - ioh_1588_init | ||
7036 | + * - ioh_1588_probe | ||
7037 | + * <hr> | ||
7038 | + */ | ||
7039 | +static struct ioh_1588_params_ { | ||
7040 | + /* module parameters */ | ||
7041 | + int eth_enable; /**< IEEE 1588 on ethernet interface | ||
7042 | + 0=Disabled 1=Enabled (default 1)*/ | ||
7043 | + int can_enable; /**< IEEE 1588 on CAN interface | ||
7044 | + 0=Disabled 1=Enabled (default 0)*/ | ||
7045 | + int major; /**< IEEE 1588 device major number to | ||
7046 | + use (default system assigned)*/ | ||
7047 | + unsigned char station[STATION_ADDR_LEN]; /**< IEEE 1588 station address | ||
7048 | + to use - column separated hex values*/ | ||
7049 | +} ioh_1588_param = { | ||
7050 | +1, 0, 0, "00:00:00:00:00:00"}; | ||
7051 | + | ||
7052 | +module_param_named(eth_enable, ioh_1588_param.eth_enable, bool, 0444); | ||
7053 | +MODULE_PARM_DESC(eth_enable, | ||
7054 | + "IEEE 1588 on ethernet interface 0=Disabled 1=Enabled \ | ||
7055 | + (default 1)"); | ||
7056 | + | ||
7057 | +module_param_named(can_enable, ioh_1588_param.can_enable, bool, 0444); | ||
7058 | +MODULE_PARM_DESC(can_enable, | ||
7059 | + "IEEE 1588 on CAN interface 0=Disabled 1=Enabled (default 0)"); | ||
7060 | + | ||
7061 | +module_param_named(major, ioh_1588_param.major, int, 0444); | ||
7062 | +MODULE_PARM_DESC(major, | ||
7063 | + "IEEE 1588 device major number to use (default system \ | ||
7064 | + assigned)"); | ||
7065 | + | ||
7066 | +module_param_string(station, ioh_1588_param.station, | ||
7067 | + sizeof ioh_1588_param.station, 0444); | ||
7068 | +MODULE_PARM_DESC(station, | ||
7069 | + "IEEE 1588 station address to use - column separated hex \ | ||
7070 | + values"); | ||
7071 | + | ||
7072 | +/*!@ingroup IEEE_1588_PCILayerAPI | ||
7073 | + * @fn int ioh_1588_probe(struct pci_dev *pdev,const struct pci_device_id *id) | ||
7074 | + * @brief | ||
7075 | + * This function is called right after insmod by the PCI core. Here we enable | ||
7076 | + * the | ||
7077 | + * device to make the device's resources live. We can then read PCI CFG space | ||
7078 | + * and init the device. | ||
7079 | + * | ||
7080 | + * @remarks | ||
7081 | + * The main tasks performed by this method are: | ||
7082 | + * - Allocate PCI resource required using | ||
7083 | + * request_mem_region API | ||
7084 | + * and map the memory to kernel virtual space using | ||
7085 | + * ioremap API. | ||
7086 | + * - Enable the PCI device using pci_enable_device | ||
7087 | + * API. | ||
7088 | + * - Initialize global variables and wait queues | ||
7089 | + * using | ||
7090 | + * init_waitqueue_head API | ||
7091 | + * - Set the memory address to be used by the HAL | ||
7092 | + * using ioh_1588_blpl_base_address_set API | ||
7093 | + * - Register the interrupt handler using request_irq | ||
7094 | + * API | ||
7095 | + * - Register the charecter driver using | ||
7096 | + * sregister_chrdev_region/ | ||
7097 | + * alloc_chrdev_region APIs based on whether major | ||
7098 | + * number has been | ||
7099 | + * provided by the user or not. | ||
7100 | + * - Add the device to the system using the APIs | ||
7101 | + * cdev_init and | ||
7102 | + * cdev_add. | ||
7103 | + * - If any of the above calls fail, undo the steps | ||
7104 | + * performed before the failure and return | ||
7105 | + * appropraite error | ||
7106 | + * status. | ||
7107 | + * - Depending on the parameters passed during module | ||
7108 | + * load, | ||
7109 | + * enable/disable PTP clock synchronization control | ||
7110 | + * on GbE | ||
7111 | + * (using ioh_1588_eth_enable/ioh_1588_eth_disable | ||
7112 | + * API). /CAN | ||
7113 | + * (using ioh_1588_can_enable/ioh_1588_can_disable | ||
7114 | + * API) channel. | ||
7115 | + * - Set the Station address as specified in the | ||
7116 | + * module | ||
7117 | + * parameter using ioh_1588_set_station_address | ||
7118 | + * API | ||
7119 | + * -Note: For A0/A1 sample, test mode setting is enabled for | ||
7120 | + * the 64 bit System Time Register. This is a work around | ||
7121 | + * for | ||
7122 | + * the non continuous value in the 64 bit System Time | ||
7123 | + * Register | ||
7124 | + * consisting of High(32bit) / Low(32bit) | ||
7125 | + * | ||
7126 | + * | ||
7127 | + * @param pdev [INOUT] pci device structure | ||
7128 | + * @param id [IN] list of devices supported by this driver | ||
7129 | + * | ||
7130 | + * @return int | ||
7131 | + * - 0 Success | ||
7132 | + * - -ENODEV request_mem_region or ioremap or | ||
7133 | + * pci_enable_device or request_irq error | ||
7134 | + * | ||
7135 | + * @see | ||
7136 | + * - ioh_1588_pcidev | ||
7137 | + * <hr> | ||
7138 | + */ | ||
7139 | + | ||
7140 | +static int __devinit | ||
7141 | +ioh_1588_probe(struct pci_dev *pdev, const struct pci_device_id *id) | ||
7142 | +{ | ||
7143 | + int ret = 0; | ||
7144 | + dev_t devno; | ||
7145 | + int i; | ||
7146 | + | ||
7147 | + UNUSED_ARG(id); | ||
7148 | + | ||
7149 | + /* enable the 1588 pci device */ | ||
7150 | + ret = pci_enable_device(pdev); | ||
7151 | + if (ret != 0) { | ||
7152 | + IOH_LOG(KERN_ERR, | ||
7153 | + "ioh_1588_probe:could not enable the pci device\n"); | ||
7154 | + goto exit_error; | ||
7155 | + } | ||
7156 | + IOH_DEBUG("ioh_1588_probe:pci_enable_device success\n"); | ||
7157 | + | ||
7158 | + ioh_1588_dev.mem_base = pci_resource_start(pdev, IO_MEM_BAR); | ||
7159 | + | ||
7160 | + if (!ioh_1588_dev.mem_base) { | ||
7161 | + IOH_LOG(KERN_ERR, | ||
7162 | + "ioh_1588_probe: could not locate IO memory address\n"); | ||
7163 | + /*disable the pci device */ | ||
7164 | + pci_disable_device(pdev); | ||
7165 | + ret = -ENODEV; | ||
7166 | + goto exit_error; | ||
7167 | + } | ||
7168 | + IOH_DEBUG("ioh_1588_probe:allocated IO memory address\n"); | ||
7169 | + | ||
7170 | + /* retreive the available length of the IO memory space */ | ||
7171 | + ioh_1588_dev.mem_size = pci_resource_len(pdev, IO_MEM_BAR); | ||
7172 | + | ||
7173 | + /* allocate the memory for the device registers */ | ||
7174 | + if (!request_mem_region | ||
7175 | + (ioh_1588_dev.mem_base, ioh_1588_dev.mem_size, "1588_regs")) { | ||
7176 | + IOH_LOG(KERN_ERR, | ||
7177 | + "ioh_1588_probe: could not allocate register memory \ | ||
7178 | + space\n"); | ||
7179 | + ioh_1588_dev.mem_base = 0; | ||
7180 | + /*disable the pci device */ | ||
7181 | + pci_disable_device(pdev); | ||
7182 | + ret = -EBUSY; | ||
7183 | + goto exit_error; | ||
7184 | + } | ||
7185 | + IOH_DEBUG("ioh_1588_probe:allocated register memory space\n"); | ||
7186 | + | ||
7187 | + /* get the virtual address to the 1588 registers */ | ||
7188 | + ioh_1588_dev.mem_virt = | ||
7189 | + ioremap(ioh_1588_dev.mem_base, ioh_1588_dev.mem_size); | ||
7190 | + | ||
7191 | + if (!ioh_1588_dev.mem_virt) { | ||
7192 | + pci_disable_device(pdev); | ||
7193 | + IOH_LOG(KERN_ERR, | ||
7194 | + "ioh_1588_probe: Could not get virtual address\n"); | ||
7195 | + /*release memory acquired for device registers */ | ||
7196 | + release_mem_region(ioh_1588_dev.mem_base, | ||
7197 | + ioh_1588_dev.mem_size); | ||
7198 | + ioh_1588_dev.mem_base = 0; | ||
7199 | + /*disable the pci device */ | ||
7200 | + pci_disable_device(pdev); | ||
7201 | + ret = -ENOMEM; | ||
7202 | + goto exit_error; | ||
7203 | + } | ||
7204 | + IOH_DEBUG("ioh_1588_probe:obtained virtual address=%p\n", | ||
7205 | + ioh_1588_dev.mem_virt); | ||
7206 | + | ||
7207 | + for (i = 0; i < NUM_EVENTS; i++) { | ||
7208 | + init_waitqueue_head(&ioh_1588_dev.notify_evt[i]); | ||
7209 | + ioh_1588_dev.event_flags[i] = 0; | ||
7210 | + } | ||
7211 | + IOH_DEBUG("ioh_1588_probe:initialized wait queue heads\n"); | ||
7212 | + | ||
7213 | + ret = | ||
7214 | + ioh_1588_blpl_base_address_set((unsigned int)ioh_1588_dev.mem_virt); | ||
7215 | + if (ret != IOH_1588_SUCCESS) { | ||
7216 | + IOH_LOG(KERN_ERR, | ||
7217 | + "ioh_1588_probe: ioh_1588_blpl_base_address_set \ | ||
7218 | + failed\n"); | ||
7219 | + /*unmap io */ | ||
7220 | + iounmap(ioh_1588_dev.mem_virt); | ||
7221 | + ioh_1588_dev.mem_virt = 0; | ||
7222 | + /*release memory acquired for device */ | ||
7223 | + release_mem_region(ioh_1588_dev.mem_base, | ||
7224 | + ioh_1588_dev.mem_size); | ||
7225 | + ioh_1588_dev.mem_base = 0; | ||
7226 | + /*disable device */ | ||
7227 | + pci_disable_device(pdev); | ||
7228 | + goto exit_error; | ||
7229 | + } | ||
7230 | + IOH_DEBUG("ioh_1588_probe:set base address\n"); | ||
7231 | + | ||
7232 | + ret = request_irq(pdev->irq, &ioh_1588_isr, IRQF_SHARED, DRIVER_NAME, | ||
7233 | + &ioh_1588_dev); | ||
7234 | + if (ret != 0) { | ||
7235 | + IOH_LOG(KERN_ERR, "ioh_1588_probe: failed to get irq %d\n", | ||
7236 | + pdev->irq); | ||
7237 | + /*unmap io */ | ||
7238 | + iounmap(ioh_1588_dev.mem_virt); | ||
7239 | + ioh_1588_dev.mem_virt = 0; | ||
7240 | + /*release memory acquired for device */ | ||
7241 | + release_mem_region(ioh_1588_dev.mem_base, | ||
7242 | + ioh_1588_dev.mem_size); | ||
7243 | + ioh_1588_dev.mem_base = 0; | ||
7244 | + /*disable device */ | ||
7245 | + pci_disable_device(pdev); | ||
7246 | + goto exit_error; | ||
7247 | + } | ||
7248 | + IOH_DEBUG("ioh_1588_probe:registered IRQ handler successfully\n"); | ||
7249 | + | ||
7250 | + /*register the module */ | ||
7251 | + if (ioh_1588_param.major != 0) { /* user specified a major | ||
7252 | + number, use it */ | ||
7253 | + IOH_DEBUG("ioh_1588_probe:using user specified major number\n"); | ||
7254 | + devno = MKDEV(ioh_1588_param.major, 0); | ||
7255 | + ret = register_chrdev_region(devno, 1, DRIVER_NAME); | ||
7256 | + ioh_1588_dev.devno = devno; /* store it */ | ||
7257 | + } else { /* request and reserve a device number */ | ||
7258 | + | ||
7259 | + IOH_DEBUG | ||
7260 | + ("ioh_1588_probe:dynamically allocating major number\n"); | ||
7261 | + ret = | ||
7262 | + alloc_chrdev_region(&ioh_1588_dev.devno, 0, 1, DRIVER_NAME); | ||
7263 | + devno = MKDEV(MAJOR(ioh_1588_dev.devno), 0); | ||
7264 | + } | ||
7265 | + if (ret < 0) { | ||
7266 | + IOH_LOG(KERN_ERR, | ||
7267 | + "ioh_1588_probe: Could not register module (major %d)\ | ||
7268 | + \n", | ||
7269 | + ioh_1588_param.major); | ||
7270 | + /*free irq */ | ||
7271 | + free_irq(pdev->irq, &ioh_1588_dev); | ||
7272 | + /*unmap io */ | ||
7273 | + iounmap(ioh_1588_dev.mem_virt); | ||
7274 | + ioh_1588_dev.mem_virt = 0; | ||
7275 | + /*release memory acquired for device */ | ||
7276 | + release_mem_region(ioh_1588_dev.mem_base, | ||
7277 | + ioh_1588_dev.mem_size); | ||
7278 | + ioh_1588_dev.mem_base = 0; | ||
7279 | + /*disable device */ | ||
7280 | + pci_disable_device(pdev); | ||
7281 | + goto exit_error; | ||
7282 | + } | ||
7283 | + IOH_DEBUG("ioh_1588_probe:registered the module(major %d)\n", | ||
7284 | + ioh_1588_param.major); | ||
7285 | + | ||
7286 | + /* init cdev struct for adding device to kernel */ | ||
7287 | + cdev_init(&ioh_1588_dev.cdev, &ioh_1588_fops); | ||
7288 | + ioh_1588_dev.cdev.owner = THIS_MODULE; | ||
7289 | + ioh_1588_dev.cdev.ops = &ioh_1588_fops; | ||
7290 | + | ||
7291 | + ret = cdev_add(&ioh_1588_dev.cdev, devno, 1); | ||
7292 | + if (ret != 0) { | ||
7293 | + IOH_LOG(KERN_ERR, "ioh_1588_probe: cdev_add failed\n"); | ||
7294 | + /*free region allocated for char device */ | ||
7295 | + unregister_chrdev_region(ioh_1588_dev.devno, 1); | ||
7296 | + /*free irq */ | ||
7297 | + free_irq(pdev->irq, &ioh_1588_dev); | ||
7298 | + /*unmap io */ | ||
7299 | + iounmap(ioh_1588_dev.mem_virt); | ||
7300 | + ioh_1588_dev.mem_virt = 0; | ||
7301 | + /*release memory acquired for device */ | ||
7302 | + release_mem_region(ioh_1588_dev.mem_base, | ||
7303 | + ioh_1588_dev.mem_size); | ||
7304 | + ioh_1588_dev.mem_base = 0; | ||
7305 | + /*disable device */ | ||
7306 | + pci_disable_device(pdev); | ||
7307 | + goto exit_error; | ||
7308 | + } | ||
7309 | + IOH_DEBUG("ioh_1588_probe: cdev_add successful\n"); | ||
7310 | + | ||
7311 | + ioh_1588_dev.initialized = 1; | ||
7312 | + /* indicate success */ | ||
7313 | + ioh_1588_dev.irq = pdev->irq; | ||
7314 | + | ||
7315 | + /*reset the ieee1588 h/w */ | ||
7316 | + ioh_1588_reset(); | ||
7317 | + | ||
7318 | + if (ioh_1588_param.eth_enable != 0) { /* Enable by default */ | ||
7319 | + IOH_DEBUG("ioh_1588_probe: invoking ioh_1588_eth_enable \ | ||
7320 | + to enable ethernet\n"); | ||
7321 | + (void)ioh_1588_eth_enable(); | ||
7322 | + } else { | ||
7323 | + IOH_DEBUG("ioh_1588_probe: invoking ioh_1588_eth_disable \ | ||
7324 | + to disable ethernet\n"); | ||
7325 | + (void)ioh_1588_eth_disable(); | ||
7326 | + } | ||
7327 | + if (ioh_1588_param.can_enable == 1) { /* Enable if requested */ | ||
7328 | + IOH_DEBUG("ioh_1588_probe: invoking ioh_1588_can_enable \ | ||
7329 | + to enable CAN\n"); | ||
7330 | + (void)ioh_1588_can_enable(); | ||
7331 | + } else { | ||
7332 | + IOH_DEBUG("ioh_1588_probe: invoking ioh_1588_can_disable \ | ||
7333 | + to disable CAN\n"); | ||
7334 | + (void)ioh_1588_can_disable(); | ||
7335 | + } | ||
7336 | + if (strcmp(ioh_1588_param.station, "00:00:00:00:00:00") != 0) { | ||
7337 | + if (ioh_1588_set_station_address(ioh_1588_param.station) != | ||
7338 | + IOH_1588_SUCCESS) { | ||
7339 | + IOH_LOG(KERN_ERR, | ||
7340 | + "ioh_1588_probe: Invalid station address \ | ||
7341 | + parameter\n" | ||
7342 | + "Module loaded; But, station address not set \ | ||
7343 | + correctly\n"); | ||
7344 | + } | ||
7345 | + } | ||
7346 | + IOH_DEBUG("ioh_1588_probe: probe succeeded\n"); | ||
7347 | + | ||
7348 | + return 0; | ||
7349 | + | ||
7350 | +exit_error: | ||
7351 | + | ||
7352 | + IOH_LOG(KERN_ERR, "ioh_1588_probe: probe failed\n"); | ||
7353 | + return ret; | ||
7354 | +} | ||
7355 | + | ||
7356 | +/*! @ingroup IEEE_1588_PCILayerAPI | ||
7357 | + * @fn void ioh_1588_remove(struct pci_dev *pdev) | ||
7358 | + * @brief | ||
7359 | + * This function is called when the pci driver is being unloaded from the | ||
7360 | + * kernel. | ||
7361 | + * @remarks | ||
7362 | + * The main tasks performed by this method are: | ||
7363 | + * - Free the interrupt line using free_irq API. | ||
7364 | + * - Disable the PCI device using pci_disable_device API. | ||
7365 | + * - Unmap the PCI memory and release the same using iounmap API. | ||
7366 | + * - Delete the char device from the system using cdev_del API. | ||
7367 | + * - Unregister the driver using unregister_chrdev_region API. | ||
7368 | + * | ||
7369 | + * @param pdev [INOUT] pci device structure | ||
7370 | + * | ||
7371 | + * @return None | ||
7372 | + *@see | ||
7373 | + - ioh_1588_pcidev | ||
7374 | + * | ||
7375 | + * <hr> | ||
7376 | + */ | ||
7377 | + | ||
7378 | +static void __devexit ioh_1588_remove(struct pci_dev *pdev) | ||
7379 | +{ | ||
7380 | + /* disable the interrupts on the 1588 hardware */ | ||
7381 | + IOH_DEBUG("ioh_1588_remove: disabling interrupts by \ | ||
7382 | + invoking ioh_1588_disable_interrupts\n"); | ||
7383 | + (void)ioh_1588_disable_interrupts(); | ||
7384 | + | ||
7385 | + /* free the interrupt */ | ||
7386 | + if (pdev->irq != 0) { | ||
7387 | + free_irq(pdev->irq, &ioh_1588_dev); | ||
7388 | + IOH_DEBUG("ioh_1588_remove: unregistered IRQ handler\n"); | ||
7389 | + } | ||
7390 | + | ||
7391 | + /* unmap the virtual IO memory space */ | ||
7392 | + if (ioh_1588_dev.mem_virt != 0) { | ||
7393 | + iounmap(ioh_1588_dev.mem_virt); | ||
7394 | + IOH_DEBUG | ||
7395 | + ("ioh_1588_remove: unmaped the virtual IO memory space\n"); | ||
7396 | + } | ||
7397 | + | ||
7398 | + /* release the reserved IO memory space */ | ||
7399 | + if (ioh_1588_dev.mem_base != 0) { | ||
7400 | + release_mem_region(ioh_1588_dev.mem_base, | ||
7401 | + ioh_1588_dev.mem_size); | ||
7402 | + IOH_DEBUG | ||
7403 | + ("ioh_1588_remove: released the reserved IO memory \ | ||
7404 | + space\n"); | ||
7405 | + } | ||
7406 | + | ||
7407 | + /* remove cdev struct from system */ | ||
7408 | + cdev_del(&ioh_1588_dev.cdev); | ||
7409 | + IOH_DEBUG("ioh_1588_remove: removed the cdev from system\n"); | ||
7410 | + | ||
7411 | + unregister_chrdev_region(ioh_1588_dev.devno, 1); | ||
7412 | + IOH_DEBUG("ioh_1588_remove:unregisterd the module\n"); | ||
7413 | + | ||
7414 | + /*disable the device */ | ||
7415 | + pci_disable_device(pdev); | ||
7416 | + IOH_DEBUG("ioh_1588_remove:disabled the device\n"); | ||
7417 | + | ||
7418 | + IOH_LOG(KERN_ERR, "ioh_1588_remove: complete\n"); | ||
7419 | +} | ||
7420 | + | ||
7421 | +#ifdef CONFIG_PM | ||
7422 | +/*! @ingroup IEEE_1588_PCILayerAPI | ||
7423 | + * @fn int ioh_1588_suspend(struct pci_dev *pdev,pm_message_t state) | ||
7424 | + * @brief | ||
7425 | + * This function is called to suspend a device before being put into a | ||
7426 | + * low power state. | ||
7427 | + * | ||
7428 | + * @remarks | ||
7429 | + * The main tasks performed by this method are: | ||
7430 | + * - Save PCI configuration space by invoking pci_save_state API. | ||
7431 | + * - If the above step fails, return the error from pci_save_state | ||
7432 | + * API. | ||
7433 | + * - Disable the PCI device using the pci_disable_device API. | ||
7434 | + * - Put the device to new power state using pci_set_power_state | ||
7435 | + * API. | ||
7436 | + * | ||
7437 | + * | ||
7438 | + * @param pdev [INOUT] pci device structure | ||
7439 | + * @param state [IN] suspend state | ||
7440 | + * | ||
7441 | + * @return int | ||
7442 | + * - 0 on success | ||
7443 | + * - -ENOMEM pci_save_state fails | ||
7444 | + * | ||
7445 | + * @see | ||
7446 | + * - ioh_1588_pcidev | ||
7447 | + * <hr> | ||
7448 | + * */ | ||
7449 | +static int ioh_1588_suspend(struct pci_dev *pdev, pm_message_t state) | ||
7450 | +{ | ||
7451 | + | ||
7452 | + IOH_DEBUG("ioh_1588_suspend: disabling interrupts by \ | ||
7453 | + invoking ioh_1588_disable_interrupts\n"); | ||
7454 | + (void)ioh_1588_disable_interrupts(); | ||
7455 | + | ||
7456 | + ioh_1588_dev.suspend = 1; | ||
7457 | + | ||
7458 | + IOH_DEBUG("ioh_1588_suspend: saving register values by \ | ||
7459 | + invoking ioh_1588_save_state\n"); | ||
7460 | + ioh_1588_save_state(); | ||
7461 | + | ||
7462 | + pci_disable_device(pdev); | ||
7463 | + IOH_DEBUG("ioh_1588_suspend: disabled the device\n"); | ||
7464 | + | ||
7465 | + (void)pci_enable_wake(pdev, PCI_D3hot, 0); | ||
7466 | + IOH_DEBUG("ioh_1588_suspend: disabled PM notifications\n"); | ||
7467 | + | ||
7468 | + if (pci_save_state(pdev) != 0) { | ||
7469 | + IOH_LOG(KERN_ERR, | ||
7470 | + "ioh_1588_suspend: could not save PCI config state\n"); | ||
7471 | + return -ENOMEM; | ||
7472 | + } | ||
7473 | + IOH_DEBUG("ioh_1588_suspend: saved state\n"); | ||
7474 | + | ||
7475 | + pci_set_power_state(pdev, pci_choose_state(pdev, state)); | ||
7476 | + | ||
7477 | + IOH_DEBUG("ioh_1588_suspend: returning success\n"); | ||
7478 | + return 0; | ||
7479 | +} | ||
7480 | + | ||
7481 | +/*! @ingroup IEEE_1588_PCILayerAPI | ||
7482 | + * @fn int ioh_1588_resume(struct pci_dev *pdev) | ||
7483 | + * @brief | ||
7484 | + * This function is called to resume a device after being put into a | ||
7485 | + * low power state. | ||
7486 | + * @remarks | ||
7487 | + * The main tasks performed by this method are: | ||
7488 | + * - Restore the power state of the device using | ||
7489 | + * pci_set_power_state | ||
7490 | + * API. | ||
7491 | + * - Restore the PCI configuration space using pci_restore_state | ||
7492 | + * API. | ||
7493 | + * - Enable the PCI device using pci_enable_device API. | ||
7494 | + * - If pci_enable_device fails, return the error status; | ||
7495 | + * else return 0. | ||
7496 | + * | ||
7497 | + * | ||
7498 | + * @param pdev [INOUT] pci device structure | ||
7499 | + * | ||
7500 | + * @return int | ||
7501 | + * - 0 on success | ||
7502 | + * - -EIO pci_enable_device fails | ||
7503 | + * - -EINVAL pci_enable_device fails | ||
7504 | + * @see | ||
7505 | + * - ioh_1588_pcidev | ||
7506 | + * <hr> | ||
7507 | + */ | ||
7508 | + | ||
7509 | +static int ioh_1588_resume(struct pci_dev *pdev) | ||
7510 | +{ | ||
7511 | + int ret; | ||
7512 | + | ||
7513 | + pci_set_power_state(pdev, PCI_D0); | ||
7514 | + | ||
7515 | + ret = pci_restore_state(pdev); | ||
7516 | + | ||
7517 | + if (ret != 0) { | ||
7518 | + IOH_LOG(KERN_ERR, | ||
7519 | + "ioh_1588_resume: pci_restore_state failed\n"); | ||
7520 | + return ret; | ||
7521 | + } | ||
7522 | + IOH_DEBUG("ioh_1588_resume: restored state\n"); | ||
7523 | + | ||
7524 | + ret = pci_enable_device(pdev); | ||
7525 | + | ||
7526 | + if (ret) { | ||
7527 | + IOH_LOG(KERN_ERR, | ||
7528 | + "ioh_1588_resume: pci_enable_device failed\n"); | ||
7529 | + return ret; | ||
7530 | + } | ||
7531 | + | ||
7532 | + IOH_DEBUG("ioh_1588_resume: enabled device\n"); | ||
7533 | + | ||
7534 | + (void)pci_enable_wake(pdev, PCI_D3hot, 0); | ||
7535 | + IOH_DEBUG("ioh_1588_resume: disabled PM notifications\n"); | ||
7536 | + | ||
7537 | + IOH_DEBUG("ioh_1588_resume: restoring register values by \ | ||
7538 | + invoking ioh_1588_restore_state\n"); | ||
7539 | + ioh_1588_restore_state(); | ||
7540 | + | ||
7541 | + ioh_1588_dev.suspend = 0; | ||
7542 | + | ||
7543 | + IOH_DEBUG("ioh_1588_resume: returning success\n"); | ||
7544 | + return 0; | ||
7545 | +} | ||
7546 | +#endif | ||
7547 | + | ||
7548 | +/*! @ingroup IEEE_1588_InterfaceLayerAPI | ||
7549 | + * @fn void ioh_1588_exit(void) | ||
7550 | + * @brief Un-loads the IEEE 1588 PCI driver. | ||
7551 | + * @remarks This function is invoked when the driver is | ||
7552 | + * unloaded. The main task performed by this | ||
7553 | + * function is un-registering the module as | ||
7554 | + * PCI driver. | ||
7555 | + * @param None | ||
7556 | + * @return None | ||
7557 | + * <hr> | ||
7558 | + */ | ||
7559 | +static void __exit ioh_1588_exit(void) | ||
7560 | +{ | ||
7561 | + | ||
7562 | + pci_unregister_driver(&ioh_1588_pcidev); | ||
7563 | + | ||
7564 | + IOH_DEBUG("ioh_1588_exit: Driver unloaded\n"); | ||
7565 | +} | ||
7566 | + | ||
7567 | +/*! @ingroup IEEE_1588_InterfaceLayerAPI | ||
7568 | + * @fn int ioh_1588_init(void) | ||
7569 | + * @brief Initializes the driver. | ||
7570 | + * @remarks This function is the entry point for the driver. | ||
7571 | + * The main tasks performed by this method are: | ||
7572 | + * - Register IEEE 1588 driver as a PCI driver by calling | ||
7573 | + * pci_register_driver | ||
7574 | + * | ||
7575 | + * @param None | ||
7576 | + * | ||
7577 | + * @return int | ||
7578 | + * - 0 on success | ||
7579 | + * - -EBUSY register_chrdev_region fails | ||
7580 | + * - -ENOMEM cdev_add/register_chrdev_region/ | ||
7581 | + * pci_register_driver fails | ||
7582 | + * - -EEXIST pci_register_driver fails | ||
7583 | + * - -EINVAL pci_register_driver fails | ||
7584 | + * <hr> | ||
7585 | + */ | ||
7586 | +static int __init ioh_1588_init(void) | ||
7587 | +{ | ||
7588 | + int ret; | ||
7589 | + | ||
7590 | + (void)memset((void *)&ioh_1588_dev, 0, sizeof ioh_1588_dev); | ||
7591 | + | ||
7592 | + /* register the driver with the pci core */ | ||
7593 | + ret = pci_register_driver(&ioh_1588_pcidev); | ||
7594 | + | ||
7595 | + if (ret) | ||
7596 | + IOH_LOG(KERN_ERR, "ioh_1588_init: pci_register failed\n"); | ||
7597 | + | ||
7598 | + IOH_DEBUG("ioh_1588_init: pci_register success\n"); | ||
7599 | + return ret; | ||
7600 | +} | ||
7601 | + | ||
7602 | +module_init(ioh_1588_init); | ||
7603 | +module_exit(ioh_1588_exit); | ||
7604 | +MODULE_LICENSE("GPL"); | ||
7605 | +MODULE_DEVICE_TABLE(pci, ioh_1588_pcidev_id); | ||
7606 | diff -urN linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_pci.h topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_pci.h | ||
7607 | --- linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_pci.h 1970-01-01 09:00:00.000000000 +0900 | ||
7608 | +++ topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_1588_pci.h 2010-03-09 05:27:48.000000000 +0900 | ||
7609 | @@ -0,0 +1,122 @@ | ||
7610 | + /*! | ||
7611 | + * @file ioh_1588_pci.h | ||
7612 | + * @brief | ||
7613 | + * This file lists the declarations for IEEE_1588_PCILayer APIs. | ||
7614 | + * @version 0.92 | ||
7615 | + * @section | ||
7616 | + * This program is free software; you can redistribute it and/or modify | ||
7617 | + * it under the terms of the GNU General Public License as published by | ||
7618 | + * the Free Software Foundation; version 2 of the License. | ||
7619 | + * | ||
7620 | + * This program is distributed in the hope that it will be useful, | ||
7621 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
7622 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
7623 | + * GNU General Public License for more details. | ||
7624 | + * | ||
7625 | + * You should have received a copy of the GNU General Public License | ||
7626 | + * along with this program; if not, write to the Free Software | ||
7627 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
7628 | + */ | ||
7629 | + | ||
7630 | +/* | ||
7631 | + * History: | ||
7632 | + * modified to support Intel IOH GE IEEE 1588 hardware | ||
7633 | + * Copyright (C) 2008 OKI SEMICONDUCTOR Co., LTD. | ||
7634 | + * All rights reserved. | ||
7635 | + * derived from | ||
7636 | + * IEEE 1588 Time Synchronization Driver for Intel EP80579 | ||
7637 | + * Copyright(c) 2007,2008 Intel Corporation. All rights reserved. | ||
7638 | + * All rights reserved. | ||
7639 | + * | ||
7640 | + */ | ||
7641 | + | ||
7642 | +#ifndef IOH_1588_PCI_H | ||
7643 | +#define IOH_1588_PCI_H | ||
7644 | + | ||
7645 | +#include <linux/types.h> | ||
7646 | +#include <linux/errno.h> | ||
7647 | +#include <linux/kernel.h> | ||
7648 | +#include <linux/module.h> | ||
7649 | +#include <linux/poll.h> | ||
7650 | +#include <linux/init.h> | ||
7651 | +#include <linux/fs.h> | ||
7652 | +#include <linux/fcntl.h> | ||
7653 | +#include <linux/interrupt.h> | ||
7654 | +#include <linux/uaccess.h> | ||
7655 | +#include <linux/cdev.h> | ||
7656 | +#include <linux/pci.h> | ||
7657 | + | ||
7658 | +/*! @ingroup IEEE_1588_Global | ||
7659 | + * @def DRIVER_NAME | ||
7660 | + * @brief Macro representing the name of this driver | ||
7661 | + * <hr> | ||
7662 | + */ | ||
7663 | +#define DRIVER_NAME "ioh_ieee1588" | ||
7664 | + | ||
7665 | +/*! @ingroup IEEE_1588_Global | ||
7666 | + * @def STATION_ADDR_LEN | ||
7667 | + * @brief Macro representing the station address length | ||
7668 | + * <hr> | ||
7669 | + */ | ||
7670 | +#define STATION_ADDR_LEN 20 | ||
7671 | + | ||
7672 | +/*! @ingroup IEEE_1588_PCILayer | ||
7673 | + @def PCI_VENDOR_ID_IOH | ||
7674 | + @brief Outlines the PCI Vendor ID for IOH board. | ||
7675 | + */ | ||
7676 | + | ||
7677 | +/*! @ingroup IEEE_1588_PCILayer | ||
7678 | + @def PCI_DEVICE_ID_IOH_1588 | ||
7679 | + @brief Outlines the PCI Device ID for IEEE 1588 device. | ||
7680 | + */ | ||
7681 | +#define PCI_DEVICE_ID_IOH_1588 0x8819 | ||
7682 | + | ||
7683 | +/*! @ingroup IEEE_1588_PCILayer | ||
7684 | + * @def IO_MEM_BAR | ||
7685 | + * @brief Macro representing IO memory BAR | ||
7686 | + * <hr> | ||
7687 | + */ | ||
7688 | +#define IO_MEM_BAR 1 | ||
7689 | + | ||
7690 | +/* enumeration of events used */ | ||
7691 | + | ||
7692 | +/*! @ingroup IEEE_1588_Global | ||
7693 | + * @enum notify_event | ||
7694 | + * @brief enumeration of events used | ||
7695 | + * <hr> | ||
7696 | + */ | ||
7697 | +enum _notify_event { | ||
7698 | + TARG_TIME_EVENT_NUM, | ||
7699 | + AUX_TIME_EVENT_NUM, | ||
7700 | + PPS_EVENT_NUM, | ||
7701 | + NUM_EVENTS | ||
7702 | +}; | ||
7703 | + | ||
7704 | +/* private driver data */ | ||
7705 | +/*! @ingroup IEEE_1588_Global | ||
7706 | + * @struct ioh_1588_dev_t | ||
7707 | + * @brief Driver private data | ||
7708 | + * <hr> | ||
7709 | + */ | ||
7710 | +struct ioh_1588_dev { | ||
7711 | + dev_t devno; /**< The device (major) number. */ | ||
7712 | + struct cdev cdev; /**< The cdev structure instance. */ | ||
7713 | + void *mem_virt; /**< The virtual memory base address.*/ | ||
7714 | + unsigned int mem_base; /**< The physical memory base address.*/ | ||
7715 | + unsigned int mem_size; /**< The memory size. */ | ||
7716 | + unsigned int irq; /**< The IRQ line of the device.*/ | ||
7717 | + unsigned int suspend:1; /**< The suspend flag. */ | ||
7718 | + unsigned int initialized:1; /**< The initialized flag. */ | ||
7719 | + /* event variables */ | ||
7720 | + unsigned int event_flags[NUM_EVENTS]; /**< The event variables. */ | ||
7721 | + wait_queue_head_t notify_evt[NUM_EVENTS]; /**< The notify event | ||
7722 | + variable.*/ | ||
7723 | +}; | ||
7724 | + | ||
7725 | +extern struct ioh_1588_dev *ioh_1588_devp; | ||
7726 | +extern const struct file_operations ioh_1588_fops; | ||
7727 | +irqreturn_t ioh_1588_isr(int irq, void *p_data); | ||
7728 | +extern void ioh_1588_save_state(void); | ||
7729 | +extern void ioh_1588_restore_state(void); | ||
7730 | + | ||
7731 | +#endif /* IOH_1588_PCI_H */ | ||
7732 | diff -urN linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_common.h topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_common.h | ||
7733 | --- linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_common.h 1970-01-01 09:00:00.000000000 +0900 | ||
7734 | +++ topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_common.h 2010-03-09 05:56:11.000000000 +0900 | ||
7735 | @@ -0,0 +1,146 @@ | ||
7736 | +/*! | ||
7737 | + * @file ioh_common.h | ||
7738 | + * @brief Provides the macro definitions used by all files. | ||
7739 | + * @version 1.0.0.0 | ||
7740 | + * @section | ||
7741 | + * This program is free software; you can redistribute it and/or modify | ||
7742 | + * it under the terms of the GNU General Public License as published by | ||
7743 | + * the Free Software Foundation; version 2 of the License. | ||
7744 | + * | ||
7745 | + * This program is distributed in the hope that it will be useful, | ||
7746 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
7747 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
7748 | + * GNU General Public License for more details. | ||
7749 | + * | ||
7750 | + * You should have received a copy of the GNU General Public License | ||
7751 | + * along with this program; if not, write to the Free Software | ||
7752 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
7753 | + */ | ||
7754 | + | ||
7755 | +/* | ||
7756 | + * History: | ||
7757 | + * Copyright (C) 2008 OKI SEMICONDUCTOR Co., LTD. | ||
7758 | + * All rights reserved. | ||
7759 | + * | ||
7760 | + * created: | ||
7761 | + * WIPRO 03/07/2009 | ||
7762 | + * modified: | ||
7763 | + * WIPRO 05/08/2009 | ||
7764 | + * | ||
7765 | + */ | ||
7766 | + | ||
7767 | +#ifndef __IOH_COMMON_H__ | ||
7768 | +#define __IOH_COMMON_H__ | ||
7769 | + | ||
7770 | +/*! @ingroup Global | ||
7771 | +@def IOH_WRITE8 | ||
7772 | +@brief Macro for writing 8 bit data to an io/mem address | ||
7773 | +*/ | ||
7774 | +#define IOH_WRITE8(val, addr) iowrite8((val), (void __iomem *)(addr)) | ||
7775 | +/*! @ingroup Global | ||
7776 | +@def IOH_LOG | ||
7777 | +@brief Macro for writing 16 bit data to an io/mem address | ||
7778 | +*/ | ||
7779 | +#define IOH_WRITE16(val, addr) iowrite16((val), (void __iomem *)(addr)) | ||
7780 | +/*! @ingroup Global | ||
7781 | +@def IOH_LOG | ||
7782 | +@brief Macro for writing 32 bit data to an io/mem address | ||
7783 | +*/ | ||
7784 | +#define IOH_WRITE32(val, addr) iowrite32((val), (void __iomem *)(addr)) | ||
7785 | + | ||
7786 | +/*! @ingroup Global | ||
7787 | +@def IOH_READ8 | ||
7788 | +@brief Macro for reading 8 bit data from an io/mem address | ||
7789 | +*/ | ||
7790 | +#define IOH_READ8(addr) ioread8((void __iomem *)(addr)) | ||
7791 | +/*! @ingroup Global | ||
7792 | +@def IOH_READ16 | ||
7793 | +@brief Macro for reading 16 bit data from an io/mem address | ||
7794 | +*/ | ||
7795 | +#define IOH_READ16(addr) ioread16((void __iomem *)(addr)) | ||
7796 | +/*! @ingroup Global | ||
7797 | +@def IOH_READ32 | ||
7798 | +@brief Macro for reading 32 bit data from an io/mem address | ||
7799 | +*/ | ||
7800 | +#define IOH_READ32(addr) ioread32((void __iomem *)(addr)) | ||
7801 | +/*! @ingroup Global | ||
7802 | +@def IOH_WRITE32_F | ||
7803 | +@brief Macro for writing 32 bit data to an io/mem address | ||
7804 | +*/ | ||
7805 | +#define IOH_WRITE32_F(val, addr) do \ | ||
7806 | + { IOH_WRITE32((val), (addr)); (void)IOH_READ32((addr)); } while (0); | ||
7807 | + | ||
7808 | +/*! @ingroup Global | ||
7809 | +@def IOH_WRITE_BYTE | ||
7810 | +@brief Macro for writing 1 byte data to an io/mem address | ||
7811 | +*/ | ||
7812 | +#define IOH_WRITE_BYTE IOH_WRITE8 | ||
7813 | +/*! @ingroup Global | ||
7814 | +@def IOH_WRITE_WORD | ||
7815 | +@brief Macro for writing 1 word data to an io/mem address | ||
7816 | +*/ | ||
7817 | +#define IOH_WRITE_WORD IOH_WRITE16 | ||
7818 | +/*! @ingroup Global | ||
7819 | +@def IOH_WRITE_LONG | ||
7820 | +@brief Macro for writing long data to an io/mem address | ||
7821 | +*/ | ||
7822 | +#define IOH_WRITE_LONG IOH_WRITE32 | ||
7823 | + | ||
7824 | +/*! @ingroup Global | ||
7825 | +@def IOH_READ_BYTE | ||
7826 | +@brief Macro for reading 1 byte data from an io/mem address | ||
7827 | +*/ | ||
7828 | +#define IOH_READ_BYTE IOH_READ8 | ||
7829 | +/*! @ingroup Global | ||
7830 | +@def IOH_READ_WORD | ||
7831 | +@brief Macro for reading 1 word data from an io/mem address | ||
7832 | +*/ | ||
7833 | +#define IOH_READ_WORD IOH_READ16 | ||
7834 | +/*! @ingroup Global | ||
7835 | +@def IOH_READ_LONG | ||
7836 | +@brief Macro for reading long data from an io/mem address | ||
7837 | +*/ | ||
7838 | +#define IOH_READ_LONG IOH_READ32 | ||
7839 | + | ||
7840 | +/* Bit Manipulation Macros */ | ||
7841 | + | ||
7842 | +/*! @ingroup Global | ||
7843 | +@def IOH_READ_LONG | ||
7844 | +@brief macro to set a specified bit(mask) at the | ||
7845 | + specified address | ||
7846 | +*/ | ||
7847 | +#define IOH_SET_ADDR_BIT(addr, bitmask) IOH_WRITE_LONG((IOH_READ_LONG(addr) |\ | ||
7848 | + (bitmask)), (addr)) | ||
7849 | + | ||
7850 | +/*! @ingroup Global | ||
7851 | +@def IOH_READ_LONG | ||
7852 | +@brief macro to clear a specified bit(mask) at the specified address | ||
7853 | +*/ | ||
7854 | +#define IOH_CLR_ADDR_BIT(addr, bitmask) IOH_WRITE_LONG((IOH_READ_LONG(addr) &\ | ||
7855 | + ~(bitmask)), (addr)) | ||
7856 | + | ||
7857 | +/*! @ingroup Global | ||
7858 | +@def IOH_READ_LONG | ||
7859 | +@brief macro to set a specified bitmask for a variable | ||
7860 | +*/ | ||
7861 | +#define IOH_SET_BITMSK(var, bitmask) ((var) |= (bitmask)) | ||
7862 | + | ||
7863 | +/*! @ingroup Global | ||
7864 | +@def IOH_READ_LONG | ||
7865 | +@brief macro to clear a specified bitmask for a variable | ||
7866 | +*/ | ||
7867 | +#define IOH_CLR_BITMSK(var, bitmask) ((var) &= (~(bitmask))) | ||
7868 | + | ||
7869 | +/*! @ingroup Global | ||
7870 | +@def IOH_READ_LONG | ||
7871 | +@brief macro to set a specified bit for a variable | ||
7872 | +*/ | ||
7873 | +#define IOH_SET_BIT(var, bit) ((var) |= (1<<(bit))) | ||
7874 | + | ||
7875 | +/*! @ingroup Global | ||
7876 | +@def IOH_READ_LONG | ||
7877 | +@brief macro to clear a specified bit for a variable | ||
7878 | +*/ | ||
7879 | +#define IOH_CLR_BIT(var, bit) ((var) &= ~(1<<(bit))) | ||
7880 | + | ||
7881 | +#endif | ||
7882 | diff -urN linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_debug.h topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_debug.h | ||
7883 | --- linux-2.6.33-rc3/drivers/char/pch_ieee1588/pch_debug.h 1970-01-01 09:00:00.000000000 +0900 | ||
7884 | +++ topcliff-2.6.33-rc3/drivers/char/pch_ieee1588/pch_debug.h 2010-03-09 05:37:47.000000000 +0900 | ||
7885 | @@ -0,0 +1,60 @@ | ||
7886 | +/*! | ||
7887 | + * @file ioh_debug.h | ||
7888 | + * @brief Provides the macro definitions used for debugging. | ||
7889 | + * @version 1.0.0.0 | ||
7890 | + * @section | ||
7891 | + * This program is free software; you can redistribute it and/or modify | ||
7892 | + * it under the terms of the GNU General Public License as published by | ||
7893 | + * the Free Software Foundation; version 2 of the License. | ||
7894 | + * | ||
7895 | + * This program is distributed in the hope that it will be useful, | ||
7896 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
7897 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
7898 | + * GNU General Public License for more details. | ||
7899 | + * | ||
7900 | + * You should have received a copy of the GNU General Public License | ||
7901 | + * along with this program; if not, write to the Free Software | ||
7902 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | ||
7903 | + */ | ||
7904 | + | ||
7905 | +/* | ||
7906 | + * History: | ||
7907 | + * Copyright (C) 2008 OKI SEMICONDUCTOR Co., LTD. | ||
7908 | + * All rights reserved. | ||
7909 | + * | ||
7910 | + * created: | ||
7911 | + * WIPRO 03/07/2009 | ||
7912 | + * modified: | ||
7913 | + * WIPRO 05/08/2009 | ||
7914 | + * | ||
7915 | + */ | ||
7916 | + | ||
7917 | +#ifndef __IOH_DEBUG_H__ | ||
7918 | +#define __IOH_DEBUG_H__ | ||
7919 | + | ||
7920 | +#ifdef MODULE | ||
7921 | +#define IOH_LOG(level, fmt, args...) printk(level "%s:" fmt "\n",\ | ||
7922 | + THIS_MODULE->name, ##args) | ||
7923 | +#else | ||
7924 | +#define IOH_LOG(level, fmt, args...) printk(level "%s:" fmt "\n" ,\ | ||
7925 | + __FILE__, ##args) | ||
7926 | +#endif | ||
7927 | + | ||
7928 | + | ||
7929 | +#ifdef DEBUG | ||
7930 | + #define IOH_DEBUG(fmt, args...) IOH_LOG(KERN_DEBUG, fmt, ##args) | ||
7931 | +#else | ||
7932 | + #define IOH_DEBUG(fmt, args...) | ||
7933 | +#endif | ||
7934 | + | ||
7935 | +#ifdef IOH_TRACE_ENABLED | ||
7936 | + #define IOH_TRACE IOH_DEBUG | ||
7937 | +#else | ||
7938 | + #define IOH_TRACE(fmt, args...) | ||
7939 | +#endif | ||
7940 | + | ||
7941 | +#define IOH_TRACE_ENTER IOH_TRACE("Enter %s", __func__) | ||
7942 | +#define IOH_TRACE_EXIT IOH_TRACE("Exit %s", __func__) | ||
7943 | + | ||
7944 | + | ||
7945 | +#endif | ||