blob: 8a04d527074cb1329bfe185ea32c35f51b9988ea [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2001
8*
9*****************************************************************************/
10
11/*****************************************************************************
12 *
13 * Filename:
14 * ---------
15 * dcl_rtc.h
16 *
17 * Project:
18 * --------
19 * Maui
20 *
21 * Description:
22 * ------------
23 * Header file of DCL (Driver Common Layer) for RTC.
24 *
25 * Author:
26 * -------
27 * -------
28 *
29 *============================================================================
30 * HISTORY
31 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
32 *------------------------------------------------------------------------------
33 * removed!
34 * removed!
35 * removed!
36 *
37 * removed!
38 * removed!
39 * removed!
40 *
41 * removed!
42 * removed!
43 * removed!
44 *
45 * removed!
46 * removed!
47 * removed!
48 *
49 * removed!
50 * removed!
51 * removed!
52 *
53 * removed!
54 * removed!
55 * removed!
56 *
57 * removed!
58 * removed!
59 * removed!
60 *
61 * removed!
62 * removed!
63 * removed!
64 *
65 * removed!
66 * removed!
67 * removed!
68 *
69 * removed!
70 * removed!
71 * removed!
72 *
73 * removed!
74 * removed!
75 * removed!
76 *
77 * removed!
78 * removed!
79 * removed!
80 *
81 * removed!
82 * removed!
83 * removed!
84 *
85 * removed!
86 * removed!
87 * removed!
88 *
89 * removed!
90 * removed!
91 * removed!
92 *
93 * removed!
94 * removed!
95 * removed!
96 *
97 * removed!
98 * removed!
99 * removed!
100 *
101 * removed!
102 * removed!
103 * removed!
104 *
105 *------------------------------------------------------------------------------
106 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
107 *============================================================================
108 ****************************************************************************/
109
110#ifdef DCL_DEFINITION_STRUCT
111#ifndef __DCL_RTC_H_STRUCT__
112#define __DCL_RTC_H_STRUCT__
113
114/*******************************************************************************
115 * DCL_OPTIONS for RTC
116 *******************************************************************************/
117#define RTC_OPTIONS
118
119 /*******************************************************************************
120 * DCL_CONFIGURE_T for RTC
121 *******************************************************************************/
122#define RTC_CONFIGS
123
124/*******************************************************************************
125 * DCL_EVENT for RTC
126 *******************************************************************************/
127#define RTC_EVENTS \
128 EVENT_RTC_ALARM = 0x00000001,\
129 EVENT_RTC_TC = 0x00000002,
130
131/*******************************************************************************
132 * DCL_CTRL_CMD for RTC
133 *******************************************************************************/
134#ifdef __BUILD_DOM__
135/* The RTC Command Values in DCL_CTRL_CMD_T Enum of dcl.h */
136typedef enum {
137 RTC_CMD_BOOTLOADER_POWERON, /* For RTC Bootloader Power On */
138 RTC_CMD_CLEAR_PDN_BITS, /* To Clear RTC PDN Bits */
139 RTC_CMD_CONFIG_AL_TC, /* To Configure the RTC Interrupt */
140 RTC_CMD_DELAY, /* To Delay */
141 RTC_CMD_FT_POWEROFF, /* For Flash Tool Power Off */
142 RTC_CMD_GET_ALARM_TIME, /* To Get Alarm Time */
143 RTC_CMD_GET_TIME, /* To Get Time*/
144 RTC_CMD_GPIO_GET_INPUT, /* To Get GPIO Input */
145 RTC_CMD_GPIO_SET_EXPORT_32K, /* To Set Export 32K for GPIO */
146 RTC_CMD_GPIO_SET_EXPORT_COREDETB, /* To Set Export COREDETB for GPIO */
147 RTC_CMD_GPIO_SET_INPUT_MODE, /* To Set GPIO Input Mode */
148 RTC_CMD_GPIO_SET_OUTPUT_MODE, /* To Set GPIO Output Mode */
149 RTC_CMD_HW_INIT, /* To Initialize RTC HW */
150 RTC_CMD_INIT, /* To Initialize RTC SW */
151 RTC_CMD_INIT_TC_AL_INTR, /* To Initialize RTC SW (RTC_TCintr,RTC_ALintr) */
152 RTC_CMD_IS_CONFIG_VALID, /* To Check If RTC Configure Valid or Not */
153 RTC_CMD_IS_FIRST_ON, /* To Check If RTC Is First On or Not */
154 RTC_CMD_IS_MS_FIRSTPOWERON, /* To Check If RTC Is First On or Not (for MMI Only) */
155 RTC_CMD_IS_TIME_VALID, /* To Check If RTC Time Is Valid or Not */
156 RTC_CMD_PWIC_CHECK_POWERON, /* To Check RTC Power On (for PWIC Only) */
157 RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME, /* To Initialize RTC Time When First Power On (for PWIC Only) */
158 RTC_CMD_PWIC_MASK_AL, /* To Diable All Alarm Mask (for PWIC Only) */
159 RTC_CMD_PWIC_POWEROFF_RTC_INIT, /* To Do RTC Initalize When Power Off (for PWIC Only) */
160 RTC_CMD_PWIC_POWERON_RTC_INIT, /* To Do RTC Initalize When Power On (for PWIC Only) */
161 RTC_CMD_READ_PDN_BITS, /* To Read RTC PDN Bits */
162 RTC_CMD_READ_SPAR, /* To Read SPAR Register */
163 RTC_CMD_READ_XOSC_REG, /* To Read RTC XOSC Register */
164 RTC_CMD_RELOAD, /* To Do RTC Reload */
165 RTC_CMD_SET_ALARM_TIME, /* To Set Alarm Time */
166 RTC_CMD_SET_FIRST_POWERON, /* To Set First Power On */
167 RTC_CMD_SET_PDN_BITS, /* To Set RTC PDN Bits */
168 RTC_CMD_SET_PWR_KEY, /* To Set Power Key */
169 RTC_CMD_SET_TIME, /* To Set Time */
170 RTC_CMD_SETBBPU, /* To Set BBPU */
171 RTC_CMD_SETXOSC, /* To Set XOSC */
172 RTC_CMD_START_CALI, /* To Start Calibration */
173 RTC_CMD_WAIT_DEBOUNCE, /* To Wait De-bounce */
174 RTC_CMD_WRITE_PDN_BITS, /* To Write RTC PDN Bits */
175 RTC_CMD_WRITE_SPAR, /* To Write SPAR Register */
176 RTC_CMD_WRITE_TRIGGER, /* To Set Write Trigger */
177 RTC_CMD_WRITE_TRIGGER_WAIT, /* To Set Write Trigger And Wait */
178 RTC_CMD_WRITE_XOSC_REG, /* To Write RTC XOSC Register */
179 RTC_CMD_PROT_UNLOCK, /* To Unlock RTC PROT */
180 RTC_CMD_REGISTER_MODULE_TO_SEND_RTCTIME, /* To register ilm infomation by other modules to request RTC time */
181 RTC_CMD_WRITE_OSC32CON_REG, /* To Write RTC OSC32CON Register */
182} DCL_CTRL_CMD_T;
183#else /* __BUILD_DOM__ */
184#define RTC_CMDS \
185 RTC_CMD_BOOTLOADER_POWERON, \
186 RTC_CMD_CLEAR_PDN_BITS, \
187 RTC_CMD_CONFIG_AL_TC, \
188 RTC_CMD_DELAY, \
189 RTC_CMD_FT_POWEROFF, \
190 RTC_CMD_GET_ALARM_TIME, \
191 RTC_CMD_GET_TIME, \
192 RTC_CMD_GPIO_GET_INPUT, \
193 RTC_CMD_GPIO_SET_EXPORT_32K, \
194 RTC_CMD_GPIO_SET_EXPORT_COREDETB, \
195 RTC_CMD_GPIO_SET_INPUT_MODE, \
196 RTC_CMD_GPIO_SET_OUTPUT_MODE, \
197 RTC_CMD_HW_INIT, \
198 RTC_CMD_INIT, \
199 RTC_CMD_INIT_TC_AL_INTR, \
200 RTC_CMD_IS_CONFIG_VALID,\
201 RTC_CMD_IS_FIRST_ON, \
202 RTC_CMD_IS_MS_FIRSTPOWERON, \
203 RTC_CMD_IS_TIME_VALID, \
204 RTC_CMD_PWIC_CHECK_POWERON, \
205 RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME, \
206 RTC_CMD_PWIC_MASK_AL, \
207 RTC_CMD_PWIC_POWEROFF_RTC_INIT, \
208 RTC_CMD_PWIC_POWERON_RTC_INIT, \
209 RTC_CMD_READ_PDN_BITS, \
210 RTC_CMD_READ_SPAR, \
211 RTC_CMD_READ_XOSC_REG, \
212 RTC_CMD_RELOAD, \
213 RTC_CMD_SET_ALARM_TIME, \
214 RTC_CMD_SET_FIRST_POWERON, \
215 RTC_CMD_SET_PDN_BITS, \
216 RTC_CMD_SET_PWR_KEY, \
217 RTC_CMD_SET_TIME, \
218 RTC_CMD_SETBBPU, \
219 RTC_CMD_SETXOSC, \
220 RTC_CMD_START_CALI, \
221 RTC_CMD_WAIT_DEBOUNCE, \
222 RTC_CMD_WRITE_PDN_BITS, \
223 RTC_CMD_WRITE_SPAR, \
224 RTC_CMD_WRITE_TRIGGER, \
225 RTC_CMD_WRITE_TRIGGER_WAIT, \
226 RTC_CMD_WRITE_XOSC_REG, \
227 RTC_CMD_PROT_UNLOCK, \
228 RTC_CMD_REGISTER_MODULE_TO_SEND_RTCTIME, \
229 RTC_CMD_WRITE_OSC32CON_REG,
230#endif /* __BUILD_DOM__ */
231
232/*******************************************************************************
233 * Define the Data and Time Interrupt Control Bit
234 *******************************************************************************/
235
236/* Y:Year, M:Month, W:DOW, D:DOM, H:Hour, M:Min, S:SEC */
237
238/* Alarm Enable None */
239#define AL_EN_None 0
240/* Alarm Enable Check Sec */
241#define AL_EN_ChkS 1
242/* Alarm Enable Check Min & Sec */
243#define AL_EN_ChkMS 2
244/* Alarm Enable Check Hour, Min & Sec */
245#define AL_EN_ChkHMS 3
246/* Alarm Enable Check DOM, Hour, Min & Sec */
247#define AL_EN_ChkDHMS 4
248/* Alarm Enable Check DOW, Hour, Min & Sec */
249#define AL_EN_ChkWHMS 5
250/* Alarm Enable Check Month, DOM, Hour, Min & Sec */
251#define AL_EN_ChkMDHMS 6
252/* Alarm Enable Check Year, Month, DOM, Hour, Min & Sec */
253#define AL_EN_ChkYMDHMS 7
254/* Alarm Enable No Change */
255#define AL_EN_NoChange 8
256
257/* Time Counter Enable None */
258#define TC_EN_None 0
259/* Time Counter Enable Check Sec */
260#define TC_EN_ChkS 1
261/* Time Counter Enable Check Min & Sec */
262#define TC_EN_ChkM 2
263/* Time Counter Enable Check Hour, Min & Sec */
264#define TC_EN_ChkH 3
265/* Time Counter Enable Check DOM, Hour, Min & Sec */
266#define TC_EN_ChkD 4
267/* Time Counter Enable Check DOW, Hour, Min & Sec */
268#define TC_EN_ChkW 5
269/* Time Counter Enable Check Month, DOM, Hour, Min & Sec */
270#define TC_EN_ChkMon 6
271/* Time Counter Enable Check Year, Month, DOM, Hour, Min & Sec */
272#define TC_EN_ChkY 7
273/* Time Counter Enable No Change */
274#define TC_EN_NoChange 8
275
276/*******************************************************************************
277 * RTC PDN Bits Definitions
278 *******************************************************************************/
279
280/* PDN 1 Bit[7], META Reset RTC */
281#define DRV_COMM_REG1_META_RESET_RTC 0x0080
282/* PDN 2 Bit[7], Normal Reset */
283#define DRV_COMM_REG2_NORMAL_RESET 0x0080
284/* PDN 2 Bit[6], Charge Power On */
285#define DRV_COMM_REG2_CHRPWRON 0x0040
286/* PDN 2 Bit[5], USB Mass Storage Power On */
287#define DRV_COMM_REG2_USBMS_PWRON 0x0020
288/* PDN 2 Bit[4], RTC Power On */
289#define DRV_COMM_REG2_RTCPWRON 0x0010
290/* PDN 2 Bit[3], USB Mass Storage Power Off */
291#define DRV_COMM_REG2_USBMS_PWROFF 0x0008
292/* PDN 2 Bit[2], RTC NVRAM Valid */
293#define DRV_COMM_REG2_RTC_NVRAM 0x0004
294/* PDN 2 Bit[1], Swich To IDLE Power On */
295#define DRV_COMM_REG2_SWITCH2IDLE_PWRON 0x0002
296/* PDN 2 Bit[0], BTMT Watchdog Reset Power On */
297#define DRV_COMM_REG2_BTMT_WDTRET_PWRON 0x0001
298
299/* Reserved for bootrom security, support it after 6227 */
300#if defined(DRV_RTC_COMM_REG1_SECURITY)
301/* Bootrom Security 1 */
302#define DRV_COMM_REG1_BOOTROM_SECURITY1 0x0001
303/* Bootrom Security 2 */
304#define DRV_COMM_REG1_BOOTROM_SECURITY2 0x0010
305/* Bootrom Security 3 */
306#define DRV_COMM_REG1_BOOTROM_SECURITY3 0x0020
307/* Bootrom Security 4 */
308#define DRV_COMM_REG1_BOOTROM_SECURITY4 0x0040
309#endif
310
311/* RTC PDN1, use RTC INFO1 as DRV_COMM_REG1 */
312#define DRV_COMM_REG1 (RTC_base+0x0058)
313/* RTC PDN1, use RTC INFO2 as DRV_COMM_REG2 */
314#define DRV_COMM_REG2 (RTC_base+0x005c)
315
316/*******************************************************************************
317 * DCL_CTRL_DATA_T: Define the Control data structure for each module's command
318 *******************************************************************************/
319
320/* RTC Data Stucture for Save Information Only (Cannot be used for function's parameter) */
321typedef struct
322{
323 DCL_UINT8 rtc_sec; /* Seconds after the minute - [0,59] */
324 DCL_UINT8 rtc_min; /* Minutes after the hour - [0,59] */
325 DCL_UINT8 rtc_hour; /* Hours after the midnight - [0,23] */
326 DCL_UINT8 rtc_day; /* Day of the month - [1,31] */
327 DCL_UINT8 rtc_mon; /* Months - [1,12] */
328 DCL_UINT8 rtc_wday; /* Days in a week - [1,7] */
329 DCL_UINT8 rtc_year; /* Years - [0,127] */
330}DCL_RTC_DATA_T;
331
332/* For RTC_CMD_BOOTLOADER_POWERON command. */
333typedef struct
334{
335 DCL_BOOLEAN fgBootloaderPowerOn; /* Output : TRUE: Indicate Device Is First On; FALSE: Device Is Not First On */
336}RTC_CTRL_BOOTLOADER_POWERON_T;
337
338/* Enum of PDN Registers */
339typedef enum
340{
341 DCL_RTC_PDN1 = 0, /* PDN1 */
342 DCL_RTC_PDN2, /* PDN2 */
343 DCL_RTC_MAX_INDEX /* Maximum PDN Register */
344}DCL_RTC_PDN_INDEX_T;
345
346/* For RTC_CMD_CLEAR_PDN_BITS, RTC_CMD_READ_PDN_BITS, RTC_CMD_SET_PDN_BITS, RTC_CMD_WRITE_PDN_BITS commands. */
347typedef struct
348{
349 DCL_RTC_PDN_INDEX_T PDNIndex; /* Input : Number of PDN Register */
350 DCL_UINT16 fgConfigBit; /* Input : PDN Bit for Configuration */
351 DCL_UINT16 PDNValue; /* Output : Value of PDN Register */
352}RTC_CTRL_CONFIG_PDN_BIT_T;
353
354/* For RTC_CMD_CONFIG_AL_TC command. */
355typedef struct
356{
357 DCL_UINT8 u1ALEn; /* Input : Alarm Enable */
358 DCL_UINT8 u1TCEn; /* Input : Time Counter Enable */
359}RTC_CTRL_CONFIG_AL_TC_T;
360
361/* For RTC_CMD_DELAY command. */
362// RTC_CMD_DELAY does NOT need parameters
363
364/* For RTC_CMD_FT_POWEROFF command. */
365typedef struct
366{
367 DCL_BOOLEAN fgMetaReset; /* Output : If DRV_COMM_REG1_META_RESET_RTC set or not*/
368}RTC_CTRL_FT_POWEROFF_T;
369
370/* For RTC_CMD_GET_ALARM_TIME command. */
371typedef struct
372{
373 DCL_UINT8 u1Sec; /* Output : Seconds after the minute - [0,59] */
374 DCL_UINT8 u1Min; /* Output : Minutes after the hour - [0,59] */
375 DCL_UINT8 u1Hour; /* Output : Hours after the midnight - [0,23] */
376 DCL_UINT8 u1Day; /* Output : Day of the month - [1,31] */
377 DCL_UINT8 u1Mon; /* Output : Months - [1,12] */
378 DCL_UINT8 u1WDay; /* Output : Days in a week - [1,7] */
379 DCL_UINT8 u1Year; /* Output : Years - [0,127] */
380 DCL_BOOLEAN ALEnBit; /* Output : The status of AL enable bit of RTC_IRQ_EN */
381}RTC_CTRL_GET_ALARM_TIME_T;
382
383/* For RTC_CMD_GET_TIME command. */
384typedef struct
385{
386 DCL_UINT8 u1Sec; /* Output : Seconds after the minute - [0,59] */
387 DCL_UINT8 u1Min; /* Output : Minutes after the hour - [0,59] */
388 DCL_UINT8 u1Hour; /* Output : Hours after the midnight - [0,23] */
389 DCL_UINT8 u1Day; /* Output : Day of the month - [1,31] */
390 DCL_UINT8 u1Mon; /* Output : Months - [1,12] */
391 DCL_UINT8 u1WDay; /* Output : Days in a week - [1,7] */
392 DCL_UINT8 u1Year; /* Output : Years - [0,127] */
393}RTC_CTRL_GET_TIME_T;
394
395/* For RTC GPIO Pulling Type */
396typedef enum {
397 DCL_RTC_GPIO_NO_PULL = 0, /* No Pull */
398 DCL_RTC_GPIO_PULL_DOWN, /* Pull Down */
399 DCL_RTC_GPIO_PULL_UP /* Pull Up */
400}DCL_RTC_GPIO_PULL_TYPE_T;
401
402/* For RTC GPIO Driving Strength */
403typedef enum {
404 DCL_RTC_GPIO_DS_4mA = 0, /* 4mA */
405 DCL_RTC_GPIO_DS_8mA, /* 8mA */
406 DCL_RTC_GPIO_DS_12mA, /* 12mA */
407 DCL_RTC_GPIO_DS_16mA /* 16mA */
408}DCL_RTC_GPIO_DRIVING_STRENGTH_T;
409
410/* For RTC_CMD_GPIO_CONFIG_MODE command. */
411typedef struct
412{
413 DCL_RTC_GPIO_PULL_TYPE_T rPullType; /* Input : Pull Type */
414 DCL_RTC_GPIO_DRIVING_STRENGTH_T rPullStrength; /* Input : Drving Strength */
415 DCL_BOOLEAN InputValue; /* Output : Value of GPIO Input */
416 DCL_BOOLEAN OutputValue; /* Input : Value of GPIO Output */
417 DCL_BOOLEAN is_SmithTrigger; /* Input : Is Smith Triggter Or Not */
418 DCL_BOOLEAN is_SlewRateControl; /* Input : Is Slew Rate Control Or Not */
419}RTC_CTRL_GPIO_TIME_T;
420
421/* For RTC_CMD_HW_INIT command. */
422// RTC_CMD_HW_INIT does NOT need parameters
423
424/* For RTC_CMD_INIT command. */
425typedef struct
426{
427 void (*RTC_TCCallback)(void); /* Input : Callback Function for Timer Count */
428 void (*RTC_ALCallback)(void); /* Input : Callback Function for Alarm */
429}RTC_CTRL_INIT_T;
430
431/* For RTC_CMD_INIT_TC_AL_INTR command. */
432// RTC_CMD_INIT_TC_AL_INTR does NOT need parameters
433
434/* For RTC_CMD_IS_CONFIG_VALID command. */
435typedef struct
436{
437 DCL_BOOLEAN fgIsValid; /* Output : RTC Config Is Valid Or Not */
438}RTC_CTRL_IS_CONFIG_VALID_T;
439
440/* For RTC_CMD_IS_FIRST_ON command. */
441typedef struct
442{
443 DCL_BOOLEAN fgFirstOn; /* Output : TRUE: Indicate Device Is First On; FALSE: Device Is Not First On */
444}RTC_CTRL_IS_FIRST_ON_T;
445
446/* For RTC_CMD_IS_MS_FIRSTPOWERON command. */
447typedef struct
448{
449 DCL_BOOLEAN fgMSFirstPowerOn; /* Output : TRUE: Indicate Device Is First On; FALSE: Device Is Not First On */
450}RTC_CTRL_IS_MS_FIRSTPOWERON_T;
451
452/* For RTC_CMD_IS_TIME_VALID command. */
453typedef struct
454{
455 DCL_UINT8 u1Sec; /* Input : Seconds after the minute - [0,59] */
456 DCL_UINT8 u1Min; /* Input : Minutes after the hour - [0,59] */
457 DCL_UINT8 u1Hour; /* Input : Hours after the midnight - [0,23] */
458 DCL_UINT8 u1Day; /* Input : Day of the month - [1,31] */
459 DCL_UINT8 u1Mon; /* Input : Months - [1,12] */
460 DCL_UINT8 u1WDay; /* Input : Days in a week - [1,7] */
461 DCL_UINT8 u1Year; /* Input : Years - [0,127] */
462 DCL_BOOLEAN isTimeValid; /* Output: If time is valid */
463}RTC_CTRL_IS_TIME_VALID_T;
464
465/* For RTC_CMD_PWIC_CHECK_POWERON command. */
466typedef struct
467{
468 DCL_BOOLEAN fgIsPowerOn; /* Output : If Power On Or Not */
469}RTC_CTRL_PWIC_CHECK_POWERON_T;
470
471/* For RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME command. */
472typedef struct
473{
474 DCL_UINT8 u1Sec; /* Input : Seconds after the minute - [0,59] */
475 DCL_UINT8 u1Min; /* Input : Minutes after the hour - [0,59] */
476 DCL_UINT8 u1Hour; /* Input : Hours after the midnight - [0,23] */
477 DCL_UINT8 u1Day; /* Input : Day of the month - [1,31] */
478 DCL_UINT8 u1Mon; /* Input : Months - [1,12] */
479 DCL_UINT8 u1WDay; /* Input : Days in a week - [1,7] */
480 DCL_UINT8 u1Year; /* Input : Years - [0,127] */
481}RTC_CTRL_PWIC_FIRST_POWERON_INIT_RTCTIME_T;
482
483/* For RTC_CMD_PWIC_MASK_AL command. */
484// RTC_CMD_PWIC_MASK_AL does NOT need parameters
485
486/* For RTC_CMD_PWIC_POWEROFF_RTC_INIT command. */
487// RTC_CMD_PWIC_POWEROFF_RTC_INIT does NOT need parameters
488
489/* For RTC_CMD_PWIC_POWERON_RTC_INIT command. */
490// RTC_CMD_PWIC_POWERON_RTC_INIT does NOT need parameters
491
492/* Enum of SPAR Registers */
493typedef enum
494{
495 DCL_RTC_SPAR0 = 0, /* SPAR0 */
496 DCL_RTC_SPAR1, /* SPAR1 */
497 DCL_RTC_SPAR_MAX_INDEX /* Maximum SPAR Register */
498}DCL_RTC_SPAR_INDEX_T;
499
500/* For RTC_CMD_READ_SPAR, RTC_CMD_WRITE_SPAR commands. */
501typedef struct
502{
503 DCL_RTC_SPAR_INDEX_T SPARIndex; /* Input : Number of SPAR Register */
504 DCL_UINT16 WriteValue; /* Input : Value of SPAR for Configuration */
505 DCL_UINT16 ReadValue; /* Output : Value of SPAR Register */
506}RTC_CTRL_CONFIG_SPAR_T;
507
508/* For RTC_CMD_READ_XOSC_REG command. */
509typedef struct
510{
511 DCL_UINT8 XOSCValue; /* Output : The Result of XOSCCALI */
512}RTC_CTRL_READ_XOSC_REG_T;
513
514/* For RTC_CMD_RELOAD command. */
515// RTC_CMD_RELOAD does NOT need parameters
516
517/* For RTC_CMD_SET_ALARM_TIME command. */
518typedef struct
519{
520 DCL_UINT8 u1Sec; /* Input : Seconds after the minute - [0,59] */
521 DCL_UINT8 u1Min; /* Input : Minutes after the hour - [0,59] */
522 DCL_UINT8 u1Hour; /* Input : Hours after the midnight - [0,23] */
523 DCL_UINT8 u1Day; /* Input : Day of the month - [1,31] */
524 DCL_UINT8 u1Mon; /* Input : Months - [1,12] */
525 DCL_UINT8 u1WDay; /* Input : Days in a week - [1,7] */
526 DCL_UINT8 u1Year; /* Input : Years - [0,127] */
527}RTC_CTRL_SET_ALARM_TIME_T;
528
529/* For RTC_CMD_SET_FIRST_POWERON command. */
530typedef struct
531{
532 DCL_BOOLEAN fgPowerOn; /* Input : Set First Power On */
533}RTC_CTRL_SET_FIRST_POWERON_T;
534
535/* For RTC_CMD_SET_PWR_KEY command. */
536// RTC_CMD_SET_PWR_KEY does NOT need parameters
537
538/* For RTC_CMD_SET_TIME command. */
539typedef struct
540{
541 DCL_UINT8 u1Sec; /* Input : Seconds after the minute - [0,59] */
542 DCL_UINT8 u1Min; /* Input : Minutes after the hour - [0,59] */
543 DCL_UINT8 u1Hour; /* Input : Hours after the midnight - [0,23] */
544 DCL_UINT8 u1Day; /* Input : Day of the month - [1,31] */
545 DCL_UINT8 u1Mon; /* Input : Months - [1,12] */
546 DCL_UINT8 u1WDay; /* Input : Days in a week - [1,7] */
547 DCL_UINT8 u1Year; /* Input : Years - [0,127] */
548}RTC_CTRL_SET_TIME_T;
549
550/* For RTC_CMD_SETBBPU command. */
551typedef struct
552{
553 DCL_UINT16 BBPUReg; /* Input : Set BBPU Register */
554}RTC_CTRL_SETBBPU_T;
555
556/* For RTC_CMD_SETXOSC command. */
557// RTC_CMD_SETXOSC does NOT need parameters
558
559/* For RTC_CMD_START_CALI command. */
560// RTC_CMD_START_CALI does NOT need parameters
561
562/* For RTC_CMD_WAIT_DEBOUNCE command. */
563// RTC_CMD_WAIT_DEBOUNCE does NOT need parameters
564
565/* For RTC_CMD_WRITE_TRIGGER command. */
566// RTC_CMD_WRITE_TRIGGER does NOT need parameters
567
568/* For RTC_CMD_WRITE_TRIGGER_WAIT command. */
569// RTC_CMD_WRITE_TRIGGER_WAIT does NOT need parameters
570
571/* For RTC_CMD_WRITE_XOSC_REG command. */
572typedef struct
573{
574 DCL_UINT8 XOSC_Reg; /* Input : Set XOSCCALI Register */
575}RTC_CTRL_WRITE_XOSC_REG_T;
576
577typedef struct
578{
579 DCL_UINT32 dest_mod_id;
580 DCL_UINT32 sap_id;
581 DCL_UINT32 msg_id;
582 DCL_BOOLEAN fgRegisterILM;
583}RTC_CTRL_REGISTER_MODULE_ILM_INFO_T;
584
585/* For RTC_CMD_WRITE_XOSC_REG command. */
586typedef struct
587{
588 DCL_UINT16 OSC32CON_Reg; /* Input : Set XOSCCALI Register */
589}RTC_CTRL_WRITE_OSC32CON_REG_T;
590
591#ifdef __BUILD_DOM__
592/* The RTC Command Parameter Data Structure for Each Command in DCL_CTRL_DATA_T Enum of dcl.h */
593typedef struct
594{
595 RTC_CTRL_BOOTLOADER_POWERON_T rBootloaderPowerOn; /* Data Structure for RTC_CMD_BOOTLOADER_POWERON */
596 RTC_CTRL_CONFIG_AL_TC_T rConfigALTC; /* Data Structure for RTC_CMD_CONFIG_AL_TC */
597 RTC_CTRL_CONFIG_PDN_BIT_T rConfigPDNBit; /* Data Structure for RTC_CMD_CLEAR_PDN_BITS, RTC_CMD_READ_PDN_BITS, RTC_CMD_SET_PDN_BITS, and RTC_CMD_WRITE_PDN_BITS */
598 RTC_CTRL_FT_POWEROFF_T rFTPowerOff; /* Data Structure for RTC_CMD_FT_POWEROFF */
599 RTC_CTRL_GET_ALARM_TIME_T rGetAlarmTime; /* Data Structure for RTC_CMD_GET_ALARM_TIME */
600 RTC_CTRL_GET_TIME_T rGetTime; /* Data Structure for RTC_CMD_GET_TIME */
601 RTC_CTRL_GPIO_TIME_T rGPIO; /* Data Structure for RTC_CMD_GPIO_GET_INPUT, RTC_CMD_GPIO_SET_INPUT_MODE, and RTC_CMD_GPIO_SET_OUTPUT_MODE */
602 RTC_CTRL_INIT_T rInit; /* Data Structure for RTC_CMD_INIT */
603 RTC_CTRL_IS_CONFIG_VALID_T rIsConfigValid; /* Data Structure for RTC_CMD_IS_CONFIG_VALID */
604 RTC_CTRL_IS_FIRST_ON_T rIsFirstOn; /* Data Structure for RTC_CMD_IS_FIRST_ON */
605 RTC_CTRL_IS_MS_FIRSTPOWERON_T rIsMSFirstPowerOn; /* Data Structure for RTC_CMD_IS_MS_FIRSTPOWERON */
606 RTC_CTRL_IS_TIME_VALID_T rIsTimeValid; /* Data Structure for RTC_CMD_IS_TIME_VALID */
607 RTC_CTRL_PWIC_CHECK_POWERON_T rPwicCheckPowerOn; /* Data Structure for RTC_CMD_PWIC_CHECK_POWERON */
608 RTC_CTRL_PWIC_FIRST_POWERON_INIT_RTCTIME_T rPwicFirstPowerOnInitRTCTime; /* Data Structure for RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME */
609 RTC_CTRL_CONFIG_SPAR_T rConfigSPARReg; /* Data Structure for RTC_CMD_READ_SPAR, and RTC_CMD_WRITE_SPAR */
610 RTC_CTRL_READ_XOSC_REG_T rReadXOSCReg; /* Data Structure for RTC_CMD_READ_XOSC_REG */
611 RTC_CTRL_SET_ALARM_TIME_T rSetAlarmTime; /* Data Structure for RTC_CMD_SET_ALARM_TIME */
612 RTC_CTRL_SET_FIRST_POWERON_T rSetFirstPowerOn; /* Data Structure for RTC_CMD_SET_FIRST_POWERON */
613 RTC_CTRL_SET_TIME_T rSetTime; /* Data Structure for RTC_CMD_SET_TIME */
614 RTC_CTRL_SETBBPU_T rSetBBPU; /* Data Structure for RTC_CMD_SETBBPU */
615 RTC_CTRL_WRITE_XOSC_REG_T rWriteXOSCRef; /* Data Structure for RTC_CMD_WRITE_XOSC_REG */
616 RTC_CTRL_REGISTER_MODULE_ILM_INFO_T rRegisterModILMInfo; /* Data Structure for ilm to send to other modules */
617 RTC_CTRL_WRITE_OSC32CON_REG_T rWriteOSC32CONReg; /* Data Structure for RTC_CMD_REGISTER_MODULE_TO_SEND_RTCTIME */
618}DCL_CTRL_DATA_T;
619#else /* __BUILD_DOM__ */
620
621#define RTC_CTRLS \
622 RTC_CTRL_BOOTLOADER_POWERON_T rBootloaderPowerOn; \
623 RTC_CTRL_CONFIG_AL_TC_T rConfigALTC; \
624 RTC_CTRL_CONFIG_PDN_BIT_T rConfigPDNBit; \
625 RTC_CTRL_FT_POWEROFF_T rFTPowerOff; \
626 RTC_CTRL_GET_ALARM_TIME_T rGetAlarmTime; \
627 RTC_CTRL_GET_TIME_T rGetTime; \
628 RTC_CTRL_GPIO_TIME_T rGPIO; \
629 RTC_CTRL_INIT_T rInit; \
630 RTC_CTRL_IS_CONFIG_VALID_T rIsConfigValid; \
631 RTC_CTRL_IS_FIRST_ON_T rIsFirstOn; \
632 RTC_CTRL_IS_MS_FIRSTPOWERON_T rIsMSFirstPowerOn; \
633 RTC_CTRL_IS_TIME_VALID_T rIsTimeValid; \
634 RTC_CTRL_PWIC_CHECK_POWERON_T rPwicCheckPowerOn; \
635 RTC_CTRL_PWIC_FIRST_POWERON_INIT_RTCTIME_T rPwicFirstPowerOnInitRTCTime; \
636 RTC_CTRL_CONFIG_SPAR_T rConfigSPARReg; \
637 RTC_CTRL_READ_XOSC_REG_T rReadXOSCReg; \
638 RTC_CTRL_SET_ALARM_TIME_T rSetAlarmTime; \
639 RTC_CTRL_SET_FIRST_POWERON_T rSetFirstPowerOn; \
640 RTC_CTRL_SET_TIME_T rSetTime; \
641 RTC_CTRL_SETBBPU_T rSetBBPU; \
642 RTC_CTRL_WRITE_XOSC_REG_T rWriteXOSCRef; \
643 RTC_CTRL_REGISTER_MODULE_ILM_INFO_T rRegisterModILMInfo; \
644 RTC_CTRL_WRITE_OSC32CON_REG_T rWriteOSC32CONReg;
645
646#endif /* __BUILD_DOM__ */
647
648#endif // #ifndef __DCL_RTC_H_STRUCT__
649#endif // #ifdef DCL_DEFINITION_STRUCT
650
651
652#ifdef DCL_DEFINITION_PROTOTYPE
653#ifndef __DCL_RTC_H_PROTOTYPE__
654#define __DCL_RTC_H_PROTOTYPE__
655
656/*************************************************************************
657* FUNCTION
658* DclRTC_Initialize
659*
660* DESCRIPTION
661* This function is to initialize RTC module
662*
663* PARAMETERS
664* None
665*
666* RETURNS
667* Return the status of DclRTC_Initialize
668*
669* RETURN VALUES
670* STATUS_OK: Initialize Finished
671*
672*************************************************************************/
673extern DCL_STATUS DclRTC_Initialize(void);
674/*************************************************************************
675* FUNCTION
676* DclRTC_Open
677*
678* DESCRIPTION
679* This function is to open the RTC module and return a handle
680*
681* PARAMETERS
682* dev: [IN] Only valid for DCL_RTC
683* flags: [IN] No sepcial flags is needed. Please use FLAGS_NONE
684*
685* RETURNS
686* Return DCL_HANDLE of RTC
687*
688* RETURN VALUES
689* DCL_HANDLE_INVALID : Open failed
690* Other value : A valid handle
691*
692*************************************************************************/
693extern DCL_HANDLE DclRTC_Open(DCL_DEV dev, DCL_FLAGS flags);
694/*************************************************************************
695* FUNCTION
696* DclRTC_ReadData
697*
698* DESCRIPTION
699* This function is not supported for the RTC module now.
700*
701* PARAMETERS
702* N/A
703*
704* RETURNS
705* STATUS_UNSUPPORTED
706*
707*************************************************************************/
708extern DCL_STATUS DclRTC_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options);
709/*************************************************************************
710* FUNCTION
711* DclRTC_WriteData
712*
713* DESCRIPTION
714* This function is not supported for the RTC module now.
715*
716* PARAMETERS
717* N/A
718*
719* RETURNS
720* STATUS_UNSUPPORTED
721*
722*************************************************************************/
723extern DCL_STATUS DclRTC_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options);
724/*************************************************************************
725* FUNCTION
726* DclRTC_Configure
727*
728* DESCRIPTION
729* This function is not supported for the RTC module now.
730*
731* PARAMETERS
732* N/A
733*
734* RETURNS
735* STATUS_UNSUPPORTED
736*
737*************************************************************************/
738extern DCL_STATUS DclRTC_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
739/*************************************************************************
740* FUNCTION
741* DclRTC_RegisterCallback
742*
743* DESCRIPTION
744* This function is to set callback function for the RTC module.
745*
746* PARAMETERS
747* handle: [IN] The returned handle value of DclRTC_Open
748* event: [IN] Supported events:
749* 1.EVENT_RTC_ALARM: RTC alarm interrupt
750* 2.EVENT_RTC_TC: RTC tick interrupt
751* callback: [IN] the callback function for registered events
752*
753* RETURNS
754* Return the status of DclRTC_RegisterCallback
755*
756* RETURN VALUES
757* STATUS_OK: Successfully register the callback function.
758* STATUS_INVALID_DCL_HANDLE: It's a invalid handle.
759* STATUS_NOT_OPENED: The module has not been opened.
760* STATUS_INVALID_EVENT: The event parameter is invalid.
761*
762*************************************************************************/
763extern DCL_STATUS DclRTC_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback);
764/*************************************************************************
765* FUNCTION
766* DclRTC_Control
767*
768* DESCRIPTION
769* This function is to send command to control the RTC module.
770*
771* PARAMETERS
772* handle: [IN] The handle value returned from DclRTC_Open
773* cmd: [IN] A control command for RTC module
774* 1. RTC_CMD_BOOTLOADER_POWERON: to check RTC Power On in bootloader
775* 2. RTC_CMD_CLEAR_PDN_BITS: to clear RTC PDN bits
776* 3. RTC_CMD_CONFIG_AL_TC: to set alarm mask and tick mask
777* 4. RTC_CMD_DELAY: to Delay 2000 counts
778* 5. RTC_CMD_FT_POWEROFF: to Power Off for FlashTool
779* 6. RTC_CMD_GET_ALARM_TIME: to get alarm time
780* 7. RTC_CMD_GET_TIME: to get time
781* 8. RTC_CMD_GPIO_GET_INPUT: to get RTC_GPIO_GPI register value
782* 9. RTC_CMD_GPIO_SET_EXPORT_32K: to export 32.768KHz clock on RTC_GPIO
783* 10. RTC_CMD_GPIO_SET_EXPORT_COREDETB: to export COREDETB on RTC_GPIO
784* 11. RTC_CMD_GPIO_SET_INPUT_MODE: to set RTC_GPIO input mode
785* 12. RTC_CMD_GPIO_SET_OUTPUT_MODE: to set RTC_GPIO output mode
786* 13. RTC_CMD_HW_INIT: to initialize RTC hardware
787* 14. RTC_CMD_INIT: to initialize RTC software
788* 15. RTC_CMD_INIT_TC_AL_INTR: to initialize RTC TC & AL INTR
789* 16. RTC_CMD_IS_CONFIG_VALID: to check if RTC time and Alarm are valid
790* 17. RTC_CMD_IS_FIRST_ON: to check if device is first on
791* 18. RTC_CMD_IS_MS_FIRSTPOWERON: to check whether RTC is first power on(for MMI)
792* 19. RTC_CMD_IS_TIME_VALID: to check if time are valid
793* 20. RTC_CMD_PWIC_CHECK_POWERON: to check if power on (for PWIC)
794* 21. RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME: to init RTC time at first power on (for PWIC)
795* 22. RTC_CMD_PWIC_MASK_AL: to control RTC Alarm mask (for PWIC)
796* 23. RTC_CMD_PWIC_POWEROFF_RTC_INIT: to init RTC at power off (for PWIC)
797* 24. RTC_CMD_PWIC_POWERON_RTC_INIT: to init RTC at power on (for PWIC)
798* 25. RTC_CMD_READ_PDN_BITS: to read RTC PDN bits
799* 26. RTC_CMD_READ_SPAR: to read RTC SPAR Register
800* 27. RTC_CMD_READ_XOSC_REG: to read RTC XOSCCALI register
801* 28. RTC_CMD_RELOAD: to load RTC whole register info from RTC module
802* 29. RTC_CMD_SET_ALARM_TIME: to set alarm time
803* 30. RTC_CMD_SET_FIRST_POWERON: to set first power on
804* 31. RTC_CMD_SET_PDN_BITS: to set RTC PDN bits
805* 32. RTC_CMD_SET_PWR_KEY: to set PWR KEY
806* 33. RTC_CMD_SET_TIME: to set time
807* 34. RTC_CMD_SETBBPU: to set RTC_BBPU
808* 35. RTC_CMD_SETXOSC: to set RTC XOSCCALI register
809* 36. RTC_CMD_START_CALI: to start calibration process
810* 37. RTC_CMD_WAIT_DEBOUNCE: to wait until debounce bit becomes 0
811* 38. RTC_CMD_WRITE_PDN_BITS: to write RTC PDN bits
812* 39. RTC_CMD_WRITE_SPAR: to write RTC SPAR Register
813* 40. RTC_CMD_WRITE_TRIGGER: to set write trigger
814* 41. RTC_CMD_WRITE_TRIGGER_WAIT: to set write trigger and wait until BUSY bit becomes 0
815* 42. RTC_CMD_WRITE_XOSC_REG: to write RTC XOSCCALI register
816*
817* data: The data of the control command
818* 1. RTC_CMD_BOOTLOADER_POWERON: pointer to a RTC_CTRL_BOOTLOADER_POWERON_T structure
819* 2. RTC_CMD_CLEAR_PDN_BITS: pointer to a RTC_CTRL_CONFIG_PDN_BIT_T structure
820* 3. RTC_CMD_CONFIG_AL_TC: pointer to a RTC_CTRL_CONFIG_AL_TC_T structure
821* 4. RTC_CMD_DELAY: A null pointer
822* 5. RTC_CMD_FT_POWEROFF: A null pointer
823* 6. RTC_CMD_GET_ALARM_TIME: pointer to a RTC_CTRL_GET_ALARM_TIME_T structure
824* 7. RTC_CMD_GET_TIME: pointer to a RTC_CTRL_GET_TIME_T structure
825* 8. RTC_CMD_GPIO_GET_INPUT: pointer to a RTC_CTRL_GPIO_TIME_T structure
826* 9. RTC_CMD_GPIO_SET_EXPORT_32K: pointer to a RTC_CTRL_GPIO_TIME_T structure
827* 10. RTC_CMD_GPIO_SET_EXPORT_COREDETB: pointer to a RTC_CTRL_GPIO_TIME_T structure
828* 11. RTC_CMD_GPIO_SET_INPUT_MODE: pointer to a RTC_CTRL_GPIO_TIME_T structure
829* 12. RTC_CMD_GPIO_SET_OUTPUT_MODE: pointer to a RTC_CTRL_GPIO_TIME_T structure
830* 13. RTC_CMD_HW_INIT: A null pointer
831* 14. RTC_CMD_INIT: pointer to a RTC_CTRL_INIT_T structure
832* 15. RTC_CMD_INIT_TC_AL_INTR: A null pointer
833* 16. RTC_CMD_IS_CONFIG_VALID: pointer to a RTC_CTRL_IS_CONFIG_VALID_T structure
834* 17. RTC_CMD_IS_FIRST_ON: pointer to a RTC_CTRL_IS_FIRST_ON_T structure
835* 18. RTC_CMD_IS_MS_FIRSTPOWERON: pointer to a RTC_CTRL_IS_MS_FIRSTPOWERON_T structure
836* 19. RTC_CMD_IS_TIME_VALID: pointer to a RTC_CTRL_IS_TIME_VALID_T structure
837* 20. RTC_CMD_PWIC_CHECK_POWERON: pointer to a RTC_CTRL_PWIC_CHECK_POWERON_T structure
838* 21. RTC_CMD_PWIC_FIRST_POWERON_INIT_RTCTIME: pointer to a RTC_CTRL_PWIC_FIRST_POWERON_INIT_RTCTIME_T structure
839* 22. RTC_CMD_PWIC_MASK_AL: A null pointer
840* 23. RTC_CMD_PWIC_POWEROFF_RTC_INIT: A null pointer
841* 24. RTC_CMD_PWIC_POWERON_RTC_INIT: A null pointer
842* 25. RTC_CMD_READ_PDN_BITS: pointer to a RTC_CTRL_CONFIG_PDN_BIT_T structure
843* 26. RTC_CMD_READ_SPAR: pointer to a RTC_CTRL_CONFIG_SPAR_T structure
844* 27. RTC_CMD_READ_XOSC_REG: pointer to a RTC_CTRL_READ_XOSC_REG_T structure
845* 28. RTC_CMD_RELOAD: A null pointer
846* 29. RTC_CMD_SET_ALARM_TIME: pointer to a RTC_CTRL_SET_ALARM_TIME_T structure
847* 30. RTC_CMD_SET_FIRST_POWERON: pointer to a RTC_CTRL_SET_FIRST_POWERON_T structure
848* 31. RTC_CMD_SET_PDN_BITS: pointer to a RTC_CTRL_CONFIG_PDN_BIT_T structure
849* 32. RTC_CMD_SET_PWR_KEY: A null pointer
850* 33. RTC_CMD_SET_TIME: pointer to a RTC_CTRL_SET_TIME_T structure
851* 34. RTC_CMD_SETBBPU: pointer to a RTC_CTRL_SETBBPU_T structure
852* 35. RTC_CMD_SETXOSC: A null pointer
853* 36. RTC_CMD_START_CALI: A null pointer
854* 37. RTC_CMD_WAIT_DEBOUNCE: A null pointer
855* 38. RTC_CMD_WRITE_PDN_BITS: pointer to a RTC_CTRL_CONFIG_PDN_BIT_T structure
856* 39. RTC_CMD_WRITE_SPAR: pointer to a RTC_CTRL_CONFIG_SPAR_T structure
857* 40. RTC_CMD_WRITE_TRIGGER: A null pointer
858* 41. RTC_CMD_WRITE_TRIGGER_WAIT: A null pointer
859* 42. RTC_CMD_WRITE_XOSC_REG: pointer to a RTC_CTRL_WRITE_XOSC_REG_T structure
860*
861* RETURNS
862* Return the status of DclRTC_Control
863*
864* RETURN VALUES
865* STATUS_OK: Command is executed successfully.
866* STATUS_FAIL: Command is failed.
867* STATUS_INVALID_CMD: It's a invalid command.
868*
869*************************************************************************/
870extern DCL_STATUS DclRTC_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
871/*************************************************************************
872* FUNCTION
873* DclRTC_Close
874*
875* DESCRIPTION
876* This function is to close the RTC module.
877*
878* PARAMETERS
879* handle: [IN] The returned handle value of DclRTC_Open
880*
881* RETURNS
882* Return the status of DclRTC_Close
883*
884* RETURN VALUES
885* STATUS_OK
886*
887*************************************************************************/
888extern DCL_STATUS DclRTC_Close(DCL_HANDLE handle);
889
890
891#endif // #ifndef __DCL_RTC_H_PROTOTYPE__
892#endif // #ifdef DCL_DEFINITION_PROTOTYPE
893