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/**
11 * @file
12 * @brief Device Tables (DT) for IP alert_handler and top earlgrey.
13 *
14 * This file contains the type definitions and global functions of the alert_handler.
15 */
16
17#include "dt_api.h"
18#include <stdint.h>
19
20/**
21 * List of instances.
22 */
23typedef enum dt_alert_handler {
24 kDtAlertHandler = 0, /**< alert_handler */
25 kDtAlertHandlerFirst = 0, /**< \internal First instance */
26 kDtAlertHandlerCount = 1, /**< \internal Number of instances */
28
29/**
30 * List of register blocks.
31 *
32 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
33 */
35 kDtAlertHandlerRegBlockCore = 0, /**< */
36 kDtAlertHandlerRegBlockCount = 1, /**< \internal Number of register blocks */
38
39/** Primary register block (associated with the "primary" set of registers that control the IP). */
40static const dt_alert_handler_reg_block_t kDtAlertHandlerRegBlockPrimary = kDtAlertHandlerRegBlockCore;
41
42/**
43 * List of IRQs.
44 *
45 * IRQs are guaranteed to be numbered consecutively from 0.
46 */
48 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. */
49 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. */
50 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. */
51 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. */
52 kDtAlertHandlerIrqCount = 4, /**< \internal Number of IRQs */
54
55/**
56 * List of clock ports.
57 *
58 * Clock ports are guaranteed to be numbered consecutively from 0.
59 */
61 kDtAlertHandlerClockClk = 0, /**< Clock port clk_i */
62 kDtAlertHandlerClockEdn = 1, /**< Clock port clk_edn_i */
63 kDtAlertHandlerClockCount = 2, /**< \internal Number of clock ports */
65
66/**
67 * List of reset ports.
68 *
69 * Reset ports are guaranteed to be numbered consecutively from 0.
70 */
72 kDtAlertHandlerResetRst = 0, /**< Reset port rst_ni */
73 kDtAlertHandlerResetEdn = 1, /**< Reset port rst_edn_ni */
74 kDtAlertHandlerResetCount = 2, /**< \internal Number of reset ports */
76
77/**
78 * List of supported hardware features.
79 */
80#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_OBSERVE 1
81#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_INTERRUPT 1
82#define OPENTITAN_ALERT_HANDLER_HAS_ALERT_ESCALATE 1
83#define OPENTITAN_ALERT_HANDLER_HAS_PING_TIMER 1
84#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_COUNT 1
85#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_TIMEOUT 1
86#define OPENTITAN_ALERT_HANDLER_HAS_ESCALATION_PHASES 1
87#define OPENTITAN_ALERT_HANDLER_HAS_CRASH_DUMP 1
88
89
90
91/**
92 * Get the alert_handler instance from an instance ID
93 *
94 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
95 *
96 * @param inst_id Instance ID.
97 * @return A alert_handler instance.
98 *
99 * **Note:** This function only makes sense if the instance ID has device type alert_handler,
100 * otherwise the returned value is unspecified.
101 */
103
104/**
105 * Get the instance ID of an instance.
106 *
107 * @param dt Instance of alert_handler.
108 * @return The instance ID of that instance.
109 */
111
112/**
113 * Get the register base address of an instance.
114 *
115 * @param dt Instance of alert_handler.
116 * @param reg_block The register block requested.
117 * @return The register base address of the requested block.
118 */
122
123/**
124 * Get the primary register base address of an instance.
125 *
126 * This is just a convenience function, equivalent to
127 * `dt_alert_handler_reg_block(dt, kDtAlertHandlerRegBlockCore)`
128 *
129 * @param dt Instance of alert_handler.
130 * @return The register base address of the primary register block.
131 */
132static inline uint32_t dt_alert_handler_primary_reg_block(
134 return dt_alert_handler_reg_block(dt, kDtAlertHandlerRegBlockCore);
135}
136
137/**
138 * Get the PLIC ID of a alert_handler IRQ for a given instance.
139 *
140 * If the instance is not connected to the PLIC, this function
141 * will return `kDtPlicIrqIdNone`.
142 *
143 * @param dt Instance of alert_handler.
144 * @param irq A alert_handler IRQ.
145 * @return The PLIC ID of the IRQ of this instance.
146 */
150
151/**
152 * Convert a global IRQ ID to a local alert_handler IRQ type.
153 *
154 * @param dt Instance of alert_handler.
155 * @param irq A PLIC ID that belongs to this instance.
156 * @return The alert_handler IRQ, or `kDtAlertHandlerIrqCount`.
157 *
158 * **Note:** This function assumes that the PLIC ID belongs to the instance
159 * of alert_handler passed in parameter. In other words, it must be the case that
160 * `dt_alert_handler_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
161 * will return `kDtAlertHandlerIrqCount`.
162 */
165 dt_plic_irq_id_t irq);
166
167
168
169
170/**
171 * Get the clock signal connected to a clock port of an instance.
172 *
173 * @param dt Instance of alert_handler.
174 * @param clk Clock port.
175 * @return Clock signal.
176 */
180
181/**
182 * Get the reset signal connected to a reset port of an instance.
183 *
184 * @param dt Instance of alert_handler.
185 * @param rst Reset port.
186 * @return Reset signal.
187 */
191
192
193
194#endif // OPENTITAN_DT_ALERT_HANDLER_H_