Skip to content

Commit c866c85

Browse files
committed
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, saving power and resources. Change-Id: Ic555f93763736adb5837534b8011aa9c123fea08 Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
1 parent fd2f3e8 commit c866c85

5 files changed

Lines changed: 128 additions & 0 deletions

File tree

src/mainboard/google/brya/cfr.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@
77
#include <intelblocks/cfr.h>
88
#include <soc/cfr.h>
99

10+
#if CONFIG(BOARD_GOOGLE_TANIKS) || CONFIG(BOARD_GOOGLE_TAEKO)
11+
12+
enum storage_device {
13+
STORAGE_NVME = 0,
14+
STORAGE_EMMC = 1,
15+
};
16+
17+
static const struct sm_object storage_device_opt = SM_DECLARE_ENUM({
18+
.opt_name = "storage_device",
19+
.ui_name = "Storage Device",
20+
.ui_helptext = "Select which storage device to use (NVMe SSD or eMMC)",
21+
.default_value = STORAGE_NVME,
22+
.values = (const struct sm_enum_value[]) {
23+
{ "NVMe SSD", STORAGE_NVME },
24+
{ "eMMC", STORAGE_EMMC },
25+
SM_ENUM_VALUE_END },
26+
});
27+
static struct sm_obj_form devices = {
28+
.ui_name = "Devices",
29+
.obj_list = (const struct sm_object *[]) {
30+
&storage_device_opt,
31+
NULL
32+
},
33+
};
34+
#endif
35+
1036
static struct sm_obj_form system = {
1137
.ui_name = "System",
1238
.obj_list = (const struct sm_object *[]) {
@@ -40,6 +66,9 @@ static struct sm_obj_form ec = {
4066

4167
static struct sm_obj_form *sm_root[] = {
4268
&system,
69+
#if CONFIG(BOARD_GOOGLE_TANIKS) || CONFIG(BOARD_GOOGLE_TAEKO)
70+
&devices,
71+
#endif
4372
&ec,
4473
NULL
4574
};

src/mainboard/google/brya/variants/taeko/Makefile.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ romstage-y += memory.c
88

99
ramstage-y += gpio.c
1010

11+
romstage-$(CONFIG_FW_CONFIG) += fw_config.c
1112
ramstage-$(CONFIG_FW_CONFIG) += fw_config.c
1213

1314
ramstage-$(CONFIG_FW_CONFIG) += variant.c

src/mainboard/google/brya/variants/taeko/fw_config.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,55 @@
44
#include <console/console.h>
55
#include <fw_config.h>
66
#include <gpio.h>
7+
#include <option.h>
8+
#include <string.h>
9+
#include <types.h>
10+
11+
enum storage_device {
12+
STORAGE_NVME = 0,
13+
STORAGE_EMMC = 1,
14+
};
15+
16+
/* Override fw_config_probe_mainboard_override to check CFR for storage selection */
17+
bool fw_config_probe_mainboard_override(const struct fw_config *match, bool *handled)
18+
{
19+
/* Check if this is a storage-related probe */
20+
if (match->field_name) {
21+
if (strcmp(match->field_name, "BOOT_NVME_MASK") == 0) {
22+
/* Read CFR option directly - default to NVMe if not available */
23+
uint8_t storage_selection = get_uint_option("storage_device", STORAGE_NVME);
24+
/* NVMe is enabled if storage selection is NVMe */
25+
*handled = true;
26+
if (storage_selection == STORAGE_NVME) {
27+
printk(BIOS_INFO, "fw_config: NVMe enabled by CFR (selection=%d)\n",
28+
storage_selection);
29+
return true;
30+
}
31+
printk(BIOS_INFO, "fw_config: NVMe disabled by CFR (selection=%d)\n",
32+
storage_selection);
33+
return false;
34+
}
35+
if (strcmp(match->field_name, "BOOT_EMMC_MASK") == 0) {
36+
/* Read CFR option directly - default to NVMe if not available */
37+
uint8_t storage_selection = get_uint_option("storage_device", STORAGE_NVME);
38+
/* eMMC is enabled if storage selection is eMMC */
39+
*handled = true;
40+
if (storage_selection == STORAGE_EMMC) {
41+
printk(BIOS_INFO, "fw_config: eMMC enabled by CFR (selection=%d)\n",
42+
storage_selection);
43+
return true;
44+
}
45+
printk(BIOS_INFO, "fw_config: eMMC disabled by CFR (selection=%d)\n",
46+
storage_selection);
47+
return false;
48+
}
49+
}
50+
51+
/* Not handled - use standard fw_config logic */
52+
*handled = false;
53+
return false;
54+
}
55+
756

857
static const struct pad_config dmic_enable_pads[] = {
958
PAD_CFG_NF(GPP_S2, NONE, DEEP, NF2), /* DMIC_CLK0_R */

src/mainboard/google/brya/variants/taniks/Makefile.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ romstage-y += gpio.c
66
romstage-y += memory.c
77

88
ramstage-y += gpio.c
9+
romstage-$(CONFIG_FW_CONFIG) += fw_config.c
910
ramstage-$(CONFIG_FW_CONFIG) += fw_config.c
1011

1112
ramstage-$(CONFIG_FW_CONFIG) += variant.c

src/mainboard/google/brya/variants/taniks/fw_config.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,54 @@
44
#include <console/console.h>
55
#include <fw_config.h>
66
#include <gpio.h>
7+
#include <option.h>
8+
#include <string.h>
9+
#include <types.h>
10+
11+
enum storage_device {
12+
STORAGE_NVME = 0,
13+
STORAGE_EMMC = 1,
14+
};
15+
16+
/* Override fw_config_probe_mainboard_override to check CFR for storage selection */
17+
bool fw_config_probe_mainboard_override(const struct fw_config *match, bool *handled)
18+
{
19+
/* Check if this is a storage-related probe */
20+
if (match->field_name) {
21+
if (strcmp(match->field_name, "BOOT_NVME_MASK") == 0) {
22+
/* Read CFR option directly - default to NVMe if not available */
23+
uint8_t storage_selection = get_uint_option("storage_device", STORAGE_NVME);
24+
/* NVMe is enabled if storage selection is NVMe */
25+
*handled = true;
26+
if (storage_selection == STORAGE_NVME) {
27+
printk(BIOS_INFO, "fw_config: NVMe enabled by CFR (selection=%d)\n",
28+
storage_selection);
29+
return true;
30+
}
31+
printk(BIOS_INFO, "fw_config: NVMe disabled by CFR (selection=%d)\n",
32+
storage_selection);
33+
return false;
34+
}
35+
if (strcmp(match->field_name, "BOOT_EMMC_MASK") == 0) {
36+
/* Read CFR option directly - default to NVMe if not available */
37+
uint8_t storage_selection = get_uint_option("storage_device", STORAGE_NVME);
38+
/* eMMC is enabled if storage selection is eMMC */
39+
*handled = true;
40+
if (storage_selection == STORAGE_EMMC) {
41+
printk(BIOS_INFO, "fw_config: eMMC enabled by CFR (selection=%d)\n",
42+
storage_selection);
43+
return true;
44+
}
45+
printk(BIOS_INFO, "fw_config: eMMC disabled by CFR (selection=%d)\n",
46+
storage_selection);
47+
return false;
48+
}
49+
}
50+
51+
/* Not handled - use standard fw_config logic */
52+
*handled = false;
53+
return false;
54+
}
755

856
static const struct pad_config dmic_enable_pads[] = {
957
PAD_CFG_NF(GPP_S2, NONE, DEEP, NF2), /* DMIC_CLK0_R */

0 commit comments

Comments
 (0)