Software APIs
dt_spi_device.h File Reference

Device Tables (DT) for IP spi_device and top earlgrey. More...

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

Go to the source code of this file.

Macros

#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION   1
 List of supported hardware features.
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM   1
 
#define OPENTITAN_SPI_DEVICE_HAS_HW_LANES   1
 
#define OPENTITAN_SPI_DEVICE_HAS_HW_SERDES_ORDERING   1
 
#define OPENTITAN_SPI_DEVICE_HAS_HW_CSB_STATUS   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_COMMANDS   1
 
#define OPENTITAN_SPI_DEVICE_HAS_HW_FLASH_EMULATION_BLOCKS   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_READ_COMMAND_PROCESSOR   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_DUMMY_CYCLE   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_WRITE_ENABLE_DISABLE   1
 
#define OPENTITAN_SPI_DEVICE_HAS_HW_LAST_READ_ADDR   1
 
#define OPENTITAN_SPI_DEVICE_HAS_HW_CMDINFOS   1
 
#define OPENTITAN_SPI_DEVICE_HAS_HW_COMMAND_UPLOAD   1
 
#define OPENTITAN_SPI_DEVICE_HAS_HW_3B4B_ADDRESSING   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_CMD_FILTER   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_ADDRESS_MANIPULATION   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_STATUS_MANIPULATION   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_OUTPUT_ENABLE_CONTROL   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_INTERCEPT_EN   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_MAILBOX   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_RETURN_BY_HW_REGS   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_AUTO_WAIT   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_READ_FIFO_MODE   1
 
#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_CAPABILITY   1
 

Typedefs

typedef enum dt_spi_device dt_spi_device_t
 List of instances.
 
typedef enum dt_spi_device_reg_block dt_spi_device_reg_block_t
 List of register blocks.
 
typedef enum dt_spi_device_irq dt_spi_device_irq_t
 List of IRQs.
 
typedef enum dt_spi_device_alert dt_spi_device_alert_t
 List of Alerts.
 
typedef enum dt_spi_device_clock dt_spi_device_clock_t
 List of clock ports.
 
typedef enum dt_spi_device_reset dt_spi_device_reset_t
 List of reset ports.
 
typedef enum dt_spi_device_periph_io dt_spi_device_periph_io_t
 List of peripheral I/O.
 

Enumerations

enum  dt_spi_device {
  kDtSpiDevice = 0 ,
  kDtSpiDeviceFirst = 0 ,
  kDtSpiDeviceCount = 1
}
 List of instances. More...
 
enum  dt_spi_device_reg_block {
  kDtSpiDeviceRegBlockCore = 0 ,
  kDtSpiDeviceRegBlockCount = 1
}
 List of register blocks. More...
 
enum  dt_spi_device_irq {
  kDtSpiDeviceIrqUploadCmdfifoNotEmpty = 0 ,
  kDtSpiDeviceIrqUploadPayloadNotEmpty = 1 ,
  kDtSpiDeviceIrqUploadPayloadOverflow = 2 ,
  kDtSpiDeviceIrqReadbufWatermark = 3 ,
  kDtSpiDeviceIrqReadbufFlip = 4 ,
  kDtSpiDeviceIrqTpmHeaderNotEmpty = 5 ,
  kDtSpiDeviceIrqTpmRdfifoCmdEnd = 6 ,
  kDtSpiDeviceIrqTpmRdfifoDrop = 7 ,
  kDtSpiDeviceIrqCount = 8
}
 List of IRQs. More...
 
enum  dt_spi_device_alert {
  kDtSpiDeviceAlertFatalFault = 0 ,
  kDtSpiDeviceAlertCount = 1
}
 List of Alerts. More...
 
enum  dt_spi_device_clock {
  kDtSpiDeviceClockClk = 0 ,
  kDtSpiDeviceClockCount = 1
}
 List of clock ports. More...
 
enum  dt_spi_device_reset {
  kDtSpiDeviceResetRst = 0 ,
  kDtSpiDeviceResetCount = 1
}
 List of reset ports. More...
 
enum  dt_spi_device_periph_io {
  kDtSpiDevicePeriphIoSck = 0 ,
  kDtSpiDevicePeriphIoCsb = 1 ,
  kDtSpiDevicePeriphIoTpmCsb = 2 ,
  kDtSpiDevicePeriphIoSd0 = 3 ,
  kDtSpiDevicePeriphIoSd1 = 4 ,
  kDtSpiDevicePeriphIoSd2 = 5 ,
  kDtSpiDevicePeriphIoSd3 = 6 ,
  kDtSpiDevicePeriphIoCount = 7
}
 List of peripheral I/O. More...
 

Functions

dt_spi_device_t dt_spi_device_from_instance_id (dt_instance_id_t inst_id)
 Get the spi_device instance from an instance ID.
 
dt_instance_id_t dt_spi_device_instance_id (dt_spi_device_t dt)
 Get the instance ID of an instance.
 
uint32_t dt_spi_device_reg_block (dt_spi_device_t dt, dt_spi_device_reg_block_t reg_block)
 Get the register base address of an instance.
 
