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