Software APIs
dif_sensor_ctrl.h
Go to the documentation of this file.
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #ifndef OPENTITAN_SW_DEVICE_LIB_DIF_DIF_SENSOR_CTRL_H_
6 #define OPENTITAN_SW_DEVICE_LIB_DIF_DIF_SENSOR_CTRL_H_
7 
8 /**
9  * @file
10  * @brief <a href="/hw/top_earlgrey/ip/sensor_ctrl/doc/">Sensor Controller</a>
11  * Device Interface Functions
12  */
13 
14 #include <stdint.h>
15 
19 
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif // __cplusplus
25 
26 /**
27  * An event, identified by a numeric id.
28  *
29  */
30 typedef uint32_t dif_sensor_ctrl_event_idx_t;
31 
32 /**
33  * A vector of AST events, where each bit represents one event.
34  *
35  */
36 typedef uint32_t dif_sensor_ctrl_events_t;
37 
38 /**
39  * IO power status
40  * Each bit represents the current status of a particular IO rail.
41  *
42  */
44 
45 /**
46  * Locks sensor control configuration from further updates.
47  *
48  *
49  * @param sensor_ctrl A sensor_ctrl handle.
50  * @return 'kDifBadArg' if `handle` is null.
51  */
54 
55 /**
56  * Gets the value of a particular AST event trigger.
57  *
58  * @param sensor_ctrl A sensor_ctrl handle.
59  * @param event_idx The event to read.
60  * @param[out] enable The current trigger enable status.
61  * @return 'kDifBadArg' if `sensor_ctrl` or `enable` are null, or if `event_idx`
62  * is larger than the number of events supported.
63  */
66  const dif_sensor_ctrl_t *sensor_ctrl, dif_sensor_ctrl_event_idx_t event_idx,
67  dif_toggle_t *enable);
68 
69 /**
70  * Sets the value for a particular AST event trigger.
71  *
72  * @param sensor_ctrl A sensor_ctrl handle.
73  * @param event_idx The event to configure.
74  * @param enable The toggle status to set.
75  * @return 'kDifBadArg' if `handle` is null or if `event_idx` is larger than the
76  * number of events supported.
77  */
80  const dif_sensor_ctrl_t *sensor_ctrl, dif_sensor_ctrl_event_idx_t event_idx,
81  dif_toggle_t enable);
82 
83 /**
84  * Enable a particular alert event..
85  *
86  * @param sensor_ctrl A sensor_ctrl handle.
87  * @param event_idx The event to configure.
88  * @param en Whether an event is enabled or not. If
89  * `kDifToggleEnabled`, the event is enabled. Otherwise, it is disabled.
90  * @return 'kDifBadArg' if `handle` is null or `event_idx` is larger than the
91  * number of events supported.
92  */
96  dif_toggle_t en);
97 
98 /**
99  * Sets the fatality configuration of a particular event.
100  *
101  * An event can be configured to be either fatal or recoverable.
102  *
103  * @param sensor_ctrl A sensor_ctrl handle.
104  * @param event_idx The event to configure.
105  * @param en_fatal The fatality enablement state of an event. If
106  * `kDifToggleEnabled`, the event is fatal. Otherwise, it is recoverable.
107  * @return 'kDifBadArg' if `handle` is null or `event_idx` is larger than the
108  * number of events supported.
109  */
112  const dif_sensor_ctrl_t *sensor_ctrl, dif_sensor_ctrl_event_idx_t event_idx,
113  dif_toggle_t en_fatal);
114 
115 /**
116  * Gets the current vector of recoverable events.
117  *
118  * @param sensor_ctrl A sensor_ctrl handle.
119  * @param[out] events The set of current recoverable events
120  * @return 'kDifBadArg' if `handle` is null.
121  */
124  const dif_sensor_ctrl_t *sensor_ctrl, dif_sensor_ctrl_events_t *events);
125 
126 /**
127  * Clears the specified recoverable events.
128  *
129  * @param sensor_ctrl A sensor_ctrl handle.
130  * @param event_idx The event to clear.
131  * @return 'kDifBadArg' if `handle` is null or 'event_idx' is larger than the
132  * number of events supported..
133  */
136  const dif_sensor_ctrl_t *sensor_ctrl,
137  dif_sensor_ctrl_event_idx_t event_idx);
138 
139 /**
140  * Gets the current vector of fatal events.
141  *
142  * @param sensor_ctrl A sensor_ctrl handle.
143  * @param[out] events The set of current fatal events.
144  * @return 'kDifBadArg' if `handle` is null.
145  */
148  const dif_sensor_ctrl_t *sensor_ctrl, dif_sensor_ctrl_events_t *events);
149 
150 /**
151  * Gets the current ast init done status.
152  *
153  * @param sensor_ctrl A sensor_ctrl handle.
154  * @param[out] done Current init_done status.
155  * @return 'kDifBadArg' if `handle` is null.
156  */
159  const dif_sensor_ctrl_t *sensor_ctrl, dif_toggle_t *done);
160 
161 /**
162  * Gets the current io power status.
163  *
164  * @param sensor_ctrl A sensor_ctrl handle.
165  * @param[out] done Current io power status.
166  * @return 'kDifBadArg' if `handle` is null.
167  */
170  const dif_sensor_ctrl_t *sensor_ctrl,
172 
173 #ifdef __cplusplus
174 } // extern "C"
175 #endif // __cplusplus
176 
177 #endif // OPENTITAN_SW_DEVICE_LIB_DIF_DIF_SENSOR_CTRL_H_