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 "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/** Primary register block (associated with the "primary" set of registers that control the IP). */
46static const dt_alert_handler_reg_block_t kDtAlertHandlerRegBlockPrimary = kDtAlertHandlerRegBlockCore;
47
48/**
49 * List of IRQs.
50 *
51 * IRQs are guaranteed to be numbered consecutively from 0.
52 */
54 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. */
55 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. */
56 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. */
57 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. */
58 kDtAlertHandlerIrqCount = 4, /**< \internal Number of IRQs */
60
61/**
62 * List of clock ports.
63 *
64 * Clock ports are guaranteed to be numbered consecutively from 0.
65 */
67 kDtAlertHandlerClockClk = 0, /**< Clock port clk_i */
68 kDtAlertHandlerClockEdn = 1, /**< Clock port clk_edn_i */
69 kDtAlertHandlerClockCount = 2, /**< \internal Number of clock ports */
71
72/**
73 * List of reset ports.
74 *
75 * Reset ports are guaranteed to be numbered consecutively from 0.
76 */
78 kDtAlertHandlerResetRst = 0, /**< Reset port rst_ni */
79 kDtAlertHandlerResetEdn = 1, /**< Reset port rst_edn_ni */
80 kDtAlertHandlerResetCount = 2, /**< \internal Number of reset ports */
82
83/**
84 * List of supported hardware features.
85 */
86#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_OBSERVE 1
87#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_INTERRUPT 1
88#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_ESCALATE 1
89#define OPENTITAN_ALERT_HANDLER_HAS_PING_TIMER 1
90#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_COUNT 1
91#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_TIMEOUT 1
92#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_PHASES 1
93#define OPENTITAN_ALERT_HANDLER_HAS_CRASH_DUMP 1
94
95
96
97/**
98 * Get the alert_handler instance from an instance ID
99 *
100 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
101 *
102 * @param inst_id Instance ID.
103 * @return A alert_handler instance.
104 *
105 * **Note:** This function only makes sense if the instance ID has device type alert_handler,
106 * otherwise the returned value is unspecified.
107 */
109
110/**
111 * Get the instance ID of an instance.
112 *
113 * @param dt Instance of alert_handler.
114 * @return The instance ID of that instance.
115 */
117
118/**
119 * Get the register base address of an instance.
120 *
121 * @param dt Instance of alert_handler.
122 * @param reg_block The register block requested.
123 * @return The register base address of the requested block.
124 */
128
129/**
130 * Get the primary register base address of an instance.
131 *
132 * This is just a convenience function, equivalent to
133 * `dt_alert_handler_reg_block(dt, kDtAlertHandlerRegBlockCore)`
134 *
135 * @param dt Instance of alert_handler.
136 * @return The register base address of the primary register block.
137 */
138static inline uint32_t dt_alert_handler_primary_reg_block(
140 return dt_alert_handler_reg_block(dt, kDtAlertHandlerRegBlockCore);
141}
142
143/**
144 * Get the PLIC ID of a alert_handler IRQ for a given instance.
145 *
146 * If the instance is not connected to the PLIC, this function
147 * will return `kDtPlicIrqIdNone`.
148 *
149 * @param dt Instance of alert_handler.
150 * @param irq A alert_handler IRQ.
151 * @return The PLIC ID of the IRQ of this instance.
152 */
156
157/**
158 * Convert a global IRQ ID to a local alert_handler IRQ type.
159 *
160 * @param dt Instance of alert_handler.
161 * @param irq A PLIC ID that belongs to this instance.
162 * @return The alert_handler IRQ, or `kDtAlertHandlerIrqCount`.
163 *
164 * **Note:** This function assumes that the PLIC ID belongs to the instance
165 * of alert_handler passed in parameter. In other words, it must be the case that
166 * `dt_alert_handler_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
167 * will return `kDtAlertHandlerIrqCount`.
168 */
171 dt_plic_irq_id_t irq);
172
173
174
175
176/**
177 * Get the clock signal connected to a clock port of an instance.
178 *
179 * @param dt Instance of alert_handler.
180 * @param clk Clock port.
181 * @return Clock signal.
182 */
186
187/**
188 * Get the reset signal connected to a reset port of an instance.
189 *
190 * @param dt Instance of alert_handler.
191 * @param rst Reset port.
192 * @return Reset signal.
193 */
197
198
199
200#ifdef __cplusplus
201} // extern "C"
202#endif // __cplusplus
203
204#endif // OPENTITAN_DT_ALERT_HANDLER_H_