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