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