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