Software APIs
dt_spi_host.h File Reference

Device Tables (DT) for IP spi_host and top englishbreakfast. More...

#include "dt_api.h"
#include <stdint.h>

Go to the source code of this file.

Macros

#define OPENTITAN_SPI_HOST_HAS_USECASE_SERIALNORFLASH   1
 List of supported hardware features.
 
#define OPENTITAN_SPI_HOST_HAS_USECASE_PASSTHROUGH   1
 
#define OPENTITAN_SPI_HOST_HAS_RATE_STANDARD   1
 
#define OPENTITAN_SPI_HOST_HAS_RATE_DUAL   1
 
#define OPENTITAN_SPI_HOST_HAS_RATE_QUAD   1
 
#define OPENTITAN_SPI_HOST_HAS_CONFIG_CPOL   1
 
#define OPENTITAN_SPI_HOST_HAS_CONFIG_CLOCKDIV   1
 
#define OPENTITAN_SPI_HOST_HAS_EVENT_WATERMARK   1
 
#define OPENTITAN_SPI_HOST_HAS_EVENT_FULL   1
 
#define OPENTITAN_SPI_HOST_HAS_EVENT_EMPTY   1
 

Typedefs

typedef enum dt_spi_host dt_spi_host_t
 List of instances.
 
typedef enum dt_spi_host_reg_block dt_spi_host_reg_block_t
 List of register blocks.
 
typedef enum dt_spi_host_irq dt_spi_host_irq_t
 List of IRQs.
 
typedef enum dt_spi_host_clock dt_spi_host_clock_t
 List of clock ports.
 
typedef enum dt_spi_host_reset dt_spi_host_reset_t
 List of reset ports.
 
typedef enum dt_spi_host_periph_io dt_spi_host_periph_io_t
 List of peripheral I/O.
 

Enumerations

enum  dt_spi_host {
  kDtSpiHost0 = 0 ,
  kDtSpiHostFirst = 0 ,
  kDtSpiHostCount = 1
}
 List of instances. More...
 
enum  dt_spi_host_reg_block {
  kDtSpiHostRegBlockCore = 0 ,
  kDtSpiHostRegBlockCount = 1
}
 List of register blocks. More...
 
enum  dt_spi_host_irq {
  kDtSpiHostIrqError = 0 ,
  kDtSpiHostIrqSpiEvent = 1 ,
  kDtSpiHostIrqCount = 2
}
 List of IRQs. More...
 
enum  dt_spi_host_clock {
  kDtSpiHostClockClk = 0 ,
  kDtSpiHostClockCount = 1
}
 List of clock ports. More...
 
enum  dt_spi_host_reset {
  kDtSpiHostResetRst = 0 ,
  kDtSpiHostResetCount = 1
}
 List of reset ports. More...
 
enum  dt_spi_host_periph_io {
  kDtSpiHostPeriphIoSck = 0 ,
  kDtSpiHostPeriphIoCsb = 1 ,
  kDtSpiHostPeriphIoSd0 = 2 ,
  kDtSpiHostPeriphIoSd1 = 3 ,
  kDtSpiHostPeriphIoSd2 = 4 ,
  kDtSpiHostPeriphIoSd3 = 5 ,
  kDtSpiHostPeriphIoCount = 6
}
 List of peripheral I/O. More...
 

Functions

dt_spi_host_t dt_spi_host_from_instance_id (dt_instance_id_t inst_id)
 Get the spi_host instance from an instance ID.
 
dt_instance_id_t dt_spi_host_instance_id (dt_spi_host_t dt)
 Get the instance ID of an instance.
 
uint32_t dt_spi_host_reg_block (dt_spi_host_t dt, dt_spi_host_reg_block_t reg_block)
 Get the register base address of an instance.
 
dt_plic_irq_id_t dt_spi_host_irq_to_plic_id (dt_spi_host_t dt, dt_spi_host_irq_t irq)
 Get the PLIC ID of a spi_host IRQ for a given instance.
 
