Skip to content

minerva-ag: Support i2c telemetry command and support fru product custom data and modify bootstrap command with setting hex-value #2261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 changes: 1 addition & 1 deletion common/hal/hal_i2c_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static int i2c_target_stop(struct i2c_slave_config *config)

/* if target queue is full, unregister the bus target to prevent next message handle */
if (!k_msgq_num_free_get(&data->target_wr_msgq_id)) {
LOG_DBG("Target queue is full, unregister bus[%d]", data->i2c_bus);
LOG_WRN("Target queue is full, unregister bus[%d]", data->i2c_bus);
do_i2c_target_unregister(data->i2c_bus);
}
}
Expand Down
3 changes: 2 additions & 1 deletion common/hal/hal_i2c_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ struct i2c_target_data {
/* TARGET READ - Not support pending messages storage */
uint32_t rd_buffer_idx; // message buffer index
struct i2c_msg_package target_rd_msg; // message's buffer and length
bool (*rd_data_collect_func)(void *); // do something before read first byte
bool (*rd_data_collect_func)(
void *); // do something before read first byte: Return false if need to skip data collect while target stop
};

struct _i2c_target_config {
Expand Down
63 changes: 24 additions & 39 deletions meta-facebook/minerva-ag/src/platform/plat_fru.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,6 @@ const EEPROM_CFG plat_fru_config[] = {
},
};

#define CHASSIS_CUSTOM_DATA_MAX 24
#define BOARD_CUSTOM_DATA_MAX 4

typedef struct {
uint8_t chassis_type;
char chassis_part_number[32];
char chassis_serial_number[32];
char chassis_custom_data[CHASSIS_CUSTOM_DATA_MAX][32];
} ChassisInfo;

typedef struct {
uint8_t language;
char board_mfg_date[32];
char board_mfg[32];
char board_product[32];
char board_serial[32];
char board_part_number[32];
char board_fru_id[32];
char board_custom_data[BOARD_CUSTOM_DATA_MAX][32];
} BoardInfo;

typedef struct {
uint8_t language;
char product_manufacturer[32];
char product_name[32];
char product_part_number[32];
char product_version[32];
char product_serial[32];
char product_asset_tag[32];
char product_fru_id[32];
} ProductInfo;

void pal_load_fru_config(void)
{
memcpy(&fru_config, &plat_fru_config, sizeof(plat_fru_config));
Expand Down Expand Up @@ -190,12 +158,6 @@ bool plat_get_cpld_fru_data(uint8_t *data)
return true;
}

typedef struct {
ChassisInfo chassis;
BoardInfo board;
ProductInfo product;
} FRU_INFO;

FRU_INFO *plat_fru_info = NULL;

FRU_INFO *create_fru_info(void)
Expand Down Expand Up @@ -231,7 +193,7 @@ static void parse_board_mfg_date(const uint8_t *src, char *dest, int dest_size)
uint32_t minutes = src[0] | (src[1] << 8) | (src[2] << 16);
time_t epoch = 820454400; // Unix time for 1996-01-01 00:00:00 GMT
time_t t = epoch + minutes * 60;
struct tm *time_info = gmtime(&t);
const struct tm *time_info = gmtime(&t);

// Manually format date string as "YYYY-MM-DD HH:MM:SS" using snprintf
snprintf(dest, dest_size, "%04d-%02d-%02d %02d:%02d:%02d", time_info->tm_year + 1900,
Expand Down Expand Up @@ -473,6 +435,18 @@ bool init_fru_info(void)
offset += len;
}
}
/* Fields 8 ~ 15: Product Custom Data 1 ~ 8 */
for (int i = 0;
i < PRODUCT_CUSTOM_DATA_MAX && offset < product_offset + area_len - 1; i++) {
uint8_t type_length = fru_data[offset++];
if (type_length == 0xC1)
break;
int len = type_length & 0x3F;
decode_field(&fru_data[offset], len,
plat_fru_info->product.product_custom_data[i],
sizeof(plat_fru_info->product.product_custom_data[i]));
offset += len;
}
} else {
LOG_ERR("Invalid product offset");
return false;
Expand Down Expand Up @@ -531,5 +505,16 @@ void print_fru_info(void)
printf(" Product Serial: %s\n", plat_fru_info->product.product_serial);
printf(" Product Asset Tag: %s\n", plat_fru_info->product.product_asset_tag);
printf(" Product FRU ID: %s\n", plat_fru_info->product.product_fru_id);
for (int i = 0; i < PRODUCT_CUSTOM_DATA_MAX; i++) {
if (strlen(plat_fru_info->product.product_custom_data[i]) > 0) {
printf(" Product Custom Data %d: %s\n", i + 1,
plat_fru_info->product.product_custom_data[i]);
}
}
printf("\n");
}

FRU_INFO *get_fru_info(void)
{
return plat_fru_info;
}
41 changes: 41 additions & 0 deletions meta-facebook/minerva-ag/src/platform/plat_fru.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,46 @@
#define LOG_EEPROM_ADDR (0xA0 >> 1)
#define CPLD_EEPROM_ADDR (0xA0 >> 1)

#define CHASSIS_CUSTOM_DATA_MAX 24
#define BOARD_CUSTOM_DATA_MAX 8
#define PRODUCT_CUSTOM_DATA_MAX 8

typedef struct {
uint8_t chassis_type;
char chassis_part_number[32];
char chassis_serial_number[32];
char chassis_custom_data[CHASSIS_CUSTOM_DATA_MAX][32];
} ChassisInfo;

typedef struct {
uint8_t language;
char board_mfg_date[32];
char board_mfg[32];
char board_product[32];
char board_serial[32];
char board_part_number[32];
char board_fru_id[32];
char board_custom_data[BOARD_CUSTOM_DATA_MAX][32];
} BoardInfo;

typedef struct {
uint8_t language;
char product_manufacturer[32];
char product_name[32];
char product_part_number[32];
char product_version[32];
char product_serial[32];
char product_asset_tag[32];
char product_fru_id[32];
char product_custom_data[PRODUCT_CUSTOM_DATA_MAX][32];
} ProductInfo;

typedef struct {
ChassisInfo chassis;
BoardInfo board;
ProductInfo product;
} FRU_INFO;

enum FRU_ID {
LOG_EEPROM_ID = 0x00,
CPLD_EEPROM_ID,
Expand All @@ -31,5 +71,6 @@ bool init_fru_info(void);
void print_fru_info(void);
bool plat_eeprom_write(uint32_t offset, uint8_t *data, uint16_t data_len);
bool plat_eeprom_read(uint32_t offset, uint8_t *data, uint16_t data_len);
FRU_INFO *get_fru_info(void);

#endif
Loading