cpu/x86/smm/pci_resource_store: Store DEV/VEN ID
[coreboot2.git] / src / mainboard / google / reef / mainboard.c
blobff3bb36e09c262b5950369d4dda7c2a14e138df2
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpi.h>
4 #include <baseboard/variants.h>
5 #include <boardid.h>
6 #include <console/console.h>
7 #include <device/device.h>
8 #include <ec/ec.h>
9 #include <gpio.h>
10 #include <nhlt.h>
11 #include <smbios.h>
12 #include <soc/nhlt.h>
13 #include <string.h>
14 #include <variant/ec.h>
15 #include <variant/gpio.h>
17 /* override specific gpio by sku id */
18 const struct pad_config __weak
19 *variant_sku_gpio_table(size_t *num)
21 *num = 0;
22 return NULL;
25 static void mainboard_init(void *chip_info)
27 int boardid;
28 const struct pad_config *pads;
29 size_t num;
31 boardid = board_id();
32 printk(BIOS_INFO, "Board ID: %d\n", boardid);
34 pads = variant_gpio_table(&num);
35 gpio_configure_pads(pads, num);
37 pads = variant_sku_gpio_table(&num);
38 gpio_configure_pads(pads, num);
40 mainboard_ec_init();
42 variant_board_ec_set_skuid();
46 * There are 2 pins on reef-like boards that can be used for SKU'ing
47 * board differences. They each have optional stuffing for a pullup and
48 * a pulldown. This way we can generate 9 different values with the
49 * 2 pins.
51 uint8_t sku_strapping_value(void)
53 gpio_t board_sku_gpios[] = {
54 [1] = GPIO_17, [0] = GPIO_16,
56 const size_t num = ARRAY_SIZE(board_sku_gpios);
58 return gpio_base3_value(board_sku_gpios, num);
61 uint8_t __weak variant_board_sku(void)
63 static int board_sku_num = -1;
65 if (board_sku_num < 0)
66 board_sku_num = sku_strapping_value();
68 return board_sku_num;
71 /* Set variant board sku to ec by sku id */
72 void __weak variant_board_ec_set_skuid(void)
76 const char *smbios_system_sku(void)
78 static char sku_str[7]; /* sku{0..255} */
80 snprintf(sku_str, sizeof(sku_str), "sku%d", variant_board_sku());
82 return sku_str;
85 void __weak variant_nhlt_oem_overrides(const char **oem_id,
86 const char **oem_table_id,
87 uint32_t *oem_revision)
89 *oem_id = "reef";
90 *oem_table_id = CONFIG_VARIANT_DIR;
91 *oem_revision = variant_board_sku();
94 static unsigned long mainboard_write_acpi_tables(
95 const struct device *device, unsigned long current, acpi_rsdp_t *rsdp)
97 uintptr_t start_addr;
98 uintptr_t end_addr;
99 struct nhlt *nhlt;
100 const char *oem_id = NULL;
101 const char *oem_table_id = NULL;
102 uint32_t oem_revision = 0;
104 start_addr = current;
106 nhlt = nhlt_init();
108 if (nhlt == NULL)
109 return start_addr;
111 variant_nhlt_init(nhlt);
112 variant_nhlt_oem_overrides(&oem_id, &oem_table_id, &oem_revision);
114 end_addr = nhlt_soc_serialize_oem_overrides(nhlt, start_addr,
115 oem_id, oem_table_id, oem_revision);
117 if (end_addr != start_addr)
118 acpi_add_table(rsdp, (void *)start_addr);
120 return end_addr;
123 static void mainboard_enable(struct device *dev)
125 dev->ops->write_acpi_tables = mainboard_write_acpi_tables;
128 struct chip_operations mainboard_ops = {
129 .init = mainboard_init,
130 .enable_dev = mainboard_enable,