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