3rdparty/fsp: Update submodule to upstream master
[coreboot2.git] / src / mainboard / prodrive / atlas / mainboard.c
blob84888366559c36e54b124eab447ab6adde037e0a
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpigen.h>
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <gpio.h>
7 #include <smbios.h>
8 #include <stdio.h>
9 #include <types.h>
11 #include "gpio.h"
12 #include "vpd.h"
14 void smbios_fill_dimm_locator(const struct dimm_info *dimm, struct smbios_type17 *t)
16 const u8 mc = dimm->ctrlr_num;
17 const u8 ch = dimm->channel_num;
18 const u8 mm = dimm->dimm_num;
20 char dev_loc[40] = { "\x00" };
21 snprintf(dev_loc, sizeof(dev_loc), "SO-DIMM %c%u", 'A' + mc, mm);
22 t->device_locator = smbios_add_string(t->eos, dev_loc);
24 char bnk_loc[40] = { "\x00" };
25 snprintf(bnk_loc, sizeof(bnk_loc), "BANK-%u-%u-%u", mc, ch, mm);
26 t->bank_locator = smbios_add_string(t->eos, bnk_loc);
29 void smbios_fill_dimm_asset_tag(const struct dimm_info *dimm, struct smbios_type17 *t)
31 const u8 mc = dimm->ctrlr_num;
32 const u8 ch = dimm->channel_num;
33 const u8 mm = dimm->dimm_num;
35 char tag[40] = { "\x00" };
36 snprintf(tag, sizeof(tag), "MC-%u-CH-%u-DIMM-%u", mc, ch, mm);
37 t->asset_tag = smbios_add_string(t->eos, tag);
40 static uint8_t get_hsid(void)
42 const gpio_t hsid_gpios[] = {
43 GPP_A8,
44 GPP_F19,
45 GPP_H23,
46 GPP_H19,
48 return gpio_base2_value(hsid_gpios, ARRAY_SIZE(hsid_gpios));
51 static void mainboard_init(void *chip_info)
53 configure_gpio_pads();
54 printk(BIOS_INFO, "HSID: 0x%x\n", get_hsid());
57 static const char *get_formatted_pn(void)
59 static char buffer[32 + ATLAS_SN_PN_LENGTH] = {0};
60 const char *prefix = "P/N: ";
61 snprintf(buffer, sizeof(buffer), "%s%s", prefix, get_emi_eeprom_vpd()->part_number);
62 return buffer;
65 static void mainboard_smbios_strings(struct device *dev, struct smbios_type11 *t)
67 t->count = smbios_add_string(t->eos, get_formatted_pn());
70 static void mainboard_fill_ssdt(const struct device *dev)
72 const struct emi_eeprom_vpd *eeprom = get_emi_eeprom_vpd();
73 const bool sleep_enable = eeprom->profile != ATLAS_PROF_REALTIME_PERFORMANCE ? 1 : 0;
74 acpigen_ssdt_override_sleep_states(false, false,
75 CONFIG(HAVE_ACPI_RESUME) && sleep_enable,
76 sleep_enable);
79 static void mainboard_enable(struct device *dev)
81 dev->ops->get_smbios_strings = mainboard_smbios_strings;
82 dev->ops->acpi_fill_ssdt = mainboard_fill_ssdt;
85 struct chip_operations mainboard_ops = {
86 .init = mainboard_init,
87 .enable_dev = mainboard_enable,