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 "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/** Primary register block (associated with the "primary" set of registers that control the IP). */
46static const dt_spi_host_reg_block_t kDtSpiHostRegBlockPrimary = kDtSpiHostRegBlockCore;
47
48/**
49 * List of IRQs.
50 *
51 * IRQs are guaranteed to be numbered consecutively from 0.
52 */
53typedef enum dt_spi_host_irq {
54 kDtSpiHostIrqError = 0, /**< Error-related interrupts, see !!ERROR_ENABLE register for more
55 information. */
56 kDtSpiHostIrqSpiEvent = 1, /**< Event-related interrupts, see !!EVENT_ENABLE register for more
57 information. */
58 kDtSpiHostIrqCount = 2, /**< \internal Number of IRQs */
60
61/**
62 * List of clock ports.
63 *
64 * Clock ports are guaranteed to be numbered consecutively from 0.
65 */
66typedef enum dt_spi_host_clock {
67 kDtSpiHostClockClk = 0, /**< Clock port clk_i */
68 kDtSpiHostClockCount = 1, /**< \internal Number of clock ports */
70
71/**
72 * List of reset ports.
73 *
74 * Reset ports are guaranteed to be numbered consecutively from 0.
75 */
76typedef enum dt_spi_host_reset {
77 kDtSpiHostResetRst = 0, /**< Reset port rst_ni */
78 kDtSpiHostResetCount = 1, /**< \internal Number of reset ports */
80
81/**
82 * List of peripheral I/O.
83 *
84 * Peripheral I/O are guaranteed to be numbered consecutively from 0.
85 */
87 kDtSpiHostPeriphIoSck = 0, /**< */
88 kDtSpiHostPeriphIoCsb = 1, /**< */
89 kDtSpiHostPeriphIoSd0 = 2, /**< */
90 kDtSpiHostPeriphIoSd1 = 3, /**< */
91 kDtSpiHostPeriphIoSd2 = 4, /**< */
92 kDtSpiHostPeriphIoSd3 = 5, /**< */
93 kDtSpiHostPeriphIoCount = 6, /**< \internal Number of peripheral I/O */
95
96/**
97 * List of supported hardware features.
98 */
99#define OPENTITAN_SPI_HOST_HAS_USECASE_SERIALNORFLASH 1
100#define OPENTITAN_SPI_HOST_HAS_USECASE_PASSTHROUGH 1
101#define OPENTITAN_SPI_HOST_HAS_RATE_STANDARD 1
102#define OPENTITAN_SPI_HOST_HAS_RATE_DUAL 1
103#define OPENTITAN_SPI_HOST_HAS_RATE_QUAD 1
104#define OPENTITAN_SPI_HOST_HAS_CONFIG_CPOL 1
105#define OPENTITAN_SPI_HOST_HAS_CONFIG_CLOCKDIV 1
106#define OPENTITAN_SPI_HOST_HAS_EVENT_WATERMARK 1
107#define OPENTITAN_SPI_HOST_HAS_EVENT_FULL 1
108#define OPENTITAN_SPI_HOST_HAS_EVENT_EMPTY 1
109
110
111
112/**
113 * Get the spi_host instance from an instance ID
114 *
115 * For example, `dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3`.
116 *
117 * @param inst_id Instance ID.
118 * @return A spi_host instance.
119 *
120 * **Note:** This function only makes sense if the instance ID has device type spi_host,
121 * otherwise the returned value is unspecified.
122 */
124
125/**
126 * Get the instance ID of an instance.
127 *
128 * @param dt Instance of spi_host.
129 * @return The instance ID of that instance.
130 */
132
133/**
134 * Get the register base address of an instance.
135 *
136 * @param dt Instance of spi_host.
137 * @param reg_block The register block requested.
138 * @return The register base address of the requested block.
139 */
140uint32_t dt_spi_host_reg_block(
141 dt_spi_host_t dt,
142 dt_spi_host_reg_block_t reg_block);
143
144/**
145 * Get the primary register base address of an instance.
146 *
147 * This is just a convenience function, equivalent to
148 * `dt_spi_host_reg_block(dt, kDtSpiHostRegBlockCore)`
149 *
150 * @param dt Instance of spi_host.
151 * @return The register base address of the primary register block.
152 */
153static inline uint32_t dt_spi_host_primary_reg_block(
154 dt_spi_host_t dt) {
155 return dt_spi_host_reg_block(dt, kDtSpiHostRegBlockCore);
156}
157
158/**
159 * Get the PLIC ID of a spi_host IRQ for a given instance.
160 *
161 * If the instance is not connected to the PLIC, this function
162 * will return `kDtPlicIrqIdNone`.
163 *
164 * @param dt Instance of spi_host.
165 * @param irq A spi_host IRQ.
166 * @return The PLIC ID of the IRQ of this instance.
167 */
169 dt_spi_host_t dt,
171
172/**
173 * Convert a global IRQ ID to a local spi_host IRQ type.
174 *
175 * @param dt Instance of spi_host.
176 * @param irq A PLIC ID that belongs to this instance.
177 * @return The spi_host IRQ, or `kDtSpiHostIrqCount`.
178 *
179 * **Note:** This function assumes that the PLIC ID belongs to the instance
180 * of spi_host passed in parameter. In other words, it must be the case that
181 * `dt_spi_host_instance_id(dt) == dt_plic_id_to_instance_id(irq)`. Otherwise, this function
182 * will return `kDtSpiHostIrqCount`.
183 */
185 dt_spi_host_t dt,
186 dt_plic_irq_id_t irq);
187
188
189
190/**
191 * Get the peripheral I/O description of an instance.
192 *
193 * @param dt Instance of spi_host.
194 * @param sig Requested peripheral I/O.
195 * @return Description of the requested peripheral I/O for this instance.
196 */
198 dt_spi_host_t dt,
200
201/**
202 * Get the clock signal connected to a clock port of an instance.
203 *
204 * @param dt Instance of spi_host.
205 * @param clk Clock port.
206 * @return Clock signal.
207 */
209 dt_spi_host_t dt,
211
212/**
213 * Get the reset signal connected to a reset port of an instance.
214 *
215 * @param dt Instance of spi_host.
216 * @param rst Reset port.
217 * @return Reset signal.
218 */
220 dt_spi_host_t dt,
222
223
224
225#ifdef __cplusplus
226} // extern "C"
227#endif // __cplusplus
228
229#endif // OPENTITAN_DT_SPI_HOST_H_