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