OpenBIC
OpenSource Bridge-IC
lattice.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <logging/log.h>
#include "hal_i2c.h"
#include "pldm_firmware_update.h"
#include "libutil.h"
#include "lattice.h"
Include dependency graph for lattice.c:

Macros

#define CHECK_STATUS_RETRY   100
 
#define IDCODE_PUB   0xE0
 
#define LSC_READ_STATUS   0x3C
 
#define LSC_READ_STATUS1   0x3D
 
#define LSC_INIT_ADDRESS   0x46
 
#define LSC_INIT_ADDR_UFM   0x47
 
#define LSC_CHECK_BUSY   0xF0
 
#define LSC_PROG_INCR_NV   0x70
 
#define USERCODE   0xC0
 
#define ISC_PROGRAM_USERCODE   0xC2
 
#define ISC_PROGRAM_DONE   0x5E
 
#define ISC_ENABLE_X   0x74
 
#define ISC_ERASE   0x0E
 
#define ISC_DISABLE   0x26
 
#define TAG_CFG_START_STR   "L000"
 
#define TAG_CFG_END_STR   "*"
 
#define TAG_USER_CODE_STR   "UH"
 
#define CFG_BYTE_PER_LINE   128
 
#define MAX_TRANS_LEN   (CFG_BYTE_PER_LINE + 2)
 
#define CPLD_FW_BOTTOM_PART_LENGTH   260
 

Enumerations

enum  data_passing_state {
  DATA_PASSING_FIRST , DATA_PASSING_STARTED , DATA_PASSING_CFG_STARTED , DATA_PASSING_CFG_ENDED ,
  DATA_PASSING_UC_STARTED , DATA_PASSING_UC_ENDED , DATA_PASSING_ENDED
}
 

Functions

 LOG_MODULE_REGISTER (lattice)
 
lattice_dev_type_t find_type_by_str (char *str)
 
bool cpld_i2c_get_id (uint8_t bus, uint8_t addr, uint32_t *dev_id)
 
bool cpld_i2c_get_usercode (uint8_t bus, uint8_t addr, uint32_t *usercode)
 
bool lattice_fwupdate (lattice_update_config_t *config)
 

Variables

uint8_t new_line [] = { 0x0d, 0x0a }
 
struct lattice_dev_config LATTICE_CFG_TABLE []
 

Macro Definition Documentation

◆ CFG_BYTE_PER_LINE

#define CFG_BYTE_PER_LINE   128

◆ CHECK_STATUS_RETRY

#define CHECK_STATUS_RETRY   100

◆ CPLD_FW_BOTTOM_PART_LENGTH

#define CPLD_FW_BOTTOM_PART_LENGTH   260

◆ IDCODE_PUB

#define IDCODE_PUB   0xE0

◆ ISC_DISABLE

#define ISC_DISABLE   0x26

◆ ISC_ENABLE_X

#define ISC_ENABLE_X   0x74

◆ ISC_ERASE

#define ISC_ERASE   0x0E

◆ ISC_PROGRAM_DONE

#define ISC_PROGRAM_DONE   0x5E

◆ ISC_PROGRAM_USERCODE

#define ISC_PROGRAM_USERCODE   0xC2

◆ LSC_CHECK_BUSY

#define LSC_CHECK_BUSY   0xF0

◆ LSC_INIT_ADDR_UFM

#define LSC_INIT_ADDR_UFM   0x47

◆ LSC_INIT_ADDRESS

#define LSC_INIT_ADDRESS   0x46

◆ LSC_PROG_INCR_NV

#define LSC_PROG_INCR_NV   0x70

◆ LSC_READ_STATUS

#define LSC_READ_STATUS   0x3C

◆ LSC_READ_STATUS1

#define LSC_READ_STATUS1   0x3D

◆ MAX_TRANS_LEN

#define MAX_TRANS_LEN   (CFG_BYTE_PER_LINE + 2)

◆ TAG_CFG_END_STR

#define TAG_CFG_END_STR   "*"

◆ TAG_CFG_START_STR

#define TAG_CFG_START_STR   "L000"

◆ TAG_USER_CODE_STR

#define TAG_USER_CODE_STR   "UH"

◆ USERCODE

#define USERCODE   0xC0

Enumeration Type Documentation

◆ data_passing_state

Enumerator
DATA_PASSING_FIRST 
DATA_PASSING_STARTED 
DATA_PASSING_CFG_STARTED 
DATA_PASSING_CFG_ENDED 
DATA_PASSING_UC_STARTED 
DATA_PASSING_UC_ENDED 
DATA_PASSING_ENDED 

Function Documentation

◆ cpld_i2c_get_id()

bool cpld_i2c_get_id ( uint8_t  bus,
uint8_t  addr,
uint32_t *  dev_id 
)
Here is the call graph for this function:

◆ cpld_i2c_get_usercode()

bool cpld_i2c_get_usercode ( uint8_t  bus,
uint8_t  addr,
uint32_t *  usercode 
)
Here is the call graph for this function:

◆ find_type_by_str()

lattice_dev_type_t find_type_by_str ( char *  str)

◆ lattice_fwupdate()

bool lattice_fwupdate ( lattice_update_config_t config)

◆ LOG_MODULE_REGISTER()

LOG_MODULE_REGISTER ( lattice  )

Variable Documentation

◆ LATTICE_CFG_TABLE

struct lattice_dev_config LATTICE_CFG_TABLE[]

◆ new_line

uint8_t new_line[] = { 0x0d, 0x0a }