dt_plic_irq_id_t dt_spi_device_irq_to_plic_id (dt_spi_device_t dt, dt_spi_device_irq_t irq)
 Get the PLIC ID of a spi_device IRQ for a given instance.
 
dt_spi_device_irq_t dt_spi_device_irq_from_plic_id (dt_spi_device_t dt, dt_plic_irq_id_t irq)
 Convert a global IRQ ID to a local spi_device IRQ type.
 
dt_alert_id_t dt_spi_device_alert_to_alert_id (dt_spi_device_t dt, dt_spi_device_alert_t alert)
 Get the alert ID of a spi_device alert for a given instance.
 
dt_spi_device_alert_t dt_spi_device_alert_from_alert_id (dt_spi_device_t dt, dt_alert_id_t alert)
 Convert a global alert ID to a local spi_device alert type.
 
dt_periph_io_t dt_spi_device_periph_io (dt_spi_device_t dt, dt_spi_device_periph_io_t sig)
 Get the peripheral I/O description of an instance.
 
dt_clock_t dt_spi_device_clock (dt_spi_device_t dt, dt_spi_device_clock_t clk)
 Get the clock signal connected to a clock port of an instance.
 
dt_reset_t dt_spi_device_reset (dt_spi_device_t dt, dt_spi_device_reset_t rst)
 Get the reset signal connected to a reset port of an instance.
 

Detailed Description

Device Tables (DT) for IP spi_device and top earlgrey.

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

Definition in file dt_spi_device.h.

Macro Definition Documentation

◆ OPENTITAN_SPI_DEVICE_HAS_HW_3B4B_ADDRESSING

#define OPENTITAN_SPI_DEVICE_HAS_HW_3B4B_ADDRESSING   1

Definition at line 141 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_HW_CMDINFOS

#define OPENTITAN_SPI_DEVICE_HAS_HW_CMDINFOS   1

Definition at line 139 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_HW_COMMAND_UPLOAD

#define OPENTITAN_SPI_DEVICE_HAS_HW_COMMAND_UPLOAD   1

Definition at line 140 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_HW_CSB_STATUS

#define OPENTITAN_SPI_DEVICE_HAS_HW_CSB_STATUS   1

Definition at line 132 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_HW_FLASH_EMULATION_BLOCKS

#define OPENTITAN_SPI_DEVICE_HAS_HW_FLASH_EMULATION_BLOCKS   1

Definition at line 134 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_HW_LANES

#define OPENTITAN_SPI_DEVICE_HAS_HW_LANES   1

Definition at line 130 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_HW_LAST_READ_ADDR

#define OPENTITAN_SPI_DEVICE_HAS_HW_LAST_READ_ADDR   1

Definition at line 138 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_HW_SERDES_ORDERING

#define OPENTITAN_SPI_DEVICE_HAS_HW_SERDES_ORDERING   1

Definition at line 131 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION

#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION   1

List of supported hardware features.

Definition at line 127 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_COMMANDS

#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_COMMANDS   1

Definition at line 133 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_DUMMY_CYCLE

#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_DUMMY_CYCLE   1

Definition at line 136 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_READ_COMMAND_PROCESSOR

#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_READ_COMMAND_PROCESSOR   1

Definition at line 135 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_WRITE_ENABLE_DISABLE

#define OPENTITAN_SPI_DEVICE_HAS_MODE_FLASH_EMULATION_WRITE_ENABLE_DISABLE   1

Definition at line 137 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH

#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH   1

Definition at line 128 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_ADDRESS_MANIPULATION

#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_ADDRESS_MANIPULATION   1

Definition at line 143 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_CMD_FILTER

#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_CMD_FILTER   1

Definition at line 142 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_INTERCEPT_EN

#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_INTERCEPT_EN   1

Definition at line 146 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_MAILBOX

#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_MAILBOX   1

Definition at line 147 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_OUTPUT_ENABLE_CONTROL

#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_OUTPUT_ENABLE_CONTROL   1

Definition at line 145 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_STATUS_MANIPULATION

#define OPENTITAN_SPI_DEVICE_HAS_MODE_PASSTHROUGH_STATUS_MANIPULATION   1

Definition at line 144 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_TPM

#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM   1

Definition at line 129 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_AUTO_WAIT

#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_AUTO_WAIT   1

Definition at line 149 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_CAPABILITY

#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_CAPABILITY   1

Definition at line 151 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_READ_FIFO_MODE

#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_READ_FIFO_MODE   1

Definition at line 150 of file dt_spi_device.h.

◆ OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_RETURN_BY_HW_REGS

#define OPENTITAN_SPI_DEVICE_HAS_MODE_TPM_RETURN_BY_HW_REGS   1

Definition at line 148 of file dt_spi_device.h.

Typedef Documentation

◆ dt_spi_device_alert_t

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

◆ dt_spi_device_clock_t

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

◆ dt_spi_device_irq_t

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

◆ dt_spi_device_periph_io_t

List of peripheral I/O.

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

◆ dt_spi_device_reg_block_t

List of register blocks.

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

◆ dt_spi_device_reset_t

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumeration Type Documentation

◆ dt_spi_device

List of instances.

Enumerator
kDtSpiDevice 

