Debian Codegraph @

src/mainboard/prodrive/atlas/mainboard.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
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>
10
11 #include "gpio.h"
12 #include "vpd.h"
13
14 void smbios_fill_dimm_locator(const struct dimm_info *dimm, struct smbios_type17 *t)
15 {
16 const u8 mc = dimm->ctrlr_num;
17 const u8 ch = dimm->channel_num;
18 const u8 mm = dimm->dimm_num;
19
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);
23
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);
27 }
28
29 void smbios_fill_dimm_asset_tag(const struct dimm_info *dimm, struct smbios_type17 *t)
30 {
31 const u8 mc = dimm->ctrlr_num;
32 const u8 ch = dimm->channel_num;
33 const u8 mm = dimm->dimm_num;
34
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);
38 }
39
40 static uint8_t get_hsid(void)
41 {
42 const gpio_t hsid_gpios[] = {
43 GPP_A8,
44 GPP_F19,
45 GPP_H23,
46 GPP_H19,
47 };
48 return gpio_base2_value(hsid_gpios, ARRAY_SIZE(hsid_gpios));
49 }
50
51 static void mainboard_init(void *chip_info)
52 {
53 configure_gpio_pads();
54 printk(BIOS_INFO, "HSID: 0x%x\n", get_hsid());
55 }
56
57 static const char *get_formatted_pn(void)
58 {
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;
63 }
64
65 static void mainboard_smbios_strings(struct device *dev, struct smbios_type11 *t)
66 {
67 t->count = smbios_add_string(t->eos, get_formatted_pn());
68 }
69
70 static void mainboard_fill_ssdt(const struct device *dev)
71 {
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);
77 }
78
79 static void mainboard_enable(struct device *dev)
80 {
81 dev->ops->get_smbios_strings = mainboard_smbios_strings;
82 dev->ops->acpi_fill_ssdt = mainboard_fill_ssdt;
83 }
84
85 struct chip_operations mainboard_ops = {
86 .init = mainboard_init,
87 .enable_dev = mainboard_enable,
88 };