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