spi_device

Definition at line 23 of file dt_spi_device.h.

◆ dt_spi_device_alert

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

Enumerator
kDtSpiDeviceAlertFatalFault 

This fatal alert is triggered when a fatal TL-UL bus integrity fault is detected.

Definition at line 83 of file dt_spi_device.h.

◆ dt_spi_device_clock

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtSpiDeviceClockClk 

Clock port clk_i.

Definition at line 93 of file dt_spi_device.h.

◆ dt_spi_device_irq

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

Enumerator
kDtSpiDeviceIrqUploadCmdfifoNotEmpty 

Upload Command FIFO is not empty.

kDtSpiDeviceIrqUploadPayloadNotEmpty 

Upload payload is not empty.

The event occurs after SPI transaction completed

kDtSpiDeviceIrqUploadPayloadOverflow 

Upload payload overflow event.

When a SPI Host system issues a command with payload more than 256B, this event is reported. When it happens, SW should read the last written payload index CSR to figure out the starting address of the last 256B.

kDtSpiDeviceIrqReadbufWatermark 

Read Buffer Threshold event.

The host system accesses greater than or equal to the threshold of a buffer.

kDtSpiDeviceIrqReadbufFlip 

Read buffer flipped event.

The host system accesses other side of buffer.

kDtSpiDeviceIrqTpmHeaderNotEmpty 

TPM Header(Command/Address) buffer available.

kDtSpiDeviceIrqTpmRdfifoCmdEnd 

TPM RdFIFO command ended.

The TPM Read command targeting the RdFIFO ended. Check TPM_STATUS.rdfifo_aborted to see if the transaction completed.

kDtSpiDeviceIrqTpmRdfifoDrop 

TPM RdFIFO data dropped.

Data was dropped from the RdFIFO. Data was written while a read command was not active, and it was not accepted. This can occur when the host aborts a read command.

Definition at line 47 of file dt_spi_device.h.

◆ dt_spi_device_periph_io

List of peripheral I/O.

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

Definition at line 113 of file dt_spi_device.h.

◆ dt_spi_device_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_device.h.

◆ dt_spi_device_reset

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtSpiDeviceResetRst 

Reset port rst_ni.

Definition at line 103 of file dt_spi_device.h.

Function Documentation

◆ dt_spi_device_alert_from_alert_id()

dt_spi_device_alert_t dt_spi_device_alert_from_alert_id ( dt_spi_device_t dt,
dt_alert_id_t alert )

Convert a global alert ID to a local spi_device alert type.

Parameters
dtInstance of spi_device.
alertA global alert ID that belongs to this instance.
Returns
The spi_device alert, or kDtSpiDeviceAlertCount.

Note: This function assumes that the global alert ID belongs to the instance of spi_device passed in parameter. In other words, it must be the case that dt_spi_device_instance_id(dt) == dt_alert_id_to_instance_id(alert). Otherwise, this function will return kDtSpiDeviceAlertCount.

Definition at line 174 of file dt_spi_device.c.

◆ dt_spi_device_alert_to_alert_id()

dt_alert_id_t dt_spi_device_alert_to_alert_id ( dt_spi_device_t dt,
dt_spi_device_alert_t alert )

Get the alert ID of a spi_device alert for a given instance.

Note: This function only makes sense if the instance is connected to the Alert Handler. For any instances where the instance is not connected, the return value is unspecified.

Parameters
dtInstance of spi_device.
alertA spi_device alert.
Returns
The Alert Handler alert ID of the alert of this instance.

Definition at line 168 of file dt_spi_device.c.

◆ dt_spi_device_clock()

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

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

Definition at line 192 of file dt_spi_device.c.

◆ dt_spi_device_from_instance_id()

dt_spi_device_t dt_spi_device_from_instance_id ( dt_instance_id_t inst_id)

Get the spi_device instance from an instance ID.

For example, dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3.

Parameters
inst_idInstance ID.
Returns
A spi_device instance.

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

Definition at line 124 of file dt_spi_device.c.

◆ dt_spi_device_instance_id()

dt_instance_id_t dt_spi_device_instance_id ( dt_spi_device_t dt)

Get the instance ID of an instance.

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

Definition at line 131 of file dt_spi_device.c.

◆ dt_spi_device_irq_from_plic_id()

dt_spi_device_irq_t dt_spi_device_irq_from_plic_id ( dt_spi_device_t dt,
dt_plic_irq_id_t irq )

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

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

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

Definition at line 153 of file dt_spi_device.c.

◆ dt_spi_device_irq_to_plic_id()

dt_plic_irq_id_t dt_spi_device_irq_to_plic_id ( dt_spi_device_t dt,
dt_spi_device_irq_t irq )

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

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

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

Definition at line 143 of file dt_spi_device.c.

◆ dt_spi_device_periph_io()

Get the peripheral I/O description of an instance.

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

Definition at line 185 of file dt_spi_device.c.

◆ dt_spi_device_reg_block()

Get the register base address of an instance.

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

Definition at line 136 of file dt_spi_device.c.

◆ dt_spi_device_reset()

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

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

Definition at line 199 of file dt_spi_device.c.