aboutsummaryrefslogtreecommitdiff
path: root/include/linux/pmic_rtc.h
blob: f0d87423f568b45012dbc269e055d17744c4b3bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * Copyright 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU Lesser General
 * Public License.  You may obtain a copy of the GNU Lesser General
 * Public License Version 2.1 or later at the following locations:
 *
 * http://www.opensource.org/licenses/lgpl-license.html
 * http://www.gnu.org/copyleft/lgpl.html
 */

#ifndef __ASM_ARCH_MXC_PMIC_RTC_H__
#define __ASM_ARCH_MXC_PMIC_RTC_H__

/*!
 * @defgroup PMIC_RTC PMIC RTC Driver
 * @ingroup PMIC_DRVRS
 */

/*!
 * @file arch-mxc/pmic_rtc.h
 * @brief This is the header of PMIC RTC driver.
 *
 * @ingroup PMIC_RTC
 */

/*
 * Includes
 */
#include <linux/ioctl.h>
#include <linux/pmic_status.h>
#include <linux/pmic_external.h>

#define         PMIC_RTC_SET_TIME                    _IOWR('p', 0xd1, int)
#define         PMIC_RTC_GET_TIME                    _IOWR('p', 0xd2, int)
#define         PMIC_RTC_SET_ALARM		     _IOWR('p', 0xd3, int)
#define         PMIC_RTC_GET_ALARM		     _IOWR('p', 0xd4, int)
#define         PMIC_RTC_WAIT_ALARM		     _IOWR('p', 0xd5, int)
#define         PMIC_RTC_ALARM_REGISTER              _IOWR('p', 0xd6, int)
#define         PMIC_RTC_ALARM_UNREGISTER            _IOWR('p', 0xd7, int)

/*!
 * This enumeration define all RTC interrupt
 */
typedef enum {
	/*!
	 * Time of day alarm
	 */
	RTC_IT_ALARM,
	/*!
	 * 1 Hz timetick
	 */
	RTC_IT_1HZ,
	/*!
	 * RTC reset occurred
	 */
	RTC_IT_RST,
} t_rtc_int;

/*
 * RTC PMIC API
 */

/* EXPORTED FUNCTIONS */
#ifdef __KERNEL__

/*!
 * This function set the real time clock of PMIC
 *
 * @param        pmic_time  	value of date and time
 *
 * @return       This function returns PMIC_STATUS if successful.
 */
PMIC_STATUS pmic_rtc_set_time(struct timeval *pmic_time);

/*!
 * This function get the real time clock of PMIC
 *
 * @param        pmic_time  	return value of date and time
 *
 * @return       This function returns PMIC_STATUS if successful.
 */
PMIC_STATUS pmic_rtc_get_time(struct timeval *pmic_time);

/*!
 * This function set the real time clock alarm of PMIC
 *
 * @param        pmic_time  	value of date and time
 *
 * @return       This function returns PMIC_STATUS if successful.
 */
PMIC_STATUS pmic_rtc_set_time_alarm(struct timeval *pmic_time);

/*!
 * This function get the real time clock alarm of PMIC
 *
 * @param        pmic_time  	return value of date and time
 *
 * @return       This function returns PMIC_STATUS if successful.
 */
PMIC_STATUS pmic_rtc_get_time_alarm(struct timeval *pmic_time);

/*!
 * This function wait the Alarm event
 *
 * @return       This function returns PMIC_STATUS if successful.
 */
PMIC_STATUS pmic_rtc_wait_alarm(void);

/*!
 * This function is used to un/subscribe on RTC event IT.
 *
 * @param        event  	type of event.
 * @param        callback  	event callback function.
 * @param        sub      	define if Un/subscribe event.
 *
 * @return       This function returns PMIC_STATUS if successful.
 */
PMIC_STATUS pmic_rtc_event(t_rtc_int event, void *callback, bool sub);

/*!
 * This function is used to subscribe on RTC event IT.
 *
 * @param        event  	type of event.
 * @param        callback  	event callback function.
 *
 * @return       This function returns PMIC_STATUS if successful.
 */
PMIC_STATUS pmic_rtc_event_sub(t_rtc_int event, void *callback);

/*!
 * This function is used to un-subscribe on RTC event IT.
 *
 * @param        event  	type of event.
 * @param        callback  	event callback function.
 *
 * @return       This function returns PMIC_STATUS if successful.
 */
PMIC_STATUS pmic_rtc_event_unsub(t_rtc_int event, void *callback);

/*!
 * This function is used to tell if PMIC RTC has been correctly loaded.
 *
 * @return       This function returns 1 if RTC was successfully loaded
 * 		 0 otherwise.
 */
int pmic_rtc_loaded(void);

#endif				/* __KERNEL__ */

#endif				/* __ASM_ARCH_MXC_PMIC_RTC_H__ */