Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 1 | /* |
Mohit Aggarwal | 4392352 | 2020-01-30 14:25:31 +0530 | [diff] [blame] | 2 | * Copyright (c) 2010-2014, 2016, 2018-2020 The Linux Foundation. All rights reserved. |
Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 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. |
Duy Truong | 8253366 | 2013-01-17 10:32:03 -0800 | [diff] [blame] | 11 | * * Neither the name of The Linux Foundation nor the names of its contributors |
Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 12 | * 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 Paran | 1f2db25 | 2014-04-03 15:01:44 +0530 | [diff] [blame] | 32 | #ifdef __cplusplus |
| 33 | extern "C" { |
| 34 | #endif |
| 35 | |
Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 36 | /* |
| 37 | * Time genoff base -- To be used by the time setter |
| 38 | * Reserved bases to be supported later. |
| 39 | */ |
| 40 | typedef enum time_bases { |
| 41 | ATS_RTC = 0, |
| 42 | ATS_TOD, |
| 43 | ATS_USER, |
Ashay Jaiswal | 8ae7d56 | 2012-04-25 20:55:41 +0530 | [diff] [blame] | 44 | ATS_SECURE, |
Mohit Aggarwal | 86a2bbd | 2014-11-21 09:07:41 +0530 | [diff] [blame] | 45 | ATS_DRM, |
Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 46 | ATS_RESERVED_2, |
| 47 | ATS_RESERVED_3, |
Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 48 | ATS_GPS, |
| 49 | ATS_1X, |
Ashay Jaiswal | 8ae7d56 | 2012-04-25 20:55:41 +0530 | [diff] [blame] | 50 | ATS_RESERVED_4, |
Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 51 | ATS_WCDMA, |
Ashay Jaiswal | 8ae7d56 | 2012-04-25 20:55:41 +0530 | [diff] [blame] | 52 | ATS_SNTP, |
Ashay Jaiswal | b69a90b | 2013-04-09 15:37:15 +0530 | [diff] [blame] | 53 | ATS_UTC, |
Mohit Aggarwal | 58da2a7 | 2013-10-25 11:47:28 +0530 | [diff] [blame] | 54 | ATS_MODEM, |
Ashay Jaiswal | 8ae7d56 | 2012-04-25 20:55:41 +0530 | [diff] [blame] | 55 | ATS_MFLO, |
Mohit Aggarwal | bffb7e2 | 2016-04-16 19:54:36 +0530 | [diff] [blame] | 56 | ATS_TOD_MODEM, |
Mohit Aggarwal | 37f3c83 | 2016-11-04 18:59:50 +0530 | [diff] [blame] | 57 | ATS_WLAN, |
Mohit Aggarwal | 77f0a68 | 2018-02-21 14:09:03 +0530 | [diff] [blame] | 58 | ATS_5G, |
Mohit Aggarwal | 4392352 | 2020-01-30 14:25:31 +0530 | [diff] [blame] | 59 | ATS_TOD_GEN, |
Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 60 | ATS_INVALID |
| 61 | } time_bases_type; |
| 62 | |
| 63 | /* Time unit -- Unit in which time is set/get */ |
| 64 | typedef 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 */ |
| 74 | typedef enum time_genoff_opr { |
| 75 | T_SET, |
| 76 | T_GET, |
Katish Paran | 31321e7 | 2014-01-30 18:26:04 +0530 | [diff] [blame] | 77 | T_IS_SET, |
Katish Paran | 51b8dcf | 2014-03-27 16:09:11 +0530 | [diff] [blame] | 78 | T_DISABLE, |
| 79 | T_ENABLE, |
Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 80 | 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 | */ |
| 89 | typedef 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 */ |
| 97 | int time_genoff_operation(time_genoff_info_type *pargs); |
| 98 | |
Katish Paran | 51b8dcf | 2014-03-27 16:09:11 +0530 | [diff] [blame] | 99 | /* API to be called for logging operations */ |
| 100 | int time_control_operations(time_genoff_info_type *pargs); |
| 101 | |
Mohit Aggarwal | ba647c8 | 2019-10-30 10:49:22 +0530 | [diff] [blame] | 102 | /* API to be called for getting qtimer based timestamp */ |
| 103 | unsigned long long time_get_from_timetick(); |
| 104 | |
Katish Paran | 1f2db25 | 2014-04-03 15:01:44 +0530 | [diff] [blame] | 105 | #ifdef __cplusplus |
| 106 | } |
| 107 | #endif |
| 108 | |
Anirudh Ghayal | 3f3245b | 2010-08-05 20:38:03 +0530 | [diff] [blame] | 109 | #endif /* __TIME_GENOFF_H__ */ |