diff options
Diffstat (limited to 'src/mainboard')
9 files changed, 93 insertions, 0 deletions
diff --git a/src/mainboard/google/brox/variants/baseboard/brox/Makefile.mk b/src/mainboard/google/brox/variants/baseboard/brox/Makefile.mk index 3a6695828f..b3149ba8aa 100644 --- a/src/mainboard/google/brox/variants/baseboard/brox/Makefile.mk +++ b/src/mainboard/google/brox/variants/baseboard/brox/Makefile.mk @@ -4,6 +4,7 @@ bootblock-y += gpio.c romstage-y += memory.c romstage-y += gpio.c +romstage-y += romstage.c romstage-$(CONFIG_MAINBOARD_USE_EARLY_LIBGFXINIT) += gma-mainboard.ads ramstage-y += gpio.c diff --git a/src/mainboard/google/brox/variants/baseboard/brox/romstage.c b/src/mainboard/google/brox/variants/baseboard/brox/romstage.c new file mode 100644 index 0000000000..66ed99b9f4 --- /dev/null +++ b/src/mainboard/google/brox/variants/baseboard/brox/romstage.c @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <baseboard/variants.h> +#include <cbfs.h> +#include <ec/google/chromeec/ec.h> +#include <security/vboot/vboot_common.h> +#include <security/vboot/misc.h> +#include <soc/romstage.h> + +#define FWVER_SIZE 3 +#define FWVER_TO_INT(MAJOR, MINOR, PATCH) \ + ((uint32_t)(((MAJOR) & 0xFF) << 16 | ((MINOR) & 0xFF) << 8 | ((PATCH) & 0xFF))) + +static bool check_auxfw_ver_mismatch(void) +{ + uint8_t *new_ver; + size_t new_ver_size; + struct ec_response_pd_chip_info pd_chip_r = {0}; + const char *fwver_fname = variant_get_auxfw_version_file(); + uint8_t cur_major_ver; + bool mismatch = false, is_productionfw; + int ret; + + ret = google_chromeec_get_pd_chip_info(0, 0, &pd_chip_r); + if (ret < 0) { + printk(BIOS_INFO, "%s: Cannot get PD port info\n", __func__); + return mismatch; + } + cur_major_ver = (pd_chip_r.fw_version_number >> 16) & 0xFF; + is_productionfw = !!(cur_major_ver & 0xF0); + + /* find bundled fw hash */ + new_ver = cbfs_map(fwver_fname, &new_ver_size); + if (new_ver == NULL || new_ver_size != FWVER_SIZE) + return mismatch; + + /* + * Firmware version mismatches and satisfies anti-rollback conditions. + * Anti-rollback conditions are one of the following: + * 1) Not a production firmware. + * 2) New major version is greater than current major version. + */ + if ((pd_chip_r.fw_version_number != + FWVER_TO_INT(new_ver[0], new_ver[1], new_ver[2])) && + (!is_productionfw || new_ver[0] >= cur_major_ver)) { + printk(BIOS_INFO, "%s: Expecting Aux FW update and hence a reset\n", __func__); + mismatch = true; + } + + cbfs_unmap(new_ver); + return mismatch; +} + +bool mainboard_expects_another_reset(void) +{ + if (vboot_recovery_mode_enabled()) + return false; + + if (!CONFIG(VBOOT) || + (vboot_is_gbb_flag_set(VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC) && + vboot_is_gbb_flag_set(VB2_GBB_FLAG_DISABLE_AUXFW_SOFTWARE_SYNC))) + return false; + + return check_auxfw_ver_mismatch(); +} diff --git a/src/mainboard/google/brox/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/brox/variants/baseboard/include/baseboard/variants.h index a1fbe018b1..070b2f8634 100644 --- a/src/mainboard/google/brox/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/brox/variants/baseboard/include/baseboard/variants.h @@ -60,4 +60,5 @@ void variant_update_power_limits(const struct cpu_power_limits *limits, void variant_init(void); void variant_finalize(void); +const char *variant_get_auxfw_version_file(void); #endif /*__BASEBOARD_VARIANTS_H__ */ diff --git a/src/mainboard/google/brox/variants/brox/Makefile.mk b/src/mainboard/google/brox/variants/brox/Makefile.mk index 4a7ff71e45..19eb924149 100644 --- a/src/mainboard/google/brox/variants/brox/Makefile.mk +++ b/src/mainboard/google/brox/variants/brox/Makefile.mk @@ -2,6 +2,7 @@ bootblock-y += gpio.c romstage-y += gpio.c +romstage-$(CONFIG_FW_CONFIG) += variant.c ramstage-$(CONFIG_FW_CONFIG) += fw_config.c ramstage-$(CONFIG_FW_CONFIG) += variant.c ramstage-y += gpio.c diff --git a/src/mainboard/google/brox/variants/brox/variant.c b/src/mainboard/google/brox/variants/brox/variant.c index 332d152a8e..f09c60e7a3 100644 --- a/src/mainboard/google/brox/variants/brox/variant.c +++ b/src/mainboard/google/brox/variants/brox/variant.c @@ -25,3 +25,12 @@ const char *get_wifi_sar_cbfs_filename(void) { return get_wifi_sar_fw_config_filename(FW_CONFIG_FIELD(WIFI_BT)); } + +const char *variant_get_auxfw_version_file(void) +{ + if (fw_config_probe(FW_CONFIG(RETIMER, RETIMER_BYPASS))) + return "rts5453_retimer_bypass.hash"; + else if (fw_config_probe(FW_CONFIG(RETIMER, RETIMER_JHL8040))) + return "rts5453_retimer_jhl8040.hash"; + return NULL; +} diff --git a/src/mainboard/google/brox/variants/jubilant/Makefile.mk b/src/mainboard/google/brox/variants/jubilant/Makefile.mk index 503ef8f722..bb7543b968 100644 --- a/src/mainboard/google/brox/variants/jubilant/Makefile.mk +++ b/src/mainboard/google/brox/variants/jubilant/Makefile.mk @@ -4,6 +4,7 @@ bootblock-y += gpio.c romstage-y += gpio.c romstage-y += memory.c +romstage-$(CONFIG_FW_CONFIG) += variant.c ramstage-$(CONFIG_FW_CONFIG) += fw_config.c ramstage-$(CONFIG_FW_CONFIG) += variant.c diff --git a/src/mainboard/google/brox/variants/jubilant/variant.c b/src/mainboard/google/brox/variants/jubilant/variant.c index 5b75380740..ff84374cc3 100644 --- a/src/mainboard/google/brox/variants/jubilant/variant.c +++ b/src/mainboard/google/brox/variants/jubilant/variant.c @@ -31,6 +31,11 @@ const char *get_wifi_sar_cbfs_filename(void) return get_wifi_sar_fw_config_filename(FW_CONFIG_FIELD(WIFI_BT)); } +const char *variant_get_auxfw_version_file(void) +{ + return "rts5453_retimer_bypass.hash"; +} + static void wwan_out_of_reset(void *unused) { if (fw_config_probe(FW_CONFIG(DB_USB, DB_1A_LTE))) { diff --git a/src/mainboard/google/brox/variants/lotso/Makefile.mk b/src/mainboard/google/brox/variants/lotso/Makefile.mk index a1059a5eba..dde5215227 100644 --- a/src/mainboard/google/brox/variants/lotso/Makefile.mk +++ b/src/mainboard/google/brox/variants/lotso/Makefile.mk @@ -4,6 +4,7 @@ bootblock-y += gpio.c romstage-y += memory.c romstage-y += gpio.c ramstage-y += gpio.c +romstage-$(CONFIG_FW_CONFIG) += variant.c ramstage-$(CONFIG_FW_CONFIG) += variant.c ramstage-y += ramstage.c smm-y += smihandler.c diff --git a/src/mainboard/google/brox/variants/lotso/variant.c b/src/mainboard/google/brox/variants/lotso/variant.c index 066acb2878..6121450911 100644 --- a/src/mainboard/google/brox/variants/lotso/variant.c +++ b/src/mainboard/google/brox/variants/lotso/variant.c @@ -19,3 +19,12 @@ const char *get_wifi_sar_cbfs_filename(void) { return get_wifi_sar_fw_config_filename(FW_CONFIG_FIELD(WIFI_BT)); } + +const char *variant_get_auxfw_version_file(void) +{ + if (fw_config_probe(FW_CONFIG(RETIMER, RETIMER_BYPASS))) + return "rts5453_retimer_bypass.hash"; + else if (fw_config_probe(FW_CONFIG(RETIMER, RETIMER_JHL8040))) + return "rts5453_retimer_jhl8040.hash"; + return NULL; +} |