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