OpenBIC
OpenSource Bridge-IC
util_spi.h File Reference
#include <zephyr.h>
#include <stdbool.h>
#include <stdint.h>
#include <drivers/spi_nor.h>
Include dependency graph for util_spi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NUM_SPI_DEV   3
 
#define SECTOR_SZ_64K   0x10000
 
#define SECTOR_SZ_32K   0x08000
 
#define SECTOR_SZ_16K   0x04000
 
#define SECTOR_SZ_4K   0x01000
 
#define SECTOR_SZ_1K   0x00400
 
#define SECTOR_SZ_256   0x00100
 
#define SHA256_DIGEST_SIZE   32
 
#define SECTOR_END_FLAG   BIT(7)
 
#define NO_RESET_FLAG   BIT(0)
 

Enumerations

enum  DEVICE_POSITIONS {
  DEVSPI_FMC_CS0 , DEVSPI_FMC_CS1 , DEVSPI_SPI1_CS0 , DEVSPI_SPI1_CS1 ,
  DEVSPI_SPI2_CS0 , DEVSPI_SPI2_CS1
}
 
enum  FIRMWARE_UPDATE_RETURN_CODE {
  FWUPDATE_SUCCESS , FWUPDATE_OUT_OF_HEAP , FWUPDATE_OVER_LENGTH , FWUPDATE_REPEATED_UPDATED ,
  FWUPDATE_UPDATE_FAIL , FWUPDATE_ERROR_OFFSET , FWUPDATE_NOT_SUPPORT
}
 

Functions

uint8_t fw_update (uint32_t offset, uint16_t msg_len, uint8_t *msg_buf, uint8_t flag, uint8_t flash_position)
 
int read_fw_image (uint32_t offset, uint8_t msg_len, uint8_t *msg_buf, uint8_t flash_position)
 
uint8_t fw_update_cxl (uint32_t offset, uint16_t msg_len, uint8_t *msg_buf, bool sector_end)
 
uint8_t get_fw_sha256 (uint8_t *msg_buf, uint32_t offset, uint32_t length, uint8_t flash_position)
 
int pal_get_bios_flash_position ()
 
int pal_get_prot_flash_position ()
 
bool pal_switch_bios_spi_mux (int gpio_status)
 
int pal_get_cxl_flash_position ()
 
int do_update (const struct device *flash_device, off_t offset, uint8_t *buf, size_t len)
 
void set_default_retry_count (int count)
 
int ckeck_flash_device_isinit (const struct device *flash_device, uint8_t flash_position)
 
char * get_flash_device_string_by_index (uint8_t flash_index)
 

Macro Definition Documentation

◆ NO_RESET_FLAG

#define NO_RESET_FLAG   BIT(0)

◆ NUM_SPI_DEV

#define NUM_SPI_DEV   3

◆ SECTOR_END_FLAG

#define SECTOR_END_FLAG   BIT(7)

◆ SECTOR_SZ_16K

#define SECTOR_SZ_16K   0x04000

◆ SECTOR_SZ_1K

#define SECTOR_SZ_1K   0x00400

◆ SECTOR_SZ_256

#define SECTOR_SZ_256   0x00100

◆ SECTOR_SZ_32K

#define SECTOR_SZ_32K   0x08000

◆ SECTOR_SZ_4K

#define SECTOR_SZ_4K   0x01000

◆ SECTOR_SZ_64K

#define SECTOR_SZ_64K   0x10000

◆ SHA256_DIGEST_SIZE

#define SHA256_DIGEST_SIZE   32

Enumeration Type Documentation

◆ DEVICE_POSITIONS

Enumerator
DEVSPI_FMC_CS0 
DEVSPI_FMC_CS1 
DEVSPI_SPI1_CS0 
DEVSPI_SPI1_CS1 
DEVSPI_SPI2_CS0 
DEVSPI_SPI2_CS1 

◆ FIRMWARE_UPDATE_RETURN_CODE

Enumerator
FWUPDATE_SUCCESS 
FWUPDATE_OUT_OF_HEAP 
FWUPDATE_OVER_LENGTH 
FWUPDATE_REPEATED_UPDATED 
FWUPDATE_UPDATE_FAIL 
FWUPDATE_ERROR_OFFSET 
FWUPDATE_NOT_SUPPORT 

Function Documentation

◆ ckeck_flash_device_isinit()

int ckeck_flash_device_isinit ( const struct device *  flash_device,
uint8_t  flash_position 
)

◆ do_update()

int do_update ( const struct device *  flash_device,
off_t  offset,
uint8_t *  buf,
size_t  len 
)

◆ fw_update()

uint8_t fw_update ( uint32_t  offset,
uint16_t  msg_len,
uint8_t *  msg_buf,
uint8_t  flag,
uint8_t  flash_position 
)

◆ fw_update_cxl()

uint8_t fw_update_cxl ( uint32_t  offset,
uint16_t  msg_len,
uint8_t *  msg_buf,
bool  sector_end 
)

◆ get_flash_device_string_by_index()

char * get_flash_device_string_by_index ( uint8_t  flash_index)

◆ get_fw_sha256()

uint8_t get_fw_sha256 ( uint8_t *  msg_buf,
uint32_t  offset,
uint32_t  length,
uint8_t  flash_position 
)

◆ pal_get_bios_flash_position()

int pal_get_bios_flash_position ( )

◆ pal_get_cxl_flash_position()

int pal_get_cxl_flash_position ( )

◆ pal_get_prot_flash_position()

int pal_get_prot_flash_position ( )

◆ pal_switch_bios_spi_mux()

bool pal_switch_bios_spi_mux ( int  gpio_status)
Here is the call graph for this function:

◆ read_fw_image()

int read_fw_image ( uint32_t  offset,
uint8_t  msg_len,
uint8_t *  msg_buf,
uint8_t  flash_position 
)

◆ set_default_retry_count()

void set_default_retry_count ( int  count)