dt_spi_host_irq_t dt_spi_host_irq_from_plic_id (dt_spi_host_t dt, dt_plic_irq_id_t irq)
 Convert a global IRQ ID to a local spi_host IRQ type.
 
dt_periph_io_t dt_spi_host_periph_io (dt_spi_host_t dt, dt_spi_host_periph_io_t sig)
 Get the peripheral I/O description of an instance.
 
dt_clock_t dt_spi_host_clock (dt_spi_host_t dt, dt_spi_host_clock_t clk)
 Get the clock signal connected to a clock port of an instance.
 
dt_reset_t dt_spi_host_reset (dt_spi_host_t dt, dt_spi_host_reset_t rst)
 Get the reset signal connected to a reset port of an instance.
 

Detailed Description

Device Tables (DT) for IP spi_host and top englishbreakfast.

This file contains the type definitions and global functions of the spi_host.

Definition in file dt_spi_host.h.

Macro Definition Documentation

◆ OPENTITAN_SPI_HOST_HAS_CONFIG_CLOCKDIV

#define OPENTITAN_SPI_HOST_HAS_CONFIG_CLOCKDIV   1

Definition at line 99 of file dt_spi_host.h.

◆ OPENTITAN_SPI_HOST_HAS_CONFIG_CPOL

#define OPENTITAN_SPI_HOST_HAS_CONFIG_CPOL   1

Definition at line 98 of file dt_spi_host.h.

◆ OPENTITAN_SPI_HOST_HAS_EVENT_EMPTY

#define OPENTITAN_SPI_HOST_HAS_EVENT_EMPTY   1

Definition at line 102 of file dt_spi_host.h.

◆ OPENTITAN_SPI_HOST_HAS_EVENT_FULL

#define OPENTITAN_SPI_HOST_HAS_EVENT_FULL   1

Definition at line 101 of file dt_spi_host.h.

◆ OPENTITAN_SPI_HOST_HAS_EVENT_WATERMARK

#define OPENTITAN_SPI_HOST_HAS_EVENT_WATERMARK   1

Definition at line 100 of file dt_spi_host.h.

◆ OPENTITAN_SPI_HOST_HAS_RATE_DUAL

#define OPENTITAN_SPI_HOST_HAS_RATE_DUAL   1

Definition at line 96 of file dt_spi_host.h.

◆ OPENTITAN_SPI_HOST_HAS_RATE_QUAD

#define OPENTITAN_SPI_HOST_HAS_RATE_QUAD   1

Definition at line 97 of file dt_spi_host.h.

◆ OPENTITAN_SPI_HOST_HAS_RATE_STANDARD

#define OPENTITAN_SPI_HOST_HAS_RATE_STANDARD   1

Definition at line 95 of file dt_spi_host.h.

◆ OPENTITAN_SPI_HOST_HAS_USECASE_PASSTHROUGH

#define OPENTITAN_SPI_HOST_HAS_USECASE_PASSTHROUGH   1

Definition at line 94 of file dt_spi_host.h.

◆ OPENTITAN_SPI_HOST_HAS_USECASE_SERIALNORFLASH

#define OPENTITAN_SPI_HOST_HAS_USECASE_SERIALNORFLASH   1

List of supported hardware features.

Definition at line 93 of file dt_spi_host.h.

Typedef Documentation

◆ dt_spi_host_clock_t

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

◆ dt_spi_host_irq_t

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

◆ dt_spi_host_periph_io_t

List of peripheral I/O.

Peripheral I/O are guaranteed to be numbered consecutively from 0.

◆ dt_spi_host_reg_block_t

List of register blocks.

Register blocks are guaranteed to start at 0 and to be consecutively numbered.

◆ dt_spi_host_reset_t

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumeration Type Documentation

◆ dt_spi_host

List of instances.

Enumerator
kDtSpiHost0 

spi_host0

Definition at line 23 of file dt_spi_host.h.

◆ dt_spi_host_clock

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtSpiHostClockClk 

