Software APIs
dt_pinmux.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_PINMUX_H_
8
#define OPENTITAN_DT_PINMUX_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP pinmux and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the pinmux.
19
*/
20
21
#include "hw/top/dt/dt_api.h"
22
#include <stdint.h>
23
24
25
26
/**
27
* List of instances.
28
*/
29
typedef
enum
dt_pinmux
{
30
kDtPinmuxAon
= 0,
/**< pinmux_aon */
31
kDtPinmuxFirst = 0,
/**< \internal First instance */
32
kDtPinmuxCount = 1,
/**< \internal Number of instances */
33
}
dt_pinmux_t
;
34
35
/**
36
* List of register blocks.
37
*
38
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
39
*/
40
typedef
enum
dt_pinmux_reg_block
{
41
kDtPinmuxRegBlockCore = 0,
/**< */
42
kDtPinmuxRegBlockCount = 1,
/**< \internal Number of register blocks */
43
}
dt_pinmux_reg_block_t
;
44
45
/** Primary register block (associated with the "primary" set of registers that control the IP). */
46
static
const
dt_pinmux_reg_block_t
kDtPinmuxRegBlockPrimary = kDtPinmuxRegBlockCore;
47
48
/**
49
* List of memories.
50
*
51
* Memories are guaranteed to start at 0 and to be consecutively numbered.
52
*/
53
typedef
enum
dt_pinmux_memory
{
54
kDtPinmuxMemoryCount = 0,
/**< \internal Number of memories */
55
}
dt_pinmux_memory_t
;
56
57
/**
58
* List of Alerts.
59
*
60
* Alerts are guaranteed to be numbered consecutively from 0.
61
*/
62
typedef
enum
dt_pinmux_alert
{
63
kDtPinmuxAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
64
kDtPinmuxAlertCount = 1,
/**< \internal Number of Alerts */
65
}
dt_pinmux_alert_t
;
66
67
/**
68
* List of clock ports.
69
*
70
* Clock ports are guaranteed to be numbered consecutively from 0.
71
*/
72
typedef
enum
dt_pinmux_clock
{
73
kDtPinmuxClockClk
= 0,
/**< Clock port clk_i */
74
kDtPinmuxClockAon
= 1,
/**< Clock port clk_aon_i */
75
kDtPinmuxClockCount = 2,
/**< \internal Number of clock ports */
76
}
dt_pinmux_clock_t
;
77
78
/**
79
* List of reset ports.
80
*
81
* Reset ports are guaranteed to be numbered consecutively from 0.
82
*/
83
typedef
enum
dt_pinmux_reset
{
84
kDtPinmuxResetRst
= 0,
/**< Reset port rst_ni */
85
kDtPinmuxResetAon
= 1,
/**< Reset port rst_aon_ni */
86
kDtPinmuxResetSys
= 2,
/**< Reset port rst_sys_ni */
87
kDtPinmuxResetCount = 3,
/**< \internal Number of reset ports */
88
}
dt_pinmux_reset_t
;
89
90
/**
91
* List of wakeups.
92
*
93
* Wakeups are guaranteed to be numbered consecutively from 0.
94
*/
95
typedef
enum
dt_pinmux_wakeup
{
96
kDtPinmuxWakeupPinWkupReq
= 0,
/**< pin wake request */
97
kDtPinmuxWakeupUsbWkupReq
= 1,
/**< usb wake request */
98
kDtPinmuxWakeupCount = 2,
/**< \internal Number of wakeups */
99
}
dt_pinmux_wakeup_t
;
100
101
102
/**
103
* Get the pinmux instance from an instance ID
104
*
105
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
106
*
107
* @param inst_id Instance ID.
108
* @return A pinmux instance.
109
*
110
* **Note:** This function only makes sense if the instance ID has device type pinmux,
111
* otherwise the returned value is unspecified.
112
*/
113
dt_pinmux_t
dt_pinmux_from_instance_id
(
dt_instance_id_t
inst_id);
114
115
/**
116
* Get the instance ID of an instance.
117
*
118
* @param dt Instance of pinmux.
119
* @return The instance ID of that instance.
120
*/
121
dt_instance_id_t
dt_pinmux_instance_id
(
dt_pinmux_t
dt);
122
123
/**
124
* Get the register base address of an instance.
125
*
126
* @param dt Instance of pinmux.
127
* @param reg_block The register block requested.
128
* @return The register base address of the requested block.
129
*/
130
uint32_t
dt_pinmux_reg_block
(
131
dt_pinmux_t
dt,
132
dt_pinmux_reg_block_t
reg_block);
133
134
/**
135
* Get the primary register base address of an instance.
136
*
137
* This is just a convenience function, equivalent to
138
* `dt_pinmux_reg_block(dt, kDtPinmuxRegBlockCore)`
139
*
140
* @param dt Instance of pinmux.
141
* @return The register base address of the primary register block.
142
*/
143
static
inline
uint32_t dt_pinmux_primary_reg_block(
144
dt_pinmux_t
dt) {
145
return
dt_pinmux_reg_block
(dt, kDtPinmuxRegBlockCore);
146
}
147
148
/**
149
* Get the base address of a memory.
150
*
151
* @param dt Instance of pinmux.
152
* @param mem The memory requested.
153
* @return The base address of the requested memory.
154
*/
155
uint32_t
dt_pinmux_memory_base
(
156
dt_pinmux_t
dt,
157
dt_pinmux_memory_t
mem);
158
159
/**
160
* Get the size of a memory.
161
*
162
* @param dt Instance of pinmux.
163
* @param mem The memory requested.
164
* @return The size of the requested memory.
165
*/
166
uint32_t
dt_pinmux_memory_size
(
167
dt_pinmux_t
dt,
168
dt_pinmux_memory_t
mem);
169
170
171
/**
172
* Get the alert ID of a pinmux alert for a given instance.
173
*
174
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
175
* instances where the instance is not connected, the return value is unspecified.
176
*
177
* @param dt Instance of pinmux.
178
* @param alert A pinmux alert.
179
* @return The Alert Handler alert ID of the alert of this instance.
180
*/
181
dt_alert_id_t
dt_pinmux_alert_to_alert_id
(
182
dt_pinmux_t
dt,
183
dt_pinmux_alert_t
alert);
184
185
/**
186
* Convert a global alert ID to a local pinmux alert type.
187
*
188
* @param dt Instance of pinmux.
189
* @param alert A global alert ID that belongs to this instance.
190
* @return The pinmux alert, or `kDtPinmuxAlertCount`.
191
*
192
* **Note:** This function assumes that the global alert ID belongs to the
193
* instance of pinmux passed in parameter. In other words, it must be the case
194
* that `dt_pinmux_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
195
* this function will return `kDtPinmuxAlertCount`.
196
*/
197
dt_pinmux_alert_t
dt_pinmux_alert_from_alert_id
(
198
dt_pinmux_t
dt,
199
dt_alert_id_t
alert);
200
201
202
203
/**
204
* Get the clock signal connected to a clock port of an instance.
205
*
206
* @param dt Instance of pinmux.
207
* @param clk Clock port.
208
* @return Clock signal.
209
*/
210
dt_clock_t
dt_pinmux_clock
(
211
dt_pinmux_t
dt,
212
dt_pinmux_clock_t
clk);
213
214
/**
215
* Get the reset signal connected to a reset port of an instance.
216
*
217
* @param dt Instance of pinmux.
218
* @param rst Reset port.
219
* @return Reset signal.
220
*/
221
dt_reset_t
dt_pinmux_reset
(
222
dt_pinmux_t
dt,
223
dt_pinmux_reset_t
rst);
224
225
226
227
#ifdef __cplusplus
228
}
// extern "C"
229
#endif
// __cplusplus
230
231
#endif
// OPENTITAN_DT_PINMUX_H_
(earlgrey)
hw
top
dt
dt_pinmux.h
Return to
OpenTitan Documentation