Software APIs
dt_aon_timer.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// Device table API auto-generated by `dtgen`
6
7#ifndef OPENTITAN_DT_AON_TIMER_H_
8#define OPENTITAN_DT_AON_TIMER_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP aon_timer and top darjeeling.
17 *
18 * This file contains the type definitions and global functions of the aon_timer.
19 */
20
21#include "hw/top/dt/dt_api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_aon_timer {
30 kDtAonTimerAon = 0, /**< aon_timer_aon */
31 kDtAonTimerFirst = 0, /**< \internal First instance */
32 kDtAonTimerCount = 1, /**< \internal Number of instances */
34
35/**
36 * List of register blocks.
37 *
38 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39 */
41 kDtAonTimerRegBlockCore = 0, /**< */
42 kDtAonTimerRegBlockCount = 1, /**< \internal Number of register blocks */
44
45/** Primary register block (associated with the "primary" set of registers that control the IP). */
46static const dt_aon_timer_reg_block_t kDtAonTimerRegBlockPrimary = kDtAonTimerRegBlockCore;
47
48/**
49 * List of memories.
50 *
51 * Memories are guaranteed to start at 0 and to be consecutively numbered.
52 */
53typedef enum dt_aon_timer_memory {
54 kDtAonTimerMemoryCount = 0, /**< \internal Number of memories */
56
57/**
58 * List of IRQs.
59 *
60 * IRQs are guaranteed to be numbered consecutively from 0.
61 */
62typedef enum dt_aon_timer_irq {
63 kDtAonTimerIrqWkupTimerExpired = 0, /**< Raised if the wakeup timer has hit the specified threshold. */
64 kDtAonTimerIrqWdogTimerBark = 1, /**< Raised if the watchdog timer has hit the bark threshold. */
65 kDtAonTimerIrqCount = 2, /**< \internal Number of IRQs */
67
68/**
69 * List of Alerts.
70 *
71 * Alerts are guaranteed to be numbered consecutively from 0.
72 */
73typedef enum dt_aon_timer_alert {
74 kDtAonTimerAlertFatalFault = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
75 kDtAonTimerAlertCount = 1, /**< \internal Number of Alerts */
77
78/**
79 * List of clock ports.
80 *
81 * Clock ports are guaranteed to be numbered consecutively from 0.
82 */
83typedef enum dt_aon_timer_clock {
84 kDtAonTimerClockClk = 0, /**< Clock port clk_i */
85 kDtAonTimerClockAon = 1, /**< Clock port clk_aon_i */
86 kDtAonTimerClockCount = 2, /**< \internal Number of clock ports */
88
89/**
90 * List of reset requests.
91 *
92 * Reset requests are guaranteed to be numbered consecutively from 0.
93 */
95 kDtAonTimerResetReqAonTimer = 0, /**< Watchdog reset request. */
96 kDtAonTimerResetReqCount = 1, /**< \internal Number of reset requests */
98
99/**
100 * List of reset ports.
101 *
102 * Reset ports are guaranteed to be numbered consecutively from 0.
103 */
104typedef enum dt_aon_timer_reset {
105 kDtAonTimerResetRst = 0, /**< Reset port rst_ni */
106 kDtAonTimerResetAon = 1, /**< Reset port rst_aon_ni */
107 kDtAonTimerResetCount = 2, /**< \internal Number of reset ports */
109
110/**
111 * List of wakeups.
112 *
113 * Wakeups are guaranteed to be numbered consecutively from 0.
114 */
116 kDtAonTimerWakeupWkupReq = 0, /**< Raised if the wakeup or watchdog timer has hit the specified threshold. */
117 kDtAonTimerWakeupCount = 1, /**< \internal Number of wakeups */
119
120/**
121 * List of supported hardware features.
122 */
123#define OPENTITAN_AON_TIMER_HAS_WAKEUP_WAKEUP_CONFIG 1
124#define OPENTITAN_AON_TIMER_HAS_WAKEUP_WAKEUP_REQUEST 1
125#define OPENTITAN_AON_TIMER_HAS_WAKEUP_INTERRUPT 1
126#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_BARK 1
127#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_BITE 1
128#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_PAUSE 1
129#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_DISABLE_BY_LC_CTRL 1
130#define OPENTITAN_AON_TIMER_HAS_WATCHDOG_INTERRUPT 1
131
132
133
134/**
135 * Get the aon_timer instance from an instance ID
136 *
137 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
138 *
139 * @param inst_id Instance ID.
140 * @return A aon_timer instance.
141 *
142 * **Note:** This function only makes sense if the instance ID has device type aon_timer,
143 * otherwise the returned value is unspecified.
144 */
146
147/**
148 * Get the instance ID of an instance.
149 *
150 * @param dt Instance of aon_timer.
151 * @return The instance ID of that instance.
152 */
154
155/**
156 * Get the register base address of an instance.
157 *
158 * @param dt Instance of aon_timer.
159 * @param reg_block The register block requested.
160 * @return The register base address of the requested block.
161 */
164 dt_aon_timer_reg_block_t reg_block);
165
166/**
167 * Get the primary register base address of an instance.
168 *
169 * This is just a convenience function, equivalent to
170 * `dt_aon_timer_reg_block(dt, kDtAonTimerRegBlockCore)`
171 *
172 * @param dt Instance of aon_timer.
173 * @return The register base address of the primary register block.
174 */
175static inline uint32_t dt_aon_timer_primary_reg_block(
176 dt_aon_timer_t dt) {
177 return dt_aon_timer_reg_block(dt, kDtAonTimerRegBlockCore);
178}
179
180/**
181 * Get the base address of a memory.
182 *
183 * @param dt Instance of aon_timer.
184 * @param mem The memory requested.
185 * @return The base address of the requested memory.
186 */
190
191/**
192 * Get the size of a memory.
193 *
194 * @param dt Instance of aon_timer.
195 * @param mem The memory requested.
196 * @return The size of the requested memory.
197 */
201
202/**
203 * Get the PLIC ID of a aon_timer IRQ for a given instance.
204 *
205 * If the instance is not connected to the PLIC, this function
206 * will return `kDtPlicIrqIdNone`.
207 *
208 * @param dt Instance of aon_timer.
209 * @param irq A aon_timer IRQ.
210 * @return The PLIC ID of the IRQ of this instance.
211 */
215
216/**
217 * Convert a global IRQ ID to a local aon_timer IRQ type.
218 *
219 * @param dt Instance of aon_timer.
220 * @param irq A PLIC ID that belongs to this instance.
221 * @return The aon_timer IRQ, or `kDtAonTimerIrqCount`.
222 *
223 * **Note:** This function assumes that the PLIC ID belongs to the instance
224 * of aon_timer passed in parameter. In other words, it must be the case that
225 * `dt_aon_timer_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
226 * will return `kDtAonTimerIrqCount`.
227 */
230 dt_plic_irq_id_t irq);
231
232
233/**
234 * Get the alert ID of a aon_timer alert for a given instance.
235 *
236 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
237 * instances where the instance is not connected, the return value is unspecified.
238 *
239 * @param dt Instance of aon_timer.
240 * @param alert A aon_timer alert.
241 * @return The Alert Handler alert ID of the alert of this instance.
242 */
246
247/**
248 * Convert a global alert ID to a local aon_timer alert type.
249 *
250 * @param dt Instance of aon_timer.
251 * @param alert A global alert ID that belongs to this instance.
252 * @return The aon_timer alert, or `kDtAonTimerAlertCount`.
253 *
254 * **Note:** This function assumes that the global alert ID belongs to the
255 * instance of aon_timer passed in parameter. In other words, it must be the case
256 * that `dt_aon_timer_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
257 * this function will return `kDtAonTimerAlertCount`.
258 */
261 dt_alert_id_t alert);
262
263
264
265/**
266 * Get the clock signal connected to a clock port of an instance.
267 *
268 * @param dt Instance of aon_timer.
269 * @param clk Clock port.
270 * @return Clock signal.
271 */
275
276/**
277 * Get the reset signal connected to a reset port of an instance.
278 *
279 * @param dt Instance of aon_timer.
280 * @param rst Reset port.
281 * @return Reset signal.
282 */
286
287
288
289#ifdef __cplusplus
290} // extern "C"
291#endif // __cplusplus
292
293#endif // OPENTITAN_DT_AON_TIMER_H_