Software APIs
dt_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 earlgrey.
17 *
18 * This file contains the type definitions and global functions of the rv_plic.
19 */
20
21#include "dt_api.h"
22#include <stdint.h>
23
24
25
26/**
27 * List of instances.
28 */
29typedef enum dt_rv_plic {
30 kDtRvPlic = 0, /**< rv_plic */
31 kDtRvPlicFirst = 0, /**< \internal First instance */
32 kDtRvPlicCount = 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 */
41 kDtRvPlicRegBlockCore = 0, /**< */
42 kDtRvPlicRegBlockCount = 1, /**< \internal Number of register blocks */
44
45/** Primary register block (associated with the "primary" set of registers that control the IP). */
46static const dt_rv_plic_reg_block_t kDtRvPlicRegBlockPrimary = kDtRvPlicRegBlockCore;
47
48/**
49 * List of Alerts.
50 *
51 * Alerts are guaranteed to be numbered consecutively from 0.
52 */
53typedef enum dt_rv_plic_alert {
54 kDtRvPlicAlertFatalFault = 0, /**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
55 kDtRvPlicAlertCount = 1, /**< \internal Number of Alerts */
57
58/**
59 * List of clock ports.
60 *
61 * Clock ports are guaranteed to be numbered consecutively from 0.
62 */
63typedef enum dt_rv_plic_clock {
64 kDtRvPlicClockClk = 0, /**< Clock port clk_i */
65 kDtRvPlicClockCount = 1, /**< \internal Number of clock ports */
67
68/**
69 * List of reset ports.
70 *
71 * Reset ports are guaranteed to be numbered consecutively from 0.
72 */
73typedef enum dt_rv_plic_reset {
74 kDtRvPlicResetRst = 0, /**< Reset port rst_ni */
75 kDtRvPlicResetCount = 1, /**< \internal Number of reset ports */
77
78/**
79 * List of supported hardware features.
80 */
81#define OPENTITAN_RV_PLIC_HAS_PRIORITY 1
82#define OPENTITAN_RV_PLIC_HAS_ENABLE 1
83
84
85
86/**
87 * Get the rv_plic instance from an instance ID
88 *
89 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
90 *
91 * @param inst_id Instance ID.
92 * @return A rv_plic instance.
93 *
94 * **Note:** This function only makes sense if the instance ID has device type rv_plic,
95 * otherwise the returned value is unspecified.
96 */
98
99/**
100 * Get the instance ID of an instance.
101 *
102 * @param dt Instance of rv_plic.
103 * @return The instance ID of that instance.
104 */
106
107/**
108 * Get the register base address of an instance.
109 *
110 * @param dt Instance of rv_plic.
111 * @param reg_block The register block requested.
112 * @return The register base address of the requested block.
113 */
114uint32_t dt_rv_plic_reg_block(
115 dt_rv_plic_t dt,
116 dt_rv_plic_reg_block_t reg_block);
117
118/**
119 * Get the primary register base address of an instance.
120 *
121 * This is just a convenience function, equivalent to
122 * `dt_rv_plic_reg_block(dt, kDtRvPlicRegBlockCore)`
123 *
124 * @param dt Instance of rv_plic.
125 * @return The register base address of the primary register block.
126 */
127static inline uint32_t dt_rv_plic_primary_reg_block(
128 dt_rv_plic_t dt) {
129 return dt_rv_plic_reg_block(dt, kDtRvPlicRegBlockCore);
130}
131
132
133/**
134 * Get the alert ID of a rv_plic alert for a given instance.
135 *
136 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
137 * instances where the instance is not connected, the return value is unspecified.
138 *
139 * @param dt Instance of rv_plic.
140 * @param alert A rv_plic alert.
141 * @return The Alert Handler alert ID of the alert of this instance.
142 */
144 dt_rv_plic_t dt,
145 dt_rv_plic_alert_t alert);
146
147/**
148 * Convert a global alert ID to a local rv_plic alert type.
149 *
150 * @param dt Instance of rv_plic.
151 * @param alert A global alert ID that belongs to this instance.
152 * @return The rv_plic alert, or `kDtRvPlicAlertCount`.
153 *
154 * **Note:** This function assumes that the global alert ID belongs to the
155 * instance of rv_plic passed in parameter. In other words, it must be the case
156 * that `dt_rv_plic_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
157 * this function will return `kDtRvPlicAlertCount`.
158 */
160 dt_rv_plic_t dt,
161 dt_alert_id_t alert);
162
163
164
165/**
166 * Get the clock signal connected to a clock port of an instance.
167 *
168 * @param dt Instance of rv_plic.
169 * @param clk Clock port.
170 * @return Clock signal.
171 */
173 dt_rv_plic_t dt,
175
176/**
177 * Get the reset signal connected to a reset port of an instance.
178 *
179 * @param dt Instance of rv_plic.
180 * @param rst Reset port.
181 * @return Reset signal.
182 */
184 dt_rv_plic_t dt,
186
187
188
189#ifdef __cplusplus
190} // extern "C"
191#endif // __cplusplus
192
193#endif // OPENTITAN_DT_RV_PLIC_H_