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 darjeeling.
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
kDtPinmuxWakeupCount = 1,
/**< \internal Number of wakeups */
85
}
dt_pinmux_wakeup_t
;
86
87
88
/**
89
* Get the pinmux instance from an instance ID
90
*
91
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
92
*
93
* @param inst_id Instance ID.
94
* @return A pinmux instance.
95
*
96
* **Note:** This function only makes sense if the instance ID has device type pinmux,
97
* otherwise the returned value is unspecified.
98
*/
99
dt_pinmux_t
dt_pinmux_from_instance_id
(
dt_instance_id_t
inst_id);
100
101
/**
102
* Get the instance ID of an instance.
103
*
104
* @param dt Instance of pinmux.
105
* @return The instance ID of that instance.
106
*/
107
dt_instance_id_t
dt_pinmux_instance_id
(
dt_pinmux_t
dt);
108
109
/**
110
* Get the register base address of an instance.
111
*
112
* @param dt Instance of pinmux.
113
* @param reg_block The register block requested.
114
* @return The register base address of the requested block.
115
*/
116
uint32_t
dt_pinmux_reg_block
(
117
dt_pinmux_t
dt,
118
dt_pinmux_reg_block_t
reg_block);
119
120
/**
121
* Get the primary register base address of an instance.
122
*
123
* This is just a convenience function, equivalent to
124
* `dt_pinmux_reg_block(dt, kDtPinmuxRegBlockCore)`
125
*
126
* @param dt Instance of pinmux.
127
* @return The register base address of the primary register block.
128
*/
129
static
inline
uint32_t dt_pinmux_primary_reg_block(
130
dt_pinmux_t
dt) {
131
return
dt_pinmux_reg_block
(dt, kDtPinmuxRegBlockCore);
132
}
133
134
135
/**
136
* Get the alert ID of a pinmux alert for a given instance.
137
*
138
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
139
* instances where the instance is not connected, the return value is unspecified.
140
*
141
* @param dt Instance of pinmux.
142
* @param alert A pinmux alert.
143
* @return The Alert Handler alert ID of the alert of this instance.
144
*/
145
dt_alert_id_t
dt_pinmux_alert_to_alert_id
(
146
dt_pinmux_t
dt,
147
dt_pinmux_alert_t
alert);
148
149
/**
150
* Convert a global alert ID to a local pinmux alert type.
151
*
152
* @param dt Instance of pinmux.
153
* @param alert A global alert ID that belongs to this instance.
154
* @return The pinmux alert, or `kDtPinmuxAlertCount`.
155
*
156
* **Note:** This function assumes that the global alert ID belongs to the
157
* instance of pinmux passed in parameter. In other words, it must be the case
158
* that `dt_pinmux_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
159
* this function will return `kDtPinmuxAlertCount`.
160
*/
161
dt_pinmux_alert_t
dt_pinmux_alert_from_alert_id
(
162
dt_pinmux_t
dt,
163
dt_alert_id_t
alert);
164
165
166
167
/**
168
* Get the clock signal connected to a clock port of an instance.
169
*
170
* @param dt Instance of pinmux.
171
* @param clk Clock port.
172
* @return Clock signal.
173
*/
174
dt_clock_t
dt_pinmux_clock
(
175
dt_pinmux_t
dt,
176
dt_pinmux_clock_t
clk);
177
178
/**
179
* Get the reset signal connected to a reset port of an instance.
180
*
181
* @param dt Instance of pinmux.
182
* @param rst Reset port.
183
* @return Reset signal.
184
*/
185
dt_reset_t
dt_pinmux_reset
(
186
dt_pinmux_t
dt,
187
dt_pinmux_reset_t
rst);
188
189
190
191
#endif
// OPENTITAN_DT_PINMUX_H_
(darjeeling)
hw
top
dt
dt_pinmux.h
Return to
OpenTitan Documentation