Software APIs
api.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_TOP_DARJEELING_DT_API_H_
8#define OPENTITAN_TOP_DARJEELING_DT_API_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) API for top darjeeling
17 *
18 * This file contains the type definitions and global functions of the DT.
19 *
20 * The DT models the chip as a collection of instances. Each instance has
21 * a type (the IP block) and a number of attributes such as I/Os, IRQs
22 * and so on. The DT also provides top-specific lists of global resources
23 * such as I/O pads, clocks and interrupts.
24 */
25
26#include <stddef.h>
27#include <stdint.h>
29
30/**
31 * List of device types.
32 *
33 * Device types are guaranteed to be numbered consecutively from 0.
34 */
35typedef enum dt_device_type {
36 kDtDeviceTypeUnknown = 0, /**< Instance of unknown type */
37 kDtDeviceTypeAcRangeCheck = 1, /**< instance of ac_range_check */
38 kDtDeviceTypeAes = 2, /**< instance of aes */
39 kDtDeviceTypeAlertHandler = 3, /**< instance of alert_handler */
40 kDtDeviceTypeAonTimer = 4, /**< instance of aon_timer */
41 kDtDeviceTypeAst = 5, /**< instance of ast */
42 kDtDeviceTypeClkmgr = 6, /**< instance of clkmgr */
43 kDtDeviceTypeCsrng = 7, /**< instance of csrng */
44 kDtDeviceTypeDma = 8, /**< instance of dma */
45 kDtDeviceTypeEdn = 9, /**< instance of edn */
46 kDtDeviceTypeEntropySrc = 10, /**< instance of entropy_src */
47 kDtDeviceTypeGpio = 11, /**< instance of gpio */
48 kDtDeviceTypeHmac = 12, /**< instance of hmac */
49 kDtDeviceTypeI2c = 13, /**< instance of i2c */
50 kDtDeviceTypeKeymgrDpe = 14, /**< instance of keymgr_dpe */
51 kDtDeviceTypeKmac = 15, /**< instance of kmac */
52 kDtDeviceTypeLcCtrl = 16, /**< instance of lc_ctrl */
53 kDtDeviceTypeMbx = 17, /**< instance of mbx */
54 kDtDeviceTypeOtbn = 18, /**< instance of otbn */
55 kDtDeviceTypeOtpCtrl = 19, /**< instance of otp_ctrl */
56 kDtDeviceTypeOtpMacro = 20, /**< instance of otp_macro */
57 kDtDeviceTypePinmux = 21, /**< instance of pinmux */
58 kDtDeviceTypePwrmgr = 22, /**< instance of pwrmgr */
59 kDtDeviceTypeRaclCtrl = 23, /**< instance of racl_ctrl */
60 kDtDeviceTypeRomCtrl = 24, /**< instance of rom_ctrl */
61 kDtDeviceTypeRstmgr = 25, /**< instance of rstmgr */
62 kDtDeviceTypeRvCoreIbex = 26, /**< instance of rv_core_ibex */
63 kDtDeviceTypeRvDm = 27, /**< instance of rv_dm */
64 kDtDeviceTypeRvPlic = 28, /**< instance of rv_plic */
65 kDtDeviceTypeRvTimer = 29, /**< instance of rv_timer */
66 kDtDeviceTypeSocDbgCtrl = 30, /**< instance of soc_dbg_ctrl */
67 kDtDeviceTypeSocProxy = 31, /**< instance of soc_proxy */
68 kDtDeviceTypeSpiDevice = 32, /**< instance of spi_device */
69 kDtDeviceTypeSpiHost = 33, /**< instance of spi_host */
70 kDtDeviceTypeSramCtrl = 34, /**< instance of sram_ctrl */
71 kDtDeviceTypeUart = 35, /**< instance of uart */
73
74enum {
75 kDtDeviceTypeCount = 36, /**< Number of instance types */
76};
77
78
79/**
80 * List of instance IDs.
81 *
82 * Instance IDs are guaranteed to be numbered consecutively from 0.
83 */
84typedef enum dt_instance_id {
85 kDtInstanceIdUnknown = 0, /**< Unknown instance */
86 kDtInstanceIdAcRangeCheck = 1, /**< instance ac_range_check of ac_range_check */
87 kDtInstanceIdAes = 2, /**< instance aes of aes */
88 kDtInstanceIdAlertHandler = 3, /**< instance alert_handler of alert_handler */
89 kDtInstanceIdAonTimerAon = 4, /**< instance aon_timer_aon of aon_timer */
90 kDtInstanceIdAst = 5, /**< instance ast of ast */
91 kDtInstanceIdClkmgrAon = 6, /**< instance clkmgr_aon of clkmgr */
92 kDtInstanceIdCsrng = 7, /**< instance csrng of csrng */
93 kDtInstanceIdDma = 8, /**< instance dma of dma */
94 kDtInstanceIdEdn0 = 9, /**< instance edn0 of edn */
95 kDtInstanceIdEdn1 = 10, /**< instance edn1 of edn */
96 kDtInstanceIdEntropySrc = 11, /**< instance entropy_src of entropy_src */
97 kDtInstanceIdGpio = 12, /**< instance gpio of gpio */
98 kDtInstanceIdHmac = 13, /**< instance hmac of hmac */
99 kDtInstanceIdI2c0 = 14, /**< instance i2c0 of i2c */
100 kDtInstanceIdKeymgrDpe = 15, /**< instance keymgr_dpe of keymgr_dpe */
101 kDtInstanceIdKmac = 16, /**< instance kmac of kmac */
102 kDtInstanceIdLcCtrl = 17, /**< instance lc_ctrl of lc_ctrl */
103 kDtInstanceIdMbx0 = 18, /**< instance mbx0 of mbx */
104 kDtInstanceIdMbx1 = 19, /**< instance mbx1 of mbx */
105 kDtInstanceIdMbx2 = 20, /**< instance mbx2 of mbx */
106 kDtInstanceIdMbx3 = 21, /**< instance mbx3 of mbx */
107 kDtInstanceIdMbx4 = 22, /**< instance mbx4 of mbx */
108 kDtInstanceIdMbx5 = 23, /**< instance mbx5 of mbx */
109 kDtInstanceIdMbx6 = 24, /**< instance mbx6 of mbx */
110 kDtInstanceIdMbxJtag = 25, /**< instance mbx_jtag of mbx */
111 kDtInstanceIdMbxPcie0 = 26, /**< instance mbx_pcie0 of mbx */
112 kDtInstanceIdMbxPcie1 = 27, /**< instance mbx_pcie1 of mbx */
113 kDtInstanceIdOtbn = 28, /**< instance otbn of otbn */
114 kDtInstanceIdOtpCtrl = 29, /**< instance otp_ctrl of otp_ctrl */
115 kDtInstanceIdOtpMacro = 30, /**< instance otp_macro of otp_macro */
116 kDtInstanceIdPinmuxAon = 31, /**< instance pinmux_aon of pinmux */
117 kDtInstanceIdPwrmgrAon = 32, /**< instance pwrmgr_aon of pwrmgr */
118 kDtInstanceIdRaclCtrl = 33, /**< instance racl_ctrl of racl_ctrl */
119 kDtInstanceIdRomCtrl0 = 34, /**< instance rom_ctrl0 of rom_ctrl */
120 kDtInstanceIdRomCtrl1 = 35, /**< instance rom_ctrl1 of rom_ctrl */
121 kDtInstanceIdRstmgrAon = 36, /**< instance rstmgr_aon of rstmgr */
122 kDtInstanceIdRvCoreIbex = 37, /**< instance rv_core_ibex of rv_core_ibex */
123 kDtInstanceIdRvDm = 38, /**< instance rv_dm of rv_dm */
124 kDtInstanceIdRvPlic = 39, /**< instance rv_plic of rv_plic */
125 kDtInstanceIdRvTimer = 40, /**< instance rv_timer of rv_timer */
126 kDtInstanceIdSocDbgCtrl = 41, /**< instance soc_dbg_ctrl of soc_dbg_ctrl */
127 kDtInstanceIdSocProxy = 42, /**< instance soc_proxy of soc_proxy */
128 kDtInstanceIdSpiDevice = 43, /**< instance spi_device of spi_device */
129 kDtInstanceIdSpiHost0 = 44, /**< instance spi_host0 of spi_host */
130 kDtInstanceIdSramCtrlRetAon = 45, /**< instance sram_ctrl_ret_aon of sram_ctrl */
131 kDtInstanceIdSramCtrlMain = 46, /**< instance sram_ctrl_main of sram_ctrl */
132 kDtInstanceIdSramCtrlMbox = 47, /**< instance sram_ctrl_mbox of sram_ctrl */
133 kDtInstanceIdUart0 = 48, /**< instance uart0 of uart */
135
136enum {
137 kDtInstanceIdCount = 49, /**< Number of instance IDs */
138};
139
140
141/**
142 * Get the instance type of a device instance.
143 *
144 * For example the instance type of `kDtUart0` is `kDtInstanceTypeUart`.
145 *
146 * @param id An instance ID.
147 * @return The instance type, or `kDtInstanceIdUnknown` if the ID is not valid.
148 */
150
151/** PLIC IRQ ID type.
152 *
153 * This type represents a raw IRQ ID from the PLIC.
154 *
155 * This is an alias to the top's `plic_irq_id_t` type for backward compatibility
156 * with existing code.
157 */
159
160/** PLIC IRQ ID for no interrupt. */
161static const dt_plic_irq_id_t kDtPlicIrqIdNone = kTopDarjeelingPlicIrqIdNone;
162
163/**
164 * Get the instance ID for a given PLIC IRQ ID.
165 *
166 * For example, on earlgrey, the instance ID of `kTopEarlgreyPlicIrqIdUart0TxWatermark`
167 * is `kDtInstanceIdUart0`. One can then use the type specific function to retrieve the
168 * IRQ name, for example `dt_uart_irq_from_plic_id` for the UART.
169 *
170 * @param irq A PLIC ID.
171 * @return The instance ID, or `kDtInstanceIdUnknown` if the PLIC ID is not valid.
172 */
174
175/**
176 * Alert ID type.
177 *
178 * This type represents a raw alert ID from the Alert Handler.
179 *
180 * This is an alias to the top's `alert_id_t` type for backward compatibility
181 * with existing code.
182 */
184
185/** Number of alerts. */
186enum {
187 /** Total number of alert IDs. */
188 kDtAlertCount = kTopDarjeelingAlertIdLast + 1,
189};
190
191/**
192 * Get the instance ID for a given alert ID.
193 *
194 * For example, on earlgrey, the instance ID of `kTopEarlgreyAlertIdUart0FatalFault` is
195 * `kDtInstanceIdUart0`. One can then use the type specific function to retrieve the
196 * alert name, for example `dt_uart_alert_from_alert_id` for the UART.
197 *
198 * @param alert An alert ID.
199 * @return The instance ID, or `kDtInstanceIdUnknown` if the alert ID is not valid.
200 */
202
203/**
204 * List of clocks.
205 *
206 * Clocks are guaranteed to be numbered consecutively from 0.
207 */
208typedef enum dt_clock {
209 kDtClockMain = 0, /**< clock main */
210 kDtClockIo = 1, /**< clock io */
211 kDtClockAon = 2, /**< clock aon */
213
214enum {
215 kDtClockCount = 3, /**< Number of clocks */
216};
217
218
219/**
220 * Get the frequency of a clock.
221 *
222 * @param clk A clock ID.
223 * @return Clock frequency in Hz.
224 */
226
227/**
228 * List of resets.
229 *
230 * Resets are guaranteed to be numbered consecutively from 0.
231 */
232typedef enum dt_reset {
233 kDtResetUnknown = 0, /**< Unknown reset */
234 kDtResetPorAon = 1, /**< Reset node por_aon */
235 kDtResetLcSrc = 2, /**< Reset node lc_src */
236 kDtResetSysSrc = 3, /**< Reset node sys_src */
237 kDtResetPor = 4, /**< Reset node por */
238 kDtResetPorIo = 5, /**< Reset node por_io */
239 kDtResetLc = 6, /**< Reset node lc */
240 kDtResetLcAon = 7, /**< Reset node lc_aon */
241 kDtResetLcIo = 8, /**< Reset node lc_io */
242 kDtResetSys = 9, /**< Reset node sys */
243 kDtResetSpiDevice = 10, /**< Reset node spi_device */
244 kDtResetSpiHost0 = 11, /**< Reset node spi_host0 */
245 kDtResetI2c0 = 12, /**< Reset node i2c0 */
247
248enum {
249 kDtResetCount = 13, /**< Number of resets */
250};
251
252
253/**
254 * List of pads names.
255 */
256typedef enum dt_pad {
257 kDtPadConstantZero = 0, /**< Pad that is constantly tied to zero (input) */
258 kDtPadConstantOne = 1, /**< Pad that is constantly tied to one (input) */
259 kDtPadMio0 = 2, /**< Muxed IO pad */
260 kDtPadMio1 = 3, /**< Muxed IO pad */
261 kDtPadMio2 = 4, /**< Muxed IO pad */
262 kDtPadMio3 = 5, /**< Muxed IO pad */
263 kDtPadMio4 = 6, /**< Muxed IO pad */
264 kDtPadMio5 = 7, /**< Muxed IO pad */
265 kDtPadMio6 = 8, /**< Muxed IO pad */
266 kDtPadMio7 = 9, /**< Muxed IO pad */
267 kDtPadMio8 = 10, /**< Muxed IO pad */
268 kDtPadMio9 = 11, /**< Muxed IO pad */
269 kDtPadMio10 = 12, /**< Muxed IO pad */
270 kDtPadMio11 = 13, /**< Muxed IO pad */
271 kDtPadSpiHost0Sd0 = 14, /**< SPI host data */
272 kDtPadSpiHost0Sd1 = 15, /**< SPI host data */
273 kDtPadSpiHost0Sd2 = 16, /**< SPI host data */
274 kDtPadSpiHost0Sd3 = 17, /**< SPI host data */
275 kDtPadSpiDeviceSd0 = 18, /**< SPI device data */
276 kDtPadSpiDeviceSd1 = 19, /**< SPI device data */
277 kDtPadSpiDeviceSd2 = 20, /**< SPI device data */
278 kDtPadSpiDeviceSd3 = 21, /**< SPI device data */
279 kDtPadI2c0Scl = 22, /**< I2C clock */
280 kDtPadI2c0Sda = 23, /**< I2C data */
281 kDtPadGpioGpio0 = 24, /**< GPIO pad */
282 kDtPadGpioGpio1 = 25, /**< GPIO pad */
283 kDtPadGpioGpio2 = 26, /**< GPIO pad */
284 kDtPadGpioGpio3 = 27, /**< GPIO pad */
285 kDtPadGpioGpio4 = 28, /**< GPIO pad */
286 kDtPadGpioGpio5 = 29, /**< GPIO pad */
287 kDtPadGpioGpio6 = 30, /**< GPIO pad */
288 kDtPadGpioGpio7 = 31, /**< GPIO pad */
289 kDtPadGpioGpio8 = 32, /**< GPIO pad */
290 kDtPadGpioGpio9 = 33, /**< GPIO pad */
291 kDtPadGpioGpio10 = 34, /**< GPIO pad */
292 kDtPadGpioGpio11 = 35, /**< GPIO pad */
293 kDtPadGpioGpio12 = 36, /**< GPIO pad */
294 kDtPadGpioGpio13 = 37, /**< GPIO pad */
295 kDtPadGpioGpio14 = 38, /**< GPIO pad */
296 kDtPadGpioGpio15 = 39, /**< GPIO pad */
297 kDtPadGpioGpio16 = 40, /**< GPIO pad */
298 kDtPadGpioGpio17 = 41, /**< GPIO pad */
299 kDtPadGpioGpio18 = 42, /**< GPIO pad */
300 kDtPadGpioGpio19 = 43, /**< GPIO pad */
301 kDtPadGpioGpio20 = 44, /**< GPIO pad */
302 kDtPadGpioGpio21 = 45, /**< GPIO pad */
303 kDtPadGpioGpio22 = 46, /**< GPIO pad */
304 kDtPadGpioGpio23 = 47, /**< GPIO pad */
305 kDtPadGpioGpio24 = 48, /**< GPIO pad */
306 kDtPadGpioGpio25 = 49, /**< GPIO pad */
307 kDtPadGpioGpio26 = 50, /**< GPIO pad */
308 kDtPadGpioGpio27 = 51, /**< GPIO pad */
309 kDtPadGpioGpio28 = 52, /**< GPIO pad */
310 kDtPadGpioGpio29 = 53, /**< GPIO pad */
311 kDtPadGpioGpio30 = 54, /**< GPIO pad */
312 kDtPadGpioGpio31 = 55, /**< GPIO pad */
313 kDtPadSpiDeviceSck = 56, /**< SPI device clock */
314 kDtPadSpiDeviceCsb = 57, /**< SPI device chip select */
315 kDtPadSpiDeviceTpmCsb = 58, /**< SPI device TPM chip select */
316 kDtPadUart0Rx = 59, /**< UART receive */
317 kDtPadSocProxySocGpi0 = 60, /**< SoC general purpose input */
318 kDtPadSocProxySocGpi1 = 61, /**< SoC general purpose input */
319 kDtPadSocProxySocGpi2 = 62, /**< SoC general purpose input */
320 kDtPadSocProxySocGpi3 = 63, /**< SoC general purpose input */
321 kDtPadSocProxySocGpi4 = 64, /**< SoC general purpose input */
322 kDtPadSocProxySocGpi5 = 65, /**< SoC general purpose input */
323 kDtPadSocProxySocGpi6 = 66, /**< SoC general purpose input */
324 kDtPadSocProxySocGpi7 = 67, /**< SoC general purpose input */
325 kDtPadSocProxySocGpi8 = 68, /**< SoC general purpose input */
326 kDtPadSocProxySocGpi9 = 69, /**< SoC general purpose input */
327 kDtPadSocProxySocGpi10 = 70, /**< SoC general purpose input */
328 kDtPadSocProxySocGpi11 = 71, /**< SoC general purpose input */
329 kDtPadSpiHost0Sck = 72, /**< SPI host clock */
330 kDtPadSpiHost0Csb = 73, /**< SPI host chip select */
331 kDtPadUart0Tx = 74, /**< UART transmit */
332 kDtPadSocProxySocGpo0 = 75, /**< SoC general purpose output */
333 kDtPadSocProxySocGpo1 = 76, /**< SoC general purpose output */
334 kDtPadSocProxySocGpo2 = 77, /**< SoC general purpose output */
335 kDtPadSocProxySocGpo3 = 78, /**< SoC general purpose output */
336 kDtPadSocProxySocGpo4 = 79, /**< SoC general purpose output */
337 kDtPadSocProxySocGpo5 = 80, /**< SoC general purpose output */
338 kDtPadSocProxySocGpo6 = 81, /**< SoC general purpose output */
339 kDtPadSocProxySocGpo7 = 82, /**< SoC general purpose output */
340 kDtPadSocProxySocGpo8 = 83, /**< SoC general purpose output */
341 kDtPadSocProxySocGpo9 = 84, /**< SoC general purpose output */
342 kDtPadSocProxySocGpo10 = 85, /**< SoC general purpose output */
343 kDtPadSocProxySocGpo11 = 86, /**< SoC general purpose output */
345
346enum {
347 kDtPadCount = 87, /**< Number of pads */
348};
349
350
351/** Type of peripheral I/O. */
352typedef enum dt_periph_io_type {
353 /** This peripheral I/O is connected to a muxed IO (MIO). */
355 /** This peripheral I/O is connected to a direct IO (DIO). */
357 /** This peripheral I/O is not connected to either a MIO or a DIO. */
360
361
362/** Direction of a peripheral I/O. */
363typedef enum dt_periph_io_dir {
364 /** This peripheral I/O is an input. */
366 /** This peripheral I/O is an output */
368 /** This peripheral I/O is an input-output */
371
372/** Peripheral I/O description.
373 *
374 * A `dt_periph_io_t` represents a HW IP block peripheral I/O, which can be an input, output or both.
375 * Importantly, this only represents how the block peripheral I/O is wired, i.e.
376 * whether it is connected a MIO or a direct IO on the pinmux, and the relevant information necessary to
377 * configure it.
378 *
379 * **Note:** The fields of this structure are internal, use the dt_periph_io_* functions to access them.
380 */
381typedef struct dt_periph_io {
382 struct {
383 dt_periph_io_type_t type; /**< Peripheral I/O type */
384 dt_periph_io_dir_t dir; /**< Peripheral I/O direction */
385 /**
386 * For `kDtPeriphIoTypeMio`: peripheral input number. This is the index of the MIO_PERIPH_INSEL register
387 * that controls this peripheral I/O.
388 *
389 * For `kDtPeriphIoTypeDio`: DIO pad number. This is the index of the various DIO_PAD_* registers
390 * that control this peripheral I/O.
391 */
392 uint16_t periph_input_or_direct_pad;
393 /**
394 * For `kDtPeriphIoTypeMio`: peripheral output number. This is the value to put in the MIO_OUTSEL registers
395 * to connect an output to this peripheral I/O. For `kDtPeriphIoTypeDio`: the pad index (`dt_pad_t`) to which this I/O is connected.
396 */
397 uint16_t outsel_or_dt_pad;
398 } __internal; /**< Private fields */
400
401
402/* Peripheral I/O that is constantly tied to high-Z (output only) */
403extern const dt_periph_io_t kDtPeriphIoConstantHighZ;
404
405/* Peripheral I/O that is constantly tied to one (output only) */
406extern const dt_periph_io_t kDtPeriphIoConstantZero;
407
408/* Peripheral I/O that is constantly tied to zero (output only) */
409extern const dt_periph_io_t kDtPeriphIoConstantOne;
410
411/**
412 * Return the type of a `dt_periph_io_t`.
413 *
414 * @param periph_io A peripheral I/O description.
415 * @return The peripheral I/O type (MIO, DIO, etc).
416 */
418 return periph_io.__internal.type;
419}
420
421/**
422 * Return the direction of a `dt_periph_io_t`.
423 *
424 * @param periph_io A peripheral I/O description.
425 * @return The peripheral I/O direction.
426 */
427static inline dt_periph_io_dir_t dt_periph_io_dir(dt_periph_io_t periph_io) {
428 return periph_io.__internal.dir;
429}
430
431/**
432 * Pinmux types.
433 *
434 * These types are aliases to top-level types for backward compatibility
435 * with existing code.
436 */
438typedef top_darjeeling_pinmux_insel_t dt_pinmux_insel_t;
439typedef top_darjeeling_pinmux_outsel_t dt_pinmux_outsel_t;
440typedef top_darjeeling_pinmux_mio_out_t dt_pinmux_mio_out_t;
441typedef top_darjeeling_direct_pads_t dt_pinmux_direct_pad_t;
442typedef top_darjeeling_muxed_pads_t dt_pinmux_muxed_pad_t;
443
444/** Tie constantly to zero. */
445static const dt_pinmux_outsel_t kDtPinmuxOutselConstantZero = kTopDarjeelingPinmuxOutselConstantZero;
446
447/** Tie constantly to one. */
448static const dt_pinmux_outsel_t kDtPinmuxOutselConstantOne = kTopDarjeelingPinmuxOutselConstantOne;
449
450/** Tie constantly to high-Z. */
451static const dt_pinmux_outsel_t kDtPinmuxOutselConstantHighZ = kTopDarjeelingPinmuxOutselConstantHighZ;
452
453/**
454 * Return the peripheral input for an MIO peripheral I/O.
455 *
456 * This is the index of the `MIO_PERIPH_INSEL` pinmux register that controls this peripheral I/O.
457 *
458 * @param periph_io A peripheral I/O of type `kDtPeriphIoTypeMio`.
459 * @return The peripheral input number of the MIO that this peripheral I/O is connected to.
460 *
461 * **Note:** This function only makes sense for peripheral I/Os of type `kDtPeriphIoTypeMio` which are
462 * inputs (`kDtPeriphIoDirIn`). For any other peripheral I/O, the return value is unspecified.
463 */
464static inline dt_pinmux_peripheral_in_t dt_periph_io_mio_periph_input(dt_periph_io_t periph_io) {
465 return (dt_pinmux_peripheral_in_t)periph_io.__internal.periph_input_or_direct_pad;
466}
467
468/**
469 * Return the outsel for an MIO peripheral I/O.
470 *
471 * This is the value to put in the `MIO_OUTSEL` pinmux registers to connect a pad to this peripheral I/O.
472 *
473 * @param periph_io A peripheral I/O of type `kDtPeriphIoTypeMio`.
474 * @return The outsel of the MIO that this peripheral I/O is connected to.
475 *
476 * **Note:** This function only makes sense for peripheral I/Os of type `kDtPeriphIoTypeMio` which are
477 * outputs (`kDtPeriphIoDirOut`). For any other peripheral I/O, the return value is unspecified.
478 */
479static inline dt_pinmux_outsel_t dt_periph_io_mio_outsel(dt_periph_io_t periph_io) {
480 return (dt_pinmux_outsel_t)periph_io.__internal.outsel_or_dt_pad;
481}
482
483/**
484 * Return the direct pad number of a DIO peripheral I/O.
485 *
486 * This is the index of the various `DIO_PAD_*` pinmux registers that control this peripheral I/O.
487 *
488 * @param periph_io A peripheral I/O of type `kDtPeriphIoTypeDio`.
489 * @return The direct pad number of the DIO that this peripheral I/O is connected to.
490 *
491 * **Note:** This function only makes sense for peripheral I/Os of type `kDtPeriphIoTypeDio` which are
492 * either outputs or inouts. For any other peripheral I/O type, the return value is unspecified.
493 */
494static inline dt_pinmux_direct_pad_t dt_periph_io_dio_pad_index(dt_periph_io_t periph_io) {
495 return (dt_pinmux_direct_pad_t)periph_io.__internal.periph_input_or_direct_pad;
496}
497
498/**
499 * Return the pad of a DIO peripheral I/O.
500 *
501 * @param periph_io A peripheral I/O of type `kDtPeriphIoTypeDio`.
502 * @return The pad to which this peripheral I/O is connected to.
503 *
504 * **Note:** This function only makes sense for peripheral I/Os of type `kDtPeriphIoTypeDio` which are
505 * either outputs or inouts. For any other peripheral I/O type, the return value is unspecified.
506 */
507static inline dt_pad_t dt_periph_io_dio_pad(dt_periph_io_t periph_io) {
508 return (dt_pad_t)periph_io.__internal.outsel_or_dt_pad;
509}
510
511/** Type of a pad. */
512typedef enum dt_pad_type {
513 /** This pad is a muxed IO (MIO). */
515 /** This pad is a direct IO (DIO). */
517 /** This pad is not an MIO or a DIO. */
520
521/**
522 * Return the type of a `dt_pad_t`.
523 *
524 * @param pad A pad description.
525 * @return The pad type (MIO, DIO, etc).
526 */
528
529/**
530 * Return the pad out number for an MIO pad.
531 *
532 * This is the index of the `MIO_OUT` registers that control this pad
533 * (or the output part of this pad).
534 *
535 * @param pad A pad of type `kDtPadTypeMio`.
536 * @return The pad out number of the MIO.
537 *
538 * **Note:** This function only makes sense for pads of type `kDtPadTypeMio` which are
539 * either inputs or inouts. For any other pad, the return value is unspecified.
540 */
541dt_pinmux_mio_out_t dt_pad_mio_out(dt_pad_t pad);
542
543/**
544 * Return the pad out number for an MIO pad.
545 *
546 * This is the index of the `MIO_PAD` registers that control this pad
547 * (or the output part of this pad).
548 *
549 * @param pad A pad of type `kDtPadTypeMio`.
550 * @return The pad out number of the MIO.
551 *
552 * **Note:** This function only makes sense for pads of type `kDtPadTypeMio`.
553 * For any other pad, the return value is unspecified.
554 */
555dt_pinmux_muxed_pad_t dt_pad_mio_pad_index(dt_pad_t pad);
556
557/**
558 * Return the insel for an MIO pad.
559 *
560 * This is the value to put in the `MIO_PERIPH_INSEL` registers to connect a peripheral I/O to this pad.
561 *
562 * @param pad A pad of type `kDtPadTypeMio`.
563 * @return The insel of the MIO that this pad is connected to.
564 *
565 * **Note:** This function only makes sense for pads of type `kDtPadTypeMio`.
566 * For any other pad, the return value is unspecified.
567 */
568dt_pinmux_insel_t dt_pad_mio_insel(dt_pad_t pad);
569
570/**
571 * Return the direct pad number of a DIO pad.
572 *
573 * This is the index of the various `DIO_PAD_*` registers that control this pad.
574 *
575 * @param pad A pad of type `kDtPadTypeDio`.
576 * @return The direct pad number of the DID that this pad is connected to.
577 *
578 * **Note:** This function only makes sense for pads of type `kDtPeriphIoTypeDio` which are
579 * either outputs or inouts. For any other pad type, the return value is unspecified.
580 */
581dt_pinmux_direct_pad_t dt_pad_dio_pad_index(dt_pad_t pad);
582
583#ifdef __cplusplus
584} // extern "C"
585#endif // __cplusplus
586
587#endif // OPENTITAN_TOP_DARJEELING_DT_API_H_