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