mb/ocp/deltalake: Make use of vpd_get_int to clean up code
Tested=On OCP Delta Lake, verify the VPD values can be read correctly. Change-Id: I1c27cb61cd52902c92b3733e53bc8e6fd6a5fe7f Signed-off-by: Johnny Lin <johnny_lin@wiwynn.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/48908 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jonathan Zhang <jonzhang@fb.com> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
parent
418bc72d01
commit
9918c34d87
|
@ -100,9 +100,8 @@ enum cb_err ipmi_set_post_start(const int port)
|
||||||
|
|
||||||
void init_frb2_wdt(void)
|
void init_frb2_wdt(void)
|
||||||
{
|
{
|
||||||
char val[VPD_LEN];
|
uint8_t enable;
|
||||||
uint8_t enable, action;
|
int action, countdown;
|
||||||
uint16_t countdown;
|
|
||||||
|
|
||||||
if (vpd_get_bool(FRB2_TIMER, VPD_RW_THEN_RO, &enable)) {
|
if (vpd_get_bool(FRB2_TIMER, VPD_RW_THEN_RO, &enable)) {
|
||||||
printk(BIOS_DEBUG, "Got VPD %s value: %d\n", FRB2_TIMER, enable);
|
printk(BIOS_DEBUG, "Got VPD %s value: %d\n", FRB2_TIMER, enable);
|
||||||
|
@ -113,8 +112,7 @@ void init_frb2_wdt(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
if (vpd_gets(FRB2_COUNTDOWN, val, VPD_LEN, VPD_RW_THEN_RO)) {
|
if (vpd_get_int(FRB2_COUNTDOWN, VPD_RW_THEN_RO, &countdown)) {
|
||||||
countdown = (uint16_t)atol(val);
|
|
||||||
printk(BIOS_DEBUG, "FRB2 timer countdown set to: %d ms\n",
|
printk(BIOS_DEBUG, "FRB2 timer countdown set to: %d ms\n",
|
||||||
countdown * 100);
|
countdown * 100);
|
||||||
} else {
|
} else {
|
||||||
|
@ -123,15 +121,15 @@ void init_frb2_wdt(void)
|
||||||
countdown = FRB2_COUNTDOWN_DEFAULT;
|
countdown = FRB2_COUNTDOWN_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vpd_gets(FRB2_ACTION, val, VPD_LEN, VPD_RW_THEN_RO)) {
|
if (vpd_get_int(FRB2_ACTION, VPD_RW_THEN_RO, &action)) {
|
||||||
action = (uint8_t)atol(val);
|
|
||||||
printk(BIOS_DEBUG, "FRB2 timer action set to: %d\n", action);
|
printk(BIOS_DEBUG, "FRB2 timer action set to: %d\n", action);
|
||||||
} else {
|
} else {
|
||||||
printk(BIOS_DEBUG, "FRB2 timer action use default value: %d\n",
|
printk(BIOS_DEBUG, "FRB2 timer action use default value: %d\n",
|
||||||
FRB2_ACTION_DEFAULT);
|
FRB2_ACTION_DEFAULT);
|
||||||
action = FRB2_ACTION_DEFAULT;
|
action = FRB2_ACTION_DEFAULT;
|
||||||
}
|
}
|
||||||
ipmi_init_and_start_bmc_wdt(CONFIG_BMC_KCS_BASE, countdown, action);
|
ipmi_init_and_start_bmc_wdt(CONFIG_BMC_KCS_BASE, (uint16_t)countdown,
|
||||||
|
(uint8_t)action);
|
||||||
} else {
|
} else {
|
||||||
printk(BIOS_DEBUG, "Disable FRB2 timer\n");
|
printk(BIOS_DEBUG, "Disable FRB2 timer\n");
|
||||||
ipmi_stop_bmc_wdt(CONFIG_BMC_KCS_BASE);
|
ipmi_stop_bmc_wdt(CONFIG_BMC_KCS_BASE);
|
||||||
|
|
|
@ -9,10 +9,8 @@
|
||||||
int get_console_loglevel(void)
|
int get_console_loglevel(void)
|
||||||
{
|
{
|
||||||
int log_level = COREBOOT_LOG_LEVEL_DEFAULT;
|
int log_level = COREBOOT_LOG_LEVEL_DEFAULT;
|
||||||
char val_str[VPD_LEN];
|
|
||||||
|
|
||||||
if (vpd_gets(COREBOOT_LOG_LEVEL, val_str, VPD_LEN, VPD_RW_THEN_RO)) {
|
if (vpd_get_int(COREBOOT_LOG_LEVEL, VPD_RW_THEN_RO, &log_level)) {
|
||||||
log_level = (int)atol(val_str);
|
|
||||||
if (log_level < 0 || log_level >= BIOS_NEVER)
|
if (log_level < 0 || log_level >= BIOS_NEVER)
|
||||||
log_level = COREBOOT_LOG_LEVEL_DEFAULT;
|
log_level = COREBOOT_LOG_LEVEL_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
static void mainboard_config_upd(FSPM_UPD *mupd)
|
static void mainboard_config_upd(FSPM_UPD *mupd)
|
||||||
{
|
{
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
char val_str[VPD_LEN];
|
int val_int;
|
||||||
|
|
||||||
/* Send FSP log message to SOL */
|
/* Send FSP log message to SOL */
|
||||||
if (vpd_get_bool(FSP_LOG, VPD_RW_THEN_RO, &val))
|
if (vpd_get_bool(FSP_LOG, VPD_RW_THEN_RO, &val))
|
||||||
|
@ -33,15 +33,14 @@ static void mainboard_config_upd(FSPM_UPD *mupd)
|
||||||
|
|
||||||
if (mupd->FspmConfig.SerialIoUartDebugEnable) {
|
if (mupd->FspmConfig.SerialIoUartDebugEnable) {
|
||||||
/* FSP debug log level */
|
/* FSP debug log level */
|
||||||
if (vpd_gets(FSP_LOG_LEVEL, val_str, VPD_LEN, VPD_RW_THEN_RO)) {
|
if (vpd_get_int(FSP_LOG_LEVEL, VPD_RW_THEN_RO, &val_int)) {
|
||||||
val = (uint8_t)atol(val_str);
|
if (val_int < 0 || val_int > 0x0f) {
|
||||||
if (val > 0x0f) {
|
|
||||||
printk(BIOS_DEBUG, "Invalid DebugPrintLevel value from VPD: "
|
printk(BIOS_DEBUG, "Invalid DebugPrintLevel value from VPD: "
|
||||||
"%d\n", val);
|
"%d\n", val_int);
|
||||||
val = FSP_LOG_LEVEL_DEFAULT;
|
val_int = FSP_LOG_LEVEL_DEFAULT;
|
||||||
}
|
}
|
||||||
printk(BIOS_DEBUG, "Setting DebugPrintLevel %d from VPD\n", val);
|
printk(BIOS_DEBUG, "Setting DebugPrintLevel %d from VPD\n", val_int);
|
||||||
mupd->FspmConfig.DebugPrintLevel = val;
|
mupd->FspmConfig.DebugPrintLevel = (uint8_t)val_int;
|
||||||
} else {
|
} else {
|
||||||
printk(BIOS_INFO, "Not able to get VPD %s, default set "
|
printk(BIOS_INFO, "Not able to get VPD %s, default set "
|
||||||
"DebugPrintLevel to %d\n", FSP_LOG_LEVEL,
|
"DebugPrintLevel to %d\n", FSP_LOG_LEVEL,
|
||||||
|
@ -65,15 +64,14 @@ static void mainboard_config_upd(FSPM_UPD *mupd)
|
||||||
* Following code is effective when MemRefreshWaterMark patch is added to FSP
|
* Following code is effective when MemRefreshWaterMark patch is added to FSP
|
||||||
* and when corresponding VPD variable is set.
|
* and when corresponding VPD variable is set.
|
||||||
*/
|
*/
|
||||||
if (vpd_gets(FSPM_MEMREFRESHWATERMARK, val_str, VPD_LEN, VPD_RW_THEN_RO)) {
|
if (vpd_get_int(FSPM_MEMREFRESHWATERMARK, VPD_RW_THEN_RO, &val_int)) {
|
||||||
val = (uint8_t)atol(val_str);
|
if (val_int < 0 || val_int > 2) {
|
||||||
if (val > 2) {
|
|
||||||
printk(BIOS_DEBUG, "Invalid MemRefreshWatermark value from VPD: "
|
printk(BIOS_DEBUG, "Invalid MemRefreshWatermark value from VPD: "
|
||||||
"%d\n", val);
|
"%d\n", val_int);
|
||||||
val = FSPM_MEMREFRESHWATERMARK_DEFAULT;
|
val_int = FSPM_MEMREFRESHWATERMARK_DEFAULT;
|
||||||
}
|
}
|
||||||
printk(BIOS_DEBUG, "Setting MemRefreshWatermark %d from VPD\n", val);
|
printk(BIOS_DEBUG, "Setting MemRefreshWatermark %d from VPD\n", val_int);
|
||||||
mupd->FspmConfig.UnusedUpdSpace0[0] = val;
|
mupd->FspmConfig.UnusedUpdSpace0[0] = (uint8_t)val_int;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
#ifndef DELTALAKE_VPD_H
|
#ifndef DELTALAKE_VPD_H
|
||||||
#define DELTALAKE_VPD_H
|
#define DELTALAKE_VPD_H
|
||||||
|
|
||||||
/* VPD variable maximum length */
|
|
||||||
#define VPD_LEN 10
|
|
||||||
|
|
||||||
/* VPD variable for enabling/disabling FRB2 timer. 1/0: Enable/disable */
|
/* VPD variable for enabling/disabling FRB2 timer. 1/0: Enable/disable */
|
||||||
#define FRB2_TIMER "frb2_timer_enable"
|
#define FRB2_TIMER "frb2_timer_enable"
|
||||||
#define FRB2_TIMER_DEFAULT 1 /* Default value when the VPD variable is not found */
|
#define FRB2_TIMER_DEFAULT 1 /* Default value when the VPD variable is not found */
|
||||||
|
|
Loading…
Reference in New Issue