Software APIs
dt_flash_ctrl.h File Reference

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

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

Go to the source code of this file.

Macros

#define OPENTITAN_FLASH_CTRL_HAS_ESCALATION   1
 List of supported hardware features.
 
#define OPENTITAN_FLASH_CTRL_HAS_FETCH_CODE   1
 
#define OPENTITAN_FLASH_CTRL_HAS_INFO_CREATOR_PARTITION   1
 
#define OPENTITAN_FLASH_CTRL_HAS_INFO_ISOLATED_PARTITION   1
 
#define OPENTITAN_FLASH_CTRL_HAS_INFO_OWNER_PARTITION   1
 
#define OPENTITAN_FLASH_CTRL_HAS_INIT_ROOT_SEEDS   1
 
#define OPENTITAN_FLASH_CTRL_HAS_INIT_SCRAMBLING_KEYS   1
 
#define OPENTITAN_FLASH_CTRL_HAS_MEM_PROTECTION   1
 
#define OPENTITAN_FLASH_CTRL_HAS_OP_HOST_READ   1
 
#define OPENTITAN_FLASH_CTRL_HAS_OP_PROTOCOL_CTRL   1
 
#define OPENTITAN_FLASH_CTRL_HAS_RMA   1
 

Typedefs

typedef enum dt_flash_ctrl dt_flash_ctrl_t
 List of instances.
 
typedef enum dt_flash_ctrl_reg_block dt_flash_ctrl_reg_block_t
 List of register blocks.
 
typedef enum dt_flash_ctrl_irq dt_flash_ctrl_irq_t
 List of IRQs.
 
typedef enum dt_flash_ctrl_alert dt_flash_ctrl_alert_t
 List of Alerts.
 
typedef enum dt_flash_ctrl_clock dt_flash_ctrl_clock_t
 List of clock ports.
 
typedef enum dt_flash_ctrl_reset dt_flash_ctrl_reset_t
 List of reset ports.
 
typedef enum dt_flash_ctrl_periph_io dt_flash_ctrl_periph_io_t
 List of peripheral I/O.
 

Enumerations

enum  dt_flash_ctrl {
  kDtFlashCtrl = 0 ,
  kDtFlashCtrlFirst = 0 ,
  kDtFlashCtrlCount = 1
}
 List of instances. More...
 
enum  dt_flash_ctrl_reg_block {
  kDtFlashCtrlRegBlockCore = 0 ,
  kDtFlashCtrlRegBlockPrim = 1 ,
  kDtFlashCtrlRegBlockMem = 2 ,
  kDtFlashCtrlRegBlockCount = 3
}
 List of register blocks. More...
 
enum  dt_flash_ctrl_irq {
  kDtFlashCtrlIrqProgEmpty = 0 ,
  kDtFlashCtrlIrqProgLvl = 1 ,
  kDtFlashCtrlIrqRdFull = 2 ,
  kDtFlashCtrlIrqRdLvl = 3 ,
  kDtFlashCtrlIrqOpDone = 4 ,
  kDtFlashCtrlIrqCorrErr = 5 ,
  kDtFlashCtrlIrqCount = 6
}
 List of IRQs. More...
 
enum  dt_flash_ctrl_alert {
  kDtFlashCtrlAlertRecovErr = 0 ,
  kDtFlashCtrlAlertFatalStdErr = 1 ,
  kDtFlashCtrlAlertFatalErr = 2 ,
  kDtFlashCtrlAlertFatalPrimFlashAlert = 3 ,
  kDtFlashCtrlAlertRecovPrimFlashAlert = 4 ,
  kDtFlashCtrlAlertCount = 5
}
 List of Alerts. More...
 
enum  dt_flash_ctrl_clock {
  kDtFlashCtrlClockClk = 0 ,
  kDtFlashCtrlClockOtp = 1 ,
  kDtFlashCtrlClockCount = 2
}
 List of clock ports. More...
 
enum  dt_flash_ctrl_reset {
  kDtFlashCtrlResetRst = 0 ,
  kDtFlashCtrlResetOtp = 1 ,
  kDtFlashCtrlResetCount = 2
}
 List of reset ports. More...
 
enum  dt_flash_ctrl_periph_io {
  kDtFlashCtrlPeriphIoTck = 0 ,
  kDtFlashCtrlPeriphIoTms = 1 ,
  kDtFlashCtrlPeriphIoTdi = 2 ,
  kDtFlashCtrlPeriphIoTdo = 3 ,
  kDtFlashCtrlPeriphIoCount = 4
}
 List of peripheral I/O. More...
 

Functions

dt_flash_ctrl_t dt_flash_ctrl_from_instance_id (dt_instance_id_t inst_id)
 Get the flash_ctrl instance from an instance ID.
 
