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 darjeeling.
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 kDtAstClockAstRng = 3, /**< Clock port clk_ast_rng_i */
67 kDtAstClockCount = 4, /**< \internal Number of clock ports */
69
70/**
71 * List of reset ports.
72 *
73 * Reset ports are guaranteed to be numbered consecutively from 0.
74 */
75typedef enum dt_ast_reset {
76 kDtAstResetAstTlul = 0, /**< Reset port rst_ast_tlul_ni */
77 kDtAstResetAstAdc = 1, /**< Reset port rst_ast_adc_ni */
78 kDtAstResetAstAlert = 2, /**< Reset port rst_ast_alert_ni */
79 kDtAstResetAstRng = 3, /**< Reset port rst_ast_rng_ni */
80 kDtAstResetCount = 4, /**< \internal Number of reset ports */
82
83
84/**
85 * Get the ast instance from an instance ID
86 *
87 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
88 *
89 * @param inst_id Instance ID.
90 * @return A ast instance.
91 *
92 * **Note:** This function only makes sense if the instance ID has device type ast,
93 * otherwise the returned value is unspecified.
94 */
96
97/**
98 * Get the instance ID of an instance.
99 *
100 * @param dt Instance of ast.
101 * @return The instance ID of that instance.
102 */
104
105/**
106 * Get the register base address of an instance.
107 *
108 * @param dt Instance of ast.
109 * @param reg_block The register block requested.
110 * @return The register base address of the requested block.
111 */
112uint32_t dt_ast_reg_block(
113 dt_ast_t dt,
114 dt_ast_reg_block_t reg_block);
115
116/**
117 * Get the primary register base address of an instance.
118 *
119 * This is just a convenience function, equivalent to
120 * `dt_ast_reg_block(dt, kDtAstRegBlockCore)`
121 *
122 * @param dt Instance of ast.
123 * @return The register base address of the primary register block.
124 */
125static inline uint32_t dt_ast_primary_reg_block(
126 dt_ast_t dt) {
127 return dt_ast_reg_block(dt, kDtAstRegBlockCore);
128}
129
130/**
131 * Get the base address of a memory.
132 *
133 * @param dt Instance of ast.
134 * @param mem The memory requested.
135 * @return The base address of the requested memory.
136 */
137uint32_t dt_ast_memory_base(
138 dt_ast_t dt,
139 dt_ast_memory_t mem);
140
141/**
142 * Get the size of a memory.
143 *
144 * @param dt Instance of ast.
145 * @param mem The memory requested.
146 * @return The size of the requested memory.
147 */
148uint32_t dt_ast_memory_size(
149 dt_ast_t dt,
150 dt_ast_memory_t mem);
151
152
153
154
155/**
156 * Get the clock signal connected to a clock port of an instance.
157 *
158 * @param dt Instance of ast.
159 * @param clk Clock port.
160 * @return Clock signal.
161 */
163 dt_ast_t dt,
164 dt_ast_clock_t clk);
165
166/**
167 * Get the reset signal connected to a reset port of an instance.
168 *
169 * @param dt Instance of ast.
170 * @param rst Reset port.
171 * @return Reset signal.
172 */
174 dt_ast_t dt,
175 dt_ast_reset_t rst);
176
177
178
179#ifdef __cplusplus
180} // extern "C"
181#endif // __cplusplus
182
183#endif // OPENTITAN_DT_AST_H_