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