Software APIs
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 darjeeling.
17 *
18 * This file contains the type definitions and global functions of the alert_handler.
19 */
20
21#include "hw/top/dt/api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_alert_handler {
30 kDtAlertHandlerFirst = 0, /**< First instance */
31 kDtAlertHandler = 0, /**< alert_handler */
33
34enum {
35 kDtAlertHandlerCount = 1, /**< Number of instances */
36};
37
38
39/**
40 * List of register blocks.
41 *
42 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43 */
45 kDtAlertHandlerRegBlockCore = 0, /**< */
47
48enum {
49 kDtAlertHandlerRegBlockCount = 1, /**< Number of register blocks */
50};
51
52
53/** Primary register block (associated with the "primary" set of registers that control the IP). */
54static const dt_alert_handler_reg_block_t kDtAlertHandlerRegBlockPrimary = kDtAlertHandlerRegBlockCore;
55
56/**
57 * List of IRQs.
58 *
59 * IRQs are guaranteed to be numbered consecutively from 0.
60 */
62 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. */
63 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. */
64 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. */
65 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
68enum {
69 kDtAlertHandlerIrqCount = 4, /**< Number of IRQs */
70};
71
72
73/**
74 * List of clock ports.
75 *
76 * Clock ports are guaranteed to be numbered consecutively from 0.
77 */
79 kDtAlertHandlerClockClk = 0, /**< Clock port clk_i */
80 kDtAlertHandlerClockEdn = 1, /**< Clock port clk_edn_i */
82
83enum {
84 kDtAlertHandlerClockCount = 2, /**< Number of clock ports */
85};
86
87
88/**
89 * List of reset ports.
90 *
91 * Reset ports are guaranteed to be numbered consecutively from 0.
92 */
94 kDtAlertHandlerResetRst = 0, /**< Reset port rst_ni */
95 kDtAlertHandlerResetEdn = 1, /**< Reset port rst_edn_ni */
97
98enum {
99 kDtAlertHandlerResetCount = 2, /**< Number of reset ports */
100};
101
102
103/**
104 * List of supported hardware features.
105 */
106#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_OBSERVE 1
107#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_INTERRUPT 1
108#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_ESCALATE 1
109#define OPENTITAN_ALERT_HANDLER_HAS_PING_TIMER 1
110#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_COUNT 1
111#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_TIMEOUT 1
112#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_PHASES 1
113#define OPENTITAN_ALERT_HANDLER_HAS_CRASH_DUMP 1
114
115
116
117/**
118 * Get the alert_handler instance from an instance ID
119 *
120 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
121 *
122 * @param inst_id Instance ID.
123 * @return A alert_handler instance.
124 *
125 * **Note:** This function only makes sense if the instance ID has device type alert_handler,
126 * otherwise the returned value is unspecified.
127 */
129
130/**
131 * Get the instance ID of an instance.
132 *
133 * @param dt Instance of alert_handler.
134 * @return The instance ID of that instance.
135 */
137
138/**
139 * Get the register base address of an instance.
140 *
141 * @param dt Instance of alert_handler.
142 * @param reg_block The register block requested.
143 * @return The register base address of the requested block.
144 */
148
149/**
150 * Get the primary register base address of an instance.
151 *
152 * This is just a convenience function, equivalent to
153 * `dt_alert_handler_reg_block(dt, kDtAlertHandlerRegBlockCore)`
154 *
155 * @param dt Instance of alert_handler.
156 * @return The register base address of the primary register block.
157 */
158static inline uint32_t dt_alert_handler_primary_reg_block(
160 return dt_alert_handler_reg_block(dt, kDtAlertHandlerRegBlockCore);
161}
162
163/**
164 * Get the PLIC ID of a alert_handler IRQ for a given instance.
165 *
166 * If the instance is not connected to the PLIC, this function
167 * will return `kDtPlicIrqIdNone`.
168 *
169 * @param dt Instance of alert_handler.
170 * @param irq A alert_handler IRQ.
171 * @return The PLIC ID of the IRQ of this instance.
172 */
176
177/**
178 * Convert a global IRQ ID to a local alert_handler IRQ type.
179 *
180 * @param dt Instance of alert_handler.
181 * @param irq A PLIC ID that belongs to this instance.
182 * @return The alert_handler IRQ, or `kDtAlertHandlerIrqCount`.
183 *
184 * **Note:** This function assumes that the PLIC ID belongs to the instance
185 * of alert_handler passed in parameter. In other words, it must be the case that
186 * `dt_alert_handler_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
187 * will return `kDtAlertHandlerIrqCount`.
188 */
191 dt_plic_irq_id_t irq);
192
193
194
195
196/**
197 * Get the clock signal connected to a clock port of an instance.
198 *
199 * @param dt Instance of alert_handler.
200 * @param clk Clock port.
201 * @return Clock signal.
202 */
206
207/**
208 * Get the reset signal connected to a reset port of an instance.
209 *
210 * @param dt Instance of alert_handler.
211 * @param rst Reset port.
212 * @return Reset signal.
213 */
217
218
219
220#ifdef __cplusplus
221} // extern "C"
222#endif // __cplusplus
223
224#endif // OPENTITAN_DT_ALERT_HANDLER_H_