TT Zephyr Platforms 18.11.99
Tenstorrent Firmware
Loading...
Searching...
No Matches
spi_eeprom.c File Reference
#include "reg.h"
#include "status_reg.h"
#include "util.h"
#include <stdbool.h>
#include <string.h>
#include <tenstorrent/smc_msg.h>
#include <tenstorrent/msgqueue.h>
#include <tenstorrent/sys_init_defines.h>
#include <tenstorrent/tt_boot_fs.h>
#include <zephyr/drivers/mspi.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/logging/log.h>
#include <zephyr/init.h>
#include <zephyr/kernel.h>

Macros

#define SPI_PAGE_SIZE   256
#define SECTOR_SIZE   4096
#define SPI_BUFFER_SIZE   4096
#define BYTE_GET(v, b)
#define SSI_RX_DLY_SR_DEPTH   64
#define SPI_RX_SAMPLE_DELAY_TRAIN_ADDR   0x13FFC
#define SPI_RX_SAMPLE_DELAY_TRAIN_DATA   0xA5A55A5A

Functions

 LOG_MODULE_REGISTER (spi_eeprom, CONFIG_TT_APP_LOG_LEVEL)
static void EepromSetup (void)
static int SpiBlockRead (uint32_t spi_address, uint32_t num_bytes, uint8_t *dest)
static int SpiSmartWrite (uint32_t address, const uint8_t *data, uint32_t num_bytes)
static bool check_csm_region (uint32_t addr, uint32_t num_bytes)
static uint8_t read_eeprom_handler (const union request *request, struct response *response)
static uint8_t write_eeprom_handler (const union request *request, struct response *response)
 REGISTER_MESSAGE (TT_SMC_MSG_READ_EEPROM, read_eeprom_handler)
 REGISTER_MESSAGE (TT_SMC_MSG_WRITE_EEPROM, write_eeprom_handler)
static int InitSpiFS (void)
 SYS_INIT_APP (InitSpiFS)

Variables

static uint8_t spi_page_buf [4096]
static uint8_t spi_global_buffer [4096]
static struct flash_pages_info page_info
static const struct deviceflash = DEVICE_DT_GET_OR_NULL(DT_NODELABEL(spi_flash))

Macro Definition Documentation

◆ BYTE_GET

#define BYTE_GET ( v,
b )
Value:
FIELD_GET(0xFFu << ((b) * 8), (v))
#define FIELD_GET(mask, value)

◆ SECTOR_SIZE

#define SECTOR_SIZE   4096

◆ SPI_BUFFER_SIZE

#define SPI_BUFFER_SIZE   4096

◆ SPI_PAGE_SIZE

#define SPI_PAGE_SIZE   256

◆ SPI_RX_SAMPLE_DELAY_TRAIN_ADDR

#define SPI_RX_SAMPLE_DELAY_TRAIN_ADDR   0x13FFC

◆ SPI_RX_SAMPLE_DELAY_TRAIN_DATA

#define SPI_RX_SAMPLE_DELAY_TRAIN_DATA   0xA5A55A5A

◆ SSI_RX_DLY_SR_DEPTH

#define SSI_RX_DLY_SR_DEPTH   64

Function Documentation

◆ check_csm_region()

bool check_csm_region ( uint32_t addr,
uint32_t num_bytes )
static

◆ EepromSetup()

void EepromSetup ( void )
static

◆ InitSpiFS()

int InitSpiFS ( void )
static

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( spi_eeprom ,
CONFIG_TT_APP_LOG_LEVEL  )

◆ read_eeprom_handler()

uint8_t read_eeprom_handler ( const union request * request,
struct response * response )
static

◆ REGISTER_MESSAGE() [1/2]

REGISTER_MESSAGE ( TT_SMC_MSG_READ_EEPROM ,
read_eeprom_handler  )

◆ REGISTER_MESSAGE() [2/2]

◆ SpiBlockRead()

int SpiBlockRead ( uint32_t spi_address,
uint32_t num_bytes,
uint8_t * dest )
static

◆ SpiSmartWrite()

int SpiSmartWrite ( uint32_t address,
const uint8_t * data,
uint32_t num_bytes )
static

◆ SYS_INIT_APP()

SYS_INIT_APP ( InitSpiFS )

◆ write_eeprom_handler()

uint8_t write_eeprom_handler ( const union request * request,
struct response * response )
static

Variable Documentation

◆ flash

const struct device* flash = DEVICE_DT_GET_OR_NULL(DT_NODELABEL(spi_flash))
static

◆ page_info

struct flash_pages_info page_info
static

◆ spi_global_buffer

uint8_t spi_global_buffer[4096]
static

◆ spi_page_buf

uint8_t spi_page_buf[4096]
static