Software APIs
dt_ast.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_AST_H_
8#define OPENTITAN_DT_AST_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP ast and top earlgrey.
17 *
18 * This file contains the type definitions and global functions of the ast.
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_ast {
30 kDtAst = 0, /**< ast */
31 kDtAstFirst = 0, /**< \internal First instance */
32 kDtAstCount = 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_ast_reg_block {
41 kDtAstRegBlockCore = 0, /**< */
42 kDtAstRegBlockCount = 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_ast_memory {
51 kDtAstMemoryCount = 0, /**< \internal Number of memories */
53
54/** Primary register block (associated with the "primary" set of registers that control the IP). */
55static const dt_ast_reg_block_t kDtAstRegBlockPrimary = kDtAstRegBlockCore;
56
57/**
58 * List of clock ports.
59 *
60 * Clock ports are guaranteed to be numbered consecutively from 0.
61 */
62typedef enum dt_ast_clock {
63 kDtAstClockAstTlul = 0, /**< Clock port clk_ast_tlul_i */
64 kDtAstClockAstAdc = 1, /**< Clock port clk_ast_adc_i */
65 kDtAstClockAstAlert = 2, /**< Clock port clk_ast_alert_i */
66 kDtAstClockAstEs = 3, /**< Clock port clk_ast_es_i */
67 kDtAstClockAstRng = 4, /**< Clock port clk_ast_rng_i */
68 kDtAstClockAstUsb = 5, /**< Clock port clk_ast_usb_i */
69 kDtAstClockCount = 6, /**< \internal Number of clock ports */
71
72/**
73 * List of reset ports.
74 *
75 * Reset ports are guaranteed to be numbered consecutively from 0.
76 */
77typedef enum dt_ast_reset {
78 kDtAstResetAstTlul = 0, /**< Reset port rst_ast_tlul_ni */
79 kDtAstResetAstAdc = 1, /**< Reset port rst_ast_adc_ni */
80 kDtAstResetAstAlert = 2, /**< Reset port rst_ast_alert_ni */
81 kDtAstResetAstEs = 3, /**< Reset port rst_ast_es_ni */
82 kDtAstResetAstRng = 4, /**< Reset port rst_ast_rng_ni */
83 kDtAstResetAstUsb = 5, /**< Reset port rst_ast_usb_ni */
84 kDtAstResetCount = 6, /**< \internal Number of reset ports */
86
87
88/**
89 * Get the ast instance from an instance ID
90 *
91 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
92 *
93 * @param inst_id Instance ID.
94 * @return A ast instance.
95 *
96 * **Note:** This function only makes sense if the instance ID has device type ast,
97 * otherwise the returned value is unspecified.
98 */
100
101/**
102 * Get the instance ID of an instance.
103 *
104 * @param dt Instance of ast.
105 * @return The instance ID of that instance.
106 */
108
109/**
110 * Get the register base address of an instance.
111 *
112 * @param dt Instance of ast.
113 * @param reg_block The register block requested.
114 * @return The register base address of the requested block.
115 */
116uint32_t dt_ast_reg_block(
117 dt_ast_t dt,
118 dt_ast_reg_block_t reg_block);
119
120/**
121 * Get the primary register base address of an instance.
122 *
123 * This is just a convenience function, equivalent to
124 * `dt_ast_reg_block(dt, kDtAstRegBlockCore)`
125 *
126 * @param dt Instance of ast.
127 * @return The register base address of the primary register block.
128 */
129static inline uint32_t dt_ast_primary_reg_block(
130 dt_ast_t dt) {
131 return dt_ast_reg_block(dt, kDtAstRegBlockCore);
132}
133
134/**
135 * Get the base address of a memory.
136 *
137 * @param dt Instance of ast.
138 * @param mem The memory requested.
139 * @return The base address of the requested memory.
140 */
141uint32_t dt_ast_memory_base(
142 dt_ast_t dt,
143 dt_ast_memory_t mem);
144
145/**
146 * Get the size of a memory.
147 *
148 * @param dt Instance of ast.
149 * @param mem The memory requested.
150 * @return The size of the requested memory.
151 */
152uint32_t dt_ast_memory_size(
153 dt_ast_t dt,
154 dt_ast_memory_t mem);
155
156
157
158
159/**
160 * Get the clock signal connected to a clock port of an instance.
161 *
162 * @param dt Instance of ast.
163 * @param clk Clock port.
164 * @return Clock signal.
165 */
167 dt_ast_t dt,
168 dt_ast_clock_t clk);
169
170/**
171 * Get the reset signal connected to a reset port of an instance.
172 *
173 * @param dt Instance of ast.
174 * @param rst Reset port.
175 * @return Reset signal.
176 */
178 dt_ast_t dt,
179 dt_ast_reset_t rst);
180
181
182
183#ifdef __cplusplus
184} // extern "C"
185#endif // __cplusplus
186
187#endif // OPENTITAN_DT_AST_H_