PDK API Guide for J721E
pmic_wdg.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2020 Texas Instruments Incorporated - http://www.ti.com
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  *****************************************************************************/
33 
57 #ifndef PMIC_WDG_H_
58 #define PMIC_WDG_H_
59 
60 /* ========================================================================== */
61 /* Include Files */
62 /* ========================================================================== */
63 
64 #include <pmic_core.h>
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 /* ========================================================================== */
71 /* Macros & Typedefs */
72 /* ========================================================================== */
73 
80 #define PMIC_WDG_DISABLE (bool)false
81 #define PMIC_WDG_ENABLE (bool)true
82 /* @} */
83 
90 #define PMIC_WDG_RESET_DISABLE (0x0U)
91 #define PMIC_WDG_RESET_ENABLE (0x1U)
92 /* @} */
93 
100 #define PMIC_WDG_RETLONGWIN_DISABLE (bool)false
101 #define PMIC_WDG_RETLONGWIN_ENABLE (bool)true
102 /* @} */
103 
110 #define PMIC_WDG_PWRHOLD_DISABLE (0x0U)
111 #define PMIC_WDG_PWRHOLD_ENABLE (0x1U)
112 /* @} */
113 
120 #define PMIC_WDG_TRIGGER_MODE (0x0U)
121 #define PMIC_WDG_QA_MODE (0x1U)
122 /* @} */
123 
130 #define PMIC_WDG_RESET_THRESHOLD_COUNT_0 (0x0U)
131 #define PMIC_WDG_RESET_THRESHOLD_COUNT_1 (0x1U)
132 #define PMIC_WDG_RESET_THRESHOLD_COUNT_2 (0x2U)
133 #define PMIC_WDG_RESET_THRESHOLD_COUNT_3 (0x3U)
134 #define PMIC_WDG_RESET_THRESHOLD_COUNT_4 (0x4U)
135 #define PMIC_WDG_RESET_THRESHOLD_COUNT_5 (0x5U)
136 #define PMIC_WDG_RESET_THRESHOLD_COUNT_6 (0x6U)
137 #define PMIC_WDG_RESET_THRESHOLD_COUNT_7 (0x7U)
138 /* @} */
139 
146 #define PMIC_WDG_FAIL_THRESHOLD_COUNT_0 (0x0U)
147 #define PMIC_WDG_FAIL_THRESHOLD_COUNT_1 (0x1U)
148 #define PMIC_WDG_FAIL_THRESHOLD_COUNT_2 (0x2U)
149 #define PMIC_WDG_FAIL_THRESHOLD_COUNT_3 (0x3U)
150 #define PMIC_WDG_FAIL_THRESHOLD_COUNT_4 (0x4U)
151 #define PMIC_WDG_FAIL_THRESHOLD_COUNT_5 (0x5U)
152 #define PMIC_WDG_FAIL_THRESHOLD_COUNT_6 (0x6U)
153 #define PMIC_WDG_FAIL_THRESHOLD_COUNT_7 (0x7U)
154 /* @} */
155 
162 #define PMIC_WDG_QA_FEEDBACK_VALUE_0 (0x0U)
163 #define PMIC_WDG_QA_FEEDBACK_VALUE_1 (0x1U)
164 #define PMIC_WDG_QA_FEEDBACK_VALUE_2 (0x2U)
165 #define PMIC_WDG_QA_FEEDBACK_VALUE_3 (0x3U)
166 /* @} */
167 
174 #define PMIC_WDG_QA_LFSR_VALUE_0 (0x0U)
175 #define PMIC_WDG_QA_LFSR_VALUE_1 (0x1U)
176 #define PMIC_WDG_QA_LFSR_VALUE_2 (0x2U)
177 #define PMIC_WDG_QA_LFSR_VALUE_3 (0x3U)
178 /* @} */
179 
186 #define PMIC_WDG_QA_QUES_SEED_VALUE_0 (0x0U)
187 #define PMIC_WDG_QA_QUES_SEED_VALUE_1 (0x1U)
188 #define PMIC_WDG_QA_QUES_SEED_VALUE_2 (0x2U)
189 #define PMIC_WDG_QA_QUES_SEED_VALUE_3 (0x3U)
190 #define PMIC_WDG_QA_QUES_SEED_VALUE_4 (0x4U)
191 #define PMIC_WDG_QA_QUES_SEED_VALUE_5 (0x5U)
192 #define PMIC_WDG_QA_QUES_SEED_VALUE_6 (0x6U)
193 #define PMIC_WDG_QA_QUES_SEED_VALUE_7 (0x7U)
194 #define PMIC_WDG_QA_QUES_SEED_VALUE_8 (0x8U)
195 #define PMIC_WDG_QA_QUES_SEED_VALUE_9 (0x9U)
196 #define PMIC_WDG_QA_QUES_SEED_VALUE_10 (0xAU)
197 #define PMIC_WDG_QA_QUES_SEED_VALUE_11 (0xBU)
198 #define PMIC_WDG_QA_QUES_SEED_VALUE_12 (0xCU)
199 #define PMIC_WDG_QA_QUES_SEED_VALUE_13 (0xDU)
200 #define PMIC_WDG_QA_QUES_SEED_VALUE_14 (0xEU)
201 #define PMIC_WDG_QA_QUES_SEED_VALUE_15 (0xFU)
202 /* @} */
203 
211 #define PMIC_CFG_WDG_LONGWINDURATION_VALID (0U)
212 
213 #define PMIC_CFG_WDG_WIN1DURATION_VALID (1U)
214 
215 #define PMIC_CFG_WDG_WIN2DURATION_VALID (2U)
216 
217 #define PMIC_CFG_WDG_FAILTHRESHOLD_VALID (3U)
218 
219 #define PMIC_CFG_WDG_RSTTHRESHOLD_VALID (4U)
220 
222 #define PMIC_CFG_WDG_RSTENABLE_VALID (5U)
223 
224 #define PMIC_CFG_WDG_WDGMODE_VALID (6U)
225 
227 #define PMIC_CFG_WDG_PWRHOLD_VALID (7U)
228 
230 #define PMIC_CFG_WDG_RETLONGWIN_VALID (8U)
231 
232 #define PMIC_CFG_WDG_QA_FDBK_VALID (9U)
233 
234 #define PMIC_CFG_WDG_QA_LFSR_VALID (10U)
235 
236 #define PMIC_CFG_WDG_QA_QUES_SEED_VALID (11U)
237 /* @} */
238 
242 #define PMIC_WDG_WAIT_CNT_MIN_VAL (30U)
243 
253 #define PMIC_CFG_WDG_LONGWINDURATION_VALID_SHIFT \
254  (1U << PMIC_CFG_WDG_LONGWINDURATION_VALID)
255 #define PMIC_CFG_WDG_WIN1DURATION_VALID_SHIFT \
256  (1U << PMIC_CFG_WDG_WIN1DURATION_VALID)
257 #define PMIC_CFG_WDG_WIN2DURATION_VALID_SHIFT \
258  (1U << PMIC_CFG_WDG_WIN2DURATION_VALID)
259 #define PMIC_CFG_WDG_FAILTHRESHOLD_VALID_SHIFT \
260  (1U << PMIC_CFG_WDG_FAILTHRESHOLD_VALID)
261 #define PMIC_CFG_WDG_RSTTHRESHOLD_VALID_SHIFT \
262  (1U << PMIC_CFG_WDG_RSTTHRESHOLD_VALID)
263 #define PMIC_CFG_WDG_RSTENABLE_VALID_SHIFT \
264  (1U << PMIC_CFG_WDG_RSTENABLE_VALID)
265 #define PMIC_CFG_WDG_WDGMODE_VALID_SHIFT \
266  (1U << PMIC_CFG_WDG_WDGMODE_VALID)
267 #define PMIC_CFG_WDG_PWRHOLD_VALID_SHIFT \
268  (1U << PMIC_CFG_WDG_PWRHOLD_VALID)
269 #define PMIC_CFG_WDG_RETLONGWIN_VALID_SHIFT \
270  (1U << PMIC_CFG_WDG_RETLONGWIN_VALID)
271 #define PMIC_CFG_WDG_QA_FDBK_VALID_SHIFT \
272  (1U << PMIC_CFG_WDG_QA_FDBK_VALID)
273 #define PMIC_CFG_WDG_QA_LFSR_VALID_SHIFT \
274  (1U << PMIC_CFG_WDG_QA_LFSR_VALID)
275 #define PMIC_CFG_WDG_QA_QUES_SEED_VALID_SHIFT \
276  (1U << PMIC_CFG_WDG_QA_QUES_SEED_VALID)
277 /* @} */
278 
286 #define PMIC_CFG_WD_LONGWIN_TIMEOUT_ERRSTAT_VALID (0U)
287 
289 #define PMIC_CFG_WD_TIMEOUT_ERRSTAT_VALID (1U)
290 
291 #define PMIC_CFG_WD_TRIG_EARLY_ERRSTAT_VALID (2U)
292 
293 #define PMIC_CFG_WD_ANSW_EARLY_ERRSTAT_VALID (3U)
294 
295 #define PMIC_CFG_WD_SEQ_ERR_ERRSTAT_VALID (4U)
296 
298 #define PMIC_CFG_WD_ANSW_ERR_ERRSTAT_VALID (5U)
299 
300 #define PMIC_CFG_WD_FAIL_INT_ERRSTAT_VALID (6U)
301 
302 #define PMIC_CFG_WD_RST_INT_ERRSTAT_VALID (7U)
303 /* @} */
304 
313 #define PMIC_CFG_WD_BAD_EVENT_STAT_VALID (0U)
314 
316 #define PMIC_CFG_WD_GOOD_EVENT_STAT_VALID (1U)
317 
318 #define PMIC_CFG_WD_FAIL_CNT_VAL_VALID (2U)
319 /* @} */
320 
330 #define PMIC_CFG_WD_LONGWIN_TIMEOUT_ERRSTAT_VALID_SHIFT \
331  (1U << PMIC_CFG_WD_LONGWIN_TIMEOUT_ERRSTAT_VALID)
332 #define PMIC_CFG_WD_TIMEOUT_ERRSTAT_VALID_SHIFT \
333  (1U << PMIC_CFG_WD_TIMEOUT_ERRSTAT_VALID)
334 #define PMIC_CFG_WD_TRIG_EARLY_ERRSTAT_VALID_SHIFT \
335  (1U << PMIC_CFG_WD_TRIG_EARLY_ERRSTAT_VALID)
336 #define PMIC_CFG_WD_ANSW_EARLY_ERRSTAT_VALID_SHIFT \
337  (1U << PMIC_CFG_WD_ANSW_EARLY_ERRSTAT_VALID)
338 #define PMIC_CFG_WD_SEQ_ERR_ERRSTAT_VALID_SHIFT \
339  (1U << PMIC_CFG_WD_SEQ_ERR_ERRSTAT_VALID)
340 #define PMIC_CFG_WD_ANSW_ERR_ERRSTAT_VALID_SHIFT \
341  (1U << PMIC_CFG_WD_ANSW_ERR_ERRSTAT_VALID)
342 #define PMIC_CFG_WD_FAIL_INT_ERRSTAT_VALID_SHIFT \
343  (1U << PMIC_CFG_WD_FAIL_INT_ERRSTAT_VALID)
344 #define PMIC_CFG_WD_RST_INT_ERRSTAT_VALID_SHIFT \
345  (1U << PMIC_CFG_WD_RST_INT_ERRSTAT_VALID)
346 /* @} */
347 
357 #define PMIC_CFG_WD_BAD_EVENT_STAT_VALID_SHIFT \
358  (1U << PMIC_CFG_WD_BAD_EVENT_STAT_VALID)
359 #define PMIC_CFG_WD_GOOD_EVENT_STAT_VALID_SHIFT \
360  (1U << PMIC_CFG_WD_GOOD_EVENT_STAT_VALID)
361 #define PMIC_CFG_WD_FAIL_CNT_VAL_VALID_SHIFT \
362  (1U << PMIC_CFG_WD_FAIL_CNT_VAL_VALID)
363 
364 /* @} */
365 
369 #define PMIC_WD_QA_INFINITE_SEQ (0xFFFFFFFFU)
370 
377 #define PMIC_WDG_ERR_LONG_WIN_TIMEOUT (0x0U)
378 #define PMIC_WDG_ERR_TIMEOUT (0x1U)
379 #define PMIC_WDG_ERR_TRIGGER_EARLY (0x2U)
380 #define PMIC_WDG_ERR_ANSWER_EARLY (0x3U)
381 #define PMIC_WDG_ERR_SEQ_ERR (0x4U)
382 #define PMIC_WDG_ERR_ANS_ERR (0x5U)
383 #define PMIC_WDG_ERR_FAIL_INT (0x6U)
384 #define PMIC_WDG_ERR_RST_INT (0x7U)
385 #define PMIC_WDG_ERR_ALL (0x8U)
386 /* @} */
387 
388 /* ========================================================================== */
389 /* Structures and Enums */
390 /* ========================================================================== */
391 
449 typedef struct Pmic_WdgCfg_s
450 {
451  uint32_t validParams;
452 
454  uint32_t win1Duration_us;
455  uint32_t win2Duration_us;
456 
457  uint8_t failThreshold;
458  uint8_t rstThreshold;
459 
460  bool wdgMode;
461  bool pwrHold;
462  bool rstEnable;
464 
465  uint8_t qaFdbk;
466  uint8_t qaLfsr;
467  uint8_t qaQuesSeed;
468 
470 
490 typedef struct Pmic_WdgErrStatus_s
491 {
492  uint32_t validParams;
494  bool wdTimeout;
497  bool wdSeqErr;
498  bool wdAnswErr;
499  bool wdFailInt;
500  bool wdRstInt;
502 
517 typedef struct Pmic_WdgFailCntStat_s
518 {
519  uint32_t validParams;
522  uint32_t wdFailCnt;
524 
525 /* ========================================================================== */
526 /* Function Declarations */
527 /* ========================================================================== */
544 int32_t Pmic_wdgEnable(Pmic_CoreHandle_t *pPmicCoreHandle);
545 
562 int32_t Pmic_wdgDisable(Pmic_CoreHandle_t *pPmicCoreHandle);
563 
584 int32_t Pmic_wdgSetCfg(Pmic_CoreHandle_t *pPmicCoreHandle,
585  const Pmic_WdgCfg_t wdgCfg);
586 
607 int32_t Pmic_wdgGetCfg(Pmic_CoreHandle_t *pPmicCoreHandle,
608  Pmic_WdgCfg_t *pWdgCfg);
609 
650 int32_t Pmic_wdgStartQaSequence(Pmic_CoreHandle_t *pPmicCoreHandle,
651  uint32_t num_of_sequences,
652  uint32_t maxCnt);
653 
673 int32_t Pmic_wdgGetErrorStatus(Pmic_CoreHandle_t *pPmicCoreHandle,
674  Pmic_WdgErrStatus_t *pErrStatus);
675 
693 int32_t Pmic_wdgGetFailCntStat(Pmic_CoreHandle_t *pPmicCoreHandle,
694  Pmic_WdgFailCntStat_t *pFailCount);
695 
732 int32_t Pmic_wdgStartTriggerSequence(Pmic_CoreHandle_t *pPmicCoreHandle);
733 
754 int32_t Pmic_wdgClrErrStatus(Pmic_CoreHandle_t *pPmicCoreHandle,
755  const uint8_t wdgErrType);
756 
794 int32_t Pmic_wdgQaSequenceWriteAnswer(Pmic_CoreHandle_t *pPmicCoreHandle);
795 
796 #ifdef __cplusplus
797 }
798 #endif /* __cplusplus */
799 
800 #endif /* PMIC_WDG_H_ */
801 
802 /* @} */
uint32_t validParams
Definition: pmic_wdg.h:519
bool wdSeqErr
Definition: pmic_wdg.h:497
bool wdRstInt
Definition: pmic_wdg.h:500
bool rstEnable
Definition: pmic_wdg.h:462
bool wdGudEvent
Definition: pmic_wdg.h:521
bool wdgMode
Definition: pmic_wdg.h:460
int32_t Pmic_wdgEnable(Pmic_CoreHandle_t *pPmicCoreHandle)
API to Enable Watchdog timer.
uint32_t win2Duration_us
Definition: pmic_wdg.h:455
bool pwrHold
Definition: pmic_wdg.h:461
bool retLongWin
Definition: pmic_wdg.h:463
bool wdTrigEarly
Definition: pmic_wdg.h:495
int32_t Pmic_wdgGetErrorStatus(Pmic_CoreHandle_t *pPmicCoreHandle, Pmic_WdgErrStatus_t *pErrStatus)
API to get PMIC watchdog error status.
int32_t Pmic_wdgClrErrStatus(Pmic_CoreHandle_t *pPmicCoreHandle, const uint8_t wdgErrType)
API to clear PMIC watchdog error status.
int32_t Pmic_wdgStartTriggerSequence(Pmic_CoreHandle_t *pPmicCoreHandle)
API to Start watchdog Trigger mode.
uint8_t qaQuesSeed
Definition: pmic_wdg.h:467
PMIC Watchdog Fail Count status structure Note: validParams is input param for all Get APIs....
Definition: pmic_wdg.h:517
bool wdTimeout
Definition: pmic_wdg.h:494
bool wdAnswErr
Definition: pmic_wdg.h:498
int32_t Pmic_wdgDisable(Pmic_CoreHandle_t *pPmicCoreHandle)
API to Disable Watchdog timer.
PMIC Interface Handle. Contains various PMIC driver instance specific information....
Definition: pmic_types.h:148
bool wdFailInt
Definition: pmic_wdg.h:499
PMIC Watchdog error status structure Note: validParams is input param for all Get APIs....
Definition: pmic_wdg.h:490
PMIC Driver Common API/interface file.
bool wdBadEvent
Definition: pmic_wdg.h:520
uint8_t rstThreshold
Definition: pmic_wdg.h:458
uint32_t wdFailCnt
Definition: pmic_wdg.h:522
uint8_t failThreshold
Definition: pmic_wdg.h:457
uint32_t win1Duration_us
Definition: pmic_wdg.h:454
int32_t Pmic_wdgStartQaSequence(Pmic_CoreHandle_t *pPmicCoreHandle, uint32_t num_of_sequences, uint32_t maxCnt)
API to Start watchdog QA mode.
uint32_t validParams
Definition: pmic_wdg.h:492
int32_t Pmic_wdgQaSequenceWriteAnswer(Pmic_CoreHandle_t *pPmicCoreHandle)
API to Write Answers in Long Window/ Window1/ Window2 Interval for watchdog QA Sequence.
uint8_t qaLfsr
Definition: pmic_wdg.h:466
int32_t Pmic_wdgGetCfg(Pmic_CoreHandle_t *pPmicCoreHandle, Pmic_WdgCfg_t *pWdgCfg)
API to get PMIC watchdog configurations.
PMIC Watchdog configuration structure Note: validParams is input param for all Set and Get APIs....
Definition: pmic_wdg.h:449
bool wdLongWinTimeout
Definition: pmic_wdg.h:493
int32_t Pmic_wdgSetCfg(Pmic_CoreHandle_t *pPmicCoreHandle, const Pmic_WdgCfg_t wdgCfg)
API to set PMIC watchdog configurations.
bool wdAnswearly
Definition: pmic_wdg.h:496
uint8_t qaFdbk
Definition: pmic_wdg.h:465
uint32_t validParams
Definition: pmic_wdg.h:451
int32_t Pmic_wdgGetFailCntStat(Pmic_CoreHandle_t *pPmicCoreHandle, Pmic_WdgFailCntStat_t *pFailCount)
API to get PMIC watchdog fail count status.
uint32_t longWinDuration_ms
Definition: pmic_wdg.h:453