Software APIs
dt_spi_host.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_SPI_HOST_H_
8
#define OPENTITAN_DT_SPI_HOST_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP spi_host and top earlgrey.
17
*
18
* This file contains the type definitions and global functions of the spi_host.
19
*/
20
21
#include "
dt_api.h
"
22
#include <stdint.h>
23
24
25
26
/**
27
* List of instances.
28
*/
29
typedef
enum
dt_spi_host
{
30
kDtSpiHost0
= 0,
/**< spi_host0 */
31
kDtSpiHost1
= 1,
/**< spi_host1 */
32
kDtSpiHostFirst = 0,
/**< \internal First instance */
33
kDtSpiHostCount = 2,
/**< \internal Number of instances */
34
}
dt_spi_host_t
;
35
36
/**
37
* List of register blocks.
38
*
39
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
40
*/
41
typedef
enum
dt_spi_host_reg_block
{
42
kDtSpiHostRegBlockCore = 0,
/**< */
43
kDtSpiHostRegBlockCount = 1,
/**< \internal Number of register blocks */
44
}
dt_spi_host_reg_block_t
;
45
46
/** Primary register block (associated with the "primary" set of registers that control the IP). */
47
static
const
dt_spi_host_reg_block_t
kDtSpiHostRegBlockPrimary = kDtSpiHostRegBlockCore;
48
49
/**
50
* List of IRQs.
51
*
52
* IRQs are guaranteed to be numbered consecutively from 0.
53
*/
54
typedef
enum
dt_spi_host_irq
{
55
kDtSpiHostIrqError
= 0,
/**< Error-related interrupts, see !!ERROR_ENABLE register for more
56
information. */
57
kDtSpiHostIrqSpiEvent
= 1,
/**< Event-related interrupts, see !!EVENT_ENABLE register for more
58
information. */
59
kDtSpiHostIrqCount = 2,
/**< \internal Number of IRQs */
60
}
dt_spi_host_irq_t
;
61
62
/**
63
* List of Alerts.
64
*
65
* Alerts are guaranteed to be numbered consecutively from 0.
66
*/
67
typedef
enum
dt_spi_host_alert
{
68
kDtSpiHostAlertFatalFault
= 0,
/**< This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected. */
69
kDtSpiHostAlertCount = 1,
/**< \internal Number of Alerts */
70
}
dt_spi_host_alert_t
;
71
72
/**
73
* List of clock ports.
74
*
75
* Clock ports are guaranteed to be numbered consecutively from 0.
76
*/
77
typedef
enum
dt_spi_host_clock
{
78
kDtSpiHostClockClk
= 0,
/**< Clock port clk_i */
79
kDtSpiHostClockCount = 1,
/**< \internal Number of clock ports */
80
}
dt_spi_host_clock_t
;
81
82
/**
83
* List of reset ports.
84
*
85
* Reset ports are guaranteed to be numbered consecutively from 0.
86
*/
87
typedef
enum
dt_spi_host_reset
{
88
kDtSpiHostResetRst
= 0,
/**< Reset port rst_ni */
89
kDtSpiHostResetCount = 1,
/**< \internal Number of reset ports */
90
}
dt_spi_host_reset_t
;
91
92
/**
93
* List of peripheral I/O.
94
*
95
* Peripheral I/O are guaranteed to be numbered consecutively from 0.
96
*/
97
typedef
enum
dt_spi_host_periph_io
{
98
kDtSpiHostPeriphIoSck = 0,
/**< */
99
kDtSpiHostPeriphIoCsb = 1,
/**< */
100
kDtSpiHostPeriphIoSd0 = 2,
/**< */
101
kDtSpiHostPeriphIoSd1 = 3,
/**< */
102
kDtSpiHostPeriphIoSd2 = 4,
/**< */
103
kDtSpiHostPeriphIoSd3 = 5,
/**< */
104
kDtSpiHostPeriphIoCount = 6,
/**< \internal Number of peripheral I/O */
105
}
dt_spi_host_periph_io_t
;
106
107
/**
108
* List of supported hardware features.
109
*/
110
#define OPENTITAN_SPI_HOST_HAS_USECASE_SERIALNORFLASH 1
111
#define OPENTITAN_SPI_HOST_HAS_USECASE_PASSTHROUGH 1
112
#define OPENTITAN_SPI_HOST_HAS_RATE_STANDARD 1
113
#define OPENTITAN_SPI_HOST_HAS_RATE_DUAL 1
114
#define OPENTITAN_SPI_HOST_HAS_RATE_QUAD 1
115
#define OPENTITAN_SPI_HOST_HAS_CONFIG_CPOL 1
116
#define OPENTITAN_SPI_HOST_HAS_CONFIG_CLOCKDIV 1
117
#define OPENTITAN_SPI_HOST_HAS_EVENT_WATERMARK 1
118
#define OPENTITAN_SPI_HOST_HAS_EVENT_FULL 1
119
#define OPENTITAN_SPI_HOST_HAS_EVENT_EMPTY 1
120
121
122
123
/**
124
* Get the spi_host instance from an instance ID
125
*
126
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
127
*
128
* @param inst_id Instance ID.
129
* @return A spi_host instance.
130
*
131
* **Note:** This function only makes sense if the instance ID has device type spi_host,
132
* otherwise the returned value is unspecified.
133
*/
134
dt_spi_host_t
dt_spi_host_from_instance_id
(
dt_instance_id_t
inst_id);
135
136
/**
137
* Get the instance ID of an instance.
138
*
139
* @param dt Instance of spi_host.
140
* @return The instance ID of that instance.
141
*/
142
dt_instance_id_t
dt_spi_host_instance_id
(
dt_spi_host_t
dt);
143
144
/**
145
* Get the register base address of an instance.
146
*
147
* @param dt Instance of spi_host.
148
* @param reg_block The register block requested.
149
* @return The register base address of the requested block.
150
*/
151
uint32_t
dt_spi_host_reg_block
(
152
dt_spi_host_t
dt,
153
dt_spi_host_reg_block_t
reg_block);
154
155
/**
156
* Get the primary register base address of an instance.
157
*
158
* This is just a convenience function, equivalent to
159
* `dt_spi_host_reg_block(dt, kDtSpiHostRegBlockCore)`
160
*
161
* @param dt Instance of spi_host.
162
* @return The register base address of the primary register block.
163
*/
164
static
inline
uint32_t dt_spi_host_primary_reg_block(
165
dt_spi_host_t
dt) {
166
return
dt_spi_host_reg_block
(dt, kDtSpiHostRegBlockCore);
167
}
168
169
/**
170
* Get the PLIC ID of a spi_host IRQ for a given instance.
171
*
172
* If the instance is not connected to the PLIC, this function
173
* will return `kDtPlicIrqIdNone`.
174
*
175
* @param dt Instance of spi_host.
176
* @param irq A spi_host IRQ.
177
* @return The PLIC ID of the IRQ of this instance.
178
*/
179
dt_plic_irq_id_t
dt_spi_host_irq_to_plic_id
(
180
dt_spi_host_t
dt,
181
dt_spi_host_irq_t
irq);
182
183
/**
184
* Convert a global IRQ ID to a local spi_host IRQ type.
185
*
186
* @param dt Instance of spi_host.
187
* @param irq A PLIC ID that belongs to this instance.
188
* @return The spi_host IRQ, or `kDtSpiHostIrqCount`.
189
*
190
* **Note:** This function assumes that the PLIC ID belongs to the instance
191
* of spi_host passed in parameter. In other words, it must be the case that
192
* `dt_spi_host_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
193
* will return `kDtSpiHostIrqCount`.
194
*/
195
dt_spi_host_irq_t
dt_spi_host_irq_from_plic_id
(
196
dt_spi_host_t
dt,
197
dt_plic_irq_id_t
irq);
198
199
200
/**
201
* Get the alert ID of a spi_host alert for a given instance.
202
*
203
* **Note:** This function only makes sense if the instance is connected to the Alert Handler. For any
204
* instances where the instance is not connected, the return value is unspecified.
205
*
206
* @param dt Instance of spi_host.
207
* @param alert A spi_host alert.
208
* @return The Alert Handler alert ID of the alert of this instance.
209
*/
210
dt_alert_id_t
dt_spi_host_alert_to_alert_id
(
211
dt_spi_host_t
dt,
212
dt_spi_host_alert_t
alert);
213
214
/**
215
* Convert a global alert ID to a local spi_host alert type.
216
*
217
* @param dt Instance of spi_host.
218
* @param alert A global alert ID that belongs to this instance.
219
* @return The spi_host alert, or `kDtSpiHostAlertCount`.
220
*
221
* **Note:** This function assumes that the global alert ID belongs to the
222
* instance of spi_host passed in parameter. In other words, it must be the case
223
* that `dt_spi_host_instance_id(dt) == dt_alert_id_to_instance_id(alert)`. Otherwise,
224
* this function will return `kDtSpiHostAlertCount`.
225
*/
226
dt_spi_host_alert_t
dt_spi_host_alert_from_alert_id
(
227
dt_spi_host_t
dt,
228
dt_alert_id_t
alert);
229
230
231
/**
232
* Get the peripheral I/O description of an instance.
233
*
234
* @param dt Instance of spi_host.
235
* @param sig Requested peripheral I/O.
236
* @return Description of the requested peripheral I/O for this instance.
237
*/
238
dt_periph_io_t
dt_spi_host_periph_io
(
239
dt_spi_host_t
dt,
240
dt_spi_host_periph_io_t
sig);
241
242
/**
243
* Get the clock signal connected to a clock port of an instance.
244
*
245
* @param dt Instance of spi_host.
246
* @param clk Clock port.
247
* @return Clock signal.
248
*/
249
dt_clock_t
dt_spi_host_clock
(
250
dt_spi_host_t
dt,
251
dt_spi_host_clock_t
clk);
252
253
/**
254
* Get the reset signal connected to a reset port of an instance.
255
*
256
* @param dt Instance of spi_host.
257
* @param rst Reset port.
258
* @return Reset signal.
259
*/
260
dt_reset_t
dt_spi_host_reset
(
261
dt_spi_host_t
dt,
262
dt_spi_host_reset_t
rst);
263
264
265
266
#ifdef __cplusplus
267
}
// extern "C"
268
#endif
// __cplusplus
269
270
#endif
// OPENTITAN_DT_SPI_HOST_H_
(earlgrey)
hw
top
dt
dt_spi_host.h
Return to
OpenTitan Documentation