forked from lowRISC/opentitan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dif_sysrst_ctrl.h
896 lines (852 loc) · 27.5 KB
/
dif_sysrst_ctrl.h
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#ifndef OPENTITAN_SW_DEVICE_LIB_DIF_DIF_SYSRST_CTRL_H_
#define OPENTITAN_SW_DEVICE_LIB_DIF_DIF_SYSRST_CTRL_H_
/**
* @file
* @brief <a href="/hw/ip/sysrst_ctrl/doc/">System Reset Controller</a> Device
* Interface Functions
*/
#include "sw/device/lib/dif/autogen/dif_sysrst_ctrl_autogen.h"
#include "sysrst_ctrl_regs.h" // Generated.
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/**
* A System Reset Controller key combination.
*/
typedef enum dif_sysrst_ctrl_key_combo {
/**
* Key combination 0.
*/
kDifSysrstCtrlKeyCombo0 = 1U << 0,
/**
* Key combination 1.
*/
kDifSysrstCtrlKeyCombo1 = 1U << 1,
/**
* Key combination 2.
*/
kDifSysrstCtrlKeyCombo2 = 1U << 2,
/**
* Key combination 3.
*/
kDifSysrstCtrlKeyCombo3 = 1U << 3,
/**
* All key combination ORed together.
*
* This is useful when clearing all key combination IRQ causes at once, e.g.,
* when initializing the System Reset Controller.
*/
kDifSysrstCtrlKeyComboAll = (1U << 4) - 1,
} dif_sysrst_ctrl_key_combo_t;
/**
* System Reset Controller keys that can form a key combination.
*/
typedef enum dif_sysrst_ctrl_key {
/**
* Key 0.
*/
kDifSysrstCtrlKey0 = 1U << 0,
/**
* Key 1.
*/
kDifSysrstCtrlKey1 = 1U << 1,
/**
* Key 2.
*/
kDifSysrstCtrlKey2 = 1U << 2,
/**
* Power button key.
*/
kDifSysrstCtrlKeyPowerButton = 1U << 3,
/**
* AC power preset key.
*/
kDifSysrstCtrlKeyAcPowerPresent = 1U << 4,
/**
* All keys ORed together.
*/
kDifSysrstCtrlKeyAll = (1U << 5) - 1,
} dif_sysrst_ctrl_key_t;
/**
* System Reset Controller key combination detection actions.
*/
typedef enum dif_sysrst_ctrl_key_combo_action {
/**
* Disable / disconnect battery.
*/
kDifSysrstCtrlKeyComboActionBatteryDisable = 1U << 0,
/**
* Issue an interrupt to the processor.
*/
kDifSysrstCtrlKeyComboActionInterrupt = 1U << 1,
/**
* Assert the embedded controller reset for a specified duration.
*/
kDifSysrstCtrlKeyComboActionEcReset = 1U << 2,
/**
* Issue a reset request to the reset manager block.
*/
kDifSysrstCtrlKeyComboActionSelfReset = 1U << 3,
/**
* All actions.
*/
kDifSysrstCtrlKeyComboActionAll = (1U << 4) - 1,
} dif_sysrst_ctrl_key_combo_action_t;
/**
* Runtime configuration for the System Reset Controller key combination
* detection feature.
*/
typedef struct dif_sysrst_ctrl_key_combo_config {
/**
* The keys that comprise the pre-condition key combination to detect (i.e.,
* one or more `dif_sysrst_ctrl_key_t`s ORed together).
*/
uint32_t pre_condition_keys;
/**
* The duration the pre-condition key combination should be pressed to enable
* triggering an action by an additional key combination press.
*
* Units: increments of 5us; [0, 2^32) represents [0, 60) seconds.
*/
uint32_t pre_condition_detection_time_threshold;
/**
* The keys that comprise the key combination to detect (i.e., one or more
* `dif_sysrst_ctrl_key_t`s ORed together).
*/
uint32_t keys;
/**
* The duration the key combination should be pressed to trigger an action.
*
* Units: increments of 5us; [0, 2^32) represents [0, 60) seconds.
*/
uint32_t detection_time_threshold;
/**
* The actions to trigger after detecting the key press combination (one or
* more `dif_sysrst_ctrl_key_combo_action_t`s ORed together).
*/
uint32_t actions;
/**
* The embedded controller's reset pulse width.
*
* Note: only applicable if the `kDifSysrstCtrlKeyComboActionEcReset` action
* is enabled for the key combination.
*
* Units: increments of 5us; [0, 2^16) represents [10, 200) milliseconds.
*/
uint16_t embedded_controller_reset_duration;
} dif_sysrst_ctrl_key_combo_config_t;
/**
* System Reset Controller input signal changes that may be detected.
*/
typedef enum dif_sysrst_ctrl_input_change {
/**
* Power button input signal high-to-low.
*/
kDifSysrstCtrlInputPowerButtonH2L = 1U << 0,
/**
* Key 0 input signal high-to-low.
*/
kDifSysrstCtrlInputKey0H2L = 1U << 1,
/**
* Key 1 input signal high-to-low.
*/
kDifSysrstCtrlInputKey1H2L = 1U << 2,
/**
* Key 2 input signal high-to-low.
*/
kDifSysrstCtrlInputKey2H2L = 1U << 3,
/**
* AC power present input signal high-to-low.
*/
kDifSysrstCtrlInputAcPowerPresetH2L = 1U << 4,
/**
* Embedded controller reset input signal high-to-low.
*/
kDifSysrstCtrlInputEcResetH2L = 1U << 5,
/**
* Flash write protect input signal high-to-low.
*/
kDifSysrstCtrlInputFlashWriteProtectH2L = 1U << 6,
/**
* Power button input signal low-to-high.
*/
kDifSysrstCtrlInputPowerButtonL2H = 1U << 7,
/**
* Key 0 input signal low-to-high.
*/
kDifSysrstCtrlInputKey0L2H = 1U << 8,
/**
* Key 1 input signal low-to-high.
*/
kDifSysrstCtrlInputKey1L2H = 1U << 9,
/**
* Key 2 input signal low-to-high.
*/
kDifSysrstCtrlInputKey2L2H = 1U << 10,
/**
* AC power present input signal low-to-high.
*/
kDifSysrstCtrlInputAcPowerPresetL2H = 1U << 11,
/**
* Embedded controller reset input signal low-to-high.
*/
kDifSysrstCtrlInputEcResetL2H = 1U << 12,
/**
* Flash write protect input signal low-to-high.
*/
kDifSysrstCtrlInputFlashWriteProtectL2H = 1U << 13,
/**
* All input signal transitions.
*/
kDifSysrstCtrlInputAll = ((1U << 14) - 1),
} dif_sysrst_ctrl_input_change_t;
/**
* System Reset Controller key interrupt sources.
*/
typedef enum dif_sysrst_ctrl_key_intr_src {
/**
* Power button input signal high-to-low.
*/
kDifSysrstCtrlKeyIntrStatusInputPowerButtonH2L =
1U << SYSRST_CTRL_KEY_INTR_STATUS_PWRB_H2L_BIT,
/**
* Key 0 input signal high-to-low.
*/
kDifSysrstCtrlKeyIntrStatusInputKey0H2L =
1U << SYSRST_CTRL_KEY_INTR_STATUS_KEY0_IN_H2L_BIT,
/**
* Key 1 input signal high-to-low.
*/
kDifSysrstCtrlKeyIntrStatusInputKey1H2L =
1U << SYSRST_CTRL_KEY_INTR_STATUS_KEY1_IN_H2L_BIT,
/**
* Key 2 input signal high-to-low.
*/
kDifSysrstCtrlKeyIntrStatusInputKey2H2L =
1U << SYSRST_CTRL_KEY_INTR_STATUS_KEY2_IN_H2L_BIT,
/**
* AC power present input signal high-to-low.
*/
kDifSysrstCtrlKeyIntrStatusInputAcPowerPresetH2L =
1U << SYSRST_CTRL_KEY_INTR_STATUS_AC_PRESENT_H2L_BIT,
/**
* Embedded controller reset input signal high-to-low.
*/
kDifSysrstCtrlKeyIntrStatusInputEcResetH2L =
1U << SYSRST_CTRL_KEY_INTR_STATUS_EC_RST_L_H2L_BIT,
/**
* Flash write protect input signal high-to-low.
*/
kDifSysrstCtrlKeyIntrStatusInputFlashWriteProtectH2L =
1U << SYSRST_CTRL_KEY_INTR_STATUS_FLASH_WP_L_H2L_BIT,
/**
* Power button input signal low-to-high.
*/
kDifSysrstCtrlKeyIntrStatusInputPowerButtonL2H =
1U << SYSRST_CTRL_KEY_INTR_STATUS_PWRB_L2H_BIT,
/**
* Key 0 input signal low-to-high.
*/
kDifSysrstCtrlKeyIntrStatusInputKey0L2H =
1U << SYSRST_CTRL_KEY_INTR_STATUS_KEY0_IN_L2H_BIT,
/**
* Key 1 input signal low-to-high.
*/
kDifSysrstCtrlKeyIntrStatusInputKey1L2H =
1U << SYSRST_CTRL_KEY_INTR_STATUS_KEY1_IN_L2H_BIT,
/**
* Key 2 input signal low-to-high.
*/
kDifSysrstCtrlKeyIntrStatusInputKey2L2H =
1U << SYSRST_CTRL_KEY_INTR_STATUS_KEY2_IN_L2H_BIT,
/**
* AC power present input signal low-to-high.
*/
kDifSysrstCtrlKeyIntrStatusInputAcPowerPresetL2H =
1U << SYSRST_CTRL_KEY_INTR_STATUS_AC_PRESENT_L2H_BIT,
/**
* Embedded controller reset input signal low-to-high.
*/
kDifSysrstCtrlKeyIntrStatusInputEcResetL2H =
1U << SYSRST_CTRL_KEY_INTR_STATUS_EC_RST_L_L2H_BIT,
/**
* Flash write protect input signal low-to-high.
*/
kDifSysrstCtrlKeyIntrStatusInputFlashWriteProtectL2H =
1U << SYSRST_CTRL_KEY_INTR_STATUS_FLASH_WP_L_L2H_BIT,
} dif_sysrst_ctrl_key_intr_src_t;
/**
* System Reset Controller combo interrupt sources.
*/
typedef enum dif_sysrst_ctrl_combo_intr_src {
/**
* Power button input signal high-to-low.
*/
kDifSysrstCtrlComboIntrStatusCombo0H2L =
1U << SYSRST_CTRL_COMBO_INTR_STATUS_COMBO0_H2L_BIT,
/**
* Key 0 input signal high-to-low.
*/
kDifSysrstCtrlComboIntrStatusCombo1H2L =
1U << SYSRST_CTRL_COMBO_INTR_STATUS_COMBO1_H2L_BIT,
/**
* Key 1 input signal high-to-low.
*/
kDifSysrstCtrlComboIntrStatusCombo2H2L =
1U << SYSRST_CTRL_COMBO_INTR_STATUS_COMBO2_H2L_BIT,
/**
* Key 2 input signal high-to-low.
*/
kDifSysrstCtrlComboIntrStatusCombo3H2L =
1U << SYSRST_CTRL_COMBO_INTR_STATUS_COMBO3_H2L_BIT,
} dif_sysrst_ctrl_combo_intr_src_t;
/**
* Runtime configuration for the System Reset Controller input signal change
* detection feature.
*/
typedef struct dif_sysrst_ctrl_input_change_config {
/**
* A combination of input signal changes to detect (one or more
* `dif_sysrst_ctrl_input_change_t`s ORed together).
*/
uint32_t input_changes;
/**
* The time to allow the input signal to stabilize before reevaluating its
* value to decide whether to trigger an interrupt.
*
* Units: increments of 5us; [0, 2^16) represents [0, 200) milliseconds.
*/
uint16_t debounce_time_threshold;
} dif_sysrst_ctrl_input_change_config_t;
/**
* Runtime configuration for the System Reset Controller key signal
* auto-override feature.
*
* Upon detection of a Power Button high-to-low transition, the signals from
* generic keys 0 through 2 may be overriden with specified values.
*/
typedef struct dif_sysrst_ctrl_auto_override_config {
/**
* The time to allow the Power Button signal to stabilize before reevaluating
* its value to decide whether it was pressed.
*
* Units: increments of 5us; [0, 2^16) represents [0, 200) milliseconds.
*/
uint16_t debounce_time_threshold;
/**
* Whether to override the key 0 signal.
*/
dif_toggle_t override_key_0;
/**
* The value to override onto the key 0 signal.
*/
bool key_0_override_value;
/**
* Whether to override the key 1 signal.
*/
dif_toggle_t override_key_1;
/**
* The value to override onto the key 1 signal.
*/
bool key_1_override_value;
/**
* Whether to override the key 2 signal.
*/
dif_toggle_t override_key_2;
/**
* The value to override onto the key 2 signal.
*/
bool key_2_override_value;
} dif_sysrst_ctrl_auto_override_config_t;
/**
* System Reset Controller pins that can be inverted, read, or overridden.
*/
typedef enum dif_sysrst_ctrl_pin {
/**
* Key 0 input.
*/
kDifSysrstCtrlPinKey0In = 1U << 0,
/**
* Key 0 output.
*/
kDifSysrstCtrlPinKey0Out = 1U << 1,
/**
* Key 1 input.
*/
kDifSysrstCtrlPinKey1In = 1U << 2,
/**
* Key 1 output.
*/
kDifSysrstCtrlPinKey1Out = 1U << 3,
/**
* Key 2 input.
*/
kDifSysrstCtrlPinKey2In = 1U << 4,
/**
* Key 2 output.
*/
kDifSysrstCtrlPinKey2Out = 1U << 5,
/**
* Power button input.
*/
kDifSysrstCtrlPinPowerButtonIn = 1U << 6,
/**
* Power button output.
*/
kDifSysrstCtrlPinPowerButtonOut = 1U << 7,
/**
* AC power preset input.
*/
kDifSysrstCtrlPinAcPowerPresentIn = 1U << 8,
/**
* Battery disable output.
*/
kDifSysrstCtrlPinBatteryDisableOut = 1U << 9,
/**
* Lid open input.
*/
kDifSysrstCtrlPinLidOpenIn = 1U << 10,
/**
* Z3 Wakeup output.
*/
kDifSysrstCtrlPinZ3WakeupOut = 1U << 11,
/**
* Embedded controller reset inout.
*/
kDifSysrstCtrlPinEcResetInOut = 1U << 12,
/**
* Flash write protect inout.
*/
kDifSysrstCtrlPinFlashWriteProtectInOut = 1U << 13,
/**
* All non open drain pins.
*/
kDifSysrstCtrlPinAllNonOpenDrain = (1U << 12) - 1,
} dif_sysrst_ctrl_pin_t;
/**
* Runtime configuration for the System Reset Controller output pin override
* feature.
*/
typedef struct dif_sysrst_ctrl_pin_config_t {
/**
* The enablement of the output pin's override feature.
*/
dif_toggle_t enabled;
/**
* Whether to allow overriding the output pin with a value of 0.
*/
bool allow_zero;
/**
* Whether to allow overriding the output pin with a value of 1.
*/
bool allow_one;
/**
* The override value to write.
*
* Note: writing a non-allowable value will cause
* `dif_sysrst_ctrl_output_pin_override_configure()` to return `kDifBadArg`.
*/
bool override_value;
} dif_sysrst_ctrl_pin_config_t;
/**
* Runtime configuration for the System Reset Controller ultra-low-power (ULP)
* wakeup feature.
*
* When enabled, detection of any of the following conditions:
*
* 1. HIGH level on the AC Power present signal, or
* 2. HIGH --> LOW transition on the Power Button signal, or
* 3. LOW --> HIGH transition on the Lid Open signal,
*
* will cause the System Reset Controller to assert the Z3 Wakeup output signal
* and trigger an interrupt, which will also issue a wakeup request to the power
* manager.
*/
typedef struct dif_sysrst_ctrl_ulp_wakeup_config_t {
/**
* The enablement of the ULP wakeup feature.
*/
dif_toggle_t enabled;
/**
* The time to allow the AC Power present signal to stabilize before
* reevaluating its value to decide whether it was activated.
*
* Units: increments of 5us; [0, 2^16) represents [10, 200) milliseconds.
*/
uint16_t ac_power_debounce_time_threshold;
/**
* The time to allow the Lid Open signal to stabilize before reevaluating its
* value to decide whether it was activated.
*
* Units: increments of 5us; [0, 2^16) represents [10, 200) milliseconds.
*/
uint16_t lid_open_debounce_time_threshold;
/**
* The time to allow the Power Button signal to stabilize before reevaluating
* its value to decide whether it was pressed.
*
* Units: increments of 5us; [0, 2^16) represents [10, 200) milliseconds.
*/
uint16_t power_button_debounce_time_threshold;
} dif_sysrst_ctrl_ulp_wakeup_config_t;
/**
* Configures a System Reset Controller's key combination detection feature.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param key_combo Key combination to configure.
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_key_combo_detect_configure(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_key_combo_t key_combo,
dif_sysrst_ctrl_key_combo_config_t config);
/**
* Configures a System Reset Controller's input signal change detection feature.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_input_change_detect_configure(
const dif_sysrst_ctrl_t *sysrst_ctrl,
dif_sysrst_ctrl_input_change_config_t config);
/**
* Configures a System Reset Controller's output pin override feature.
*
* Note, only output (or inout) pins may be overriden, i.e., set to a specific
* value. Attempting to configure the override feature for input pins will
* return `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param output_pin Output pin to configure.
* @param config Output pin override configuration parameters.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_output_pin_override_configure(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_pin_t output_pin,
dif_sysrst_ctrl_pin_config_t config);
/**
* Configures a System Reset Controller's key signal auto-override feature.
*
* Upon detection of a Power Button high-to-low transition, the signals from
* generic keys 0 through 2 may be overriden with specified values.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param config Runtime configuration parameters.
* @param enabled Whether to enable the feature or not.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_auto_override_configure(
const dif_sysrst_ctrl_t *sysrst_ctrl,
dif_sysrst_ctrl_auto_override_config_t config, dif_toggle_t enabled);
/**
* Configures a System Reset Controller's ultra-low-power (ULP) wakeup feature.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_ulp_wakeup_configure(
const dif_sysrst_ctrl_t *sysrst_ctrl,
dif_sysrst_ctrl_ulp_wakeup_config_t config);
/**
* Sets the enablement state of a System Reset Controller's ultra-low-power
* (ULP) wakeup feature.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param enabled The enablement state to configure the ULP wakeup feature in.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_ulp_wakeup_set_enabled(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_toggle_t enabled);
/**
* Gets the enablement state of a System Reset Controller's ultra-low-power
* (ULP) wakeup feature.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param[out] is_enabled The enablement state of the ULP wakeup feature.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_ulp_wakeup_get_enabled(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_toggle_t *is_enabled);
/**
* Sets the inversion state a System Reset Controller's input and output pins.
*
* Note, only input and output (NOT inout) pins may be inverted. Attempting
* to set the inversion state of inout pins will return `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param pins The input and output pins to set the inverted state of (i.e., one
* or more `dif_sysrst_ctrl_pin_t`s ORed together).
* @param inverted The inverted state to configure for the pins.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_pins_set_inverted(
const dif_sysrst_ctrl_t *sysrst_ctrl, uint32_t pins, bool inverted);
/**
* Gets the inversion state a System Reset Controller's input and output pins.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param[out] inverted_pins The input and output pins that are inverted (i.e.,
* one or more `dif_sysrst_ctrl_pin_t`s ORed
* together).
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_pins_get_inverted(
const dif_sysrst_ctrl_t *sysrst_ctrl, uint32_t *inverted_pins);
/**
* Sets allowable override values for a System Reset Controller's output pin.
*
* Note, only output (or inout) pins may be overriden, i.e., set to a specific
* value. Attempting to set the allowable override values for input pins will
* return `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param pin The output pin whose allowable override values should be set.
* @param allow_zero Whether to allow overriding the pin's value to 0.
* @param allow_one Whether to allow overriding the pin's value to 1.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_output_pin_override_set_allowed(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_pin_t pin,
bool allow_zero, bool allow_one);
/**
* Gets allowable override values for a System Reset Controller's output pin.
*
* Note, only output (or inout) pins may be overriden, i.e., set to a specific
* value. Attempting to get the allowable override values for input pins will
* return `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param pin The allowable override values to get for an output pin.
* @param[out] allow_zero Whether overriding the pin's value to 0 is allowed.
* @param[out] allow_one Whether overriding the pin's value to 1 is allowed.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_output_pin_override_get_allowed(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_pin_t pin,
bool *allow_zero, bool *allow_one);
/**
* Sets the enablement of a System Reset Controller's output pin override
* feature.
*
* Note, only output (or inout) pins may be overriden, i.e., set to a specific
* value. Attempting to set the enablement of the override feature for input
* pins will return `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param pin The output pin whose override feature should be set.
* @param enabled The enablement state to configure the override feature in.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_output_pin_override_set_enabled(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_pin_t pin,
dif_toggle_t enabled);
/**
* Gets the enablement of a System Reset Controller's output pin override
* feature.
*
* Note, only output (or inout) pins may be overriden, i.e., set to a specific
* value. Attempting to get the enablement of the override feature for input
* pins will return `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param pin The output pin whose override feature should be set.
* @param[out] is_enabled The enablement state the override feature is
* configured in.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_output_pin_override_get_enabled(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_pin_t pin,
dif_toggle_t *is_enabled);
/**
* Sets the override value of a System Reset Controller's output pin (like
* writing to a GPIO pin).
*
* Note, only output (or inout) pins may be overriden, i.e., set to a specific
* value. Attempting to set the override value of an input pin will return
* `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param pin The output pin to override.
* @param value The override value to set on the pin.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_output_pin_set_override(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_pin_t pin,
bool value);
/**
* Gets the override value of a System Reset Controller's output pin (like
* writing to a GPIO pin).
*
* Note, only output (or inout) pins may be overriden, i.e., set to a specific
* value. Attempting to get the override value of an input pin will return
* `kDifBadArg`.
*
* Additionally, this will return the configured override value of an output pin
* regardless if the override function is enabled or the override value is
* allowed.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param pin The output pin to override.
* @param[out] value The override value set on the pin.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_output_pin_get_override(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_pin_t pin,
bool *value);
/**
* Reads a System Reset Controller's input pin (like a GPIO pin).
*
* Note, only input (or inout) pins may be read. Attempting to read the value of
* an output pin will return `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param pin The pin to read.
* @param[out] value The value set on the pin.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_input_pin_read(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_pin_t pin,
bool *value);
/**
* Sets the enablement of a System Reset Controller's key signal auto-override
* feature.
*
* Note, this feature is only available for keys 0, 1, and 2. Attempting to
* enable the auto-override feature on non-supported keys will return
* `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param key The key to enable the override feature for.
* @param enabled Whether to enable the feature or not.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_auto_override_set_enabled(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_key_t key,
dif_toggle_t enabled);
/**
* Gets the enablement of a System Reset Controller's key signal auto-override
* feature.
*
* Note, this feature is only available for keys 0, 1, and 2. Attempting to
* check whether the auto-override feature is enabled non-supported keys will
* return `kDifBadArg`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param key The key the override feature is enabled for.
* @param[out] is_enabled Whether the feature is enabled or not.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_auto_override_get_enabled(
const dif_sysrst_ctrl_t *sysrst_ctrl, dif_sysrst_ctrl_key_t key,
dif_toggle_t *is_enabled);
/**
* Gets the cause(s) of a key combination detection IRQ.
*
* @param sysrst_ctrl An sysrst_ctrl handle.
* @param[out] causes The causes of the IRQ (one or more
* `dif_sysrst_ctrl_key_combo_t`s ORed together).
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_key_combo_irq_get_causes(
const dif_sysrst_ctrl_t *sysrst_ctrl, uint32_t *causes);
/**
* Clears the cause(s) of a key combination detection IRQ.
*
* @param sysrst_ctrl An sysrst_ctrl handle.
* @param causes The causes of the IRQ (one or more
* `dif_sysrst_ctrl_key_combo_t`s ORed together).
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_key_combo_irq_clear_causes(
const dif_sysrst_ctrl_t *sysrst_ctrl, uint32_t causes);
/**
* Gets the cause(s) of an input signal change detection IRQ.
*
* @param sysrst_ctrl An sysrst_ctrl handle.
* @param[out] causes The causes of the IRQ (one or more
* `dif_sysrst_ctrl_input_change_t`s ORed together).
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_input_change_irq_get_causes(
const dif_sysrst_ctrl_t *sysrst_ctrl, uint32_t *causes);
/**
* Clears the cause(s) of an input signal change detection IRQ.
*
* @param sysrst_ctrl An sysrst_ctrl handle.
* @param causes The causes of the IRQ (one or more
* `dif_sysrst_ctrl_input_change_t`s ORed together).
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_input_change_irq_clear_causes(
const dif_sysrst_ctrl_t *sysrst_ctrl, uint32_t causes);
/**
* Gets the ultra-low-power wakeup status.
*
* @param sysrst_ctrl An sysrst_ctrl handle.
* @param[out] wakeup_detected The ULP wakeup detection state.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_ulp_wakeup_get_status(
const dif_sysrst_ctrl_t *sysrst_ctrl, bool *wakeup_detected);
/**
* Clears the ultra-low-power wakeup status.
*
* @param sysrst_ctrl An sysrst_ctrl handle.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_ulp_wakeup_clear_status(
const dif_sysrst_ctrl_t *sysrst_ctrl);
/**
* Locks System Reset Controller configurations.
*
* This function is reentrant: calling it while locked will have no effect and
* return `kDifOk`.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_lock(const dif_sysrst_ctrl_t *sysrst_ctrl);
/**
* Checks whether System Reset Controller configurations are locked.
*
* @param sysrst_ctrl A System Reset Controller handle.
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_sysrst_ctrl_is_locked(const dif_sysrst_ctrl_t *sysrst_ctrl,
bool *is_locked);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // OPENTITAN_SW_DEVICE_LIB_DIF_DIF_SYSRST_CTRL_H_