xref: /freebsd/sys/contrib/ncsw/Peripherals/FM/Rtc/fm_rtc.h (revision c2c014f24c10f90d85126ac5fbd4d8524de32b1c)
1 /*
2  * Copyright 2008-2012 Freescale Semiconductor Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above copyright
9  *       notice, this list of conditions and the following disclaimer in the
10  *       documentation and/or other materials provided with the distribution.
11  *     * Neither the name of Freescale Semiconductor nor the
12  *       names of its contributors may be used to endorse or promote products
13  *       derived from this software without specific prior written permission.
14  *
15  *
16  * ALTERNATIVELY, this software may be distributed under the terms of the
17  * GNU General Public License ("GPL") as published by the Free Software
18  * Foundation, either version 2 of that License or (at your option) any
19  * later version.
20  *
21  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 
34 /******************************************************************************
35  @File          fm_rtc.h
36 
37  @Description   Memory map and internal definitions for FM RTC IEEE1588 Timer driver.
38 
39  @Cautions      None
40 *//***************************************************************************/
41 
42 #ifndef __FM_RTC_H__
43 #define __FM_RTC_H__
44 
45 #include "std_ext.h"
46 #include "fm_rtc_ext.h"
47 
48 
49 #define __ERR_MODULE__  MODULE_FM_RTC
50 
51 /* General definitions */
52 
53 #define ACCUMULATOR_OVERFLOW            ((uint64_t)(1LL << 32))
54 #define DEFAULT_OUTPUT_CLOCK_DIVISOR     0x00000002
55 #define DEFAULT_BYPASS      			 FALSE
56 #define DEFAULT_CLOCK_PERIOD             1000
57 
58 
59 
60 typedef struct t_FmRtcAlarm
61 {
62     t_FmRtcExceptionsCallback   *f_AlarmCallback;
63     bool                        clearOnExpiration;
64 } t_FmRtcAlarm;
65 
66 typedef struct t_FmRtcPeriodicPulse
67 {
68     t_FmRtcExceptionsCallback   *f_PeriodicPulseCallback;
69 } t_FmRtcPeriodicPulse;
70 
71 typedef struct t_FmRtcExternalTrigger
72 {
73     t_FmRtcExceptionsCallback   *f_ExternalTriggerCallback;
74 } t_FmRtcExternalTrigger;
75 
76 
77 /**************************************************************************//**
78  @Description RTC FM driver control structure.
79 *//***************************************************************************/
80 typedef struct t_FmRtc
81 {
82     t_Part                  *p_Part;            /**< Pointer to the integration device              */
83     t_Handle                h_Fm;
84     t_Handle                h_App;              /**< Application handle */
85     struct rtc_regs			*p_MemMap;
86     uint32_t                clockPeriodNanoSec; /**< RTC clock period in nano-seconds (for FS mode) */
87     uint32_t                srcClkFreqMhz;
88     uint16_t                outputClockDivisor; /**< Output clock divisor (for FS mode) */
89     t_FmRtcAlarm            alarmParams[FM_RTC_NUM_OF_ALARMS];
90     t_FmRtcPeriodicPulse    periodicPulseParams[FM_RTC_NUM_OF_PERIODIC_PULSES];
91     t_FmRtcExternalTrigger  externalTriggerParams[FM_RTC_NUM_OF_EXT_TRIGGERS];
92     struct rtc_cfg 			*p_RtcDriverParam;  /**< RTC Driver parameters (for Init phase) */
93 } t_FmRtc;
94 
95 
96 #endif /* __FM_RTC_H__ */
97