summaryrefslogtreecommitdiff
path: root/src/mainboard/google/zork/variants/baseboard
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2020-07-07 12:50:55 -0700
committerFurquan Shaikh <furquan@google.com>2020-07-08 23:07:34 +0000
commit30ee0d881b5c5568fb8e1cf0ad2144b9e84d6a06 (patch)
tree807618e9cde48f1ec6a080dab85590ff9281e6cd /src/mainboard/google/zork/variants/baseboard
parentca36acf773b1941c6df25329846765d0225fbd37 (diff)
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>
Diffstat (limited to 'src/mainboard/google/zork/variants/baseboard')
-rw-r--r--src/mainboard/google/zork/variants/baseboard/Makefile.inc3
-rw-r--r--src/mainboard/google/zork/variants/baseboard/gpio_baseboard_dalboz.c16
-rw-r--r--src/mainboard/google/zork/variants/baseboard/gpio_baseboard_trembyle.c16
-rw-r--r--src/mainboard/google/zork/variants/baseboard/helpers.c32
-rw-r--r--src/mainboard/google/zork/variants/baseboard/include/baseboard/variants.h5
-rw-r--r--src/mainboard/google/zork/variants/baseboard/ramstage_common.c4
6 files changed, 51 insertions, 25 deletions
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))