Software APIs
spi_device.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_DEVICE_H_
8
#define OPENTITAN_DT_SPI_DEVICE_H_
9
10
#ifdef __cplusplus
11
extern
"C"
{
12
#endif
// __cplusplus
13
14
/**
15
* @file
16
* @brief Device Tables (DT) for IP spi_device and top englishbreakfast.
17
*
18
* This file contains the type definitions and global functions of the spi_device.
19
*/
20
21
#include "hw/top/dt/api.h"
22
#include <stdint.h>
23
24
25
26
/**
27
* List of instances.
28
*/
29
typedef
enum
dt_spi_device
{
30
kDtSpiDeviceFirst
= 0,
/**< First instance */
31
kDtSpiDevice
= 0,
/**< spi_device */
32
}
dt_spi_device_t
;
33
34
enum
{
35
kDtSpiDeviceCount
= 1,
/**< Number of instances */
36
};
37
38
39
/**
40
* List of register blocks.
41
*
42
* Register blocks are guaranteed to start at 0 and to be consecutively numbered.
43
*/
44
typedef
enum
dt_spi_device_reg_block
{
45
kDtSpiDeviceRegBlockCore = 0,
/**< */
46
}
dt_spi_device_reg_block_t
;
47
48
enum
{
49
kDtSpiDeviceRegBlockCount
= 1,
/**< Number of register blocks */
50
};
51
52
53
/** Primary register block (associated with the "primary" set of registers that control the IP). */
54
static
const
dt_spi_device_reg_block_t
kDtSpiDeviceRegBlockPrimary = kDtSpiDeviceRegBlockCore;
55
56
/**
57
* List of IRQs.
58
*
59
* IRQs are guaranteed to be numbered consecutively from 0.
60
*/
61
typedef
enum
dt_spi_device_irq
{
62
kDtSpiDeviceIrqUploadCmdfifoNotEmpty
= 0,
/**< Upload Command FIFO is not empty */
63
kDtSpiDeviceIrqUploadPayloadNotEmpty
= 1,
/**< Upload payload is not empty.
64
65
The event occurs after SPI transaction completed */
66
kDtSpiDeviceIrqUploadPayloadOverflow
= 2,
/**< Upload payload overflow event.
67
68
When a SPI Host system issues a command with payload more than 256B,
69
this event is reported. When it happens, SW should read the last
70
written payload index CSR to figure out the starting address of the
71
last 256B. */
72
kDtSpiDeviceIrqReadbufWatermark
= 3,
/**< Read Buffer Threshold event.
73
74
The host system accesses greater than or equal to the threshold of a
75
buffer. */
76
kDtSpiDeviceIrqReadbufFlip
= 4,
/**< Read buffer flipped event.
77
78
The host system accesses other side of buffer. */
79
kDtSpiDeviceIrqTpmHeaderNotEmpty
= 5,
/**< TPM Header(Command/Address) buffer available */
80
kDtSpiDeviceIrqTpmRdfifoCmdEnd
= 6,
/**< TPM RdFIFO command ended.
81
82
The TPM Read command targeting the RdFIFO ended.
83
Check TPM_STATUS.rdfifo_aborted to see if the transaction completed. */
84
kDtSpiDeviceIrqTpmRdfifoDrop
= 7,
/**< TPM RdFIFO data dropped.
85
86
Data was dropped from the RdFIFO.
87
Data was written while a read command was not active, and it was not accepted.
88
This can occur when the host aborts a read command. */
89
}
dt_spi_device_irq_t
;
90
91
enum
{
92
kDtSpiDeviceIrqCount
= 8,
/**< Number of IRQs */
93
};
94
95
96
/**
97
* List of clock ports.
98
*
99
* Clock ports are guaranteed to be numbered consecutively from 0.
100
*/
101
typedef
enum
dt_spi_device_clock
{
102
kDtSpiDeviceClockClk
= 0,
/**< Clock port clk_i */
103
}
dt_spi_device_clock_t
;
104
105
enum
{
106
kDtSpiDeviceClockCount
= 1,
/**< Number of clock ports */
107
};
108
109
110
/**
111
* List of reset ports.
112
*
113
* Reset ports are guaranteed to be numbered consecutively from 0.
114
*/
115
typedef
enum
dt_spi_device_reset
{
116
kDtSpiDeviceResetRst
= 0,
/**< Reset port rst_ni */
117
}
dt_spi_device_reset_t
;
118
119
enum
{
120
kDtSpiDeviceResetCount
= 1,
/**< Number of reset ports */
121
};
122
123
124
/**
125
* List of peripheral I/O.
126
*
127
* Peripheral I/O are guaranteed to be numbered consecutively from 0.
128
*/
129
typedef
enum
dt_spi_device_periph_io
{
130
kDtSpiDevicePeriphIoSck = 0,
/**< */
131
kDtSpiDevicePeriphIoCsb = 1,
/**< */
132
kDtSpiDevicePeriphIoTpmCsb = 2,
/**< */
133
kDtSpiDevicePeriphIoSd0 = 3,
/**< */
134
kDtSpiDevicePeriphIoSd1 = 4,
/**< */
135
kDtSpiDevicePeriphIoSd2 = 5,
/**< */
136
kDtSpiDevicePeriphIoSd3 = 6,
/**< */
137
}
dt_spi_device_periph_io_t
;
138
139
enum
{
140
kDtSpiDevicePeriphIoCount
= 7,
/**< Number of peripheral I/O */
141
};
142
143
144
/**
145
* List of supported hardware features.
146
*/
147
#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION 1
148
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH 1
149
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM 1
150
#define OPENTITAN_SPI_DEVICE_HAS_HW_LANES 1
151
#define OPENTITAN_SPI_DEVICE_HAS_HW_SERDES_ORDERING 1
152
#define OPENTITAN_SPI_DEVICE_HAS_HW_CSB_STATUS 1
153
#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_COMMANDS 1
154
#define OPENTITAN_SPI_DEVICE_HAS_HW_FLASH_EMULATION_BLOCKS 1
155
#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_READ_COMMAND_PROCESSOR 1
156
#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_DUMMY_CYCLE 1
157
#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_WRITE_ENABLE_DISABLE 1
158
#define OPENTITAN_SPI_DEVICE_HAS_HW_LAST_READ_ADDR 1
159
#define OPENTITAN_SPI_DEVICE_HAS_HW_CMDINFOS 1
160
#define OPENTITAN_SPI_DEVICE_HAS_HW_COMMAND_UPLOAD 1
161
#define OPENTITAN_SPI_DEVICE_HAS_HW_3B4B_ADDRESSING 1
162
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_CMD_FILTER 1
163
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_ADDRESS_MANIPULATION 1
164
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_STATUS_MANIPULATION 1
165
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_OUTPUT_ENABLE_CONTROL 1
166
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_INTERCEPT_EN 1
167
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_MAILBOX 1
168
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_RETURN_BY_HW_REGS 1
169
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_AUTO_WAIT 1
170
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_READ_FIFO_MODE 1
171
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_CAPABILITY 1
172
173
174
175
/**
176
* Get the spi_device instance from an instance ID
177
*
178
* For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
179
*
180
* @param inst_id Instance ID.
181
* @return A spi_device instance.
182
*
183
* **Note:** This function only makes sense if the instance ID has device type spi_device,
184
* otherwise the returned value is unspecified.
185
*/
186
dt_spi_device_t
dt_spi_device_from_instance_id
(
dt_instance_id_t
inst_id);
187
188
/**
189
* Get the instance ID of an instance.
190
*
191
* @param dt Instance of spi_device.
192
* @return The instance ID of that instance.
193
*/
194
dt_instance_id_t
dt_spi_device_instance_id
(
dt_spi_device_t
dt);
195
196
/**
197
* Get the register base address of an instance.
198
*
199
* @param dt Instance of spi_device.
200
* @param reg_block The register block requested.
201
* @return The register base address of the requested block.
202
*/
203
uint32_t
dt_spi_device_reg_block
(
204
dt_spi_device_t
dt,
205
dt_spi_device_reg_block_t
reg_block);
206
207
/**
208
* Get the primary register base address of an instance.
209
*
210
* This is just a convenience function, equivalent to
211
* `dt_spi_device_reg_block(dt, kDtSpiDeviceRegBlockCore)`
212
*
213
* @param dt Instance of spi_device.
214
* @return The register base address of the primary register block.
215
*/
216
static
inline
uint32_t dt_spi_device_primary_reg_block(
217
dt_spi_device_t
dt) {
218
return
dt_spi_device_reg_block
(dt, kDtSpiDeviceRegBlockCore);
219
}
220
221
/**
222
* Get the PLIC ID of a spi_device IRQ for a given instance.
223
*
224
* If the instance is not connected to the PLIC, this function
225
* will return `kDtPlicIrqIdNone`.
226
*
227
* @param dt Instance of spi_device.
228
* @param irq A spi_device IRQ.
229
* @return The PLIC ID of the IRQ of this instance.
230
*/
231
dt_plic_irq_id_t
dt_spi_device_irq_to_plic_id
(
232
dt_spi_device_t
dt,
233
dt_spi_device_irq_t
irq);
234
235
/**
236
* Convert a global IRQ ID to a local spi_device IRQ type.
237
*
238
* @param dt Instance of spi_device.
239
* @param irq A PLIC ID that belongs to this instance.
240
* @return The spi_device IRQ, or `kDtSpiDeviceIrqCount`.
241
*
242
* **Note:** This function assumes that the PLIC ID belongs to the instance
243
* of spi_device passed in parameter. In other words, it must be the case that
244
* `dt_spi_device_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
245
* will return `kDtSpiDeviceIrqCount`.
246
*/
247
dt_spi_device_irq_t
dt_spi_device_irq_from_plic_id
(
248
dt_spi_device_t
dt,
249
dt_plic_irq_id_t
irq);
250
251
252
253
/**
254
* Get the peripheral I/O description of an instance.
255
*
256
* @param dt Instance of spi_device.
257
* @param sig Requested peripheral I/O.
258
* @return Description of the requested peripheral I/O for this instance.
259
*/
260
dt_periph_io_t
dt_spi_device_periph_io
(
261
dt_spi_device_t
dt,
262
dt_spi_device_periph_io_t
sig);
263
264
/**
265
* Get the clock signal connected to a clock port of an instance.
266
*
267
* @param dt Instance of spi_device.
268
* @param clk Clock port.
269
* @return Clock signal.
270
*/
271
dt_clock_t
dt_spi_device_clock
(
272
dt_spi_device_t
dt,
273
dt_spi_device_clock_t
clk);
274
275
/**
276
* Get the reset signal connected to a reset port of an instance.
277
*
278
* @param dt Instance of spi_device.
279
* @param rst Reset port.
280
* @return Reset signal.
281
*/
282
dt_reset_t
dt_spi_device_reset
(
283
dt_spi_device_t
dt,
284
dt_spi_device_reset_t
rst);
285
286
287
288
#ifdef __cplusplus
289
}
// extern "C"
290
#endif
// __cplusplus
291
292
#endif
// OPENTITAN_DT_SPI_DEVICE_H_
(englishbreakfast)
hw
top
dt
spi_device.h
Return to
OpenTitan Documentation