blob: 50e75bb94bbab8333248e174a52117545fe6b078 [file] [log] [blame]
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +05301/*
Mohit Aggarwal43923522020-01-30 14:25:31 +05302 * Copyright (c) 2010-2014, 2016, 2018-2020 The Linux Foundation. All rights reserved.
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +05303 *
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.
Duy Truong82533662013-01-17 10:32:03 -080011 * * Neither the name of The Linux Foundation nor the names of its contributors
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +053012 * may be used to endorse or promote products derived from this software
13 * without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 */
28
29#ifndef __TIME_GENOFF_H__
30#define __TIME_GENOFF_H__
31
Katish Paran1f2db252014-04-03 15:01:44 +053032#ifdef __cplusplus
33extern "C" {
34#endif
35
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +053036/*
37 * Time genoff base -- To be used by the time setter
38 * Reserved bases to be supported later.
39 */
40typedef enum time_bases {
41 ATS_RTC = 0,
42 ATS_TOD,
43 ATS_USER,
Ashay Jaiswal8ae7d562012-04-25 20:55:41 +053044 ATS_SECURE,
Mohit Aggarwal86a2bbd2014-11-21 09:07:41 +053045 ATS_DRM,
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +053046 ATS_RESERVED_2,
47 ATS_RESERVED_3,
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +053048 ATS_GPS,
49 ATS_1X,
Ashay Jaiswal8ae7d562012-04-25 20:55:41 +053050 ATS_RESERVED_4,
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +053051 ATS_WCDMA,
Ashay Jaiswal8ae7d562012-04-25 20:55:41 +053052 ATS_SNTP,
Ashay Jaiswalb69a90b2013-04-09 15:37:15 +053053 ATS_UTC,
Mohit Aggarwal58da2a72013-10-25 11:47:28 +053054 ATS_MODEM,
Ashay Jaiswal8ae7d562012-04-25 20:55:41 +053055 ATS_MFLO,
Mohit Aggarwalbffb7e22016-04-16 19:54:36 +053056 ATS_TOD_MODEM,
Mohit Aggarwal37f3c832016-11-04 18:59:50 +053057 ATS_WLAN,
Mohit Aggarwal77f0a682018-02-21 14:09:03 +053058 ATS_5G,
Mohit Aggarwal43923522020-01-30 14:25:31 +053059 ATS_TOD_GEN,
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +053060 ATS_INVALID
61} time_bases_type;
62
63/* Time unit -- Unit in which time is set/get */
64typedef enum time_unit {
65 TIME_STAMP, /* Not supported */
66 TIME_MSEC,
67 TIME_SECS,
68 TIME_JULIAN,
69 TIME_20MS_FRAME, /* Not supported */
70 TIME_INVALID
71} time_unit_type;
72
73/* Operation to be done */
74typedef enum time_genoff_opr {
75 T_SET,
76 T_GET,
Katish Paran31321e72014-01-30 18:26:04 +053077 T_IS_SET,
Katish Paran51b8dcf2014-03-27 16:09:11 +053078 T_DISABLE,
79 T_ENABLE,
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +053080 T_MAX
81} time_genoff_opr_type;
82
83/* Structure to be passed as argument to time_genoff_operation() */
84/*
85 * In set/get: ts_val should be assigned memory and then passed.
86 * if time_unit = TIME_MSEC, TIME_SECS then ts_val = (uint64_t *)
87 * if time_unit = TIME_JULIAN then ts_val = (struct tm *)
88 */
89typedef struct time_genoff_info {
90 time_bases_type base; /* Genoff in consideration */
91 void *ts_val; /* Time to be set/get */
92 time_unit_type unit; /* Time unit */
93 time_genoff_opr_type operation; /* Time operation to be done */
94}time_genoff_info_type;
95
96/* API to be called for time get/set operation */
97int time_genoff_operation(time_genoff_info_type *pargs);
98
Katish Paran51b8dcf2014-03-27 16:09:11 +053099/* API to be called for logging operations */
100int time_control_operations(time_genoff_info_type *pargs);
101
Mohit Aggarwalba647c82019-10-30 10:49:22 +0530102/* API to be called for getting qtimer based timestamp */
103unsigned long long time_get_from_timetick();
104
Katish Paran1f2db252014-04-03 15:01:44 +0530105#ifdef __cplusplus
106}
107#endif
108
Anirudh Ghayal3f3245b2010-08-05 20:38:03 +0530109#endif /* __TIME_GENOFF_H__ */