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