Software APIs
dt_alert_handler.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_ALERT_HANDLER_H_
8#define OPENTITAN_DT_ALERT_HANDLER_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP alert_handler and top earlgrey.
17 *
18 * This file contains the type definitions and global functions of the alert_handler.
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_alert_handler {
30 kDtAlertHandler = 0, /**< alert_handler */
31 kDtAlertHandlerFirst = 0, /**< \internal First instance */
32 kDtAlertHandlerCount = 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 kDtAlertHandlerRegBlockCore = 0, /**< */
42 kDtAlertHandlerRegBlockCount = 1, /**< \internal Number of register blocks */
44
45/**
46 * List of memories.
47 *
48 * Memories are guaranteed to start at 0 and to be consecutively numbered.
49 */
51 kDtAlertHandlerMemoryCount = 0, /**< \internal Number of memories */
53
54/** Primary register block (associated with the "primary" set of registers that control the IP). */
55static const dt_alert_handler_reg_block_t kDtAlertHandlerRegBlockPrimary = kDtAlertHandlerRegBlockCore;
56
57/**
58 * List of IRQs.
59 *
60 * IRQs are guaranteed to be numbered consecutively from 0.
61 */
63 kDtAlertHandlerIrqClassa = 0, /**< Interrupt state bit of Class A. Set by HW in case an alert within this class triggered. Defaults true, write one to clear. */
64 kDtAlertHandlerIrqClassb = 1, /**< Interrupt state bit of Class B. Set by HW in case an alert within this class triggered. Defaults true, write one to clear. */
65 kDtAlertHandlerIrqClassc = 2, /**< Interrupt state bit of Class C. Set by HW in case an alert within this class triggered. Defaults true, write one to clear. */
66 kDtAlertHandlerIrqClassd = 3, /**< Interrupt state bit of Class D. Set by HW in case an alert within this class triggered. Defaults true, write one to clear. */
67 kDtAlertHandlerIrqCount = 4, /**< \internal Number of IRQs */
69
70/**
71 * List of clock ports.
72 *
73 * Clock ports are guaranteed to be numbered consecutively from 0.
74 */
76 kDtAlertHandlerClockClk = 0, /**< Clock port clk_i */
77 kDtAlertHandlerClockEdn = 1, /**< Clock port clk_edn_i */
78 kDtAlertHandlerClockCount = 2, /**< \internal Number of clock ports */
80
81/**
82 * List of reset ports.
83 *
84 * Reset ports are guaranteed to be numbered consecutively from 0.
85 */
87 kDtAlertHandlerResetRst = 0, /**< Reset port rst_ni */
88 kDtAlertHandlerResetEdn = 1, /**< Reset port rst_edn_ni */
89 kDtAlertHandlerResetCount = 2, /**< \internal Number of reset ports */
91
92/**
93 * List of supported hardware features.
94 */
95#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_OBSERVE 1
96#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_INTERRUPT 1
97#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_ESCALATE 1
98#define OPENTITAN_ALERT_HANDLER_HAS_PING_TIMER 1
99#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_COUNT 1
100#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_TIMEOUT 1
101#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_PHASES 1
102#define OPENTITAN_ALERT_HANDLER_HAS_CRASH_DUMP 1
103
104
105
106/**
107 * Get the alert_handler instance from an instance ID
108 *
109 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
110 *
111 * @param inst_id Instance ID.
112 * @return A alert_handler instance.
113 *
114 * **Note:** This function only makes sense if the instance ID has device type alert_handler,
115 * otherwise the returned value is unspecified.
116 */
118
119/**
120 * Get the instance ID of an instance.
121 *
122 * @param dt Instance of alert_handler.
123 * @return The instance ID of that instance.
124 */
126
127/**
128 * Get the register base address of an instance.
129 *
130 * @param dt Instance of alert_handler.
131 * @param reg_block The register block requested.
132 * @return The register base address of the requested block.
133 */
137
138/**
139 * Get the primary register base address of an instance.
140 *
141 * This is just a convenience function, equivalent to
142 * `dt_alert_handler_reg_block(dt, kDtAlertHandlerRegBlockCore)`
143 *
144 * @param dt Instance of alert_handler.
145 * @return The register base address of the primary register block.
146 */
147static inline uint32_t dt_alert_handler_primary_reg_block(
149 return dt_alert_handler_reg_block(dt, kDtAlertHandlerRegBlockCore);
150}
151
152/**
153 * Get the base address of a memory.
154 *
155 * @param dt Instance of alert_handler.
156 * @param mem The memory requested.
157 * @return The base address of the requested memory.
158 */
162
163/**
164 * Get the size of a memory.
165 *
166 * @param dt Instance of alert_handler.
167 * @param mem The memory requested.
168 * @return The size of the requested memory.
169 */
173
174/**
175 * Get the PLIC ID of a alert_handler IRQ for a given instance.
176 *
177 * If the instance is not connected to the PLIC, this function
178 * will return `kDtPlicIrqIdNone`.
179 *
180 * @param dt Instance of alert_handler.
181 * @param irq A alert_handler IRQ.
182 * @return The PLIC ID of the IRQ of this instance.
183 */
187
188/**
189 * Convert a global IRQ ID to a local alert_handler IRQ type.
190 *
191 * @param dt Instance of alert_handler.
192 * @param irq A PLIC ID that belongs to this instance.
193 * @return The alert_handler IRQ, or `kDtAlertHandlerIrqCount`.
194 *
195 * **Note:** This function assumes that the PLIC ID belongs to the instance
196 * of alert_handler passed in parameter. In other words, it must be the case that
197 * `dt_alert_handler_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
198 * will return `kDtAlertHandlerIrqCount`.
199 */
202 dt_plic_irq_id_t irq);
203
204
205
206
207/**
208 * Get the clock signal connected to a clock port of an instance.
209 *
210 * @param dt Instance of alert_handler.
211 * @param clk Clock port.
212 * @return Clock signal.
213 */
217
218/**
219 * Get the reset signal connected to a reset port of an instance.
220 *
221 * @param dt Instance of alert_handler.
222 * @param rst Reset port.
223 * @return Reset signal.
224 */
228
229
230
231#ifdef __cplusplus
232} // extern "C"
233#endif // __cplusplus
234
235#endif // OPENTITAN_DT_ALERT_HANDLER_H_