Software APIs
mbx.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_MBX_H_
8#define OPENTITAN_DT_MBX_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP mbx and top darjeeling.
17 *
18 * This file contains the type definitions and global functions of the mbx.
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_mbx {
30 kDtMbxFirst = 0, /**< First instance */
31 kDtMbx0 = 0, /**< mbx0 */
32 kDtMbx1 = 1, /**< mbx1 */
33 kDtMbx2 = 2, /**< mbx2 */
34 kDtMbx3 = 3, /**< mbx3 */
35 kDtMbx4 = 4, /**< mbx4 */
36 kDtMbx5 = 5, /**< mbx5 */
37 kDtMbx6 = 6, /**< mbx6 */
38 kDtMbxJtag = 7, /**< mbx_jtag */
39 kDtMbxPcie0 = 8, /**< mbx_pcie0 */
40 kDtMbxPcie1 = 9, /**< mbx_pcie1 */
42
43enum {
44 kDtMbxCount = 10, /**< Number of instances */
45};
46
47
48/**
49 * List of register blocks.
50 *
51 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
52 */
53typedef enum dt_mbx_reg_block {
54 kDtMbxRegBlockCore = 0, /**< */
55 kDtMbxRegBlockSoc = 1, /**< */
57
58enum {
59 kDtMbxRegBlockCount = 2, /**< Number of register blocks */
60};
61
62
63/** Primary register block (associated with the "primary" set of registers that control the IP). */
64static const dt_mbx_reg_block_t kDtMbxRegBlockPrimary = kDtMbxRegBlockCore;
65
66/**
67 * List of IRQs.
68 *
69 * IRQs are guaranteed to be numbered consecutively from 0.
70 */
71typedef enum dt_mbx_irq {
72 kDtMbxIrqMbxReady = 0, /**< A new object was received in the inbound mailbox. */
73 kDtMbxIrqMbxAbort = 1, /**< An abort request was received from the requester. */
74 kDtMbxIrqMbxError = 2, /**< The mailbox instance generated an error. */
76
77enum {
78 kDtMbxIrqCount = 3, /**< Number of IRQs */
79};
80
81
82/**
83 * List of Alerts.
84 *
85 * Alerts are guaranteed to be numbered consecutively from 0.
86 */
87typedef enum dt_mbx_alert {
88 kDtMbxAlertFatalFault = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
89 kDtMbxAlertRecovFault = 1, /**< This recoverable alert is triggered when memory with invalid ECC (e.g., uninitialized memory) or at an invalid address is accessed. */
91
92enum {
93 kDtMbxAlertCount = 2, /**< Number of Alerts */
94};
95
96
97/**
98 * List of clock ports.
99 *
100 * Clock ports are guaranteed to be numbered consecutively from 0.
101 */
102typedef enum dt_mbx_clock {
103 kDtMbxClockClk = 0, /**< Clock port clk_i */
105
106enum {
107 kDtMbxClockCount = 1, /**< Number of clock ports */
108};
109
110
111/**
112 * List of reset ports.
113 *
114 * Reset ports are guaranteed to be numbered consecutively from 0.
115 */
116typedef enum dt_mbx_reset {
117 kDtMbxResetRst = 0, /**< Reset port rst_ni */
119
120enum {
121 kDtMbxResetCount = 1, /**< Number of reset ports */
122};
123
124
125
126/**
127 * Get the mbx instance from an instance ID
128 *
129 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
130 *
131 * @param inst_id Instance ID.
132 * @return A mbx instance.
133 *
134 * **Note:** This function only makes sense if the instance ID has device type mbx,
135 * otherwise the returned value is unspecified.
136 */
138
139/**
140 * Get the instance ID of an instance.
141 *
142 * @param dt Instance of mbx.
143 * @return The instance ID of that instance.
144 */
146
147/**
148 * Get the register base address of an instance.
149 *
150 * @param dt Instance of mbx.
151 * @param reg_block The register block requested.
152 * @return The register base address of the requested block.
153 */
154uint32_t dt_mbx_reg_block(
155 dt_mbx_t dt,
156 dt_mbx_reg_block_t reg_block);
157
158/**
159 * Get the primary register base address of an instance.
160 *
161 * This is just a convenience function, equivalent to
162 * `dt_mbx_reg_block(dt, kDtMbxRegBlockCore)`
163 *
164 * @param dt Instance of mbx.
165 * @return The register base address of the primary register block.
166 */
167static inline uint32_t dt_mbx_primary_reg_block(
168 dt_mbx_t dt) {
169 return dt_mbx_reg_block(dt, kDtMbxRegBlockCore);
170}
171
172/**
173 * Get the PLIC ID of a mbx IRQ for a given instance.
174 *
175 * If the instance is not connected to the PLIC, this function
176 * will return `kDtPlicIrqIdNone`.
177 *
178 * @param dt Instance of mbx.
179 * @param irq A mbx IRQ.
180 * @return The PLIC ID of the IRQ of this instance.
181 */
183 dt_mbx_t dt,
184 dt_mbx_irq_t irq);
185
186/**
187 * Convert a global IRQ ID to a local mbx IRQ type.
188 *
189 * @param dt Instance of mbx.
190 * @param irq A PLIC ID that belongs to this instance.
191 * @return The mbx IRQ, or `kDtMbxIrqCount`.
192 *
193 * **Note:** This function assumes that the PLIC ID belongs to the instance
194 * of mbx passed in parameter. In other words, it must be the case that
195 * `dt_mbx_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
196 * will return `kDtMbxIrqCount`.
197 */
199 dt_mbx_t dt,
200 dt_plic_irq_id_t irq);
201
202
203/**
204 * Get the alert ID of a mbx alert for a given instance.
205 *
206 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
207 * instances where the instance is not connected, the return value is unspecified.
208 *
209 * @param dt Instance of mbx.
210 * @param alert A mbx alert.
211 * @return The Alert Handler alert ID of the alert of this instance.
212 */
214 dt_mbx_t dt,
215 dt_mbx_alert_t alert);
216
217/**
218 * Convert a global alert ID to a local mbx alert type.
219 *
220 * @param dt Instance of mbx.
221 * @param alert A global alert ID that belongs to this instance.
222 * @return The mbx alert, or `kDtMbxAlertCount`.
223 *
224 * **Note:** This function assumes that the global alert ID belongs to the
225 * instance of mbx passed in parameter. In other words, it must be the case
226 * that `dt_mbx_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
227 * this function will return `kDtMbxAlertCount`.
228 */
230 dt_mbx_t dt,
231 dt_alert_id_t alert);
232
233
234
235/**
236 * Get the clock signal connected to a clock port of an instance.
237 *
238 * @param dt Instance of mbx.
239 * @param clk Clock port.
240 * @return Clock signal.
241 */
243 dt_mbx_t dt,
244 dt_mbx_clock_t clk);
245
246/**
247 * Get the reset signal connected to a reset port of an instance.
248 *
249 * @param dt Instance of mbx.
250 * @param rst Reset port.
251 * @return Reset signal.
252 */
254 dt_mbx_t dt,
255 dt_mbx_reset_t rst);
256
257
258
259#ifdef __cplusplus
260} // extern "C"
261#endif // __cplusplus
262
263#endif // OPENTITAN_DT_MBX_H_