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 earlgrey.
17 *
18 * This file contains the type definitions and global functions of the pinmux.
19 */
20
21#include "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 Alerts.
50 *
51 * Alerts are guaranteed to be numbered consecutively from 0.
52 */
53typedef 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 */
57
58/**
59 * List of clock ports.
60 *
61 * Clock ports are guaranteed to be numbered consecutively from 0.
62 */
63typedef 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 */
68
69/**
70 * List of reset ports.
71 *
72 * Reset ports are guaranteed to be numbered consecutively from 0.
73 */
74typedef enum dt_pinmux_reset {
75 kDtPinmuxResetRst = 0, /**< Reset port rst_ni */
76 kDtPinmuxResetAon = 1, /**< Reset port rst_aon_ni */
77 kDtPinmuxResetSys = 2, /**< Reset port rst_sys_ni */
78 kDtPinmuxResetCount = 3, /**< \internal Number of reset ports */
80
81/**
82 * List of wakeups.
83 *
84 * Wakeups are guaranteed to be numbered consecutively from 0.
85 */
86typedef enum dt_pinmux_wakeup {
87 kDtPinmuxWakeupPinWkupReq = 0, /**< pin wake request */
88 kDtPinmuxWakeupUsbWkupReq = 1, /**< usb wake request */
89 kDtPinmuxWakeupCount = 2, /**< \internal Number of wakeups */
91
92
93/**
94 * Get the pinmux instance from an instance ID
95 *
96 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
97 *
98 * @param inst_id Instance ID.
99 * @return A pinmux instance.
100 *
101 * **Note:** This function only makes sense if the instance ID has device type pinmux,
102 * otherwise the returned value is unspecified.
103 */
105
106/**
107 * Get the instance ID of an instance.
108 *
109 * @param dt Instance of pinmux.
110 * @return The instance ID of that instance.
111 */
113
114/**
115 * Get the register base address of an instance.
116 *
117 * @param dt Instance of pinmux.
118 * @param reg_block The register block requested.
119 * @return The register base address of the requested block.
120 */
121uint32_t dt_pinmux_reg_block(
122 dt_pinmux_t dt,
123 dt_pinmux_reg_block_t reg_block);
124
125/**
126 * Get the primary register base address of an instance.
127 *
128 * This is just a convenience function, equivalent to
129 * `dt_pinmux_reg_block(dt, kDtPinmuxRegBlockCore)`
130 *
131 * @param dt Instance of pinmux.
132 * @return The register base address of the primary register block.
133 */
134static inline uint32_t dt_pinmux_primary_reg_block(
135 dt_pinmux_t dt) {
136 return dt_pinmux_reg_block(dt, kDtPinmuxRegBlockCore);
137}
138
139
140/**
141 * Get the alert ID of a pinmux alert for a given instance.
142 *
143 * **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
144 * instances where the instance is not connected, the return value is unspecified.
145 *
146 * @param dt Instance of pinmux.
147 * @param alert A pinmux alert.
148 * @return The Alert Handler alert ID of the alert of this instance.
149 */
151 dt_pinmux_t dt,
152 dt_pinmux_alert_t alert);
153
154/**
155 * Convert a global alert ID to a local pinmux alert type.
156 *
157 * @param dt Instance of pinmux.
158 * @param alert A global alert ID that belongs to this instance.
159 * @return The pinmux alert, or `kDtPinmuxAlertCount`.
160 *
161 * **Note:** This function assumes that the global alert ID belongs to the
162 * instance of pinmux passed in parameter. In other words, it must be the case
163 * that `dt_pinmux_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
164 * this function will return `kDtPinmuxAlertCount`.
165 */
167 dt_pinmux_t dt,
168 dt_alert_id_t alert);
169
170
171
172/**
173 * Get the clock signal connected to a clock port of an instance.
174 *
175 * @param dt Instance of pinmux.
176 * @param clk Clock port.
177 * @return Clock signal.
178 */
180 dt_pinmux_t dt,
182
183/**
184 * Get the reset signal connected to a reset port of an instance.
185 *
186 * @param dt Instance of pinmux.
187 * @param rst Reset port.
188 * @return Reset signal.
189 */
191 dt_pinmux_t dt,
193
194
195
196#ifdef __cplusplus
197} // extern "C"
198#endif // __cplusplus
199
200#endif // OPENTITAN_DT_PINMUX_H_