Software APIs
rv_plic.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_PLIC_H_
8#define OPENTITAN_DT_RV_PLIC_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP rv_plic and top darjeeling.
17 *
18 * This file contains the type definitions and global functions of the rv_plic.
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_rv_plic {
30 kDtRvPlicFirst = 0, /**< First instance */
31 kDtRvPlic = 0, /**< rv_plic */
33
34enum {
35 kDtRvPlicCount = 1, /**< Number of instances */
36};
37
38
39/**
40 * List of register blocks.
41 *
42 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43 */
45 kDtRvPlicRegBlockCore = 0, /**< */
47
48enum {
49 kDtRvPlicRegBlockCount = 1, /**< Number of register blocks */
50};
51
52
53/** Primary register block (associated with the "primary" set of registers that control the IP). */
54static const dt_rv_plic_reg_block_t kDtRvPlicRegBlockPrimary = kDtRvPlicRegBlockCore;
55
56/**
57 * List of Alerts.
58 *
59 * Alerts are guaranteed to be numbered consecutively from 0.
60 */
61typedef enum dt_rv_plic_alert {
62 kDtRvPlicAlertFatalFault = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
64
65enum {
66 kDtRvPlicAlertCount = 1, /**< Number of Alerts */
67};
68
69
70/**
71 * List of clock ports.
72 *
73 * Clock ports are guaranteed to be numbered consecutively from 0.
74 */
75typedef enum dt_rv_plic_clock {
76 kDtRvPlicClockClk = 0, /**< Clock port clk_i */
78
79enum {
80 kDtRvPlicClockCount = 1, /**< Number of clock ports */
81};
82
83
84/**
85 * List of reset ports.
86 *
87 * Reset ports are guaranteed to be numbered consecutively from 0.
88 */
89typedef enum dt_rv_plic_reset {
90 kDtRvPlicResetRst = 0, /**< Reset port rst_ni */
92
93enum {
94 kDtRvPlicResetCount = 1, /**< Number of reset ports */
95};
96
97
98/**
99 * List of supported hardware features.
100 */
101#define OPENTITAN_RV_PLIC_HAS_PRIORITY 1
102#define OPENTITAN_RV_PLIC_HAS_ENABLE 1
103
104
105
106/**
107 * Get the rv_plic instance from an instance ID
108 *
109 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
110 *
111 * @param inst_id Instance ID.
112 * @return A rv_plic instance.
113 *
114 * **Note:** This function only makes sense if the instance ID has device type rv_plic,
115 * otherwise the returned value is unspecified.
116 */
118
119/**
120 * Get the instance ID of an instance.
121 *
122 * @param dt Instance of rv_plic.
123 * @return The instance ID of that instance.
124 */
126
127/**
128 * Get the register base address of an instance.
129 *
130 * @param dt Instance of rv_plic.
131 * @param reg_block The register block requested.
132 * @return The register base address of the requested block.
133 */
134uint32_t dt_rv_plic_reg_block(
135 dt_rv_plic_t dt,
136 dt_rv_plic_reg_block_t reg_block);
137
138/**
139 * Get the primary register base address of an instance.
140 *
141 * This is just a convenience function, equivalent to
142 * `dt_rv_plic_reg_block(dt, kDtRvPlicRegBlockCore)`
143 *
144 * @param dt Instance of rv_plic.
145 * @return The register base address of the primary register block.
146 */
147static inline uint32_t dt_rv_plic_primary_reg_block(
148 dt_rv_plic_t dt) {
149 return dt_rv_plic_reg_block(dt, kDtRvPlicRegBlockCore);
150}
151
152
153/**
154 * Get the alert ID of a rv_plic alert for a given instance.
155 *
156 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
157 * instances where the instance is not connected, the return value is unspecified.
158 *
159 * @param dt Instance of rv_plic.
160 * @param alert A rv_plic alert.
161 * @return The Alert Handler alert ID of the alert of this instance.
162 */
164 dt_rv_plic_t dt,
165 dt_rv_plic_alert_t alert);
166
167/**
168 * Convert a global alert ID to a local rv_plic alert type.
169 *
170 * @param dt Instance of rv_plic.
171 * @param alert A global alert ID that belongs to this instance.
172 * @return The rv_plic alert, or `kDtRvPlicAlertCount`.
173 *
174 * **Note:** This function assumes that the global alert ID belongs to the
175 * instance of rv_plic passed in parameter. In other words, it must be the case
176 * that `dt_rv_plic_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
177 * this function will return `kDtRvPlicAlertCount`.
178 */
180 dt_rv_plic_t dt,
181 dt_alert_id_t alert);
182
183
184
185/**
186 * Get the clock signal connected to a clock port of an instance.
187 *
188 * @param dt Instance of rv_plic.
189 * @param clk Clock port.
190 * @return Clock signal.
191 */
193 dt_rv_plic_t dt,
195
196/**
197 * Get the reset signal connected to a reset port of an instance.
198 *
199 * @param dt Instance of rv_plic.
200 * @param rst Reset port.
201 * @return Reset signal.
202 */
204 dt_rv_plic_t dt,
206
207
208
209#ifdef __cplusplus
210} // extern "C"
211#endif // __cplusplus
212
213#endif // OPENTITAN_DT_RV_PLIC_H_