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 englishbreakfast.
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/**
46 * List of memories.
47 *
48 * Memories are guaranteed to start at 0 and to be consecutively numbered.
49 */
50typedef enum dt_pinmux_memory {
51 kDtPinmuxMemoryCount = 0, /**< \internal Number of memories */
53
54/** Primary register block (associated with the "primary" set of registers that control the IP). */
55static const dt_pinmux_reg_block_t kDtPinmuxRegBlockPrimary = kDtPinmuxRegBlockCore;
56
57/**
58 * List of clock ports.
59 *
60 * Clock ports are guaranteed to be numbered consecutively from 0.
61 */
62typedef enum dt_pinmux_clock {
63 kDtPinmuxClockClk = 0, /**< Clock port clk_i */
64 kDtPinmuxClockAon = 1, /**< Clock port clk_aon_i */
65 kDtPinmuxClockCount = 2, /**< \internal Number of clock ports */
67
68/**
69 * List of reset ports.
70 *
71 * Reset ports are guaranteed to be numbered consecutively from 0.
72 */
73typedef enum dt_pinmux_reset {
74 kDtPinmuxResetRst = 0, /**< Reset port rst_ni */
75 kDtPinmuxResetAon = 1, /**< Reset port rst_aon_ni */
76 kDtPinmuxResetSys = 2, /**< Reset port rst_sys_ni */
77 kDtPinmuxResetCount = 3, /**< \internal Number of reset ports */
79
80/**
81 * List of wakeups.
82 *
83 * Wakeups are guaranteed to be numbered consecutively from 0.
84 */
85typedef enum dt_pinmux_wakeup {
86 kDtPinmuxWakeupPinWkupReq = 0, /**< pin wake request */
87 kDtPinmuxWakeupUsbWkupReq = 1, /**< usb wake request */
88 kDtPinmuxWakeupCount = 2, /**< \internal Number of wakeups */
90
91
92/**
93 * Get the pinmux instance from an instance ID
94 *
95 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
96 *
97 * @param inst_id Instance ID.
98 * @return A pinmux instance.
99 *
100 * **Note:** This function only makes sense if the instance ID has device type pinmux,
101 * otherwise the returned value is unspecified.
102 */
104
105/**
106 * Get the instance ID of an instance.
107 *
108 * @param dt Instance of pinmux.
109 * @return The instance ID of that instance.
110 */
112
113/**
114 * Get the register base address of an instance.
115 *
116 * @param dt Instance of pinmux.
117 * @param reg_block The register block requested.
118 * @return The register base address of the requested block.
119 */
120uint32_t dt_pinmux_reg_block(
121 dt_pinmux_t dt,
122 dt_pinmux_reg_block_t reg_block);
123
124/**
125 * Get the primary register base address of an instance.
126 *
127 * This is just a convenience function, equivalent to
128 * `dt_pinmux_reg_block(dt, kDtPinmuxRegBlockCore)`
129 *
130 * @param dt Instance of pinmux.
131 * @return The register base address of the primary register block.
132 */
133static inline uint32_t dt_pinmux_primary_reg_block(
134 dt_pinmux_t dt) {
135 return dt_pinmux_reg_block(dt, kDtPinmuxRegBlockCore);
136}
137
138/**
139 * Get the base address of a memory.
140 *
141 * @param dt Instance of pinmux.
142 * @param mem The memory requested.
143 * @return The base address of the requested memory.
144 */
145uint32_t dt_pinmux_memory_base(
146 dt_pinmux_t dt,
148
149/**
150 * Get the size of a memory.
151 *
152 * @param dt Instance of pinmux.
153 * @param mem The memory requested.
154 * @return The size of the requested memory.
155 */
156uint32_t dt_pinmux_memory_size(
157 dt_pinmux_t dt,
159
160
161
162
163/**
164 * Get the clock signal connected to a clock port of an instance.
165 *
166 * @param dt Instance of pinmux.
167 * @param clk Clock port.
168 * @return Clock signal.
169 */
171 dt_pinmux_t dt,
173
174/**
175 * Get the reset signal connected to a reset port of an instance.
176 *
177 * @param dt Instance of pinmux.
178 * @param rst Reset port.
179 * @return Reset signal.
180 */
182 dt_pinmux_t dt,
184
185
186
187#ifdef __cplusplus
188} // extern "C"
189#endif // __cplusplus
190
191#endif // OPENTITAN_DT_PINMUX_H_