Software APIs
dt_ast.c
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
/**
8
* @file
9
* @brief Device Tables (DT) for IP ast and top englishbreakfast.
10
*/
11
12
#include "hw/top/dt/dt_ast.h"
13
14
15
16
/**
17
* Description of instances.
18
*/
19
typedef
struct
dt_desc_ast
{
20
dt_instance_id_t
inst_id
;
/**< Instance ID */
21
uint32_t
reg_addr
[kDtAstRegBlockCount];
/**< Base address of each register block */
22
uint32_t
mem_addr
[kDtAstMemoryCount];
/**< Base address of each memory */
23
uint32_t
mem_size
[kDtAstMemoryCount];
/**< Size in bytes of each memory */
24
dt_clock_t
clock
[kDtAstClockCount];
/**< Clock signal connected to each clock port */
25
dt_reset_t
reset
[kDtAstResetCount];
/**< Reset signal connected to each reset port */
26
}
dt_desc_ast_t
;
27
28
29
30
31
static
const
dt_desc_ast_t
ast_desc[kDtAstCount] = {
32
[
kDtAst
] = {
33
.inst_id =
kDtInstanceIdAst
,
34
.reg_addr = {
35
[kDtAstRegBlockCore] = 0x40480000,
36
},
37
.mem_addr = {
38
},
39
.mem_size = {
40
},
41
.clock = {
42
[
kDtAstClockAstTlul
] =
kDtClockIoDiv4
,
43
[
kDtAstClockAstAdc
] =
kDtClockAon
,
44
[
kDtAstClockAstAlert
] =
kDtClockIoDiv4
,
45
[
kDtAstClockAstEs
] =
kDtClockMain
,
46
[
kDtAstClockAstRng
] =
kDtClockMain
,
47
[
kDtAstClockAstUsb
] =
kDtClockUsb
,
48
},
49
.reset = {
50
[
kDtAstResetAstTlul
] =
kDtResetLcIoDiv4
,
51
[
kDtAstResetAstAdc
] =
kDtResetSysAon
,
52
[
kDtAstResetAstAlert
] =
kDtResetLcIoDiv4
,
53
[
kDtAstResetAstEs
] =
kDtResetSys
,
54
[
kDtAstResetAstRng
] =
kDtResetSys
,
55
[
kDtAstResetAstUsb
] =
kDtResetUsb
,
56
},
57
},
58
};
59
60
/**
61
* Return a pointer to the `dt_ast_desc_t` structure of the requested
62
* `dt` if it's a valid index. Otherwise, this macro will `return` (i.e. exit
63
* the function) with the provided default value.
64
*/
65
#define TRY_GET_DT(dt, default) ({ if ((dt) < (dt_ast_t)0 || (dt) >= kDtAstCount) return (default); &ast_desc[dt]; })
66
67
dt_ast_t
dt_ast_from_instance_id
(
dt_instance_id_t
inst_id) {
68
if
(inst_id >=
kDtInstanceIdAst
&& inst_id <=
kDtInstanceIdAst
) {
69
return
(
dt_ast_t
)(inst_id -
kDtInstanceIdAst
);
70
}
71
return
(
dt_ast_t
)0;
72
}
73
74
dt_instance_id_t
dt_ast_instance_id
(
75
dt_ast_t
dt) {
76
return
TRY_GET_DT
(dt,
kDtInstanceIdUnknown
)->inst_id;
77
}
78
79
uint32_t
dt_ast_reg_block
(
80
dt_ast_t
dt,
81
dt_ast_reg_block_t
reg_block) {
82
// Return a recognizable address in case of wrong argument.
83
return
TRY_GET_DT
(dt, 0xdeadbeef)->reg_addr[reg_block];
84
}
85
86
uint32_t
dt_ast_memory_base
(
87
dt_ast_t
dt,
88
dt_ast_memory_t
mem) {
89
// Return a recognizable address in case of wrong argument.
90
return
TRY_GET_DT
(dt, 0xdeadbeef)->mem_addr[mem];
91
}
92
93
uint32_t
dt_ast_memory_size
(
94
dt_ast_t
dt,
95
dt_ast_memory_t
mem) {
96
// Return an empty size in case of wrong argument.
97
return
TRY_GET_DT
(dt, 0)->mem_size[mem];
98
}
99
100
101
102
103
dt_clock_t
dt_ast_clock
(
104
dt_ast_t
dt,
105
dt_ast_clock_t
clk) {
106
// Return the first clock in case of invalid argument.
107
return
TRY_GET_DT
(dt, (
dt_clock_t
)0)->clock[clk];
108
}
109
110
dt_reset_t
dt_ast_reset
(
111
dt_ast_t
dt,
112
dt_ast_reset_t
rst) {
113
const
dt_ast_reset_t
count = kDtAstResetCount;
114
if
(rst >= count) {
115
return
kDtResetUnknown
;
116
}
117
return
TRY_GET_DT
(dt,
kDtResetUnknown
)->reset[rst];
118
}
119
120
(englishbreakfast)
hw
top
dt
dt_ast.c
Return to
OpenTitan Documentation