dt_instance_id_t dt_flash_ctrl_instance_id (dt_flash_ctrl_t dt)
 Get the instance ID of an instance.
 
uint32_t dt_flash_ctrl_reg_block (dt_flash_ctrl_t dt, dt_flash_ctrl_reg_block_t reg_block)
 Get the register base address of an instance.
 
dt_plic_irq_id_t dt_flash_ctrl_irq_to_plic_id (dt_flash_ctrl_t dt, dt_flash_ctrl_irq_t irq)
 Get the PLIC ID of a flash_ctrl IRQ for a given instance.
 
dt_flash_ctrl_irq_t dt_flash_ctrl_irq_from_plic_id (dt_flash_ctrl_t dt, dt_plic_irq_id_t irq)
 Convert a global IRQ ID to a local flash_ctrl IRQ type.
 
dt_alert_id_t dt_flash_ctrl_alert_to_alert_id (dt_flash_ctrl_t dt, dt_flash_ctrl_alert_t alert)
 Get the alert ID of a flash_ctrl alert for a given instance.
 
dt_flash_ctrl_alert_t dt_flash_ctrl_alert_from_alert_id (dt_flash_ctrl_t dt, dt_alert_id_t alert)
 Convert a global alert ID to a local flash_ctrl alert type.
 
dt_periph_io_t dt_flash_ctrl_periph_io (dt_flash_ctrl_t dt, dt_flash_ctrl_periph_io_t sig)
 Get the peripheral I/O description of an instance.
 
dt_clock_t dt_flash_ctrl_clock (dt_flash_ctrl_t dt, dt_flash_ctrl_clock_t clk)
 Get the clock signal connected to a clock port of an instance.
 
dt_reset_t dt_flash_ctrl_reset (dt_flash_ctrl_t dt, dt_flash_ctrl_reset_t rst)
 Get the reset signal connected to a reset port of an instance.
 

Detailed Description

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

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

Definition in file dt_flash_ctrl.h.

Macro Definition Documentation

◆ OPENTITAN_FLASH_CTRL_HAS_ESCALATION

#define OPENTITAN_FLASH_CTRL_HAS_ESCALATION   1

List of supported hardware features.

Definition at line 117 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_FETCH_CODE

#define OPENTITAN_FLASH_CTRL_HAS_FETCH_CODE   1

Definition at line 118 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_INFO_CREATOR_PARTITION

#define OPENTITAN_FLASH_CTRL_HAS_INFO_CREATOR_PARTITION   1

Definition at line 119 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_INFO_ISOLATED_PARTITION

#define OPENTITAN_FLASH_CTRL_HAS_INFO_ISOLATED_PARTITION   1

Definition at line 120 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_INFO_OWNER_PARTITION

#define OPENTITAN_FLASH_CTRL_HAS_INFO_OWNER_PARTITION   1

Definition at line 121 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_INIT_ROOT_SEEDS

#define OPENTITAN_FLASH_CTRL_HAS_INIT_ROOT_SEEDS   1

Definition at line 122 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_INIT_SCRAMBLING_KEYS

#define OPENTITAN_FLASH_CTRL_HAS_INIT_SCRAMBLING_KEYS   1

Definition at line 123 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_MEM_PROTECTION

#define OPENTITAN_FLASH_CTRL_HAS_MEM_PROTECTION   1

Definition at line 124 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_OP_HOST_READ

#define OPENTITAN_FLASH_CTRL_HAS_OP_HOST_READ   1

Definition at line 125 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_OP_PROTOCOL_CTRL

#define OPENTITAN_FLASH_CTRL_HAS_OP_PROTOCOL_CTRL   1

Definition at line 126 of file dt_flash_ctrl.h.

◆ OPENTITAN_FLASH_CTRL_HAS_RMA

#define OPENTITAN_FLASH_CTRL_HAS_RMA   1

Definition at line 127 of file dt_flash_ctrl.h.

Typedef Documentation

◆ dt_flash_ctrl_alert_t

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

◆ dt_flash_ctrl_clock_t

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

◆ dt_flash_ctrl_irq_t

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

◆ dt_flash_ctrl_periph_io_t

List of peripheral I/O.

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

◆ dt_flash_ctrl_reg_block_t

List of register blocks.

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

◆ dt_flash_ctrl_reset_t

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumeration Type Documentation

◆ dt_flash_ctrl

List of instances.

Enumerator
kDtFlashCtrl 

flash_ctrl

Definition at line 23 of file dt_flash_ctrl.h.

◆ dt_flash_ctrl_alert

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

Enumerator
kDtFlashCtrlAlertRecovErr 

flash recoverable errors

kDtFlashCtrlAlertFatalStdErr 

flash standard fatal errors

kDtFlashCtrlAlertFatalErr 

