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