1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <baseboard/variants.h>
6 #include <console/console.h>
7 #include <device/device.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
)
25 static void mainboard_init(void *chip_info
)
28 const struct pad_config
*pads
;
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
);
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
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();
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());
85 void __weak
variant_nhlt_oem_overrides(const char **oem_id
,
86 const char **oem_table_id
,
87 uint32_t *oem_revision
)
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
)
100 const char *oem_id
= NULL
;
101 const char *oem_table_id
= NULL
;
102 uint32_t oem_revision
= 0;
104 start_addr
= current
;
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
);
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
,