blob: 84888366559c36e54b124eab447ab6adde037e0a [file] [log] [blame]
Lean Sheng Tan5352d222022-01-07 13:48:13 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
Arthur Heymansb1c19962023-04-13 16:04:48 +02003#include <acpi/acpigen.h>
Maximilian Brune97a86732022-10-07 18:29:29 +02004#include <console/console.h>
Angel Pons56c1c4d2023-03-22 13:25:09 +01005#include <device/device.h>
Maximilian Brune97a86732022-10-07 18:29:29 +02006#include <gpio.h>
David Milosevic0f5b87c2022-10-20 16:47:48 +02007#include <smbios.h>
Elyes Haouasbdd03c22024-05-27 11:20:07 +02008#include <stdio.h>
Angel Pons56c1c4d2023-03-22 13:25:09 +01009#include <types.h>
Lean Sheng Tan5352d222022-01-07 13:48:13 +010010
11#include "gpio.h"
Angel Pons56c1c4d2023-03-22 13:25:09 +010012#include "vpd.h"
Lean Sheng Tan5352d222022-01-07 13:48:13 +010013
David Milosevic0f5b87c2022-10-20 16:47:48 +020014void 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
29void 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
Maximilian Brune97a86732022-10-07 18:29:29 +020040static 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
Lean Sheng Tan5352d222022-01-07 13:48:13 +010051static void mainboard_init(void *chip_info)
52{
53 configure_gpio_pads();
Maximilian Brune97a86732022-10-07 18:29:29 +020054 printk(BIOS_INFO, "HSID: 0x%x\n", get_hsid());
Lean Sheng Tan5352d222022-01-07 13:48:13 +010055}
56
Angel Pons56c1c4d2023-03-22 13:25:09 +010057static 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
65static 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
Arthur Heymansb1c19962023-04-13 16:04:48 +020070static 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
Angel Pons56c1c4d2023-03-22 13:25:09 +010079static void mainboard_enable(struct device *dev)
80{
81 dev->ops->get_smbios_strings = mainboard_smbios_strings;
Arthur Heymansb1c19962023-04-13 16:04:48 +020082 dev->ops->acpi_fill_ssdt = mainboard_fill_ssdt;
Angel Pons56c1c4d2023-03-22 13:25:09 +010083}
84
Lean Sheng Tan5352d222022-01-07 13:48:13 +010085struct chip_operations mainboard_ops = {
Angel Pons56c1c4d2023-03-22 13:25:09 +010086 .init = mainboard_init,
87 .enable_dev = mainboard_enable,
Lean Sheng Tan5352d222022-01-07 13:48:13 +010088};