Clock port clk_i.

Definition at line 60 of file dt_spi_host.h.

◆ dt_spi_host_irq

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

Enumerator
kDtSpiHostIrqError 

Error-related interrupts, see !

!ERROR_ENABLE register for more information.

kDtSpiHostIrqSpiEvent 

Event-related interrupts, see !

!EVENT_ENABLE register for more information.

Definition at line 47 of file dt_spi_host.h.

◆ dt_spi_host_periph_io

List of peripheral I/O.

Peripheral I/O are guaranteed to be numbered consecutively from 0.

Definition at line 80 of file dt_spi_host.h.

◆ dt_spi_host_reg_block

List of register blocks.

Register blocks are guaranteed to start at 0 and to be consecutively numbered.

Definition at line 34 of file dt_spi_host.h.

◆ dt_spi_host_reset

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtSpiHostResetRst 

Reset port rst_ni.

Definition at line 70 of file dt_spi_host.h.

Function Documentation

◆ dt_spi_host_clock()

Get the clock signal connected to a clock port of an instance.

Parameters
dtInstance of spi_host.
clkClock port.
Returns
Clock signal.

Definition at line 248 of file dt_spi_host.c.

◆ dt_spi_host_from_instance_id()

dt_spi_host_t dt_spi_host_from_instance_id ( dt_instance_id_t inst_id)

Get the spi_host instance from an instance ID.

For example, dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3.

Parameters
inst_idInstance ID.
Returns
A spi_host instance.

Note: This function only makes sense if the instance ID has device type spi_host, otherwise the returned value is unspecified.

Definition at line 180 of file dt_spi_host.c.

◆ dt_spi_host_instance_id()

dt_instance_id_t dt_spi_host_instance_id ( dt_spi_host_t dt)

Get the instance ID of an instance.

Parameters
dtInstance of spi_host.
Returns
The instance ID of that instance.

Definition at line 187 of file dt_spi_host.c.

◆ dt_spi_host_irq_from_plic_id()

dt_spi_host_irq_t dt_spi_host_irq_from_plic_id ( dt_spi_host_t dt,
dt_plic_irq_id_t irq )

Convert a global IRQ ID to a local spi_host IRQ type.

Parameters
dtInstance of spi_host.
irqA PLIC ID that belongs to this instance.
Returns
The spi_host IRQ, or kDtSpiHostIrqCount.

Note: This function assumes that the PLIC ID belongs to the instance of spi_host passed in parameter. In other words, it must be the case that dt_spi_host_instance_id(dt) == dt_plic_id_to_instance_id(irq). Otherwise, this function will return kDtSpiHostIrqCount.

Definition at line 209 of file dt_spi_host.c.

◆ dt_spi_host_irq_to_plic_id()

dt_plic_irq_id_t dt_spi_host_irq_to_plic_id ( dt_spi_host_t dt,
dt_spi_host_irq_t irq )

Get the PLIC ID of a spi_host IRQ for a given instance.

If the instance is not connected to the PLIC, this function will return kDtPlicIrqIdNone.

Parameters
dtInstance of spi_host.
irqA spi_host IRQ.
Returns
The PLIC ID of the IRQ of this instance.

Definition at line 199 of file dt_spi_host.c.

◆ dt_spi_host_periph_io()

Get the peripheral I/O description of an instance.

Parameters
dtInstance of spi_host.
sigRequested peripheral I/O.
Returns
Description of the requested peripheral I/O for this instance.

Definition at line 241 of file dt_spi_host.c.

◆ dt_spi_host_reg_block()

Get the register base address of an instance.

Parameters
dtInstance of spi_host.
reg_blockThe register block requested.
Returns
The register base address of the requested block.

Definition at line 192 of file dt_spi_host.c.

◆ dt_spi_host_reset()

Get the reset signal connected to a reset port of an instance.

Parameters
dtInstance of spi_host.
rstReset port.
Returns
Reset signal.

Definition at line 255 of file dt_spi_host.c.