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 */
23typedef enum dt_pinmux {
24 kDtPinmuxAon = 0, /**< pinmux_aon */
25 kDtPinmuxFirst = 0, /**< \internal First instance */
26 kDtPinmuxCount = 1, /**< \internal Number of instances */
28
29/**
30 * List of register blocks.
31 *
32 * Register blocks are guaranteed to start at 0 and to be consecutively numbered.
33 */
34typedef enum dt_pinmux_reg_block {
35 kDtPinmuxRegBlockCore = 0, /**< */
36 kDtPinmuxRegBlockCount = 1, /**< \internal Number of register blocks */
38
39/** Primary register block (associated with the "primary" set of registers that control the IP). */
40static 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 */
47typedef 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 */
51
52/**
53 * List of clock ports.
54 *
55 * Clock ports are guaranteed to be numbered consecutively from 0.
56 */
57typedef 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 */
62
63/**
64 * List of reset ports.
65 *
66 * Reset ports are guaranteed to be numbered consecutively from 0.
67 */
68typedef 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 */
74
75/**
76 * List of wakeups.
77 *
78 * Wakeups are guaranteed to be numbered consecutively from 0.
79 */
80typedef enum dt_pinmux_wakeup {
81 kDtPinmuxWakeupPinWkupReq = 0, /**< pin wake request */
82 kDtPinmuxWakeupCount = 1, /**< \internal Number of wakeups */
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 */
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 */
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 */
114uint32_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 */
127static 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 */
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 */
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 */
173 dt_pinmux_t dt,
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 */
184 dt_pinmux_t dt,
186
187
188
189#endif // OPENTITAN_DT_PINMUX_H_