Software APIs
dt_rv_dm.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_RV_DM_H_
8#define OPENTITAN_DT_RV_DM_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP rv_dm and top earlgrey.
17 *
18 * This file contains the type definitions and global functions of the rv_dm.
19 */
20
21#include "hw/top/dt/dt_api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_rv_dm {
30 kDtRvDm = 0, /**< rv_dm */
31 kDtRvDmFirst = 0, /**< \internal First instance */
32 kDtRvDmCount = 1, /**< \internal Number of instances */
34
35/**
36 * List of register blocks.
37 *
38 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39 */
40typedef enum dt_rv_dm_reg_block {
41 kDtRvDmRegBlockRegs = 0, /**< */
42 kDtRvDmRegBlockMem = 1, /**< */
43 kDtRvDmRegBlockDbg = 2, /**< */
44 kDtRvDmRegBlockCount = 3, /**< \internal Number of register blocks */
46
47/**
48 * List of memories.
49 *
50 * Memories are guaranteed to start at 0 and to be consecutively numbered.
51 */
52typedef enum dt_rv_dm_memory {
53 kDtRvDmMemoryCount = 0, /**< \internal Number of memories */
55
56/** Primary register block (associated with the "primary" set of registers that control the IP). */
57static const dt_rv_dm_reg_block_t kDtRvDmRegBlockPrimary = kDtRvDmRegBlockRegs;
58
59/**
60 * List of Alerts.
61 *
62 * Alerts are guaranteed to be numbered consecutively from 0.
63 */
64typedef enum dt_rv_dm_alert {
65 kDtRvDmAlertFatalFault = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
66 kDtRvDmAlertCount = 1, /**< \internal Number of Alerts */
68
69/**
70 * List of clock ports.
71 *
72 * Clock ports are guaranteed to be numbered consecutively from 0.
73 */
74typedef enum dt_rv_dm_clock {
75 kDtRvDmClockClk = 0, /**< Clock port clk_i */
76 kDtRvDmClockLc = 1, /**< Clock port clk_lc_i */
77 kDtRvDmClockCount = 2, /**< \internal Number of clock ports */
79
80/**
81 * List of reset ports.
82 *
83 * Reset ports are guaranteed to be numbered consecutively from 0.
84 */
85typedef enum dt_rv_dm_reset {
86 kDtRvDmResetRst = 0, /**< Reset port rst_ni */
87 kDtRvDmResetLc = 1, /**< Reset port rst_lc_ni */
88 kDtRvDmResetCount = 2, /**< \internal Number of reset ports */
90
91/**
92 * List of supported hardware features.
93 */
94#define OPENTITAN_RV_DM_HAS_JTAG_FSM 1
95#define OPENTITAN_RV_DM_HAS_JTAG_DTM 1
96#define OPENTITAN_RV_DM_HAS_DBG_DATA_REGS 1
97#define OPENTITAN_RV_DM_HAS_DBG_DMCONTROL_REG 1
98#define OPENTITAN_RV_DM_HAS_DBG_DMSTATUS_REG 1
99#define OPENTITAN_RV_DM_HAS_DBG_HARTINFO_REG 1
100#define OPENTITAN_RV_DM_HAS_DBG_HALTSUM0_REG 1
101#define OPENTITAN_RV_DM_HAS_DBG_ABSTRACT_COMMAND 1
102#define OPENTITAN_RV_DM_HAS_DBG_PROGBUF 1
103#define OPENTITAN_RV_DM_HAS_DBG_SBA 1
104#define OPENTITAN_RV_DM_HAS_DBG_NDM_RESET 1
105#define OPENTITAN_RV_DM_HAS_DBG_GDB 1
106
107
108
109/**
110 * Get the rv_dm instance from an instance ID
111 *
112 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
113 *
114 * @param inst_id Instance ID.
115 * @return A rv_dm instance.
116 *
117 * **Note:** This function only makes sense if the instance ID has device type rv_dm,
118 * otherwise the returned value is unspecified.
119 */
121
122/**
123 * Get the instance ID of an instance.
124 *
125 * @param dt Instance of rv_dm.
126 * @return The instance ID of that instance.
127 */
129
130/**
131 * Get the register base address of an instance.
132 *
133 * @param dt Instance of rv_dm.
134 * @param reg_block The register block requested.
135 * @return The register base address of the requested block.
136 */
137uint32_t dt_rv_dm_reg_block(
138 dt_rv_dm_t dt,
139 dt_rv_dm_reg_block_t reg_block);
140
141/**
142 * Get the primary register base address of an instance.
143 *
144 * This is just a convenience function, equivalent to
145 * `dt_rv_dm_reg_block(dt, kDtRvDmRegBlockRegs)`
146 *
147 * @param dt Instance of rv_dm.
148 * @return The register base address of the primary register block.
149 */
150static inline uint32_t dt_rv_dm_primary_reg_block(
151 dt_rv_dm_t dt) {
152 return dt_rv_dm_reg_block(dt, kDtRvDmRegBlockRegs);
153}
154
155/**
156 * Get the base address of a memory.
157 *
158 * @param dt Instance of rv_dm.
159 * @param mem The memory requested.
160 * @return The base address of the requested memory.
161 */
162uint32_t dt_rv_dm_memory_base(
163 dt_rv_dm_t dt,
165
166/**
167 * Get the size of a memory.
168 *
169 * @param dt Instance of rv_dm.
170 * @param mem The memory requested.
171 * @return The size of the requested memory.
172 */
173uint32_t dt_rv_dm_memory_size(
174 dt_rv_dm_t dt,
176
177
178/**
179 * Get the alert ID of a rv_dm alert for a given instance.
180 *
181 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
182 * instances where the instance is not connected, the return value is unspecified.
183 *
184 * @param dt Instance of rv_dm.
185 * @param alert A rv_dm alert.
186 * @return The Alert Handler alert ID of the alert of this instance.
187 */
189 dt_rv_dm_t dt,
190 dt_rv_dm_alert_t alert);
191
192/**
193 * Convert a global alert ID to a local rv_dm alert type.
194 *
195 * @param dt Instance of rv_dm.
196 * @param alert A global alert ID that belongs to this instance.
197 * @return The rv_dm alert, or `kDtRvDmAlertCount`.
198 *
199 * **Note:** This function assumes that the global alert ID belongs to the
200 * instance of rv_dm passed in parameter. In other words, it must be the case
201 * that `dt_rv_dm_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
202 * this function will return `kDtRvDmAlertCount`.
203 */
205 dt_rv_dm_t dt,
206 dt_alert_id_t alert);
207
208
209
210/**
211 * Get the clock signal connected to a clock port of an instance.
212 *
213 * @param dt Instance of rv_dm.
214 * @param clk Clock port.
215 * @return Clock signal.
216 */
218 dt_rv_dm_t dt,
219 dt_rv_dm_clock_t clk);
220
221/**
222 * Get the reset signal connected to a reset port of an instance.
223 *
224 * @param dt Instance of rv_dm.
225 * @param rst Reset port.
226 * @return Reset signal.
227 */
229 dt_rv_dm_t dt,
230 dt_rv_dm_reset_t rst);
231
232
233
234#ifdef __cplusplus
235} // extern "C"
236#endif // __cplusplus
237
238#endif // OPENTITAN_DT_RV_DM_H_