From e0bc32ce6195f8b7c44893ab69d739043e7275a7 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Sun, 14 Dec 2025 18:13:21 -0600 Subject: [PATCH] mb/google/brya: Add CFR-based storage selection for taeko/taniks Add support for selecting NVMe or eMMC storage via CFR option on taeko and taniks variants. Override fw_config_probe() to check the CFR "storage_device" option and enable/disable the appropriate PCIe root port based on user selection. This allows runtime configuration of storage devices while ensuring only the selected device is initialized, since initializing both causes neither to be detected. TEST=build/boot taeko, verify both eMMC and NVMe M.2 storage modules functional when correct type selected from setup menu. Change-Id: Ic555f93763736adb5837534b8011aa9c123fea08 Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/90742 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- src/mainboard/google/brya/cfr.c | 29 ++++++++++++++ .../google/brya/variants/taeko/Makefile.mk | 1 + .../google/brya/variants/taeko/fw_config.c | 38 +++++++++++++++++++ .../google/brya/variants/taniks/Makefile.mk | 1 + .../google/brya/variants/taniks/fw_config.c | 37 ++++++++++++++++++ 5 files changed, 106 insertions(+) diff --git a/src/mainboard/google/brya/cfr.c b/src/mainboard/google/brya/cfr.c index 2128145042..31b3274933 100644 --- a/src/mainboard/google/brya/cfr.c +++ b/src/mainboard/google/brya/cfr.c @@ -6,6 +6,32 @@ #include #include +#if CONFIG(BOARD_GOOGLE_TANIKS) || CONFIG(BOARD_GOOGLE_TAEKO) + +enum storage_device { + STORAGE_NVME = 0, + STORAGE_EMMC = 1, +}; + +static const struct sm_object storage_device_opt = SM_DECLARE_ENUM({ + .opt_name = "storage_device", + .ui_name = "Storage Device", + .ui_helptext = "Select which storage device to use (NVMe SSD or eMMC)", + .default_value = STORAGE_NVME, + .values = (const struct sm_enum_value[]) { + { "NVMe SSD", STORAGE_NVME }, + { "eMMC", STORAGE_EMMC }, + SM_ENUM_VALUE_END }, +}); +static struct sm_obj_form devices = { + .ui_name = "Devices", + .obj_list = (const struct sm_object *[]) { + &storage_device_opt, + NULL + }, +}; +#endif + static struct sm_obj_form system = { .ui_name = "System", .obj_list = (const struct sm_object *[]) { @@ -37,6 +63,9 @@ static struct sm_obj_form ec = { static struct sm_obj_form *sm_root[] = { &system, +#if CONFIG(BOARD_GOOGLE_TANIKS) || CONFIG(BOARD_GOOGLE_TAEKO) + &devices, +#endif &ec, NULL }; diff --git a/src/mainboard/google/brya/variants/taeko/Makefile.mk b/src/mainboard/google/brya/variants/taeko/Makefile.mk index 47f0432aeb..f269b09163 100644 --- a/src/mainboard/google/brya/variants/taeko/Makefile.mk +++ b/src/mainboard/google/brya/variants/taeko/Makefile.mk @@ -8,6 +8,7 @@ romstage-y += memory.c ramstage-y += gpio.c +romstage-$(CONFIG_FW_CONFIG) += fw_config.c ramstage-$(CONFIG_FW_CONFIG) += fw_config.c ramstage-$(CONFIG_FW_CONFIG) += variant.c diff --git a/src/mainboard/google/brya/variants/taeko/fw_config.c b/src/mainboard/google/brya/variants/taeko/fw_config.c index 5068f84581..fbf214db54 100644 --- a/src/mainboard/google/brya/variants/taeko/fw_config.c +++ b/src/mainboard/google/brya/variants/taeko/fw_config.c @@ -4,6 +4,44 @@ #include #include #include +#include +#include +#include + +enum storage_device { + STORAGE_NVME = 0, + STORAGE_EMMC = 1, +}; + +/* Override fw_config_probe_mainboard_override to check CFR for storage selection */ +bool fw_config_probe_mainboard_override(const struct fw_config *match, bool *result) +{ + /* Check if this is a storage-related probe */ + if (match->field_name) { + /* Read CFR option directly - default to NVMe if not available */ + uint8_t storage_selection = get_uint_option("storage_device", STORAGE_NVME); + if (strcmp(match->field_name, "BOOT_NVME_MASK") == 0) { + /* NVMe is enabled if storage selection is NVMe */ + *result = (storage_selection == STORAGE_NVME); + if (*result) { + printk(BIOS_INFO, "fw_config: NVMe enabled by CFR\n"); + } + return true; + } + if (strcmp(match->field_name, "BOOT_EMMC_MASK") == 0) { + /* eMMC is enabled if storage selection is eMMC */ + *result = (storage_selection == STORAGE_EMMC); + if (*result) { + printk(BIOS_INFO, "fw_config: eMMC enabled by CFR\n"); + } + return true; + } + } + + /* Not handled - use standard fw_config logic */ + return false; +} + static const struct pad_config dmic_enable_pads[] = { PAD_CFG_NF(GPP_S2, NONE, DEEP, NF2), /* DMIC_CLK0_R */ diff --git a/src/mainboard/google/brya/variants/taniks/Makefile.mk b/src/mainboard/google/brya/variants/taniks/Makefile.mk index 61a70ec0ef..a70ba96714 100644 --- a/src/mainboard/google/brya/variants/taniks/Makefile.mk +++ b/src/mainboard/google/brya/variants/taniks/Makefile.mk @@ -6,6 +6,7 @@ romstage-y += gpio.c romstage-y += memory.c ramstage-y += gpio.c +romstage-$(CONFIG_FW_CONFIG) += fw_config.c ramstage-$(CONFIG_FW_CONFIG) += fw_config.c ramstage-$(CONFIG_FW_CONFIG) += variant.c diff --git a/src/mainboard/google/brya/variants/taniks/fw_config.c b/src/mainboard/google/brya/variants/taniks/fw_config.c index f79110391c..b29ea56d98 100644 --- a/src/mainboard/google/brya/variants/taniks/fw_config.c +++ b/src/mainboard/google/brya/variants/taniks/fw_config.c @@ -4,6 +4,43 @@ #include #include #include +#include +#include +#include + +enum storage_device { + STORAGE_NVME = 0, + STORAGE_EMMC = 1, +}; + +/* Override fw_config_probe_mainboard_override to check CFR for storage selection */ +bool fw_config_probe_mainboard_override(const struct fw_config *match, bool *result) +{ + /* Check if this is a storage-related probe */ + if (match->field_name) { + /* Read CFR option directly - default to NVMe if not available */ + uint8_t storage_selection = get_uint_option("storage_device", STORAGE_NVME); + if (strcmp(match->field_name, "BOOT_NVME_MASK") == 0) { + /* NVMe is enabled if storage selection is NVMe */ + *result = (storage_selection == STORAGE_NVME); + if (*result) { + printk(BIOS_INFO, "fw_config: NVMe enabled by CFR\n"); + } + return true; + } + if (strcmp(match->field_name, "BOOT_EMMC_MASK") == 0) { + /* eMMC is enabled if storage selection is eMMC */ + *result = (storage_selection == STORAGE_EMMC); + if (*result) { + printk(BIOS_INFO, "fw_config: eMMC enabled by CFR\n"); + } + return true; + } + } + + /* Not handled - use standard fw_config logic */ + return false; +} static const struct pad_config dmic_enable_pads[] = { PAD_CFG_NF(GPP_S2, NONE, DEEP, NF2), /* DMIC_CLK0_R */