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
11extern "C" {
12#endif // __cplusplus
13
14/**
15 * @file
16 * @brief Device Tables (DT) for IP spi_host and top englishbreakfast.
17 *
18 * This file contains the type definitions and global functions of the spi_host.
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_spi_host {
30 kDtSpiHost0 = 0, /**< spi_host0 */
31 kDtSpiHostFirst = 0, /**< \internal First instance */
32 kDtSpiHostCount = 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 */
41 kDtSpiHostRegBlockCore = 0, /**< */
42 kDtSpiHostRegBlockCount = 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_spi_host_memory {
51 kDtSpiHostMemoryCount = 0, /**< \internal Number of memories */
53
54/** Primary register block (associated with the "primary" set of registers that control the IP). */
55static const dt_spi_host_reg_block_t kDtSpiHostRegBlockPrimary = kDtSpiHostRegBlockCore;
56
57/**
58 * List of IRQs.
59 *
60 * IRQs are guaranteed to be numbered consecutively from 0.
61 */
62typedef enum dt_spi_host_irq {
63 kDtSpiHostIrqError = 0, /**< Error-related interrupts, see !!ERROR_ENABLE register for more
64 information. */
65 kDtSpiHostIrqSpiEvent = 1, /**< Event-related interrupts, see !!EVENT_ENABLE register for more
66 information. */
67 kDtSpiHostIrqCount = 2, /**< \internal Number of IRQs */
69
70/**
71 * List of clock ports.
72 *
73 * Clock ports are guaranteed to be numbered consecutively from 0.
74 */
75typedef enum dt_spi_host_clock {
76 kDtSpiHostClockClk = 0, /**< Clock port clk_i */
77 kDtSpiHostClockCount = 1, /**< \internal Number of clock ports */
79
80/**
81 * List of reset ports.
82 *
83 * Reset ports are guaranteed to be numbered consecutively from 0.
84 */
85typedef enum dt_spi_host_reset {
86 kDtSpiHostResetRst = 0, /**< Reset port rst_ni */
87 kDtSpiHostResetCount = 1, /**< \internal Number of reset ports */
89
90/**
91 * List of peripheral I/O.
92 *
93 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
94 */
96 kDtSpiHostPeriphIoSck = 0, /**< */
97 kDtSpiHostPeriphIoCsb = 1, /**< */
98 kDtSpiHostPeriphIoSd0 = 2, /**< */
99 kDtSpiHostPeriphIoSd1 = 3, /**< */
100 kDtSpiHostPeriphIoSd2 = 4, /**< */
101 kDtSpiHostPeriphIoSd3 = 5, /**< */
102 kDtSpiHostPeriphIoCount = 6, /**< \internal Number of peripheral I/O */
104
105/**
106 * List of supported hardware features.
107 */
108#define OPENTITAN_SPI_HOST_HAS_USECASE_SERIALNORFLASH 1
109#define OPENTITAN_SPI_HOST_HAS_USECASE_PASSTHROUGH 1
110#define OPENTITAN_SPI_HOST_HAS_RATE_STANDARD 1
111#define OPENTITAN_SPI_HOST_HAS_RATE_DUAL 1
112#define OPENTITAN_SPI_HOST_HAS_RATE_QUAD 1
113#define OPENTITAN_SPI_HOST_HAS_CONFIG_CPOL 1
114#define OPENTITAN_SPI_HOST_HAS_CONFIG_CLOCKDIV 1
115#define OPENTITAN_SPI_HOST_HAS_EVENT_WATERMARK 1
116#define OPENTITAN_SPI_HOST_HAS_EVENT_FULL 1
117#define OPENTITAN_SPI_HOST_HAS_EVENT_EMPTY 1
118
119
120
121/**
122 * Get the spi_host instance from an instance ID
123 *
124 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
125 *
126 * @param inst_id Instance ID.
127 * @return A spi_host instance.
128 *
129 * **Note:** This function only makes sense if the instance ID has device type spi_host,
130 * otherwise the returned value is unspecified.
131 */
133
134/**
135 * Get the instance ID of an instance.
136 *
137 * @param dt Instance of spi_host.
138 * @return The instance ID of that instance.
139 */
141
142/**
143 * Get the register base address of an instance.
144 *
145 * @param dt Instance of spi_host.
146 * @param reg_block The register block requested.
147 * @return The register base address of the requested block.
148 */
149uint32_t dt_spi_host_reg_block(
150 dt_spi_host_t dt,
151 dt_spi_host_reg_block_t reg_block);
152
153/**
154 * Get the primary register base address of an instance.
155 *
156 * This is just a convenience function, equivalent to
157 * `dt_spi_host_reg_block(dt, kDtSpiHostRegBlockCore)`
158 *
159 * @param dt Instance of spi_host.
160 * @return The register base address of the primary register block.
161 */
162static inline uint32_t dt_spi_host_primary_reg_block(
163 dt_spi_host_t dt) {
164 return dt_spi_host_reg_block(dt, kDtSpiHostRegBlockCore);
165}
166
167/**
168 * Get the base address of a memory.
169 *
170 * @param dt Instance of spi_host.
171 * @param mem The memory requested.
172 * @return The base address of the requested memory.
173 */
175 dt_spi_host_t dt,
177
178/**
179 * Get the size of a memory.
180 *
181 * @param dt Instance of spi_host.
182 * @param mem The memory requested.
183 * @return The size of the requested memory.
184 */
186 dt_spi_host_t dt,
188
189/**
190 * Get the PLIC ID of a spi_host IRQ for a given instance.
191 *
192 * If the instance is not connected to the PLIC, this function
193 * will return `kDtPlicIrqIdNone`.
194 *
195 * @param dt Instance of spi_host.
196 * @param irq A spi_host IRQ.
197 * @return The PLIC ID of the IRQ of this instance.
198 */
200 dt_spi_host_t dt,
202
203/**
204 * Convert a global IRQ ID to a local spi_host IRQ type.
205 *
206 * @param dt Instance of spi_host.
207 * @param irq A PLIC ID that belongs to this instance.
208 * @return The spi_host IRQ, or `kDtSpiHostIrqCount`.
209 *
210 * **Note:** This function assumes that the PLIC ID belongs to the instance
211 * of spi_host passed in parameter. In other words, it must be the case that
212 * `dt_spi_host_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
213 * will return `kDtSpiHostIrqCount`.
214 */
216 dt_spi_host_t dt,
217 dt_plic_irq_id_t irq);
218
219
220
221/**
222 * Get the peripheral I/O description of an instance.
223 *
224 * @param dt Instance of spi_host.
225 * @param sig Requested peripheral I/O.
226 * @return Description of the requested peripheral I/O for this instance.
227 */
229 dt_spi_host_t dt,
231
232/**
233 * Get the clock signal connected to a clock port of an instance.
234 *
235 * @param dt Instance of spi_host.
236 * @param clk Clock port.
237 * @return Clock signal.
238 */
240 dt_spi_host_t dt,
242
243/**
244 * Get the reset signal connected to a reset port of an instance.
245 *
246 * @param dt Instance of spi_host.
247 * @param rst Reset port.
248 * @return Reset signal.
249 */
251 dt_spi_host_t dt,
253
254
255
256#ifdef __cplusplus
257} // extern "C"
258#endif // __cplusplus
259
260#endif // OPENTITAN_DT_SPI_HOST_H_