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