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