diff options
author | Furquan Shaikh <furquan@google.com> | 2020-07-07 12:50:55 -0700 |
---|---|---|
committer | Furquan Shaikh <furquan@google.com> | 2020-07-08 23:07:34 +0000 |
commit | 30ee0d881b5c5568fb8e1cf0ad2144b9e84d6a06 (patch) | |
tree | 807618e9cde48f1ec6a080dab85590ff9281e6cd | |
parent | ca36acf773b1941c6df25329846765d0225fbd37 (diff) | |
download | coreboot-30ee0d881b5c5568fb8e1cf0ad2144b9e84d6a06.tar.xz |
mb/google/zork: Add helpers for v3 schematics and wifi power enable
This change adds following two helper functions:
1. variant_uses_v3_schematics() - Check whether the variant is using
v3 version of schematics.
2. variant_has_active_low_wifi_power() - Check whether the variant is
using active low power enable for WiFi.
In addition to this, Kconfig options are reorganized to add two new
configs - VARIANT_SUPPORTS_PRE_V3_SCHEMATICS and
VARIANT_SUPPORTS_WIFI_POWER_ACTIVE_HIGH. This allows the helper
functions to return `true` early without checking for board version.
Eventually, when a variant decides to drop support for pre-v3
schematics, it can be dropped from selecting
VARIANT_SUPPORTS_PRE_V3_SCHEMATICS. Similarly, when the variant
decides to drop support for active high power enable for WiFi, it can
be dropped from selecting VARIANT_SUPPORTS_WIFI_POWER_ACTIVE_HIGH.
Change-Id: I62851299e8dd7929a8e1e9a287389abd71c7706c
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/43224
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
7 files changed, 90 insertions, 25 deletions
diff --git a/src/mainboard/google/zork/Kconfig b/src/mainboard/google/zork/Kconfig index a6c866df48..057090bda5 100644 --- a/src/mainboard/google/zork/Kconfig +++ b/src/mainboard/google/zork/Kconfig @@ -149,8 +149,24 @@ config VARIANT_BOARD_VER_FW_CONFIG_VALID help Which board version did FW_CONFIG become valid in CBI. +config VARIANT_SUPPORTS_PRE_V3_SCHEMATICS + bool + default y if BOARD_GOOGLE_TREMBYLE + default y if BOARD_GOOGLE_EZKINIL + default y if BOARD_GOOGLE_MORPHIUS + default y if BOARD_GOOGLE_BERKNIP + default y if BOARD_GOOGLE_DALBOZ + default y if BOARD_GOOGLE_VILBOZ + default n + help + Whether this variant supports pre-v3 version of schematics. + Eventually, when a variant moves to a point where it no + longer has to support pre-v3 schematics, `default y` entry + for it can be dropped. + config VARIANT_MIN_BOARD_ID_V3_SCHEMATICS int + depends on VARIANT_SUPPORTS_PRE_V3_SCHEMATICS default 4 if BOARD_GOOGLE_TREMBYLE default 3 if BOARD_GOOGLE_EZKINIL default 3 if BOARD_GOOGLE_MORPHIUS @@ -158,12 +174,35 @@ config VARIANT_MIN_BOARD_ID_V3_SCHEMATICS default 3 if BOARD_GOOGLE_DALBOZ default 1 if BOARD_GOOGLE_VILBOZ default 256 + help + Minimum board version where the variant starts supporting + v3 version of reference schematics. + +config VARIANT_SUPPORTS_WIFI_POWER_ACTIVE_HIGH + bool + default y if VARIANT_SUPPORTS_PRE_V3_SCHEMATICS + default y if BOARD_GOOGLE_BERKNIP + default y if BOARD_GOOGLE_VILBOZ + default n + help + Whether this variant supports active high power enable for + WiFi. For pre-v3 schematics, this is always true. There are + some variants which used v3 schematics, but did not pick up + the change for active low WiFi power enable. Those variants + will have to set this config to true. Eventually, when a + variant needs to only support v3 schematics with active low + power enable for WiFi, `default y` entry for it can be + dropped. config VARIANT_MIN_BOARD_ID_WIFI_POWER_ACTIVE_LOW int + depends on VARIANT_SUPPORTS_WIFI_POWER_ACTIVE_HIGH default 3 if BOARD_GOOGLE_BERKNIP default 2 if BOARD_GOOGLE_VILBOZ default VARIANT_MIN_BOARD_ID_V3_SCHEMATICS + help + Minimum board version where the variant starts supporting + active low power enable for WiFi. config VBOOT_STARTS_BEFORE_BOOTBLOCK bool "PSP verstage" diff --git a/src/mainboard/google/zork/variants/baseboard/Makefile.inc b/src/mainboard/google/zork/variants/baseboard/Makefile.inc index 2b0ee3cbd8..c9e3657f4b 100644 --- a/src/mainboard/google/zork/variants/baseboard/Makefile.inc +++ b/src/mainboard/google/zork/variants/baseboard/Makefile.inc @@ -1,10 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-or-later bootblock-y += gpio_baseboard_common.c +bootblock-y += helpers.c bootblock-$(CONFIG_BOARD_GOOGLE_BASEBOARD_TREMBYLE) += gpio_baseboard_trembyle.c bootblock-$(CONFIG_BOARD_GOOGLE_BASEBOARD_DALBOZ) += gpio_baseboard_dalboz.c verstage-y += gpio_baseboard_common.c +verstage-y += helpers.c ifeq ($(CONFIG_VBOOT_STARTS_BEFORE_BOOTBLOCK),y) verstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_TREMBYLE) += gpio_baseboard_trembyle.c verstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_DALBOZ) += gpio_baseboard_dalboz.c @@ -12,6 +14,7 @@ endif verstage-y += tpm_tis.c romstage-y += gpio_baseboard_common.c +romstage-y += helpers.c romstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_TREMBYLE) += gpio_baseboard_trembyle.c romstage-$(CONFIG_BOARD_GOOGLE_BASEBOARD_DALBOZ) += gpio_baseboard_dalboz.c romstage-y += tpm_tis.c diff --git a/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c b/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c index 8e6124c6d7..cdce5d3381 100644 --- a/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c +++ b/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c @@ -181,10 +181,7 @@ static const struct soc_amd_gpio gpio_set_stage_ram[] = { const __weak struct soc_amd_gpio *variant_romstage_gpio_table(size_t *size) { - uint32_t board_version; - - if (!google_chromeec_cbi_get_board_version(&board_version) && - (board_version >= CONFIG_VARIANT_MIN_BOARD_ID_V3_SCHEMATICS)) { + if (variant_uses_v3_schematics()) { *size = ARRAY_SIZE(gpio_set_stage_rom_v3); return gpio_set_stage_rom_v3; } @@ -260,9 +257,9 @@ static void wifi_power_reset_configure_active_high_power(void) gpio_set(GPIO_29, 0); } -static void wifi_power_reset_configure_v3(uint32_t board_version) +static void wifi_power_reset_configure_v3(void) { - if (board_version >= CONFIG_VARIANT_MIN_BOARD_ID_WIFI_POWER_ACTIVE_LOW) + if (variant_has_active_low_wifi_power()) wifi_power_reset_configure_active_low_power(); else wifi_power_reset_configure_active_high_power(); @@ -296,14 +293,11 @@ static void wifi_power_reset_configure_pre_v3(void) __weak void variant_pcie_power_reset_configure(void) { - uint32_t board_version; - /* Deassert PCIE_RST1_L */ gpio_set(GPIO_27, 1); - if (!google_chromeec_cbi_get_board_version(&board_version) && - (board_version >= CONFIG_VARIANT_MIN_BOARD_ID_V3_SCHEMATICS)) - wifi_power_reset_configure_v3(board_version); + if (variant_uses_v3_schematics()) + wifi_power_reset_configure_v3(); else wifi_power_reset_configure_pre_v3(); } diff --git a/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c b/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c index 77a3212de5..a0d385435a 100644 --- a/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c +++ b/src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c @@ -171,10 +171,7 @@ static const struct soc_amd_gpio gpio_set_stage_ram[] = { const __weak struct soc_amd_gpio *variant_romstage_gpio_table(size_t *size) { - uint32_t board_version; - - if (!google_chromeec_cbi_get_board_version(&board_version) && - (board_version >= CONFIG_VARIANT_MIN_BOARD_ID_V3_SCHEMATICS)) { + if (variant_uses_v3_schematics()) { *size = ARRAY_SIZE(gpio_set_stage_rom_v3); return gpio_set_stage_rom_v3; } @@ -250,9 +247,9 @@ static void wifi_power_reset_configure_active_high_power(void) gpio_set(GPIO_86, 1); } -static void wifi_power_reset_configure_v3(uint32_t board_version) +static void wifi_power_reset_configure_v3(void) { - if (board_version >= CONFIG_VARIANT_MIN_BOARD_ID_WIFI_POWER_ACTIVE_LOW) + if (variant_has_active_low_wifi_power()) wifi_power_reset_configure_active_low_power(); else wifi_power_reset_configure_active_high_power(); @@ -286,11 +283,8 @@ static void wifi_power_reset_configure_pre_v3(void) __weak void variant_pcie_power_reset_configure(void) { - uint32_t board_version; - - if (!google_chromeec_cbi_get_board_version(&board_version) && - (board_version >= CONFIG_VARIANT_MIN_BOARD_ID_V3_SCHEMATICS)) - wifi_power_reset_configure_v3(board_version); + if (variant_uses_v3_schematics()) + wifi_power_reset_configure_v3(); else wifi_power_reset_configure_pre_v3(); } diff --git a/src/mainboard/google/zork/variants/baseboard/helpers.c b/src/mainboard/google/zork/variants/baseboard/helpers.c index 06cc9ad4ff..0a1cf5ccd1 100644 --- a/src/mainboard/google/zork/variants/baseboard/helpers.c +++ b/src/mainboard/google/zork/variants/baseboard/helpers.c @@ -113,3 +113,35 @@ int variant_has_nvme(void) { return !!extract_field(FW_CONFIG_MASK_NVME, FW_CONFIG_SHIFT_NVME); } + +bool variant_uses_v3_schematics(void) +{ + uint32_t board_version; + + if (!CONFIG(VARIANT_SUPPORTS_PRE_V3_SCHEMATICS)) + return true; + + if (google_chromeec_cbi_get_board_version(&board_version)) + return false; + + if ((int)board_version < CONFIG_VARIANT_MIN_BOARD_ID_V3_SCHEMATICS) + return false; + + return true; +} + +bool variant_has_active_low_wifi_power(void) +{ + uint32_t board_version; + + if (!CONFIG(VARIANT_SUPPORTS_WIFI_POWER_ACTIVE_HIGH)) + return true; + + if (google_chromeec_cbi_get_board_version(&board_version)) + return false; + + if ((int)board_version < CONFIG_VARIANT_MIN_BOARD_ID_WIFI_POWER_ACTIVE_LOW) + return false; + + return true; +} diff --git a/src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h b/src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h index ac29b92e0d..14123d57c3 100644 --- a/src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h +++ b/src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h @@ -63,4 +63,9 @@ int variant_has_nvme(void); /* Determine if booting in factory by using CROS_SKU_UNPROVISIONED. */ int boot_is_factory_unprovisioned(void); +/* Return true if variant uses v3 version of reference schematics. */ +bool variant_uses_v3_schematics(void); +/* Return true if variant has active low power enable fow WiFi. */ +bool variant_has_active_low_wifi_power(void); + #endif /* __BASEBOARD_VARIANTS_H__ */ diff --git a/src/mainboard/google/zork/variants/baseboard/ramstage_common.c b/src/mainboard/google/zork/variants/baseboard/ramstage_common.c index 6372af6a88..143c1b4420 100644 --- a/src/mainboard/google/zork/variants/baseboard/ramstage_common.c +++ b/src/mainboard/google/zork/variants/baseboard/ramstage_common.c @@ -8,11 +8,9 @@ void variant_audio_update(void) { struct soc_amd_picasso_config *cfg = config_of_soc(); - uint32_t board_version; struct acpi_gpio *gpio = &cfg->dmic_select_gpio; - if (!google_chromeec_cbi_get_board_version(&board_version) && - (board_version >= CONFIG_VARIANT_MIN_BOARD_ID_V3_SCHEMATICS)) + if (!variant_uses_v3_schematics()) return; if (CONFIG(BOARD_GOOGLE_BASEBOARD_TREMBYLE)) |