Flash fatal errors including uncorrectable ECC errors.

Note that this alert is not always fatal. The underlying error bits in the !!FAULT_STATUS register remain set until reset, meaning the alert keeps firing. This doesn't hold for !!FAULT_STATUS.PHY_RELBL_ERR and !!FAULT_STATUS.PHY_STORAGE_ERR. To enable firmware dealing with multi-bit ECC and ICV errors during firmware selection and verification, these error bits can be cleared. After passing this stage, it is recommended that firmware classifies the corresponding alert as fatal on the receiver end, i.e, inside the alert handler.

kDtFlashCtrlAlertFatalPrimFlashAlert 

Fatal alert triggered inside the flash primitive, including fatal TL-UL bus integrity faults of the test interface.

kDtFlashCtrlAlertRecovPrimFlashAlert 

Recoverable alert triggered inside the flash primitive.

Definition at line 64 of file dt_flash_ctrl.h.

◆ dt_flash_ctrl_clock

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtFlashCtrlClockClk 

Clock port clk_i.

kDtFlashCtrlClockOtp 

Clock port clk_otp_i.

Definition at line 84 of file dt_flash_ctrl.h.

◆ dt_flash_ctrl_irq

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

Enumerator
kDtFlashCtrlIrqProgEmpty 

Program FIFO empty.

kDtFlashCtrlIrqProgLvl 

Program FIFO drained to level.

kDtFlashCtrlIrqRdFull 

Read FIFO full.

kDtFlashCtrlIrqRdLvl 

Read FIFO filled to level.

kDtFlashCtrlIrqOpDone 

Operation complete.

kDtFlashCtrlIrqCorrErr 

Correctable error encountered.

Definition at line 49 of file dt_flash_ctrl.h.

◆ dt_flash_ctrl_periph_io

List of peripheral I/O.

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

Definition at line 106 of file dt_flash_ctrl.h.

◆ dt_flash_ctrl_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_flash_ctrl.h.

◆ dt_flash_ctrl_reset

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtFlashCtrlResetRst 

Reset port rst_ni.

kDtFlashCtrlResetOtp 

Reset port rst_otp_ni.

Definition at line 95 of file dt_flash_ctrl.h.

Function Documentation

◆ dt_flash_ctrl_alert_from_alert_id()

dt_flash_ctrl_alert_t dt_flash_ctrl_alert_from_alert_id ( dt_flash_ctrl_t dt,
dt_alert_id_t alert )

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

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

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

Definition at line 154 of file dt_flash_ctrl.c.

◆ dt_flash_ctrl_alert_to_alert_id()

dt_alert_id_t dt_flash_ctrl_alert_to_alert_id ( dt_flash_ctrl_t dt,
dt_flash_ctrl_alert_t alert )

Get the alert ID of a flash_ctrl 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 flash_ctrl.
alertA flash_ctrl alert.
Returns
The Alert Handler alert ID of the alert of this instance.

Definition at line 148 of file dt_flash_ctrl.c.

◆ dt_flash_ctrl_clock()

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

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

Definition at line 172 of file dt_flash_ctrl.c.

◆ dt_flash_ctrl_from_instance_id()

dt_flash_ctrl_t dt_flash_ctrl_from_instance_id ( dt_instance_id_t inst_id)

Get the flash_ctrl instance from an instance ID.

For example, dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3.

Parameters
inst_idInstance ID.
Returns
A flash_ctrl instance.

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

Definition at line 104 of file dt_flash_ctrl.c.

◆ dt_flash_ctrl_instance_id()

dt_instance_id_t dt_flash_ctrl_instance_id ( dt_flash_ctrl_t dt)

Get the instance ID of an instance.

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

Definition at line 111 of file dt_flash_ctrl.c.

◆ dt_flash_ctrl_irq_from_plic_id()

dt_flash_ctrl_irq_t dt_flash_ctrl_irq_from_plic_id ( dt_flash_ctrl_t dt,
dt_plic_irq_id_t irq )

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

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

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

Definition at line 133 of file dt_flash_ctrl.c.

◆ dt_flash_ctrl_irq_to_plic_id()

dt_plic_irq_id_t dt_flash_ctrl_irq_to_plic_id ( dt_flash_ctrl_t dt,
dt_flash_ctrl_irq_t irq )

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

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

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

Definition at line 123 of file dt_flash_ctrl.c.

◆ dt_flash_ctrl_periph_io()

Get the peripheral I/O description of an instance.

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

Definition at line 165 of file dt_flash_ctrl.c.

◆ dt_flash_ctrl_reg_block()

Get the register base address of an instance.

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

Definition at line 116 of file dt_flash_ctrl.c.

◆ dt_flash_ctrl_reset()

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

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

Definition at line 179 of file dt_flash_ctrl.c.